Vijay Janapa Reddi
|
d8f6abae4b
|
feat(worker): Phase 3 D1 worker scaffold + shared types package
Phase 3 is CODE-COMPLETE; actual D1 creation + Worker deployment
require authenticated Cloudflare credentials (user action gate per
kickoff stop-conditions).
staffml-vault-worker/
wrangler.toml — DB binding, CORS allowlist, TTL env vars,
SCHEMA_FINGERPRINT placeholder,
GRACE_WINDOW_SECONDS for cross-release
serving.
src/index.ts — 6 endpoints (manifest, questions, questions/:id,
search, stats) with ETag + cursor pagination +
SWR Cache-Control + CORS.
src/types.ts — Env binding + row shapes.
README.md — deploy-day runbook.
Key v2.1 behaviors wired:
- X-Vault-Release is INFORMATIONAL (not hard-reject) — worker serves
from release_metadata.release_id; header is SLI signal only. Fixes
Soumith H-NEW-2 local-dev + SWR revalidation brownout.
- schema_fingerprint cold-start check hashes actual sqlite_master DDL
(not metadata-vs-metadata, closes Dean N-4). On mismatch: Cache-API
read-only mode with X-Vault-Degraded header, never 5xx (closes
Chip N-H1 total-outage risk).
- Cache keys keyed by release_id → deploy-time atomic POP
invalidation (H-14).
- ETag format: '<release_id>:q:<content_hash>' — 304 support
(Soumith H-NEW-2).
- Cursor pagination via opaque base64 {offset, filter_hash} tokens
(H-20). Clients never construct cursors.
- CORS allowlist from wrangler var; no wildcard in prod.
staffml-vault-types/
index.ts — shared TS contract types; pnpm workspace
protocol between worker + site (Soumith
M-NEW-1 resolution).
package.json — @staffml/vault-types, workspace-private.
vault-cli/scripts/
emit_d1_schema.py — generates d1-schema.sql from compiler DDL;
reports SHA-256 fingerprint to paste into
wrangler.toml SCHEMA_FINGERPRINT var.
d1-schema.sql — committed schema; applied to fresh D1 via
'wrangler d1 execute <db> --file d1-schema.sql'.
Deploy-day gates (per CUTOVER_QA.md §0 and TESTING.md phase-entry):
1. License decision resolved (L-10 still OPEN).
2. wrangler d1 create staffml-vault (prod + staging) — user action.
3. Apply d1-schema.sql + seed via d1-migration.sql.
4. FTS5 load-test gate: p99 warm ≤100ms, p99 cold ≤500ms,
≤500 D1 row-reads/query (Dean N-5 cost gate).
5. Data-plane SLI crons emitting to Grafana.
|
2026-04-16 12:42:13 -04:00 |
|