Skip to content

Epic: summary.json schema 1.1 + page-bundle (dataset detail perf) - #625

Merged
neuromechanist merged 3 commits into
devfrom
feature/issue-618-epic-summary-11
May 26, 2026
Merged

neuromechanist merged 3 commits into
devfrom
feature/issue-618-epic-summary-11

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Cut cold dataset-detail latency on ww2.nemar.org by (a) embedding README content in summary.json so the website stops roundtripping GitHub for every page, (b) adding tooling to backfill + monitor schema drift across all published versions, and (c) introducing a single page-bundle.json endpoint that returns landing + metadata + summary + catalog in one response so the website's cold-load waterfall collapses to one RTT.

Closes #618 (epic). Sub-issues #619, #620, #621 closed by their squash-merges.

Phases

# Title Repo PR
1 Generator schema 1.1 — embed readme.content nemarDatasets/.github #15
2 Coverage report + backfill dispatch + drift cron nemarOrg/nemar-cli #623
3 Backend /page-bundle.json endpoint nemarOrg/nemar-cli #624

Companion website work runs in parallel on a separate agent: nemarOrg/website#63 (consume inline README), #64 (progressive tree), #65 (cache invalidation).

What ships in this PR

  • Backend — two new admin routes (GET /admin/summary/coverage, POST /admin/manifest/dispatch), one new public route (GET /<id>/page-bundle.json?v=<v>), one new service (manifest-coverage.ts + page-bundle.ts), triggerManifestGeneration extended with skipCallback option.
  • CLI — nemar admin summary check [--fix] [--id <id>] [--only-stale] [--json].
  • CI — .github/workflows/check-summary-drift.yml (weekly Mon 09:00 UTC, opens or updates an issue when drift is detected; opens a separate P1 issue if the coverage probe itself is broken).
  • Tests — 27 new unit tests (10 manifest-coverage + 17 page-bundle including the cache-policy truth table).

Schema 1.1 contract

summary.json now ships schema_version: "1.1" with readme.content (raw markdown) for non-annexed READMEs up to 256 KB. Annexed, oversize, binary, and unreadable READMEs ship truncated: true, content: null so consumers fall back. Schema 1.0 readers that consume readme.path keep working; strict-equality consumers will see a shape change.

Post-merge plan

  1. Deploy backend (auto via deploy-backend.yml on merge to dev → main).
  2. nemar admin summary check --json against prod to confirm versions: ~150, ok: 0, stale: ~120, missing: ~30 (every existing version is schema 1.0 today).
  3. nemar admin summary check --fix --yes to backfill — workflow runs queue on nemarDatasets/.github runner pool, ~4 min throttled.
  4. nemar admin summary check again to confirm zero drift.
  5. Smoke /<id>/page-bundle.json?v=v1.0.0 against a known-healthy on* dataset to confirm complete: true and the README embedded inside summary.readme.content.
  6. Hand off to the website agent: Eliminate per-pageload GitHub roundtrip for README website#63 can ship its consumer change as soon as backfill completes.

Test plan

  • Phase 1: 45 unit tests pass on generator (python3 scripts/test_emit_manifest.py)
  • Phase 2: 13 unit tests pass (bun test test/manifest-coverage.unit.test.ts)
  • Phase 3: 17 unit tests pass (bun test test/page-bundle.unit.test.ts)
  • Backend typecheck clean on every phase
  • Each phase reviewed via /pr-review-toolkit:review-pr with 4 agents (code, tests, errors, comments); findings addressed before merge
  • Cross-phase /review-pr against this epic PR (per project memory feedback_cross_phase_review)
  • Post-deploy smoke + backfill steps above

Merge strategy

Regular merge (gh pr merge --merge), not squash — preserves the 3 phase commits per project convention (MEMORY.md Git Merge Rules).

* feat(admin): summary.json coverage report + backfill dispatch

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).

* review(#623): drift cron resilience, labels, abort wiring, comments
* feat(data): page-bundle endpoint for one-RTT dataset detail SSR

Phase 3 of epic #618 / Closes #621.

New `GET /<id>/page-bundle.json?v=<v>` returns landing + enriched
metadata + summary + catalog row in one JSON response so the website
can render the dataset detail page in a single SSR fetch instead of
its current 4-parallel-SSR + 2-deferred-client waterfall.

Internals:
- backend/src/services/page-bundle.ts owns the fan-in. Each upstream is
  wrapped in Promise.allSettled and surfaces as a tagged union
  ({ok: true, data} | {ok: false, error}) so a single failure doesn't
  blank the whole bundle.
- bundle.complete drives the cache header: success path gets long
  s-maxage + SWR, partial-failure path gets no-store so a transient
  blip isn't pinned at the edge for 24h.
- Skips the latestManifest read (multi-MB) — the website renders the
  tree progressively from summary.paths per nemarOrg/website#64, so
  metadata.bids_index would be unused work here.
- pickVersion falls back to landing.latest when the requested version
  is missing or unknown rather than 404-ing the whole bundle; the
  consumer can render a 'version not found, showing latest' UI from
  the bundle's own data.

Route is registered before /:datasetId/:version so Hono doesn't treat
'page-bundle.json' as a version param. Mirrors the metadata.json
registration order.

Tests: 10 new unit tests for the pure helpers (pickVersion + settled).
Per project policy, no D1/S3 mocks for the full buildPageBundle —
end-to-end coverage is via the post-deploy smoke against a real
dataset.

* review(#624): hard-fail D1, extract isBundleComplete, enrichment_degraded
… no-store coverage, P1 cron escalation, route registration test)
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Cross-phase /review-pr complete (4 agents). Two real cross-phase bugs surfaced that weren't visible to per-phase reviews:

Fixed inline:

  • code-reviewer 88% (Phase 2 ↔ private datasets): listAllPublishedVersions was missing visibility = 'public'. Private datasets (nm000103-nm000107 are intentionally private) would classify as missing because the probe goes through data.nemar.org whose visibility gate 404s them. --fix would dispatch workflows regenerating S3 artifacts nobody can read. Added the filter with a docstring pinning why.

  • code-reviewer 85% (Phase 2 ↔ Phase 1's cache policy): probeSummary fetched the same URL whose handler ships s-maxage=86400, swr=86400. After --fix, the re-check could see stale schema for up to 48 h — the CLI's "re-run check to verify drift cleared" guidance was a lie. Added a per-request ?_cb=<ts> cache-bust param + a test asserting the value is unique per call.

  • silent-failure-hunter HIGH: /admin/summary/coverage was missing Cache-Control. Cloudflare's heuristic TTL could pin a stale all-green report against the cron, silently masking a real drift week. Added no-store, must-revalidate.

  • silent-failure-hunter MEDIUM: Added a majority_errored branch to the cron — when more than half the catalog reports error, it's almost certainly an S3-route or IAM problem, not individual stale summaries. The cron now opens a distinct P1 "probe failing" issue with route-specific triage steps instead of editing the same P2 "drift" issue forever while --fix dispatches workflows that succeed-but-don't-help.

  • pr-test-analyzer severity 8: Added test/page-bundle-route.test.ts mirroring the established data-summary-route.test.ts pattern — asserts the route is registered, returns 404 on invalid id, and is ordered before any depth-2 /:datasetId/:version capture (catches the registration-order regression the handler's own docstring warns about).

  • comment-analyzer: Softened the bundle docstring's claim about README content being available today (it isn't until backfill runs); replaced the memory-note reference with an inline summary; dropped the literal "(1.1)" from the cron header in favor of pointing at the source-of-truth constant.

Deferred as follow-up issues (real but out of scope for this perf-focused epic):

Tests: 34 unit tests passing across 3 files (was 30 → +4). Backend typecheck clean. Phase reviews + this cross-phase review all addressed.

CI pending on this push.

@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR625

Version: 0.8.35-PR625.d782e16
Commit: d782e16


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 094e03f into dev May 26, 2026
10 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-618-epic-summary-11 branch May 26, 2026 20:50

This branch was previously deployed

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