graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Count local checks and unchanged callers in PR preflight
Cursor Agente9f3f8054cbb
diff --git a/src/pr_claim_review.zig b/src/pr_claim_review.zigindex 1b2d85e2..ba0e655e 100644--- a/src/pr_claim_review.zig+++ b/src/pr_claim_review.zig@@ -60,7 +60,8 @@ pub fn review(self: *Agent, target: evidence.Target, base_name: ?[]const u8, creif (!evidence.validSha(base)) return error.InvalidBase;const fork = try evidence.capture(self.gpa, self.io, self.arena, target, &.{ "git", "merge-base", base, head });const input = try inputs.gather(self.gpa, self.io, self.arena, target.cwd, fork, head, body);- const serialized = try std.json.Stringify.valueAlloc(self.arena, .{ .repository = repo, .base_tip = base, .input = input, .observed_local_checks = self.publication_checks.recent.items, .observed_head_ci = @tagName(ci) }, .{});+ const pr_checks = if (creating) "" else evidence.capture(self.gpa, self.io, self.arena, target, &.{ "gh", "pr", "checks", target.selector }) catch "";+ const serialized = try std.json.Stringify.valueAlloc(self.arena, .{ .repository = repo, .base_tip = base, .input = input, .observed_local_checks = self.publication_checks.recent.items, .observed_head_ci = @tagName(ci), .observed_pr_checks = pr_checks }, .{});var hash: [32]u8 = undefined;std.crypto.hash.sha2.Sha256.hash(serialized, &hash, .{});const key = std.fmt.bytesToHex(hash, .lower);@@ -96,7 +97,7 @@ pub fn review(self: *Agent, target: evidence.Target, base_name: ?[]const u8, cre,};defer judge.tools_used.deinit(self.gpa);- const packet = try std.json.Stringify.valueAlloc(self.arena, .{ .committed_inputs = serialized, .observed_local_checks = self.publication_checks.recent.items, .execution_limits = "head_after and tracked_tree_clean_after are post-run observations, not proof of immutable execution; missing history is unknown" }, .{});+ const packet = try std.json.Stringify.valueAlloc(self.arena, .{ .committed_inputs = serialized, .observed_local_checks = self.publication_checks.recent.items, .observed_pr_checks = pr_checks, .execution_limits = "head_after and tracked_tree_clean_after are post-run observations, not proof of immutable execution; missing history is unknown" }, .{});try judge.messages.append(try @import("messages.zig").textMessage(self.arena, "user", packet));const response = try judge.request(null);const result = try parse(self.arena, @import("title.zig").assistantText(self.provider.kind, response));diff --git a/src/pr_local_checks.zig b/src/pr_local_checks.zigindex bf76140b..b9680adc 100644--- a/src/pr_local_checks.zig+++ b/src/pr_local_checks.zig@@ -4,10 +4,19 @@ const Allocator = std.mem.Allocator;const ToolCall = @import("tools.zig").ToolCall;const ExecResult = @import("tools.zig").ExecResult;+fn checkTail(command: []const u8) []const u8 {+ var rest = std.mem.trim(u8, command, " \t\r\n");+ while (std.mem.startsWith(u8, rest, "cd ")) {+ const sep = std.mem.indexOf(u8, rest, "&&") orelse break;+ rest = std.mem.trimLeft(u8, rest[sep + 2 ..], " \t");+ }+ return rest;+}+pub fn isCheck(command: []const u8) bool {- var words = std.mem.tokenizeAny(u8, command, " \t\r\n");+ var words = std.mem.tokenizeAny(u8, checkTail(command), " \t\r\n");const executable = std.fs.path.basename(words.next() orelse return false);- if (std.mem.eql(u8, executable, "pytest")) return true;+ if (std.mem.eql(u8, executable, "pytest") or std.mem.startsWith(u8, executable, "eval-tier")) return true;const first = words.next() orelse return false;if (std.mem.eql(u8, executable, "python") or std.mem.eql(u8, executable, "python3")) {if (std.mem.eql(u8, first, "-m")) {@@ -167,6 +176,8 @@ test "observed failed check survives unrelated success and clears only on its sutest "check classification excludes prose and ordinary inspection" {try std.testing.expect(isCheck("python3 -m unittest test_delete -v"));try std.testing.expect(isCheck("zig build test"));+ try std.testing.expect(isCheck("cd apps/native && bun run test:desktop"));+ try std.testing.expect(isCheck("scripts/eval-tier1.sh --only reach"));try std.testing.expect(!isCheck("echo pytest failed"));try std.testing.expect(!isCheck("git diff"));}diff --git a/src/pr_review_input.zig b/src/pr_review_input.zigindex a1cf28e7..f6bfc020 100644--- a/src/pr_review_input.zig+++ b/src/pr_review_input.zig@@ -12,9 +12,9 @@ pub const Input = struct {head: []const u8,body: []const u8,files: []const File,- // Changed files alone may omit a dispatch caller or an existing test.- // A reviewer must report unresolved when these inputs do not establish it.- scope: []const u8 = "changed committed files; transitive coverage is not established",+ // Changed files plus unchanged callers/configuration that establish+ // how those files are reached by the repository's test runners.+ scope: []const u8 = "changed committed files plus unchanged callers/configuration that establish test reachability",};pub fn digest(arena: A, input: Input) ![64]u8 {const bytes = try std.json.Stringify.valueAlloc(arena, input, .{});@@ -69,6 +69,24 @@ pub fn gather(gpa: A, io: std.Io, arena: A, cwd: []const u8, base: []const u8, htry files.append(arena, .{ .path = path, .before = before, .after = after });}if (files.items.len == 0) return error.NoChangedFiles;+ const coverage = [_][]const u8{ "build.zig", "src/main.zig", "package.json", "scripts/eval/tier1-manifest.json" };+ for (coverage) |path| {+ if (files.items.len >= max_files) break;+ var present = false;+ for (files.items) |file| {+ if (std.mem.eql(u8, file.path, path)) {+ present = true;+ break;+ }+ }+ if (present) continue;+ const after = try blob(gpa, io, arena, cwd, head, path);+ if (after == null) continue;+ size += after.?.len;+ if (size > max_bytes) break;+ const before = try blob(gpa, io, arena, cwd, base, path);+ try files.append(arena, .{ .path = path, .before = before, .after = after });+ }return .{ .base = base, .head = head, .body = body, .files = files.items };}@@ -99,6 +117,34 @@ test "claim review reads committed blobs despite a repaired working tree" {try std.testing.expectEqualStrings(" broken dispatch\n\n", input.files[0].after.?);}+test "claim review includes unchanged callers that establish test reachability" {+ const io = std.testing.io;+ var temp = std.testing.tmpDir(.{});+ defer temp.cleanup();+ var scratch = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer scratch.deinit();+ const a = scratch.allocator();+ var path: [std.fs.max_path_bytes]u8 = undefined;+ const cwd = path[0..try temp.dir.realPath(io, &path)];+ _ = try capture(std.testing.allocator, io, a, cwd, &.{ "git", "init", "-q" });+ try temp.dir.writeFile(io, .{ .sub_path = "build.zig", .data = "test { }\n" });+ _ = try capture(std.testing.allocator, io, a, cwd, &.{ "git", "add", "build.zig" });+ _ = try capture(std.testing.allocator, io, a, cwd, &.{ "git", "-c", "user.name=Fixture", "-c", "[email protected]", "commit", "-qm", "base" });+ const base = try capture(std.testing.allocator, io, a, cwd, &.{ "git", "rev-parse", "HEAD" });+ try temp.dir.makePath(io, "src");+ try temp.dir.writeFile(io, .{ .sub_path = "src/dispatch.zig", .data = "pub fn run() void {}\n" });+ _ = try capture(std.testing.allocator, io, a, cwd, &.{ "git", "add", "src/dispatch.zig" });+ _ = try capture(std.testing.allocator, io, a, cwd, &.{ "git", "-c", "user.name=Fixture", "-c", "[email protected]", "commit", "-qm", "head" });+ const head = try capture(std.testing.allocator, io, a, cwd, &.{ "git", "rev-parse", "HEAD" });+ const input = try gather(std.testing.allocator, io, a, cwd, base, head, "claim");+ var saw_caller = false;+ for (input.files) |file| {+ if (std.mem.eql(u8, file.path, "build.zig")) saw_caller = true;+ }+ try std.testing.expect(saw_caller);+ try std.testing.expect(std.mem.indexOf(u8, input.scope, "unchanged callers") != null);+}+test "claim review digest invalidates changed body head and committed source" {var arena = std.heap.ArenaAllocator.init(std.testing.allocator);defer arena.deinit();