Skip to content

feat: add backend CLI commands (authenticate, underwrite, tap-credit)#10

Merged
bengobeil merged 4 commits intomainfrom
gerald/dev-2462-backend-commands
Mar 18, 2026
Merged

feat: add backend CLI commands (authenticate, underwrite, tap-credit)#10
bengobeil merged 4 commits intomainfrom
gerald/dev-2462-backend-commands

Conversation

@GeraldBennyClawBot
Copy link
Copy Markdown
Contributor

Adds three new factoring subcommands (authenticate, underwrite, tap-credit) that call the Bulla backend API. Follows existing CLI architecture with Command.make(), Effect.gen(), and Layer-based DI. Includes 12 mock-based unit tests. All 190 tests pass. Closes DEV-2462

…credit

Implements three new factoring subcommands that interact with the Bulla backend API:
- `factoring authenticate` — derives wallet from private key, signs SIWE challenge, returns JWT
- `factoring underwrite` — submits claim IDs for underwriting via backend API
- `factoring tap-credit` — batch tap-credit requests from a JSON file

New files:
- Domain types for backend request/response shapes
- BackendClientService port with Context.Tag-based DI
- HTTP implementation using native fetch
- CLI command definitions following existing patterns
- 12 mock-based unit tests covering JWT extraction, service calls, and request construction

DEV-2462

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@bengobeil bengobeil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests don't

…ning

Replace mock-only unit tests with CLI-level tests that invoke the actual
commands via runCli(). Tests now validate argument parsing, JWT extraction
errors, and file handling through the full command pipeline.

Added real SIWE signing integration test that signs and recovers a
message using viem, verifying the authenticate flow works end-to-end.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@bengobeil bengobeil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still want the backend mocked. but at least this is closer to the desired scope.

Use a real HTTP server in tests to exercise the full CLI pipeline:
authenticate signs SIWE with real signature verification, underwrite
and tap-credit send requests through the mock and verify JSON output.

Backend URLs are now configurable via BULLA_AUTH_URL / BULLA_UW_URL
env vars (defaulting to production). Added async runCliAsync helper
to avoid spawnSync blocking the event loop while mock server responds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The CLI-level tests spawn `node dist/index.js` and need the build
output to exist.  Moving from *.test.ts to *.e2e.test.ts ensures they
run during `yarn test:e2e` (after build) rather than `yarn test`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bengobeil bengobeil merged commit 3c6ab87 into main Mar 18, 2026
1 check passed
@bengobeil
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.0.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants