Skip to content

feat(patchy): patchy dev, the local runtime over PGlite with fixtures #207

Closed

Description

@allisonmahmood

Part of #193. Implements spec §13 (the dev runtime) and the dev half of §7; decisions Dev is local, on real code, with fixtures, the PGlite research, What init pulls from the server § patchy dev for agents, The tables surface § Dev follows production and Tier 1 serving § Dev serves production. The init prototype's patchy dev (PR #187) is the shape to lift; the repo's own pnpm dev runner is the daemon shape.

What to build

patchy/dev in packages/patchy: the dev runtime composing runtime, primitives, integrations (dev layers) and company-database (PGlite layer) with a filesystem content store under .patchy/dev/, serving @patchy/serving/shell, never importing apps/server.

  • patchy dev [--foreground]: the release check (new starts refuse an outdated pin, CLI or runtime; a running session is never killed by a release); authenticate and bind the viewer from /api/me as the machine token's user; pull GET /api/patches/:id/inventory when patchy.json has an id and the declaration metadata, regenerate declarations (ticket 11's generation); execute the config and provision into PGlite with the same additive diff and refusals (before the first publish the local database is disposable and recreated on every schema change; after it, the baseline is the published inventory); load fixtures/postgres-<handle>.sql into one PGlite per connection and fixtures/shared-<alias>.sql into a local copy of the source's inventory definition (a declaration with no fixture file fails naming the file); run Vite in build-watch mode producing the same single-file bundle publish would; serve the production shell, CSP, sandbox and broker at the by-id content URL; swap the bundle atomically and reload the whole shell at the current route after each build; expose POST /api/runtime/call and the bytes routes locally with the same admission minus Clerk. Detached and idempotent, exits 0 only when healthy, prints one URL, the log path and the stop command. State and daemon identity under .patchy/dev/, scoped to repo and instance; a stale record never kills an unrelated process.
  • patchy dev status, stop, logs, reset (wipes local rows and files, never the baseline), each with --json.
  • Dev-loop calls are not logged; the keyring and the runtime log store are never loaded.

Done when

  • On ticket 11's tree, patchy dev provisions the starter table in a few seconds; the browser at the printed URL inserts and lists through the real broker; a file uploads and renders through url(name); code that fetches, uses localStorage or opens a popup fails exactly as in production.
  • A schema change publish would refuse is refused at dev start with the same message once the repo has a published id; before the id, the local database is recreated.
  • dev twice is one daemon; stop ends it; a stale pid file for a dead process is cleaned; reset empties rows and files and keeps the baseline; --foreground streams logs.
  • A Postgres declaration with its fixture answers list and query locally; a shared-table declaration reads its fixture rows; without a fixture file, dev fails naming it.
  • The prototype's fresh-agent run on the laid-down tree reaches a local insert and a publish without editing _generated/, touching production or re-installing.
  • The patchy-dev-loop skill and docs/DEVELOPMENT.md say how a maintainer runs a patch repo against a worktree's instance.

Surfaces

The CLI (README, ADR-0004 for dev and its subcommands), the dev loop (docs/DEVELOPMENT.md, patchy-dev-loop), vocabulary (Dev runtime, Environment, Fixture), docs/product.md § Building a patch (the dev loop) and § Integrations › Development.

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