Skip to content

feat(dev): Effect dev runner behind pnpm dev #70

Closed

Description

@allisonmahmood

Problem

There is no local instance an agent can start, keep alive across turns and tear down cleanly. The runner is also the port's first Effect 4 code and the harness every later port PR is smoked on, so it lands before any package moves.

Do

An Effect 4 CLI under scripts/ (e.g. scripts/dev/), entry pnpm dev. Requirements from Local dev environment and Dev runner supervisor prototype (branch prototype/dev-runner-supervisor is throwaway reference, not a base):

  • Plan: per-worktree ports from a hash of the worktree path (scan upward for a free port); per-worktree state in <worktree>/.local/dev/ (Postgres data, logs, env, plan.json). --dry-run --json prints the resolved Plan (an Effect Schema) with no side effects; plan.json is the same document. First tests are plan-computation tests (hash → ports, worktree detection) with no processes.
  • Start is idempotent and end to end: compute plan → initdb --no-sync if missing → start embedded Postgres → run migrations → seed → start the server → write .local/dev/env + plan.json → print the plan. Spawn the supervisor detached + unref, run under node --import tsx (never the tsx wrapper) so the recorded pid is the one signals reach; poll /healthz.
  • Supervisor: one Effect scope owning every handle — Postgres via acquireRelease, each service via effect/unstable/process spawn with killSignal: SIGTERM + forceKillAfter; any service's exit closes the scope. Env goes straight to each child; log lines carry one [service] prefix. Turbo is not on the dev path.
  • Subcommands: status, stop (SIGTERM only the pids plan.json records, keep state), logs, reset (stop + wipe .local/dev/ + re-initdb). Always scoped to the current worktree.
  • Seed: one dev company + one working token, the token written into .local/dev/env (PATCHY_API_URL, PATCHY_API_TOKEN) so the CLI works right after pnpm dev. Seeds are SQL fixtures; the same module feeds the vitest globalSetup from #39.
  • Migrations run through today's packages/db runner via a thin adapter; the sql ticket swaps it for Effect's Migrator.
  • Server startup stays Fastify; the runner only spawns it.
  • docs/DEVELOPMENT.md documents pnpm dev, the subcommands and .local/dev/; .local/ is gitignored.

Conventions: .agents/skills/effect-service-conventions/SKILL.md; namespace imports; Schema.TaggedError failures; NodeRuntime.runMain maps SIGINT/SIGTERM to interruption. Promote the language-service warning rules to error for scripts/dev.

Done when

pnpm dev from two worktrees runs two instances side by side; stop leaves the other untouched; reset gives a fresh seeded instance; --dry-run --json is stable and tested; the CLI, pointed at .local/dev/env by hand (PATCHY_API_URL/token exported), can whoami and upload.

Decisions implemented

Local dev environment, Dev runner supervisor prototype, spec §11.


Filed from the Effect v4 port spec (#68) by the map task Write the port spec and file the build tickets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ciarea:serverready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions