From 4cea301aed913302cc5c75a4509b3caa714e4885 Mon Sep 17 00:00:00 2001 From: "Hermes (coordinator)" Date: Tue, 1 Dec 2026 23:05:18 -0500 Subject: [PATCH] lease(merge-lane-gate-authority-compare): frozen contract 55360719 (r6) + lease --- ...813c3acd87d01e630486f14c8411a8460aa3d.json | 202 ++++++++++++++++++ .../merge-lane-gate-authority-compare.json | 47 ++++ 2 files changed, 249 insertions(+) create mode 100644 .rizzstack/contracts/55360719423009b1fe4da094220813c3acd87d01e630486f14c8411a8460aa3d.json create mode 100644 .rizzstack/leases/merge-lane-gate-authority-compare.json diff --git a/.rizzstack/contracts/55360719423009b1fe4da094220813c3acd87d01e630486f14c8411a8460aa3d.json b/.rizzstack/contracts/55360719423009b1fe4da094220813c3acd87d01e630486f14c8411a8460aa3d.json new file mode 100644 index 0000000..72e79ca --- /dev/null +++ b/.rizzstack/contracts/55360719423009b1fe4da094220813c3acd87d01e630486f14c8411a8460aa3d.json @@ -0,0 +1,202 @@ +{ + "acceptance_criteria": [ + { + "id": "AC-001", + "regression": false, + "statement": "gate_authority_facts compares the base tip to each candidate run's head (base_tip...run.head_sha) and records the status. A trusted run whose head_sha is the pull request head, whose pull_requests[] entry base sha equals the current base tip, and whose base tip is an ancestor of that head (status 'ahead') is proven: gate_authority_state returns (True, None, run_id). The compare is directed base-first; the reverse direction 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. A file entry under .github/scripts/ or the gate workflow paths refuses gate_authority_stale_gate; the test covers both a gate script and the gate workflow.", + "tests": [ + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_a_changed_gate_path_in_the_compare_still_refuses" + ], + "verification": "test" + }, + { + "id": "AC-003", + "regression": false, + "statement": "A base that moved past the gated head is refused: 'diverged' and 'behind' both return gate_authority_wrong_base. For the 'behind' case the fixture returns 'ahead' in the reverse direction, so a reversed fallback cannot pass this test.", + "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": "The 300-file compare limit and the non-list refusal exist on main since #49 (gate_authority_state, GATE_AUTHORITY_COMPARE_LIMIT = 300); this test fails at the RED only because the old compare direction never reaches the file list. With the base-first direction, four malformed shapes all refuse gate_authority_stale_gate: a non-list 'files' value, a list of 300 distinct non-gate files (docs/f000.md ... docs/f299.md, status modified), a document with no 'files' key at all, and a list carrying an entry with no readable filename. The limit case is what refuses at 300; the missing-key and malformed-entry cases prove that a missing or partially readable change set is never accepted.", + "tests": [ + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_an_incomplete_or_malformed_file_list_is_refused" + ], + "verification": "test" + }, + { + "id": "AC-005", + "regression": true, + "statement": "Ancestry alone is not proof of the evaluated base: a trusted run whose pull_requests[] entry base sha is an older commit than the current base tip is refused gate_authority_wrong_base, and a run whose entry carries no base sha at all is also refused, even when the compare reports 'ahead'. This guard passes at the baseline only because the old direction refuses every case; it fails if the entry-base-sha check is omitted after the operand swap.", + "tests": [ + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_a_run_tied_to_an_older_base_is_refused", + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_a_run_without_a_base_sha_is_refused" + ], + "verification": "test" + }, + { + "id": "AC-006", + "regression": true, + "statement": "An unreadable compare still fails closed: a FetchError sets error true with compare_status None, and gate_authority_state returns gate_authority_unproven.", + "tests": [ + "tests/test_merge_lane_v5.py::GateAuthorityCompareDirectionTests::test_an_unreadable_compare_refuses" + ], + "verification": "test" + }, + { + "id": "AC-007", + "regression": true, + "statement": "An equal head/base SHA with compare status 'identical' is proven end to end.", + "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 first host review (blocking 2): AC-003 exercises both 'diverged' and 'behind'; AC-006 asserts the error flag and the unset compare_status, not only the final refusal; AC-007 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: 187 tests, 7 failure reports across 4 test methods, 0 errors.", + "Host r2 on lease PR #85 (2026-12-02T03:3xZ), both blockers accepted: ancestry alone does not establish which base snapshot the run judged, so AC-005 requires the run's pull_requests[] entry base sha to equal the current base tip; and GitHub Compare returns at most 300 files, so AC-004 covers the non-list and the 300-entry limit (now a regression guard, with 300 distinct non-gate docs files so the limit rather than the gate-path branch refuses).", + "RED branch red/w1d-gate-authority-compare-r5 carries one tests-only commit 2cf03fd224850b5819fbc9e29025c4e185c8eba8 whose parent is e6fb6119; the branch diff against e6fb6119 is +192/-0 in tests/test_merge_lane_v5.py. Isolated baseline 179 OK; at the RED 187 tests, 7 failure reports across 4 test methods (AC-001 pair, AC-002's two paths, AC-003's behind subtest, AC-004's two paths), 0 errors.", + "Host r4 on lease PR #86 (2026-12-02T03:5xZ), both blockers accepted: AC-004 now refuses a missing 'files' key and a malformed entry in the list (not just a non-list and the 300 limit), and AC-005 now refuses a run whose entry carries no base sha, with the compare still reporting 'ahead'. The blast-radius text is corrected: the slice changes the operand order AND adds the entry-base-sha check; it is not operand-only.", + "Owner corrections for r5 are retained: AC-004 uses 300 distinct non-gate docs files and is regression true; the stale counts and old AC references are cleaned. RED branch red/w1d-gate-authority-compare-r6 carries one tests-only commit c6d2560549926f0492da77bdcf448a8776906037 whose parent is e6fb6119; the branch diff against e6fb6119 is +211/-0. Isolated baseline 179 OK; at the RED 188 tests, 9 failure reports across 4 test methods, 0 errors." + ], + "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 55360719423009b1fe4da094220813c3acd87d01e630486f14c8411a8460aa3d (RED c6d2560549926f0492da77bdcf448a8776906037 on red/w1d-gate-authority-compare-r6).", + "approved_at": "2026-12-02T04:05:03Z", + "contract_sha256": "55360719423009b1fe4da094220813c3acd87d01e630486f14c8411a8460aa3d", + "test_collection": { + "manifest_sha256": "082dc53cfccb3b0f3f9eab82f2eb3561c828b8917c811813a2695aa5b1390b15", + "source_rev": "c6d2560549926f0492da77bdcf448a8776906037", + "collected": 188 + } + }, + "risk": { + "blast_radius": "The compare operand order in gate_authority_facts changes, and gate_authority_state gains a requirement that the trusted run's pull_requests[] entry base sha equals the current base tip. 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, unreadable, incomplete or malformed 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": "c6d2560549926f0492da77bdcf448a8776906037", + "supersedes": [], + "targets": [ + { + "base": "e6fb6119bba3fd7c6e200f8ad70f4931a3203f34", + "red": "c6d2560549926f0492da77bdcf448a8776906037", + "red_branch": "red/w1d-gate-authority-compare-r6", + "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..c793182 --- /dev/null +++ b/.rizzstack/leases/merge-lane-gate-authority-compare.json @@ -0,0 +1,47 @@ +{ + "branch": "feat/merge-lane-gate-authority-compare-r6", + "contract_id": "merge-lane-gate-authority-compare", + "contract_sha256": "55360719423009b1fe4da094220813c3acd87d01e630486f14c8411a8460aa3d", + "derived_from": { + "approved_at": "2026-12-02T04:05:03Z", + "approved_by": "Kyle: approved: merge-lane-gate-authority-compare 55360719423009b1fe4da094220813c3acd87d01e630486f14c8411a8460aa3d (RED c6d2560549926f0492da77bdcf448a8776906037 on red/w1d-gate-authority-compare-r6).", + "contract": ".rizzstack/contracts/55360719423009b1fe4da094220813c3acd87d01e630486f14c8411a8460aa3d.json" + }, + "id": "merge-lane-gate-authority-compare", + "lease_version": "rizzstack.lease/1", + "review": { + "approved_at": "2026-12-02T04:05:03Z", + "approved_by": "Kyle: approved: merge-lane-gate-authority-compare 55360719423009b1fe4da094220813c3acd87d01e630486f14c8411a8460aa3d (RED c6d2560549926f0492da77bdcf448a8776906037 on red/w1d-gate-authority-compare-r6).", + "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": "c6d2560549926f0492da77bdcf448a8776906037", + "verify_sha": "c6d2560549926f0492da77bdcf448a8776906037" +}