Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .claude/agents/proto-change-tracer.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ When proto definitions change, trace the impact through the full dependency chai
## Architecture: Proto → Feature Chain

```
definitions/<service>/protos/src/main/proto/.proto files
[protobuf codegen]
com.flipcash:{ocp,flipcash2}-client-protocolpublished artifact, pinned in libs.versions.toml
[generated in its own repo — nothing runs protoc here]
com.codeinc.<service>.gen.<domain>.v1 ← Generated stubs (GrpcKt, request/response classes)
Expand All @@ -29,15 +29,20 @@ services/<service>/ — *Controller.kt ← User-facing abstraction (r
apps/flipcash/shared/*/ or features/*/ ← ViewModels consume controllers
```

**Proto packages:**
- Flipcash: `com.codeinc.flipcash.gen.<domain>.v1` (phone, account, email, profile, push, activity, event, settings, iap, moderation, thirdparty)
- OpenCode: `com.codeinc.opencode.gen.<domain>.v1` (transaction, account, currency, messaging)
**Proto packages** (the artifact coordinate is `com.flipcash`; the packages inside are not):
- Flipcash, from `flipcash2-client-protocol`: `com.codeinc.flipcash.gen.<domain>.v1` (phone, account, email, profile, push, activity, event, settings, iap, moderation, thirdparty)
- OpenCode, from `ocp-client-protocol`: `com.codeinc.opencode.gen.<domain>.v1` (transaction, account, currency, messaging)

To read a generated stub, look in the resolved artifact under `~/.gradle/caches/modules-2/`
or in the client repo's build output — there is no generated source tree in this project.

## Analysis Process

### 1. Identify what changed in the proto definitions

Compare the current proto files with the previous version (use git diff on `definitions/`). Identify:
The `.proto` sources are not in this repo. Diff the contract between the old and new
artifact versions with `gh api repos/code-payments/<ocp|flipcash2>-client-protocol/compare/<old>...<new>`,
or read `proto/` in a local clone at each tag. Identify:
- New services or RPCs
- Changed request/response message fields
- New or modified enum values
Expand Down
99 changes: 56 additions & 43 deletions .claude/skills/fetch-protos/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: fetch-protos
description: >
Fetch latest protobuf definitions, verify build, summarize API changes,
and scaffold new service stubs. Usage: /fetch-protos [flipcash|opencode] [commit_sha]
Bump a client-protocol artifact, summarize the contract changes it carries,
and scaffold new service stubs. Usage: /fetch-protos [flipcash|opencode] [version]
user-invocable: true
argument-hint: "[flipcash|opencode] [commit_sha]"
argument-hint: "[flipcash|opencode] [version]"
allowed-tools:
- Bash
- Read
Expand All @@ -17,79 +17,92 @@ allowed-tools:

# Fetch Protos

Fetch protobuf definitions from upstream repos, verify they compile, summarize
API changes, and scaffold missing service layer implementations.
The protos are no longer vendored here. Both contracts arrive as published
artifacts, so "fetching" is bumping a version pin and reacting to what the new
version changed.

| Target | Artifact | Client repo | Upstream contract |
|--------|----------|-------------|-------------------|
| `flipcash` | `com.flipcash:flipcash2-client-protocol` | `code-payments/flipcash2-client-protocol` | `code-payments/flipcash2-protobuf-api` |
| `opencode` | `com.flipcash:ocp-client-protocol` | `code-payments/ocp-client-protocol` | `code-payments/ocp-protobuf-api` |

## Pre-flight context

- Current proto files: !`find definitions/*/protos/src/main/proto -name "*.proto" 2>/dev/null | wc -l | tr -d ' '` proto files across targets
- Git status: !`git status --short definitions/`
- Pinned versions: !`grep -E "^(ocp|flipcash2)-client-protocol = " gradle/libs.versions.toml`
- Git status: !`git status --short gradle/libs.versions.toml services/`

## Input

Parse `$ARGUMENTS` to determine targets and optional commit SHA.
Parse `$ARGUMENTS` to determine targets and an optional version.

**Rules:**
- Known targets: `flipcash`, `opencode`
- If no targets specified, fetch **both** (`flipcash` and `opencode`)
- A hex string (7+ chars) as the last argument is treated as a commit SHA
- If no targets specified, check **both**
- A semver-looking string as the last argument is the version to move to; without
one, use the latest release
- Examples:
- `/fetch-protos` → fetch flipcash + opencode at HEAD
- `/fetch-protos flipcash` → fetch flipcash only
- `/fetch-protos opencode abc1234` → fetch opencode at commit abc1234
- `/fetch-protos flipcash opencode` → fetch both explicitly
- `/fetch-protos` → check both artifacts for newer releases
- `/fetch-protos flipcash` → flipcash only, latest release
- `/fetch-protos opencode 0.2.0` → opencode at 0.2.0

## Steps

### Step 1 — Fetch protos

For each target, run the fetch script from the repo root:
### Step 1 — Find the release

```bash
bash scripts/fetch-protos.sh -t <target> [commit_sha]
gh release list --repo code-payments/<ocp|flipcash2>-client-protocol --limit 10
```

Target-to-repo mapping (handled by the script):
| Target | Repository |
|--------|-----------|
| `flipcash` | `git@github.com:code-payments/flipcash2-protobuf-api.git` |
| `opencode` | `git@github.com:code-payments/ocp-protobuf-api.git` |
Compare against the pin in `gradle/libs.versions.toml`. If the pinned version is
already the latest and no version was requested, say so and stop.

If the contract change you want has **not been released**, it has to land in the
client repo first: sync its protos at the upstream SHA, regenerate, and publish.
That repo's README covers it — this skill does not do it.

Show the script output to the user.
### Step 2 — Bump the pin

Edit `gradle/libs.versions.toml`:

```toml
ocp-client-protocol = "<new>" # or flipcash2-client-protocol
```

### Step 2 — Diff and summarize changes
### Step 3 — Diff and summarize the contract change

Run `git diff` on the proto directories to identify what changed:
The `.proto` sources are not in this repo. Diff them between the two release tags:

```bash
git diff --stat definitions/
git diff definitions/
gh api repos/code-payments/<repo>/compare/<old-version>...<new-version> \
--jq '.files[] | select(.filename | startswith("proto/")) | .filename'
```

For each changed `.proto` file, summarize:
Read the patch for each changed file. Summarize:
- **New RPCs** added to services
- **Modified RPCs** (changed request/response types or fields)
- **Removed RPCs**
- **New/modified messages** and fields

Present a structured change summary table to the user. If nothing changed, report
that protos are already up to date and stop here.
Present a structured change summary table. If the diff carries no `proto/` change,
the release is generator or packaging work only — say so, and expect no service
layer impact.

### Step 3 — Build verification
### Step 4 — Build verification

Build the definitions modules to verify the protos compile:
Build the service module that consumes the artifact:

```bash
./gradlew :definitions:flipcash:models:assembleDebug :definitions:opencode:models:assembleDebug
./gradlew :services:<flipcash|opencode>:assembleDebug
```

Only build the targets that were fetched. If the build fails, show errors and stop.
Only build the targets that were bumped. If the build fails, show errors and stop —
a removed or renamed field breaks compilation here, which is the point.

### Step 4 — Detect service layer impact
### Step 5 — Detect service layer impact

#### 4a — RPC changes
#### 5a — RPC changes

For each new or modified RPC found in Step 2:
For each new or modified RPC found in Step 3:

1. Identify which service proto file it belongs to (e.g., `account/v1/flipcash_account_service.proto`)
2. Search for the corresponding Api class in `services/<target>/src/**/network/api/`
Expand All @@ -103,7 +116,7 @@ Present a report:
| `NewRpc` | missing | missing | missing | missing | **New — needs scaffolding** |
| `ModifiedRpc` | exists | exists | exists | exists | **Signature may need update** |

#### 4b — Message field changes (domain models)
#### 5b — Message field changes (domain models)

For each message with added or removed fields (e.g., `UserFlags`, `UserProfile`):

Expand Down Expand Up @@ -156,7 +169,7 @@ For **read-only** fields (e.g., booleans like `enablePhoneNumberSend`):

Present a report of domain model updates needed and apply them after user confirmation.

### Step 5 — Scaffold new service stubs
### Step 6 — Scaffold new service stubs

For RPCs marked as needing scaffolding, ask the user if they want to scaffold them.
If confirmed, generate code following the patterns below.
Expand Down Expand Up @@ -269,13 +282,13 @@ suspend fun newRpc(...): Result<DomainType> {
If a new Repository interface+impl pair was created, add a `@Provides` binding in
the corresponding Hilt module (`FlipcashModule.kt` or `OpenCodeModule.kt`).

### Step 6 — Review and commit
### Step 7 — Review and commit

Show the user a summary of all changes (proto updates + any scaffolded code).

Offer to commit with a conventional commit message:
```
chore(protos): update <target> protobuf definitions
chore(protos): bump <flipcash2|ocp>-client-protocol to <version>
```

If service stubs were also scaffolded, suggest a separate commit:
Expand All @@ -285,7 +298,7 @@ feat(<target>): scaffold service stubs for new RPCs

## Never

- Edit generated protobuf code in `definitions/*/models/build/`
- Try to edit the generated protobuf code — it lives in the published artifact
- Commit without user approval
- Skip build verification
- Scaffold service code without asking the user first
2 changes: 0 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
- "apps/flipcash/shared/transfers/**"
- "apps/flipcash/shared/bills/**"
- "apps/flipcash/shared/google-play-billing/**"
- "definitions/**/micropayment/**"

"area: crypto":
- changed-files:
Expand Down Expand Up @@ -68,7 +67,6 @@
- "services/flipcash-compose/**"
- "services/opencode/**"
- "services/opencode-compose/**"
- "definitions/**"

"area: onramp":
- changed-files:
Expand Down
6 changes: 1 addition & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ services/
opencode/ — Open Code Protocol gRPC services
*-compose/ — Compose wrappers for services

definitions/
flipcash/ — Protobuf definitions for Flipcash
opencode/ — Protobuf definitions for OCP

libs/ — 20+ internal libraries
crypto/ — Solana, Kin, Ed25519, encryption, key management
network/ — Connectivity, JWT, exchange rates, Coinbase
Expand Down Expand Up @@ -86,7 +82,7 @@ The feature plugin automatically includes `:libs:logging`, `:ui:core`, `:ui:comp

- **CompositionLocal injection**: `MainActivity` provides dozens of controllers/services via `CompositionLocalProvider` — features access dependencies through `Local*` composition locals rather than direct injection
- **Feature modules are self-contained**: Each has its own state, controllers, and UI; communicates via shared modules
- **Protobuf models**: Backend models are generated from `.proto` files in `definitions/`; don't hand-edit generated code
- **Protobuf models**: Backend models come from the published `com.flipcash:{ocp,flipcash2}-client-protocol` artifacts, not from protos in this repo; the contracts are generated in their own repos
- **Dark mode only**: App forces `MODE_NIGHT_YES`

## Namespaces
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ graph TD
Features["apps/flipcash/features/* — 26 self-contained screens"]
Shared["apps/flipcash/shared/* — coordinators / controllers / services"]
Services["services/* — gRPC wrappers (API → Service → Repository → Controller)"]
Defs["definitions/* — protobuf sources + generated models"]
UI["ui/* — Compose components, theme, navigation, scanner"]
Libs["libs/* — crypto, network, logging, currency (leaf utilities)"]

App --> Features --> Shared --> Services --> Defs --> Libs
App --> Features --> Shared --> Services --> Libs
Features --> UI --> Libs
Services --> Libs
```
Expand All @@ -83,7 +82,7 @@ persistence, payments, the design system, testing, and more.
| Navigation | Jetpack **Navigation 3** + a custom `CodeNavigator` |
| DI | **Hilt** + `CompositionLocal` |
| Async | Kotlin **Coroutines + Flow** (MVI via `BaseViewModel<State, Event>`) |
| Networking | **gRPC + Protobuf**; Retrofit/OkHttp for REST |
| Networking | **gRPC + Protobuf** (contracts from the published `com.flipcash:{ocp,flipcash2}-client-protocol` artifacts); Retrofit/OkHttp for REST |
| Persistence | **Room** (per-user database) + DataStore |
| Crypto | **Ed25519**, BIP39 mnemonic/key derivation, **Solana** |
| Build | Gradle convention plugins, KSP, **Java 21** |
Expand All @@ -93,7 +92,6 @@ persistence, payments, the design system, testing, and more.
```
apps/flipcash/ Main app + feature (26) and shared modules
services/ gRPC clients: flipcash, opencode (+ Compose wrappers)
definitions/ Protobuf sources and generated models
libs/ Reusable utilities (crypto, network, logging, currency, …)
ui/ Compose design system, navigation, scanner, biometrics
vendor/ Third-party SDKs (Kik scanner, OpenCV, TipKit)
Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ plugins {
alias(libs.plugins.bugsnag.gradle) apply false
alias(libs.plugins.secrets) apply false
alias(libs.plugins.navigation.safeargs) apply false
alias(libs.plugins.protobuf) apply false
alias(libs.plugins.androidx.room) apply false
alias(libs.plugins.screenshot) apply false
alias(libs.plugins.kover)
Expand Down
2 changes: 0 additions & 2 deletions definitions/flipcash/models/.gitignore

This file was deleted.

74 changes: 0 additions & 74 deletions definitions/flipcash/models/build.gradle.kts

This file was deleted.

2 changes: 0 additions & 2 deletions definitions/flipcash/protos/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions definitions/flipcash/protos/build.gradle.kts

This file was deleted.

Loading
Loading