Skip to content

feat(approvals): an approval covers what the person saw - #57

Closed
ahmad-ajmal wants to merge 22 commits into
mainfrom
feat/approvals-native-adapters
Closed

ahmad-ajmal wants to merge 22 commits into
mainfrom
feat/approvals-native-adapters

Conversation

@ahmad-ajmal

@ahmad-ajmal ahmad-ajmal commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

An approval covers what the person saw. Replaces #47 and #48: the same code, without the new test files. Their descriptions have the full details.

Merge after #56. Until then this diff includes it; see only this PR's changes.

What changes

  • Preview. A destructive operation may name a read-only preview. Its answer comes with the 428, and the approval ends when that answer changes: reason: "changed", a new preview, a new key. Anything else that changes in the app leaves the approval standing.
  • Two fixes for every destructive operation. A key works only for the credential that asked, and a refused key comes with one that works.
  • reason on every 428: asked, changed, spent or mismatch.
  • The gate, the sidecar, the CLI, the react-node starter and the skills follow.

Spec: spec/v0_2/approvals.md. New fields are optional.

Things to know

Tests

  • The new .test files are left out, on request. They stay on the old branch (feat/approval-preview).
  • So CI covers approvals through conformance (14 class A and 6 class D checks), and not the gate, the CLI's output or expiry and restart.
  • pnpm -r build, typecheck and test pass on this branch, conformance 150/150. Before the files were left out, all of them passed against this same code.
  • conformance/starter 85/85 in each auth mode and conformance/multi-user 77/77 on a running react-node app. Live, with a browser and an agent over MCP: after a change in the page the old approval was refused and nothing was removed.

…ose by that order

manifest.json may carry `transports`, an ordered list of cli, mcp and http. The
first is the app's primary channel and the rest are fallbacks; without it the
order is cli, mcp, http. Entries are kinds, never addresses. The gate checks it,
the builder may edit it, toolkit-sync keeps it, `scaffold --transport` puts one
first, and inspect reports it.

Identity gains optional `transports` and `mcpUrl` (published by adapters in a
later change). Arriving by CLI at an app that asks for another transport first
says so. Skills, AGENTS.md and the README say how to choose, and how to operate
over plain HTTP when there is no CLI.

Spec: spec/v0_2/transports.md.
…ame its app

adapter-core serves the app as an MCP server at POST /api/_a2app/mcp/<app id>.
Each tool call is one request through the adapter's own router, so the guard,
scopes, approval, idempotency, rate limits and audit are the ones HTTP callers
meet. Ten tools, the same in every app (spec/v0_2/mcp-tools.json); MCP
2026-07-28 and, without sessions, the three handshake revisions before it. The
caller is a credential, never a browser session.

HTTP callers may name the app they mean (X-A2App-App); another app answers 409
app_mismatch. The CLI names a verified remote app on every call, and reads
identity without its credential. Identity publishes `transports` and `mcpUrl`.

Conformance class D covers the binding, and the starter conformance checks it
against a running app on any stack.
Agents given only a task and an app picked the right transport each time, and
stopped at every refusal. What slowed them is fixed: tools take an entity or
operation by its own name, a declared operation is preferred over a raw write,
the HTTP routes are listed in full, what to do when a scope or an approval is
missing and the person can't be reached, and an MCP server that answers
app_mismatch is another app's.
A destructive operation may name a read-only `preview` that says what it would
do. Its answer comes with the 428, and the key covers it: when the answer
changes, nothing runs, and the caller is shown the new one. Anything else that
changes leaves the approval standing.

Two fixes for every destructive operation: a key works only for the credential
that asked, and a refused key always comes with one that works. A 428 says why
(`reason`: asked, changed, spent, mismatch).

The gate and the adapter refuse a preview that is not one. The sidecar runs an
adopted app's own read route. The CLI shows the preview before the line that
would run the call. The react-node starter's clear-done names list-done.

Spec: spec/v0_2/approvals.md.
The read-only check used the name as written and the route decodes it, so a
percent-encoded name ("clear%2Ddone") passed the check and ran. The name is
decoded once, checked, and sent as that one segment. Scopes always applied; what
was missing is the promise a harness relies on when it runs a read-only tool
without asking. Found by the Go port's comparison run.
The bridge told every harness to use the a2app CLI. It now uses the first of
the app's transports the run can reach, and writes the prompt for it.

Over MCP, the harness gets a configuration file for that one run with the app's
endpoint and the task's own credential: 0600, only its path in the arguments,
removed when the run ends. Routes in harnesses.json gain `transports` and
`mcpArgs`; the built-in claude route has the latter. An inbound route gets the
app's address, order and MCP endpoint in its body.

Plugins say what to do when the CLI is missing, and no longer call it the only
way to operate an app. The account page shows the app's MCP address beside a
new token.
@ahmad-ajmal
ahmad-ajmal force-pushed the feat/approvals-native-adapters branch from 61f792c to 4d80fe9 Compare November 30, 2026 15:30
@ahmad-ajmal ahmad-ajmal changed the title feat(approvals): an approval covers what the person saw; native adapters catch up with the reference feat(approvals): an approval covers what the person saw Nov 30, 2026
- An agent that came by MCP is told the app's order: in the server's
  instructions, in whoami, and in the first describe (conventions.transports).
  The skill and AGENTS.md say to read it before the first call.
- A 401 says where a credential comes from (A2APP_TOKEN, the account page), and
  no longer points at .agent-token. HTTP is reachable only with a credential in
  hand, where the work changes anything.
- dev, the skills and AGENTS.md say that only a2app moves to the candidate:
  connected MCP tools and the usual address still reach the live app.
- scaffold writes `transports` only when it is a choice, so an older agent-app
  accepts the app. It refuses --transport mcp on a blueprint that does not serve
  MCP, the gate refuses it on a running app, and serve names a malformed list.
- starter conformance says what it did not check.
- Docs keep the token off the command line; a missing CLI is the person's to
  install.
…e described

From the second audit.

- whoami says when a credential gives less than the owner has, and such a caller
  is told to stay with it, not sent to a CLI that acts as the owner.
- A2APP_TOKEN is one app's: A2APP_APP names it, and it goes to no other app.
- a2app says nothing of the live app's transports while it answers from a dev
  candidate.
- The SDK encodes ids, entities and operations in paths: `b-1?x` was `b-1`.
- Bridge routes have arguments per transport, their own MCP configuration format
  and a JSON prompt; the run's values are in the environment.
- Plugin tools follow the app's order, over MCP or HTTP without the CLI.
- One table of transports, and what must name each is keyed by it.
@ahmad-ajmal

Copy link
Copy Markdown
Collaborator Author

Replaced by #61, which has this same code. The branch is kept.

@ahmad-ajmal ahmad-ajmal closed this Dec 1, 2026
@ahmad-ajmal
ahmad-ajmal deleted the feat/approvals-native-adapters branch December 2, 2026 11:18
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