Skip to content

Effect v4 port map #54

Closed
8 of 8 issues completed
Closed

Description

@allisonmahmood

Destination

A charted Effect v4 port whose decision log reads as the migration spec: every shape decision locked (packages by capability, HTTP shape, SQL, CLI, config, tests, guardrails, order) so the spec can be written and the build filed as ready-for-agent issues, one agent session each. The build itself runs from those issues, not under this map; mid-port decisions come back here as grilling tickets.

Notes

  • What "faithful" means. Behaviour at the two user-facing edges — how readers experience served pages and how agents experience the CLI and HTTP API — is preserved. Internals are free to be simpler; the port is also a clean-up.
  • Packages by capability, not by layer. The monorepo's packages become swappable capabilities (auth, patches, serving, storage, sql, api, cli) so any one can be ripped out or extended — especially serving, which tiers 1 and 2 will build on — and each package's test suite isolates problems to their source. YAGNI still applies: a capability with one consumer stays a module until a second appears.
  • Effect 4 RC, everywhere, pinned through a pnpm catalog: entry with overrides forcing every transitive effect/@effect/* to it. HTTP, HttpApi, SQL and CLI are all effect/unstable/* and may break in minors; accepted. Dependabot opens a PR per RC and an agent finishes each bump against MIGRATION.md. Two merged-but-unreleased breaks are known and planned for: the @effect/sql-pg native client (int8→bigint, timestamps→epoch ms) and the Config PascalCase rename.
  • Package by package on main. Each port step is one PR; main stays green; thin Effect.runPromise adapters at the boundary until the next package moves. No long-lived port branch.
  • Order: prototype → package decomposition → dev runner (first Effect 4 code; the harness every later PR is smoked on) → packages/api + --json (Fastify decodes through Schema as the interim adapter) → sql + auth → patches + storage → serving + apps/server on HttpApi/HttpRouter (Effect lint rules land here) → cli → wipe self-hosting artefacts, ADRs, CONTEXT-MAP.md redraw.
  • Inside the fence: --json with Effect Schema wire types (#35), the dev runner from Local dev environment and Dev runner supervisor prototype, the Effect half of taste-as-lint (#38), and the draft → patch rename as a rule: rename what you touch.
  • Self-hosting is over. Patchy Cloud is the only deployment. The JSON-file DB driver, docs/SELF_HOSTING.md, the env-registry doc-sync test, the Docker save/verify scripts and the operator's storage-driver choice go with it.
  • Skills every session consults: grilling + domain-modeling on grilling tickets; prototype on the prototype; read node_modules/effect/AGENTS.md and MIGRATION.md once Effect is installed; the two research write-ups on their branches — Effect 4 landscape and Effect done well for agents — what t3code does. ~/Dev/t3code is the reference codebase for conventions (single-file services, Context.Service, Schema.TaggedError, namespace imports).
  • ADRs sparingly, in docs/adr/, only for decisions meeting all three tests; inherited ADR-0000/0001 are retired by the PRs that supersede them. Expected to produce one: Postgres-only, the api contract package, the CLI's .local/dev/env precedence.

Settled while charting (2026-08-28, grilled with Allison)

  1. HTTP shape — /api/* is an HttpApi defined in packages/api (typed HttpApiClient for the CLI, OpenAPI for docs/API.md, HttpApiTest for tests); pages (/, /d/*, /report/*, /healthz) are plain HttpRouter routes owned by serving. The observable status-code contract of the pre-routing target classification (400/404/414) and of auth-before-body (no double rate-limit debit) is kept; the Fastify mechanisms (rewriteUrl + Symbol-marked request, preBody* flags) are dropped in favour of one raw middleware and one API-group middleware.
  2. SQL — @effect/sql-pg + SqlSchema; sql.withTransaction for the four manual transactions; row decoding through Schema in one module so the native-client type change lands in one place. Effect's Migrator replaces the hand-rolled runner (nothing deployed depends on schema_migrations), provided it composes migrations owned by several capability packages — the prototype checks. prepare: false reserved for the Neon pooler.
  3. Postgres only — the JSON-file driver is deleted; embedded-postgres is the dev/test store; app.test.ts moves onto template-cloned Postgres. ADR.
  4. CLI — effect/unstable/cli: --json via withGlobalFlags, client derived from packages/api, Effect owns argv and process lifecycle. Gated by the prototype (esbuild bundling, packed-CLI e2e core). The agent-visible exit-code contract is decided in its own ticket.
  5. Config — Effect Config per capability, Redacted secrets, fail-on-first-missing-key (matches today). Trusted-proxy CIDR parsing stays as a Schema because HttpMiddleware.xForwardedHeaders has no allow-list.
  6. Tests — @effect/vitest (it.effect, it.layer), HttpApiTest for API routes, NodeHttpServer.layerTest for raw-socket cases, TestClock for the mutable clock, Scope for manual close pairs, fault injection by alternate layers (no mocks). app.test.ts splits by capability as each ports.
  7. Limiter, sweep, analytics — our limiter's semantics (Retry-After, fails closed at 10k keys) are kept as an Effect service whose interface mirrors RateLimiter.consume, so a later swap to Effect's limiter + Redis store is a layer change; sweep is Effect.repeat(job, Schedule.spaced("1 hour")) forked in the server scope; analytics is a service whose finalizer flushes under 3 s. PostHog stays.
  8. Agent guardrails — AGENTS.md points at node_modules/effect/AGENTS.md; @effect/language-service diagnostics as errors gating typecheck (mechanism decided by a task ticket — TS 6 patch vs @effect/tsgo); the two t3code lint rules written locally for ESLint (no plugin exists); no vendoring, no Macroscope — its two review specs become repo skills for /code-review.
  9. Wire schemas live in packages/api (schemas + HttpApi + client), a third thing beside the two contexts; core shrinks to html-policy + ids.
  10. docs/API.md is rendered from OpenApi.fromApi by a small local renderer and pinned by a test (Effect has no markdown emitter).

Decisions so far

Not yet specified

  • A shared rate-limiter store for multi-replica production (Effect's Redis store, or a Postgres one) — surfaces with deployment work, which has its own map.
  • Neon specifics the port must design around once production points at it: transaction-mode pooler (prepare: false), scale-to-zero dropping sessions.
  • What the patch vocabulary looks like in CONTEXT.md once the code renames — lands in the CONTEXT-MAP.md redraw.

Out of scope

  • Feature-by-feature keep/drop of PatchPage-isms (mint, expiry, pins, quotas) — carried faithfully as foundations; decided by the systems that supersede them. Exception, decided on Package decomposition by capability: reports are removed — a free-service valve nothing later builds on, with a reader-facing surface that would otherwise leak into serving. First build ticket of the spec.
  • Deployment target, replicas, hosting infra, release channel — their own effort.
  • Auth replacement, tier 1/2 runtimes, the integration layer — each its own map; the port only leaves clean seams.
  • Self-hosting in any form.

Sub-issues

Sub-issues

8 of 8 Issues completed
Loading 8 sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    wayfinder:map

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions