From 859a79234f24953bfc6c60e94e77bfbdbc6e11f0 Mon Sep 17 00:00:00 2001 From: "Hermes (coordinator)" Date: Tue, 1 Dec 2026 21:25:58 -0500 Subject: [PATCH] lease(merge-lane-gate-authority-compare): frozen contract 7ac505af + lease --- ...a34aeb448276d85e100c7a444bfa3e4773692.json | 166 ++++++++++++++++++ .../merge-lane-gate-authority-compare.json | 47 +++++ 2 files changed, 213 insertions(+) create mode 100644 .rizzstack/contracts/7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692.json create mode 100644 .rizzstack/leases/merge-lane-gate-authority-compare.json diff --git a/.rizzstack/contracts/7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692.json b/.rizzstack/contracts/7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692.json new file mode 100644 index 0000000..4bc4233 --- /dev/null +++ b/.rizzstack/contracts/7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692.json @@ -0,0 +1,166 @@ +{ + "acceptance_criteria": [ + { + "id": "AC-001", + "regression": false, + "statement": "gate_authority_facts compares the current base tip to each candidate run's head (fetch_compare(base_tip, run.head_sha)) and records GitHub's status. A trusted run whose head_sha is the pull request's head and whose base tip is an ancestor of that head (status 'ahead') is proven: gate_authority_state returns (True, None, run_id). The compare request is directed base-first; the reverse direction (head...base) is never requested.", + "tests": [ + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_a_gate_run_at_the_head_is_proven_against_an_ancestor_base", + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_the_compare_is_directed_from_the_base_tip_to_the_gated_head" + ], + "verification": "test" + }, + { + "id": "AC-002", + "regression": true, + "statement": "A base that moved past the gated head is still refused: when the base-tip...head compare reports 'diverged' or 'behind', gate_authority_state returns gate_authority_wrong_base. The change weakens no existing wrong-base refusal.", + "tests": [ + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_a_base_that_moved_past_the_gated_head_is_refused" + ], + "verification": "test" + }, + { + "id": "AC-003", + "regression": true, + "statement": "An unreadable compare still fails closed: a FetchError leaves error true and compare_status None, and gate_authority_state returns gate_authority_unproven, never a pass.", + "tests": [ + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_an_unreadable_compare_refuses" + ], + "verification": "test" + }, + { + "id": "AC-004", + "regression": true, + "statement": "An 'identical' compare is accepted: a trusted run whose head is the base tip is proven, because the gated head contains the current base (it is the current base).", + "tests": [ + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_an_identical_compare_is_accepted" + ], + "verification": "test" + } + ], + "assumptions": [ + "GitHub's compare API reports 'ahead' when the second revision contains the first and has commits beyond it, 'identical' when they are the same commit, and 'diverged'/'behind' otherwise.", + "The trusted gate-authority run is pull_request_target and its run head_sha is the pull request head, not a base commit; the entry's base ref remains the PR's base ref." + ], + "authorization": { + "human_gates": [ + "merge", + "tag", + "release", + "deploy", + "publish", + "post" + ], + "not_authorized": [ + "merge", + "tag", + "release", + "deploy", + "publish", + "force-push", + "branch deletion", + "edit approved tests", + "ruleset or settings changes", + "app or key changes" + ] + }, + "contract_version": "acdd/1", + "dependencies": [], + "evidence_required": [ + "red", + "green", + "review", + "security" + ], + "id": "merge-lane-gate-authority-compare", + "interfaces": [ + { + "change": "modify", + "kind": "function", + "name": "gate_authority_facts" + } + ], + "notes": [ + "Why: rizzstack#73 at 0c4362f85976229fdae066f33d0b420a226b0468. Run 46787387514 (gate-authority.yml, pull_request_target, app github-actions) has head_sha 0c4362f8 (the PR head) and base e6fb6119 (current main), completed/success. gate_authority_facts calls fetch_compare(repo_slug, head_sha, base_tip); GitHub answers status 'behind' (ahead_by 0, behind_by 8), and gate_authority_state accepts only 'ahead' or 'identical', so the lane refuses gate_authority_wrong_base while the gate is green and pinned to exactly the current base.", + "The 01:35Z record note that base_tip was empty and the refusal came from the line-1878 guard is wrong. base_tip is fetched (demanded is true because the base tree carries .github/workflows/gate-authority.yml), and an empty tip would return gate_authority_unproven, not wrong_base. The observed facts are the operand order at line 1799.", + "Fix: swap the compare operands to (base_tip, run.head_sha). The compare's file list is the same changed-file set, so the gate-code staleness check is unchanged. 'ahead' proves the gated head contains the current base; 'identical' proves it is the base; 'diverged', 'behind' and an unreadable compare still refuse.", + "Not in scope: accepting a trusted run whose base is an older ancestor when the PR's diff against the current base is identical. That older-base card stays separate.", + "At baseline: 2 failed (the two AC-001 tests), 3 passed (the regression guards).", + "RED branch red/w1d-gate-authority-compare carries one tests-only commit eaa85519aa3f4a0e1e6848e538812272fb97590c whose parent is e6fb6119bba3fd7c6e200f8ad70f4931a3203f34." + ], + "outcome": { + "observable_behavior": [ + "a trusted gate run at the PR head whose base is an ancestor of that head reads as proven", + "the lane asks GitHub for base_tip...head, never head...base_tip", + "a base the gated head does not contain still refuses wrong_base", + "an unreadable compare still refuses as unproven" + ], + "summary": "The lane proves a trusted gate-authority run by showing the gated head contains the current base tip, instead of comparing in the direction that reports every normal PR as behind." + }, + "review": { + "status": "approved", + "approved_by": "Kyle: approved: merge-lane-gate-authority-compare 7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692 (RED eaa85519aa3f4a0e1e6848e538812272fb97590c on red/w1d-gate-authority-compare)", + "approved_at": "2026-12-02T02:24:29Z", + "contract_sha256": "7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692", + "test_collection": { + "manifest_sha256": "3642c968c25cffa57ff5f7b8bfd9dc0ffb3871744fc79f74a19d2cb727618e61", + "source_rev": "eaa85519aa3f4a0e1e6848e538812272fb97590c", + "collected": 184 + } + }, + "risk": { + "blast_radius": "Only the compare operand order in gate_authority_facts changes. Every other gate predicate (run identity, app, base ref, conclusion, review timing, gate code on the base) is untouched, and diverged, behind or unreadable compares still refuse.", + "reasons": [ + "scripts/merge_lane_* is a gate-lane path", + "changes which gate evidence the lane will accept" + ], + "tier": "high" + }, + "scope": { + "assigned_files": [ + "scripts/merge_lane_v5.py" + ], + "prohibited": [ + ".github/**", + "policy/**", + ".rizzstack/**", + "docs/**", + "CHANGELOG.md", + "conftest.py", + "pyproject.toml", + "scripts/preauth.py", + "scripts/preauth_verify.py", + "scripts/compat.py", + "scripts/merge_lane_v4.py" + ], + "read_only": [ + "tests/test_lease_tamper.py", + ".github/scripts/lease_tamper.py", + "tests/fixtures/**" + ], + "test_files": [ + "tests/test_merge_lane_v5.py" + ] + }, + "source_rev": "eaa85519aa3f4a0e1e6848e538812272fb97590c", + "supersedes": [], + "targets": [ + { + "base": "e6fb6119bba3fd7c6e200f8ad70f4931a3203f34", + "red": "eaa85519aa3f4a0e1e6848e538812272fb97590c", + "red_branch": "red/w1d-gate-authority-compare", + "repo": "mojomast/rizzstack" + } + ], + "tdd": { + "applicable": true, + "test_first": true + }, + "title": "merge-lane: prove the gate-authority run by comparing the base tip to the gated head", + "verification": { + "commands": [ + "env -u PYTHONPATH python3 -m unittest discover -s tests -p test_merge_lane_v5.py -v" + ], + "independent": true + } +} diff --git a/.rizzstack/leases/merge-lane-gate-authority-compare.json b/.rizzstack/leases/merge-lane-gate-authority-compare.json new file mode 100644 index 0000000..a1cb487 --- /dev/null +++ b/.rizzstack/leases/merge-lane-gate-authority-compare.json @@ -0,0 +1,47 @@ +{ + "branch": "feat/merge-lane-gate-authority-compare", + "contract_id": "merge-lane-gate-authority-compare", + "contract_sha256": "7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692", + "derived_from": { + "approved_at": "2026-12-02T02:24:29Z", + "approved_by": "Kyle: approved: merge-lane-gate-authority-compare 7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692 (RED eaa85519aa3f4a0e1e6848e538812272fb97590c on red/w1d-gate-authority-compare)", + "contract": ".rizzstack/contracts/7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692.json" + }, + "id": "merge-lane-gate-authority-compare", + "lease_version": "rizzstack.lease/1", + "review": { + "approved_at": "2026-12-02T02:24:29Z", + "approved_by": "Kyle: approved: merge-lane-gate-authority-compare 7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692 (RED eaa85519aa3f4a0e1e6848e538812272fb97590c on red/w1d-gate-authority-compare)", + "note": "contract_sha256 names the approved frozen contract; scope and source_rev are its verbatim scope", + "status": "frozen" + }, + "scope": { + "assigned_files": [ + "scripts/merge_lane_v5.py" + ], + "prohibited": [ + ".github/**", + "policy/**", + ".rizzstack/**", + "docs/**", + "CHANGELOG.md", + "conftest.py", + "pyproject.toml", + "scripts/preauth.py", + "scripts/preauth_verify.py", + "scripts/compat.py", + "scripts/merge_lane_v4.py" + ], + "read_only": [ + "tests/test_lease_tamper.py", + ".github/scripts/lease_tamper.py", + "tests/fixtures/**" + ], + "test_files": [ + "tests/test_merge_lane_v5.py" + ] + }, + "slice": "W1D", + "source_rev": "eaa85519aa3f4a0e1e6848e538812272fb97590c", + "verify_sha": "eaa85519aa3f4a0e1e6848e538812272fb97590c" +}