Skip to content

Phase 2: summary.json coverage report + backfill dispatch - #623

Merged
neuromechanist merged 2 commits into
feature/issue-618-epic-summary-11from
feature/issue-620-phase2-backfill
May 26, 2026
Merged

neuromechanist merged 2 commits into
feature/issue-618-epic-summary-11from
feature/issue-620-phase2-backfill

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

  • Backend service manifest-coverage.ts walks dataset_versions, probes data.nemar.org/<id>/<v>/summary.json for each, classifies as ok | stale | missing | error against the target schema (currently 1.1) with bounded parallelism (8 concurrent fetches).
  • Admin routes:
    • GET /admin/summary/coverage — returns the full report.
    • POST /admin/manifest/dispatch — fires repository_dispatch[generate-manifest] for one (dataset_id, version) with skip_callback: true so no manifest_jobs row needs to be seeded for backfill.
  • CLI: nemar admin summary check [--fix] [--id <id>] [--only-stale] [--json] — colored table + opt-in dispatch loop, throttled 1.5s between dispatches.
  • Weekly cron .github/workflows/check-summary-drift.yml opens or updates a drift issue when coverage isn't clean.
  • triggerManifestGeneration() extended with skipCallback option (additive).
  • 10 unit tests for the schema-comparison logic — forward-compat for future minor/major schema bumps, transient 5xx is error (not missing), URL v prefix normalisation.

Closes #620
Phase 2 of epic #618.

Why this exists

After Phase 1 (nemarDatasets/.github#15) shipped schema 1.1, every existing version is still at 1.0 until something re-runs generate-manifest. Without a coverage tracker + backfill tool we'd manually inventory ~120 versions and dispatch each by hand. This phase makes both routine and continuous.

Test plan

  • bun test test/manifest-coverage.unit.test.ts — 10/10 pass
  • cd backend && bun run typecheck — clean
  • bunx tsc --noEmit at repo root — clean
  • Smoke test after merge: nemar admin summary check --json against prod (admin token)
  • Smoke test after merge: nemar admin summary check --id <one-on-dataset> --fix to backfill one stale version end-to-end
  • Drift cron workflow_dispatch once after deploy to confirm the issue-creation path

Companion / next

  • Phase 3 (Phase 3: backend page-bundle endpoint #621) — backend page-bundle endpoint (independent, parallel-developable).
  • After the epic lands on dev, run the full backfill against all ~120 published versions, then verify drift is clean.

Phase 2 of epic #618.

Backend:
- new service backend/src/services/manifest-coverage.ts walks
  dataset_versions, probes data.nemar.org/<id>/<v>/summary.json for
  each, and classifies as ok/stale/missing/error against the target
  schema (currently 1.1). Bounded parallelism (8) protects the
  upstream rate limit.
- new admin route GET /admin/summary/coverage returns the report.
- new admin route POST /admin/manifest/dispatch fires
  repository_dispatch[generate-manifest] for a single version with
  skip_callback=true so the worker doesn't need a seeded manifest_jobs
  row.
- triggerManifestGeneration() extended with skipCallback option.

CLI:
- new `nemar admin summary check [--fix] [--id <id>] [--only-stale]
  [--json]` walks the coverage report, prints a colored table or
  emits JSON, and with --fix dispatches generate-manifest for every
  stale or missing version (throttled 1.5s).
- new typed api helpers getSummaryCoverage + dispatchManifest.

Cron:
- .github/workflows/check-summary-drift.yml runs weekly (Mon 09:00
  UTC), opens or updates a drift issue when coverage is not clean.

Tests:
- 10 unit tests for schema-comparison + URL normalisation logic.

Closes #620 (phase 2 of #618).
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Addressed PR review (4 agents).

HIGH (silent-failure-hunter): cron Python heredoc could crash silently, skipping every downstream conditional. Now wraps parse in try/except, writes drift=-1 sentinel on failure, and a new "report broken" branch opens / updates a P1 issue separately from the drift issue. Both branches also pre-create the drift/P1/P2 labels (idempotent) so first-run doesn't fail closed with "could not add label".

HIGH 88% (code-reviewer): gh issue create --label drift,P2 now preceded by gh label create ... --force || true for both labels.

82% (code-reviewer): probeSummary now honors already-aborted outer signals; previously the listener never fired and the fetch ran to its 8 s timeout.

Severity 7 (pr-test-analyzer): added 3 tests — empty schema_version → error (not stale), forward-compat schemas echo the version verbatim, pre-aborted outer signal short-circuits fetch.

Comment fixes (comment-analyzer): moved the "Sentinel value the generator emits" docstring from compareSchemas to TARGET_SCHEMA where it actually applies. Fixed "123 dataset fetches" → "all N published versions". Added rationale to DISPATCH_THROTTLE_MS referencing GitHub's 500/hour ceiling. Added intent note on the SQL filter (do NOT tighten to nm-only — on* must stay per catalog policy). Hard-asserted the skipCallback === true invariant in the dispatch handler so a future change of that default can't silently leak HMAC material via empty callback_token.

Out of scope (acknowledged, not addressed): integration test of buildCoverageReport against a live D1 — agent agreed it wasn't worth the maintenance cost. CLI exit-code test on partial dispatch failure — the throttle loop is thin enough that operator review of the exit-code line is adequate; a follow-up issue can add the harness if drift backfill becomes scripted.

Tests: 13/13 passing (was 10). Backend typecheck clean. CI pending on this push.

@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR623

Version: 0.8.35-PR623.12f60d6
Commit: 12f60d6


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit f9ae17d into feature/issue-618-epic-summary-11 May 26, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-620-phase2-backfill branch May 26, 2026 20:05
neuromechanist added a commit that referenced this pull request May 27, 2026
…#630)

* fix(admin): probe summary.json directly from S3 (not via self-Worker)

Discovered on first post-deploy smoke of /admin/summary/coverage: all 130
published versions classified as kind: error, status: 522 (Cloudflare
'origin connection timed out'). Direct curl to the same
data.nemar.org/<id>/<v>/summary.json URL from outside returned 200 in
~730ms. The 522 only happens when the call originates inside the Worker.

Root cause: probeSummary used globalThis.fetch against
data.nemar.org/<id>/<v>/summary.json, but that URL is served by the SAME
Worker that hosts /admin/summary/coverage. Fanning out 8 concurrent ×
130 ids triggers Worker-to-Worker subrequest behavior that 522s under
load. Cross-component code-reviewer flagged this as 'option c' on PR
#623 (the cleaner alternative to the cache-bust fix we shipped at the
time); the bill came due on first prod run.

Fix: refactor probeSummary to read S3 directly via loadSummary() — the
same code path Phase 3's page-bundle service uses for its summary fan-in.
Bypasses CF + the self-call entirely, so no subrequest limit and no
24h s-maxage to cache-bust around.

Wiring: introduce SummaryFetcher type + defaultSummaryFetcher(env)
builder, and dependency-inject the fetcher into probeSummary /
buildCoverageReport. Tests stub the fetcher directly instead of swapping
globalThis.fetch.

Tests: 11 unit tests cover the schema classifier (ok / stale /
forward-compat 1.2 / forward-compat 2.0 / missing / error / malformed
JSON / empty schema_version / missing key / non-string schema /
fetcher-args wire contract). Backend typecheck clean.

* review(#630): hang-protection timeout, default-arg fix, ordering + totals tests

This branch was previously deployed

1 inactive deployment
npm — 12f60d6a Deployed May 26, 2026 by neuromechanist via publish #1155
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