Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
{
"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, a non-list 'files' value and a list of 300 distinct non-gate files (docs/f000.md ... docs/f299.md, status modified) both return gate_authority_stale_gate, so the limit, not the gate-path branch, is what refuses.",
"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, even when the gated head contains both commits. 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"
],
"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.",
"Owner correction for r5 (2026-12-02): AC-004's 300 entries are now 300 distinct non-gate files, so the test exercises GATE_AUTHORITY_COMPARE_LIMIT and not the gate-path branch; AC-004 is marked regression true because the limit and non-list refusal are on main since #49 and it fails at the RED only because of the compare direction; the stale '185 tests, 3 failures' figure is removed and the old AC references are renumbered (error flag AC-006, equal-SHA AC-007)."
],
"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 7d322b2e4f7fb6890c9a9bc4c17565aaa902299c0a928b490fac2cf14b05b379 (RED 2cf03fd224850b5819fbc9e29025c4e185c8eba8 on red/w1d-gate-authority-compare-r5).",
"approved_at": "2026-12-02T03:56:23Z",
"contract_sha256": "7d322b2e4f7fb6890c9a9bc4c17565aaa902299c0a928b490fac2cf14b05b379",
"test_collection": {
"manifest_sha256": "e7b94b6b286fa2ec75d22003e24ba244ecbe9cfdceb512d583be51a326759d9a",
"source_rev": "2cf03fd224850b5819fbc9e29025c4e185c8eba8",
"collected": 187
}
},
"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": "2cf03fd224850b5819fbc9e29025c4e185c8eba8",
"supersedes": [],
"targets": [
{
"base": "e6fb6119bba3fd7c6e200f8ad70f4931a3203f34",
"red": "2cf03fd224850b5819fbc9e29025c4e185c8eba8",
"red_branch": "red/w1d-gate-authority-compare-r5",
"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
}
}
47 changes: 47 additions & 0 deletions .rizzstack/leases/merge-lane-gate-authority-compare.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"branch": "feat/merge-lane-gate-authority-compare-r5",
"contract_id": "merge-lane-gate-authority-compare",
"contract_sha256": "7d322b2e4f7fb6890c9a9bc4c17565aaa902299c0a928b490fac2cf14b05b379",
"derived_from": {
"approved_at": "2026-12-02T03:56:23Z",
"approved_by": "Kyle: approved: merge-lane-gate-authority-compare 7d322b2e4f7fb6890c9a9bc4c17565aaa902299c0a928b490fac2cf14b05b379 (RED 2cf03fd224850b5819fbc9e29025c4e185c8eba8 on red/w1d-gate-authority-compare-r5).",
"contract": ".rizzstack/contracts/7d322b2e4f7fb6890c9a9bc4c17565aaa902299c0a928b490fac2cf14b05b379.json"
},
"id": "merge-lane-gate-authority-compare",
"lease_version": "rizzstack.lease/1",
"review": {
"approved_at": "2026-12-02T03:56:23Z",
"approved_by": "Kyle: approved: merge-lane-gate-authority-compare 7d322b2e4f7fb6890c9a9bc4c17565aaa902299c0a928b490fac2cf14b05b379 (RED 2cf03fd224850b5819fbc9e29025c4e185c8eba8 on red/w1d-gate-authority-compare-r5).",
"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": "2cf03fd224850b5819fbc9e29025c4e185c8eba8",
"verify_sha": "2cf03fd224850b5819fbc9e29025c4e185c8eba8"
}
Loading