feat(wrangler): add SERVICE_SCOPE_DB hyperdrive binding#110
Conversation
Adds the SERVICE_SCOPE_DB hyperdrive binding (id 89158b50e55a4d5d9279b5d5c890ea7b) to both root wrangler.jsonc and deploy/system-wrangler.jsonc. This is the service's own authoritative scopes Hyperdrive, paired with the existing CHITTYOS_CORE_DB binding for projection into ChittyOS-Core. Required by chittyschema/identity/scripts/validate-fractal-scopes.ts. The consumer code already exists in server/lib/central-workflows.ts via the @chittyos/schema/scope-projector adapter (PR #103) — without this binding the projector falls back to the SERVICE_SCOPE_DATABASE_URL env var. Validated: chittyschema validate-fractal-scopes.ts passes against both wrangler files (exit 0). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
chittyfinance | 765f62c | Apr 30 2026, 07:08 PM |
|
@coderabbitai review Please evaluate:
|
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds a second Hyperdrive database binding named Changes
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
Code Review — PR #110:
|
| Issue | Severity |
|---|---|
env.dev/env.staging/env.production blocks missing hyperdrive in wrangler.jsonc |
Critical |
env.dev/env.staging blocks missing hyperdrive in deploy/system-wrangler.jsonc |
Critical |
Env interface missing CHITTYOS_CORE_DB and SERVICE_SCOPE_DB Hyperdrive types |
Critical |
SERVICE_SCOPE_DATABASE_URL fallback not in Env |
Medium |
Stale comment in deploy/system-wrangler.jsonc top-level hyperdrive block |
Low |
The binding ID and the production env block in deploy/system-wrangler.jsonc are correct — the fix is mostly additive (copy the hyperdrive array into the remaining env blocks and update env.ts).
There was a problem hiding this comment.
Pull request overview
Adds a new Cloudflare Hyperdrive binding (SERVICE_SCOPE_DB) to the Workers configs so the shared scope projector can write authoritative scopes into the service DB (and continue projecting into ChittyOS-Core).
Changes:
- Add
SERVICE_SCOPE_DBHyperdrive binding towrangler.jsonc. - Add
SERVICE_SCOPE_DBHyperdrive binding todeploy/system-wrangler.jsonc(top-level andenv.production).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| wrangler.jsonc | Adds SERVICE_SCOPE_DB Hyperdrive binding alongside CHITTYOS_CORE_DB at the top level. |
| deploy/system-wrangler.jsonc | Adds SERVICE_SCOPE_DB Hyperdrive binding at the top level and within env.production. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Hyperdrive bindings for fractal scope projection. | ||
| // CHITTYOS_CORE_DB → ChittyOS-Core aggregation. SERVICE_SCOPE_DB → service's own authoritative scopes. | ||
| // Required by chittyschema/identity/scripts/validate-fractal-scopes.ts | ||
| "hyperdrive": [ | ||
| { "binding": "CHITTYOS_CORE_DB", "id": "1d126444cff1416cb415447e6cc6d15a" } | ||
| { "binding": "CHITTYOS_CORE_DB", "id": "1d126444cff1416cb415447e6cc6d15a" }, | ||
| { "binding": "SERVICE_SCOPE_DB", "id": "89158b50e55a4d5d9279b5d5c890ea7b" } | ||
| ], |
There was a problem hiding this comment.
wrangler.jsonc has explicit env blocks, and the header comment notes certain bindings do not inherit into env blocks. Right now the new Hyperdrive bindings are only declared at the top level, so wrangler deploy --env production (and any other env deploys) may run without SERVICE_SCOPE_DB/CHITTYOS_CORE_DB bound. To avoid missing bindings at runtime, duplicate this hyperdrive array into the relevant env.* blocks (at minimum env.production, and any envs where scope projection should work).
| // Hyperdrive binding for fractal scope projection into ChittyOS-Core | ||
| "hyperdrive": [ | ||
| { "binding": "CHITTYOS_CORE_DB", "id": "1d126444cff1416cb415447e6cc6d15a" } | ||
| { "binding": "CHITTYOS_CORE_DB", "id": "1d126444cff1416cb415447e6cc6d15a" }, | ||
| { "binding": "SERVICE_SCOPE_DB", "id": "89158b50e55a4d5d9279b5d5c890ea7b" } | ||
| ], |
There was a problem hiding this comment.
The comment above the hyperdrive block still says “binding” and mentions only projection into ChittyOS-Core, but the config now declares two bindings (Core + SERVICE_SCOPE_DB). Update the comment to reflect both bindings (and optionally the validate-fractal-scopes requirement) so future edits don’t miss one of them.
Summary
SERVICE_SCOPE_DBHyperdrive binding (id89158b50e55a4d5d9279b5d5c890ea7b) to bothwrangler.jsoncanddeploy/system-wrangler.jsonc.CHITTYOS_CORE_DBbinding so the fractal scope projector can write authoritative scopes to the service's own DB and project into ChittyOS-Core.chittyschema/identity/scripts/validate-fractal-scopes.ts(it errors on missingSERVICE_SCOPE_DB).deploy/already had locally).Why
The shared scope projector (
@chittyos/schema/scope-projector, wired inserver/lib/central-workflows.tsvia PR #103) readsenv.SERVICE_SCOPE_DB?.connectionStringand falls back toSERVICE_SCOPE_DATABASE_URL. With this binding in place, scope writes go through Hyperdrive instead of the env-var fallback path.Validation
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit