Skip to content

feat: any app and any agent: names in any script, Python SDK 0.2, conformance for any app - #59

Closed
ahmad-ajmal wants to merge 61 commits into
mainfrom
feat/any-app
Closed

ahmad-ajmal wants to merge 61 commits into
mainfrom
feat/any-app

Conversation

@ahmad-ajmal

Copy link
Copy Markdown
Collaborator

Works with more apps and more agents: names in any script, specs in any language, a Python SDK that speaks 0.2, and conformance for an app that is not a starter. From the second audit's search for hardcoded rules.

Merge after #58. Until then this diff includes the stack; see only this PR's changes.

What changes

  • Names. Modules and operations may use letters and digits of any script, capitals included (Büro, заметки, zählen), in Unicode NFC. Before: lower-case ASCII only. Entities follow the blueprint's database.
  • A module may have a command's name. a2app <app> ./tasks is the place, a2app <app> tasks the command. Before, eight names were refused.
  • Specs in any language. The gate finds a section by a comment on its heading: ## Функции <!-- a2app: Features -->.
  • Python SDK: protocol 0.2, encoded paths, the app pin, transports, a timeout, and no redirect followed. Backward compatible, standard library only.
  • Conformance for any app. conformance/starter/run.mjs and multi-user/run.mjs read the app's own describe, take flags, and say what they could not check. A destructive operation of an unknown app runs only when --destructive-op names it.
  • The walk quotes names that are more than one word.

Things to know

  • Older clients: a CLI from before this refuses such names at its gate, and reads ./tasks as a module called ./tasks.
  • Still fixed on purpose: the protocol's own paths, headers, codes, the ten MCP tools and MCP versions. Still not done: the gate's Q1–Q18 and F- ids are conventions in ASCII; framework text to agents is English (codes are machine-readable); a fourth transport is a protocol version, and needs the schemas and five adapters as well as the table.

Tests

  • pnpm -r build, typecheck, test; conformance 150/150; the Python SDK's own tests.
  • Live, top of the stack: React-Node, Python, Go, Rust 96/96 in both auth modes and multi-user 77/77; PocketBase 85/96 (the 11 it fails on main and as listed in feat(adapters): MCP, app naming and approval previews in Python, Go, Rust, Rails and PocketBase #58) and 77/77.
  • A React-Node app with modules tasks, Büro and заметки and an operation zählen: gate, walk and calls.
  • Conformance on apps that are no starter (Bücher, записка; no string field; no entities; operations only), and 12 deliberately broken ones, all of which fail.
  • Python SDK: 58 checks against a real app, and 1,634 against a server made for odd ids, redirects and slow answers; transport choices equal to the TypeScript SDK's in 1,156 cases.
  • No .test files are added.

…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 Ruby port of the reference's transports and approvals: identity publishes
the declared transports and the MCP address, a call that names another app is
refused, and the app answers MCP by sending each tool call through its own
router. A 428 says why, its key works for the caller that asked, and a
destructive operation may name a preview its approval is held to; the starter's
clear-done names list-done.

Header values are read as text, as Node reads them, so an idempotency key is
one key over HTTP and MCP (SQLite kept the two apart); keys stored before are
converted. The adapter is built at boot, so a declaration it refuses stops the
app instead of failing its first request.
The Go adapter serves the app's MCP endpoint, refuses a call that names
another app, and holds an approval to what the person was shown.

- identity publishes `transports` and `mcpUrl`; a malformed declaration
  does not start; X-A2App-App of another app is 409 app_mismatch
- MCP: ten tools, each one request through Handle, stateless and
  handshake revisions, credentials only
- approvals carry a reason, are stored for the caller and the call, and
  cover the preview the operation names
- the starter's clear-done names list-done as its preview
- the self-test covers all of it
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.
Brings the native Rust adapter up to adapter-core for spec/v0_2
transports.md and approvals.md:

- identity publishes transports and mcpUrl; a malformed declaration does
  not start, and a list without mcp serves no endpoint
- X-A2App-App refuses a call meant for another app (409 app_mismatch)
- POST /api/_a2app/mcp/<app id>: ten tools, word for word the spec's, each
  one request through the adapter's own dispatch
- every 428 says why and carries a key issued to its caller, for its call;
  a preview is run as the caller, shown, and covered by the key
- the starter's clear-done names list-done as its preview
- query_operation judges the decoded operation name, the one it runs
- the selftest covers all of it
…pter

The FastAPI adapter serves the app's MCP endpoint, publishes its transports,
refuses a call that names another app, and asks for approval the way
adapter-core does: a reason on every 428, a key held for the caller that asked,
and previews that an approval is held to. The starter's clear-done names
list-done as its preview.
As in the reference: the read-only check used the name as written and the route
decodes it, so a percent-encoded name passed the check and ran. The name is
decoded once, checked, and sent as that one segment.
…base adapter

Identity publishes the declared transports and the MCP endpoint; a call that
names another app is refused on every route but identity; approvals are bound to
the caller and, where an operation names a preview, to what it would do.

Every MCP tool call is one request to the app's own loopback address, the same
path HTTP callers take: PocketBase serves records itself, so there is no router
to hand the call to. The launcher says where that is, and refuses to start on a
malformed transports list or preview.
The MCP tools promise it and the records API ignored it. A key already applied
is a 409 naming the record, before the guard; a new one is recorded in the same
transaction as the row, so a write that fails uses none and two at once with one
key make one record. An app's own record hooks stay outside that transaction.
… read-only

The root called a module read-only for any caller with less than everything in
it, so one that could write every record was told it could not. `full` is now
everything, `read-only` nothing that changes anything, and `partial` what lies
between; a module with only operations is judged the same way, and PocketBase
no longer says full to everyone.

The CLI reads a word it does not know as some access. An older one prints "no
access" for `partial`, so it is released no later than the adapters.
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.
- 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.
Modules and operations may be named in letters of any script, with capitals, and
modules may have a command's name: `a2app <app> ./tasks` is then the place. The
gate finds a spec's sections by a comment on the heading, so the spec may be in
the person's language. The walk quotes names that are more than one word.
@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/any-app 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