Skip to content
Merged
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
10 changes: 10 additions & 0 deletions .github/ci/delivery-cutover.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ final trees. A singleton, reset, duplicate/full fallback or uncertain result is
not efficiency acceptance. Other files, dependencies and old full-only queues
retain their original full checks; this is not an arbitrary-lane fast path.

## Source-event description updates

Unrelated description prose may differ between the triggering source event and
the live PR, for example when a summary is appended before CI starts. Both
descriptions must independently contain the unique supported shadow/delivery
opt-ins and neither may declare a dependency. Every other snapshot field and
all Git/fast provenance checks remain exact. Later live rereads still compare
the complete body strictly; this does not ignore changes during verification,
trust an editing actor, grant queue authority or widen eligible files/actions.

## Exact-head local review receipts

This is an **alternative review contract**, not activation or merge
Expand Down
7 changes: 6 additions & 1 deletion .github/ci/delivery_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ def source(env, event, root, main, request, base_changes):
require(event["action"] in {"opened", "synchronize", "reopened"}, "Unsupported PR event")
number = evidence.positive(event["number"])
pr = request(REPOSITORY, f"pulls/{number}")
require(policy.snapshot(pr) == policy.snapshot(event["pull_request"])
expected = event["pull_request"]
# Prose may change before routing. Validate both decisions independently;
# retain every other snapshot field and the strict subsequent live rereads.
require(verifier.delivery_intended(expected.get("body"))
and not re.search(r"(?m)^Depends-On:", expected["body"])
and policy.snapshot(dict(pr, body=expected["body"])) == policy.snapshot(expected)
and pr["state"] == "open" and pr["draft"] is False
and pr["number"] == number and verifier.delivery_intended(pr["body"])
and not re.search(r"(?m)^Depends-On:", pr["body"]), "Source is not opted-in/current")
Expand Down
73 changes: 73 additions & 0 deletions tests/test_ci_cutover.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,79 @@
assert "queue_admission" not in result


@pytest.mark.parametrize("side", ["event", "live"])
@pytest.mark.parametrize("prose", ["prefix", "suffix", "replace"])
def test_ci_cutover_source_description_prose_preserves_decision(cutover, batch, side, prose):
env, event = source_fixture(cutover, batch)
expected = route_fixture(cutover, batch, env, event)
assert expected["mode"] == "source" and expected["omit_full"] is True

Check warning on line 137 in tests/test_ci_cutover.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this composite assertion into separate assertions.

See more on https://sonarcloud.io/project/issues?id=opensoft_openRepoTools-code&issues=AaHVeqAYbHm0dhBzQisU&open=AaHVeqAYbHm0dhBzQisU&pullRequest=59
pr = event["pull_request"] if side == "event" else batch["prs"][7]
if prose == "prefix":
pr["body"] = "Explanatory prose.\n\n" + pr["body"]
elif prose == "suffix":
pr["body"] += "\n\n## Summary by Sourcery\n\nHelp summary."
else:
pr["body"] = "Revised prose.\nCI-Shadow: claude-current\nCI-Delivery: claude-current"
assert route_fixture(cutover, batch, env, event) == expected


@pytest.mark.parametrize("side", ["event", "live"])
@pytest.mark.parametrize("change", ["missing-shadow", "duplicate-shadow", "wrong-shadow",
"missing-delivery", "duplicate-delivery", "wrong-delivery", "dependency", "non-string"])
def test_ci_cutover_source_description_decision_drift_is_full(cutover, batch, side, change):
env, event = source_fixture(cutover, batch)
pr = event["pull_request"] if side == "event" else batch["prs"][7]
marker = "CI-Shadow: claude-current" if change.endswith("shadow") else "CI-Delivery: claude-current"
if change.startswith("missing"):
pr["body"] = pr["body"].replace(marker, "")
elif change.startswith("duplicate"):
pr["body"] += "\n" + marker
elif change.startswith("wrong"):
pr["body"] = pr["body"].replace(marker, marker.replace("claude-current", "other"))
elif change == "dependency":
pr["body"] += "\nDepends-On: #123"
else:
pr["body"] = None
assert route_fixture(cutover, batch, env, event) == cutover.FULL


@pytest.mark.parametrize("side", ["event", "live"])
@pytest.mark.parametrize("field", ["state", "draft", "merged", "author", "head-sha",
"head-ref", "base-sha", "base-ref", "merge-sha"])
def test_ci_cutover_source_prose_does_not_relax_other_metadata(cutover, batch, side, field):
env, event = source_fixture(cutover, batch)
pr = event["pull_request"] if side == "event" else batch["prs"][7]
pr["body"] += "\nUnrelated summary."
if field == "state":
pr["state"] = "closed"
elif field in {"draft", "merged"}:
pr[field] = True
elif field == "author":
pr["user"]["login"] = "other-author"
elif field == "merge-sha":
pr["merge_commit_sha"] = "f" * 40
else:
name, part = field.split("-")
pr[name][part] = "f" * 40 if part == "sha" else "other-ref"
assert route_fixture(cutover, batch, env, event) == cutover.FULL


def test_ci_cutover_source_description_live_reread_stays_strict(cutover, batch):
env, event = source_fixture(cutover, batch)
original = request_for(batch)
reads = 0
def request(repo, endpoint):
nonlocal reads
if endpoint == "pulls/7":
reads += 1
if reads == 2:
batch["prs"][7]["body"] += "\nLive summary race."
return original(repo, endpoint)
assert cutover.route(env, event, batch["root"], request,
threads=lambda number: threads(number, batch), base_changes=base_changes) == cutover.FULL
assert reads >= 2


@pytest.mark.parametrize("failure", ["old-rules", "no-new-rule", "wrong-app", "reusable", "manual",
"nightly", "release", "foreign-run", "rerun-mismatch", "run-head", "no-opt-in", "duplicate-intent",
"draft", "base", "event-head", "test-merge", "fast-failed", "retarget", "api-error", "rules-race"])
Expand Down
Loading