Skip to content

feat(serving): tier 1: the shell, the sandboxed frame and the broker #205

Closed

Description

@allisonmahmood

Part of #193. Implements spec §10 and ADR-0010; decisions Paths for addresses, a sandboxed frame, the frame prototype (lift the broker's shape and the click-through from proto/frame-broker, PR #185; copy the shape, not the files) and Tier 1 serving.

What to build

  • The shell for tier ≥ 1 versions in packages/serving: the page at the address resolves the name, binds a patch id and a version id, frames /~content/<patchId>/<versionId>?n=<nonce> in <iframe sandbox="allow-scripts allow-modals">; the shell's own CSP carries frame-src 'self'. Tier 0 keeps srcdoc; two branches in one renderer keyed on the version's tier; a historical version renders with its own tier. @patchy/serving/shell exports the renderer, the broker script and the CSP constants with no auth or platform infrastructure, for ticket 14.
  • The content response for tier ≥ 1: spec §10's CSP (sandbox allow-scripts allow-modals; default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src blob: data:; font-src blob: data:; media-src blob: data:; connect-src 'none'), a Permissions-Policy denying camera, microphone and geolocation, the same door as the shell, caching keyed to sharing.
  • The broker (Patchy's own script, on company and public shells alike): a MessageChannel handed once to the intended document (nonce echoed in ready { wire, nonce }), bounded bootstrap failure shown as a notice, a second load closes the port; envelope per spec §10; own-property dispatch; every runtime request validated with the packages/api operation schemas, then forwarded to POST /api/runtime/call with the bound ids, the principal, the X-Patchy-Wire and X-Patchy-Principal headers and credentials: "same-origin"; me first with a null principal, its user id bound as the principal for every later call; bytes transferred as ArrayBuffer and carried on the bytes routes; browser-owned ops route.set (refusing a ~ first segment), route on popstate, download; outstanding requests and held bytes bounded (32, 64 MiB).
  • Notices: session_expired and principal_changed reload the whole page after sign-in; access_denied is non-suppressible and offers no reload; validation errors are the patch's. The bootstrap me on a public shell answers null and every other op surfaces not_available_on_public.
  • Wire version: the bundle declares wire in ready; the shell forwards it; the three stale states of spec §10 with the needs-rebuild door as a first-party page (ui-consistency).
  • Publish admission widens to tier 1 (ticket 1's interim refusal goes): a tier 1 bundle is stored raw, never through the safe-HTML policy; a tier 0 claim over script stays tier_mismatch.

Admitted at merge

Tier 1 manifests and bundles; they serve in the sandbox.

Done when

Playwright, Chromium and Firefox, serial and few, against a server with fake Clerk keys and a seeded session:

  • Spec §10's acceptance list: script-initiated navigation, redirects and 204 responses from inside the frame blocked by frame-src; navigation during pending reads and writes; malformed, oversized and duplicate-id messages; login, logout, expiry and account switch mid-session; simple cross-site POSTs refused; the CSP present on redirects, error pages and uploaded active content; a stale public shell refreshes once and stops; a 2,000-row print with the first and last row checked.
  • Deep link and back/forward through the route bridge; an own file shown through url(name); a shell-owned download; localStorage, fetch and window.open fail inside the frame; a public tier 1 patch renders signed out and tables.list shows the notice.
  • ADR-0010 written; the Serving glossary rewritten tier-scoped (Serving guarantee, Page, Shell, Broker, Envelope, Route bridge, Needs-rebuild door); docs/product.md § Tier 0 and § Tier 1 carry the shell-script line and the promise.

Surfaces

Served pages (ui-consistency), the wire (admission), vocabulary, the ADR, the patchy skill's reading section and lock hash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions