Skip to content

Local dev environment #15

Closed
Closed

Description

@allisonmahmood

Question

What does the local dev environment look like — designed for where Patchy Cloud is going (Effect 4, more than one service) but shipped small first? The dev runner and how agents start it, drive it, keep it alive across turns, and tear down only what they created; per-worktree ports and state; how the CLI is pointed at the local instance and never at a remote one by accident; the Postgres and test story (hermetic database, no describe.skip anywhere but CI); seeding; --dry-run --json; dev version stamping.

Resolves to requirements the Effect v4 port map inherits, and possibly a prototype ticket for the runner. Input: Local dev for a multi-service Effect monorepo — the options.

Activity

  1. added
    wayfinder:grilling
    on Aug 26, 2026
  2. allisonmahmood commented on Aug 26, 2026

    @allisonmahmood
    OwnerAuthor

    Resolution

    Requirements the Effect v4 port map inherits. Grilled with Allison, 2026-08-26; input was Local dev for a multi-service Effect monorepo — the options.

    The runner

    • A small Effect 4 CLI under scripts/ owns the plan; pnpm dev is its entry point. Ships small: server + embedded Postgres only. No forward-designed service registry or reserved service names — rework when the next service's shape is known.
    • Per-worktree ports from a hash of the worktree path (t3code's rule, scan upward for a free port), so worktrees run and test in parallel. Per-worktree state in <worktree>/.local/dev/ (Postgres data, logs, env, plan.json); nothing shared across worktrees.
    • Start is idempotent and end to end: compute plan → initdb if missing → start Postgres → run migrations automatically on every start → seed → start server → write .local/dev/env + plan.json → print the plan. The runner daemonises so the instance survives the agent's shell call; later turns attach.
    • Subcommands: status, stop, logs, reset. stop kills only the PIDs plan.json records and keeps state; reset = stop + wipe .local/dev/ + re-initdb. Both scoped to the current worktree, always.
    • --dry-run --json prints the resolved Plan with no side effects. Plan (also written as plan.json) is the only machine-readable contract; logs are for humans. The runner's first tests are plan-computation tests (hash → ports, worktree detection), which need no processes.
    • Supervisor is undecided → prototype ticket Dev runner supervisor prototype.

    CLI targeting

    • The CLI reads .local/dev/env by walking up from cwd and ranks it above PATCHY_API_URL and ~/.patchy; only --api-url overrides. Mutating commands print where the target came from. A dev checkout can never publish to a remote instance by accident. (Surprising precedence, hard to reverse once agents depend on it — the port records it as an ADR when implemented.)

    Postgres and tests

    • embedded-postgres everywhere — dev, tests, CI. No Docker, no postgres:17-alpine service, pinned version. Neon's local story is a cloud-backed proxy, so the inner loop stays hermetic; Neon branches are reserved for per-PR CI once preview deployments exist (fog).
    • No skip gate. PATCHY_REQUIRE_POSTGRES_TESTS / PATCHY_TEST_DATABASE_URL go away. Vitest globalSetup starts one cluster per run, applies migrations + seed, template-clones per test (CREATE DATABASE … TEMPLATE), with non-durable settings on. The only permitted skip is a platform one, and it fails loudly in CI.

    Seeding

    • Fresh dev instance = one dev company + one working token, the token written into .local/dev/env so the CLI works immediately after pnpm dev. Seeds are SQL fixtures applied through the migration runner; the same fixture module feeds tests. Expanded as tiers 1 and 2 land, not before.

    Source resolution and versions

    • exports point at src/*.ts unconditionally; bundle at release (t3code's way). Keep tsx; don't churn .js specifiers for Node type-stripping.
    • Dev version stamp 0.0.0-dev.g<sha>[.dirty] from git describe --dirty, so bug reports distinguish releases from dirty checkouts and a dev build never satisfies a release range. No ordering — that's a release-channel concern, out of scope.
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