Skip to content

spike: Step-2 deploy oracle — static Effect-DI graph + ManagedRuntime (DO NOT MERGE)#23

Open
usirin wants to merge 1 commit into
mainfrom
umut/spike-effectdi-deploy
Open

spike: Step-2 deploy oracle — static Effect-DI graph + ManagedRuntime (DO NOT MERGE)#23
usirin wants to merge 1 commit into
mainfrom
umut/spike-effectdi-deploy

Conversation

@usirin
Copy link
Copy Markdown
Member

@usirin usirin commented Jun 1, 2026

Throwaway spike — do not merge. Close this PR to destroy the pr-<n> stage.

Tests two unknowns from the Effect-DI refactor audit via the pr-<n> preview auto-deploy.

Q1 — plan-phase safety. Does building the idiomatic static layer graph fire DrizzleLive's eager connection.raw at alchemy deploy plan time (→ deploy error), or stay deferred to runtime (→ safe)?

Q2 — runtime wiring. Does a route driven by a worker-init ManagedRuntime over the static AppLayer resolve real data at runtime?

How to read the result

  • Deploy succeeds → Q1 safe (lazy ManagedRuntime never builds the graph at plan).
  • Deploy fails at plan → eager connection.raw fired at plan. One-line fix: defer it under Effect.cached, like BetterAuthLive.
  • curl https://<pr-url>/api/spike/whoami{"ok":true,"hasSession":false,"user":null} confirms Q2 (Drizzle + better-auth resolve through the injected runtime).

Scope (additive, isolated)

  • spike/graph.tsDrizzleLive / PasaportLive / AppLayer (idiomatic R-channel layers, zero casts).
  • spike/route.ts — throwaway GET /api/spike/whoami, run through the spike ManagedRuntime.
  • index.ts — builds the runtime in init from the real captured ambient context; merges the route additively. /fate, /api/auth/*, /fate/live, /api/health untouched.

Lazy wiring (primary); a one-line eager toggle is left in index.ts to stress Q1 at plan time. pnpm typecheck green, zero as/any.

🤖 Generated with Claude Code

… probe

Additive, non-merge deploy spike to test two things under a single future
`alchemy deploy --stage spike-effectdi`:

  Q1 (plan-phase safety): does building DrizzleLive (eager `connection.raw`
      inside Layer.effect) fire that runtime-only binding at deploy PLAN time?
  Q2 (runtime wiring): does a route on static AppLayer + a worker-init
      ManagedRuntime resolve REAL data (a session lookup)?

- worker/spike/graph.ts — DrizzleLive / PasaportLive / AppLayer (layer defs
  only; the branch's structural-stub ambient + stub ManagedRuntime dropped).
- worker/spike/route.ts — GET /api/spike/whoami, runs Pasaport.validateSession
  through the spike ManagedRuntime, returns JSON via runPromiseExit.
- worker/index.ts — builds the ManagedRuntime in init from AppLayer with the
  REAL captured ambient context (Effect.context + Layer.succeedContext, zero
  casts); merges the route additively. LAZY primary wiring (Q1 safe by lazy
  construction); one-line EAGER toggle to stress Q1 at plan time.

typecheck green; zero `as`/`any`; biome clean. Not deployed, not pushed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant