36. No local bridge: agents reach ArchLang through text, stateless calls and links
- Status: Proposed (draft, 2026-11-30). Decisions 1 to 3 are not ruled by the owner. Decision 4 was taken on 2026-11-30 by the coordinating Claude session under the owner's delegation (see "Addendum: decision 4 taken under delegation" at the end); the owner has not ruled on it and can overrule it in one sentence. The owner asked for the question and its findings to be recorded in full and for a draft ADR to be written. Until she rules, this record changes no surface, tool or document that ships.
- Date: 2026-11
- Relates to: ADR 0007 (source metadata only on request), ADR 0012 (the MCP shim is a channel, the CLI stays primary), ADR 0015 (the CLI is an agent interface), ADR 0026 (the stateless hosted server, its viewer,
/svg/<payload>), ADR 0034 (a plan is stored only when its owner asks) - Scope: a record and a proposal. It changes no code, no tool, no schema and no deployed behaviour: nothing under
src/,packages/mcp/,packages/mcp-worker/orplayground/. The one direction it names for building something (decision 4) would be built only under its own backlog card and review (docs/backlog.md, entries HX.1 to HX.4).
Context
The question
Some tools that let an AI agent work with a design program pair a local process with a page open in the user's browser: a small server listens on the loopback address, the page connects to it, and the agent, which runs elsewhere, drives whatever state lives in that tab (a loaded model, an interactive viewer). Should ArchLang add such a pairing, or keep the surfaces it has?
What a bridge is for
It earns its place where the state an agent needs is in the tab and nowhere else: a model loaded from a binary file, a selection, an undo stack, a scene that only the viewer can compute. The agent cannot get at that state except through the tab, so the tab must be reachable from outside it.
ArchLang's situation
Known (read from the repository on 2026-11-30).
- The plan is a text file.
compile()is pure, sync and deterministic ("no I/O, time, randomness or Node APIs insrc/outsidesrc/cli.ts+src/cli/",AGENTS.md§ Hard rules), and it is isomorphic ("pure, synchronous and isomorphic",docs/agents/architecture.md): the same function runs in the CLI, in the stdio server, in the hosted Worker and in the playground. Every output (SVG, DXF, TXT, Plan JSON,describe(),lint()) is a function of the text. - The agent surfaces that exist:
- the CLI, "ArchLang's primary agent interface" (ADR 0015) and, in ADR 0012's words, "The CLI remains the primary interface";
- the stdio MCP server,
packages/mcp, a shim whose tools "each wrap one pure exported function"; - the hosted MCP server,
packages/mcp-workerathttps://mcp.archlang.uk/mcp: "Streamable HTTP, stateless: no sign-in, no session id, a freshMcpServerper request" (ADR 0026), with a viewer, alinktool andGET /svg/<payload>image URLs; - playground links, whose plan travels in the URL fragment (
#z=…) and so never reaches a server, and short links (/s/<id>), which store a plan only when its owner presses "Copy short link" (ADR 0034).
- The annotations on a drawing are derived by the compiler, not drawn by hand:
dims autowrites dimension chains,schedule roomsandschedule openingswrite the schedules ("Rows are derived from the rooms, never authored"),legendis "Fully derived", and the room areas come from the geometry (docs/language-reference.md, statements table). - ADR 0026 deferred server-side state by name: "Sessions, auth, server-initiated messages — nothing here needs them."
Inferred (the author's reading, not stated in a record). Because the text is the whole state, an agent that holds the text holds everything a browser tab holds, and can compile it, describe it, lint it and draw it without the tab. No state is trapped there.
Decision
All four points are proposals. None is a ruling.
Proposed: ArchLang adds no local bridge. Agents keep reaching it through text, stateless calls and links. One gap that a real user can hit, a DXF for someone who has only the hosted server, is worth closing, by a route that needs no session.
1. No local bridge, daemon or loopback pairing
ArchLang does not add a feature that pairs a local process with a browser tab. The reasons come from the product:
- There is no state trapped in a tab to drive. The plan is text. The playground keeps it in the URL fragment or in a stored short link; an agent given the text can reproduce anything the page shows.
- The hosted server is stateless by decision (ADR 0026). A bridge is a session by another name.
- A bridge adds failure classes the current surfaces do not have: a listening socket on the user's machine, which must be secured; a permission prompt that browsers show when a public page reaches a local address (the author's understanding of current browser behaviour; not tested in this repository); an origin allowlist to keep right; and a wire protocol that ties a deployed page to the version of an installed package, so that a site deploy (pushing
maindeploys the sites,AGENTS.md) and an npm release must agree. - The cost lands on a small project. Each of those arrives as a "it does not connect" report whose cause is on the user's machine (the author's inference).
2. The three agent surfaces stay, and stay client-neutral
The CLI, the stdio MCP server and the hosted MCP server (any host that takes a URL) remain the supported ways in. None is tuned to one host, and none is dropped to make another easier.
3. "A person points at an element and the agent learns which one" is parked
If it is ever asked for, it is answered with a text reference that the person copies and pastes (an element id plus a source span), or that a viewer sends as a message where the host allows it; not with a session. No request for it is recorded in the backlog, an issue or a pull request. The groundwork that exists:
Known.
compile(source, { annotate: true })stampsdata-span="start:end"on each drawn primitive that has a source span, and, for an element,data-arch-id,data-arch-kind,data-arch-labelanddata-arch-primary(src/backends/svg.ts, theopts.annotateblock). It is opt-in (ADR 0007); the default SVG is byte-identical, and the playground re-compiles without it for any export.- The MCP
compiletool passesannotateonly forformat:"txt"(packages/mcp/src/tools.ts). For SVG it does not, so the SVG the hosted viewer draws carries no element ids. - The playground hit-tests a click (
playground/src/interact.ts) and opens a room's facts card (playground/src/room-card.ts) that, in edit mode, offers "Jump to source" and moves the editor's caret to the statement that drew the room. - There is no "copy element id" or "copy reference" in the playground or the viewer, and no backlog entry for one before HX.3.
- The hosted viewer (
packages/mcp-worker/src/viewer/viewer.ts) has no handler that selects or identifies an element (its pointer and click handlers only pan and zoom). The only call it makes to its host iscallServerToolfor thelinttool. It creates theAppwithwebMcpBridge: false; its comment gives the reason: "ext-apps 2.x turns on a WebMCP tool bridge by default, which this viewer, with no tools of its own, does not want." ADR 0026 adds that it pins the SDK client exactly "so it holds one SDK core". That setting is about the viewer exposing tools, not about sending text back. - The installed
@modelcontextprotocol/ext-apps2.1.0 offerssendMessage(a user-role message to the host's chat),updateModelContext(state for the model's next turn),openLink,downloadFileandcallServerTool(read from its type declarations on 2026-11-30).
Not determined. Which hosts honour sendMessage, updateModelContext or downloadFile. The only host in which the viewer is proven to render is the one ADR 0026 records in its "Addendum: production"; of the rest it says "No other host is claimed."
Inferred. The two smallest forms are a playground button that copies the element's id and span as text, and a viewer message that sends the same text to the host. Either needs compile to be asked for annotations on the SVG it returns to the viewer, which is a change to a tool result and so its own design, not part of this record.
4. The gap worth closing: a hosted-only user cannot get a DXF or a vector PDF
Known (2026-11-30, core 1.69.0, dist/ built 2026-11-29).
compile'sformatisz.enum(["svg", "txt", "json", "png"])(packages/mcp/src/tools.ts).dxfandpdfappear nowhere inpackages/mcp/src/. On the hosted serverpngis also refused, withE_PNG_DEPENDENCYand the sentencePNG_HOSTED(packages/mcp-worker/src/server.ts).toDxf(scene: Scene): string(src/export/dxf.ts) is pure and sync, imports only core modules and uses no Node API; its header says "Pure, synchronous, zero-dep". It is a public export of the core (src/index.ts): the scene iscompile().scene, orpages[i].sceneper storey. It is already in the hosted bundle: a build of the Worker made in a scratch folder on 2026-11-30 from this checkout'sdist/(3,599,227 bytes, 1,024 KiB gzip, the 661 KiB viewer included) contains the DXF header text once.toPdf(scene)(src/export/pdf.ts) is async, needs the optional dependencypdfkitbyimport("pdfkit"), and reads the bundled font through lazynode:fs(src/backends/font.ts). The Worker build replacespdfkit,@resvg/resvg-jsandclipper2-wasmwith modules that throw ("Optional core dependencies the Worker can never load",packages/mcp-worker/scripts/build.mjs).pdfkit0.20.2 ships a browser build (js/pdfkit.browser.mjs, 241 KB); no repository code uses it.packages/mcp/capabilities.mdsays "dxf: no dependency, CLI only", "pdf: needs the optionalpdfkit, CLI only" and "dxf,pdfcome only from the CLI, not fromcompile". That text is generated (packages/mcp/scripts/gen-capabilities.tsadds ", CLI only" to every export format that is not incompile's enum). It first appeared on 2026-11-11, in commit9d0190d5, pull request #703 (card RM5.1). It describes the state; it gives no reason.compilebegan with["svg", "txt"](commita4003e88, 2026-07-11) and gainedjsonandpngon 2026-10-13 (commit6f69b35d, pull request #170, card B2).dxfandpdfwere never added.- No recorded reason was found for leaving DXF out. The search covered ADRs 0009, 0012, 0015, 0019, 0026 and 0034,
docs/plans/,docs/backlog.md, the history ofpackages/mcpandpackages/mcp-worker, and pull requests and issues. Onlypnghas a recorded reason (ADR 0026, "No/png/": a native module that reads fonts throughnode:fs, "A Worker has neither"). Forpdfthe Worker build records thatpdfkitcannot be loaded there, which does not explain the stdio server. - ADR 0012's token-cost argument ("a CLI costs nothing in an agent's context window until it is called, whereas an MCP tool schema sits in the window permanently") is about tool schemas, not about the size of a result.
- The path a hosted-only user takes today: the agent calls
link, which returnsplaygroundandembedURLs (no short link); the user opens the page and chooses Share, Export, Download, then DXF or PDF. The playground builds the DXF in the browser with the core'stoDxf; its PDF is a raster made with jsPDF (backlog U.18). The only hash flags the page reads areeditand3d(playground/src/share.ts), so no link opens on an export. Thearchlang-exportskill tells the agent to give theplaygroundURL and to say that "a vector PDF needs the CLI". The plan stays in the URL fragment throughout. - Two public descriptions read as if the MCP tools produce DXF and PDF (backlog HX.4): the registry description in
packages/mcp/server.json("compile, lint and repair ArchLang (.arch) floor plans to SVG, DXF and PDF") anddocs-site/mcp.md("you write.archtext and compile it to SVG, DXF or PDF").
Measured (Node on Windows, 2026-11-30, core 1.69.0 dist/cli.js, pdfkit 0.20.2; "tokens" is bytes divided by 4, a rough figure).
Plan (from examples/) | Source (bytes) | SVG (bytes, about tokens) | DXF (bytes, about tokens) | DXF gzipped (bytes; Node zlib.gzipSync, default level) | PDF (bytes) | toDxf alone (ms) |
|---|---|---|---|---|---|---|
one-room | 742 | 5,461 (1.4k) | 6,282 (1.6k) | 1,450 | 8,000 | 5.2 |
studio | 3,883 | 20,125 (5.0k) | 28,291 (7.1k) | 4,722 | 13,940 | 4.5 |
classroom-block | 5,763 | 114,510 (28.6k) | 90,720 (22.7k) | 12,013 | 28,220 | 17.4 |
courtyard-house | 14,427 | 118,668 (29.7k) | 139,576 (34.9k) | 19,505 | 32,120 | 13.7 |
hillside-villa, two storeys summed | 18,422 | 259,620 (64.9k) | 303,195 (75.8k) | 43,142 | 74,502 | 21.9 |
| synthetic 60 KB grid of rooms | 61,293 | 456,725 (114k) | 481,652 (120k) | 33,787 | 28,993 | 11.4 |
A DXF is about 0.8 to 1.4 times the size of the SVG that compile already returns in full (0.79 for classroom-block, 1.41 for studio), so a DXF in a tool result costs the same order as the SVG. A PDF is binary. The CLI writes one file per storey. The synthetic plan is the generator of packages/mcp-worker/scripts/measure-cpu.mjs at 60 KB.
Worker constraints as the repository states them. A source argument is capped at 64 KiB (SOURCE_CAP_BYTES); a /svg/ payload at 88,406 characters (MCP_PAYLOAD_CAP_CHARS, computed here from its formula); CPU per request at limits.cpu_ms: 5000 (packages/mcp-worker/wrangler.jsonc). ADR 0026 measured compile at p50 8 ms, p95 34 ms and max 105 ms over the examples, and 663 ms at p50 for the 60 KB synthetic plan. Rate limits are per address: 600 /mcp requests and 3,000 /svg/ cache misses a minute (best-effort bindings), plus a zone rule outside the repository (100 requests per 10 s per IP). The only platform size limit the repository states is ADR 0034's "10 MiB compressed limit", for the playground Worker. A hosted /svg/ URL sends the plan to the server in its path (ADR 0026, docs-site/privacy.md); a playground link does not.
Proposed direction, to be built only under its own card (HX.1) and review.
- First look: a hosted download URL for DXF, modelled on
GET /svg/<payload>: the same base64url-deflate payload, the same caps, the same pinned and unpinned cache keys andETag, the same per-address check on a cache miss,toDxfalready in the bundle, and the privacy sentence that already covers/svg/. Thelinkorread_metext would have to name it (ADR 0026 lists "Alinkresult that also names the/svg/URL" as deferred). - Rated weakest: DXF as text in the
compileresult. It costs the same order as the SVG in the model's context (about 0.8 to 1.4 times its tokens: 7k tokens forstudio, 35k forcourtyard-house, 76k for the two-storeyhillside-villa) and still leaves the user without a file. - Held: PDF, until
pdfkit(its browser build) and the font are tested inside a Worker within the CPU limit (HX.2). Until then the playground's raster PDF stays what a hosted-only user gets.
Not determined.
- Whether hosts that take a URL show a link to a file download, or accept a
resource_linkor an embedded resource, and whether they honourdownloadFile. Nothing in the repository records it. - A host's tool-result size limit. The repository states none for text;
tools.tsonly says that a host's result cap bounds an image. - Whether
pdfkitand the bundled font run in a Worker, and at what CPU cost. - The size and time of a
/dxf/response on the platform (the figures above are Node, not Cloudflare). GET /svg/<payload>serves the lowest storey only; it has no storey selector. A/dxf/twin would need to decide between the lowest storey, alevelparameter and one file per storey. That is an open design point.- Why DXF was left out: inferred, not recorded. The best fit with the evidence is that nobody asked for it: no pull request, issue, backlog entry or ruling mentions DXF over MCP.
Consequences
- No new listening surface, permission prompt or version-coupled protocol is added. The three agent surfaces keep their present failure modes and their present documentation.
- If the owner accepts decision 4, a hosted-only user would get a DXF through a URL without a session, at the price of one more route on a Worker that counts requests (ADR 0026's spend bound covers it, with a new route to measure) and of a plan in a URL path, which the privacy page already says for
/svg/. - The wording in
packages/mcp/server.json,docs-site/mcp.mdanddocs/integrations.mdstays as it is until the owner chooses: either the capability ships, or the wording is corrected (backlog HX.4). Leaving it is a known mismatch, recorded, not hidden.server.jsonis version-pinned (.claude/rules/mcp.md), so any change to it rides a release. - "Copy a reference" stays unbuilt and costs nothing until asked for.
- Accepting this draft needs the owner's words. Until then it is a draft, and a reader must not cite it as a decision.
Alternatives considered
- A local bridge (a loopback server paired with an open tab). Rejected in this proposal for the reasons in decision 1: there is no state in a tab that the text does not hold, and a bridge adds a socket, a permission prompt, an origin allowlist and a page-to-package version coupling.
- A hosted session relay (the hosted server holds a connection between a tab and an agent). Contradicts ADR 0026's stateless design ("no session to resume and no server-initiated message to stream") and would hold plan text on the server for the length of a session, which ADR 0034 limits to a plan its owner chose to store.
- DXF as text in the
compileresult. The cheapest to build (toDxfis in the bundle and costs about 4 to 22 ms in Node on Windows, core 1.69.0, 2026-11-30). Rated weakest: the same order of token cost as the SVG, and a chat host must still turn the text into a file the user can open. - Short-link
.dxfand.pdf(/s/<id>.dxf). The playground Worker already holds a stored plan and serves/s/<id>.png, rate-limited per address. But a plan is stored only when its owner asks: "Copy short link is the one action that sends a plan to the server" (ADR 0034). The MCPlinktool "builds its URLs locally and fetches nothing" (openWorldHint: false,tools.ts); having it store a plan to mint a short link would reverse that, and the playground'spdfkitis a stub, as the hosted one is. - A playground deep link that opens on an export. Needs a new hash flag and a playground change; the plan stays in the fragment, which is its privacy advantage. A browser download generally needs a user action (inferred), and the PDF would still be the raster one.
- An MCP resource, an embedded resource or
downloadFilefrom the viewer. Possible in the protocol (ext-apps 2.1.0 hasdownloadFile, taking an embedded resource or a link the host fetches). Host support is not determined, a blob result is large, and the viewer is proven in one host only. Worth checking after a download URL exists, as a way to hand that URL to the host. - Do nothing. Keeps today's path (the playground link, a client-side DXF, a raster PDF) and the mismatch in HX.4. It is a valid outcome of the owner's ruling.
Reverse if
- The playground gains direct manipulation whose state is not in the source (a drag that is not yet a statement, a selection that matters across calls): then there is state in the tab, and a pairing is reconsidered against decision 1.
- A host that matters to users can be reached only through a local pairing (it takes no URL and runs no stdio server): then decision 2 is reopened for that host.
- Requests repeat to let an agent drive an open playground session: then the request is read for the state it needs, and the answer is chosen between a text reference (decision 3), a link, and a session.
- A measurement shows
pdfkitand the font run in a Worker well inside the CPU limit: then HX.2 is promoted and the PDF half of decision 4 is decided against its numbers. - A host is shown to take a file from a tool result or a viewer message: then the option rated weakest or a resource hand-off is weighed again.
Addendum: decision 4 taken under delegation (2026-11-30)
The sections above are the proposal as first written and are not rewritten. This addendum records what happened to decision 4 afterwards.
- Authority. The owner said in chat on 2026-11-30: 请你帮我做出最佳决策,然后记录下来,本次对话不做具体的开发,仅做开发规划。 (A gloss, not a translation she gave: make the best decision for me and record it; this conversation does no concrete development, only development planning.) Under that delegation the coordinating Claude session took the two decisions below, for this one occasion. They are the coordinator's, not the owner's, and she can overrule either in one sentence. They are rulings RM-D117 and RM-D118 (
docs/plans/product-roadmap/rulings.md§ 6.49). The full plan, the acceptance checklist, the sweep and the wording are indocs/plans/hosted-export.md. - HX.1, build a hosted DXF download URL.
GET /dxf/<payload>on the hosted server, modelled on/svg/<payload>, DXF only, answering a file download. Of the options weighed above it takes the download URL; it does not take DXF as text incompile, a short-link.dxf, a playground deep link, or a DXF format in the stdio server. Aresource_linkordownloadFilehand-off waits until host support is known. PDF is not part of it. Open design points (where the URL sits, the storey selector, the content type and filename, the rate-limit binding) stay open for the build's review. - HX.4, correct the wording first. The public descriptions that read as if the MCP tools produce DXF and PDF are corrected now, independently of HX.1, in two steps: a docs-only change for the surfaces that are not version-pinned, then the pinned manifests at the next release.
- Order. HX.4 step (a), then HX.1, then HX.2 as a time-boxed test, with HX.3 parked.
- Still proposals, not ruled by the owner: decision 1 (no local bridge), decision 2 (the three agent surfaces stay and stay client-neutral) and decision 3 (copying a reference is parked). The "Reverse if" conditions above apply to them unchanged.
- Nothing is built by this addendum. No code, tool, schema, manifest, site copy or behaviour changes with it.