Skip to content

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

Closed
ahmad-ajmal wants to merge 6 commits into
mainfrom
feat/approval-preview
Closed

ahmad-ajmal wants to merge 6 commits into
mainfrom
feat/approval-preview

Conversation

@ahmad-ajmal

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

Copy link
Copy Markdown
Collaborator

An approval now covers what the person saw. A destructive operation may name a read-only preview that says what it would do. Its answer comes with the 428, and the approval ends when that answer changes. This is step 1 of the proposal in #47, and replaces it. It is stacked on #45 and #46: review the last commit until those merge.

Why

On a running app, an agent asked to run clear-done when one task was done. The person marked a second one done and approved. The same key removed both.

What changes

  • preview on an operation. "clear-done" names "list-done". The adapter runs it with the call's own arguments, as the caller, when approval is asked for and again before the call runs. If the answer differs, nothing runs: 428, reason: "changed", the new preview and 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. A refused key always comes with one that works: before, an expired one handed back a key that never could.
  • reason on every 428: asked, changed, spent or mismatch.
  • The gate and the adapter refuse a preview that is not declared, is not read-only, or takes arguments the call doesn't have.
  • Sidecar: an adopted app's own read route can be the preview.
  • CLI: shows the preview before the line that would run the call.
  • Starter: react-node's clear-done names list-done.
  • Skills: the creator says when to declare one, and the operator says to show it and to ask again on changed.

Spec: spec/v0_2/approvals.md. The new fields are optional; the code, the header and the retry are unchanged.

Things to know

  • An operation with no preview behaves as before, apart from the two fixes.
  • Approvals waiting when an app updates are asked for again.
  • Custom state stores need no change: the same two calls, with a longer key.
  • The Python, Go, Rust, Rails and PocketBase adapters and the Marketplace kit ignore preview until their own PRs. Their describe doesn't publish it.
  • It is not a lock. A change between the second preview and the run isn't seen, unless the app does both in one transaction.
  • Raw record deletes still ask for no approval.

Tests

  • adapters/adapter-core/test/approval.test.mjs: 53 checks, including expiry, restart, another caller, cut previews, a preview that fails and one that moves by itself.
  • Conformance: 14 new class A checks and 6 new class D checks, 148/148. The caller check was confirmed to fail with the caller left out of the key.
  • framework/cli/test/preview.test.mjs (gate and CLI), and 4 checks in reverse-proxy.
  • conformance/starter/run.mjs: 85/85 against a running react-node app (both auth modes), and conformance/multi-user 77/77. Its new checks are skipped, with a note, on adapters that don't have this yet.
  • Live, with a browser and an agent over MCP: the agent showed the person the app's own list; after a change in the page the old approval was refused and nothing was removed; an unrelated change left the new approval standing.
  • pnpm -r build, typecheck and test pass on Windows, Node 24.

…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.
@ahmad-ajmal

Copy link
Copy Markdown
Collaborator Author

Replaced by #57, with the same code. The branch is kept.

@ahmad-ajmal
ahmad-ajmal deleted the feat/approval-preview 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