From 137f7e354be9d016cd1c570b7d17479f63cd98d8 Mon Sep 17 00:00:00 2001 From: Dylan Roy Date: Tue, 6 Oct 2026 14:21:17 +0000 Subject: [PATCH] Witness checker: exact nested types in matches() (R-1) matches() in the Math-#160 witness checker enforced the Boolean type only at the top level, so review_basis[i].source_exposed set to 1 or 1.0 passed as the proposed true and the full CLI printed the pinned installed output (reported at Math-#250 5972612166, reproduced by Codex at 08f86862). same() now requires equal values of the same type at every nesting level. The packet pin is updated; proposals, pinned outputs and the workflow mutant list are unchanged. The readiness tests add numeric/string substitutes for all five nested Booleans in both installed states, a full-checker rejection, and a guard that the #167/#173 proposals compare only top-level controlling Booleans. Nothing is executed; scientific effect NONE. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017Mi3hxjaxV45x6zo6o1ee3 --- .../SOURCE_FILES.json | 6 +- .../reconciliation_check.py | 16 ++++- .../README.md | 10 +++ .../test_witness_states.py | 68 +++++++++++++++++++ 4 files changed, 94 insertions(+), 6 deletions(-) diff --git a/reviews/c6_witness_collision_reconciliation_20260929/SOURCE_FILES.json b/reviews/c6_witness_collision_reconciliation_20260929/SOURCE_FILES.json index 2a2f97f5f..84485a8af 100644 --- a/reviews/c6_witness_collision_reconciliation_20260929/SOURCE_FILES.json +++ b/reviews/c6_witness_collision_reconciliation_20260929/SOURCE_FILES.json @@ -28,9 +28,9 @@ }, { "path": "reconciliation_check.py", - "bytes": 36795, - "sha256": "ec5c919812e2765892df0e5a3eb512c696427483cabd2960feb8a9da72d03f9b", - "git_blob": "94058a013fde66f3413df8a46e8d5d86632e33f7" + "bytes": 37185, + "sha256": "216926d61676ef9e6ff274aa39be34df78d2a2a19eadbd9928ddfcf011c9b87b", + "git_blob": "8bdd4b6f843cc330dace59f0a8708c87e9b7b72e" }, { "path": "RESULTS_INSTALLED.json", diff --git a/reviews/c6_witness_collision_reconciliation_20260929/reconciliation_check.py b/reviews/c6_witness_collision_reconciliation_20260929/reconciliation_check.py index 94058a013..8bdd4b6f8 100644 --- a/reviews/c6_witness_collision_reconciliation_20260929/reconciliation_check.py +++ b/reviews/c6_witness_collision_reconciliation_20260929/reconciliation_check.py @@ -245,10 +245,20 @@ def check_negatives(src): return all(rejected) and len(rejected) == 4 +def same(a, b): + """Exact JSON equality: equal values of the same type at every nesting level, so 1, 1.0 or "true" never + stand in for a proposed Boolean inside review_basis or any other nested field (R-1, Math-#250 5972612166).""" + if type(a) is not type(b): + return False + if isinstance(a, dict): + return a.keys() == b.keys() and all(same(a[k], b[k]) for k in a) + if isinstance(a, list): + return len(a) == len(b) and all(same(x, y) for x, y in zip(a, b)) + return a == b + + def matches(live, fields): - return isinstance(live, dict) and all(live.get(k) == v and - (type(v) is not bool or type(live.get(k)) is bool) - for k, v in fields.items()) + return isinstance(live, dict) and all(k in live and same(live[k], v) for k, v in fields.items()) def installed_state(graph, proposed_nodes, proposed_edges): diff --git a/reviews/register_execution_readiness_20260930/README.md b/reviews/register_execution_readiness_20260930/README.md index b05633766..4cc096e6b 100644 --- a/reviews/register_execution_readiness_20260930/README.md +++ b/reviews/register_execution_readiness_20260930/README.md @@ -7,6 +7,16 @@ executable regression controls in this directory; they run in both Python modes before the three existing composition checks. No mathematical proposal, live register, selector table or scientific status is executed by these repairs. +**R-1 successor (6 October 2026).** Post-merge read [250/5972612166](https://github.com/d6g8k5htny-coder/Math-/pull/250#issuecomment-5972612166) +found that the Math-#160 witness checker compared nested proposal fields by plain equality, so `source_exposed: 1` (or +`1.0`) inside `review_basis` passed as the proposed `true`; Codex reproduced it at `08f86862` +([main#229 6018032227](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6018032227)). `matches()` now +requires equal type at every nesting level, and `test_witness_states.py` rejects numeric and string substitutes for each +of the five nested Booleans in both documented installed states and through the full checker. The Math-#167 and #173 +proposals carry no compared Boolean below a node's top level (their only compared Booleans are top-level `controlling` +flags, which the hard gate types exactly); a guard test fails if that ever changes. Pinned outputs, proposals and the +workflow mutant list are unchanged. Nothing is executed. + **Object:** REGISTER-EXECUTION-READINESS-20260930-v1. **Author:** Anthropic Claude, Claude Code session `session_017Mi3hxjaxV45x6zo6o1ee3` — the same session that authored the three records (author-side; exposure stated in §5). **Read at:** Math- `main` `dda8991` (30 September 2026; Math-#177 merged). diff --git a/reviews/register_execution_readiness_20260930/test_witness_states.py b/reviews/register_execution_readiness_20260930/test_witness_states.py index 7417f34b8..fafb51a80 100644 --- a/reviews/register_execution_readiness_20260930/test_witness_states.py +++ b/reviews/register_execution_readiness_20260930/test_witness_states.py @@ -54,6 +54,24 @@ def graph_fixture(stage): return graph +def nested_booleans(value, path=()): + """Paths of every Boolean strictly below a node's top level (R-1 class).""" + if isinstance(value, dict): + for key, item in value.items(): + yield from nested_booleans(item, path + (key,)) + elif isinstance(value, list): + for index, item in enumerate(value): + yield from nested_booleans(item, path + (index,)) + elif isinstance(value, bool) and len(path) > 1: + yield path + + +def set_path(record, path, value): + for key in path[:-1]: + record = record[key] + record[path[-1]] = value + + def state(graph): return witness.installed_state(graph, PROPOSAL["proposed_graph_nodes"], PROPOSAL["proposed_graph_edges"])["state"] @@ -88,6 +106,26 @@ def test_component_boolean_cannot_be_integer_zero(self): graph["nodes"][node["id"]]["controlling"] = 0 self.assertEqual(state(graph), "partial") + def test_nested_boolean_cannot_be_number_or_string(self): + # R-1 (Math-#250 5972612166, reproduced by Codex at 08f86862): a nested Boolean such as + # review_basis[i].source_exposed must keep its exact type; 1 == True must not pass as the proposal. + cases = [(node["id"], path, node) for node in PROPOSAL["proposed_graph_nodes"] + for path in nested_booleans({k: v for k, v in node.items() if k != "id"})] + self.assertEqual(len(cases), 5) + for nid, path, proposed in cases: + current = proposed + for key in path: + current = current[key] + substitutes = (1, 1.0, "true") if current is True else (0, 0.0, "false") + for stage in ("open", "reviewed"): + for value in substitutes: + with self.subTest(node=nid, path=path, stage=stage, value=value): + graph = graph_fixture(stage) + set_path(graph["nodes"][nid], path, value) + self.assertEqual(state(graph), "partial") + set_path(graph["nodes"][nid], path, current) + self.assertEqual(state(graph), "installed") + def test_malformed_proposal_edge_is_not_absent_or_exact(self): # Even an extra malformed parallel edge must not disappear in set intersection. for proposed in PROPOSAL["proposed_graph_edges"]: @@ -195,6 +233,36 @@ def test_integer_controlling_component_is_rejected_by_full_checker(self): self.assertFalse(result["checks"]["TRANSITIONS"]) self.assertFalse(result["passed"]) + def test_nested_integer_boolean_is_rejected_by_full_checker(self): + for stage in ("open", "reviewed"): + with self.subTest(stage=stage): + graph = graph_fixture(stage) + graph["nodes"]["math.c6-component.palm-proof"]["review_basis"][0]["source_exposed"] = 1 + run, result = self.run_graph(graph) + self.assertEqual(run.returncode, 1) + self.assertFalse(result["checks"]["TRANSITIONS"]) + self.assertFalse(result["passed"]) + self.assertNotEqual(run.stdout, (PACKET / "RESULTS_INSTALLED.json").read_bytes()) + + +class SiblingProposals(unittest.TestCase): + """Math-#167 and Math-#173 compare proposed fields with plain equality. That is exact today only because every + Boolean they compare on a live node is a top-level controlling flag, which the hard gate types exactly. Fail if a + nested or other compared Boolean is ever proposed there, so R-1 cannot reappear unnoticed.""" + + META = ("id", "create_if_absent", "cross_record") + + def test_compared_booleans_are_top_level_controlling_only(self): + for record in ("reviews/register_alignment_20260930", "reviews/c6_residual_closure_20260930"): + data = json.loads((ROOT / record / "PROPOSED_TRANSITIONS.json").read_text()) + fields = [{k: v for k, v in n.items() if k not in self.META} for n in data["proposed_graph_nodes"]] + fields += [t["proposed"] for t in data["transitions"] if isinstance(t.get("proposed"), dict)] + self.assertTrue(fields) + for compared in fields: + with self.subTest(record=record, node=compared.get("source") or compared.get("kind")): + self.assertEqual(list(nested_booleans(compared)), []) + self.assertEqual({k for k, v in compared.items() if isinstance(v, bool)} - {"controlling"}, set()) + if __name__ == "__main__": unittest.main()