4.5 KiB
4.5 KiB
Tasks — @suaveplan/api-router-worker-bridge
Every checkbox MUST reflect work actually done in this change.
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin each) - 0.2 If any worktrees exist under
.claude/worktrees/, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (git worktree remove) before opening a new one — code that has been lost twice on main is the failure mode this guards against. - 0.3 Confirm the package set in
MANIFEST.mdmatchesfind packages -maxdepth 3 -name package.jsoncount. Drift here means a prior change archived without regenerating the manifest.
1. Spec authoring
- 1.1 Read design doc §6 (per-request data flow) + §5.2a
- 1.2 Read umbrella
- 1.3 Read
openspec/AGENTS.mdSections 13 and 14 - 1.4 Draft
proposal.md - 1.5 Draft
specs/api-router-worker-bridge/spec.md - 1.6 Every requirement carries
**Verified by:**
2. Implementation
- 2.1 Scaffold
packages/api/api-router-worker-bridge/(0.1.0, deps:@suaveplan/api-worker-rpc,@suaveplan/api-types,@suaveplan/error,zod) - 2.2
src/main-side/—BridgeMain.dispatch(routeHit) → Promise<Response> - 2.3
src/worker-side/—BridgeWorker.serve(handler)accepts envelopes from main - 2.4
src/envelope-schemas/— Zod schemas forHttpDispatchEnvelope+HttpResponseEnvelope - 2.5
src/streaming-marshal/—Transferablestream marshalling both directions - 2.6
src/header-allowlist/— default deny list (authorization,cookie,set-cookie,x-csrf-token); per-route allowlist - 2.7
src/error-codes.ts— everyBRIDGE_*code - 2.8
src/index.ts— namespace re-exports - 2.9 Conformance: bridge MUST pass
runRouterConformance(Stage 4 gate) under worker-proxy surface
3. Tests
- 3.1
src/main-side/main-side.test.ts— given route match + body, envelope sent + response rehydrated - 3.2
src/worker-side/worker-side.test.ts— envelope decoded; handler invoked with reconstructed ctx; response envelope sent - 3.3
src/envelope-schemas/envelope-schemas.test.ts— invalid envelope rejected (BRIDGE_ENVELOPE_INVALID) - 3.4
src/streaming-marshal/streaming-marshal.test.ts— large request stream + large response stream both round-trip with back-pressure - 3.5
src/header-allowlist/header-allowlist.spec-conformance.test.ts—expectTypeOfAND runtime assertions thatAuthorization/Cookieare NEVER inctx.request.headersworker-side - 3.6
tests/no-raw-request.test.ts— pin invariant: envelope never carriesRequestreference; rawRequestis unreachable from worker - 3.7 Every
it(...)carries{ timeout: 5000 }
4. Documentation
- 4.1 Sibling
.mdfor every implementation.ts(≥200 words, basic + advanced examples) - 4.2 README links every co-located
.md; explicitly call out the no-raw-Requestinvariant - 4.3 Update CLAUDE.md
5. Pre-archive verification (the 5-gate triple)
- 5.1
bun run check— Biome 0/0/0 - 5.2
bunx turbo lint typecheck test --filter=@suaveplan/api-router-worker-bridge— green - 5.3
bunx turbo test:coverage --filter=@suaveplan/api-router-worker-bridge— 100/100/100/100 - 5.4
bun scripts/openspec-conformance.ts @suaveplan/api-router-worker-bridge— exit 0 - 5.5
bunx turbo build --filter=@suaveplan/api-router-worker-bridge— green - 5.6 Conformance gate:
runRouterConformancefrom@suaveplan/api-router/testingpasses against the bridge as the surface — required before Stage 4 can complete
6. Pre-archive 7-row checklist
- 6.1 Generics threaded;
expectTypeOfproves response type preserved across bridge - 6.2 Zod schemas validate envelopes on both sides
- 6.3 Every
BRIDGE_*code thrown from a production path - 6.4 Strict-mode behaviors (header allowlist on/off configurable; strict default)
- 6.5 OTel — N/A (host's request span continues across bridge; bridge adds
api.bridge.dispatchchild span tested withInMemoryMetricExporter) - 6.6 Lifecycle dedup — N/A
- 6.7 No retroactive tick
7. Archive
- 7.1 Fold spec delta into
openspec/specs/api-router-worker-bridge/spec.md - 7.2 Move to
openspec/archive/<yyyy-mm-dd>-api-router-worker-bridge/ - 7.3 Tick Stage-3 row in umbrella
- 7.4 Refresh
MANIFEST.md