Repository navigation
Description
Charted on the Portal map (2026-09-12 to 2026-09-15). This issue is the deployed-stage spec: every shape decision the build implements, assembled from the map's Notes and its closed tickets, which hold the reasoning. The build runs from the sub-issues at the end, one PR and one agent session each, staged so discovery lands first; main stays green throughout. Mid-build decisions go back to the map as grilling tickets, not into PR threads.
Problem Statement
A signed-in person landing on / sees a marketing page; the only way to find a colleague's tool is a link someone pasted. An agent asked "do we already have a tool for this" or "which patch has the tables I need" has catalog, which lists shared tables without the patches behind them. A patch published once lives 90 days unless someone visits it, then vanishes; the owner's only exit is a delete with no way back; nobody but the owner can touch a patch, so a departed colleague's tool is stuck; and the address of a patch that is off tells a colleague nothing. The portal, the lifecycle, admin authority and agent discovery are four landings of one state model, and the model is what is missing.
Solution
One inventory, several views. A patch is live, retired or deleted, with three moves (retire, delete, restore) and a 30-day recovery window; expiry goes. The signed-in / is a two-column portal: a compact index of the company's patches beside one patch's card at /patches/<name>, which is catalog plus manage, never the patch itself. Owners edit the description, sharing and served version on the card and confirm retire, delete, a broken restore and reassign on pages under it; admins do everything an owner can on any patch except publish. Deactivating a user offers to retire their patches with the damage listed; reactivation mirrors it. The agent reads the same inventory through one patchy list with drill-down to a patch's tables, stores, reads and connections, under the machine token, seeing only what it can use; catalog goes. Every page Patchy renders for a signed-in member shares one app shell and one component set.
User Stories
- As a member, I want
/to show me my company's patches, mine first, with a line that says what each does, so that I find a tool without asking who built it. - As a member, I want to click a patch and see its address, owner, sharing and what reads it, so that I know what I am opening and who to ask about it.
- As a member opening a retired colleague's link, I want a notice saying who retired it and that it can be restored, so that a dead link is not a mystery.
- As an owner, I want to fix the description in the browser and have my repo pick it up the next time my agent runs, so that the portal and the code never disagree for long.
- As an owner, I want to change who can open a patch on the card, with a hint that this does not govern tables, so that I never believe a radio button protects data.
- As an owner, I want to put an older version back at the address with one click and know that tables and the description do not move, so that a bad publish is undone in seconds.
- As an owner, I want to retire a patch and get it back later exactly as it was, so that shelving a tool is not deleting it.
- As an owner, I want delete to keep the patch 30 days and to be told the day it is gone for good, so that deleting the wrong thing is recoverable.
- As an owner, I want retire, delete and unshare to name the patches that read my tables and refuse until I acknowledge the breakage, so that I never break a colleague's tool by accident.
- As an owner restoring a patch whose source is off, I want to be told it will come back broken, so that restore is never a surprise.
- As an owner, I want the same retire, delete, restore, rollback and describe verbs in the CLI with
--json, exit codes and--force, so that my agent can manage a patch it built. - As an owner whose page was open while someone else acted, I want the action refused with a line saying who did what, and nothing done, so that two people never fight over one patch.
- As an admin, I want every patch in the company on my portal with the owner's controls, so that a tool nobody owns anymore is not stuck.
- As an admin, I want to reassign a patch to an active member, myself included, so that I can take it over and publish from the repo.
- As an admin deactivating a user, I want their live patches listed with what depends on each, and the choice to leave them, retire some or retire all, so that I decide what breaks rather than discovering it.
- As an admin reactivating a user, I want the mirror: restore some or all of their retired patches, warned when one comes back broken.
- As a member, I want a deactivated owner's patch marked so on the card and in
patchy list, so that I know nobody can publish to it. - As an agent, I want
patchy listto show my company's patches with ids, states, owners and descriptions, yours first, so that "do we have a tool for this" is one call. - As an agent, I want
patchy list <patch>to show its tables, stores and what it reads, with a copy-readyaddline only where a declaration path exists, so that I never learn a command that cannot work. - As an agent, I want
patchy list <patch> <table>to show columns, indexes and the schema revision, never rows, so that I can judge a dependency without a data read. - As an agent, I want a patch I cannot open to be absent and not-found rather than doored, so that a listing never leaks and never mints access.
- As an agent, I want a publish to a patch that belongs to a colleague refused with their name and never a suggestion to create a new patch, so that I do not fork the tool.
- As an agent, I want a publish to a retired patch refused with "restore it or ask an admin", not "remove it from patchy.json", so that I do not fork the tool that way either.
- As an agent writing a table, I want the description to be the first argument of
table()and a notice when the definition changed but the description did not, so that what a table is for stays true. - As a person, I want Company, Connections, Your machines and the portal to look like one product with one set of buttons, fields and notices, so that I always know what a control does.
Implementation Decisions
Settled on the map's tickets; each build ticket names the ones it implements. Where a ticket left a name, a value or a package boundary to the spec, it is here and listed under Further Notes.
1. The shape in one paragraph
A patch has one row and three states a person sees, live, retired, deleted; gone is the sweep having run (lifecycle). Three gates: serving (live and not disabled) for the address, shared reads and the runtime; openable (same company, not gone, not disabled, and within the credential's sharing reach) for the card, GET /api/patches… and patchy list, in any state; publishable (openable, owner, live) for publish, with not_owner, patch_retired and patch_deleted as the refusals, never a 404 inside the company (prototype). Manage is the owner or an admin; publish is the owner only. The owner acts on their patches from the CLI and the portal; an admin does every owner act except publish, from the portal only (admin authority). Off is off for everything, so a retired or deleted source denies its consumers on their next read and restore brings them back; every act that breaks a dependant lists it and refuses unless forced. The portal is master-detail at / and /patches/<name> with inline edits and confirmation pages (list mocks, page mocks); the agent's view is patchy list with a positional path over the same query (discovery); the description is local-owned with a sync (metadata). First-party pages stay server-rendered on one app shell and one component set.
2. Packages and services
One package is born; four gain code. Each still owns its migrations and its HttpApi group; apps/server is wiring.
| package | owns |
|---|---|
patches |
the lifecycle: the state columns and actor stamps, the three gates (serving, openable, publishable), retire, delete, restore, rollback, reassign, describe and their dependant and source checks, the reserved names, the deletion sweep (replaces the expiry sweep), the read query behind the portal and patchy list, the patches API group's new routes, the retired and ownership publish refusals |
primitives |
primitive descriptions in the manifest, the inventory and the additive diff; the table-or-store name collision |
integrations |
the connections API group: the connection list and one connection's snapshot, replacing the catalog's connection half |
sdk |
catalog removed from the group, the CLI and the project skills; the skills teach descriptions and the discovery chain |
patchy |
list, retire, delete (dependants, --yes, --force), restore, rollback, describe, publish --description; patchy.json's description and descriptionSyncedAt and the pull-down; the primitive-change reminder; init --purpose writing the description; the retired and ownership refusals as the agent reads them |
core |
the component set and the app shell body in htmlPage; auth's pageResponse gains the app mode and the header |
portal (born) |
the signed-in / and /patches/<name> with its six sub-routes, the deactivation and reactivation pick and confirmation pages under /company/users/:id, the stale-action rule; the Portal context and glossary |
serving |
the address notice for a retired or deleted patch; / and the catch-all handed to one owner; 414 on an overlong ref |
companies |
the Deactivate and Reactivate buttons become links to the portal's pick pages; Users.deactivate/reactivate run inside the portal's one transaction |
api |
every wire shape below |
Direction: portal → patches, companies, auth, core; serving → patches, auth (unchanged); patches → companies for user names on rows (a join, no service call); integrations unchanged. No package imports portal. One file per service in the conventions' order; dependencies from the environment.
3. The lifecycle
From the lifecycle, amended by admin authority (restore warns) and the prototype (expiry goes, two predicates).
- States and moves. Live, retired, deleted, derived from two stamps:
deleted_atset is deleted; elseretired_atset is retired; else live. Retire from live; delete from live or retired (a delete from retired keepsretired_atfor the notice's history and setsdeleted_at); restore from retired or deleted clears both stamps and always lands live, and a restore from deleted requiresnow < purgeAt(past it the answer ispatch_deletedeven if the sweep has not run yet, so the sweep is the only mover after the window). A move from any other state, and a rollback or scope change on a patch that is not live, iswrong_state(409) naming the current state; nothing is done. - Expiry goes. No
expires_at, no publish reset, no visit top-up, no "never reviving". A patch is off only because someone took it off. - The recovery window is 30 days from the delete, fixed.
deleted_at + 30 daysispurgeAt, carried on the wire and never computed twice. Past it the deletion sweep reclaims the patch: under the platform row lock it rechecks the row is still deleted and past the window, queues the object keys durably, deletes the versions, the names and the row in one platform transaction, then drops the company-database namespace and its file objects; a crash between the two leaves a namespace with no row, which the existing orphan sweep drops after a day. Restore takes the same row lock, so it either finds the row and its namespace or finds nothing; it can never revive a hollow patch. The sweep also reclaims orphaned publish objects as today. Gone is not a state; after the sweep there is no card, no row and no notice, and the address is 404. - Names stay reserved until gone. Retire and delete free nothing; restore always gets its address back. A publish under a reserved name is
name_takenthroughout the window. Rename redirects are untouched by retire and delete and dropped at gone, as a claim by another patch drops them today. - Off is off. A retired or deleted patch does not serve, and every consumer of its shared tables gets
access_deniedon its next read, whole call, its own rows untouched, exactly as a deleted source does today. Restore brings consumers back with no action on their side, because declarations bind the patch id. Nothing physically changes under a retire or a delete-in-window: tables, files, versions, the inventory and sharing flags stay; only the reclaim at gone drops them. - Rollback moves
current_version_idto any retained version of the same patch, in place, creating no version; the next publish moves it forward again. It never touches data, cumulative provisioning, sharing flags, the description or the name. A rolled-back version renders with its own tier and wire; a retired wire shows the needs-rebuild door. No new refusals: a gone source readsaccess_deniedat runtime like any dead source. All versions are kept; no cap, no pruning. - Dependants. Retire, delete from live, and a publish that flips a shared table to
shared: falsecompute the live dependants (distinct patches with a live declaration across retained versions, by patch name and owner, as today's unshare count does) and refuse unless forced:has_dependants(409) with the list. Portal: an acknowledgement checkbox on the confirmation page. CLI: the list and exit 2;--forceproceeds. The refusal text tells the agent to ask its user before forcing. Delete from retired lists nothing: the dependants already broke at retire. - Restore warns when the sources the restored patch's current version declares are retired, deleted or gone (what would actually error when served; older versions' reads are a listing matter only):
sources_off(409) with each source's patch id, name when it still exists, table and state,goneincluded. Portal: the/restorepage with the acknowledgement. CLI:patchy restorerefuses with the list;--forceproceeds. A restore whose sources are all live is one button, no page. - Who. The owner on their own patches; admins on every patch in the company. Retire, delete, restore and rollback in the CLI are owner-only (the machine token is the owner's); admin acts happen in the portal only. Delete asks the portal actor to type the patch name and the CLI for
--yes. disabled_at/disabled_reasonstay the operator's take-down: never owner-restorable, hidden from every list, and the address 404s as today. Disable is the operator's word; retire is the owner's; deactivate is a user's.
4. Authority
From admin authority.
- Admins do every owner act on any company patch except publish: retire, delete, restore, rollback, change sharing, reassign, describe. Publish stays owner-only because it needs the repo; it is accountability (one named person behind each version), not a boundary against admins, and the docs say so. Company controls admins already hold are unchanged; integrations stay admin-only.
- Reassign to any active user of the company, the acting admin included, never a deactivated user. Per-version attribution is untouched. No notification; there is no mail. Portal only. A patch always has an owner, possibly deactivated; nothing must be reassigned before a deactivation.
- The old owner's agent. A publish, share, retire, delete, restore, rollback or describe from a same-company member who is not the owner is refused
not_owner(403) naming the current owner: "This patch belongs to Sam. Ask them, or an admin, to reassign it." It is definitive (the saved publish attempt is forgotten), the patch id stays inpatchy.json, and the message never suggests creating a new patch. Another company's member keeps the 404 that confirms nothing. The server checks ownership when the version commits, atomically with the update, so a publish authorised before a reassignment cannot land after it. - Publish to a retired patch is
patch_retired(409): "This patch is retired. Restore it (patchy restore) or ask an admin." A deleted-in-window patch answerspatch_deleted(409) withpurgeAtand the same advice; both are definitive refusals. Neither says to removepatchfrompatchy.json; a gone patch is the 404 that does. The lifecycle is checked where ownership is: before the bytes and again when the version commits, under the row lock, so a publish authorised while live cannot land after a retire.not_owneris evaluated first, then the state, so a non-owner is never told to restore what they cannot. - Members see resulting state, not intervening acts: the current owner, the owner-deactivated mark, the actor and date on the retired and deleted notices, and the description's actor line. No history on any page.
- Machine tokens reach the read routes and the owner verbs; the portal admits browser sessions only; the API stays token-only (prototype 8). One query serves both.
5. Stale actions and actor stamps
From the prototype 3 and 4.
- Each act gates on its own precondition, carried as a hidden field on the portal form and checked in the same transaction as the act: retire needs live; delete needs not-deleted; restore needs off; rollback the expected current version; reassign the expected owner; scope the expected scope; description the expected
description_updated_at(a no-op save stamps nothing). A description save never refuses because of an unrelated rollback. The CLI verbs carry no expectation except rollback's target and description's text; they act on the current row. - A stale form answers 409 and re-renders the card with a fresh hidden field and one notice: "This patch changed while you had this page open: retired by Sam 2 minutes ago. Nothing was done." The notice always names the person and the act, from
last_changed_by/at: retired, deleted, restored, rolled back to v7, sharing changed, description changed, reassigned. No codes, no "revision". - Every act stamps
last_changed_byandlast_changed_atbeside its own actor columns, so every notice can say who. Own columns:retired_at/by,deleted_at/by,reassigned_at/by,description_updated_at/by; restore, rollback and scope stamp only the shared pair. The Effect clock stamps every column the portal displays, so a test can wind them together. - An inline restore that finds
sources_off(the sources went off after the card was drawn) answers 409 with the/restoreconfirmation page, not the card. Validation failures answer 422 and redisplay the posted page with the submitted text: a typed-name miss says "Typenameto confirm. Nothing was done." A member's POST to Manage is 403 with the card and "Only the owner or an admin can do that. Nothing was done."
6. The description and primitive descriptions
From metadata, amending the destination and discovery; retired cards from the prototype 7.
The patch description is local-owned with a sync. It lives in patchy.json as description beside the instance and patch id, CLI-written, committed, agent-editable; init --purpose writes it there (and the purpose into AGENTS.md, independent, no sync). The manifest carries it; every repo publish sends it; the patches row stores it with description_updated_by/at. Portal and describe edits pull down: whenever the CLI talks to the cloud for the repo (refresh, dev, publish), it compares the cloud's description_updated_at with patchy.json's descriptionSyncedAt (a timestamp, never old text); if the cloud moved, the CLI writes the cloud text into patchy.json, prints "The description was changed in the portal to '…'; check it" (quoting the replaced local text when it differed), and records the new stamp. Publish records the returned stamp as synced. Rollback and restore never touch it; edits create no version; existing patches backfill empty.
- File mode:
patchy publish page.html --description "…"applies on every publish where given; omitted, the cloud value stands. In a repo the flag is refused, pointing atpatchy.json. patchy describe "<text>",describe <file> "<text>",describe "<text>" --patch <id>,describe [<file>] --clear [--patch <id>], following theshare/deletetarget rules; never creates a patch; returns the cloud's normalised text; in a repo rewritespatchy.jsonin the same run.--clearrather than an empty positional; whitespace-only text is refused.- Bound: 500 Unicode code points after collapsing whitespace runs and trimming; one paragraph; no control characters; markup stored literally and escaped on render; never truncated.
initrefuses an over-long--purposewith the count and the bound (interactive: re-prompt). Required non-empty inpatchy.json; the cloud value may be empty. - Empty: the portal shows a muted "No description" with the form for the owner or an admin; JSON always carries
"description": ""; text prints(no description). Never the title or the purpose in its place. - Editable while live or retired, from the card's form and
describe; deleted-in-window is refused with the state; shared access grants no edit right.PUT /api/patches/:patchId/description { description }, last-write-wins, owner via token; the portal form takes the same path through the service for owner or admin. - Attribution: one muted "Description edited by X on date" line under the description on the card; nothing in the index; no history.
- The index line cuts the description at the first
.,;or–and at 80 characters with an ellipsis; the description hint on the card and in the skills says to front-load what the tool does. - No icon, category or tags.
Primitive descriptions are config-owned. table("Each row is one lunch order placed by a person for a day", { …columns }, { indexes, shared }) and files("Receipt photos, one per order"): the description is the first argument so it cannot be skipped; required non-blank in the manifest schema; table and store level only, no column descriptions. Mutation mirrors columns: a publish that defines the primitive replaces its description, omission preserves it, rollback never changes it. The inventory stores it beside the definition. The reminder: at refresh, dev and publish, for every table or store whose definition (columns, indexes, shared flag) differs from the last generated manifest while its description is byte-identical, the CLI prints "Table orders changed since its last generation; check that its description still holds: '…'". Notice only; publish proceeds. The patchy-tables and patchy-files skills teach what a good description says (what one row or object is, its identifying keys, units).
7. Discovery: patchy list
From discovery, amended by the prototype 5, 6 and 8. There is no inspect and no catalog.
patchy list patches, yours first then the company's, then connections
patchy list patches identical to bare list
patchy list <patch> the row, then its tables, stores and reads
patchy list <patch> <primitive> one table or store: columns, indexes, sharing, revision
patchy list connections connections only; --all adds offered integrations
patchy list connections <handle> one connection's schema snapshot with its taken-at
<patch>is the canonical id or the name; a name resolves exactly, within the caller's company, to the one non-deleted patch with that name; a deleted-in-window patch is reachable by id only, with--state all. Every output leads with the id; the skills teach agents to carry ids, not names, intoadd. A pasted address resolves by its last segment.- Flags.
--state live|retired|all(defaultlive;alladds deleted-in-window) governs which patches the top level lists and how<patch>resolves at the patch and primitive levels: a name resolves among non-deleted patches, an id among all; a resolved patch whose state lies outside the requested--stateiswrong_state(409 from the API, exit 2) naming its actual state, solist <retired-name>without a flag says "retired; pass--state retired", a deleted id without--state allsays "deleted; pass--state all", and a live name under--state retiredsays "live"; a deleted patch never resolves by name; an unknown, unopenable or gone ref is 404, and only a gone patch ever tells an agent to removepatchfrompatchy.json. The same rule holds at the primitive level.--mineis top level only;--allis connections only; a flag where it does not apply is a local error, not ignored.--jsoneverywhere. No search, filters beyond these, or paging; agents filter--jsonlocally. No slashes inlist; theaddhints keep theirs. - Reserved names.
patchesandconnectionsare refused as patch names at create (reserved_name, 422). Config refuses a table and a file store with the same name (invalid_manifest). - Top level, per patch:
id, name, address, owner { id, name, deactivated }, mine, tier, scope, description, state, retiredAt, deletedAt, purgeAt, currentVersion, publishedAt. Text: id, name, state (deleted, 18 days leftfrompurgeAt), owner with· deactivated,v7, the first line of the description or(no description). No shared-table names at this level. Connections inline as a third group, merged by the CLI fromGET /api/connections: handle, description, status, theadd postgres/<handle>line for a connected one, the/company/connectionspointer for a disconnected one. The CLI's--jsonis{ patches, connections }; the two routes stay separate on the wire. - Patch level: the row, then the cumulative inventory, company-readable and openability-gated, as
inventory: { tables, stores } | null(null when the company database is unavailable; text printsTables: unavailable, nevernone), each table and store with name, description, shared,declarable, areasoncode when not (not_shared,not_shareable,source_off) and a humanhint; thenreads: every shared-table declaration across the patch's retained versions (alias, source patch id, its name when it still exists, table, source state includinggone). No versions, no dependants. - Primitive level:
kind, name, description, shared, schemaRevision, columns [{ name, kind, optional, default?, ref? }](an absentdefaultis no default; an explicit one is present,nullincluded),indexes [{ name, columns, unique }]. No row count, no existence flag, no contents. - Connection level: the current immutable snapshot with
takenAt; an unavailable snapshot is reported unavailable, never as an empty database. - Visibility: only the caller's company's patches, public ones included, never another company's. A patch the credential cannot open is absent, and
list <name>on it is the same 404 as an unknown name. Openability is evaluated for the actual credential and the patch's current state; listing mints nothing. Today every company patch is openable by every member, so the rule is written for narrower sharing later. The skill says "no match" means "none you can use" and sends the agent to--state retiredbefore it concludes a tool does not exist. - Hints only where a declaration path exists. Shared table:
patchy add shared-table <patchId>/<table>. Unshared table:not sharedand the owner's name. File store:not shareable yet. Connected connection:patchy add postgres/<handle>. Disconnected:/company/connections(reason: not_connected). JSON carriesdeclarableand thereasoncode;hintis for people, and agents never parse it. - Catalog goes away:
GET /api/sdk/catalog,patchy catalog, its README rows, tests and every skill mention. Its contracts survive inlist.listruns anywhere under the saved login; it is not a repo command. The project skills teach the chain: find candidates by description, drill into the candidate's primitives, check keys and types,addby canonical id.
8. The CLI
Every new verb follows ADR-0004: --json, the exit-code ladder, code on refusals. Targets follow the share/delete rules: the repo id from patchy.json, file mode by file, --patch <id>; conflicting targets refused; an unpublished repo is a local refusal.
| command | behaviour | --json success |
|---|---|---|
patchy list [patches|connections|<patch> [<primitive>]|connections <handle>] [--mine] [--state live|retired|all] [--all] |
§7 | the top level is the CLI's merge { patches, connections }; the other levels are the wire body, no ok wrapper |
patchy retire [<file>] [--patch <id>] [--force] |
Retire a live owned patch; refuses with the dependant list unless forced. | { ok, patchId, state: "retired", retiredAt } |
patchy delete [<file>] [--patch <id>] [--yes] [--force] |
Delete from live or retired; asks for confirmation unless --yes, a CLI-local gate (non-interactive without it is local exit 1; the wire has no yes); from live, refuses with the dependant list unless forced. Forgets file-cache entries only after success. |
{ ok, patchId, state: "deleted", deletedAt, purgeAt } |
patchy restore [<file>] [--patch <id>] [--force] |
Restore to live; refuses with the off sources unless forced. | { ok, patchId, state: "live" } |
patchy rollback <n> [<file>] [--patch <id>] |
Move the address to version n of a live patch; a missing version is rejected, a retired or deleted patch wrong_state. |
{ ok, patchId, currentVersion: n, address } |
patchy describe … |
§6 | { ok, patchId, description, descriptionUpdatedAt } |
patchy publish … [--description <text>] [--force] |
§6; --description is a local refusal in repo mode; --force accepts the breakage of an unshare |
the publish response, which gains description and descriptionUpdatedAt |
Refusal codes an agent branches on (all rejected, exit 2): has_dependants with dependants: [{ patchId, name, owner: { id, name } }]; sources_off with sources: [{ patchId, name?, table, state }] (name absent when the source is gone); wrong_state with state; not_owner with owner: { id, name }; patch_retired, patch_deleted with purgeAt; reserved_name; invalid_description (422). The failure document keeps { ok: false, error, kind, code } and gains those fields beside code. has_dependants and sources_off texts end with "Ask the person you are working for before forcing." A not_owner, patch_retired or patch_deleted refusal on publish is definitive (clears the attempt) and leaves patchy.json alone.
patchy.json becomes { instance, patch?, description, descriptionSyncedAt? }. init writes description from --purpose; a repo without one is invalid_manifest at publish, naming the field.
9. The portal
From the list mocks and the page mocks, as the prototype built them (PR #246, never merged, is the reference implementation for copy and layout, not for code).
Routes, browser session only, every POST a plain form, every page on the app shell:
| route | who | what |
|---|---|---|
GET / |
any member | login door signed out; signed in, the index with the first of Yours selected, else the first live patch, else the empty state |
GET /patches/:name[?all=1] |
any member | the same two columns with that patch's card; a retired or deleted patch shows its off card at the same URL; all=1 shows the Retired and deleted group |
POST /patches/:name/description, /scope, /rollback, /restore |
owner, admin | inline acts; /restore posts directly only when the sources are live |
GET /patches/:name/versions |
any member | the full versions table |
GET+POST /patches/:name/retire, /delete, /restore, /reassign |
owner, admin (/reassign admin only) |
confirmation pages |
GET+POST /company/users/:id/deactivate, /reactivate |
admin | §10 |
An unknown name, another company's name and a gone patch are the app-shell 404. A member's POST to an owner route is 403. An overlong :name is 414. / and the catch-all are registered by the server in one place so registration order cannot decide the root.
The index: name plus the description's first clause, grouped Yours and Company (live patches only) and Retired and deleted (every off patch, whoever owns it) behind a "Show retired and deleted" toggle (a GET link carrying all=1, kept on card links while on). Retired rows carry retired; deleted rows deleted · gone in N days; a deactivated owner's rows carry owner deactivated. Sorted by name within a group. No search, filters or paging; the card is position: sticky so it stays beside a long index. The empty company (no rows in any state) shows one card: "No patches yet", how to publish the first; a company whose only patches are off shows the empty live index with the toggle.
The card, top to bottom: the address line (company / name), the name as h1, the title as one secondary line only when present and not a restatement of the name (never in the index), the description or muted "No description", the description's actor line, Open (to /<company>/<name>) beside the address to copy, then the facts: Owner (with "(deactivated)"), Current version ("v7, published 3 days ago by Sam"), Who can open it ("Anyone at Northwind who signs in. Not the public." / "Anyone on the internet. No sign-in."), Used by other patches (live dependants by table, patch and owner; count plus the first three, "and N more"; or "Nothing else reads this patch"). The card is never the patch and never rides under /<company>/<patch>/….
Manage, for the owner or an admin, split by one rule: an act stays on the card when the same actor can undo it with one click; an act that breaks someone else's tool, or that the actor cannot undo alone, leaves the card for a confirmation page.
- On the card: Description (textarea, 500, hint "The repo pulls this change in the next time it runs
patchy devor publishes. Start with what the tool does."), Who can open it (two radios, People at the company / Anyone on the internet, hint "This governs opening the page only. Which tables other patches may read is declared in code and changes at publish."), Versions (current plus the last three, each older row a Show this version at the address button, hint "The address changes for everyone now. Tables and the description do not move.", "All N versions" to/versions), and on an off card whose sources are live, Restore as one button. - The amber block Stop serving: Retire… ("Keeps everything indefinitely. Nobody can open it until it is restored.") and Delete… ("Keeps it 30 days, then it is gone for good.") as two equal buttons, with the dependant count.
- Admin: an Owner line in the facts with Reassign…, and above Manage "You can do everything an owner can from here, except publish." On a deactivated owner's card an amber notice: "Nobody can publish to this patch. Its owner is deactivated. Reassign it or retire it."
- Member: facts and Open, no Manage.
- Retired card: the state fact ("Retired by Sam, 12 May"), the note "Off the shelf, kept as it was: its tables, files and all its versions are kept for as long as you like; nobody can open
nameuntil it is restored", and for the owner or an admin Restore (button, or/restorelink when sources are off), Delete… ("Delete starts the 30-day clock"), only the description form from Manage, and for an admin Reassign… so a shelved tool can be taken over. Deleted card: "Gone for good in N days. Until then the owner or an admin can restore it; after that the page, its versions, tables, files and the name are all reclaimed", Restore, and Reassign… for an admin. A member's off card is the state fact and the note, with no Open and no acts. After the sweep there is no card and no row.
Confirmation pages, one form each, the consequence in plain words, Cancel back to the card:
/retire: the dependant list ("office-map(Priya) readsorders") and an acknowledgement checkbox; with none, "Nothing else reads this patch" and no checkbox./delete: from live, the same list and checkbox plus the typed name; from retired, no list ("Its readers already lost access when it was retired"), the typed name, and "This starts the 30-day clock"./restore: only when the current version's sources are off; lists each with its actual state (retired, deleted, gone) and says the patch will serve but error when it reads them until they are restored too; acknowledgement. A GET while the sources are live redirects to the card, whose button posts directly./reassign: admins; the active members (a plain GET filter over hundreds), never a deactivated user; the consequence ("Priya can publish, retire or delete it at once; you can reassign it again"). The POST re-checks that the target is an active member of the company (else 409 with the picker) and that the current owner is the expected one; reassigning to the current owner is a no-op that stamps nothing.
10. Deactivation and reactivation
From admin authority, drawn on the page mocks.
- Deactivation itself changes no patch: the user's patches keep serving, marked owner deactivated everywhere a patch is listed. Their access and tokens stop as today.
- The Deactivate button on
/companybecomes a link to the pick pageGET /company/users/:id/deactivate: the user's live patches, each with a checkbox and a static badge listing its live dependants (patch and owner; the user's own marked "theirs"); already retired or deleted patches shown, not selectable; three submits, Keep their patches live (the "leave them all" choice: deactivates at once, no second page), Retire selected, Retire all. Retire selected with nothing checked stays on the pick page with "Select at least one, or keep their patches live." (422). A user with no live patches gets the confirmation directly. - The confirmation page (
POSTwith the selection, re-rendered): recomputed for the exact selection; lists every live dependant not itself in the selection, whichever owner it has (a chain inside the selection shows no breakage; a dependant owned by someone else always does); the acknowledgement when anything breaks, "Nothing breaks" otherwise; confirm commits deactivation and every selected retire in one transaction, each retire ordinary (actor the admin), consumers denied on next read;Users.deactivateandUsers.reactivatetake an optional outer transaction and open their own only when none is given; after this the portal is their only caller. The last-active-admin rule still refuses at the top, on GET and POST. - Reactivation mirrors it:
GET /company/users/:id/reactivatelists the user's retired patches, however they were retired, with Keep them retired, Restore selected, Restore all; the confirmation lists the comes-back-broken warning per patch whose current version's sources are off, where a source that is live or in the same restore selection counts as intact (the mirror of deactivation's chain rule); one transaction. Access returns, fresh tokens required; the deactivated mark lifts on patches the user still owns; reassigned patches stay reassigned; deleted patches stay deleted. - Bulk retire and restore live only here. Later cleanup is per patch from the card; no multi-select on the index.
11. The address notice
From the lifecycle. /<company>/<patch>, its numbered version URLs and its content URL for a retired or deleted patch: an active colleague gets a first-party notice on the app shell (who, when, which state, days left if deleted) with Restore for the owner or an admin (Serving asks Patches whether the current version's sources are off: live sources give a form posting to /patches/<name>/restore, off sources a link to that page; Serving never imports the portal) and a link to the card; a signed-out reader keeps the login door; another company's member keeps the 404; a public patch that is off is doored like a company one (its cache of at most a minute drains on its own). A disabled patch stays 404 for everyone.
12. The app shell and the component set
From the prototype 11 and 12.
- One app shell for every signed-in page: an
htmlPageapp body with the header bar (brand, Patches, Company, Connections, Your machines, the viewer's name and company, Sign out; the current section marked) over a wide card; the portal,/company,/company/connectionsand/machinesall render through it. The sign-in door, create-or-join, the device-login confirm page and error pages keep the auth card: they are doors, not the app. - One component set: buttons (default, primary, quiet, danger), fields (input, select, textarea, checkbox, radio, hint, error), fact lists, notices (plain, warn, refused), section headings, pills, the confirmation form. Every first-party page composes those classes and keeps only layout in page CSS; a page-level override of a component's size, radius or colour is a review finding; patches are exempt. The
ui-consistencyspec's "prefer a shared class when a treatment repeats" becomes "a first-party page introduces no button, field, list, notice or heading style of its own" and names the set. No continuously repainting animation.
13. Schema and the sweep
- Migration
0008_patches_lifecyclein the Patches record, spread into all three migrator call sites:ALTER TABLE patches DROP COLUMN expires_at, ADD COLUMN retired_at TIMESTAMPTZ, retired_by TEXT REFERENCES users(id), deleted_by TEXT REFERENCES users(id), reassigned_at TIMESTAMPTZ, reassigned_by TEXT REFERENCES users(id), description TEXT NOT NULL DEFAULT '', description_updated_at TIMESTAMPTZ, description_updated_by TEXT REFERENCES users(id), last_changed_at TIMESTAMPTZ, last_changed_by TEXT REFERENCES users(id); a partial index ondeleted_atfor the sweep.deleted_atis the recovery clock. The ledger becomes eight records; ADR-0003's table gains the row. The company-database inventory schema gainsdescriptionontablesandstoreswith the primitives ticket, not this migration; nothing is deployed, so that initialisation DDL changes in place and dev databases are recreated. - The deletion sweep replaces the expiry sweep on the same hourly schedule and bounds: rows with
deleted_at + 30 days <= now, batched and recheckedFOR UPDATE(still deleted, still past the window), queue object keys durably, delete versions, names and the row in the platform transaction, then drop the namespace and its file objects through Company database's reclamation; a namespace left behind by a crash is an orphan the existing sweep drops after a day. Orphan reclamation is otherwise unchanged. Everyexpires_atmirror goes: the visit top-up,notExpired, the retention-clock glossary terms, the README, skill and doc lines the repo research listed. - The read query (one, in
patches): rows for a company joined with owners (name, deactivated), the current version's number and publish time, the dependant edges, the reads, and, per patch, the cumulative inventory through the company database when it exists (null when it is unavailable). The portal andGET /api/patches…both call it with the credential's openability predicate; connections never enter it.
14. The wire
| route | admits | body / query | answers |
|---|---|---|---|
GET /api/patches?mine&state |
bearer | state live (default), retired, all |
{ patches: [PatchSummary] } |
GET /api/patches/:patchRef?state |
bearer | id or name | PatchDetail = PatchSummary + title, inventory, reads; 404 when unopenable, unknown, foreign or (by name) deleted; wrong_state 409 when a name's only match is retired and state is live; a deleted id needs state=all |
GET /api/patches/:patchRef/primitives/:name?state |
bearer | same resolution | PrimitiveDetail |
GET /api/connections?all, GET /api/connections/:handle |
bearer | { connections, offered? }; { handle, description, status, snapshot: { revision, takenAt, … } | null } |
|
POST /api/patches/:patchId/retire, /restore |
bearer, owner | { force? } |
{ ok, patchId, state, retiredAt? }; has_dependants / sources_off 409, wrong_state 409, not_owner 403 |
DELETE /api/patches/:patchId?force |
bearer, owner | { ok, patchId, state: "deleted", deletedAt, purgeAt } |
|
POST /api/patches/:patchId/rollback |
bearer, owner | { versionNumber } |
{ ok, patchId, currentVersion, address } |
PUT /api/patches/:patchId/description |
bearer, owner | { description } |
{ ok, patchId, description, descriptionUpdatedAt }; invalid_description 422 |
POST /api/publish |
bearer | manifest.description, metadata.description? (file mode), force? |
gains description, descriptionUpdatedAt; not_owner 403, patch_retired / patch_deleted 409, reserved_name 422, has_dependants 409 on an unshare unless force |
GET /api/sdk/catalog |
removed |
Shapes: PatchSummary { id, name, address, owner { id, name, deactivated }, mine, tier, scope, description, state, retiredAt, deletedAt, purgeAt, currentVersion, publishedAt }; PatchDetail.inventory: { tables: [PatchTableSummary], stores: [PatchStoreSummary] } | null; PatchTableSummary { name, description, shared, declarable, reason?, hint? }; PatchStoreSummary { name, description, declarable: false, reason: "not_shareable", hint }; PatchRead { alias, patchId, name?, table, state } with state in live | retired | deleted | gone; PrimitiveDetail as §7; ConnectionSummary { id, handle, integration, description, status, hint, reason? }. Timestamps are ISO strings; a patch's own state is live | retired | deleted; reason is one of not_shared, not_shareable, source_off, not_connected. docs/API.md is rendered from the api package and its test keeps it current. Wire bodies keep their shape: a refusal is { ok: false, error, code, … }.
15. Bounds
| bound | value | where |
|---|---|---|
| recovery window | 30 days from deleted_at, fixed |
server; purgeAt on the wire |
| description | 500 code points, one paragraph | CLI, server, portal form |
| index line | first ., ; or –, at most 80 characters |
portal |
| versions on the card | current plus three | portal |
| dependants on the card | first three plus a count; full lists on confirmations | portal |
| reserved patch names | patches, connections, plus the company handle's reserved words |
server, CLI |
| patch name in a portal URL | the name grammar; longer is 414 | portal, guard |
| retained versions | all; no cap | server |
| sweep batch | 100 per query, 1,000 per run, hourly plus startup, as today | server |
16. ADRs, docs, skills and glossaries each ticket carries
- Amends ADR-0004:
listreplacescatalogin the command table;retire,delete(--yes,--force),restore,rollback,describe,publish --descriptionand their--jsondocuments; the refusal fields besidecode; "delete frees every name" becomes reserved through the window; the 404-on-update rule narrows to a gone patch, withnot_owner,patch_retiredandpatch_deletedas definitive refusals that keeppatchy.json;patchy.json's new fields. ADR-0003: the ledger gains0008, and the "every retention rule has one home" consequence becomes the deletion window's. ADR-0009: the sweep section names the deletion sweep and the row-then-patch lock it takes; the inventory schema gains descriptions. ADR-0002 unchanged. Writes no ADR: nothing here is hard to reverse or surprising without the product doc. Deletes nothing. docs/product.md: § Built today; § Sharing and finding (the portal as built,patchy list); § Updating, retiring, deleting rewritten as the three states; § Users, admins, groups and § Ownership and deactivation (the admin set, the pick page); § Access to a patch (admins manage, not publish); § Addresses (names reserved); § Building a patch (patchy.json, the description, the reminder, the refusals); the catalog paragraph; § Versions and publishing (rollback). The spec session records the decided shape ahead of the build; each ticket turns its paragraph from decided into built.CONTEXT-MAP.md: Portal (packages/portal) added; Patches loses "retirement remains future work" and gains the lifecycle; Publishing loses catalog. Glossaries: Patches (Retire, Delete, Restore, Rollback, Recovery window, Deletion sweep replaces Expiry sweep, Retention clock and Patch expiry removed, Description, Dependant, Reassignment, Owner and Live patch reworded); Portal (new: Portal, Index, Card, Manage, Confirmation page, Acknowledgement, Pick page, App shell, Component set, Stale action); Serving (Address notice); Companies (Deactivation gains the pick); Publishing (Catalog removed, Inventory listing, Description sync); Primitives (Definition gains the description).- The global
patchyskill:listfor "do we have a tool for this", the link-to-name note, the visibility caveat, retire/delete/restore/rollback/describe, the description inpatchy.json, the reserved names;skills-lock.jsonrefreshed by hand. The five project skills: descriptions as the first argument, the discovery chain, the sync notice and the reminder inpatchy-loop, everycatalogmention removed; the starterAGENTS.mdsays which file holds which text.packages/patchy/README.md,docs/API.md,docs/DEVELOPMENT.md(the seed's states and descriptions), thepatchy-dev-loopskill,README.md's layout,skills/patchy/references/welcome-patch.html(no "quietly retired" after inactivity), theui-consistencyspec. - Every ticket walks Hit every surface and names which entries applied.
Testing Decisions
A good test asserts what a caller sees: the response, the rows a transaction left, the document and exit code a command produced, the page a session received. Never the SQL.
- Seams.
it.layerover the migrated template for the lifecycle, the read query and the sweep, withTestClockwinding the 30 days;HttpApiTest.groupsfor the new routes and refusals;NodeHttpServer.layerTestwith the seeded session for every portal page and the address notice; the CLI suite for each verb's text and--jsondocument; the packed e2e for the agent contract. Faults through alternate layers: a company database that is unavailable during the read (the inventory is reported unavailable, not empty), a sweep whose store deletion fails (the keys stay durably queued and are retried, as today) and one whose namespace drop fails (the orphan sweep takes it a day later). - What is tested where. Patches: every move from every state, including the refused ones; names reserved through delete and freed by the sweep; dependants computed across retained versions and excluded when in the same selection; restore's off-source list with each state; rollback moving only the pointer; the ownership check inside the publish commit racing a reassign; the retired and deleted publish refusals;
last_changed_by/aton every act; the sweep reclaiming exactly the rows past the window with locks held. Primitives: a blank description refused; a redefinition replacing it; omission preserving it. Portal: each act's precondition refusing with the 409 notice and nothing done; the member/owner/admin views of one card; retired and deleted cards; the typed-name delete; the pick page's badges and the confirmation's recomputed breakage for three selections (nothing, a chain inside, a dependant outside); the transaction committing deactivation and retires together or not at all. Serving: the notice for colleague, signed-out and foreign readers on the address, a version URL and the content URL. Discovery: visibility for an unopenable patch (absent and 404), the name resolving only to non-deleted patches,--stateat each level, reads listed from older versions, hints only where declarable, thecatalogroute gone. CLI:describerewritingpatchy.json, the pull-down notice onrefresh, the reminder firing only when the definition changed and the text did not,--forceand--yes. - The packed e2e adds: publish two patches where the second reads the first's shared table;
list,list <first>,list <first> orders;retirerefused with the dependant,--force; the address notice;restore;rollback 1;describeand the pull-down on the nextrefresh.
Out of Scope
Kept out on the map; each returns as its own effort: source recovery (#229); owner-only and group sharing, so the openability predicate is written but every company patch is openable today; shared file stores (#243); a client-side framework; a hosted builder, a cloud working copy, an operator console (disable stays a SQL statement), usage analytics, a cross-company gallery; search, filters and paging on the index and in list; a version-prune setting; an audit log beyond actor columns; notification mail; a portal API for admin acts; personal-patch takedown on deactivation; tier 2, a second integration and billing.
Further Notes
Calls the spec makes on its own (not grilled; amend here if wrong; a second model reviewed the draft and the three gates, the lifecycle checked at publish commit, restore and the sweep sharing the row lock with the row deleted before the namespace, --state as a resolution rule at both levels, gone on the wire, reason codes, inventory: null, connections kept off the patches route, restore's sources from the current version, the reactivation chain rule and the deactivation transaction are its corrections; --state reaching the primitive level amends the prototype's amendment 8, which would have made a deleted patch's table unreachable): the package cut, in particular a portal package for the signed-in pages rather than pages inside patches or serving, and the connection reads as an integrations-owned connections group; the route and field names in §8 and §14; the codes wrong_state, has_dependants, sources_off, not_owner, patch_retired, patch_deleted, reserved_name, invalid_description; DELETE keeping its verb with a force query and --yes staying CLI-local; rollback by version number on the wire; the migration name and its columns, including one last_changed pair rather than an event table; the derived state with deleted_at winning; the sweep deleting the row before the namespace (the second reviewer preferred namespace first; row first was kept because patch ids are never reused, the object keys are queued before the row goes, and the existing orphan sweep is the backstop, so restore under the row lock never meets a hollow patch and an interrupted run needs no special state); Reassign… on off cards for admins, amending the page mocks' off card; the reminder computed against patchy/_generated/manifest.json rather than a new stamp; the index-line cut; three dependants on the card; the empty-company card; "Keep their patches live" deactivating without a second page; a patch with no live patches skipping the pick page; the pick and confirmation pages living in portal while Companies keeps the user services; the notice's Restore posting to the portal's route; the patches → companies join for owner names; purgeAt as the only clock on the wire; the app shell's section names; the component list in §12.
Facts for the build from the prototype: Effect's router keeps the first handler registered at a path, so / and /* must be added by one layer; docs/API.md is asserted equal to the rendered PatchyApi, so every route change regenerates it; a per-package migration record is not a self-contained history once a later capability has landed, so 0008 is applied after 0007 in Runtime's replay test; the seed's create rate limit (PATCHY_PATCH_CREATE_RATE_LIMIT_PER_MINUTE) pauses a twelve-patch seed once; TestClock at epoch zero never lines up with SQL now(), so every displayed stamp goes on the Effect clock.
Skills every build session consults: effect-service-conventions and node_modules/effect/AGENTS.md before Effect code; ui-consistency for every rendered page; patchy-dev-loop to prove a change; Hit every surface before calling a ticket done. Skill content handed to patch-building agents never compares Patchy to another product.
Build order
One sub-issue each, filed ready-for-agent, blocking wired as native dependencies (the real ones, so independent tickets run in parallel; the numbering is the recommended order). Discovery lands first: the model, primitive descriptions, the read routes, the connections group and patchy list are the first five; the portal follows on the shell. Filed from Write the deployed-stage spec and file the build tickets on 2026-09-15 after two review passes by a second model. Every ticket states what its merge admits and what stays refused, so main never accepts a promise it cannot enforce: 1 leaves a retired or deleted address at 404 until 11; 4 removes the catalog route while 5 removes the command, so 4 merges with 5 ready behind it; 8 owns / and /patches/:name and its destructive links answer 404 until 9; 10 replaces Companies' one-click buttons.
- feat(patches): the lifecycle model: expiry goes; retired and deleted states, the recovery window, names reserved, the owner verbs on the wire, the deletion sweep (the prefactor; owns migration
0008and the schemas of its own routes) - feat(primitives): primitive descriptions in the config, manifest and inventory; the name collision, beside 1
- feat(patches): the read path:
GET /api/patchesat its three levels, the company-readable inventory, reads, after 1 and 2 - feat(integrations): the
connectionsgroup: the connection list and one connection's snapshot; the catalog route removed, beside 3 - feat(patchy):
patchy listreplacescatalog; the global and project skills teach the discovery chain, after 3 and 4 - feat(patchy):
retire,delete,restore,rollback,describeand the description sync;init --purpose; the primitive-change reminder; the retired and ownership refusals, after 1 and 2 - feat(core): the component set and the app shell; Company, Connections and Your machines move onto it; the
ui-consistencyspec tightened, beside 1 - feat(portal):
/and/patches/<name>: the index, the card, the inline acts, versions, the stale-action rule, after 3 and 7 - feat(portal): the confirmation pages: retire, delete, restore, reassign, after 8
- feat(portal): deactivation and reactivation: the pick page, the confirmation, one transaction, after 9
- feat(serving): the address notice for retired and deleted patches; one owner for
/and the catch-all; 414 on an overlong name, after 8 (the notice posts to the portal's restore route) - ci+docs(domain): the packed e2e through list, retire, restore and rollback; the map after the portal, last
Activity
docs(product): the deployed stage as decided on the portal map (#260)
allisonmahmood commentedon Sep 19, 2026
all merged