Repository navigation
lease(merge-lane-gate-authority-compare): frozen contract 7ac505af + lease - #83
Closed
rizzstack-coordinator[bot] wants to merge 1 commit into
Closed
rizzstack-coordinator[bot] wants to merge 1 commit into
rizzstack-coordinator[bot] wants to merge 1 commit into
Conversation
Contributor
Author
|
Superseded before merge by the re-cut for the host r1 findings. Contract 7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692 is withdrawn; the r2 RED head is cfee5cd and the new contract is a2ce4269af29bd0999a8329b639ef165baf76fd6dc9c4443857d0f54b1d8b692 (owner hash approval pending). Branch kept; nothing merged. |
This was referenced Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lease PR for the W1D merge-lane fix. Two files only: the frozen contract and its lease.
Facts
mojomast/rizzstack. Base:e6fb6119bba3fd7c6e200f8ad70f4931a3203f34(current main).merge-lane-gate-authority-compare, sha2567ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692.review.approved_by):Kyle: approved: merge-lane-gate-authority-compare 7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692 (RED eaa85519aa3f4a0e1e6848e538812272fb97590c on red/w1d-gate-authority-compare).eaa85519aa3f4a0e1e6848e538812272fb97590conred/w1d-gate-authority-compare, parente6fb6119(verified), tests-only (+171/-0 intests/test_merge_lane_v5.py).feat/merge-lane-gate-authority-compare.Defect and fix
gate_authority_factscallsfetch_compare(repo_slug, head_sha, base_tip);fetch_compare's parameters are(older, newer), andgate_authority_stateaccepts onlyahead/identical. For a trustedpull_request_targetrun whosehead_shais the pull-request head and whose base is an ancestor of that head, GitHub answersbehind, so the lane refusesgate_authority_wrong_base.Live evidence, run
46787387514at PR #73 head0c4362f85976229fdae066f33d0b420a226b0468, basee6fb6119(both from the API):compare/0c4362f8...e6fb6119=behind(ahead_by 0,behind_by 8);compare/e6fb6119...0c4362f8=ahead(ahead_by 8).Fix: compare
base_tip...run.head_sha, acceptingaheadoridentical.diverged,behindand an unreadable compare still refuse. The file list of the compare is the same changed-file set, so the gate-code staleness check is unchanged. Not in scope: accepting an older ancestor base with an identical diff (separate later card).RED evidence
git show --stat eaa85519:Isolated run at the RED (empty HOME and XDG dirs):
Ran 184 tests in 2.667s,FAILED (failures=2); the two failures are the AC-001 cases (test_a_gate_run_at_the_head_is_proven_against_an_ancestor_base,test_the_compare_is_directed_from_the_base_tip_to_the_gated_head). Isolated run at the basee6fb6119:Ran 179 tests in 2.858s,OK. Additive: +5 tests, no existing test changed.hermes bundlebees tdd red:classification: behavioral_failure,red: valid.hermes bundlebees contract freeze:tests collected: 184 ids at source_rev, every AC reference resolved; recordedtest_collection.manifest_sha2563642c968c25cffa57ff5f7b8bfd9dc0ffb3871744fc79f74a19d2cb727618e61atsource_rev eaa85519. The collector's manifest digest is not stable across repeated freeze runs on this host (three runs, same 184 ids, three digests); the count andsource_revare stable and are the numbers asserted here. Filed as a separate defect card, not changed by this slice.Full diff of the RED commit (tests only)
commit eaa85519aa3f4a0e1e6848e538812272fb97590c Author: Hermes (coordinator) <hermes@localhost> Date: Tue Dec 1 21:04:29 2026 -0500 test(merge-lane): W1d RED - prove the gate run from the base tip to the gated head diff --git a/tests/test_merge_lane_v5.py b/tests/test_merge_lane_v5.py index cfc39e4..b0558d8 100644 --- a/tests/test_merge_lane_v5.py +++ b/tests/test_merge_lane_v5.py @@ -2102,5 +2102,176 @@ class GateLookupHardeningTests(unittest.TestCase): self.assertTrue(out["gate_authority"]["head_check_present"]) +class GateAuthorityCompareDirectionTests(unittest.TestCase): + """W1d: the gated head must contain the current base tip. + + The trusted ``pull_request_target`` run's ``head_sha`` is the pull-request + head, not a base commit. Proving that the run judged the current base + therefore means comparing ``base_tip...run.head_sha``: ``ahead`` says the + gated head contains the base tip, ``identical`` says it is the tip. The + reverse compare reports ``behind`` for every normal PR whose branch has + moved past the base, which is the shape that refused rizzstack#73 while its + gate run was green and pinned to exactly the current main. + """ + + REPO = "mojomast/rizzstack" + SUITE = 111 + RUN_ID = 9 + PR = 73 + WORKFLOW = ".github/workflows/gate-authority.yml" + + def base(self): + return "c" * 40 + + def head(self): + return "a" * 40 + + def workflow_run(self): + head = self.head() + base = self.base() + return { + "id": self.RUN_ID, + "check_suite_id": self.SUITE, + "path": self.WORKFLOW, + "event": "pull_request_target", + "head_sha": head, + "status": "completed", + "conclusion": "success", + "created_at": "2026-12-02T01:30:38Z", + "run_started_at": "2026-12-02T01:30:36Z", + "pull_requests": [ + { + "number": self.PR, + "head": {"sha": head}, + "base": {"ref": "main", "sha": base}, + } + ], + "repository": {"full_name": self.REPO}, + "head_repository": {"full_name": self.REPO}, + } + + def pr(self): + return { + "number": self.PR, + "head": {"sha": self.head()}, + "base": {"ref": "main", "sha": self.base()}, + } + + def facts(self, base_status="ahead", head_status="behind", compare_error=None): + """Drive gate_authority_facts through a GitHub double in both directions. + + The base-first key is the direction the fix must request; the head-first + key reproduces GitHub's real answer for the reversed direction, so the + old code reaches a measured ``behind`` instead of an unreadable fact. + """ + head = self.head() + base = self.base() + responses = { + "git/ref/heads/main": {"object": {"sha": base}}, + "check-suites/%d" % self.SUITE: {"app": {"slug": "github-actions"}}, + "compare/%s...%s" % (base, head): ( + compare_error + if compare_error is not None + else { + "status": base_status, + "files": [{"filename": "scripts/merge_lane_v5.py", "status": "modified"}], + } + ), + "compare/%s...%s" % (head, base): ( + compare_error + if compare_error is not None + else {"status": head_status, "files": []} + ), + } + api = _FakeApi(responses) + out = lane.gate_authority_facts( + self.REPO, + self.PR, + self.pr(), + [self.workflow_run()], + "test-token", + api_url="https://api.test", + http=api, + demanded=True, + ) + return out, api + + def comparable(self, compare_status): + head = self.head() + base = self.base() + return { + "demanded": True, + "error": False, + "number": self.PR, + "repo": self.REPO, + "base_ref": "main", + "base_tip": base, + "head_check_present": False, + "runs": [ + { + "id": self.RUN_ID, + "path": self.WORKFLOW, + "event": "pull_request_target", + "status": "completed", + "conclusion": "success", + "head_sha": head, + "created_at": "2026-12-02T01:30:38Z", + "run_started_at": "2026-12-02T01:30:36Z", + "pull_requests": [ + { + "number": self.PR, + "head": {"sha": head}, + "base": {"ref": "main", "sha": base}, + } + ], + "repository": {"full_name": self.REPO}, + "head_repository": {"full_name": self.REPO}, + "app": "github-actions", + "compare_status": compare_status, + "compare_files_present": True, + "compare_files": [], + } + ], + } + + def test_a_gate_run_at_the_head_is_proven_against_an_ancestor_base(self): + """The #73 shape: run head == PR head, base an ancestor, all green.""" + facts, _api = self.facts() + self.assertEqual( + lane.gate_authority_state(facts, self.head(), []), + (True, None, self.RUN_ID), + ) + + def test_the_compare_is_directed_from_the_base_tip_to_the_gated_head(self): + """The lane must ask GitHub for base_tip...head, not head...base_tip.""" + _facts, api = self.facts() + compares = [url for url in api.calls if "/compare/" in url] + self.assertEqual(len(compares), 1) + self.assertIn("compare/%s...%s" % (self.base(), self.head()), compares[0]) + + def test_a_base_that_moved_past_the_gated_head_is_refused(self): + """A base the gated head does not contain is still a wrong base.""" + facts, _api = self.facts(base_status="diverged", head_status="diverged") + self.assertEqual( + lane.gate_authority_state(facts, self.head(), []), + (False, "gate_authority_wrong_base", self.RUN_ID), + ) + + def test_an_unreadable_compare_refuses(self): + """An unreadable compare is unproven, never a pass.""" + facts, _api = self.facts(compare_error=lane.FetchError("compare unavailable")) + self.assertEqual( + lane.gate_authority_state(facts, self.head(), []), + (False, "gate_authority_unproven", None), + ) + + def test_an_identical_compare_is_accepted(self): + """A run whose head is the base tip is proven (identical).""" + self.assertEqual( + lane.gate_authority_state(self.comparable("identical"), self.head(), []), + (True, None, self.RUN_ID), + ) + + if __name__ == "__main__": unittest.main()Chain and scope
This is the first contract for this defect:
supersedes: []; no predecessor contract exists. The lease'sscopeandsource_revare the contract's verbatim scope: assignedscripts/merge_lane_v5.py; teststests/test_merge_lane_v5.py; prohibited.github/**,policy/**,.rizzstack/**,docs/**, the preauth/lane siblings; read-onlytests/test_lease_tamper.py,.github/scripts/lease_tamper.py,tests/fixtures/**.