Skip to content

feat(patches): publish tier 2 server artifacts - #434

Merged
allisonmahmood merged 2 commits into
mainfrom
tier2/401-publish-tier2
Oct 1, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
tier2/401-publish-tier2

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

Tier 2 repos could not publish their server code, so hosted pages could not call their handlers.

Publish now builds HTML and a closed server bundle. The instance re-derives handler descriptors from the stored bytes before admitting the version. Dev and test instances serve it through the local executor; production remains gated. Tier 2 cannot be public, and older tier 1 documents lose direct operations while tier 2 is served. Rollback restores those operations.

Stacked on tier2/400-mutations; merge that branch first. This PR targets that branch, not main.

Closes #401.

Verification

  • pnpm typecheck and pnpm lint passed.
  • pnpm test --maxWorkers=4: 124 files, 1,388 tests passed.
  • Hosted browser smoke verified a committed mutation, old-tab refusal and reload notice, rollback reopening writes, and CLI/portal public-sharing refusals.
  • Standards and specification reviews resolved.

Implemented with GPT-6 Astra using the omp harness.

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:primitives Patch tables and files area:integrations Company connections and integration implementations area:ui Portal and first-party browser pages, shared rendering and styles size:xl Over 1,000 changed lines; review in multiple passes labels Sep 29, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Astra review

Reviewed fb2682f9698d18f584a7a40518ba24cf9288b010 against origin/tier2/400-mutations at 027bf0dda5385bc24fb3b607c710cce1229fbfc1, using #401 and the relevant contracts in #384. One pass, no subagents; merge blockers only.

Standards

No merge-blocking method or YAGNI findings. The change reuses the existing inspection process, retained-version storage, pending-object reclamation, runtime admission and lifecycle checks. I found no abstraction or future-only behavior that warrants blocking this merge.

Spec

No merge-blocking intent findings. The diff covers two-artifact publication, stored-byte descriptor inspection, the served-tier gate and rollback, public-sharing refusals, artifact metadata, publish-event fields, and the development/test execution boundary. Production tier 2 publication remains refused.

Verification during this review used disposable local fixtures and the real Vite/workerd path:

  • A server mutation built successfully, recorded patchy/server, and inspection returned its expected name, kind, argument and result descriptors.
  • Inspection rejected a top-level throw, an unfinished initializer and an unresolved import.
  • The build rejected node:fs with import_refused and an unreachable dynamic import with invalid_manifest.

I did not rerun the full suite or the hosted-browser acceptance flow reported in the PR.

Summary: Standards 0 blockers, worst issue none; Spec 0 blockers, worst issue none.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Opus review

One blocking finding. It is small.

1. tier2_not_public gives the wrong fix on three of its four paths (correctness)

packages/patches/src/Patches.ts:202-206: Tier2NotPublic has one fixed message: "Tier 2 patches cannot be public. Use --share company before serving a tier 2 version." That fix is only right for publishing tier 2 to a public patch (Patches.ts:1581, :1603, :1727). The same error comes back from:

  • setScope (Patches.ts:1948). patchy share public / share --share public on a patch already serving tier 2 is told to "use --share company", but the patch is already company-scoped. The fix is to serve a tier 1 version first, or stay company.
  • rollback (Patches.ts:2052). Rolling a public patch back to tier 2 needs a scope change to company. --share is not a rollback flag.
  • The portal (packages/portal/src/PortalPages.ts:376). A person clicking the sharing control reads a CLI flag, then "Nothing was done."

The message goes through PatchesApi.ts:162-163 into the wire body error, so the CLI's human and --json output and the portal notice all carry it. ADR-0004 treats a refusal's message as the fix an agent follows. Fix: give the error a structured field (e.g. action: "publish" | "share" | "rollback") and derive the message from it. Otherwise, use wording that fits every path, such as "Tier 2 versions cannot be served publicly; keep the patch company-scoped." The portal also has no test for this refusal. One case in PortalPages.test.ts would pin the copy.

What I checked and found sound

  • Two artifacts. Both objects go through prepareObject, both pending intents are claimed in record (Patches.ts:1741-1750), and failed publishes are swept. The sweep's NOT EXISTS and purgeDeleted cover server_object_key. The payload digest covers server, so a changed bundle under the same key is publish_key_conflict.
  • Re-derivation. Content.publish reads the server bytes back from the store, inspects them in a throwaway workerd, and compares against the manifest with Schema.toEquivalence(HandlerDescriptors) before record. Tampered kinds, top-level throws, spins, unresolved top-level await and unresolvable imports are all invalid_manifest. There are tests for each, and one for storage corruption. Tier <2 with a server or handlers is refused. ServerBundles.load re-checks company, wire and sha256.
  • Served-tier gate. patchTier comes from the same query as the version (retainedRow). Runtime.ts:619 and RuntimeStream.ts:331 read it. current_version_id is always set on insert, so the inner join to served loses nothing.
  • tier2_not_public. It is checked in preflight and again under the row lock in record. setScope/rollback hold FOR UPDATE through manageable, so a publish racing a share is serialized. It is definitive in sendPublish.
  • Production gate. It uses NODE_ENV, the same as LocalExecutor and DevelopmentInvocation.make, and the Dockerfile sets production.
  • CLI. The server graph allows patchy/server and patchy/csv, refuses dynamic import(), and the output is checked to have no imports. Page runtime imports of server/ are refused and type-only imports allowed. The generated module list is checked (stale_generated), and so is the workerd pin (release_mismatch).
  • Surfaces. Checked docs/API.md, ADR-0003/0004/0010/0011/0012, docs/product.md, the Runtime glossary, the CLI README, the project skills, the dev-loop skill, and the migration ledger (0013, CLAUDE.md/AGENTS.md updated).
  • Deferred to feat(patchy): patchy init --tier 2, the server module list and changing tier in refresh #402. The global patchy skill still says repo mode admits tiers 0 and 1 (skills/patchy/SKILL.md:325). I read that as feat(patchy): patchy init --tier 2, the server module list and changing tier in refresh #402's job (init --tier 2 and tier choice), not a blocker here.

Reviewed with Claude Opus 5.5 in Claude Code.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Resolved the review in commit 246580f91506914464f0698d9ba2fa91b4bcb6e9.

Fixed

  • Opus: misleading tier2_not_public guidance. Confirmed that the same error reaches publish, share, rollback and the portal. It now says: "Tier 2 versions cannot be served publicly. Keep the patch company-scoped." This works on every path without suggesting a flag that rollback or the portal cannot accept. ADR-0004 records that contract.
  • Opus: missing portal refusal coverage. Added a real portal-route case that asserts HTTP 422 with an alert, no scope or version mutation, and successful public sharing after rollback to tier 1.
  • CI: stale packed publish receipt contract. The failing smoke assertion omitted artifacts. Updated it and added independent checks that the initial and updated publish hashes and byte counts match the HTML actually served.

Kept as is

  • No action field on Tier2NotPublic. The shared wording fixes the problem without adding operation-specific state to the domain error, using the simpler alternative proposed in the review.
  • No exact-copy assertion. The new portal test protects refusal and rollback behavior rather than pinning incidental wording, per the repository testing rules.
  • Global skill onboarding remains with feat(patchy): patchy init --tier 2, the server module list and changing tier in refresh #402. That issue explicitly owns init --tier 2, tier choice and the global skill/hash update. This PR retains its publish-only scope.
  • Astra: no blockers. Its reviewed artifact inspection, admission and lifecycle behavior remains unchanged.
  • Grok: none posted. Checked conversation comments, review bodies and inline review comments before editing and again after CI; both Reviews endpoints are empty.

Verification

  • Local: 97 affected tests passed across PortalPages.test.ts and PatchesApi.test.ts; pnpm lint passed; pnpm test:packed-cli-e2e passed against the installed package, real isolated server and browser.
  • Latest-head CI run passed: Node 22 and 24 suites, Postgres concurrency, live Clerk, CLI smoke including packed Preact, lint/format/typecheck, and dependency review. The label check passed too.
  • GitHub reports no checks marked required for this PR, but all eight reported checks succeeded on 246580f. Merge state is CLEAN and MERGEABLE.

No unresolved review or CI blockers. The PR remains stacked on tier2/400-mutations; no merge was performed.

@allisonmahmood
allisonmahmood force-pushed the tier2/401-publish-tier2 branch from 246580f to 9d2f17e Compare October 1, 2026 03:31
@allisonmahmood
allisonmahmood merged commit e268078 into main Oct 1, 2026
8 checks passed
@allisonmahmood
allisonmahmood deleted the tier2/401-publish-tier2 branch October 1, 2026 03:43
allisonmahmood added a commit that referenced this pull request Oct 1, 2026
…435)

Tier 2 patches can publish, but agents still need a working starter and
a reliable way to move existing repos between tiers.

Adds `patchy init --tier 2` with a Preact page and typed server
handlers. Init takes the exact workerd pin from the installed release.
Refresh manages both tier transitions, including pins, generated server
types and the tier-specific skill, while preserving authored files.
Updates the global and project skills, skill-lock hash and CLI/product
documentation.

Stacked on `tier2/401-publish-tier2` / #434. This PR targets that branch
and contains only the #402 changes. Implements #402 from spec #384.

## Verification
- Typecheck and lint passed.
- Full suite passed: 1,394 tests across 124 files. After the final init
pin-source correction, package typecheck, targeted lint and both init
tests passed.
- Isolated smoke covered init, two-artifact publish, both tier
transitions, stale module-list and pin refusals, context cleanup and
public-sharing recovery.
- The hosted starter saved a note and retained it after reload. A
separate release-drift smoke selected the installed release's engine and
typechecked in 0.83 seconds.

Tier 2 query subscriptions and the patch-repo dev engine remain #403 and
#404; the starter uses one-shot server calls on this stack.

Implemented with OpenAI GPT-6 Astra through omp.
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:cli Touches the cli area area:docs Touches the docs area area:integrations Company connections and integration implementations area:primitives Patch tables and files area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(patches): publish tier 2: two artifacts, server-side re-derivation, the served-tier gate and tier2_not_public

1 participant