Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions registers/CONSUMERS.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
"counts": {
"tabs": 44,
"generic_files": 4,
"MACHINE": 23,
"MACHINE": 26,
"PROSE_ONLY": 3,
"UNREAD": 18
"UNREAD": 15
},
"tabs": {
"active_work_claims": {
Expand Down Expand Up @@ -95,6 +95,7 @@
"registers/collision_proposal_2026-09-19.json",
"tests/test_collision_proposal.py",
"tests/test_operations.py",
"tests/test_register_source_selection.py",
"tools/collision_proposal_check.py",
"tools/registers_check.py"
],
Expand Down Expand Up @@ -221,6 +222,7 @@
"registers/KNOWN_FINDINGS.json",
"registers/collision_proposal_2026-09-19.json",
"tests/test_collision_proposal.py",
"tests/test_register_source_selection.py",
"tools/collision_proposal_check.py",
"tools/registers_check.py"
],
Expand All @@ -244,8 +246,10 @@
"class": "MACHINE",
"machine": [
"tests/test_frozen_check.py",
"tests/test_register_source_selection.py",
"tools/frozen_check.py",
"tools/registers_check.py"
"tools/registers_check.py",
"tools/registers_preflight.py"
],
"prose": [
"docs/FINDINGS_2026-09-18.md",
Expand All @@ -263,8 +267,10 @@
"prose": []
},
"identity_drift_watch": {
"class": "UNREAD",
"machine": [],
"class": "MACHINE",
"machine": [
"tests/test_register_source_selection.py"
],
"prose": []
},
"lpw_fold_dispositions": {
Expand Down Expand Up @@ -418,10 +424,13 @@
"engine/lanes/D.json",
"tests/test_claims.py",
"tests/test_lanes.py",
"tests/test_register_preflight.py",
"tests/test_register_source_selection.py",
"tests/test_reviews.py",
"tools/closure_pipeline.py",
"tools/lanes_check.py",
"tools/registers_check.py",
"tools/registers_preflight.py",
"tools/reviews_check.py"
],
"prose": [
Expand All @@ -444,8 +453,10 @@
]
},
"start_here": {
"class": "UNREAD",
"machine": [],
"class": "MACHINE",
"machine": [
"tests/test_register_source_selection.py"
],
"prose": []
},
"task_gates": {
Expand Down Expand Up @@ -479,6 +490,7 @@
"engine/receipt.py",
"engine/receipts/README.md",
"tests/test_bridge.py",
"tests/test_register_source_selection.py",
"tools/registers_check.py"
],
"prose": [
Expand All @@ -488,8 +500,10 @@
]
},
"work_orders": {
"class": "UNREAD",
"machine": [],
"class": "MACHINE",
"machine": [
"tests/test_register_source_selection.py"
],
"prose": []
}
}
Expand Down
34 changes: 34 additions & 0 deletions registers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,40 @@ The Drive's `GP-REG-032-v1.2 — Coupled Research Registers` workbook (Drive id
* `EXPORT_DIFF_2026-09-17_to_2026-09-18.json` — the mechanical, every-column
diff between the two exports (see *What moved between the two exports*).

## Verified source selection and successor preflight

Normal import and `--check` now resolve `current_import_source` from
`source/SOURCES.json` at call time. The selected export must have one provenance
record, a safe local XLSX basename, matching SHA-256 and byte count, and
`exact: false` (native Sheet exports are renderings). Missing or ambiguous
metadata, duplicate JSON keys, symlinks, and identity mismatches are refused
before output writes. There is no independent normal-import filename pin.

The stored Sept 23 R1 successor is **not activated**. Preview it without changing
the current selector, source files, or generated registers:

```bash
python3 tools/registers_preflight.py \
--source-name GP-REG-032_v1.2_export_2026-09-23_R1.xlsx > /tmp/register-r1-preview.json
```

Exit 0 means the named metadata/form interfaces are compatible; exit 1 reports
blockers; exit 2 means source/read failure. R1 currently returns 1: three source
status phrases are outside the R17 vocabulary (both register and review
checkers expose them); nine new frozen-object IDs lack entries in the older
inventory; two raw-file binding descriptions are uninterpreted. No missing
custody is called MATCH, no phrase is mapped to PASS, and no exception is added
to the live allowlist. The report preserves all diagnostics and states
`canonical_import_completed: false`. The R1 preview compares all 44 tabs and
checks 88 generated files in temporary directories. It is not full mathematical
CI, a scientific verdict, or a replacement governing register.

Historical replay stays fixed: `--diff-exports` without `--source` retains the
Sept 17 markdown and Sept 18 XLSX inputs. Explicit `--source PATH` remains a
standalone inspection override, not manifest acceptance. Source/consumer
reconciliation must precede activation; owner permission is already supplied
by the standing directive.

Regenerate and verify:

```bash
Expand Down
93 changes: 93 additions & 0 deletions tests/test_register_preflight.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
"""Source-bound preflight: observable blockers, no activation or scientific verdict."""
from __future__ import annotations

import json
from pathlib import Path
import sys

import pytest

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "tools"))
import registers_preflight as PF
import registers_import as RI

R1 = "GP-REG-032_v1.2_export_2026-09-23_R1.xlsx"


def test_current_snapshot_passes_only_covered_interfaces():
report = PF.preview(Path(RI.resolve_current_source()).name)
assert report["compatible_for_covered_interfaces"] is True
assert not any(report["blockers"].values())
assert report["comparison"]["changed_cells"] == []
assert report["protected_files_unchanged"] is True
assert report["canonical_import_completed"] is False
assert report["scientific_status_changed"] is False


def test_r1_has_exact_unresolved_interfaces_and_never_activates():
before = Path(RI.SOURCE_MANIFEST).read_bytes()
report = PF.preview(R1)
assert report["proposed_identity"] == {"bytes": 1979318, "sha256":
"6cec54cefa3ee8f9885dcfd763407a2e0274d2887d73bdc23ccc7793cd721469"}
assert report["tabs"] == 44 and report["generated_files_checked"] == 88
assert report["row_counts"]["review_queue"] == 40
assert {k: len(v) for k, v in report["blockers"].items()} == {
"transcription": 0, "register_structure": 3, "stale_known_findings": 0,
"bound_observations": 0, "review_interface": 3, "frozen_interface": 11}
assert report["frozen_status_counts"]["MATCH"] == 62
assert report["frozen_status_counts"]["DRIVE_ID_NOT_IN_INVENTORY"] == 9
assert report["frozen_status_counts"]["UNKNOWN_CLASS"] == 2
assert report["frozen_status_counts"].get("MISMATCH", 0) == 0
assert report["compatible_for_covered_interfaces"] is False
assert report["canonical_import_completed"] is False
assert report["scientific_status_changed"] is False
assert report["protected_files_unchanged"] is True
assert Path(RI.SOURCE_MANIFEST).read_bytes() == before
assert Path(RI.resolve_current_source()).name.endswith("2026-09-18.xlsx")


@pytest.mark.parametrize("name", ["../outside.xlsx", "not-declared.xlsx", "SOURCES.json"])
def test_undeclared_or_unsafe_candidate_is_refused_before_preview(name):
with pytest.raises(RI.SourceError):
PF.preview(name)


def test_cli_exit_one_for_blockers_not_success(capsys):
assert PF.main(["--source-name", R1]) == 1
report = json.loads(capsys.readouterr().out)
assert report["compatible_for_covered_interfaces"] is False


def test_cli_exit_two_for_source_failure(capsys):
assert PF.main(["--source-name", "not-declared.xlsx"]) == 2
output = capsys.readouterr()
assert output.out == ""
assert json.loads(output.err)["canonical_import_completed"] is False


def test_record_form_error_is_not_hidden(monkeypatch):
monkeypatch.setattr(PF.RV, "check_all", lambda *args: ["deliberate invalid review form"])
report = PF.preview(Path(RI.resolve_current_source()).name)
assert report["blockers"]["review_interface"] == ["deliberate invalid review form"]
assert report["compatible_for_covered_interfaces"] is False


def test_new_digest_mismatch_is_not_hidden(monkeypatch):
original = PF.FZ.check
def changed(*args):
rows, problems = original(*args)
rows.append({"status": "MISMATCH"})
return rows, problems + ["deliberate whole-file digest mismatch"]
monkeypatch.setattr(PF.FZ, "check", changed)
report = PF.preview(Path(RI.resolve_current_source()).name)
assert report["blockers"]["frozen_interface"] == ["deliberate whole-file digest mismatch"]
assert report["frozen_status_counts"]["MISMATCH"] == 1
assert report["compatible_for_covered_interfaces"] is False


def test_observation_drift_is_not_hidden(monkeypatch):
monkeypatch.setattr(PF.RC, "check_observations", lambda *args: (["deliberate observation drift"], 45))
report = PF.preview(Path(RI.resolve_current_source()).name)
assert report["blockers"]["bound_observations"] == ["deliberate observation drift"]
assert report["compatible_for_covered_interfaces"] is False
Loading
Loading