fix(spr-policies): wire seed-spr-policies into seed-bundle-energy-sources#3089
Merged
Conversation
…rces scripts/seed-spr-policies.mjs exists as a runnable seeder with proper isMain guard, but no Railway service ever invokes it. /api/health shows sprPolicies as EMPTY with seedAgeMin: null — energy:spr-policies:v1 has literally never been written to Redis. Wired it as a bundle entry alongside the other energy seeders. Cadence: weekly. Static-registry data (scripts/data/spr-policies.json) only needs to run once after deploys + restarts to populate the key; the 400d maxStaleMin in api/health.js confirms intent. 60s timeout is generous for a JSON-file read + Redis write. Tests: node --check on the bundle clean; npm run typecheck clean.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
Greptile SummaryWires Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Railway as Railway Bundle Service
participant BR as _bundle-runner.mjs
participant Redis as Redis (Upstash)
participant Seeder as seed-spr-policies.mjs
participant FS as scripts/data/spr-policies.json
Railway->>BR: runBundle('energy-sources', [..., SPR-Policies])
BR->>Redis: GET seed-meta:energy:spr-policies
Redis-->>BR: null (never seeded)
Note over BR: No fetchedAt → skip freshness gate, run seeder
BR->>Seeder: execFile(node seed-spr-policies.mjs)
Seeder->>FS: readFileSync('spr-policies.json')
FS-->>Seeder: raw JSON registry
Seeder->>Redis: SET energy:spr-policies:v1 (TTL 400d)
Seeder->>Redis: SET seed-meta:energy:spr-policies (TTL 400d)
Redis-->>Seeder: OK
Seeder-->>BR: exit 0
BR->>BR: ran++, log "Done"
Note over Redis: health /api/health sprPolicies: OK
Reviews (1): Last reviewed commit: "fix(spr-policies): wire seed-spr-policie..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this PR?
`scripts/seed-spr-policies.mjs` exists as a complete, runnable seeder with proper `isMain` guard at line 57-59. But no Railway service ever invokes it. `/api/health` shows `sprPolicies` as EMPTY with `seedAgeMin: null` — `energy:spr-policies:v1` has literally never been written to Redis since the seeder was added.
`scripts/seed-energy-spine.mjs` references the SPR key but only READS it; doesn't seed it. `api/health.js` registers `maxStaleMin: 576000` (400 days), confirming the intent for a static registry.
Fix
Add an entry to `scripts/seed-bundle-energy-sources.mjs` so the existing Railway bundle service runs SPR alongside its energy siblings.
```js
{ label: 'SPR-Policies', script: 'seed-spr-policies.mjs', seedMetaKey: 'energy:spr-policies', intervalMs: 7 * DAY, timeoutMs: 60_000 },
```
Weekly cadence is generous — the data is a static JSON registry (`scripts/data/spr-policies.json`); it only needs to run once after deploys + restarts. The 60s timeout is generous for a JSON-file read + Redis write.
Files
Testing
Post-Deploy Monitoring & Validation
Related