graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
pr: reserve review budget for test roots in mixed changes
justracha85c28ac5836
diff --git a/docs/adr/0133-publication-review-binds-committed-inputs.md b/docs/adr/0133-publication-review-binds-committed-inputs.mdindex cccfe755..4f0fec89 100644--- a/docs/adr/0133-publication-review-binds-committed-inputs.md+++ b/docs/adr/0133-publication-review-binds-committed-inputs.md@@ -18,12 +18,14 @@ readiness. Drafts remain available. No particular wording is required totrigger review.Changed files supply the proposed-head blob when it fits and a context diff-for prior lines; unchanged base blobs are not repeated. When a complete-proposed-head blob exceeds the individual or aggregate source budget, its-committed context diff remains available with an explicit omission marker.-The reviewer must return unresolved if the missing source is needed to assess-a claim. An oversized diff still blocks publication. Test entry points follow-committed package scripts and runner imports through a bounded chain. The+for prior lines; unchanged base blobs are not repeated. In mixed source and+documentation changes, documentation pages use marked context diffs to leave+room for committed test entry points. A complete proposed-head blob that+exceeds the individual or aggregate source budget likewise falls back to a+marked committed context diff. The reviewer must return unresolved if omitted+source is needed to assess a claim. An oversized diff still blocks publication.+Test entry points follow committed package scripts and runner imports through+a bounded chain. Thepacket names size and traversal limits when evidence is omitted. Successfullocal check receipts remain bounded and survive session restore, with theirobserved head and completion status; they are not immutable execution proof.diff --git a/src/pr_review_input.zig b/src/pr_review_input.zigindex 13b7bbd0..1686c5bf 100644--- a/src/pr_review_input.zig+++ b/src/pr_review_input.zig@@ -146,6 +146,14 @@ pub fn gather(gpa: A, io: std.Io, arena: A, cwd: []const u8, base: []const u8, hif (!evidence.validSha(base) or !evidence.validSha(head)) return error.InvalidCommit;if (body.len > max_bytes) return error.ReviewTooLarge;const names = try raw(gpa, io, arena, cwd, &.{ "git", "diff", "--no-ext-diff", "--no-renames", "--name-only", "-z", base, head, "--" });+ var has_source_change = false;+ var scan = std.mem.splitScalar(u8, names, 0);+ while (scan.next()) |path| {+ if (path.len > 0 and !std.mem.endsWith(u8, path, ".md")) {+ has_source_change = true;+ break;+ }+ }var paths = std.mem.splitScalar(u8, names, 0);var files: std.ArrayList(File) = .empty;var size = body.len;@@ -158,6 +166,9 @@ pub fn gather(gpa: A, io: std.Io, arena: A, cwd: []const u8, base: []const u8, hafter_omitted = true;break :blk null;};+ // In mixed changes, reserve room for source and test reachability+ // instead of repeating complete documentation pages.+ if (after != null and has_source_change and std.mem.endsWith(u8, path, ".md")) after_omitted = true;// A context diff carries the old lines; repeating the complete base// blob would charge unchanged source twice and crowd out test evidence.var change = try raw(gpa, io, arena, cwd, &.{ "git", "diff", "--no-ext-diff", "--no-renames", "--unified=3", base, head, "--", path });@@ -198,6 +209,10 @@ pub fn gather(gpa: A, io: std.Io, arena: A, cwd: []const u8, base: []const u8, htry support.package("");for ([_][]const u8{ "bunfig.toml", "vitest.config.ts", "vitest.config.js", "jest.config.js", "jest.config.ts", "playwright.config.ts", "pyproject.toml" }) |config|_ = try support.add(config);+ // Direct test roots matter more than broad workflow inventory when the+ // remaining support budget is tight.+ const coverage = [_][]const u8{ "build.zig", "src/main.zig", "package.json", "scripts/eval/tier1-manifest.json" };+ for (coverage) |path| _ = try support.add(path);const workflows = try raw(gpa, io, arena, cwd, &.{ "git", "ls-tree", "-r", "--name-only", "-z", head, "--", ".github/workflows" });var workflow_paths = std.mem.splitScalar(u8, workflows, 0);while (workflow_paths.next()) |path| {@@ -206,8 +221,6 @@ pub fn gather(gpa: A, io: std.Io, arena: A, cwd: []const u8, base: []const u8, htry support.runners("", text);for (support.packages.items) |dir| try support.runners(dir, text);}- const coverage = [_][]const u8{ "build.zig", "src/main.zig", "package.json", "scripts/eval/tier1-manifest.json" };- for (coverage) |path| _ = try support.add(path);return .{ .base = base, .head = head, .body = body, .files = files.items, .support_omitted = support.omitted, .support_limit = support.limit };}@@ -341,6 +354,57 @@ test "claim review uses committed context when changed head source exceeds the btry std.testing.expect(std.mem.indexOf(u8, single.files[0].change.?, "+yaaa") != null);}+test "mixed documentation changes leave room for committed test roots" {+ 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();+ const gpa = std.testing.allocator;+ var path: [std.fs.max_path_bytes]u8 = undefined;+ const cwd = path[0..try temp.dir.realPath(io, &path)];+ _ = try capture(gpa, io, a, cwd, &.{ "git", "init", "-q" });+ try temp.dir.createDirPath(io, "src");+ const docs = try a.alloc(u8, 60 * 1024);+ const source = try a.alloc(u8, 50 * 1024);+ @memset(docs, 'a');+ @memset(source, 'a');+ for (docs, 0..) |*byte, i| if (i % 80 == 79) {+ byte.* = '\n';+ };+ for (source, 0..) |*byte, i| if (i % 80 == 79) {+ byte.* = '\n';+ };+ docs[0] = 'x';+ source[0] = 'x';+ docs[docs.len - 1] = '\n';+ source[source.len - 1] = '\n';+ try temp.dir.writeFile(io, .{ .sub_path = "README.md", .data = docs });+ try temp.dir.writeFile(io, .{ .sub_path = "dispatch.zig", .data = source });+ try temp.dir.writeFile(io, .{ .sub_path = "src/main.zig", .data = source });+ _ = try capture(gpa, io, a, cwd, &.{ "git", "add", "." });+ _ = try capture(gpa, io, a, cwd, &.{ "git", "-c", "user.name=Fixture", "-c", "[email protected]", "-c", "commit.gpgsign=false", "commit", "-qm", "base" });+ const base = try capture(gpa, io, a, cwd, &.{ "git", "rev-parse", "HEAD" });+ docs[0] = 'y';+ source[0] = 'y';+ try temp.dir.writeFile(io, .{ .sub_path = "README.md", .data = docs });+ try temp.dir.writeFile(io, .{ .sub_path = "dispatch.zig", .data = source });+ _ = try capture(gpa, io, a, cwd, &.{ "git", "add", "." });+ _ = try capture(gpa, io, a, cwd, &.{ "git", "-c", "user.name=Fixture", "-c", "[email protected]", "-c", "commit.gpgsign=false", "commit", "-qm", "head" });+ const head = try capture(gpa, io, a, cwd, &.{ "git", "rev-parse", "HEAD" });+ const input = try gather(gpa, io, a, cwd, base, head, "claim");+ try std.testing.expectEqual(@as(usize, 3), input.files.len);+ try std.testing.expectEqualStrings("README.md", input.files[0].path);+ try std.testing.expect(input.files[0].after == null and input.files[0].after_omitted);+ try std.testing.expect(std.mem.indexOf(u8, input.files[0].change.?, "+yaaa") != null);+ try std.testing.expectEqual(@as(u8, 'y'), input.files[1].after.?[0]);+ try std.testing.expect(!input.files[1].after_omitted);+ try std.testing.expectEqualStrings("src/main.zig", input.files[2].path);+ try std.testing.expectEqual(@as(u8, 'x'), input.files[2].after.?[0]);+ try std.testing.expect(!input.support_omitted);+}+test "claim review includes unchanged callers that establish test reachability" {const io = std.testing.io;var temp = std.testing.tmpDir(.{});