Skip to content

fix(replication): reconcile archived DBH records into serving - #3

Open
phibkro wants to merge 2 commits into
agent/live-replication-r3from
agent/f1-close-dbh-serving
Open

fix(replication): reconcile archived DBH records into serving#3
phibkro wants to merge 2 commits into
agent/live-replication-r3from
agent/f1-close-dbh-serving

Conversation

@phibkro

@phibkro phibkro commented Jul 22, 2026

Copy link
Copy Markdown
Owner

F1 closure: DBH evidence reaches serving

Root cause: the R3 worker archived and parsed DBH responses but discarded the parsed records; NTNU reconciliation therefore published with empty DBH inputs, and the fixture-fed manual script was the only non-empty path.

This branch:

  • fetches both DBH tables from the NTNU job, archives exact response bytes, parses them, and reconciles DBH + NTNU in one atomic publication;
  • archives each parsed record's exact JSON.stringify(raw) bytes under the content-addressed DBH evidence namespace so served source_record.raw_payload can be hash-traced;
  • retires the fixture-fed ingest:official-curriculum script from the serving path while keeping fixture construction test-only.

Experience / verification

  1. Trigger one run with the ingest worker endpoint:
    curl -X POST -H "Authorization: Bearer $RUN_TOKEN" https://<ingest-host>/v1/runs/full
  2. Wait for the NTNU run to complete, then:
    curl https://<api-host>/v1/programmes
    curl "https://<api-host>/v1/planner/baseline?programmeVersionId=<served-id>"
  3. Confirm the published revision contains NTNU curriculum and DBH-sourced records.
  4. Recompute SHA-256 over a served DBH source_record.raw_payload; it matches an R2 object at evidence/dbh/table-<id>/sha256/<hash>.json, and its observed_at equals the run's retrievedAt.
  5. Rename/remove packages/source-dbh/fixtures/* and packages/source-ntnu/fixtures/* plus the retired script imports, repeat the trigger and GETs, and observe the same live DBH-provenanced serving path.

Checks: bun run check:types, bun run validate, bun test apps/ingest-worker/src/replicate-dbh.test.ts, and bun test.

Real: the code path uses live DBH/NTNU fetches and R2/D1 bindings; no Cloudflare deployment or advisor gate was run (per instruction).

@phibkro
phibkro changed the base branch from main to agent/live-replication-r3 July 22, 2026 17:56
@phibkro
phibkro force-pushed the agent/f1-close-dbh-serving branch from 72f5509 to 0705927 Compare July 22, 2026 18:11
phibkro added a commit that referenced this pull request Jul 22, 2026
The suite proved falsifiers #1/#3 (query gate serves zero fixture rows even
with seeds present) but never exercised migration 0006 — a destructive DELETE
shipped with zero coverage. Add assertions that apply 0006 against the
already-ingested DB: fixture course_versions go from >0 to 0, and a re-fetched
GET /v1/courses deep-equals the pre-cleanup response (removing the seeds
changes NOTHING served, and the migration touches no published course version).

Co-Authored-By: Claude Opus 4.8 <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.

2 participants