You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tier 1 serving: the frame, the broker's operations, files inside the frame, and the promise #183
Given the frame prototype's evidence, what exactly does tier 1 serving look like? To decide: the shell's page at the patch's path and the inner content URL; the broker's operation set for v1 (tables read and write, files put, get, list and delete, integration call, shared-table read) and its envelope (request id, patch and version bound by the shell, structured errors, the "this is your access" message); how the viewer's claims reach patch code; the route bridge for deep links and history; how the patch shows its own files and what public patches do; what is deliberately not supported at tier 1 (printing from inside the frame, arbitrary outbound, popups); the serving guarantees paragraph for tier 1 in packages/serving/CONTEXT.md and docs/product.md, replacing "the patch cannot watch you" with the tier 1 promise; and whether the transport needs a version of its own.
Recommendation: keep the broker's envelope generic over operations so tier 2 adds streaming without a second protocol, and write the tier 1 promise as one sentence a viewer would understand.
Resolved 2026-09-10 with Allison. Two rounds: eleven questions on the runtime, then four on addresses after Allison pulled human-readable addresses into this ticket. Each round was pressure-tested with astra first (three exchanges; its review is summarised at the end). Everything below sits on top of the decisions the ticket cites; the frame prototype's design holds unchanged. Two earlier positions move: today's /d/<id> addresses are removed rather than kept, and the "nobody tracks you" flavour of the serving guarantee is dropped for company patches, since the viewer is signed in and the door already knows they opened the page.
Addresses
/<company>/<patch>[/route] for every patch at every tier, now. Allison: the company route is nicer and a minor addition; /d/<id> is a leftover from an earlier product and, since nothing is live, it is removed, not redirected. Versions live at /<company>/<patch>/~v/<n>[/route]. Under an address every segment starting with ~ is Patchy's; nothing else is reserved, so a patch may have a route called /v. /<company> alone is 404 for now; company surfaces later live under /<company>/~…. The owner-only and group shapes (company/user/patch, company/group/patch) arrive with those sharing scopes, not on this map.
One per-company namespace for patch names, user handles and group handles, first-come. Users have no handles yet; the future effort inherits the rule that a handle cannot be a live patch name, which is what keeps /acme/alex/report unambiguous.
The name. A name per patch, unique among live patches in a company, the company handle's grammar (3–32 characters, lowercase letters, digits, hyphens; uniqueness by database index, never a check before insert). The name never identifies the patch: create versus update is the publish decision's id in patchy.json or the file's cached patch. Repo mode: name in patchy.config.ts, a taken name refused with name_taken on create and rename alike, the agent edits config. File mode: --name, else derived from the file name (normalised to the grammar, patch when nothing survives, truncated to leave room for a suffix), -2, -3 on collision so "publish this" never stops; re-publishing the same file updates the same patch and never takes a new suffix. Rename moves the address and leaves a redirect from the old name, stored against the patch id, until another patch takes that name, when the redirect is deleted and never resurrected. Delete frees the name. Existing patches are backfilled from their titles in creation order.
The content URL is by id, never by name. The shell resolves the human address once, binds the broker and the frame to a patch id and a version id, and frames /~content/<patchId>/<versionId>: internal, unprinted, non-redirecting, carrying that version's tier and CSP, the same door as the shell, and caching keyed to sharing (a minute at most for a public patch's current version, never for a doored page). A rename between resolving the version and fetching the bundle can therefore never serve another patch's bytes under a bound broker; there is no unversioned content URL, so a publish mid-load cannot hand bundle n+1 a broker bound to n.
Tier 0 keeps srcdoc and sandbox="". Only versions at tier 1 or above get the content URL; the agent skill reads a public tier 0 page by fetching its address and would otherwise have to follow the frame. Two rendering branches in one shell renderer, keyed on the version's tier; a historical version renders with its own tier and CSP.
The broker and its operations
Stable operation names with identifier arguments, one transport-neutral shape: tables.list { table, … }, tables.get, tables.getMany, tables.insert, tables.insertMany, tables.update, tables.delete; shared.list { alias, … }, shared.get, shared.getMany; files.put { store, name }, files.get, files.list, files.delete; postgres.list { connection, relation, … }, postgres.get, postgres.getMany, postgres.query { connection, sql, params, shape }; me. Resource names are arguments, never part of the operation name, so the per-operation schemas already decided on the tables ticket stay the contract. The shell validates every runtime request with the same packages/api schemas the server uses, then forwards it to one endpoint, POST /api/runtime/call, carrying the shell-bound patch id, version id, the bootstrap principal and the wire version, with the session cookie and the exact shell Origin. The server dispatches through the loaded version's manifest with live authorisation on every call. Browser-owned ops (route.set, download) are answered in the shell and never forwarded; route.set refuses a ~ first segment. Adding an operation touches the schema and the server, never the broker. The dev runtime exposes the same endpoint.
Bytes. The envelope gains an optional transferred ArrayBuffer on request and reply; ownership transfers. Over HTTP, files.put and files.get ride raw-body PUT and GET routes that go through the same dispatch, binding, principal and wire checks and differ only in encoding; the file GET is no-store so every retrieval is authorised live. The SDK adds files.<store>.url(name), bytes turned into a cached blob URL for <img src>. Per-file cap is a spec value.
Viewer claims.me is a server-answered runtime op, never inlined in the shell page (the public shell is cached and identical for everyone); the shell may cache the answer per page load. Shape: { user: { id, name, email }, company: { id, handle, name }, admin: boolean } | null. admin is a UI hint only; admin status grants no extra patch permission.
Public tier 1: no company capability, for anyone. A public version refuses every runtime op with not_available_on_public, member or not, with me as the one explicit exception answering null. The public shell runs the broker (Patchy's own script, never analytics) and stays cacheable. A company that wants an authenticated tool publishes it company-scoped. Allison: go with this for now, expecting to change it later; noted on the map as a later revisit, not fog.
Errors, notices, identity
One error type in the SDK with code and message: the per-operation codes already listed plus session_expired, principal_changed, not_available_on_public, shell_outdated, unknown_outcome, rate_limited, too_many_requests, too_large, timeout. The shell shows its own small non-suppressible notice for access-class refusals only (access_denied including a revoked connection or an unshared table, session_expired, principal_changed), so a patch that swallows errors never looks broken and the viewer is told plainly that this is their access; validation errors are the patch's to show.
Identity is bound at bootstrap. The shell records the principal from me and sends it on every runtime call. The server refuses before execution with principal_changed when the cookie's user differs and session_expired when there is none; both notices lead to a whole-page reload after sign-in, a fresh document and broker, and running code never receives another principal's authority. Already-dispatched work may complete under its original principal; its reply is never delivered to a new document. The SDK never replays a mutation; a request that left the shell with no reply is unknown_outcome, distinct from a refusal, because a lost reply does not mean the write failed. Access loss gets the notice and no reload offer, since signing in again cannot repair a removed shared table.
What tier 1 does not support
Said plainly in the skills: outbound fetches of any kind (the content CSP is default-src 'none' with explicit allowances for inline script and style and blob:/data: images, fonts and media, plus sandbox allow-scripts allow-modals); popups and target=_blank; top navigation; in-frame downloads except the shell op; persistent client storage (the opaque origin makes localStorage, IndexedDB and cookies throw; tables and files are the storage); service workers and workers; camera, microphone and geolocation by explicit Permissions-Policy denial; external links. Clipboard write is granted as a user-triggered interaction with a visible failure path, verified per browser.
The one channel to verify (astra). A frame can navigate itself to an outside URL, and a destination answering 204 receives the URL's data without replacing the document, so revoking the broker on the next load catches nothing. The shell page's own CSP already carries frame-src 'self', which browsers enforce on the child's navigations including self-initiated ones and redirects; that is the containment. Acceptance check on the build: script-initiated navigation, redirects and 204 responses from inside the frame, in Chromium and Firefox, must be blocked by the shell's frame-src. If a browser fails it, the promise below narrows to "nothing outside except by navigating away" and the docs say so. Safari remains Allison's hand-check when a Mac is available.
The promise
Tier 1's sentence, for docs/product.md and the serving glossary: "A tier 1 patch acts as you, only through Patchy, and never holds your login. What you do inside it can be saved in its own tables, which your colleagues can read, and every write is logged for your company's admins. It reaches outside systems only through your company's integrations." Tier 0 keeps "the patch cannot watch you". Allison: the tracking worry belonged to the old product; a viewer is signed in to Patchy and the door records that they opened the patch, so the guarantee should not pretend otherwise. The serving guarantee's "unwatched by the patch" becomes tier-scoped; its public-shell line becomes "a public shell runs only Patchy's own shell script, never analytics"; share-a-link-never-be-found, open to machines and cache keyed to sharing stay as they are.
Wire version, no transport version
The envelope's v is the runtime wire version the bundle declared at bootstrap; there is no separate broker version. The shell forwards the negotiated wire version on every call; the server refuses before dispatch. Three stale states, distinguished by the shell: a stale shell with a supported bundle (a bounded refresh that bypasses the cached shell, never an unconditional reload that can loop on a cached public shell); a bundle whose wire is retired (the "needs rebuild" door); a persistent mismatch (a visible terminal failure).
Dev serves production
patchy dev runs Vite in build-watch mode producing the same single-file bundle publish would, serves it at the dev shell's by-id content URL with the production CSP, sandbox and broker, swaps the bundle atomically and reloads the whole shell at the current route after each build (the document-bound broker grants no second handshake, so reloading only the frame would strand it). No HMR; the persona is an agent that rebuilds and screenshots. Patch code that fetches, uses localStorage or opens a popup fails in dev exactly as in production. The SDK's transport is postMessage in both environments; HTTP lives only between the shell and the runtime.
Attribution
Every mutation through tables and files is logged as one row: acting user, patch, version, operation, resource, time, execution outcome (never reply delivery or session state); no bodies, no reads; the same admin-only table as the integration call log. Allison: minimal logging was a Patch Page thing; companies value auditability. Retention stays out of scope as the integration ticket said.
Bounds
Spec values, enforced at two points with their own codes: the shell bounds outstanding requests and bytes held per frame (too_many_requests, too_large); the server bounds per-viewer per-patch calls per minute, request size, and query and file duration (rate_limited, too_large, timeout). Values go in the spec beside the tables bounds.
Wire, for the spec
POST /api/runtime/call with { patchId, versionId, principal, wire, op, args }, answering { ok: true, value } or { ok: false, error, code }; PUT and GET /api/runtime/files/<patchId>/<versionId>/<store>/<name> for bytes, same checks, no-store.
Envelope on the port: request { v, id, op, args, bytes? }; reply { v, id, kind: "result" | "error", value | error, bytes? }; streams and cancel reserved as the prototype wrote them; bootstrap { v, kind: "bootstrap", nonce, route } answered by ready { wire, nonce }.
patches gains name; a patch_names table (company_id, name, patch_id, current) with a unique index on (company_id, name) holds the live name and the redirects; the runtime log table gains mutation rows.
Three exchanges. Moved me on: public tier 1 for members (it argued the settled boundary; adopted); operation names embedding resources (dropped for identifier arguments); a name-based content URL (now by id); frame-only reload in dev (now whole shell); no mutation logging (now minimal attribution); allow="" as a deny (now explicit denials); in-flight calls "failing" on identity change (now refused before execution, completed work never misreported); an unconditional reload on a stale shell (now three states); the missing bounds question; the missing identity-change question; the 204 navigation channel, which turned "you would see it leave" into the frame-src acceptance check. Held against it: dropping HMR (its objection was the lifecycle, fixed by the whole-shell reload); tier 0 staying on srcdoc. Its earlier tier-2 warnings (unary transport as the abstraction, cookie-of-the-moment as principal, no attribution, always-current shell) are each answered above.
What other tickets inherit
Write the SDK spec, now unblocked: everything above. Glossary: address, name, shell, content URL, broker, envelope, route bridge, principal, runtime log; the Page and Serving guarantee entries rewritten tier-scoped; docs/product.md § Addresses rewritten (no /d/), § Tier 1 with the promise, § Tier 0 with the shell-script line. Hit every surface: the CLI prints addresses and gains --name; the patchy skill's reading section and its lock hash; ADR-0004 for --name and the new codes; docs/API.md; RESERVED_HANDLES stays as it is (d may drop). Build acceptance: astra's list from the frame prototype plus the frame-src navigation check, login, logout and account switch mid-session, a stale public shell, the 2,000-row print.
Clears the map's human-readable addresses fog. Adds to Out of scope: an authenticated mode of a public patch (Allison expects to revisit); user and group addresses (they inherit the shared-namespace rule).
Activity
allisonmahmood commentedon Sep 10, 2026
Resolved 2026-09-10 with Allison. Two rounds: eleven questions on the runtime, then four on addresses after Allison pulled human-readable addresses into this ticket. Each round was pressure-tested with astra first (three exchanges; its review is summarised at the end). Everything below sits on top of the decisions the ticket cites; the frame prototype's design holds unchanged. Two earlier positions move: today's
/d/<id>addresses are removed rather than kept, and the "nobody tracks you" flavour of the serving guarantee is dropped for company patches, since the viewer is signed in and the door already knows they opened the page.Addresses
/<company>/<patch>[/route]for every patch at every tier, now. Allison: the company route is nicer and a minor addition;/d/<id>is a leftover from an earlier product and, since nothing is live, it is removed, not redirected. Versions live at/<company>/<patch>/~v/<n>[/route]. Under an address every segment starting with~is Patchy's; nothing else is reserved, so a patch may have a route called/v./<company>alone is 404 for now; company surfaces later live under/<company>/~…. The owner-only and group shapes (company/user/patch,company/group/patch) arrive with those sharing scopes, not on this map.One per-company namespace for patch names, user handles and group handles, first-come. Users have no handles yet; the future effort inherits the rule that a handle cannot be a live patch name, which is what keeps
/acme/alex/reportunambiguous.The name. A
nameper patch, unique among live patches in a company, the company handle's grammar (3–32 characters, lowercase letters, digits, hyphens; uniqueness by database index, never a check before insert). The name never identifies the patch: create versus update is the publish decision's id inpatchy.jsonor the file's cached patch. Repo mode:nameinpatchy.config.ts, a taken name refused withname_takenon create and rename alike, the agent edits config. File mode:--name, else derived from the file name (normalised to the grammar,patchwhen nothing survives, truncated to leave room for a suffix),-2,-3on collision so "publish this" never stops; re-publishing the same file updates the same patch and never takes a new suffix. Rename moves the address and leaves a redirect from the old name, stored against the patch id, until another patch takes that name, when the redirect is deleted and never resurrected. Delete frees the name. Existing patches are backfilled from their titles in creation order.The content URL is by id, never by name. The shell resolves the human address once, binds the broker and the frame to a patch id and a version id, and frames
/~content/<patchId>/<versionId>: internal, unprinted, non-redirecting, carrying that version's tier and CSP, the same door as the shell, and caching keyed to sharing (a minute at most for a public patch's current version, never for a doored page). A rename between resolving the version and fetching the bundle can therefore never serve another patch's bytes under a bound broker; there is no unversioned content URL, so a publish mid-load cannot hand bundle n+1 a broker bound to n.Tier 0 keeps
srcdocandsandbox="". Only versions at tier 1 or above get the content URL; the agent skill reads a public tier 0 page by fetching its address and would otherwise have to follow the frame. Two rendering branches in one shell renderer, keyed on the version's tier; a historical version renders with its own tier and CSP.The broker and its operations
Stable operation names with identifier arguments, one transport-neutral shape:
tables.list { table, … },tables.get,tables.getMany,tables.insert,tables.insertMany,tables.update,tables.delete;shared.list { alias, … },shared.get,shared.getMany;files.put { store, name },files.get,files.list,files.delete;postgres.list { connection, relation, … },postgres.get,postgres.getMany,postgres.query { connection, sql, params, shape };me. Resource names are arguments, never part of the operation name, so the per-operation schemas already decided on the tables ticket stay the contract. The shell validates every runtime request with the samepackages/apischemas the server uses, then forwards it to one endpoint,POST /api/runtime/call, carrying the shell-bound patch id, version id, the bootstrap principal and the wire version, with the session cookie and the exact shell Origin. The server dispatches through the loaded version's manifest with live authorisation on every call. Browser-owned ops (route.set,download) are answered in the shell and never forwarded;route.setrefuses a~first segment. Adding an operation touches the schema and the server, never the broker. The dev runtime exposes the same endpoint.Bytes. The envelope gains an optional transferred
ArrayBufferon request and reply; ownership transfers. Over HTTP,files.putandfiles.getride raw-bodyPUTandGETroutes that go through the same dispatch, binding, principal and wire checks and differ only in encoding; the fileGETisno-storeso every retrieval is authorised live. The SDK addsfiles.<store>.url(name), bytes turned into a cached blob URL for<img src>. Per-file cap is a spec value.Viewer claims.
meis a server-answered runtime op, never inlined in the shell page (the public shell is cached and identical for everyone); the shell may cache the answer per page load. Shape:{ user: { id, name, email }, company: { id, handle, name }, admin: boolean } | null.adminis a UI hint only; admin status grants no extra patch permission.Public tier 1: no company capability, for anyone. A public version refuses every runtime op with
not_available_on_public, member or not, withmeas the one explicit exception answering null. The public shell runs the broker (Patchy's own script, never analytics) and stays cacheable. A company that wants an authenticated tool publishes it company-scoped. Allison: go with this for now, expecting to change it later; noted on the map as a later revisit, not fog.Errors, notices, identity
One error type in the SDK with
codeandmessage: the per-operation codes already listed plussession_expired,principal_changed,not_available_on_public,shell_outdated,unknown_outcome,rate_limited,too_many_requests,too_large,timeout. The shell shows its own small non-suppressible notice for access-class refusals only (access_deniedincluding a revoked connection or an unshared table,session_expired,principal_changed), so a patch that swallows errors never looks broken and the viewer is told plainly that this is their access; validation errors are the patch's to show.Identity is bound at bootstrap. The shell records the principal from
meand sends it on every runtime call. The server refuses before execution withprincipal_changedwhen the cookie's user differs andsession_expiredwhen there is none; both notices lead to a whole-page reload after sign-in, a fresh document and broker, and running code never receives another principal's authority. Already-dispatched work may complete under its original principal; its reply is never delivered to a new document. The SDK never replays a mutation; a request that left the shell with no reply isunknown_outcome, distinct from a refusal, because a lost reply does not mean the write failed. Access loss gets the notice and no reload offer, since signing in again cannot repair a removed shared table.What tier 1 does not support
Said plainly in the skills: outbound fetches of any kind (the content CSP is
default-src 'none'with explicit allowances for inline script and style andblob:/data:images, fonts and media, plussandbox allow-scripts allow-modals); popups andtarget=_blank; top navigation; in-frame downloads except the shell op; persistent client storage (the opaque origin makeslocalStorage, IndexedDB and cookies throw; tables and files are the storage); service workers and workers; camera, microphone and geolocation by explicit Permissions-Policy denial; external links. Clipboard write is granted as a user-triggered interaction with a visible failure path, verified per browser.The one channel to verify (astra). A frame can navigate itself to an outside URL, and a destination answering 204 receives the URL's data without replacing the document, so revoking the broker on the next load catches nothing. The shell page's own CSP already carries
frame-src 'self', which browsers enforce on the child's navigations including self-initiated ones and redirects; that is the containment. Acceptance check on the build: script-initiated navigation, redirects and 204 responses from inside the frame, in Chromium and Firefox, must be blocked by the shell'sframe-src. If a browser fails it, the promise below narrows to "nothing outside except by navigating away" and the docs say so. Safari remains Allison's hand-check when a Mac is available.The promise
Tier 1's sentence, for
docs/product.mdand the serving glossary: "A tier 1 patch acts as you, only through Patchy, and never holds your login. What you do inside it can be saved in its own tables, which your colleagues can read, and every write is logged for your company's admins. It reaches outside systems only through your company's integrations." Tier 0 keeps "the patch cannot watch you". Allison: the tracking worry belonged to the old product; a viewer is signed in to Patchy and the door records that they opened the patch, so the guarantee should not pretend otherwise. The serving guarantee's "unwatched by the patch" becomes tier-scoped; its public-shell line becomes "a public shell runs only Patchy's own shell script, never analytics"; share-a-link-never-be-found, open to machines and cache keyed to sharing stay as they are.Wire version, no transport version
The envelope's
vis the runtime wire version the bundle declared at bootstrap; there is no separate broker version. The shell forwards the negotiated wire version on every call; the server refuses before dispatch. Three stale states, distinguished by the shell: a stale shell with a supported bundle (a bounded refresh that bypasses the cached shell, never an unconditional reload that can loop on a cached public shell); a bundle whose wire is retired (the "needs rebuild" door); a persistent mismatch (a visible terminal failure).Dev serves production
patchy devruns Vite in build-watch mode producing the same single-file bundle publish would, serves it at the dev shell's by-id content URL with the production CSP, sandbox and broker, swaps the bundle atomically and reloads the whole shell at the current route after each build (the document-bound broker grants no second handshake, so reloading only the frame would strand it). No HMR; the persona is an agent that rebuilds and screenshots. Patch code that fetches, useslocalStorageor opens a popup fails in dev exactly as in production. The SDK's transport is postMessage in both environments; HTTP lives only between the shell and the runtime.Attribution
Every mutation through tables and files is logged as one row: acting user, patch, version, operation, resource, time, execution outcome (never reply delivery or session state); no bodies, no reads; the same admin-only table as the integration call log. Allison: minimal logging was a Patch Page thing; companies value auditability. Retention stays out of scope as the integration ticket said.
Bounds
Spec values, enforced at two points with their own codes: the shell bounds outstanding requests and bytes held per frame (
too_many_requests,too_large); the server bounds per-viewer per-patch calls per minute, request size, and query and file duration (rate_limited,too_large,timeout). Values go in the spec beside the tables bounds.Wire, for the spec
POST /api/runtime/callwith{ patchId, versionId, principal, wire, op, args }, answering{ ok: true, value }or{ ok: false, error, code };PUTandGET /api/runtime/files/<patchId>/<versionId>/<store>/<name>for bytes, same checks,no-store.{ v, id, op, args, bytes? }; reply{ v, id, kind: "result" | "error", value | error, bytes? }; streams andcancelreserved as the prototype wrote them; bootstrap{ v, kind: "bootstrap", nonce, route }answered byready { wire, nonce }.patchesgainsname; apatch_namestable(company_id, name, patch_id, current)with a unique index on(company_id, name)holds the live name and the redirects; the runtime log table gains mutation rows./<company>/<patch>[/route],/<company>/<patch>/~v/<n>[/route],/~content/<patchId>/<versionId>;/d/*removed.Astra's review, in short
Three exchanges. Moved me on: public tier 1 for members (it argued the settled boundary; adopted); operation names embedding resources (dropped for identifier arguments); a name-based content URL (now by id); frame-only reload in dev (now whole shell); no mutation logging (now minimal attribution);
allow=""as a deny (now explicit denials); in-flight calls "failing" on identity change (now refused before execution, completed work never misreported); an unconditional reload on a stale shell (now three states); the missing bounds question; the missing identity-change question; the 204 navigation channel, which turned "you would see it leave" into theframe-srcacceptance check. Held against it: dropping HMR (its objection was the lifecycle, fixed by the whole-shell reload); tier 0 staying onsrcdoc. Its earlier tier-2 warnings (unary transport as the abstraction, cookie-of-the-moment as principal, no attribution, always-current shell) are each answered above.What other tickets inherit
docs/product.md§ Addresses rewritten (no/d/), § Tier 1 with the promise, § Tier 0 with the shell-script line. Hit every surface: the CLI prints addresses and gains--name; thepatchyskill's reading section and its lock hash; ADR-0004 for--nameand the new codes;docs/API.md;RESERVED_HANDLESstays as it is (dmay drop). Build acceptance: astra's list from the frame prototype plus theframe-srcnavigation check, login, logout and account switch mid-session, a stale public shell, the 2,000-row print.proto/frame-broker(proto(serving): sandboxed frame and shell broker on one host (#175) #185) andprototype/init-tier1(prototype(sdk): patchy init --tier 1, dev over PGlite, publish with manifest #187) stay until the build tickets have lifted what they need.Clears the map's human-readable addresses fog. Adds to Out of scope: an authenticated mode of a public patch (Allison expects to revisit); user and group addresses (they inherit the shared-namespace rule).