Skip to content

perf(patchy): publish checks the look in its own request instead of downloading it - #729

Merged
allisonmahmood merged 1 commit into
mainfrom
perf/594-publish-look-stamp
Oct 18, 2026
Merged

allisonmahmood merged 1 commit into
mainfrom
perf/594-publish-look-stamp

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

Repo patchy publish called GET /api/look whenever the page used the look. That response carries the current look's files (up to 512 KiB with embedded fonts), every revision, the admins and, with no company look, the Patchy look's files. Publish then compared only the current revision's number and time.

How

  • Wire: PublishMetadata gains an optional look: absent means no check, null means the Patchy look, and { revision, createdAt } names a company revision (LookStamp in @patchy/api). Nothing new is stored on the version, so there's no migration.
  • Server: Looks.current reads the company's current revision (number, time, author, note) in one plain query, with no files, history, admins or locks. The publish handler compares revision and createdAt after admission and before Content.publish, so outside the publish transaction. On a mismatch it adds today's wording to warnings. This covers a newer revision, a restore to an earlier one, and moves to or from no look. Because the warning is in the stored response, a same-key retry replays it. A changed stamp under the same key changes the payload digest, so it gets publish_key_conflict. A failed read logs a warning and adds "Could not check whether this repo's look is current: The look could not be read." The publish never fails or rolls back because of it.
  • CLI: repo publish decides "uses the look" locally with the same rule as before and sends the stamp from index.json. It no longer calls GET /api/look. sendPublish remembers a successful response's warnings before its local writes, so a failed write still reports them.

Older CLIs keep working

An older CLI sends no look and still calls GET /api/look itself. The server reads an absent field as "no check", and that route is unchanged (patchy look --json relies on its full body). PublishMetadata decodes an absent look as absent, not null, and encodes it back the same way, so an attempt saved before this change replays byte for byte. The server tests publish a stampless request while the company has a look and get no look warning. The recovery test replays a saved attempt with the stamp removed and checks it goes out unchanged.

Tests

  • PatchesApi.test.ts › "publish look check":
    • today's wording for a Patchy-look repo after a first revision, a repo behind a newer revision, a repo ahead of a restore, and a company with no look
    • silence when stamps match, when both sides are on the Patchy look, and when the stamp is absent
    • the same revision number from another time counts as a different look
    • a same-key retry replays the original warning after the look changes, and a changed stamp under that key gets publish_key_conflict
    • a failed read (injected with an alternate Looks layer) warns, and the publish succeeds
  • cliRepoBuild.test.ts: publish sends the stamp and ships the repo's own look bytes, makes no GET /api/look, and passes the response's warning through --json with exit 0. A page with its own stylesheet sends no stamp.
  • cliRepoRecovery.test.ts: a local write failure after the server accepts the publish still reports the server's warnings. I confirmed this test fails without the change. A saved attempt without a stamp resends without one.
  • cliPublish.test.ts: a file publish sends no stamp.
  • Dev instance, end to end: on the Patchy look, the publish was silent. After an admin published rev 1, the publish warned "This repo has the Patchy look, but the current look is rev 1 by Patchy Dev: darker green. …" and exited 0. After a refresh, it was silent. After look restore none, it warned "… Patchy Dev has no look now. …". The server log for the publish showed /api/me, /api/patches/…, /api/release and /api/publish, and no GET /api/look.

Hit every surface

  • Wire contract: packages/api (PublishMetadata.look, publish endpoint description) → patches handler → CLI request. The --json shape is unchanged because warnings ride the existing warnings. docs/API.md is regenerated.
  • CLI: the README and ADR-0004 now say the look warning comes from the publish response, so a failed local build or an unsuccessful upload carries none, and an accepted publish's warnings survive a failed local write. The global and project skills describe only the behaviour, "publish ships the repo's own look and warns", which still holds. They never mention GET /api/look, so I left them as they are.
  • Vocabulary: GLOSSARY-MAP.md's Patches → Companies edge now includes reading the current look revision. No new term: "look revision" and its stamp already exist. @patchy/patches now lists @patchy/companies, which it already reached through runtime, primitives and integrations.
  • Not applicable: dev loop, migrations, company resources, served pages, reverse states, repo layout.

Closes #594

Built by Claude Opus 5.5 in Claude Code, running in T3 Code; reviewed by GPT 6.1 Sol in Codex.

@github-actions github-actions Bot added area:server Touches the server area area:cli Touches the cli area area:docs Touches the docs area size:m 100-500 changed lines labels Oct 17, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review, round 1 (GPT 6.1 Sol, xhigh, in Codex): no findings. Sol traced the absent / null / stamp distinction through decode and encode, the instant comparison of createdAt, the replay of the stored warning and the conflict on a changed stamp, and the CLI remembering warnings before its local writes. 15 focused CLI, schema and API-doc tests passed. The server suite couldn't start in Sol's sandbox (embedded Postgres needs a system library it lacks), so the server cases rest on the author's full local pnpm verify and CI. Verdict: resolved.

…ownloading it

Repo publish called GET /api/look, which carries the current look's files,
every revision and the admins, only to compare one revision number and time.

The publish request now carries the repo's look stamp as metadata.look
(absent: no check; null: the Patchy look; { revision, createdAt }: a company
revision). The publish handler reads the company's current revision in one
plain query through Looks.current, before the version is recorded and outside
the publish transaction, and adds today's warning to the response, so a
same-key retry replays it. A failed read warns and never fails the publish.
The CLI stops calling GET /api/look during publish and remembers a successful
response's warnings before its local writes.

Closes #594

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the perf/594-publish-look-stamp branch from aebeaca to 8e5535f Compare October 18, 2026 12:20
@allisonmahmood
allisonmahmood merged commit 7bd413d into main Oct 18, 2026
13 checks passed
@allisonmahmood
allisonmahmood deleted the perf/594-publish-look-stamp branch October 18, 2026 12:31
allisonmahmood added a commit that referenced this pull request Oct 19, 2026
…ng Reconnecting (#783)

Release 14's What's new entry, written from \`7694bab\`. It covers
everything merged since release 13's \`through\` (\`c9b8fc4\`), and sets
the \`patchy\` release to \`0.14.0\` (\`packages/patchy/package.json\`
and \`CURRENT_RELEASE\`).

| Change | PRs |
| --- | --- |
| Improved: Tools with server code answer faster | #756, #764, #768,
#769, #771, #772, #773, #775, #778 |
| Improved: Your company's tools and pages open sooner | #759, #761,
#766, #770 |
| Fixed: Tools stop flashing Reconnecting while they load | #755, #776,
#780 |
| Improved: Publishing is quicker | #729 |
| Improved: New tools start with a tidy layout | #763 |
| Improved: Your usual is easier to scan | #721 |
| Fixed: A page that isn't there says what to do | #762 |
| Fixed: A logo Patchy can't read is refused, not a crash | #728 |
| Behind the scenes: richer logs for live data | #758 |

#720 is release 13's own entry, so it's left out.

Made by Claude Opus 5.5 via 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:cli Touches the cli area area:docs Touches the docs area area:server Touches the server area size:m 100-500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(patchy): publish downloads the whole look to compare one revision number

1 participant