diff --git a/claims/LANDING_CLAIMS.json b/claims/LANDING_CLAIMS.json index a8719fcd7..524d3ecaa 100644 --- a/claims/LANDING_CLAIMS.json +++ b/claims/LANDING_CLAIMS.json @@ -357,8 +357,8 @@ "statement_path": "frontiers/downstream_gate_20260925/README.md", "statement_heading": "What it enforces", "source": { - "commit": "2e0a7b37d18277c5965e9a65adabcb26c7e44234", - "blob": "6ff49b966ab41dc4db771d48e547cc60da11764f" + "commit": "560a2965425ae9807ca504564bb45fd5c1969797", + "blob": "0d1a0492e90a18bf1565c87fa6a833923b523588" }, "domain": "machine dependency graph and repository-source transitions", "measure": "not a mathematical measure; loss-only revalidation/control state", diff --git a/frontiers/downstream_gate_20260925/README.md b/frontiers/downstream_gate_20260925/README.md index 6ff49b966..0d1a0492e 100644 --- a/frontiers/downstream_gate_20260925/README.md +++ b/frontiers/downstream_gate_20260925/README.md @@ -30,6 +30,38 @@ with `promotion_permission: false`. A changed controlling node, illegal controll or an unbound controlling source causes a nonzero exit. Unaffected author-side work can proceed. This is not a complete external-source monitor or an independent-review authority. +## Live inventory and synthetic negative controls + +`gate_ok`, closure, region coverage and reverse-impact fields describe the actual +input graph; selector fields describe the selected table. Reporting validates the +real graph and never replaces a malformed supplied input with a fixture. + +`illegal_attempts_context: synthetic_negative_controls` identifies five separate, +small diagnostic graphs. Their node IDs start with `diagnostic.`; the historical +attempt names describe the purpose of each probe, not the live D2/D3 status. +Lifetime and side24 specimens have author-side targets and reviewed prerequisites. +The fixed-remote specimen is otherwise eligible and is refused specifically for +non-discharge evidence. The historical-carrier and pre-allowlist specimens have +reviewed targets with, respectively, an absent and an author-side prerequisite. +Tests check these preconditions independently and pair each refusal with an +eligible positive control. All public eligibility, validation, closure and +reverse-impact rules remain unchanged. No specimen is written to a live register. + +The existing 71 methods and all 24 named, assertion-detected mutants run in both +modes. Direct assertions observe the reporter's false lemma flag and an explicitly +ineligible controlling node before any golden-output comparison. Live edge/source +obligations remain checked; synthetic region and selector inputs exercise category +mapping without assuming a permanent count of live open cells. + +Freeze producer/tests/docs and the real graph/table inputs before deliberately +regenerating `RESULTS.json` and the changed `SOURCE_FILES.json` identity rows. +Inspect the semantic predicates first. The unchanged runner still requires exit0 +and exact CLI bytes equal to the pinned result; validation never repins itself. +Each isolated transition scenario requires its own identified result and manifest +before replay. Such scratch results must not replace the unchanged-live result or +any transition packet's `RESULTS_INSTALLED.json`. They authorize no register +execution or scientific promotion. + ## Run ```sh diff --git a/frontiers/downstream_gate_20260925/RESULTS.json b/frontiers/downstream_gate_20260925/RESULTS.json index 657594914..19809ecb6 100644 --- a/frontiers/downstream_gate_20260925/RESULTS.json +++ b/frontiers/downstream_gate_20260925/RESULTS.json @@ -79,10 +79,8 @@ "HASH_MATCH", "SAME_AUTHOR_REVIEW" ], - "node": "math.rn-fixed-remote-window", + "node": "diagnostic.fixed-remote", "reasons": [ - "node classification is not eligible for positive CONTROLLING status: AUTHOR_SIDE_CANDIDATE", - "required transitive dependency is not satisfied", "evidence consists only of non-discharge tokens" ], "refused": true @@ -90,18 +88,17 @@ "promote_historical_env_rescov": { "allowed": false, "blocked_absent": [ - "hist.rnu_env.py" + "diagnostic.absent-carrier" ], "meaning": "integrity decision only; not theorem acceptance", "missing_terminal": [], - "node": "hist.ENV-RESCOV", + "node": "diagnostic.historical-env", "reasons": [ - "node classification is not eligible for positive CONTROLLING status: OPEN_HISTORICAL", "required BLOCKED_ABSENT dependency forces HOLD" ], "refuted_required": [], "required_dependencies": [ - "hist.rnu_env.py" + "diagnostic.absent-carrier" ], "would_be_controlling": false }, @@ -110,17 +107,13 @@ "blocked_absent": [], "meaning": "integrity decision only; not theorem acceptance", "missing_terminal": [], - "node": "math.lifetime-remainder", + "node": "diagnostic.lifetime-remainder", "reasons": [ "node classification is not eligible for positive CONTROLLING status: AUTHOR_SIDE_CANDIDATE" ], "refuted_required": [], "required_dependencies": [ - "math.uniform-matrix-cap-lifetime", - "math.d1-component.congruence-erratum", - "math.d1-component.section9-replacement-v1_1", - "math.d1-component.marked-cylinder-cap", - "math.d1-component.reconciliation-record" + "diagnostic.lifetime-parent" ], "would_be_controlling": false }, @@ -131,17 +124,16 @@ "missing_terminal": [ { "classification": "AUTHOR_SIDE_CANDIDATE", - "id": "eng.d0-packet-allowlist-fix" + "id": "diagnostic.allowlist" } ], - "node": "eng.main-pr87-crosswalk", + "node": "diagnostic.crosswalk", "reasons": [ - "node classification is not eligible for positive CONTROLLING status: HOLD", "required transitive dependency is not satisfied" ], "refuted_required": [], "required_dependencies": [ - "eng.d0-packet-allowlist-fix" + "diagnostic.allowlist" ], "would_be_controlling": false }, @@ -150,21 +142,18 @@ "blocked_absent": [], "meaning": "integrity decision only; not theorem acceptance", "missing_terminal": [], - "node": "math.side24-coefficient", + "node": "diagnostic.side24", "reasons": [ "node classification is not eligible for positive CONTROLLING status: AUTHOR_SIDE_CANDIDATE" ], "refuted_required": [], "required_dependencies": [ - "math.uniform-matrix-cap-lifetime", - "math.d1-component.congruence-erratum", - "math.d1-component.section9-replacement-v1_1", - "math.d1-component.marked-cylinder-cap", - "math.d1-component.reconciliation-record" + "diagnostic.side24-parent" ], "would_be_controlling": false } }, + "illegal_attempts_context": "synthetic_negative_controls", "illegal_promotion_refused": true, "lemma_closed": false, "meaning": "same-author integrity controls for main #90/#86; not analytic review or theorem acceptance", diff --git a/frontiers/downstream_gate_20260925/SOURCE_FILES.json b/frontiers/downstream_gate_20260925/SOURCE_FILES.json index c42e11304..aeeff2354 100644 --- a/frontiers/downstream_gate_20260925/SOURCE_FILES.json +++ b/frontiers/downstream_gate_20260925/SOURCE_FILES.json @@ -9,12 +9,12 @@ "sha256": "8822e9618678321a342d69cd0b8ae6552de1b5d578c331de5072b2892ee9dd09" }, "README.md": { - "bytes": 4025, - "sha256": "13fc1accebebd6017f34b0e5473bf6338f2604948c25a002051b5f0620fc327a" + "bytes": 6100, + "sha256": "248f2e06a53c67a6bd895ba7e138fdeaace7fe3487c11e45bd19685af9b08fb2" }, "RESULTS.json": { - "bytes": 7095, - "sha256": "0b95624e08e3eff7ca386a68534960b89ef63b10312ad5120159c0e29961264a" + "bytes": 6403, + "sha256": "5a83f49a14ce350b1ab5463928ae7e90c7ae1d87fb99aa0ca1f425aaa302d6c4" }, "SCOPE.md": { "bytes": 2218, @@ -29,8 +29,8 @@ "sha256": "393d407c2e35d2b6f3230f5a60a9aaa7691172544d3b59f72cc880c81be20701" }, "hard_gate.py": { - "bytes": 26735, - "sha256": "a78f3e25f3b0cfe113e618a4c31a7a25d7f22af638c46dec1ecba221fa333ac8" + "bytes": 28275, + "sha256": "e00a74e41ac3ad322460d461b79778c80abeb845c2952a299a978a1bc8cacc38" }, "patches/d0_packet_allowlist.patch": { "bytes": 3096, @@ -41,8 +41,8 @@ "sha256": "ec1d3315b0c21f4608ab7b824f45d7d6e1041555f62e77feeec2bacaa8e5a9f5" }, "test_hard_gate.py": { - "bytes": 23161, - "sha256": "c444e6c347da680aff5bef7f43900e45d52a0cc45081fb7b4def45266d97aac1" + "bytes": 34398, + "sha256": "9072c99a570623c7fa73bec1a3df6bb8eda6266ebe538213c3b03df2ad320dce" }, "test_transition_contract.py": { "bytes": 12679, diff --git a/frontiers/downstream_gate_20260925/hard_gate.py b/frontiers/downstream_gate_20260925/hard_gate.py index 3a334f11e..ddd231600 100644 --- a/frontiers/downstream_gate_20260925/hard_gate.py +++ b/frontiers/downstream_gate_20260925/hard_gate.py @@ -586,18 +586,48 @@ def d0_ci_unblock_report() -> dict[str, Any]: } -def results_payload(graph: dict[str, Any] | None = None) -> dict[str, Any]: - g = graph or load_graph() - # Spot-check promotions that must fail closed on the live author-side graph. - illegal_attempts = { - 'promote_fixed_remote': refuse_non_discharge_promotion( - g, 'math.rn-fixed-remote-window', - ['GREEN_CI', 'HASH_MATCH', 'SAME_AUTHOR_REVIEW']), - 'promote_lifetime_remainder': promotion_allowed(g, 'math.lifetime-remainder'), - 'promote_side24': promotion_allowed(g, 'math.side24-coefficient'), - 'promote_historical_env_rescov': promotion_allowed(g, 'hist.ENV-RESCOV'), - 'promote_pr87_before_allowlist': promotion_allowed(g, 'eng.main-pr87-crosswalk'), +def _negative_control_specimens() -> dict[str, dict[str, Any]]: + """Fresh diagnostic graphs; their deliberately invalid requests are not live statuses.""" + cases = ( + ('promote_fixed_remote', 'diagnostic.fixed-remote', 'PROVED_REVIEWED', + 'diagnostic.count-interface', 'PROVED_REVIEWED'), + ('promote_lifetime_remainder', 'diagnostic.lifetime-remainder', 'AUTHOR_SIDE_CANDIDATE', + 'diagnostic.lifetime-parent', 'PROVED_REVIEWED'), + ('promote_side24', 'diagnostic.side24', 'AUTHOR_SIDE_CANDIDATE', + 'diagnostic.side24-parent', 'PROVED_REVIEWED'), + ('promote_historical_env_rescov', 'diagnostic.historical-env', 'PROVED_REVIEWED', + 'diagnostic.absent-carrier', 'BLOCKED_ABSENT'), + ('promote_pr87_before_allowlist', 'diagnostic.crosswalk', 'PROVED_REVIEWED', + 'diagnostic.allowlist', 'AUTHOR_SIDE_CANDIDATE'), + ) + return { + name: {'node': target, 'graph': { + 'object': 'SYNTHETIC-NEGATIVE-CONTROL:' + name, + 'schema_version': 1, + 'non_discharge_tokens': list(NON_DISCHARGE_DEFAULT), + 'nodes': { + target: {'classification': own, 'controlling': False}, + premise: {'classification': classification, 'controlling': False}, + }, + 'edges': [{'from': target, 'to': premise, 'required': True, + 'relation': 'diagnostic prerequisite'}], + }} + for name, target, own, premise, classification in cases } + + +def results_payload(graph: dict[str, Any] | None = None) -> dict[str, Any]: + g = load_graph() if graph is None else graph + validate_graph_fail_closed(g) + # Invariant negative requests are separate from the real graph reported below. + illegal_attempts = {} + for name, specimen in _negative_control_specimens().items(): + diagnostic, node = specimen['graph'], specimen['node'] + illegal_attempts[name] = ( + refuse_non_discharge_promotion(diagnostic, node, + ['GREEN_CI', 'HASH_MATCH', 'SAME_AUTHOR_REVIEW']) + if name == 'promote_fixed_remote' else promotion_allowed(diagnostic, node) + ) impact = reverse_impact( g, 'math.uniform-matrix-cap-lifetime', old_fingerprint='main-63-author-side', @@ -615,6 +645,7 @@ def results_payload(graph: dict[str, Any] | None = None) -> dict[str, Any]: (v.get('refused') if 'refused' in v else not v.get('allowed')) for v in illegal_attempts.values() ), + 'illegal_attempts_context': 'synthetic_negative_controls', 'illegal_attempts': { k: {key: val for key, val in v.items() if key != 'base'} for k, v in illegal_attempts.items() diff --git a/frontiers/downstream_gate_20260925/test_hard_gate.py b/frontiers/downstream_gate_20260925/test_hard_gate.py index 0c8263e96..4f9036ce8 100644 --- a/frontiers/downstream_gate_20260925/test_hard_gate.py +++ b/frontiers/downstream_gate_20260925/test_hard_gate.py @@ -15,6 +15,65 @@ class HardGateControls(unittest.TestCase): def setUp(self): self.graph = m.load_graph() + def diagnostic_specimen(self, purpose): + # Explicit contracts, independent of the producer's graph construction. + expected = { + 'promote_fixed_remote': ('diagnostic.fixed-remote', 'PROVED_REVIEWED', + 'diagnostic.count-interface', 'PROVED_REVIEWED'), + 'promote_lifetime_remainder': ('diagnostic.lifetime-remainder', 'AUTHOR_SIDE_CANDIDATE', + 'diagnostic.lifetime-parent', 'PROVED_REVIEWED'), + 'promote_side24': ('diagnostic.side24', 'AUTHOR_SIDE_CANDIDATE', + 'diagnostic.side24-parent', 'PROVED_REVIEWED'), + 'promote_historical_env_rescov': ('diagnostic.historical-env', 'PROVED_REVIEWED', + 'diagnostic.absent-carrier', 'BLOCKED_ABSENT'), + 'promote_pr87_before_allowlist': ('diagnostic.crosswalk', 'PROVED_REVIEWED', + 'diagnostic.allowlist', 'AUTHOR_SIDE_CANDIDATE'), + } + self.assertTrue(hasattr(m, '_negative_control_specimens'), 'explicit diagnostic specimens required') + specimens = m._negative_control_specimens() + self.assertEqual(set(specimens), set(expected)) + for name, (target, own, premise, classification) in expected.items(): + with self.subTest(specimen=name): + specimen = specimens[name] + self.assertEqual(set(specimen), {'graph', 'node'}) + self.assertEqual(specimen['node'], target) + g = specimen['graph'] + self.assertIs(type(g['schema_version']), int) + self.assertEqual(g['schema_version'], 1) + self.assertEqual(g['nodes'], { + target: {'classification': own, 'controlling': False}, + premise: {'classification': classification, 'controlling': False}, + }) + for node in g['nodes'].values(): + self.assertIs(node['controlling'], False) + self.assertEqual(g['edges'], [ + {'from': target, 'to': premise, 'required': True, 'relation': 'diagnostic prerequisite'}]) + self.assertIs(g['edges'][0]['required'], True) + self.assertEqual(g['non_discharge_tokens'], [ + 'GREEN_CI', 'HASH_MATCH', 'ARCHITECTURAL_ADMISSION', 'NUMERICAL_EXPERIMENT', + 'SAME_AUTHOR_REVIEW', 'NAVIGATION_SUCCESS', 'AUTHOR_SELF_CHECK']) + m.validate_graph_fail_closed(g) + target, _, premise, _ = expected[purpose] + return specimens[purpose]['graph'], target, premise + + def check_target_and_premise_controls(self, purpose): + g, target, premise = self.diagnostic_specimen(purpose) + decision = m.promotion_allowed(g, target) + self.assertIs(decision['allowed'], False) + self.assertEqual(decision['missing_terminal'], []) + self.assertEqual(decision['reasons'], [ + 'node classification is not eligible for positive CONTROLLING status: AUTHOR_SIDE_CANDIDATE']) + g['nodes'][target]['classification'] = 'PROVED_REVIEWED' + allowed = m.promotion_allowed(g, target) + self.assertIs(allowed['allowed'], True) + self.assertEqual(allowed['reasons'], []) + g['nodes'][premise]['classification'] = 'AUTHOR_SIDE_CANDIDATE' + blocked = m.promotion_allowed(g, target) + self.assertIs(blocked['allowed'], False) + self.assertEqual(blocked['missing_terminal'], [ + {'id': premise, 'classification': 'AUTHOR_SIDE_CANDIDATE'}]) + self.assertEqual(blocked['reasons'], ['required transitive dependency is not satisfied']) + def test_schema_and_terminal_set(self): self.assertEqual(self.graph['schema_version'], 1) self.assertEqual( @@ -47,21 +106,8 @@ def test_lemma_closed_never_true(self): def test_lifetime_requires_parent(self): deps = m.required_dependencies(self.graph, 'math.lifetime-remainder') - self.assertEqual(deps, ['math.uniform-matrix-cap-lifetime']) - # Pre-reconciliation fixture: an unreviewed parent must block the dependent. - pre = copy.deepcopy(self.graph) - pre['nodes']['math.uniform-matrix-cap-lifetime']['classification'] = 'AUTHOR_SIDE_CANDIDATE' - decision = m.promotion_allowed(pre, 'math.lifetime-remainder') - self.assertFalse(decision['allowed']) - self.assertTrue(any(x['id'] == 'math.uniform-matrix-cap-lifetime' - for x in decision['missing_terminal'])) - # Live graph: the reconciled parent satisfies the edge; the dependent's own - # author-side classification still refuses promotion. - live = m.promotion_allowed(self.graph, 'math.lifetime-remainder') - self.assertEqual(self.graph['nodes']['math.uniform-matrix-cap-lifetime']['classification'], - 'PROVED_REVIEWED') - self.assertEqual(live['missing_terminal'], []) - self.assertFalse(live['allowed']) + self.assertEqual(deps.count('math.uniform-matrix-cap-lifetime'), 1) + self.check_target_and_premise_controls('promote_lifetime_remainder') def test_d1_reading_rule_components_bound_and_reviewed(self): # Every mandatory reading-rule component is its own source node, required by D1, so a byte change @@ -104,22 +150,21 @@ def test_d1_reading_rule_components_bound_and_reviewed(self): [x['id'] for x in decision['missing_terminal']]) def test_side24_requires_parent(self): - pre = copy.deepcopy(self.graph) - pre['nodes']['math.uniform-matrix-cap-lifetime']['classification'] = 'AUTHOR_SIDE_CANDIDATE' - decision = m.promotion_allowed(pre, 'math.side24-coefficient') - self.assertFalse(decision['allowed']) - self.assertIn('math.uniform-matrix-cap-lifetime', decision['required_dependencies']) - self.assertTrue(any(x['id'] == 'math.uniform-matrix-cap-lifetime' - for x in decision['missing_terminal'])) - live = m.promotion_allowed(self.graph, 'math.side24-coefficient') - self.assertEqual(live['missing_terminal'], []) - self.assertFalse(live['allowed']) + self.assertIn('math.uniform-matrix-cap-lifetime', + m.transitive_required(self.graph, 'math.side24-coefficient')) + self.check_target_and_premise_controls('promote_side24') def test_fixed_remote_requires_count_interface(self): deps = m.transitive_required(self.graph, 'math.rn-fixed-remote-window') self.assertIn('math.rn-count-interface', deps) - decision = m.promotion_allowed(self.graph, 'math.rn-fixed-remote-window') - self.assertFalse(decision['allowed']) + g, target, premise = self.diagnostic_specimen('promote_fixed_remote') + self.assertIs(m.promotion_allowed(g, target)['allowed'], True) + g['nodes'][premise]['classification'] = 'AUTHOR_SIDE_CANDIDATE' + decision = m.promotion_allowed(g, target) + self.assertIs(decision['allowed'], False) + self.assertEqual(decision['missing_terminal'], [ + {'id': premise, 'classification': 'AUTHOR_SIDE_CANDIDATE'}]) + self.assertEqual(decision['reasons'], ['required transitive dependency is not satisfied']) def test_mesoscopic_requires_fixed_remote(self): deps = m.required_dependencies(self.graph, 'math.rn-mesoscopic-reduction') @@ -131,23 +176,37 @@ def test_blocked_absent_forces_hold_on_historical_env(self): applied = m.apply_promotion(self.graph, 'hist.ENV-RESCOV') self.assertFalse(applied['decision']['ok']) self.assertEqual(applied['decision']['applied'], 'HOLD') - self.assertEqual( - applied['graph']['nodes']['hist.ENV-RESCOV']['classification'], - 'HOLD', - ) - self.assertFalse(applied['graph']['nodes']['hist.ENV-RESCOV']['controlling']) + self.assertEqual(applied['graph']['nodes']['hist.ENV-RESCOV']['classification'], 'HOLD') + self.assertIs(applied['graph']['nodes']['hist.ENV-RESCOV']['controlling'], False) + g, target, premise = self.diagnostic_specimen('promote_historical_env_rescov') + decision = m.promotion_allowed(g, target) + self.assertEqual(decision['blocked_absent'], [premise]) + self.assertEqual(decision['reasons'], ['required BLOCKED_ABSENT dependency forces HOLD']) + self.assertIs(decision['allowed'], False) + self.assertEqual(m.apply_promotion(g, target)['decision']['applied'], 'HOLD') + g['nodes'][premise]['classification'] = 'PROVED_REVIEWED' + self.assertIs(m.promotion_allowed(g, target)['allowed'], True) + self.assertEqual(m.apply_promotion(g, target)['decision']['applied'], 'CONTROLLING') def test_green_ci_alone_never_promotes(self): + g, target, _ = self.diagnostic_specimen('promote_fixed_remote') + self.assertIs(m.promotion_allowed(g, target)['allowed'], True) for tokens in ( ['GREEN_CI'], ['HASH_MATCH', 'NAVIGATION_SUCCESS'], ['SAME_AUTHOR_REVIEW', 'AUTHOR_SELF_CHECK', 'NUMERICAL_EXPERIMENT'], ['GREEN_CI', 'HASH_MATCH', 'ARCHITECTURAL_ADMISSION'], + ['GREEN_CI', 'HASH_MATCH', 'SAME_AUTHOR_REVIEW'], ): - result = m.refuse_non_discharge_promotion( - self.graph, 'math.rn-fixed-remote-window', tokens) - self.assertTrue(result['refused']) - self.assertFalse(result['allowed']) + result = m.refuse_non_discharge_promotion(g, target, tokens) + self.assertIs(result['base']['allowed'], True) + self.assertIs(result['refused'], True) + self.assertIs(result['allowed'], False) + self.assertEqual(result['reasons'], ['evidence consists only of non-discharge tokens']) + positive = m.refuse_non_discharge_promotion(g, target, ['LINE_BY_LINE_ANALYTIC_REVIEW']) + self.assertIs(positive['allowed'], True) + self.assertIs(positive['refused'], False) + self.assertEqual(positive['reasons'], []) def test_unknown_evidence_token_refused(self): result = m.refuse_non_discharge_promotion( @@ -160,17 +219,31 @@ def test_refuted_price_boundary_is_terminal(self): self.assertTrue(m.is_terminal('REFUTED')) def test_full_price_boundary_refutation_is_not_a_required_premise(self): - decision = m.promotion_allowed(self.graph, 'math.p15-full-price') - self.assertEqual(decision['required_dependencies'], []) - self.assertEqual(decision['missing_terminal'], []) - self.assertEqual(decision['blocked_absent'], []) - self.assertEqual(decision['refuted_required'], []) - self.assertFalse(decision['allowed']) # own node remains author-side edge = next(e for e in self.graph['edges'] if e['from'] == 'math.p15-full-price' and e['to'] == 'math.p15-price-boundary') - self.assertFalse(edge['required']) + self.assertIs(edge['required'], False) self.assertIn('boundary', edge['relation']) + # Historical contextual boundary, with no required positive premise. + g = {'schema_version': 1, 'nodes': { + 'diagnostic.price': {'classification': 'AUTHOR_SIDE_CANDIDATE', 'controlling': False}, + 'diagnostic.boundary': {'classification': 'REFUTED', 'controlling': False}, + }, 'edges': [{'from': 'diagnostic.price', 'to': 'diagnostic.boundary', + 'required': False, 'relation': 'contextual refuted boundary'}]} + decision = m.promotion_allowed(g, 'diagnostic.price') + for key in ('required_dependencies', 'missing_terminal', 'blocked_absent', 'refuted_required'): + self.assertEqual(decision[key], []) + self.assertIs(decision['allowed'], False) + g['nodes']['diagnostic.price']['classification'] = 'PROVED_REVIEWED' + self.assertIs(m.promotion_allowed(g, 'diagnostic.price')['allowed'], True) + # Separately reviewed additional positive dependencies are legal. + g['nodes']['diagnostic.positive'] = {'classification': 'PROVED_REVIEWED', 'controlling': False} + g['edges'].append({'from': 'diagnostic.price', 'to': 'diagnostic.positive', + 'required': True, 'relation': 'positive premise'}) + decision = m.promotion_allowed(g, 'diagnostic.price') + self.assertIs(decision['allowed'], True) + self.assertEqual(decision['required_dependencies'], ['diagnostic.positive']) + self.assertEqual(decision['refuted_required'], []) def test_reverse_impact_marks_dependents(self): impact = m.reverse_impact( @@ -210,12 +283,29 @@ def test_classification_change_triggers_impact(self): self.assertIn('math.rn-mesoscopic-reduction', impact['impacted']) def test_illegal_controlling_detected(self): - bad = copy.deepcopy(self.graph) - bad['nodes']['math.lifetime-remainder']['controlling'] = True + # A small valid graph establishes the forbidden own-node precondition. + target, parent = 'diagnostic.controlling', 'math.uniform-matrix-cap-lifetime' + bad = {'schema_version': 1, 'nodes': { + target: {'classification': 'AUTHOR_SIDE_CANDIDATE', 'controlling': True}, + parent: {'classification': 'PROVED_REVIEWED', 'controlling': False}, + }, 'edges': [{'from': target, 'to': parent, 'required': True, 'relation': 'premise'}]} + frozen = copy.deepcopy(bad) report = m.closure_report(bad) - self.assertFalse(report['gate_ok']) - self.assertEqual(len(report['illegal_controlling']), 1) - self.assertEqual(report['illegal_controlling'][0]['node'], 'math.lifetime-remainder') + self.assertIs(report['gate_ok'], False) + self.assertEqual([d['node'] for d in report['illegal_controlling']], [target]) + self.assertEqual(report['illegal_controlling'][0]['reasons'], [ + 'node classification is not eligible for positive CONTROLLING status: AUTHOR_SIDE_CANDIDATE']) + payload = m.results_payload(bad) + self.assertIs(payload['gate_ok'], False) + self.assertEqual(payload['closure']['illegal_controlling_count'], 1) + self.assertIs(payload['illegal_promotion_refused'], True) + self.assertEqual(bad, frozen) + good = copy.deepcopy(bad) + good['nodes'][target]['classification'] = 'PROVED_REVIEWED' + positive = m.closure_report(good) + self.assertIs(positive['gate_ok'], True) + self.assertEqual(positive['illegal_controlling'], []) + self.assertIs(m.results_payload(good)['gate_ok'], True) def test_live_graph_has_no_illegal_controlling(self): report = m.closure_report(self.graph) @@ -223,51 +313,78 @@ def test_live_graph_has_no_illegal_controlling(self): self.assertEqual(report['illegal_controlling'], []) def test_d4_region_complement(self): - regions = m.d4_region_complement(self.graph) - covered_ids = {r['id'] for r in regions['covered_by_fixed_remote_candidate']} - scoped_ids = {r['id'] for r in regions['covered_by_other_scoped_candidates']} - reviewed_ids = {r['id'] for r in regions['proved_reviewed_regions']} - open_ids = {r['id'] for r in regions['open_complement']} - self.assertEqual(covered_ids, {'math.rn-region.fixed-remote'}) - self.assertEqual(scoped_ids, {'math.rn-region.fixed-annulus-window'}) - self.assertEqual( - regions['covered_by_other_scoped_candidates'][0]['coverage_source'], - 'math.rn-fixed-annulus-window', - ) - self.assertEqual(reviewed_ids, { - 'math.rn-region.mesoscopic-scaled-annulus', - 'math.rn-region.pin-collision', - 'math.rn-region.intermediate-r-to-rho', - }) - self.assertTrue(reviewed_ids.isdisjoint(open_ids)) - self.assertIn('math.rn-region.witness-collision', open_ids) - witness = next(r for r in regions['open_complement'] - if r['id'] == 'math.rn-region.witness-collision') - self.assertIn('sharp global order is reviewed and merged through Math-#145', - witness['notes']) - self.assertNotIn('sharp full-window order remain open', witness['notes']) - self.assertFalse(regions['legacy_24jet_discharged']) - self.assertTrue(regions['no_event_to_expectation_reversal']) + # Explicit classification categories; these are not eternal live statuses. + categories = { + 'math.rn-region.fixed-remote': ('COVERED_BY_CANDIDATE', 'math.rn-fixed-remote-window'), + 'math.rn-region.fixed-annulus-window': ('COVERED_BY_CANDIDATE', 'math.rn-fixed-annulus-window'), + 'math.rn-region.mesoscopic-scaled-annulus': ('PROVED_REVIEWED', None), + 'math.rn-region.pin-collision': ('PROVED_REVIEWED', None), + 'math.rn-region.intermediate-r-to-rho': ('PROVED_REVIEWED', None), + 'math.rn-region.witness-collision': ('OPEN_ACTIVE', None), + } + g = {'schema_version': 1, 'nodes': {}, 'edges': []} + for nid, (classification, source) in categories.items(): + self.assertEqual(self.graph['nodes'][nid]['kind'], 'region') + g['nodes'][nid] = {'kind': 'region', 'classification': classification, + 'controlling': False, 'coverage_source': source, + 'fingerprint': 'explicit scoped fixture: ' + nid, + 'notes': 'fixture source limits are not live closure evidence'} + witness_note = ('sharp global order is reviewed and merged through Math-#145; ' + 'the regional shrinking mechanism remains open in this historical specimen') + g['nodes']['math.rn-region.witness-collision']['notes'] = witness_note + regions = m.d4_region_complement(g) + expected = { + 'covered_by_fixed_remote_candidate': {'math.rn-region.fixed-remote'}, + 'covered_by_other_scoped_candidates': {'math.rn-region.fixed-annulus-window'}, + 'proved_reviewed_regions': {'math.rn-region.mesoscopic-scaled-annulus', + 'math.rn-region.pin-collision', 'math.rn-region.intermediate-r-to-rho'}, + 'open_complement': {'math.rn-region.witness-collision'}, + } + for bucket, ids in expected.items(): + self.assertEqual({r['id'] for r in regions[bucket]}, ids) + for entry in regions[bucket]: + for field in ('classification', 'coverage_source', 'fingerprint', 'notes'): + self.assertEqual(entry[field], g['nodes'][entry['id']][field]) + self.assertEqual(regions['open_complement'][0]['notes'], witness_note) + self.assertIs(regions['legacy_24jet_discharged'], False) + self.assertIs(regions['no_event_to_expectation_reversal'], True) def test_selector_region_matrix(self): - table = m.load_selector_region() - self.assertEqual(table['schema_version'], 1) + live = m.load_selector_region() + self.assertEqual(live['schema_version'], 1) + self.assertIs(live['legacy_24jet_discharged'], False) + self.assertIs(live['no_event_to_expectation_reversal'], True) + regions = ['fixed-remote', 'mesoscopic-scaled-annulus', 'pin-collision', + 'intermediate-r-to-rho', 'witness-collision'] + table = {'schema_version': 1, 'regions': regions, + 'no_event_to_expectation_reversal': True, 'legacy_24jet_discharged': False, + 'covered_region_ids': ['math.rn-region.fixed-remote'], + 'open_region_ids': ['math.rn-region.' + r for r in regions[1:]], + 'selectors': { + 'CH-LIFT': dict(zip(regions, ['BYPASSED_BY_FIXED_RHO', 'REOPENED', + 'OPEN_ACTIVE', 'NOT_DISCHARGED', 'NOT_APPLICABLE'])), + 'diagnostic.all-categories': dict(zip(regions, ['PARTIAL_COVER_ONLY', + 'PARTIAL_PR7_REDUCTION', 'OPEN_HISTORICAL', 'PARTIAL_COVER_DECLARED_REGION', 'NOT_REQUIRED']))}} + table['selectors']['CH-LIFT']['notes'] = 'not a region cell' + frozen = copy.deepcopy(table) report = m.selector_region_report(table) - self.assertFalse(report['legacy_24jet_discharged']) - self.assertTrue(report['no_event_to_expectation_reversal']) + self.assertEqual(table, frozen) + self.assertIs(report['legacy_24jet_discharged'], False) + self.assertIs(report['no_event_to_expectation_reversal'], True) self.assertEqual(report['covered_region_ids'], ['math.rn-region.fixed-remote']) - # CH-LIFT is bypassed on fixed-remote but reopened on the mesoscopic annulus. - ch = table['selectors']['CH-LIFT'] - self.assertEqual(ch['fixed-remote'], 'BYPASSED_BY_FIXED_RHO') - self.assertEqual(ch['mesoscopic-scaled-annulus'], 'REOPENED') - # Every open complement region still has at least one non-closed selector cell. - open_regions = {c['region'] for c in report['open_or_partial_cells']} - for region in ( - 'mesoscopic-scaled-annulus', 'pin-collision', - 'intermediate-r-to-rho', 'witness-collision', - ): - self.assertIn(region, open_regions) - self.assertGreaterEqual(len(report['open_or_partial_cells']), 15) + self.assertEqual(report['open_region_ids'], table['open_region_ids']) + self.assertEqual({(c['selector'], c['region'], c['status']) for c in report['open_or_partial_cells']}, { + ('CH-LIFT', 'mesoscopic-scaled-annulus', 'REOPENED'), + ('CH-LIFT', 'pin-collision', 'OPEN_ACTIVE'), + ('CH-LIFT', 'intermediate-r-to-rho', 'NOT_DISCHARGED'), + ('diagnostic.all-categories', 'fixed-remote', 'PARTIAL_COVER_ONLY'), + ('diagnostic.all-categories', 'mesoscopic-scaled-annulus', 'PARTIAL_PR7_REDUCTION'), + ('diagnostic.all-categories', 'pin-collision', 'OPEN_HISTORICAL'), + ('diagnostic.all-categories', 'intermediate-r-to-rho', 'PARTIAL_COVER_DECLARED_REGION')}) + self.assertEqual({(c['selector'], c['region'], c['status']) for c in report['covered_bypassed_or_na_cells']}, { + ('CH-LIFT', 'fixed-remote', 'BYPASSED_BY_FIXED_RHO'), + ('CH-LIFT', 'witness-collision', 'NOT_APPLICABLE'), + ('diagnostic.all-categories', 'witness-collision', 'NOT_REQUIRED')}) def test_d0_ci_unblock_patch_ready(self): report = m.d0_ci_unblock_report() @@ -287,6 +404,13 @@ def test_pr87_hold_until_allowlist(self): decision = m.promotion_allowed(self.graph, 'eng.main-pr87-crosswalk') self.assertFalse(decision['allowed']) self.assertIn('eng.d0-packet-allowlist-fix', decision['required_dependencies']) + g, target, premise = self.diagnostic_specimen('promote_pr87_before_allowlist') + decision = m.promotion_allowed(g, target) + self.assertIs(decision['allowed'], False) + self.assertEqual(decision['missing_terminal'], [{'id': premise, 'classification': 'AUTHOR_SIDE_CANDIDATE'}]) + self.assertEqual(decision['reasons'], ['required transitive dependency is not satisfied']) + g['nodes'][premise]['classification'] = 'PROVED_REVIEWED' + self.assertIs(m.promotion_allowed(g, target)['allowed'], True) def test_layer_coverage_d0_through_d7(self): layers = {n['layer'] for n in self.graph['nodes'].values()} @@ -295,13 +419,37 @@ def test_layer_coverage_d0_through_d7(self): self.assertIn('math.rn-selector-region-crosswalk', self.graph['nodes']) def test_results_bytes_match(self): + frozen_graph = copy.deepcopy(self.graph) + frozen_inputs = {name: (ROOT / name).read_bytes() for name in ('GRAPH.json', 'SELECTOR_REGION.json')} payload = m.results_payload(self.graph) - pinned = json.loads((ROOT / 'RESULTS.json').read_text()) - self.assertEqual(payload, pinned) - self.assertTrue(payload['illegal_promotion_refused']) + # These direct predicates observe reporter mutants before any stale golden. self.assertIs(payload['lemma_closed'], False) + self.assertEqual(payload['scientific_effect'], 'NONE') + self.assertIs(payload['illegal_promotion_refused'], True) + self.assertEqual(payload.get('illegal_attempts_context'), 'synthetic_negative_controls') + self.assertEqual(payload, json.loads((ROOT / 'RESULTS.json').read_text())) self.assertTrue(payload['d0_ci_unblock']['ready']) - self.assertGreaterEqual(payload['selector_region']['open_or_partial_cell_count'], 15) + table = json.loads(frozen_inputs['SELECTOR_REGION.json']) + open_statuses = {'OPEN_ACTIVE', 'OPEN_HISTORICAL', 'NOT_DISCHARGED', 'PARTIAL_COVER_ONLY', + 'PARTIAL_PR7_REDUCTION', 'REOPENED', 'PARTIAL_COVER_DECLARED_REGION'} + count = sum(row[region] in open_statuses for row in table['selectors'].values() for region in table['regions']) + self.assertEqual(payload['selector_region']['open_or_partial_cell_count'], count) + self.assertEqual(payload['selector_region']['covered_bypassed_or_na_cell_count'], + len(table['selectors']) * len(table['regions']) - count) + # Real statuses may become eligible without changing invariant diagnostics. + eligible = copy.deepcopy(self.graph) + for target in ('math.lifetime-remainder', 'math.side24-coefficient', 'math.rn-fixed-remote-window'): + for nid in [target, *m.transitive_required(eligible, target)]: + eligible['nodes'][nid]['classification'] = 'PROVED_REVIEWED' + self.assertIs(m.promotion_allowed(eligible, target)['allowed'], True) + later = m.results_payload(eligible) + self.assertIs(later['illegal_promotion_refused'], True) + self.assertEqual(later['illegal_attempts'], payload['illegal_attempts']) + self.assertEqual(self.graph, frozen_graph) + self.assertEqual({name: (ROOT / name).read_bytes() for name in frozen_inputs}, frozen_inputs) + for invalid in ({}, [], '', 0): + with self.subTest(invalid=invalid), self.assertRaises(ValueError): + m.results_payload(invalid) def test_author_side_with_terminal_deps_cannot_become_controlling(self): g = copy.deepcopy(self.graph)