Skip to content

feat(emit-manifest): schema 1.1 — embed README content inline - #15

Merged
neuromechanist merged 2 commits into
mainfrom
feature/issue-619-schema-11-generator
May 26, 2026
Merged

neuromechanist merged 2 commits into
mainfrom
feature/issue-619-schema-11-generator

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

  • Bump summary.json schema_version to 1.1
  • Embed README content (raw markdown) under readme.content for non-annexed READMEs ≤ 256 KB
  • Add readme.content_bytes, readme.sha256, readme.truncated for diagnostics and integrity
  • Annexed, oversize, binary, or unreadable READMEs → truncated: true, content: null so consumers fall back

Eliminates the per-pageload raw.githubusercontent.com round-trip that was the dominant cold first-paint latency for the README panel on ww2.nemar.org/dataset/<id>.

Closes nemarOrg/nemar-cli#619
Phase 1 of nemarOrg/nemar-cli#618 (epic: summary.json schema 1.1 + page-bundle)

Contract

Schema 1.1 is additive. Consumers that only read readme.path (schema 1.0 contract) keep working; the new fields just go unread.

"readme": {
  "path": "README.md",
  "content": "# Dataset\n\nFull markdown body…",
  "content_bytes": 4827,
  "sha256": "abc123…",
  "truncated": false
}

Edge cases (truncated: true):

  • Annexed README (key is not git:<sha>): content lives in S3, we don't have IAM here
  • Over 256 KB cap: avoids unbounded memory; content_bytes records actual size, sha256 left null
  • Binary blob (rare in BIDS): content can't be UTF-8 decoded; sha256 still set for change-detection

Test plan

  • 41 unit tests pass, including 6 new schema-1.1 tests:
    • test_summary_schema_version (asserts "1.1")
    • test_summary_readme_content_inline (verifies inline embedding)
    • test_summary_readme_metadata (content_bytes + sha256 correctness)
    • ReadmeOversizeTruncatedTests (300 KB README → truncated)
    • ReadmeAnnexedTruncatedTests (annex symlink README → truncated)
    • ReadmeNoneSchema11Tests (no README → readme is None, schema still 1.1)
  • test_readme_priority_picks_plain_README updated to assert inline content from selected candidate
  • Smoke test: manual workflow_dispatch[generate-manifest] on nm099999 after merge, verify summary.json has schema_version: "1.1" and readme.content
  • Backfill workflow (nemarOrg/nemar-cli phase 2) re-runs every existing version

Companion work

Schema 1.1: summary.json.readme now ships {path, content, content_bytes,
sha256, truncated} for non-annexed READMEs up to 256 KB. Annexed,
oversize, binary, or unreadable READMEs ship truncated=true with
content=null so consumers fall back to fetching on demand.

Eliminates the per-pageload raw.githubusercontent.com round-trip that
was the dominant first-paint latency on ww2.nemar.org dataset pages.

Closes nemarOrg/nemar-cli#619 (epic #618).
…ests

Addressing review findings from PR #15:

- emit_manifest.py: every truncated branch now emits a structured stderr
  line (`readme_truncated` / `readme_extract_failed` with reason=…)
  so ops can grep for non-fast-path publishes. Thread dataset_id +
  version through derive_readme for those messages.
- cat-file-failure branch now reports content_bytes=None instead of
  echoing the manifest's size — we never read the blob, so claiming a
  byte count was misleading. Documented in the derive_readme docstring.
- New ReadmeBinaryTruncatedTests: locks the unique sha256-set-but-
  content-None 4-tuple. Includes >512-byte padding to sidestep a
  pre-existing build_manifest bug (filed as follow-up).
- New ReadmeCatFileFailureTests: direct unit test against a bogus sha
  in an empty real-git repo; asserts truncated=True with all-None
  content fields and no crash.
- Oversize fixture now uses multibyte UTF-8 so a future
  len(str) vs len(bytes) regression on content_bytes is visible.
- test_summary_schema_version comment tightened: schema 1.1 is
  additive for path-keyed reads but breaks strict-equality checks on
  the old 1-key readme dict.
@neuromechanist

Copy link
Copy Markdown
Member Author

Addressed PR review (4 agents):

High (silent-failure-hunter): added structured readme_truncated / readme_extract_failed stderr lines on every truncated branch (annex / oversize / cat-file failure / non-UTF-8) with dataset_id, version, candidate, and reason=…. Kept the publish non-blocking — failing the entire publish over a malformed README would be worse UX. Loud warning + truncated flag is the right balance.

Medium (code-reviewer #2): content_bytes semantics tightened. The cat-file-failure branch now reports content_bytes=None instead of echoing the manifest size, since we never read the blob. Documented in the new derive_readme docstring.

Medium (code-reviewer #1) + comment-analyzer: rephrased the "additive" claim. Schema 1.1 is additive for path-keyed reads but breaks strict-equality checks against the old 1-key {path} dict. Test comment updated.

Severity 7 + 6 (pr-test-analyzer): added the two missing test classes:

  • ReadmeBinaryTruncatedTests: locks the unique sha256-set-but-content-None 4-tuple for non-UTF-8 READMEs.
  • ReadmeCatFileFailureTests: direct unit call with a bogus SHA in a real empty git repo; asserts the graceful-degradation contract.

Low (pr-test-analyzer): oversize README fixture now uses multibyte UTF-8 so a len(str) vs len(bytes) regression on content_bytes would be visible.

Out of scope, filed as follow-up: pre-existing latent bug in build_manifest's pointer-detection probe — surfaced while authoring the binary-README test. subprocess.check_output(..., text=True) blows up on <512-byte non-UTF-8 blobs. Tracked in #16.

Tests: 45/45 passing locally (was 41 → +4). CI pending on this push.

@neuromechanist
neuromechanist merged commit c6fdebd into main May 26, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-619-schema-11-generator branch May 26, 2026 18:53
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.

Phase 1: generator schema 1.1 — embed readme.content

1 participant