graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
PR create proceeds while the head's CI run is in flight (#1189)
justrach2bd1909841d2
diff --git a/scripts/regression-release-297.py b/scripts/regression-release-297.pyindex 0fac97b6..59a03c7b 100644--- a/scripts/regression-release-297.py+++ b/scripts/regression-release-297.py@@ -252,8 +252,10 @@ def main():handoff(args.graff)stream_and_mcp(args.graff)create = "gh pr create --title fixture --body-file notes.md"- for bad in ({"runs": "failure"}, {"runs": "pending"}, {"unavailable": True}, {"runs": "malformed"}):+ for bad in ({"runs": "failure"}, {"unavailable": True}, {"runs": "malformed"}):run_case(args.graff, f"non-draft refuses {bad}", [tool(create), {"text": "Publication blocked."}], bad)+ # #1189: the push started the head's runs; create proceeds, completion still waits.+ run_case(args.graff, "non-draft create proceeds while the head run is pending", [tool(create), completion(), {"text": "CI is still running."}], {"runs": "pending"}, expected_mutations=1, refused=1, review=True)run_case(args.graff, "body flag cannot turn non-draft into draft", [tool("gh pr create --title fixture --body '--draft'"), {"text": "Blocked."}], {"runs": "failure"})run_case(args.graff, "local-only and repeated completion cannot pass PR CI", [tool(create), completion(), completion(), {"text": "CI remains unverified."}], {"runs": "none"}, expected_mutations=1, refused=2, resume_check=True, review=True)run_case(args.graff, "fresh passing remote head completes", [tool(create), completion()], {"checks": "SUCCESS"}, expected_mutations=1, expected_final="Verification complete.", review=True)diff --git a/src/pr_publish.zig b/src/pr_publish.zigindex 347e2125..482653e5 100644--- a/src/pr_publish.zig+++ b/src/pr_publish.zig@@ -21,6 +21,10 @@ pub const Evidence = struct {known_failures_disclosed: bool = false,body: []const u8 = "",coverage: Coverage = .{},+ /// `gh pr create`: the push that preceded it started the head's runs, so a+ /// pending run is evidence not yet arrived, not a failure (#1189). The+ /// verification obligation armed at publication still gates completion.+ creating: bool = false,};pub const Decision = enum { allow, block, draft_only };@@ -196,7 +200,11 @@ pub fn decide(draft: bool, ev: Evidence) Decision {if (claimOverreach(ev.body, ev.coverage)) return .block;if (!hasVerificationSection(ev.body)) return .block;return switch (ev.head_status) {- .pending, .failed => if (ev.base_reproduced and (ev.known_failures_disclosed or knownFailuresDisclosed(ev.body)))+ .pending => if (ev.creating) .allow else if (ev.base_reproduced and (ev.known_failures_disclosed or knownFailuresDisclosed(ev.body)))+ .draft_only+ else+ .block,+ .failed => if (ev.base_reproduced and (ev.known_failures_disclosed or knownFailuresDisclosed(ev.body))).draft_onlyelse.block,@@ -320,6 +328,11 @@ test "#847 failed or pending head blocks non-draft create" {const body = "## Verification\nlocal: `zig build test` (pass)\nremote: pending";try std.testing.expectEqual(Decision.block, decide(false, .{ .head_status = .failed, .body = body }));try std.testing.expectEqual(Decision.block, decide(false, .{ .head_status = .pending, .body = body }));+ // #1189: creating right after the push that started the runs is allowed;+ // completion still waits for them. Failed and unreadable evidence still block.+ try std.testing.expectEqual(Decision.allow, decide(false, .{ .head_status = .pending, .body = body, .creating = true }));+ try std.testing.expectEqual(Decision.block, decide(false, .{ .head_status = .failed, .body = body, .creating = true }));+ try std.testing.expectEqual(Decision.block, decide(false, .{ .head_status = .unknown, .body = body, .creating = true }));try std.testing.expectEqual(Decision.allow, decide(true, .{ .head_status = .failed, .body = body }));try std.testing.expectEqual(Decision.allow, decide(false, .{ .head_status = .passed, .body = body }));}diff --git a/src/publish_gate.zig b/src/publish_gate.zigindex a11699c9..03c68e50 100644--- a/src/publish_gate.zig+++ b/src/publish_gate.zig@@ -31,6 +31,7 @@ fn observe(self: *Agent, cmd: []const u8) !?ExecResult {if (self.publication_checks.unresolved(try @import("pr_local_checks.zig").repositoryRoot(self, target.cwd))) |command_text|return .{ .text = try std.fmt.allocPrint(self.arena, "PR publication preflight: observed local check has no successful completion: {s}. Rerun it successfully or publish a draft; write NOT performed.", .{command_text}), .is_error = true };if (creating) {+ ev.creating = true;ev.head_sha = evmod.localHead(self.gpa, self.io, self.arena, target) catch "";// An explicit alternate head must be resolved independently of HEAD.if (command.flag("--head", "-H")) |head| {@@ -49,7 +50,8 @@ fn observe(self: *Agent, cmd: []const u8) !?ExecResult {ev = .{ .head_sha = receipt.head, .head_status = receipt.status, .body = receipt.body };}}- if (!draft and ev.head_status == .pending) {+ // A create proceeds while the head's runs are in flight (#1189); ready waits.+ if (!draft and !creating and ev.head_status == .pending) {var poll: PendingPoll = .{ .agent = self, .target = target, .creating = creating, .alternate_head = command.flag("--head", "-H"), .initial = ev, .started = std.Io.Timestamp.now(self.io, .awake) };ev = waitPending(&poll, ev) catch |err| return .{.text = if (err == error.Interrupted) "PR publication preflight: waiting for CI was cancelled; write NOT performed." else "PR publication preflight: the head changed or readiness could not be refreshed while waiting; write NOT performed.",