← Back to Pull requests

Owners confirm the agent's terms before a transfer (decision 0014) #34

Closed
unknown closed this pull request without merging on Oct 31, 2026 10:27 UTC
View on GitHub
unknown unknown commented on Oct 31, 2026 09:00 UTC
Author

<!-- claude-projects-attribution: {"github_login":"b3hr4d"} -->
_Requested by Behrad · project thread_

What it does

Before the agent answers an owner's request with a transfer, it writes the terms it reads in the request: the token, who is paid, the most, and the latest time the transfer may be sent. The owner reads them in words on the wallet's own Approvals page and confirms them, or says no. Until an owner confirms them, the wallet refuses a transfer for that request. Once the agent proposes one, the wallet's pages check it against the confirmed terms. If it is outside them, the pages list why and offer no Approve and no Run. Reject stays. Every transfer still waits for an owner or an approver (decision 0007).

Reading the terms, writing them in words and the check all come from Meant's @meantjs/consent/terms 0.5.0, the confirmed-terms step of the profile spec (D-056 there). The record is [decision 0014](docs/decisions/0014-confirmed-terms.md), accepted on 2026-10-31: Behrad chose option A, which this PR builds. B (the wallet also requires terms on every request) and C (the check runs in the canister) are written out there. The record also cites candid-profile's re-test (its PR #79): with a careful simulated user confirming the terms, no model signed any of 1,950 bad requests.

Behrad also accepted raising the app.js budget from 560,000 to 600,000 bytes. app.js grows from 543,895 to 579,300 bytes.

Changes

  • Wallet canister (candid/wallet.did, canisters/wallet/src/terms.rs, lib.rs, types.rs, storage.rs)

  • - propose_terms(id, draft) is for proposers (and owners). It takes four fields of 1 to 160 bytes, at most 3 drafts per request, and none once a transfer answers the request.
    - confirm_terms(id, { version, terms, id, text }) and decline_terms(id, version) are for owners only. The wallet does not read the terms. It stores the JSON the page confirmed (RFC 8785, at most 2,048 bytes), the words the owner read, who and when. It refuses an id that is not the SHA-256 of that JSON.
    - request(id) is a query for members.
    - propose_for refuses a request whose terms wait for an owner or were declined.
    - Three new audit events.
    - Request.terms is an opt, so requests stored before this change read with none.
  • Owner pages (ui/src/logic/terms.ts, ui/src/parts/terms.tsx, guard.tsx, approvals.tsx, rail.tsx)

  • - The Requests card shows the agent's draft in words, read as of when it was written and in the browser's zone, with "Confirm these terms" and "Not what I meant".
    - The Approvals page, and the "Needs you" list beside every page, read the request a transfer answers and check the transfer against the confirmed terms.
    - Names that would not name one thing are left out. ICP's name stays ICP's ledger's, even when that ledger cannot be read.
  • Agent tools (mcp/src/tools.ts)

  • - New wallet_propose_terms. It reads the draft the way the page will, and refuses one that cannot be read before it is written, so a bad draft costs none of the three. It returns the words the owner will see.
    - wallet_requests now shows each request's terms and what an owner said.
    - wallet_propose_transfer refuses a transfer outside the confirmed terms and gives the reasons.
  • Packages

  • - @meantjs/format moves from 0.1.0 to 0.5.0 in ui/ and mcp/. The package did not change in anything the wallet uses.
    - @meantjs/consent 0.5.0 is added to both, and ui/ also adds @meantjs/profile 0.5.0 for the RFC 8785 JSON. All are pinned exactly and listed in ui/build.mjs.
    - npm audit --omit=dev finds nothing in either package.

    How it was checked

  • Rust: cargo fmt --all --check, clippy (native and wasm32-unknown-unknown) and cargo test --workspace --exclude integration all pass.

  • PocketIC: 105 tests pass, including the new terms_come_before_the_transfer. The upgrade test runs from main's release (12320fe, built in its own target directory). It now writes a request with that release and gives it terms after the upgrade. A fault planted in that new part makes the test fail. Later commits change only the pages, the agent tools and the docs, and the page verification tests pass again after them. CI runs the Bitcoin Core tests and the 100 MiB release test (all three jobs green).

  • UI: format, lint, typecheck and 71 tests pass (7 of them new). Three planted faults were each caught. npm run build with Node 22.22.0 changes only app.js.

  • MCP: format, lint, typecheck and 21 tests pass (4 of them new). Three planted faults were each caught.

  • One vector across all three checks: the confirmation the page writes, a JSON naming the account "Épargne" with SHA-256 4b53ee47…. The UI test pins it, the wallet's unit test accepts it, and Python's hashlib gives the same hash.

  • In a browser, against a stand-in wallet (not committed):

  • - Setup. The page code was built the way ui/build.mjs builds it, with only ui/src/ic/client.ts swapped for ic-reactor's test client (@ic-reactor/core/testing). The test client is a fake replica that signs and certifies replies, with the wallet and the ICP ledger written as plain functions. The pages were served at http://<wallet id>.localhost and driven in Chromium.
    - Confirming. The owner confirms the agent's draft on the Approvals page. The draft reads "Savings (…-eiw7ojy.1) may be sent at most 1.5 ICP, until the end of 30 November 2026 (UTC+03:00)".
    - Outside the terms. A 5 ICP transfer against terms of at most 0.5 ICP shows "Outside the terms" and the reason, and offers only Reject.
    - Within the terms. A 1.5 ICP transfer within its terms offers Approve, then Run it once approved.
    - Needs you. The "Needs you" list on the Overview does the same.
    - Result. 13 of 13 checks pass, with no console errors or page errors. With termsAllow broken on purpose, the three "no Approve" checks fail.
    - Limit. The stand-in is not the canister. The canister's rules are what the PocketIC tests cover.

    Not done yet

  • The pages have not run against the canister with Internet Identity, like the other signed-in flows (docs/ui-standard.md, "Not covered yet"). scripts/try-local.sh --browser shows it on a local network.

  • The check runs on the page. An owner using another client can still approve a transfer outside the terms (that is option C).

  • A small follow-up: Wallet health still counts a transfer outside the terms among those that "wait for you", with "Approve or run them on the Approvals page", though the page offers only Reject for it.
  • 🤖 Generated with Claude Code

    https://claude.ai/code/session_01WnX8bbgsvo3ZpPBaqqGej3

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: b3hr4d Review duration: 87m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #34"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57% (MEDIUM) · Higher = larger blast radius
    57%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%