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
The repo and dev loop on both tiers: the Preact scaffold, init --tier 2, server/, the two-artifact publish and dev on the production engine #301
What does the tier 2 repo look like, and how does the dev loop run it? With the init/dev prototype in hand:
patchy init --tier 2: the tree it lays down, server/ and its scaffold, the Preact scaffold on the client (decided on the contract ticket: Preact 10 with signals on both tiers, JSX through jsxImportSource, preact/compat loaded once by patchy/preact so patch code keeps React idioms with no React package and no aliasing, no @preact/preset-vite), what changes in the tier 1 scaffold, generated client and skills to match (tier 1's move to Preact rides this map by decision on 2026-09-21 and may open the build), what an existing vanilla tier 1 repo sees on patchy refresh, the project skills added, and the AGENTS.md guidance for the split.
The build: one HTML bundle and one server bundle per version, both produced by the CLI; the import check that resolves bare imports only to patchy and the release's pinned allowlist on both bundles, with its file-addressed message ("copy it into src/ or ask Patchy for the capability"); package.json dependencies checked against the release at publish; the server refusing a bundle with unresolved imports.
The manifest: handler descriptors, the server bundle's hash, the wire version the server bundle speaks.
patchy dev: handlers executed in the production engine over PGlite with the same callback path; per-tab identities for testing multi-user flows; logs an agent can read; how a rebuild swaps the server bundle and what happens to open subscriptions.
Publish: the evident-tier check for server/, the two-artifact upload, the refusals, and the --json shape.
Moving a live tier 1 patch to tier 2: the rewrite the server-only client implies, the skill guidance, and whether the CLI helps.
Every surface in Hit every surface: README, ADR-0004, the global and project skills, docs/API.md.
Inputs: the server function contract, the execution service decision, the init/dev prototype. Output: the repo, CLI and dev loop sections of the spec.
From the reactive queries resolution (2026-09-22): tier 1 gets list.subscribe and get.subscribe on the table client, on the same contract as tier 2 subscriptions; the Preact scaffold and the tier 1 skill carry the subscribed-screen facts (render the whole result each time, a get wakes at table grain, a permanent error ends the subscription with the last value kept).
From the execution service resolution (2026-09-25): patchy dev runs the same loader Worker and workerd binary as production, with the local runtime as the callback host, so a handler's execution is compatible with Fargate; it does not reproduce the task's containment (no supervisor watchdog, no pool), and the dev-loop skill says so. The loader Worker and the supervisor are therefore a package the dev loop reuses, part of the package cut on the spec ticket.
changed the title [-]The tier 2 repo and dev loop: init, server/, the two-artifact publish and dev on the production engine[/-][+]The repo and dev loop on both tiers: the Preact scaffold, init --tier 2, server/, the two-artifact publish and dev on the production engine[/+]on Sep 21, 2026
From the patch identity resolution (2026-09-23): two refusals land on the CLI here: patchy share --share public (and the portal's scope change) while the served version is tier 2, and publishing a tier 2 version to a public patch without --share company in the same publish; each needs a plain message, a --json code and an exit code under ADR-0004. patchy dev runs handlers with the machine token's user as the viewer and writes no runtime-log rows, as today.
From the init/dev/publish prototype resolution (2026-09-25): write the recipe from PR #380 rather than re-deciding it: the tier 2 tree (server/, src/main.tsx + src/App.tsx, patchy/preact loading compat once, exact pins in dependencies, jsx: react-jsx + jsxImportSource: preact beside oxc.jsx.importSource, modulePreload off, workerd as a devDependency spawned from the platform package with scripts off), the import check on both graphs, the two-artifact publish with server-side re-derivation in a throwaway process, patchy dev on the loader Worker with two viewer mounts as two loopback listeners. Decide here: refresh on a new server/ file plus a dev restart (the watcher enumerates modules at startup) or a watcher that re-enumerates; the --json shapes (url and colleagueUrl on dev; publish naming both artifacts and the handler inventory); a content-addressed release tarball URL, because pnpm caches a URL tarball by URL and a re-published release with the same version installs stale bytes; the promise wording for a CPU-spinning handler in dev (execution compatibility with recovery by health probe, not termination parity); tier 1's move to the Preact scaffold (the branch left tier 1 vanilla with the skill served). Acceptance work named by astra: TLS-backed ctx.connections (unexercised: the connect path wants verify-full and a non-superuser role), dev reads of shared-table fixtures from handlers, stored two-viewer attribution in the dev runtime log.
Grilled with Allison on 2026-09-27 in one round. Astra reviewed the draft round first and corrected three of my recommendations. Refresh already writes the patchy pin, so the pins needed an owner. The workerd devDependency is part of the recipe #314 accepted. A watcher that writes generated files would give generation two owners. Allison accepted all five questions and the eleven defaults. This comment is the repo, CLI and dev loop section of the spec. The recipe PR #380 proved (the tree, the two-artifact publish with server-side re-derivation, dev on the loader Worker with two listeners) is written as built and not re-decided here.
Decided
Refresh owns the release's managed pins.package.json pins exact versions of the packages the release names: patchy, the allowlist entries (today preact and @preact/signals) and, on tier 2, workerd. refresh writes only those keys and leaves every other field alone. It adds the workerd pin when the tier becomes 2 and removes it when the tier drops. After a release or a tier change, the agent runs refresh and the repo is back on the release. Publish refuses a mismatched pin with release_mismatch ("run pnpm patchy refresh"). The allowlist ticket decides what the list holds and what an off-list dependency is told.
refresh alone writes the generated server module list. Dev reads server/ live. The generated client imports each server/ file's types by name. When a server/ file is added, deleted or renamed, dev's watcher re-reads server/ for its own server build, so the handler is callable with no restart. Dev logs new server module leads: run pnpm patchy refresh for types. Only refresh regenerates the client. Publish refuses a stale module list with stale_generated, the rule stale config declarations already follow. Config changes still take effect on dev stop/start, as today.
The global skill picks tier 1 by default. It picks tier 2 in three cases. The first is a tool that enforces rules: at tier 1 any viewer can write any row the page can, from devtools, so a rule like "only managers approve" is advisory. The second is a write that must change several rows atomically. The third is work that has to happen on the server, such as combining connection data before the viewer sees it. Live sync is not a reason, because tier 1 has subscriptions. Sequential steps are not a reason either, because tier 1 can call operations in sequence. Allison wants this wording tested later by having many agents build patches and checking which tier they pick.
Changing tier is a config edit plus refresh, both ways. Neither direction gets a codemod or a dedicated command.
Tier 1 to 2. Set tier: 2 and create the server/ modules. Run refresh, which adds the workerd pin, patchy/_generated/server.ts and the patchy-server skill. The tier 2 generated client has no direct tables or files, so tsc lists every call to move into a query or mutation. Publish, with --share company if the patch is public.
Tier 2 to 1. Set tier: 1 and rewrite the patchy.server.* calls, which tsc lists because the tier 1 client has no server. Delete server/ and run refresh, which removes the managed tier 2 artifacts: the pin, the generated server file and the patchy-server skill. That removal is the one exception to sticky skills, and it is keyed to the tier. Serving a tier 1 version, by publish or rollback, makes public sharing possible again. The sharing checks read the served version's tier, never local config.
A "moving tiers" section in patchy-loop carries these steps. This clears the map's fog item on moving a live tier 1 patch.
A server rebuild in dev re-runs open subscriptions live. Both tiers get the colleague mount.
A rebuild binds the bundle and its descriptors together as one new binding.
Admitted calls, including nested ctx.run, finish on the binding they were admitted on.
Every open subscription re-runs on the new binding as a wake. Dev discards a run that finishes after the swap and runs it again.
A removed handler, or a change to args or result that breaks a re-run, ends the subscription with a permanent error, as in production. The shell reload that follows the agent's src/ edit recovers it.
A failed build or an import refusal is logged, and the last good binding keeps serving.
A src/ rebuild reloads the whole shell, as today.
The second listener, with the fixture colleague as a non-admin member, runs on tier 1 as well as tier 2. The primary mount is the machine token's user. Tabs on the same listener share its identity.
Defaults accepted
Tier 1 moves to Preact.init lays down the The server function contract: queries, mutations, actions, the context object and the generated client #296 point 14 scaffold on tiers 1 and 2; tier 0 is unchanged. The import check runs on tier 1's page code too, which closes npm to tier 1 as the destination decision intended. refresh never rewrites src/. A vanilla repo keeps working on the framework-free core client. Nothing is live, so there is no migration. patchy-preact is served on tiers 1 and 2.
Versions keep their wire. Each version already stores wire_version. For tier 2, wire 1 also fixes the protocol between the server bundle's guest entry and the loader Worker, and the workerd compatibility date. The spec promises that stored versions keep running on the wire they were built for. The retirement policy (notice, republish, what rollback shows) is designed when a second wire ships, and the spec marks it deferred.
Tier 2 with zero handlers publishes with a warning. Declaring a higher tier than the code needs is already allowed. server/ below tier 2 stays tier_mismatch.
A server/ export that is not a handler, or a descriptor the grammar rejects, is invalid_manifest (exit 1).
The server re-derives the handlers from the stored bytes. A disagreement, a throw at module load, or a load that does not finish is invalid_manifest (exit 2).
The server bundle must be one closed module with no dynamic imports. The server refuses anything the loader cannot resolve.
Page code may import from server/ only as types, and the client-graph check enforces that.
publish on every tier gains artifacts: { html: { sha256, bytes } }, computed over the bytes uploaded.
Tier 2 adds artifacts.server: { sha256, bytes } and handlers: [{ name, kind }], sorted by name. Both keys are absent below tier 2.
dev gains colleagueUrl on tiers 1 and 2.
The release tarball URL carries the full content digest of its bytes. Every advertised tarball stays retrievable, and integrity matches the bytes at that URL. pnpm caches by URL, so a rebuilt release with the same version string can no longer install stale bytes. refresh already rewrites the pin when the URL changes.
What dev promises. The dev-loop skill and patchy-server say this: "patchy dev runs the same handler engine and callback path as production. It does not reproduce production's scheduling, limits or containment. A handler that spins forever times out, and a health check restarts the dev engine, which can interrupt other calls in flight."
Acceptance cases, kept separate. Handlers read shared-table fixtures in dev. Handlers read connection fixtures in dev. ctx.connections works over TLS verify-full with a non-superuser role. The dev log attributes each call to its viewer. The TLS case does not prove the two fixture cases.
AGENTS.md at init describes the src/ and server/ split in words that hold on either tier, because refresh never rewrites it.
Surfaces the build updates:
packages/patchy/README.md
ADR-0004: the new code, the --json fields and the refresh write set
The global patchy skill (init --tier 2, the tier choice) and its hash in skills-lock.json
The patchy-loop, patchy-server and patchy-preact project skills
docs/API.md: the publish request's server artifact, the release URL and tier2_not_public
The repo-internal patchy-dev-loop skill: containment and the colleague mount on both tiers
docs/product.md: Declaring and changing a tier, and the publish and dev paragraphs
Glossary terms for the spec (drafted here, written at the spec ticket)
Managed pin: a dependency version in a patch repo's package.json that the release names and refresh writes. The builder never edits it.
Server bundle: the single closed module a tier 2 version's server/ builds into. It is stored beside the HTML bundle and described in the manifest by its hash and handler descriptors.
Colleague mount: the second local listener patchy dev opens, serving the patch as a fixture non-admin member so two-viewer flows can be tested on one machine.
Spec (Write the tier 2 spec and file the build tickets #305): the sections above, points 7 and 14 as named deferrals and acceptance items, and a tier-picking check. That check has fresh agents build several patches from the global skill and records the tier each one picks.
Grilled by Claude Fable 5.1 via Claude Code with Allison, astra as the design pair, 2026-09-27.
Activity
[-]The tier 2 repo and dev loop: init, server/, the two-artifact publish and dev on the production engine[/-][+]The repo and dev loop on both tiers: the Preact scaffold, init --tier 2, server/, the two-artifact publish and dev on the production engine[/+]allisonmahmood commentedon Sep 23, 2026
From the patch identity resolution (2026-09-23): two refusals land on the CLI here:
patchy share --share public(and the portal's scope change) while the served version is tier 2, and publishing a tier 2 version to a public patch without--share companyin the same publish; each needs a plain message, a--jsoncode and an exit code under ADR-0004.patchy devruns handlers with the machine token's user as the viewer and writes no runtime-log rows, as today.allisonmahmood commentedon Sep 25, 2026
From the init/dev/publish prototype resolution (2026-09-25): write the recipe from PR #380 rather than re-deciding it: the tier 2 tree (
server/,src/main.tsx+src/App.tsx,patchy/preactloading compat once, exact pins independencies,jsx: react-jsx+jsxImportSource: preactbesideoxc.jsx.importSource,modulePreloadoff,workerdas a devDependency spawned from the platform package with scripts off), the import check on both graphs, the two-artifact publish with server-side re-derivation in a throwaway process,patchy devon the loader Worker with two viewer mounts as two loopback listeners. Decide here:refreshon a newserver/file plus a dev restart (the watcher enumerates modules at startup) or a watcher that re-enumerates; the--jsonshapes (urlandcolleagueUrlon dev; publish naming both artifacts and the handler inventory); a content-addressed release tarball URL, because pnpm caches a URL tarball by URL and a re-published release with the same version installs stale bytes; the promise wording for a CPU-spinning handler in dev (execution compatibility with recovery by health probe, not termination parity); tier 1's move to the Preact scaffold (the branch left tier 1 vanilla with the skill served). Acceptance work named by astra: TLS-backedctx.connections(unexercised: the connect path wantsverify-fulland a non-superuser role), dev reads of shared-table fixtures from handlers, stored two-viewer attribution in the dev runtime log.allisonmahmood commentedon Sep 27, 2026
Resolution
Grilled with Allison on 2026-09-27 in one round. Astra reviewed the draft round first and corrected three of my recommendations. Refresh already writes the
patchypin, so the pins needed an owner. TheworkerddevDependency is part of the recipe #314 accepted. A watcher that writes generated files would give generation two owners. Allison accepted all five questions and the eleven defaults. This comment is the repo, CLI and dev loop section of the spec. The recipe PR #380 proved (the tree, the two-artifact publish with server-side re-derivation, dev on the loader Worker with two listeners) is written as built and not re-decided here.Decided
package.jsonpins exact versions of the packages the release names:patchy, the allowlist entries (todaypreactand@preact/signals) and, on tier 2,workerd.refreshwrites only those keys and leaves every other field alone. It adds theworkerdpin when the tier becomes 2 and removes it when the tier drops. After a release or a tier change, the agent runsrefreshand the repo is back on the release. Publish refuses a mismatched pin withrelease_mismatch("runpnpm patchy refresh"). The allowlist ticket decides what the list holds and what an off-list dependency is told.refreshalone writes the generated server module list. Dev readsserver/live. The generated client imports eachserver/file's types by name. When aserver/file is added, deleted or renamed, dev's watcher re-readsserver/for its own server build, so the handler is callable with no restart. Dev logsnew server module leads: run pnpm patchy refresh for types. Onlyrefreshregenerates the client. Publish refuses a stale module list withstale_generated, the rule stale config declarations already follow. Config changes still take effect on dev stop/start, as today.refresh, both ways. Neither direction gets a codemod or a dedicated command.tier: 2and create theserver/modules. Runrefresh, which adds theworkerdpin,patchy/_generated/server.tsand thepatchy-serverskill. The tier 2 generated client has no directtablesorfiles, sotsclists every call to move into a query or mutation. Publish, with--share companyif the patch is public.tier: 1and rewrite thepatchy.server.*calls, whichtsclists because the tier 1 client has noserver. Deleteserver/and runrefresh, which removes the managed tier 2 artifacts: the pin, the generated server file and thepatchy-serverskill. That removal is the one exception to sticky skills, and it is keyed to the tier. Serving a tier 1 version, by publish or rollback, makes public sharing possible again. The sharing checks read the served version's tier, never local config.patchy-loopcarries these steps. This clears the map's fog item on moving a live tier 1 patch.ctx.run, finish on the binding they were admitted on.src/edit recovers it.src/rebuild reloads the whole shell, as today.Defaults accepted
initlays down the The server function contract: queries, mutations, actions, the context object and the generated client #296 point 14 scaffold on tiers 1 and 2; tier 0 is unchanged. The import check runs on tier 1's page code too, which closes npm to tier 1 as the destination decision intended.refreshnever rewritessrc/. A vanilla repo keeps working on the framework-free core client. Nothing is live, so there is no migration.patchy-preactis served on tiers 1 and 2.wire_version. For tier 2, wire 1 also fixes the protocol between the server bundle's guest entry and the loader Worker, and the workerd compatibility date. The spec promises that stored versions keep running on the wire they were built for. The retirement policy (notice, republish, what rollback shows) is designed when a second wire ships, and the spec marks it deferred.server/below tier 2 staystier_mismatch.import_refused(exit 1). Its message is the one Prototype: patchy init --tier 2, server/, dev on the production engine and a two-artifact publish #314 settled.server/export that is not a handler, or a descriptor the grammar rejects, isinvalid_manifest(exit 1).invalid_manifest(exit 2).server/only as types, and the client-graph check enforces that.tier2_not_public(exit 2). The first ispatchy share --share public, or the portal's scope change, while the served version is tier 2. The second is publishing a tier 2 version to a public patch without--share company.--jsonshapes.publishon every tier gainsartifacts: { html: { sha256, bytes } }, computed over the bytes uploaded.artifacts.server: { sha256, bytes }andhandlers: [{ name, kind }], sorted by name. Both keys are absent below tier 2.devgainscolleagueUrlon tiers 1 and 2.integritymatches the bytes at that URL. pnpm caches by URL, so a rebuilt release with the same version string can no longer install stale bytes.refreshalready rewrites the pin when the URL changes.dev.loglines. Each call gets one line: viewer, handler, outcome and ms, then itsctx.loglines. In dev only, ahandler_failedline also carries the thrown message and stack. The browser still sees only the refusal. Dev writes no runtime-log rows (The patch identity at tier 2: authority, attribution and the served-version rule for direct writes #300), which replaces Prototype: patchy init --tier 2, server/, dev on the production engine and a two-artifact publish #314's "stored two-viewer attribution" wording.dev logs --jsonkeeps its current{ ok, log, text }shape.patchy-serversay this: "patchy devruns the same handler engine and callback path as production. It does not reproduce production's scheduling, limits or containment. A handler that spins forever times out, and a health check restarts the dev engine, which can interrupt other calls in flight."ctx.connectionsworks over TLSverify-fullwith a non-superuser role. The dev log attributes each call to its viewer. The TLS case does not prove the two fixture cases.AGENTS.mdat init describes thesrc/andserver/split in words that hold on either tier, becauserefreshnever rewrites it.packages/patchy/README.md--jsonfields and the refresh write setpatchyskill (init --tier 2, the tier choice) and its hash inskills-lock.jsonpatchy-loop,patchy-serverandpatchy-preactproject skillsdocs/API.md: the publish request's server artifact, the release URL andtier2_not_publicpatchy-dev-loopskill: containment and the colleague mount on both tiersdocs/product.md: Declaring and changing a tier, and the publish and dev paragraphsGlossary terms for the spec (drafted here, written at the spec ticket)
package.jsonthat the release names andrefreshwrites. The builder never edits it.server/builds into. It is stored beside the HTML bundle and described in the manifest by its hash and handler descriptors.patchy devopens, serving the patch as a fixture non-admin member so two-viewer flows can be tested on one machine.Handed on
Grilled by Claude Fable 5.1 via Claude Code with Allison, astra as the design pair, 2026-09-27.