Skip to content

refactor(topup-agent): the pull runs on the offline simulation; a pull to a real bank goes through the CodeSpar API - #136

Merged
rapguit merged 2 commits into
mainfrom
chore/topup-provider-via-api
Nov 12, 2026
Merged

rapguit merged 2 commits into
mainfrom
chore/topup-provider-via-api

Conversation

@rapguit

@rapguit rapguit commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

What

The topup-agent no longer carries a client of a payment provider. The pull runs on the kit's offline simulation of the bank, which stays the default and now is the only rail; a pull to a real bank goes through the CodeSpar API.

  • The direct sweeping client and the --rail api path are removed; --rail api is refused with a message naming the CodeSpar API.
  • The rail's types move into src/modules/sweeping-pull.ts; the rail keeps its guarantees (one pull per approved execution, marker before the payment request, no consent link in state.db).
  • The two limits are read from TOPUP_TOTAL_CENTS / TOPUP_TX_LIMIT_CENTS.
  • The hosted catalog is unchanged (apiRailKey: "none" kept).
  • README, runbook, .env.example, AGENTS.md/CLAUDE.md, agent.yaml and OPEN_QUESTIONS 66 describe the simulated rail.

Tests

  • HTTP client tests and the api-rail command test are removed; the rail tests run over an in-memory fake of the four calls.
  • npm run typecheck
  • npm run check
  • npm test (1114 passed, 43 skipped: the WhatsApp cases without the emulator)
  • npm run eval --workspace=agents/topup-agent (7 adversarial cases, 13 scenario runs)

🤖 Generated with Claude Code

rapguit and others added 2 commits November 12, 2026 14:37
…l to a real bank goes through the CodeSpar API

The kit no longer carries a client of a payment provider. The direct
sweeping client and the `--rail api` path are removed; the simulated rail
(SweepingPullRail over FixtureSweepingApi) is the only rail and the default,
with the same state machine and the same guarantees: one pull per approved
execution, the marker written before the payment request, no consent link
in state.db.

- src/iniciador.ts is removed; the rail's types and its error class
  (SweepingApiError) move into src/modules/sweeping-pull.ts.
- kit.ts builds only the simulated rail; `--rail api` is refused with a
  message that names the CodeSpar API. apiRailKey stays "none", so the
  hosted catalog is unchanged.
- The two limits are read from TOPUP_TOTAL_CENTS / TOPUP_TX_LIMIT_CENTS.
- Tests: the HTTP client tests and the api-rail command test are removed;
  the rail tests run over an in-memory fake of the four calls.
- README, runbook, .env.example, AGENTS.md/CLAUDE.md, agent.yaml and
  OPEN_QUESTIONS 66 describe the simulated rail and the CodeSpar API path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…orization; --rail api is refused

- sweeping-pull.test.ts: the happy path asserts the authorization request
  (both limits, creditor, trigger, externalId).
- kit-rail.test.ts: the rail the kit builds with TOPUP_TOTAL_CENTS /
  TOPUP_TX_LIMIT_CENTS set puts the same caps in the mandate and in the
  authorization; the defaults are R$ 10,00 / R$ 5,00; buildRail with kind
  "api" throws instead of falling back to the simulation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rapguit
rapguit merged commit 73dcc85 into main Nov 12, 2026
4 checks passed
@rapguit
rapguit deleted the chore/topup-provider-via-api branch November 12, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant