Skip to content

lease(merge-lane-gate-authority-compare): frozen contract a2ce4269 (r2) + lease - #84

Closed
rizzstack-coordinator[bot] wants to merge 1 commit into
mainfrom
lease/merge-lane-gate-authority-compare-r2
Closed

rizzstack-coordinator[bot] wants to merge 1 commit into
mainfrom
lease/merge-lane-gate-authority-compare-r2

Conversation

@rizzstack-coordinator

Copy link
Copy Markdown
Contributor

Lease PR (r2) for the W1D merge-lane fix. Two files only: the frozen contract and its lease.

Facts

  • Repo mojomast/rizzstack. Base e6fb6119bba3fd7c6e200f8ad70f4931a3203f34.
  • Contract merge-lane-gate-authority-compare, sha256 a2ce4269af29bd0999a8329b639ef165baf76fd6dc9c4443857d0f54b1d8b692.
  • Owner approval line (verbatim, in the contract's review.approved_by): Kyle: approved: merge-lane-gate-authority-compare a2ce4269af29bd0999a8329b639ef165baf76fd6dc9c4443857d0f54b1d8b692 (RED cfee5cdeb3e10b2112d2445b168ab4cda75b419f on red/w1d-gate-authority-compare).
  • RED red/w1d-gate-authority-compare head cfee5cdeb3e10b2112d2445b168ab4cda75b419f, two tests-only commits, parent e6fb6119, +172/-0 in tests/test_merge_lane_v5.py against the base.
  • Lease branch named for implementation: feat/merge-lane-gate-authority-compare-r2.

The r1 findings and how r2 fixes them

  1. The file list is not preserved under a compare reversal. Correct. The base-first compare lists the merge-base-to-gated-head diff (the PR's own change set when the base is an ancestor); the old head-first direction returns an empty list in the accepted shape. The contract claim is corrected, and AC-002 now drives a .github/scripts/lease_tamper.py entry through the facts and requires gate_authority_stale_gate.
  2. Three ACs underchecked. AC-003 now exercises both diverged and behind. AC-004 asserts error true and compare_status None as well as the unproven refusal. AC-005 drives an equal head/base SHA (d*40) through gate_authority_facts with an identical compare.

Evidence

Isolated empty HOME and XDG dirs:

  • base e6fb6119: Ran 179 tests, OK.
  • RED cfee5cde: Ran 185 tests in 2.690s, FAILED (failures=3) — the two AC-001 cases and the AC-002 gate-path case; 0 errors.

hermes bundlebees tdd red: behavioral_failure, red: valid.
hermes bundlebees contract freeze: tests collected: 185 ids at source_rev, every AC reference resolved.
Slice dry run: lease-tamper: OK ... class=slice TIER=T3 (tier from existing_test_edit), dry run: class=slice OK.

The r2 RED commit (delta the host asked for)

cfee5cd test(merge-lane): W1d RED r2 - equal-SHA, gate-path and unreadable-compare cases
 tests/test_merge_lane_v5.py | 93 +++++++++++++++++++++++----------------------
 1 file changed, 47 insertions(+), 46 deletions(-)

Chain

The first contract 7ac505af4c4722d2b36566be902a34aeb448276d85e100c7a444bfa3e4773692 was never merged; its lease PR #83 is closed as superseded and its branch is kept. supersedes is empty because a predecessor that never reached the base can never resolve in the gate; the withdrawn hash is named in the contract notes and here. This is the contract intended to land.

commit cfee5cdeb3e10b2112d2445b168ab4cda75b419f
Author: Hermes (coordinator) <hermes@localhost>
Date:   Tue Dec 1 21:29:10 2026 -0500

    test(merge-lane): W1d RED r2 - equal-SHA, gate-path and unreadable-compare cases

diff --git a/tests/test_merge_lane_v5.py b/tests/test_merge_lane_v5.py
index b0558d8..92a305c 100644
--- a/tests/test_merge_lane_v5.py
+++ b/tests/test_merge_lane_v5.py
@@ -2157,7 +2157,8 @@ class GateAuthorityCompareDirectionTests(unittest.TestCase):
             "base": {"ref": "main", "sha": self.base()},
         }
 
-    def facts(self, base_status="ahead", head_status="behind", compare_error=None):
+    def facts(self, base_status="ahead", head_status="behind", compare_error=None,
+              compare_files=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
@@ -2174,7 +2175,9 @@ class GateAuthorityCompareDirectionTests(unittest.TestCase):
                 if compare_error is not None
                 else {
                     "status": base_status,
-                    "files": [{"filename": "scripts/merge_lane_v5.py", "status": "modified"}],
+                    "files": compare_files
+                    if compare_files is not None
+                    else [{"filename": "scripts/merge_lane_v5.py", "status": "modified"}],
                 }
             ),
             "compare/%s...%s" % (head, base): (
@@ -2196,43 +2199,24 @@ class GateAuthorityCompareDirectionTests(unittest.TestCase):
         )
         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 identical_facts(self):
+        """The equal-SHA case: the run's head is the base tip itself."""
+        sha = "d" * 40
+        run = self.workflow_run()
+        run["head_sha"] = sha
+        run["pull_requests"][0]["head"]["sha"] = sha
+        run["pull_requests"][0]["base"]["sha"] = sha
+        pr = {"number": self.PR, "head": {"sha": sha}, "base": {"ref": "main", "sha": sha}}
+        api = _FakeApi({
+            "git/ref/heads/main": {"object": {"sha": sha}},
+            "check-suites/%d" % self.SUITE: {"app": {"slug": "github-actions"}},
+            "compare/%s...%s" % (sha, sha): {"status": "identical", "files": []},
+        })
+        out = lane.gate_authority_facts(
+            self.REPO, self.PR, pr, [run], "test-token",
+            api_url="https://api.test", http=api, demanded=True,
+        )
+        return out, api
 
     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."""
@@ -2249,26 +2233,43 @@ class GateAuthorityCompareDirectionTests(unittest.TestCase):
         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")
+    def test_a_changed_gate_path_in_the_compare_still_refuses(self):
+        """The base-first compare's file list still feeds the gate-code check."""
+        facts, _api = self.facts(
+            compare_files=[{"filename": ".github/scripts/lease_tamper.py", "status": "modified"}]
+        )
         self.assertEqual(
             lane.gate_authority_state(facts, self.head(), []),
-            (False, "gate_authority_wrong_base", self.RUN_ID),
+            (False, "gate_authority_stale_gate", self.RUN_ID),
         )
 
+    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."""
+        for status in ("diverged", "behind"):
+            with self.subTest(status=status):
+                facts, _api = self.facts(base_status=status, head_status=status)
+                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."""
+        """An unreadable compare is flagged unreadable and refused as unproven."""
         facts, _api = self.facts(compare_error=lane.FetchError("compare unavailable"))
+        self.assertTrue(facts["error"])
+        self.assertIsNone(facts["runs"][0]["compare_status"])
         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)."""
+        """A run whose head is the base tip is proven (equal SHA, identical)."""
+        facts, api = self.identical_facts()
+        sha = "d" * 40
+        self.assertIn("compare/%s...%s" % (sha, sha), " ".join(api.calls))
         self.assertEqual(
-            lane.gate_authority_state(self.comparable("identical"), self.head(), []),
+            lane.gate_authority_state(facts, sha, []),
             (True, None, self.RUN_ID),
         )

@rizzstack-coordinator

Copy link
Copy Markdown
Contributor Author

Superseded by the r3 cut for host r1: the r2 RED head had two commits (its direct parent was not the declared base) and AC-002 covered only a gate script. New RED red/w1d-gate-authority-compare-r2 @ 5246de7 (one commit, parent e6fb611, +174/-0) and new contract feb3863e7940fcb195815d2c3ff2a1140ce3b092d76d693995245fa7c9f94131 (owner approval pending). Branch kept; nothing merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants