Skip to content

tiers: static pages fold into tier 1, and only tier 2 reaches integrations #986

Closed

Description

@allisonmahmood

Problem

There are three tiers, and their jobs overlap. Tier 0 is a static page. Tier 1 is a browser tool, but it can also reach company integrations straight from the browser, as the viewer. That makes tier 1's boundary "whatever the browser can call". Guest sharing (#969) needed special cases because of it, and every agent has to choose among three tiers.

Direction

Two tiers, each with one clear boundary:

  • Tier 1: a page, static or interactive, with the patch's own tables and files, shared tables and stores, and the member directory. No integrations.
  • Tier 2: the full app, with server handlers. It is the only tier that reaches company integrations.

Tier 0 goes away. Publishing a single HTML file produces a tier 1 patch. Tiers 3 and 4 keep their numbers.

What production has today

A read-only check on 2026-10-28:

  • Tier 1 patches using an integration belong only to Patchy. patchy-analytics's current version declares PostHog, and an older retained tier 1 version of cloud-pulse declares PostHog too. We migrate these ourselves.
  • Tier 0: 25 live pages. 19 are Patchy's; 6 belong to four other companies, and 2 of those 6 are public. All of them must keep serving at the same addresses with nothing for their owners to do.

To settle while building

  • Existing tier 0 versions, numbered historical ones included, keep serving unchanged. Convert them when serving, or migrate the rows.
  • Older CLIs in the wild still publish tier 0, so the server accepts those publishes as tier 1 (ADR-0004).
  • patchy publish page.html stays a single-file publish with no repo.
  • Public pages lose tier 0's "the document runs no script" promise. It becomes tier 1's sandbox promise: patch code has no network access, and a public shell starts only Patchy's broker. Restate it in docs/product.md.
  • Tier 2 runs on the execution fleet while someone has the patch open. A dashboard that reads an integration and was a tier 1 page becomes fleet time.
  • On tier 2, PostHog is callable only from actions (docs/product.md › Connecting PostHog). A live PostHog dashboard moving off tier 1 loses live updates unless tier 2 queries can call PostHog.
  • Update the docs, the global and project skills, glossaries and What's new.

Guest access

#969 ships guests on tiers 0 and 2. Once this lands, tier 0 guest access carries over to tier 1, limited to the patch's own data, and #969's tier table changes to match.

Done means

  • A builder chooses between two tiers: tier 1 for a page and its own data, tier 2 for anything that reaches an integration.
  • Every page that served before still serves at its address, with no action from its owner.
  • Tier 1 can't call an integration, and Patchy's own tier 1 integration patches have moved to tier 2.

Activity

  1. added
    enhancement
    area:server
    area:cli
    area:docs
    on Oct 28, 2026
  2. allisonmahmood commented on Oct 29, 2026

    @allisonmahmood
    OwnerAuthor

    The plan below has been agreed and reviewed by GPT 6.1 Sol. Building starts now, as four PRs over three releases.

    Repo allisonmahmood/patchy-cloud, base origin/main 2f9f7c1. v2 folds in Sol's first review (GPT 6.1 xhigh, 2026-10-29); v3/v4 fold in Allison's answers (2026-10-29).

    Decided by Allison (2026-10-29)

    • One tier 1. A tier 1 page runs in the sandboxed frame with script allowed, and single-file publishes are tier 1 too. Tier 0 goes away, with no static render path and no static flag.
    • Tier 1 reaches only its own patch: its own tables and files, plus me() (who is viewing) and routing. It has no integrations, no shared tables or stores of other patches, and no member directory. Because member columns require the members declaration (memberColumnsValid), tier 1 has no member columns either. All of those are tier 2. On the portal, tier 1 patches are Pages and tier 2 patches are Tools.
    • No remote resources in tier 1. Agents can't fetch a public static page's address as raw HTML. Both are accepted.

    Production facts (read-only, 2026-10-29)

    • Tier 0 inventory. There are 36 tier 0 versions, 25 of them current on live patches.
      • All were published from a single file: original_filename is set and repo_name is null.
      • None declares tables, files or uses.
      • They belong to five companies, ours included.
    • Remote resources. The 25 current documents were scanned. None loads a remote image, font, CSS url() or @import.
    • One page depends on srcdoc. One public customer page has 12 href="about:srcdoc#…" table-of-contents links, which work only inside srcdoc. No other page has them. The only other non-fragment link is on one of our own pages.
    • Integrations on tier 1. Two tier 1 versions declare an integration, and neither is live:
      • cloud-pulse v1 declares PostHog. It's an old version (the current one is tier 2), but it can still be opened at /~v/1.
      • patchy-analytics v1 declares PostHog. It's the current version of a retired patch.
    • Dev scenarios. Two tier 1 scenarios use integrations: scenarios/pidgeon/patches/support-desk and scenarios/attio/patches/deal-desk. scenarios/brightline/patches/kudos is tier 1 and uses members and member columns.
    • Shared and members on tier 1. No tier 1 version uses a shared table or store. One live tier 1 patch uses members, one of our own. Its member reads stop working after R1 until it's republished as tier 2; Allison is told. No public tier 1 page uses the public member directory.
    • Stored metadata.
      • Every tier 1/2 version records manifest.sdkImports. WIRE_VERSION has always been 1.
      • publish_response.tier is stored on every row and replayed on publish retry. Replay runs before the release check (PatchesApi.ts:505).
    • Deploys.
      • ECS rolls old and new hosts together, with circuit-breaker auto-rollback (apps/infra/src/AppStack.ts:403).
      • Migrations run at host startup.
      • CI's rollback rehearsal publishes a file page from the old server (scripts/rollback-rehearsal.ts:857) and has no one-way exemption.

    Rollout: expand, then contract

    Each release can be rolled back to the one before it, and the rehearsal passes at every step. There are no one-way labels and no exemptions.

    Release PRs Rolls back to the previous release because
    R1 PR 1, PR 2 Neither changes stored data.
    R2 PR 3 R1's shell renders the tier 1 single-file pages R2 publishes.
    R3 PR 4 R2 hosts serve migrated rows as scripted tier 1 pages, and R2 CLIs only publish tier 1, so the new CHECK holds while old and new hosts overlap.

    Allison cuts each release as soon as the previous one is healthy (minutes, not days). PR 4 does not wait for Srikar's guest stack; that stack is being closed and rebuilt and picks up tier = 1 itself. Migration id allocated at landing (after #996 if it lands first).

    PR 1: tier 1 reaches only its own patch (ships alone)

    1. Publish contract.
      • A tier 1 manifest must declare no uses: no postgres, posthog, pidgeon, attio, sharedTable, sharedStore or members. Anything else fails with tier_mismatch in PatchesApi. Member columns already require members, so they fall out.
      • The CLI refuses the same before building, with a message naming the fix: use tier 2, which reaches these through handlers.
      • Whether a tier 1 patch's own table may be shared out to other patches is unchanged; this only removes consuming.
      • patchy dev enforces the same rule.
    2. Runtime.
      • Browser dispatch refuses every integration, shared.* and members.* operation at every tier with ServerRequired (packages/runtime/src/Runtime.ts), generalizing the existing tier 2 rule. This covers retained and restored versions. CallbackGateway, the handlers and the schemas stay for tier 2.
      • The public member directory goes: the principal bootstrap for public tier 1 and publicDirectory in packages/serving/src/Pages.ts. Public versions then reach no data.
      • Tier 1 subscriptions cover tables.* only (packages/api/src/api.ts:1149).
    3. SDK.
      • The generated tier 1 client loses patchy.connections, patchy.shared and patchy.members, and generation stops resolving them for tier 1.
      • The shared createPidgeonClient and createAttioClient exports in patchy/client stay, because tier 2 generated modules import them.
    4. Dev loop and scenarios.
      • Tier 1 dev integration reads go.
      • support-desk and deal-desk move to tier 2 actions, and kudos moves to tier 2: their configs, scenario.json and page calls.
    5. Docs.
      • docs/product.md, both the integrations and the tiers sections.
      • The sdkCapabilities.ts text.
      • The project skills patchy-postgres, patchy-posthog, patchy-pidgeon, patchy-attio, patchy-members, patchy-shared-tables, patchy-shared-stores and patchy-loop.
      • docs/DEVELOPMENT.md and docs/API.md.
      • The runtime tiers paragraph in CLAUDE.md and AGENTS.md.
      • The glossaries.
    6. Tests.
      • Publish refusal, at the API and the CLI.
      • Runtime refusal of stored tier 1 versions that declare PostHog, a shared table and members.
      • The tier 1 integration, shared and member cases are removed or moved to tier 2, including in test/browser-tier1.

    PR 2: the shell no longer requires the SDK handshake (ships alone)

    • The broker drops the 10 s "could not start" timer (packages/serving/src/broker.ts:351). The missing-attributes bootstrap_failed path and the wire stale() path stay.
    • The pinned document stream stays eager at mount for tier 2 only, because it carries the cold-start execution state. For tier 1 it starts on a valid ready (or the first subscription, as today), and the ready handler starts it if it isn't running.
    • No new manifest bit, and authorization is unchanged.
    • A page that never loads the SDK just renders, with no stream. A broken SDK bundle now shows a broken page instead of the notice.
    • Tests:
      • A page with no handshake shows no notice and opens no stream.
      • A tier 1 page with a handshake gets its stream and subscriptions.
      • Tier 2 still warms at mount.

    PR 3: single files publish as tier 1 (after R1 is live)

    1. CLI publishing.
      • patchy publish page.html and patchy validate build a tier 1 manifest with no sdkImports.
      • They run the repo builds' self-contained inspection, moved out of repoBuild.ts into a shared helper. Inline script and style are allowed, external resources are refused, and the cap is 10 MiB.
      • validateHtml leaves the CLI.
    2. Server. It accepts these tier 1 single-file publishes; nothing new is needed. Tier 0 stays accepted until PR 4.
    3. Portal. A page is a tier 1 patch and a tool is a tier 2 patch (Allison). In R2 the predicate is tier <= 1, because tier 0 rows still exist; PR 4 makes it tier === 1. The tier is already on the row, so nothing new is carried. One predicate drives:
      • the Home and All patches shelves, including the copy "A page is a static patch: tier 0.";
      • patchMark;
      • isWelcomePage on Home and in the guide;
      • patch.first_opened's welcomePage.
    4. Docs.
      • Global skills/patchy/SKILL.md, plus its skills-lock.json hash: a file publish is tier 1, script is allowed, it must be self-contained and is capped at 10 MiB, and the "fetch a public tier 0 page directly" line goes.
      • packages/patchy/README.md and ADR-0004.
      • What's new.

    PR 4: tier 0 is gone (after R2 is live)

    1. Migration (patches capability), one transaction over every row, deleted patches included:

      • set the tier column, manifest.tier and publish_response.tier to 1 where they are 0, leaving payload_digest alone;
      • change the CHECK to tier BETWEEN 1 AND 3.

      The vitest template and dev seed follow.

    2. Schemas. Manifest.tier becomes Literals([1, 2, 3]) in schemas.ts:604 and management.ts:161, and the publish response follows.

    3. CLI.

      • init --tier accepts 1 or 2, and the config type becomes 1 | 2 | 3.
      • A config with tier: 0 gets: "Tier 0 is now tier 1. Set tier: 1 and run patchy refresh."
      • A saved pending tier 0 publish attempt (State.ts:387) is cleared with a message: check patchy list, and republish if it's missing.
      • The tier 0 branches go from these files:
        • repoBuild and devServer (which then always uses documentTitle);
        • initProject, Project and executeConfig;
        • generateClient.ts:5 and scripts/dev/src/scenario.ts:28.
    4. Server publish.

      • The tier 0 branch goes (validateHtml, maxHtmlBytes).
      • Owner-action request caps keep their own small limit (PatchesApi.ts:373), and the publish envelope cap keeps the snapshots allowance (PatchesConfig.ts:52).
      • PATCHY_MAX_HTML_BYTES goes, from api.ts, docs/API.md, OPERATIONS, the packed CLI harness and ci.yml:142. The poison value there is replaced with a surviving setting.
    5. Serving.

      • The srcdoc path goes from Pages.ts and shell.ts.
      • The static CSPs go from shell-headers.ts; PATCH_CONTENT_SECURITY_POLICY stays for notices.
      • framedDocument stays only for lookPreview.
    6. Core.

      • validateHtml goes, along with the accept and reject fixtures and their readers (seed:dev, test/cli.ts, repoBuild.test.ts:26, look-preview.spec.ts:151, cliLook.test.ts:5).
      • The look fixtures, documentTitle and the parse-bound coverage stay.
    7. Stacks.

      • The guest stack's tier IN (0, 1) checks become tier = 1, and its tier 0 guest serving path folds into tier 1. Grants are patch-bound, so they carry over.
      • pullKind becomes repo === null && originalFilename !== null, with snapshots still taking precedence.
    8. The one page with about:srcdoc# links: the break is accepted. Its owner is told before R3 is deployed.

    9. Sweep.

      • Packed e2e scripts: packed-install-e2e.mjs:59, packed-preact-e2e.mjs:135, packed-cli-e2e.mjs:2168.
      • Default tier 0 publishes in test helpers: apps/server/src/test/server.ts:72, test/browser/fixtures.ts:97, packages/mcp/src/test/door.ts:343 (its negative case becomes tier 1) and the package fixtures.
      • transcript.test.ts:52.
      • scripts/rollback-rehearsal.ts:995, whose subscription expectations should follow what each patch actually subscribes to.
      • The patchy-server skill at line 365.
    10. Docs.

      • The tiers sections of docs/product.md, CLAUDE.md and AGENTS.md.
      • ADR-0010, plus ADR-0005 and ADR-0006.
      • DEVELOPMENT, SKILL_DISTRIBUTION and scenarios/README.md.
      • The patchy-look and patchy-loop skills.
      • The glossaries (patches, portal, serving) and GLOSSARY-MAP.md.
      • README.md and What's new.

    Planned by Claude Opus 5.5 in Claude Code, through T3 Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:cliarea:docsarea:serverenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions