Skip to content

feat(runtime): a pull may hand the payer two consent pages in one attempt (consent_step) - #110

Closed
rapguit wants to merge 7 commits into
mainfrom
feat/runtime-consent-step
Closed

rapguit wants to merge 7 commits into
mainfrom
feat/runtime-consent-step

Conversation

@rapguit

@rapguit rapguit commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

What

  • ChargeInstrument.consent_step?: "enroll" | "sign" (agent-core types.ts).
  • ExecutionEngine.markShown(executionId, attemptId, consentStep?): the cursor is shown:<exe>:<attempt>:<step> when a step is given, and shown:<exe>:<attempt> (unchanged) when it is not.
  • pollUntilClosed passes the instrument's step to markShown.
  • instrumentBodies picks the CTA by step through consentCta: the bank's words with no step (as today), "Cadastre sua biometria no banco..." / "Cadastrar biometria" for enroll, "Confirme com a biometria do seu celular..." / "Confirmar biometria" for sign. The en copies too.

Why

The topup-agent's next rail (Iniciador JSR, Pix with a passkey) hands the person two pages in one attempt: register the passkey, then sign the payment. Without this, markShown presents one instrument per attempt and the second link never reaches the conversation. The bank's copy ("Autorize no seu banco... cerca de 1 minuto") is also wrong for the signing page, which lasts about 10 minutes.

Not changed

  • Sweeping sets no step: its key, its words and the markers already in a state.db are unchanged.
  • No check moved into a prompt; nothing here decides money.

Note

The sign button is "Confirmar biometria" (19) rather than "Confirmar com biometria" (23): WhatsApp caps a cta_url button at 20 characters, and a test pins that for the new labels. The existing en consentButton "Authorise at the bank" is 21 characters; left alone here (the adapter already falls back to a text link on a refused button).

Checked

  • New tests: packages/agent-core/test/consent-step.test.ts (no step, enroll + sign, no cross-reading) and packages/agent-runtime/test/consent-step.test.ts (the three CTAs, the 20-character cap, two pages in one attempt presented in order once each; that last one fails with the poll.ts change reverted).
  • npm run check, npm run eval --workspace=agents/topup-agent, npm run typecheck, npm test (99 files passed, 3 skipped): green.

🤖 Generated with Claude Code

@rapguit

rapguit commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Added: channel.jsonl records a consent link as origin + path + ?<redacted>. The query is the credential (PAR request_uri; the JSR signing page carries a JWT). The person still gets the whole link. Test in packages/agent-runtime/test/consent-step.test.ts. Runtime and topup tests green (18 files), typecheck green.

rapguit and others added 2 commits November 3, 2026 13:58
…empt (consent_step)

ChargeInstrument gains an optional consent_step, "enroll" or "sign", for a
rail whose attempt has two pages to open: Iniciador JSR registers a passkey
at the bank, then each payment is approved with it. markShown keys the step
apart from the attempt, so the second page is shown after the first; with
no step the key is the attempt's alone, so a sweeping pull and the markers
already in a state.db read as before. The WhatsApp presenter picks the
words and the button by step; every new button fits WhatsApp's 20
characters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s query

A consent link's query is its credential: the sweeping PAR request_uri,
and for the JSR signing page a JWT. The person still receives the whole
link; the channel log records origin and path with "?<redacted>".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rapguit
rapguit force-pushed the feat/runtime-consent-step branch from e854e77 to 8f42309 Compare November 3, 2026 21:33
rapguit and others added 4 commits November 3, 2026 18:41
…sent_step)

recordInstrument deduplicated on attempt, status and payable, so a JSR
pull's sign page, which can share both with the enroll page, never
reached the event log or the bundle: only the shown: cursor in state.db
knew it came. The step is now part of the event id and of the payload;
without a step the id is the one it always was.

markShown takes ChargeInstrument["consent_step"] instead of a string.

New test on the real engine (scripted looks: enroll, enroll, sign,
sign): two instrument events with their steps, each page shown once.
It fails with the engine change reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hannel

The step-to-words choice lived in the WhatsApp presenter, so the
terminal copy in the topup-agent kept the bank's "about 1 minute" line
for any consent link, its comment still calling itself the WhatsApp
copy. consentWords(step, locale) is in agent-core next to the strings;
consentCta is the channel's shape of it, and the terminal prints the
step's lead line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…not only its query

The redaction kept origin + path and replaced only the query, so a page
that carries its key in the path (a JWT or a one-shot id) went into
channel.jsonl whole; a link with only a fragment was logged as
"?<redacted>"; and an unparseable link logged as "<link>" was drawn on
the console as a code to copy. Now a path segment of 24 characters or
more, or one that opens like a JWT, is "<redacted>"; the query and the
fragment have their own markers; anything not http(s) is "<consent
link, unreadable>", still drawn as a link. textOf runs once per line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… per instalment

With consent_step a pull's two pages each reach onInstrument. The
amount line before the sign page repeats the one before the enroll
page by design: the sign page is the one that moves the money, and the
person reads the amount right before signing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rapguit added a commit that referenced this pull request Nov 9, 2026
… two pages point to #110's consent_step

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rapguit added a commit that referenced this pull request Nov 11, 2026
…t links kept off the log and off disk (#109, #110, #130) (#134)

One squash of the release branch.

- #109: the WhatsApp emulator script takes --host.
- #110: a pull may hand the payer two consent pages in one attempt (consent_step); consent links are redacted in channel.jsonl.
- #130: a hosted consent link is not kept in stub_rail_attempts or the sweeping record.
- Comment cleanup in the topup-agent's sweeping client and rail.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@rapguit

rapguit commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Landed on main via #134.

@rapguit rapguit closed this Nov 11, 2026
@rapguit
rapguit deleted the feat/runtime-consent-step 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