Skip to content

feat(patches): each version keeps its repo snapshot, and members can read it - #996

Merged
allisonmahmood merged 2 commits into
mainfrom
repo-snapshots/1-server
Oct 30, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
repo-snapshots/1-server

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changed

Publish stores only a version's built page and, on tier 2, its server module. When an admin reassigns a colleague's patch, the new owner can publish to it but has nothing to edit.

A publish can now carry the repo it was built from, and that version keeps it as a repo snapshot. Anyone the patch is openable for can read it through GET /api/patches/:patchRef/repo, which patchy pull will use. Publishing stays the owner's, and public sharing never exposes a snapshot.

Nothing sends a snapshot yet. The CLI half is the next PR in this stack.

Part of #229. The plan, reviewed by Sol, is on the issue.

Look at

  • Reclamation. The snapshot goes through the same pending-object intent as the HTML and server bundle: prepared before the put, consumed in the version's transaction, skipped by the expired-intent claim once committed, and queued by the purge. One sweep test covers all four steps.
  • Admission (PatchesApi.publish, after replay, as before):
    • Paths are checked by schema: relative POSIX, no ./../empty segments, no backslash or control characters, at most 1,024 bytes.
    • Contents must be padded base64. Effect's Schema.isBase64 overflows the stack on a 10 MiB string, so repo.ts uses a linear check.
    • Paths that collide under case folding or NFC, or that turn a file into a folder, answer 400.
    • More than publish.repo.files (2,000) or publish.repo.bytes (10 MiB, decoded) answers 413. The body cap grows by twice publish.repo.bytes.
  • Pull. It uses detail's resolution, openability gate and state filter, so a retired patch needs state=retired. It returns the served version unless version is given.
    • A page published from one HTML file reads back as that file: a version with a recorded filename and a file publish's shape (tier 1, no server module, tables or stores). The filename is client metadata, so on any other version it answers no_repo rather than hand back HTML without the server code, and it is reduced to a safe basename ending .html.
    • A version with neither answers 404 no_repo, naming the owner.
  • PatchDetail.repo says what a pull would get (optional, so an older instance still decodes). patch.created and patch.updated gain repoFiles and repoBytes.

How it was verified

✓ DeletionSweep > keeps committed repo snapshots past their intents, then reclaims them with the patch
✓ repo snapshots over machine tokens > keeps each version's repo for any colleague to pull, the served one by default
✓ repo snapshots over machine tokens > pulls a file-born page as one safely named file, and nothing from anything else
✓ repo snapshots over machine tokens > refuses a repo that can't be written into one folder, or over its limits

Those tests cover:

  • The stored object, sorted by path.
  • Version pinning, and the served version after a rollback.
  • The detail.repo field.
  • The wrong-state answer for a retired patch, and the same 404 for another company's patch as for a missing one.
  • Every 400 and 413, with nothing recorded.

Two body-cap tests moved to the new cap. pnpm check passes format, lint, typecheck and synth. Its CLI suites failed here on stray GET / requests hitting their stub ports while two other worktrees' dev supervisors were running on this machine. Rerun alone, a different set failed for the same reason. This PR doesn't touch those suites; CI is the clean run.

Not exercised against a dev instance yet: no client sends a snapshot until the next PR, which will be walked end to end.

Release impact

  • Breaking — requires action from anyone already running this

  • Not breaking — four nullable columns, an optional request field and a new read route.

  • What does a revert leave behind? Migration 0030 adds four nullable patch_versions columns and an index, which the older release ignores. Any snapshot already stored stays where it is.

  • Does the release before it still work with that? Yes, it serves and publishes as before. Labelled one-way for retention only: once snapshots exist, the older purge deletes version rows without queueing their repo_object_key, so a patch reclaimed while production runs the older release leaves its code in the object store with nothing pointing at it. The plan therefore deploys this in its own release before the CLI starts sending snapshots. Rolling back that later release then lands here, where reclamation knows the key.

Built by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, running in T3 Code; plan reviewed by GPT 6.1 Sol.

@allisonmahmood allisonmahmood added area:server Touches the server area one-way Rolling production back past this PR would break the release before it labels Oct 28, 2026
@github-actions github-actions Bot added area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area area:ui Portal and first-party browser pages, shared rendering and styles size:l 501-1,000 changed lines labels Oct 28, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review by GPT 6.1 Sol: what changed

Sol reviewed this PR at its first commit and found three defects and some missing coverage. All of it is fixed in 2308e77.

  1. Case folding missed some collisions. toLowerCase() keeps ς apart from Σ, and ſ apart from S, so Σ.ts and ς.ts passed even though they collide on a case-insensitive filesystem. The same went for Σ as a file next to ς/file.ts. Paths now fold upper then lower case after NFC. That errs toward calling two names one (ß and SS collide too), which refuses a snapshot rather than letting a pull overwrite a file. repo.test.ts covers each case.
  2. Spike teardown read a new column. scripts/tier2-spike.mjs selected repo_object_key directly, so tearing down a database from before 0029 would fail before deleting anything. It now reads to_jsonb(patch_versions) ->> 'repo_object_key', which is null where the column doesn't exist.
  3. The CHECK let partial records through. repo_file_bytes >= 0 with a NULL is unknown, and a CHECK passes unknown. Both counts are now IS NOT NULL before their bounds. A test nulls each field on a stored version and expects the update to fail.

Missing coverage, now added:

  • An expired intent naming a committed snapshot is never claimed. A snapshot written by a publish whose record then fails (PublishKeyTaken) is claimed along with its HTML.
  • Pull refuses an anonymous request (401), an unopenable patch, a deleted patch named by name, and a disabled patch (404s). A deleted patch named by id still answers 200, as detail does.
  • An identical retry with a repo replays the same version, and the same key with different repo contents is publish_key_conflict.

One more fix found while building the CLI half: the client decoded a no_repo body as the plain 404 and dropped its code, version and owner. NoRepo is now listed first among the endpoint's errors, and the CLI test in #1003 checks that code, versionNumber and owner come through.

Posted by Claude Opus 5.5 via Claude Code for Allison.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Follow-up from the CLI review on #1003: snapshot files now carry an optional executable: true, kept in the stored JSON and returned by pull, so a pulled script still runs (a77f0ab).

Posted by Claude Opus 5.5 via Claude Code for Allison.

allisonmahmood added a commit that referenced this pull request Oct 29, 2026
## What changed

Tier 0 is gone. Stored tier 0 pages become tier 1 pages, served in the
sandboxed frame from their content URL like any other page. Tiers now
count from 1. A repo config that still says `tier: 0` is refused with
the fix, and a tier 0 publish an older CLI left pending is cleared
instead of wedging publishing.

Closes #986 (PR 4 of 4). It lands on main after release 25 (#1045),
which is live.

- **Migration `0029_tier_zero_is_tier_one`** (patches capability). In
one transaction, every `patch_versions` row at tier 0, deleted patches'
included, gets `tier = 1`, `manifest.tier = 1` and
`publish_response.tier = 1`. `payload_digest` is untouched, so a
same-key retry still replays. The CHECK becomes `tier BETWEEN 1 AND 3`.
- **Wire.** `Manifest.tier` and the publish response's `tier` are `1 | 2
| 3`. A raw tier 0 manifest answers `tier_mismatch` before decoding, in
#1045's words; #1045's post-decode check goes with the narrowed type.
Replay runs before release validation, so migrated receipts replay as
they are. `InvalidHtml` leaves the publish contract, because only tier 0
could raise it.
- **Server.**
  - The safe-HTML branch and `PATCHY_MAX_HTML_BYTES` are gone.
- Owner actions keep their own 1.5 MiB request cap, the same value as
before.
  - The publish envelope stays three times both bundle caps.
- **Serving.**
- Every shell frames its version's content URL. The srcdoc path and the
static CSPs are gone, leaving one content policy and one shell policy.
- `PATCH_CONTENT_SECURITY_POLICY` stays for notices, without the
`about:` allowances only srcdoc needed.
  - `framedDocument` stays for `patchy look preview --compare`.
- **CLI.**
  - `init --tier` takes 1 or 2, and the config type is `1 | 2 | 3`.
- A `tier: 0` config gets "Tier 0 is now tier 1. Set `tier: 1` and run
`patchy refresh`." (`tier_mismatch`, exit 1) from config execution
itself, so refresh refuses it too, not only publish and dev. #1045's
`refuseTierZero` goes; it can't see tier 0 through the narrowed type.
- A pending tier 0 attempt is cleared with a message to run `patchy
list` and publish again if the page is missing.
- The tier 0 branches are gone from `repoBuild`, `bundleCheck`,
`devServer` (always `documentTitle`, always a colleague URL),
`initProject`, `Project`, `generateClient` and the scenario schema.
- **Core.** `validateHtml`, its accept/reject fixtures and their readers
are gone. `isPage` is `tier === 1`. The parse-bound coverage now runs
through `documentTitle`. The look tests' Inter subset moved to
`packages/core/fixtures/looks/inter.css`, licence line kept.
- **Sweep.**
  - Test helpers and fixtures publish tier 1.
  - `seed:dev` publishes two inline single-file pages.
  - The packed Preact e2e uses tier 1.
  - CI's ambient poison is `PATCHY_MAX_BUNDLE_BYTES: "1"`.
- The rollback rehearsal expects live-query deliveries only for pages
that subscribe, or that step 1 saw deliveries for. Every repo page used
to be required to deliver, which a page without the SDK never does after
#1044.
- **Docs.** The tier sections of `docs/product.md`, AGENTS/CLAUDE and
README; ADR-0004, 0006 and 0010; DEVELOPMENT, OPERATIONS and
SKILL_DISTRIBUTION; scenarios; the patches, portal and serving
glossaries and the map; the `patchy-look`, `patchy-loop` and
`patchy-server` project skills; the global skill with its lock hash; the
`ui-consistency` review spec; `docs/API.md` re-rendered.

## Look at

**The migration**, on a database at the schema before it, in
`apps/server/src/migrations.test.ts` › "the tier 0 fold":

- A live tier 0 page, a deleted patch's tier 0 page, and tier 1 and tier
2 versions are inserted as old publishes stored them.
- After `migrate`, both tier 0 rows read `tier: 1` in the column, the
manifest and the receipt, with their digests unchanged. The tier 1 and 2
rows are untouched.
- A tier 1 insert, as the release before writes, still goes in. A tier 0
insert is a `ConstraintError`.

```
✓ apps/server/src/migrations.test.ts > the tier 0 fold > makes every stored static page tier 1, deleted ones too, in its row, manifest and receipt, and refuses tier 0 after
```

**A formerly static page, served scripted.**
`test/browser-tier1/single-file.spec.ts` replaces the srcdoc spec. A
single-file page (tier 1, no tables, files or SDK) opens with
`sandbox="allow-scripts allow-modals"` and a content URL, with no
`srcdoc`. Its `#sellers` link scrolls within the frame with no request.

```
✓ [chromium] › test/browser-tier1/single-file.spec.ts:5:1 › a single-file page opens in the scripted frame and its same-page link scrolls (231ms)
```

**The CLI's way out of tier 0.**

```
✓ packages/patchy/src/executeConfig.test.ts > refuses a config still at tier 0, saying how to move it, with resolution true
✓ packages/patchy/src/executeConfig.test.ts > refuses a config still at tier 0, saying how to move it, with resolution false
✓ packages/patchy/src/State.test.ts > clears an older patchy's tier 0 attempt, which can't be sent again, saying what to check
```

A raw tier 0 manifest is refused by name at the API, before decoding,
with #1045's exact answer, so the contract doesn't change between R2 and
R3:

```
✓ packages/patches/src/PatchesApi.test.ts > refuses unsupported tiers and missing connections before writing content
  → 422 { ok: false, code: "tier_mismatch", error: "Tier 0 is now tier 1. Publish with a tier 1 manifest; a current patchy CLI sends one." }
✓ packages/patchy/src/cliRepoPublish.test.ts > refuses a tier 0 repo by publish and dev before building, and init at tier 0   (#1045's test, kept)
```

<!-- patchy-dev:transcript:tier-zero -->

#### Transcript `tier-zero`

Recorded before the rebase onto main. Before is `1d53fee` (--base
origin/tier-fold/3-file-pages-tier1) and after is `d400586`
(tier-fold/4-no-tier0), whose tree is the head's (`6a0d3ec` only rebased
onto `1d53fee`), both on the `team` scenario, from `pnpm dev
transcript`.

Each line ran in its own `bash -c` from the side's agent workspace, as
the scenario's signed-in CLI, with stdin closed. Each side's origin
reads `<origin>`, its environment folder `<env>`, its checkout
`<checkout>` and the home folder `~`; nothing else is normalized.
Nothing in it matched a collected secret (each side's CLI state,
machine-token and login-code shapes, email addresses outside the
scenarios' example domains, secret-named variables, and any accounts the
run acts as).

1 of 2 lines changed.

##### A repo whose config still says tier 0 refreshes, then publishes

**Changed.** Before, exit 0 in 1.7 s; after, exit 1 in 1.5 s.

```console
$ patchy init brief --purpose "A one-page brief" --json > /dev/null && sed -i 's/tier: 1,/tier: 0,/' brief/patchy.config.ts && cd brief && pnpm patchy refresh --json
[stderr]
{"ok":false,"error":"Tier 0 is now tier 1. Set `tier: 1` and run `patchy refresh`.","kind":"local","code":"tier_mismatch"}
```

```diff
-{"ok":true,"release":{"from":"0.22.0","to":"0.22.0"},"changed":{"pin":false,"generated":["patchy/_generated/manifest.json"],"skills":[],"fixtures":[]},"addedCapabilities":[],"warnings":[]}
+[stderr]
+{"ok":false,"error":"Tier 0 is now tier 1. Set `tier: 1` and run `patchy refresh`.","kind":"local","code":"tier_mismatch"}
```

<details><summary><code>$ cd brief &amp;&amp; pnpm patchy publish
--json</code>: no change, exit 1 in 0.6 s</summary>

```console
$ cd brief && pnpm patchy publish --json
[stderr]
{"ok":false,"error":"Tier 0 is now tier 1. Set `tier: 1` and run `patchy refresh`.","kind":"local","code":"tier_mismatch"}
```

</details>

<!-- /patchy-dev:transcript:tier-zero -->

## How it was verified

- `pnpm check` steps (format, lint, typecheck, synth) pass.
- The focused suites pass: migrations, Server, ApiGuard,
StreamLifecycle, patches, serving, core, portal, mcp, primitives, api,
SDK, runtime, the dev scripts and the touched CLI files.
- `pnpm test:browser` passes all 83, the new spec and look preview
included.
- `pnpm verify` passes postgres-concurrency, cli-smoke, install and
tier2-smoke.
- The full offline `pnpm test`: 2544 of 2566 pass. The failures are only
in the CLI stub suites (`cli*.test.ts`) and two execution timing tests
(`LocalTaskProvider`, `Supervisor`). They are a different set on every
run, always an unauthenticated `GET /` arriving at a local stub, from
the shared machine's local port probing. PR 1, 2 and 3's verifies on
this machine show the same rotating set. CI, without that prober, is the
arbiter.
- **Rollback rehearsal, run locally with live = #1045 (before the rebase
onto #1047, #1044 and #1045; see the acceptance verdict for runs at the
current head):** `pnpm test:rollback-rehearsal --live 6d9ac75` passed
every step, before #1045's tier 0 refusal (4473d2f) and the rebase onto
it. The rebase adds only refusals; the migration and serving are
unchanged.

  ```
  Rehearsing 6d9ac75 → 5008d4d → 6d9ac75 → 5008d4d on one set of data.
  ▶ Step 1: the live commit (6d9ac75) seeds the data      passed in 48s
  ▶ Step 2: HEAD (5008d4d) upgrades it                     passed in 25s
  ▶ Step 3: the live commit (6d9ac75) comes back           passed in 21s
  ▶ Step 4: HEAD (5008d4d) comes back                      passed in 21s
Exercised rollback paths passed: 6d9ac75 → 5008d4d → 6d9ac75 → 5008d4d,
in 115s.
  ```

**CI's `rollback-rehearsal`** replays live → head → live against
production's live commit, now release 25 (`38e0c37`). Before release 25
was live, the live step published a file page as tier 0, which the
narrowed CHECK refuses on the way back. That's why its earlier runs here
failed. The acceptance verdict on `b55f247` reran the rehearsal locally
with `--live 38e0c37` and `--live 18b39ae`, and both passed.

**Not done here.**

- **`pullKind`.** The snapshots stack (#996 → #1003 → #1004) hasn't
merged, so `pullKind` is unchanged. When it lands, `pullKind` should
become `repo === null && originalFilename !== null`, with the snapshot
check still first.
- **Migration id.** #996 (`0029_version_repo_snapshots`) and #995
(`0029_company_guests`) also claim `0029`. Whichever lands first, this
migration renumbers at rebase.
- **A known, accepted break.** A page whose links are written
`about:srcdoc#…` stops jumping once it's served scripted. Its owner is
being told separately; there's no workaround here.

## Release impact

- [x] **Breaking** — requires action from anyone already running this
- [ ] **Not breaking** — no action required

The manifest and config no longer accept tier 0, and the migration
rewrites stored rows.

**Upgrade path:**

- A repo whose `patchy.config.ts` says `tier: 0` is refused with the
fix: set `tier: 1` and run `patchy refresh`.
- `patchy init --tier 0` is gone.
- An instance that set `PATCHY_MAX_HTML_BYTES` can drop it; nothing
reads it now.

- **What does a revert leave behind?** Migrated rows: stored tier 0
versions are tier 1 in their column, manifest and replayed receipt. The
CHECK is narrowed to `tier BETWEEN 1 AND 3`.
- **Does the release before it still work with that?** Yes, for R2
(#1045) and later. R2 serves tier 1 rows through the scripted frame and
its CLI publishes single files as tier 1, so it reads the migrated rows
and writes nothing the CHECK refuses. The same holds while R2 and R3
hosts overlap during the deploy. Rolling back past R2, to a release
whose CLI publishes tier 0 file pages, is not safe, so rollback is only
safe to R2 or later. Given that, this PR carries no `one-way` label.
#1045 refuses tier 0 repo configs and tier 0 manifests (4473d2f), so an
R2 host never tries a tier 0 write against the narrowed CHECK.

Built by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, through T3
Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the repo-snapshots/1-server branch from a77f0ab to 7f8b7d0 Compare October 30, 2026 14:58
@github-actions github-actions Bot added size:xl Over 1,000 changed lines; review in multiple passes and removed size:l 501-1,000 changed lines labels Oct 30, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked 0628e42f529b2915a70bb09dab0a18d7946adb5c (base 244905557ecde4e64f812046a382084d70c194be) on a fresh team instance, by GPT 6.1 Sol in the Codex harness, running in T3 Code. This is a new run of the rebased head.

Done means

  • A publish keeps a version-bound repo snapshot: passed. Real HTTP publishes of two different snapshots returned the correct file/byte summaries. A member read the exact served and pinned bytes, including the executable flag. An identical-key retry replayed the version; changing only its repo returned 409 publish_key_conflict.
  • Anyone who can open the patch may pull; publishing remains owner-only: passed. Ben pulled Ada's snapshot and received 403 on publish. Anonymous reads received 401, including while the page was public. The focused API suite additionally checked foreign-company, disabled and unopenable patches.
  • Served/pinned versions, detail and lifecycle: passed. Default pull followed rollback to v1. Retired default reads returned 409 wrong_state; explicit retired reads succeeded. Deleted-by-name was hidden, retained deleted-by-id remained readable, and restore worked. The API suite checked detail's summary and missing-version responses.
  • Current tier-1 file fallback and historical gaps: passed. A file-shaped tier-1 publish with filename ../../.Launch Plan.HTM pulled as one Launch Plan.html with identical HTML. A version without a snapshot or filename returned 404 no_repo, naming Ada Park. The API suite checked that filename metadata on a tier-2 version cannot produce an incomplete HTML-only pull.
  • Admission and reclamation: passed. Traversal and case collisions returned 400; 2,001 files and 10 MiB + 1 decoded byte returned 413. The API/path suites covered malformed base64, Unicode folding, file/folder collisions and all-or-none snapshot columns. The deletion suite checked committed intents survive expiry, failed-record objects are claimable, and purge removes both versions' snapshots.

Golden journeys

  • Publish/open/find a page, share/unshare, retire/delete/restore: passed on the instance. Ben opened the framed page and found it on Home. Public scope opened the page without exposing its repo; company scope restored the sign-in door.
  • Tier-2 publishing/runtime and CLI smoke: passed in current-head CI (checks); both CLI smoke jobs, tier2-smoke, postgres-concurrency, lint and live Clerk had passed when checked.
Independent evidence
Member reads served snapshot: HTTP 200 (v2, exact bytes)
Member pins original snapshot: HTTP 200 (v1, executable flag)
Member cannot publish: HTTP 403
Repo is covered by publish digest: HTTP 409
Default follows served pointer after rollback: HTTP 200 (v1)
Public page opens: HTTP 200
Public cannot read repo: HTTP 401
Ben opens published page / finds it on Home: HTTP 200 / 200
Retired default / explicit read: HTTP 409 / 200
Deleted name / retained id: HTTP 404 / 200
Pull safe tier-1 file with exact HTML: HTTP 200
Missing snapshot names owner: HTTP 404 no_repo
Traversal / case collision: HTTP 400 / 400
File count / decoded byte cap: HTTP 413 / 413
All independent HTTP assertions passed.
pnpm exec vitest run packages/api/src/repo.test.ts \
  packages/patches/src/PatchesApi.test.ts \
  packages/patches/src/DeletionSweep.test.ts \
  apps/server/src/ApiGuard.test.ts --no-file-parallelism
Test Files  4 passed (4)
Tests       85 passed (85)

The current rollback-rehearsal job succeeded. Its log records all four stages passing on one data set: 2449055 → 53cafc5 → 2449055 → 53cafc5 (the PR merge commit), in 147 seconds.

Rollback answers: Match the diff. Migration 0030_version_repo_snapshots adds nullable columns and an index the prior release ignores. The new purge queues repo_object_key before deleting version rows; the prior purge queues only HTML/server objects. Once snapshots exist, reverting past this server change can leave company code orphaned after deletion. The one-way label and separate server release before #1003 are justified; a successful rollback rehearsal does not remove that retention constraint.

Not run

  • The entire local pnpm verify matrix was not repeated. Current-head CI was used for CLI stub-server suites because this shared machine's port probes can inject stray GET / requests.
  • Browser, Windows install and Node 22/24/26 full test jobs were still running, and Pidgeon was pending at the last check; no verdict is claimed for those unfinished checks. Attio live was skipped by CI.

Notes

  • The first cold instance start exceeded its deadline while building the packed release. The server subsequently became healthy; a warm up team completed, and all HTTP assertions above ran against it successfully.
  • Applicable mirrored surfaces checked: API/schema/server/generated API docs, limits, migration composition, product/glossary, project server skill, analytics and teardown. No new CLI command or portal UI belongs to this server layer.

The throwaway instance was taken down before posting. No PR code, branch, body or labels changed.

allisonmahmood and others added 2 commits October 30, 2026 19:12
A filename on a scripted publish is client metadata; its HTML alone would
lose the server code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the repo-snapshots/1-server branch from 0628e42 to 0af4c4a Compare October 30, 2026 18:13
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Rebased onto 54a5581 (#1094, docs only) because main requires an up-to-date branch. git range-diff shows both commits unchanged, so the acceptance verdict at 0628e42 covers 0af4c4a. All 12 required checks pass on 0af4c4a.

@allisonmahmood
allisonmahmood merged commit ebbc215 into main Oct 30, 2026
23 checks passed
@allisonmahmood
allisonmahmood deleted the repo-snapshots/1-server branch October 30, 2026 18:24
allisonmahmood added a commit that referenced this pull request Oct 30, 2026
## What changed

This adds release 28's What's new entry, written from `ebbc215`. It
covers everything merged since release 27's `through` (`d285816`), and
sets the `patchy` release to `0.28.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`. It's the first of two releases for repo snapshots
(#229): the server learns to keep a version's repo before any CLI sends
one.

| Change | PRs |
| --- | --- |
| Behind the scenes: Patchy can now keep the files of the repo each
version was published from, the groundwork for pulling a patch back down
to work on it | #996 |

There's no announced change. No released CLI sends a repo yet, and
`patchy pull` arrives in the next release. #1094 corrects documentation
and a skill's size figure (60 KiB, not 64), so it gets no line. #1075 is
release 27's own entry.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`.
- **Rollback safety, from the live commit `2449055` (release 27) to
`ebbc215`:**
  - #1094 is docs and skill text only.
- #996 adds migration `0030_version_repo_snapshots`: four nullable
`patch_versions` columns, a CHECK and a unique partial index. Release 27
ignores them and serves and publishes as before. CI's
`rollback-rehearsal` passed against release 27.
- #996 is labelled `one-way` only for retention: once snapshots exist,
release 27's purge would delete version rows without reclaiming their
stored repo. No snapshot can exist under this release, because no
released CLI sends one, so rolling back to release 27 leaves nothing
behind. That's why #996 ships alone, before the CLI that sends
snapshots.

**Rollback line:** If this release misbehaves, roll back to `2449055`
(release 27).

## How it was verified

- **Tests.** `whatsNew.test.ts`, `WhatsNewPages.test.ts` and
`schemas.test.ts` pass (21 tests), and prettier passes on the changed
files.
- **The range.** #996 was reviewed by GPT 6.1 Sol with every finding
resolved, and acceptance gave PASS with notes. It landed with all 12
required checks green, including `rollback-rehearsal` against release
27.
- **Deploy state.** The live commit, pinned from `/healthz/deep`, is
`2449055` (release 27). The Deploy run updated last succeeded, and none
is unfinished.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Text and version numbers only. The `0.28.0` bump tells CLIs and patch
repos installed before this deploy to upgrade, as every release does.

- **What does a revert leave behind?** Nothing.
- **Does the release before it still work with that?** Yes.

Built by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, through T3
Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Oct 31, 2026
…1003)

## What changed

If Huseyin builds a patch and an admin reassigns it to Allison, Allison
can publish to it but has no repo to change. Neither does an owner on a
new laptop.

Now every repo publish keeps the repo with the version, and `patchy pull
<patch>` gets it back into a new folder, set up on today's release so
`patchy dev` runs there. Anyone in the company who can open the patch
can pull it; only its owner publishes. `patchy list <patch>` says
whether there's anything to pull.

Stacked on #996 (the server half). Part of #229; the plan is [on the
issue](#229 (comment)).

## Look at

- **What a publish keeps** (`repoSnapshot.ts`). Every file except:
  - what `.gitignore` excludes
  - `.git`, `node_modules` and `.patchy` at any depth
- `patchy/_generated/` and `.agents/skills/patchy-*`, which refresh
regenerates
  - `.env`, `.env.*` and `.DS_Store`

  How the rules are read:
- Nested `.gitignore` rules join the root's as one ordered list, rooted
at their folder. A deeper file can include again a folder its parent
excludes, with everything inside it, as git does.
- A file either case reading ignores stays out, because git is
case-sensitive on Linux and not on macOS.
- `.gitignore` files themselves are always kept, so a pulled copy keeps
the same files at its next publish.
  - Executable files stay executable.

This was checked against `git ls-files -co --exclude-standard` on eleven
edge-case trees: nested negation, anchored and unanchored nested rules,
folder-only rules, `**`, re-including under an excluded parent, escaped
`#` and `!`, glob characters in folder names, and trailing spaces. All
matched.

The repo is packed before the build, so a too-big one is refused in
seconds:
- Over 2,000 files or 10 MiB is local `too_large`, naming the five
largest top-level entries to add to `.gitignore`.
- A `.gitignore` that drops `package.json`, `patchy.json`,
`patchy.config.ts`, `index.html` or `vite.config.ts` is refused.
  - So are paths that collide by case.
  - Symlinks are left out with a warning naming them.

`ignore` (MIT) is a direct, bundled dependency, and its license ships
with the CLI like papaparse's.
- **Pull** (`Project.pull`). It stages the files beside the target and
rewrites `patchy.json` with this instance, the patch, the version and
the cloud description. Then it runs refresh's own transaction, split out
of `refresh` without its report: pin, install, generation, workerd pin
and its second install, toolchain check, fixture-preserving activation.
Finally it activates the folder.
- A patch that isn't live, or a failed install or generation, still gets
its files, with a warning saying how to finish.
- A page published from one HTML file arrives as that file, with a
quoted `publish --patch` line for it that repeats `--api-url` when the
pull used it.
  - The target-directory checks are factored out of `init` and shared.
- **End to end:** #1004's description holds a transcript of the whole
stack on fresh evidence instances: a pull, a publish from the copy, the
old folder refused as `behind`.
- **The pulled copy's `version`.** `patchy.json` now records the version
each copy was published as or pulled from, so the next PR can refuse a
stale copy.

## How it was verified

The repo publish test that inits a real repo and publishes it now also
checks:

- The snapshot it sends: sorted, with nothing from `node_modules`,
`.patchy`, `patchy/_generated` or the managed skills.
- `artifacts.repo` in the result, and `version: 1` written to
`patchy.json`.
- A pull into an occupied folder is refused.
- A pull into a fresh one installs the real release archive, generates
the client and skills, keeps `index.html` byte for byte, and stamps
`patchy.json`.

```
✓ cliRepoPublish > refuses unbundled resources before sending, then publishes the starter with its repo and pulls it back set up
✓ repoSnapshot > keeps what .gitignore keeps, as git reads nested rules, and never local state
✓ repoSnapshot > refuses a repo that leaves out what the build needs or collides in one folder
✓ repoSnapshot > refuses a repo over the snapshot limit, naming its largest entries
✓ patchy pull > writes a file-born page as its one file, with the publish line for it
✓ patchy pull > keeps a retired patch's files, names its owner, and leaves setup until it's restored
✓ patchy pull > relays a version with nothing to pull, and refuses a version number below 1 first
```

Typecheck, lint and the repo, recovery, init, help and Api suites pass.
Two recovery tests now expect the recorded `version`.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — publish sends one more optional field,
`patchy.json` gains an optional key, and `pull` is new.

- **What does a revert leave behind?** Snapshots already stored, and a
`version` key in `patchy.json` files, which the older CLI's decoder
carries along unread.
- **Does the release before it still work with that?** Yes. Ship this in
a later release than #996, so a rollback lands on a server that reclaims
snapshots (see #996).

Built by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, running in T3
Code; plan reviewed by GPT 6.1 Sol.

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Oct 31, 2026
## What changed

Once a patch can be pulled, an old folder becomes dangerous. If Huseyin
got his patch back and published from the copy on his laptop, he'd
silently replace the fix Allison published from her pulled copy. The
same happens to one owner working on two machines.

Now a repo publish says which version its copy came from. When the patch
has a newer version, publish refuses with `behind`, naming that version
and who published it and when. `--allow-behind` publishes over it on
purpose.

Stacked on #1003 (the CLI half), which stacks on #996. Part of #229.

## Look at

- **The check** runs twice. `Patches.preflight` refuses before anything
is stored, and the test asserts that a stale attempt adds no objects.
`Patches.record` checks again after the patch row lock and the version
number, so two machines publishing from the same copy can't both pass.
- **Who published the newer version.** It names that version's publisher
(`patch_versions.owner_user_id`), not the current owner. The test
reassigns the patch and checks the refusal still names the original
publisher.
- **The override.** `--allow-behind` sends no `baseVersion`; it adds no
wire field of its own. `--force` keeps meaning dependant breakage only,
so agreeing to replace newer work can't also unshare tables by accident.
- **Settling the attempt.** `behind` is a definitive publish refusal:
the saved attempt clears, and the next publish (with `--allow-behind`,
say) builds fresh. The CLI's failure document keeps `baseVersion`,
`latestVersion`, `publishedBy` and `publishedAt`.

## How it was verified

```
✓ repo snapshots over machine tokens > refuses a copy behind the newest version, naming who published it, until left out
✓ patch lifecycle commands > clears definitive behind retries without changing the repo identity
✓ isDefinitivePublishRefusal > clears 409 behind
✓ cliRepoPublish > … publishes the starter with its repo and version and pulls it back set up
```

The round trip now publishes twice more. The first republish sends
`baseVersion: 1`; the one with `--allow-behind` sends none. The
refusal's text names when the newer version was published, as its JSON
does.

The transcript below runs the whole stack on fresh evidence instances,
`main` on one side and this head on the other. On Brightline's Kudos it
shows:

- `list` saying what there is to pull
- a pull into a new folder, set up on today's release
- a publish from that copy
- the first folder refused as `behind`
- `--allow-behind` publishing over it

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — an optional request field and a new 409 code. A
publish without `baseVersion` behaves as before.

- **What does a revert leave behind?** Nothing stored. CLIs of this
release send `baseVersion`, which an older server ignores.
- **Does the release before it still work with that?** Yes.

Built by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, running in T3
Code; plan reviewed by GPT 6.1 Sol.

<!-- patchy-dev:transcript:repo-pull -->

#### Transcript `repo-pull`

Before is `2449055` (--base origin/main) and after is `93262a3`
(repo-snapshots/3-behind), both on the `brightline` scenario, from `pnpm
dev transcript`. The head since adds only #996's narrower rule for
pulling a single-file page, which these lines don't reach.

Each line ran in its own `bash -c` from the side's agent workspace, as
the scenario's signed-in CLI, with stdin closed. Each side's origin
reads `<origin>`, its environment folder `<env>`, its checkout
`<checkout>` and the home folder `~`; nothing else is normalized.
Nothing in it matched a collected secret (each side's CLI state,
machine-token and login-code shapes, email addresses outside the
scenarios' example domains, secret-named variables, and any accounts the
run acts as).

5 of 5 lines changed.

##### What Kudos's served version has to pull

**Changed.** Before, exit 1 in 0.3 s; after, exit 0 in 0.4 s.

```console
$ patchy list kudos | grep -E "^Repo"
Repo: v1, 31 files, 166.9 KiB. Pull it with: patchy pull kudos
```

```diff
+Repo: v1, 31 files, 166.9 KiB. Pull it with: patchy pull kudos
```

##### Someone without the repo pulls it into a new folder, set up on
today's release

**Changed.** Before, exit 1 in 0.3 s; after, exit 0 in 1.5 s.

```console
$ patchy pull kudos kudos-copy
Pulled kudos v1 into <env>/workspace/kudos-copy (31 files).
Set up on release 0.27.0: dependencies installed and generated files current. Run pnpm patchy dev there to work on it.
```

```diff
-DESCRIPTION
-  Build patch repos and publish patches to a Patchy Cloud instance.
-
-USAGE
-  patchy <subcommand> [flags]
-
-GLOBAL FLAGS
-  --help, -h                                                          Show help information
-  --version, -v                                                       Show version information
-  --wizard                                                            Start wizard mode for a command
-  --completions <bash|zsh|fish|powershell|sh|pwsh>                    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)
-  --log-level <all|trace|debug|info|warn|warning|error|fatal|none>    Sets the minimum log level (choices: all, trace, debug, info, warn, warning, error, fatal, none)
-  --json                                                              Print the result as one JSON document on stdout
-  --api-url string                                                    The Patchy Cloud instance to talk to (its API base URL)
-
-SUBCOMMANDS
-  login       Log this machine in; relay the URL and code, then use --complete [code].
-  logout      Forget this machine's publishing key, then revoke it as a courtesy.
-  auth        Manage CLI authentication.
-  whoami      Check the configured Patchy Cloud credentials.
@@ 12 lines cut @@
-  dev         Start this patch repo's local runtime over fixtures (detached and idempotent).
-  refresh     Upgrade the pinned release and refresh the managed files as one transaction.
-  list        Discover patches, their primitives and reads, and company connections.
-  look        Show the company's look and its history; --json includes the files' contents.
-  add         Add members, a Postgres, PostHog, Pidgeon or Attio connection, shared-table or shared-store declaration and generate its files.
-  remove      Remove a declaration and its unused skill, preserving fixtures. Members requires no member columns.
-[stderr]
-Unknown subcommand "pull" for "patchy"
+Pulled kudos v1 into <env>/workspace/kudos-copy (31 files).
+Set up on release 0.27.0: dependencies installed and generated files current. Run pnpm patchy dev there to work on it.
```

_12 of 42 lines are cut from the middle. `--json` has it all._

##### The copy builds and publishes as the next version

**Changed.** Before, exit 1 in 0.0 s; after, exit 0 in 2.4 s.

```console
$ cd kudos-copy && patchy publish 2>&1 | grep -E "^(Updated patch|Version|Repo)"
Updated patch
Version: 2
Repo: 31 files, 167.0 KiB, kept with this version
```

```diff
-[stderr]
-bash: line 1: cd: kudos-copy: No such file or directory
+Updated patch
+Version: 2
+Repo: 31 files, 167.0 KiB, kept with this version
```

##### The first folder is now behind, so publishing from it is refused

**Changed.** Before, exit 0 in 2.3 s; after, exit 0 in 1.9 s.

```console
$ cd kudos && patchy publish 2>&1 | tail -n 1
This copy is from v1, but Allison Mahmood published v2 since, at 2026-10-30T14:59:39.564Z. Pull it into a new folder with patchy pull and make the change there, or publish again with --allow-behind to replace it.
```

```diff
-Unused stores: none.
+This copy is from v1, but Allison Mahmood published v2 since, at 2026-10-30T14:59:39.564Z. Pull it into a new folder with patchy pull and make the change there, or publish again with --allow-behind to replace it.
```

##### Unless told to publish over the newer version

**Changed.** Before, exit 1 in 0.3 s; after, exit 0 in 1.8 s.

```console
$ cd kudos && patchy publish --allow-behind 2>&1 | grep -E "^(Updated patch|Version)"
Updated patch
Version: 3
```

```diff
+Updated patch
+Version: 3
```

<!-- /patchy-dev:transcript:repo-pull -->

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Oct 31, 2026
## What changed

This adds release 29's What's new entry, written from `5eeb154`. It
covers everything merged since release 28's `through` (`ebbc215`), and
sets the `patchy` release to `0.29.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`. It's the second of two releases for repo
snapshots (#229): the CLI starts keeping a repo with every publish and
can pull it back.

| Change | PRs |
| --- | --- |
| New: pick up a patch someone else built. `patchy pull` gets a copy of
any patch you can open, ready to change and run | #1003 |
| Improved: publishing won't replace newer work. A copy behind the
newest version is refused unless the agent publishes anyway | #1004 |

#1104 is release 28's own entry.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`.
- **Rollback safety, from the live commit `6a73bea` (release 28) to
`5eeb154`:**
- #1003: CLIs of this release send a repo snapshot with every repo
publish and write a `version` key into `patchy.json`. Release 28's
server stores and reclaims snapshots, and the older CLI carries the
`version` key along unread.
- #1004: CLIs of this release send `baseVersion`, which release 28's
server ignores. Nothing stored.
- Neither is labelled `one-way`. #996, which is, shipped alone in
release 28 for exactly this rollback.

**Rollback line:** If this release misbehaves, roll back to `6a73bea`
(release 28). Rolling back past release 28 would leave stored repos
behind when patches are deleted, because release 27 doesn't reclaim
them; fix forward instead.

## How it was verified

- **Tests.** `whatsNew.test.ts`, `WhatsNewPages.test.ts` and
`schemas.test.ts` pass (21 tests), and prettier passes on the changed
files.
- **The range.** #1003 and #1004 were reviewed by GPT 6.1 Sol with every
finding resolved, and acceptance gave PASS with notes on each. Each
landed with all 12 required checks green; their rebases onto main left
both commits unchanged.
- **Deploy state.** The live commit, pinned from `/healthz/deep`, is
`6a73bea` (release 28). The Deploy run updated last succeeded, and none
is unfinished.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Text and version numbers only. The `0.29.0` bump tells CLIs and patch
repos installed before this deploy to upgrade, as every release does.

- **What does a revert leave behind?** Nothing.
- **Does the release before it still work with that?** Yes.

Built by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, through T3
Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles one-way Rolling production back past this PR would break the release before it size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant