Skip to content

Phase 5 (E): records-ready webhook + records_status column - #745

Merged
neuromechanist merged 2 commits into
feature/issue-736-epic-publish-robustnessfrom
feature/issue-742-phase5-records
Jun 11, 2026
Merged

neuromechanist merged 2 commits into
feature/issue-736-epic-publish-robustnessfrom
feature/issue-742-phase5-records

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Phase 5 (E) of epic #736, the nemar-cli half: the records-ready webhook receiver + records_status observability column. Pairs with nemarDatasets/.github#42 (which dispatches generate-records on publish + POSTs the callback). Together they close the last "didn't run" gap from the nm000111 report — records.json 404'd for every dataset because the workflow was never dispatched and had no callback.

  • Migration 0041 0041_dataset_records_columns.sql — records_status TEXT CHECK (records_status IN ('pending','ready','failed')), records_checked_at TEXT, idx_datasets_records_status. Mirrors the archive columns (0036); plain ADD COLUMN, not in datasets_fts/embed-dirty.
  • POST /webhooks/records-ready in webhooks.ts — line-for-line mirror of /archive-ready: X-Webhook-Token (NEMAR_WEBHOOK_TOKEN) auth, strict status (ready|failed), UPDATE datasets SET records_status=?, records_checked_at=datetime('now'), 404 on 0 rows, 400 on bad body. No retry (records generation is light; unlike Phase 3 archive retry). records.json is served from S3 directly (loadRecords), so this column is observability-only.

Closes #742
Part of epic #736

Test plan

bun test backend/test/records-status-migration.test.ts — 4 tests, real in-memory SQLite (all migrations applied), no mocks: migration 0041 adds the columns NULL-by-default; the CHECK accepts pending/ready/failed+NULL and rejects others; idx_datasets_records_status exists; the records-ready UPDATE flips status + stamps checked_at and changes 0 rows for an unknown dataset. Typecheck (tsc --noEmit) clean; Biome clean; the migration-chain test (archive-status) still green with 0041 applied.

Deploy ordering: this receiver must be on prod before the .github callback matters; the .github success callback is best-effort (non-fatal) precisely so the two can land independently. The migration + webhook deploy at epic finalization (epic -> dev -> main, d1 migrations apply).

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Sonnet /review-pr addressed: /webhooks/records-ready faithfully mirrors /archive-ready's auth+validation (token+timingSafeEqual, strict status, 0-rows->404, parse->400); migration 0041 structurally correct, sorts after 0040, no fts/embed interaction; idempotent; tests sound. Addressed Issue 1 (Important): the 'pending' enum value is reserved (Phase 5 writes only ready/failed via the callback, exactly like archive_status 0036) — clarified the migration comment so the schema is honest rather than implying pending is written.

@neuromechanist
neuromechanist merged commit acbfd40 into feature/issue-736-epic-publish-robustness Jun 11, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR745

Version: 0.8.53-PR745.72e614d
Commit: 72e614d


🤖 Updated on each push.

This branch was previously deployed

1 inactive deployment
npm — 72e614d7 Deployed Jun 11, 2026 by neuromechanist via publish #1390
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.

1 participant