Skip to content

Coverage contract and reader registry (A1) - #2374

Merged
neuromechanist merged 6 commits into
feature/issue-2182-epic-pq-evidencefrom
feature/issue-2185-coverage-contract
Nov 25, 2026
Merged

neuromechanist merged 6 commits into
feature/issue-2182-epic-pq-evidencefrom
feature/issue-2185-coverage-contract

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Part of #2185
Part of #2182

Card A1 of the publication-queue plan: the coverage contract and the reader registry that cards A2, A4, A5, A6 and A9 build on.

What changed

  • Reader registry (shared/identifier-readers.ts): RangeSource, a page cache with 64 KiB pages, coalesced reads and a read/byte tally, ReaderLimits, FormatReader, the closed ReaderId union and the new incomplete reasons. READERS holds EDF/BDF only (256 bytes, one read). formatCoverage moved here and returns { byReader, unscreened }. A companion that a reader claims counts with its recording; a missing one is counted and makes that recording partial.
  • Shared builder (shared/identifier-report-builder.ts): reads every recording through its reader under its limits. Each read ends one of four ways: complete, partial (with a reason: limit, time, companion-missing, or the reader's own), failed (any throw), or not read (sampled out). The builder also owns classifyDataset, and its EDF statistics match the old loop. The fleet scan, the CI screen and the upload preflight all reach it through scanDatasetFromManifest.
  • Report v2 (shared/identifier-screen-report.ts): REPORT_VERSION = 2 adds read_by_format, companion_missing and readers. The door parses v1 with the v1 rule verbatim and v2 with the per-reader rule:
    • clean and dates-only need at least one recording, every recording format to have a reader, and every file read completely.
    • no-recordings needs no recording of any format.
    • partially-screened replaces clean-edf-only-others-unscreened in new reports. Both gate to acknowledge; no other state's gate changed.
    • Version 1 may not say the new word, and version 2 may not say the old one.
    • Format keys may be zip:<ext>.
  • Preflight v2: PREFLIGHT_VERSION = 2. --acknowledge-identifier-preflight accepts clean-edf-only-others-unscreened as an alias of partially-screened, so existing pipelines keep working.
  • Copy tables (shared/identifier-screen-copy.ts): KIND_COPY, STATUS_COPY and INCOMPLETE_COPY, each a Record over its union of { statement, read, remedy, anchor }, plus SCREEN_DOCS_URL (the identifier-screening page). The verdict labels, causes, count lines and the preflight refusal moved here. A v2 description follows each state, kind and reason with its remedy and docs link; a v1 report renders exactly as before. The date warning and publicationRequestNotice stay in the report module, by ruling.
  • Superseded recordings: findSuperseded and the annex-key reading use the registry, so a replaced recording in any registered format is read in its old version.
  • Migration 0150 rebuilds upstream_repull_screens so both status CHECKs accept partially-screened (lead ruling). Rows, ids, the one-waiting index and the foreign key carry over.
  • Worker: the sweep projection keeps the v2 fields, and the partial-coverage count includes the new word.
  • Publication review evidence: the structural summary counts formats through the registry.

Tests

  • New: test/identifier-coverage-contract.test.ts and backend/test/repull-screens-partially-screened-migration.test.ts (bun:sqlite and Miniflare D1).
  • findSuperseded has a new test with a reader registered only in the test.
  • Existing EDF verdict expectations are unchanged. Tests that asserted the old status word for a new scan now assert partially-screened. Fixtures that are v1 records are marked v1.
  • Each new rule was reverted one line at a time, and its test failed every time.
  • Removing an entry from KIND_COPY fails bun run typecheck (TS2741).
  • bun run migrations:d1-check replays all 141 migrations on local D1 and matches bun:sqlite.

Migration 0150 rebuilds upstream_repull_screens so both status CHECKs
accept the report-version-2 word. Rows, ids, the one-waiting index and
the foreign key carry over. Tested on bun:sqlite and Miniflare D1, and
replayed with migrations:d1-check.
Adds the format reader registry with a page-cached RangeSource, the
shared report builder, and the copy tables. Report and preflight go to
version 2 (read_by_format, companion_missing, readers); the door reads
v1 verbatim and v2 under the per-reader rule. partially-screened
replaces the old word in new reports and gates the same. Targeted
screen tests pass with EDF verdicts unchanged.
Stub readers registered through the scan's readers option prove the
v2 rules: clean without EDF, thrown reads failed, limits and missing
companions partial, the page cache, the gate and the copy tables.
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2374

Version: 0.10.40-PR2374.5d2887f
Commit: 5d2887f


🤖 Updated on each push.

Adds it to the root tsconfig include, types the Miniflare D1 helper
from Miniflare so Bun types suffice, and uses db.run over the
deprecated exec. Typecheck and the migration tests pass.
Refuses a whole-file answer to an offset read (range-ignored), counts a
complete result from a limited source as partial, writes the reader
contract down, re-reads the EDF header inside the counted try, builds
tallies from a checked literal, and advertises partially-screened
only. New tests kill the surviving cache and door mutants; targeted
root and backend tests pass.
READ_FAILURE_COPY is a Record over the closed failure classes and a v2
description prints each read failure with its remedy and docs link.
Tests cover range-ignored at the door and in the lines; targeted root
and backend tests pass.
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Merge gate (lead): head 5d2887f; every remote check passes (shard 6 failed once on the repull CLI timeout flake #2377 and passed on its one rerun). Locally on this head: typecheck clean; 73 targeted contract and report tests pass. Review: round 1 panel (code+tests; errors+comments+types), 1 important finding and 7 items fixed, with the three surviving mutants now killed; round 2 delta review found 1 important gap (the read-failure copy was not wired) and 1 suggestion, both fixed in 5d2887f and checked by the lead from the diff.

@neuromechanist
neuromechanist merged commit 5c3d65d into feature/issue-2182-epic-pq-evidence Nov 25, 2026
59 of 61 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2185-coverage-contract branch November 25, 2026 22:41

This branch was previously deployed

1 inactive deployment
npm — 5d2887f1 Deployed Nov 25, 2026 by neuromechanist via publish #4879
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