mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-06 17:49:07 -05:00
[PR #1433] [MERGED] feat(d1): cutover production D1 + live worker serving v1.0 schema #9102
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1433
Author: @profvjreddi
Created: 4/22/2026
Status: ✅ Merged
Merged: 4/22/2026
Merged by: @profvjreddi
Base:
dev← Head:feat/vault-d1-cutover📝 Commits (1)
8d385b0feat(d1): cutover production D1 to schema v1.0 + live worker serving📊 Changes
5 files changed (+181 additions, -5 deletions)
View changed files
📝
interviews/staffml-vault-worker/src/rate_limit.ts(+5 -1)📝
interviews/staffml-vault-worker/src/types.ts(+10 -2)📝
interviews/staffml-vault-worker/wrangler.toml(+2 -2)➕
interviews/vault-cli/scripts/ship_d1.py(+132 -0)📝
interviews/vault-cli/src/vault_cli/compiler.py(+32 -0)📄 Description
Summary
Cutover of the production Cloudflare D1 database + staffml-vault Worker to the schema v1.0 corpus. Worker is live and serving v1.0 + Phase 2 reclassifications end-to-end.
Live verification (run at commit time):
Four fixes
compiler.py— populatechainstable fromchains.json. Was silently empty; only surfaced when D1 (FKs enforced by default, unlike SQLite) rejectedchain_questionsinserts withFOREIGN KEY constraint failed.types.ts(worker) — addcompetency_area,bloom_level,phase,human_review_*fields. Worker SQL was alreadySELECT *so columns flowed through; only the TS row interface needed updating.rate_limit.ts— floor expirationTtl at 60s. Old calc could emit 11s, which D1 KV rejects. Was throwing error 1101 on every request post-deploy.wrangler.toml— bumpSCHEMA_FINGERPRINTto match v1.0 vault.db (b97218dae…).New script
interviews/vault-cli/scripts/ship_d1.py— end-to-endvault build→ SQL dump →wrangler d1 execute --file. Handles FK ordering. Repeatable for future schema bumps. Used for this cutover; can be wired intovault shipas a leg later.Site cutover status — hybrid today
The bundled
corpus.jsonis still the primary data path for the Next.js site. The worker path works but is opt-in via env vars. Full sync→async conversion of allgetQuestions()callers is a separate refactor (deferred because every caller needs an audit pass).To flip when ready:
Still outstanding
staffml-vault.mlsysbook.aiisn't mapped; currently onworkers.devdefault🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.