From 922a684f22e4348fa63e1c3e5c13e92e6b988a94 Mon Sep 17 00:00:00 2001 From: "Hermes (coordinator)" Date: Tue, 1 Dec 2026 22:16:40 -0500 Subject: [PATCH] lease(merge-lane-gate-authority-compare): frozen contract feb3863e + lease (r3) --- ...2a1140ce3b092d76d693995245fa7c9f94131.json | 181 ++++++++++++++++++ .../merge-lane-gate-authority-compare.json | 47 +++++ 2 files changed, 228 insertions(+) create mode 100644 .rizzstack/contracts/feb3863e7940fcb195815d2c3ff2a1140ce3b092d76d693995245fa7c9f94131.json create mode 100644 .rizzstack/leases/merge-lane-gate-authority-compare.json diff --git a/.rizzstack/contracts/feb3863e7940fcb195815d2c3ff2a1140ce3b092d76d693995245fa7c9f94131.json b/.rizzstack/contracts/feb3863e7940fcb195815d2c3ff2a1140ce3b092d76d693995245fa7c9f94131.json new file mode 100644 index 0000000..9314649 --- /dev/null +++ b/.rizzstack/contracts/feb3863e7940fcb195815d2c3ff2a1140ce3b092d76d693995245fa7c9f94131.json @@ -0,0 +1,181 @@ +{ + "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": false, + "statement": "The base-first compare's file list still feeds the gate-code staleness check. That list is the diff from the merge base to the gated head (the pull request's own change set when the base tip is an ancestor). A file entry under .github/scripts/ or the gate workflow paths in that list refuses gate_authority_stale_gate. The check is not vacuous after the operand swap: on the old head-first direction GitHub returns an empty file list for the accepted ancestor shape.", + "tests": [ + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_a_changed_gate_path_in_the_compare_still_refuses" + ], + "verification": "test" + }, + { + "id": "AC-003", + "regression": true, + "statement": "A base that moved past the gated head is still refused: both 'diverged' and 'behind' return 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-004", + "regression": true, + "statement": "An unreadable compare still fails closed: a FetchError sets the facts' error flag true with 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-005", + "regression": true, + "statement": "An equal-SHA case is accepted: a trusted run whose head_sha equals the base tip (compare status 'identical') is proven, exercising the equal-SHA path end to end rather than injecting a status on distinct SHAs.", + "tests": [ + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_an_identical_compare_is_accepted" + ], + "verification": "test" + } + ], + "assumptions": [ + "GitHub's three-dot compare 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 compare's file list is relative to the merge base and the second revision; it is not symmetric under a reversal.", + "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 '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). 'ahead' proves the gated head contains the current base; 'identical' proves it is the base; 'diverged', 'behind' and an unreadable compare still refuse.", + "Correction from the first host review of lease PR #83 (blocking 1): a three-dot compare's file list is not preserved under a reversal. The base-first list is the merge-base-to-gated-head diff (the PR's own change set when the base is an ancestor); on the old head-first direction GitHub returns an empty list in the accepted ancestor shape, so the staleness check could not be exercised. AC-002 pins the changed-gate-path refusal in the new direction, and the group is explicitly not claimed to be the same set.", + "Correction from the same review (blocking 2): AC-003 now exercises both 'diverged' and 'behind'; AC-004 asserts the error flag and the unset compare_status, not only the final refusal; AC-005 drives an equal head/base SHA through gate_authority_facts instead of injecting 'identical' on distinct SHAs.", + "Re-cut: the earlier contract 7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692 was never merged and is withdrawn with lease PR #83. supersedes is empty because a predecessor that never reached the base can never resolve in the gate; the chain is recorded in this note and in the new lease PR body.", + "At baseline: 179 tests, 0 failures, 0 errors with an isolated empty HOME and XDG dirs. At the RED: 185 tests, 3 failures (the AC-001 pair and AC-002), 0 errors.", + "Host r1 on lease PR #84 (2026-12-02T03:0xZ): blocking 1 was that the r2 RED head's direct parent was not the declared base (two commits on the branch); blocking 2 was that AC-002 exercised only a gate script, not a workflow path. This r3 RED is ONE tests-only commit whose direct parent is e6fb6119, and AC-002 loops both .github/scripts/lease_tamper.py and .github/workflows/gate-authority.yml. The earlier red/w1d-gate-authority-compare branch and the withdrawn contracts 7ac505af/ a2ce4269 stay on the remote; this is the cut intended to land.", + "RED branch red/w1d-gate-authority-compare-r2 carries one tests-only commit 5246de7f1912855cc4e5d60974263337e274eb01 whose parent is e6fb6119; the branch diff against e6fb6119 is +174/-0 in tests/test_merge_lane_v5.py." + ], + "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 changed gate path in the base-first file list still refuses stale_gate", + "a base the gated head does not contain still refuses wrong_base", + "an unreadable compare still refuses as unproven", + "an equal head/base SHA with identical status is proven" + ], + "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 feb3863e7940fcb195815d2c3ff2a1140ce3b092d76d693995245fa7c9f94131 (RED 5246de7f1912855cc4e5d60974263337e274eb01 on red/w1d-gate-authority-compare-r2).", + "approved_at": "2026-12-02T03:16:07Z", + "contract_sha256": "feb3863e7940fcb195815d2c3ff2a1140ce3b092d76d693995245fa7c9f94131", + "test_collection": { + "manifest_sha256": "a6b8bc50c7f89792f3312bc42d80a76a55ca94508f6124f8e8e3fa8c3282379f", + "source_rev": "5246de7f1912855cc4e5d60974263337e274eb01", + "collected": 185 + } + }, + "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) is untouched. The gate-code staleness check now reads the merge-base-to-head file list, so a PR that changes gate paths refuses; 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": "5246de7f1912855cc4e5d60974263337e274eb01", + "supersedes": [], + "targets": [ + { + "base": "e6fb6119bba3fd7c6e200f8ad70f4931a3203f34", + "red": "5246de7f1912855cc4e5d60974263337e274eb01", + "red_branch": "red/w1d-gate-authority-compare-r2", + "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..c4c4acc --- /dev/null +++ b/.rizzstack/leases/merge-lane-gate-authority-compare.json @@ -0,0 +1,47 @@ +{ + "branch": "feat/merge-lane-gate-authority-compare-r3", + "contract_id": "merge-lane-gate-authority-compare", + "contract_sha256": "feb3863e7940fcb195815d2c3ff2a1140ce3b092d76d693995245fa7c9f94131", + "derived_from": { + "approved_at": "2026-12-02T03:16:07Z", + "approved_by": "Kyle: approved: merge-lane-gate-authority-compare feb3863e7940fcb195815d2c3ff2a1140ce3b092d76d693995245fa7c9f94131 (RED 5246de7f1912855cc4e5d60974263337e274eb01 on red/w1d-gate-authority-compare-r2).", + "contract": ".rizzstack/contracts/feb3863e7940fcb195815d2c3ff2a1140ce3b092d76d693995245fa7c9f94131.json" + }, + "id": "merge-lane-gate-authority-compare", + "lease_version": "rizzstack.lease/1", + "review": { + "approved_at": "2026-12-02T03:16:07Z", + "approved_by": "Kyle: approved: merge-lane-gate-authority-compare feb3863e7940fcb195815d2c3ff2a1140ce3b092d76d693995245fa7c9f94131 (RED 5246de7f1912855cc4e5d60974263337e274eb01 on red/w1d-gate-authority-compare-r2).", + "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": "5246de7f1912855cc4e5d60974263337e274eb01", + "verify_sha": "5246de7f1912855cc4e5d60974263337e274eb01" +}