Skip to content

The destination: a spec for tier 2 patches, proven by prototypes #295

Closed

Description

@allisonmahmood

Part of #294.

Question

What is this map finding its way to, and which decisions were made while charting it? Resolved by the charting session itself: the destination, the lifecycle model, the tier 2/3 line, the patch identity at reduced size, the server-only client, the execution placement principle, the no-ambient-authority rule, the three handler kinds, the composition cut, local dev on the production engine, and the dependency allowlist.

Activity

  1. added
    wayfinder:grilling
    on Sep 19, 2026
  2. allisonmahmood commented on Sep 19, 2026

    @allisonmahmood
    OwnerAuthor

    Resolution

    Charted live with Allison on 2026-09-19, three rounds, each pressure-tested with astra through omp (its disagreements are noted where they changed the answer). This ticket is the record of the charting; the map body carries the gists.

    Destination. A spec for tier 2 patches, not the runtime alone, proven by prototypes that were actually run, with build tickets filed as sub-issues of the spec. Building is the next effort, as with the SDK and portal maps. Allison: "the goal here isn't just runtime alone, but tier 2 patches; 95% of that is the runtime, but there may be little things we wanna sort out too."

    Lifecycle: request-scoped handlers, Patchy owns presence and subscriptions. "While a viewer has the patch open" is execution eligibility, not a shared JavaScript heap. No live instance per patch; no in-memory state or timers in patch code; durable state lives in tables; sync is Patchy's job. Allison's framing: "with tier 2 our backend has a runtime where all this executes; we don't need to spin up a dedicated thing per patch. Tier 3 might need a dedicated thing. Tier 4 has its own Daytona sandbox." Astra's argument that settled it: a shared actor brings single-owner placement, failover, version coexistence and the temptation to keep authoritative state in memory, and reactive CRM screens do not justify it. Both models need expiring presence leases.

    The tier 2/3 line. Tier 2 v1 exposes no raw HTTP routes and receives no inbound webhooks; every call into server code comes from a client the shell opened, through the broker path. Astra's correction, adopted: the line is execution without a viewer present, not transport. Tier 2 alone is an interactive CRM, not an autonomous one; reliable webhooks, scheduled follow-ups and unattended imports are tier 3, and the spec says so plainly. Tier 3 is the map that follows.

    The patch identity, at reduced size. Kept from day one against my proposal to defer it (astra: postponing changes the security model rather than simplifying its implementation). Patch authority for the patch's own primitives, viewer authority for company data and integrations, and the runtime log records the initiating viewer, the patch and version, and the effective principal. No grant surface yet. In v1, with no row-level rules, authority is identical either way and attribution is what differs; the identity is the hook public tier 2 and integration grants later hang on.

    The client of a tier 2 version is server-only. It talks only to its own server functions; me and authorised file-byte handles are the two shell-level exceptions. Reasons: with direct tables.* writes every server-side business rule is advisory; two ways to do one thing in every codebase; and the door is one-way (loosening later is additive, tightening later breaks published patches). Astra's addition, adopted: direct client writes are admitted by the tier of the version the patch currently serves, not the version the frame loaded, so an older tier 1 version cannot bypass the server's rules; rolling back to a tier 1 version restores them as an explicit owner act. Allison: "if it's tier 2 then server only."

    Execution placement. Untrusted handler code never runs inside the credentialed hosting-server process. It runs in a credential-free execution service beside it, in the same deployment, calling back into the runtime with a short-lived per-invocation capability. Astra: separate is necessary, not sufficient; the research must establish the containment unit (bounded resources, scoped capabilities, no metadata endpoint, isolation between mutually untrusted executions), not merely pick an engine. Both paths get researched and prototyped: a self-hosted service on Azure Container Apps portable to AWS, and Cloudflare Workers for Platforms. Credits exist on Azure, AWS, Neon and Daytona, none on Cloudflare; production starts on Azure to spend credits and moves to AWS later, so anything chosen must be a container that runs in either.

    No ambient authority in handler code. No filesystem, process, network or credential access; everything reaches the world through the Patchy context object. The exact compatibility surface (which Web APIs, whether any Node-compatible pure-computation APIs) is research, not a decision made here.

    Three handler kinds, mutations atomic. Query (tracked reads of own and shared primitives, no effects, safely re-run, subscribable), mutation (writes to own primitives inside one transaction per invocation, invalidation after commit), action (effects or reads outside that domain, including company Postgres and integration clients; no implied transaction, no automatic retry). The runtime already classifies every operation as read, mutation or integration, so the kinds map onto what exists. Atomic mutations are the tier 2 evidence the SDK map's deferred transactions question was waiting for.

    Composition is in scope, cut narrow. Shared file stores read-only across declaring patches (absorbing #243) and authorised file handles for the client. Out: cross-patch writes, a patch calling another patch's server functions, company-owned tables. Proven by one complete reference CRM patch rather than an operation checklist.

    Local dev runs the production engine. patchy dev executes handlers in the same engine production uses, over PGlite; what fails hosted fails locally. Allison: "we wanna make sure we have a full and good local dev environment to test things."

    Dependencies: a pinned allowlist that ships with the release. Allison's position: no pulling packages "from god knows where npm" and becoming part of the supply-chain vulnerability list; copied source is fine and is the company's own code ("if it wants to copy in a bunch of motion's code for pretty animations, that's fine, but I don't want us hitting npm for that"); PDF processing and the like should eventually be Patchy packages in the SDK. She also did not want patches neutered: "react seems so core to our dev that maybe we should support that." The working model: a patch depends on patchy and on a short list of exact package versions each release names and Patchy has audited, first entries react and react-dom with types for the client and an empty server list; init, refresh and publish keep a repo on the list; the build resolves bare imports only to patchy and the list on both bundles; enforcement is a resolution policy, not a provenance guarantee (bundling erases imports). Astra recommended leaving the client unrestricted; overruled on the grounds that the concern is npm exposure rather than authority, that nothing published uses a client package yet, and that the door is one-way. Allison's closing call: settle what the list holds and how limited agents really are through research and prototypes on this map, not now. The helper inventory is frozen after the reference CRM.

    Prototype and research list. Research: self-hosted execution service; Workers for Platforms; reactive-query systems; what a CRM-class patch needs beyond the SDK; one transaction per mutation across callbacks. Prototypes: the execution-service spike on Azure; the Workers for Platforms spike; the reactive query loop across two browsers; init --tier 2 through a two-artifact publish with dev on the production engine; the reference CRM built twice by a fresh agent. Allison: "broadly fine; I wouldn't mind more."

    Held for their own tickets: presence leases and disconnect grace, in-flight work at last-viewer departure and duplicate effects, a publish under open viewers, and the safeguards before billing.

    Grilled by Claude Fable 5.1 via Claude Code with Allison, astra as the design pair, 2026-09-19.

  3. allisonmahmood commented on Sep 21, 2026

    @allisonmahmood
    OwnerAuthor

    Addendum, 2026-09-21: the allowlist's first entry is Preact, not React

    Allison revisited the React call while working the server function contract: with no open ecosystem (the allowlist is Patchy-curated), React's remaining argument was extensibility, which does not apply. Research on two models (astra with tools and Opus, merged on that ticket) confirmed the fit: Preact 10.29.8 is stable and MIT with a first-class TypeScript and Vite story; Preact 11 is still RC and not shipped; @preact/signals matches the full-snapshot subscription model the reactive-query research chose; the renderer is roughly 6 to 10 KB gzipped against 55 to 115 KB for React 19.

    Revised decision: the client allowlist starts with preact 10.x and @preact/signals; patchy init scaffolds Preact on tier 1 and tier 2 alike. No preact/compat, no React path aliasing. The rest of this resolution stands. Whether React stays on the list as an explicit alternative is being settled on the contract ticket.

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

Metadata

Metadata

Labels

wayfinder:grilling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions