graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Preserve bounded evidence for PR claim review
Rach Pradhane8f2b92e03c9
diff --git a/docs/adr/0133-publication-review-binds-committed-inputs.md b/docs/adr/0133-publication-review-binds-committed-inputs.mdindex 7c6e897a..9bcf878d 100644--- a/docs/adr/0133-publication-review-binds-committed-inputs.md+++ b/docs/adr/0133-publication-review-binds-committed-inputs.md@@ -16,6 +16,13 @@ identified check observations. Missing, oversized or unsupported inputs andunresolved or malformed review results do not establish readiness. Draftsremain available. No particular wording is required to trigger review.+Changed files supply the proposed-head blob and a context diff for prior lines;+unchanged base blobs are not repeated. Test entry points follow committed+package scripts and runner imports through a bounded chain. The packet names+size and traversal limits when evidence is omitted. Successful local check+receipts remain bounded and survive session restore, with their observed head+and completion status; they are not immutable execution proof.+The review supplements actual tests and fresh CI observations. It is not amechanical coverage certificate. Changed files may omit important callers;the reviewer must retain uncertainty rather than invent those paths. A checkdiff --git a/scripts/test-pr-claim-review.py b/scripts/test-pr-claim-review.pyindex d787b955..be8ae648 100644--- a/scripts/test-pr-claim-review.py+++ b/scripts/test-pr-claim-review.py@@ -136,6 +136,9 @@ Remote: passed.if not args.budget_exhausted:review_request=json.dumps(model.requests[2])assert 'changed committed files' in review_request and 'delete_word' in review_request and 'test_helper.py' in review_request+ observed=json.loads(model.requests[2]['messages'][-1]['content'])['observed_local_checks']+ assert len(observed)==1 and observed[0]['command']=='python3 -m unittest test_helper -v'+ assert observed[0]['completed'] and not observed[0]['failed'] and 'Ran 1 test' in observed[0]['output']if args.repo or args.url:assert 'https://github.com/fixture/alternate' in review_requestelse:diff --git a/src/pr_claim_review.zig b/src/pr_claim_review.zigindex ba0e655e..22c81a8d 100644--- a/src/pr_claim_review.zig+++ b/src/pr_claim_review.zig@@ -61,9 +61,23 @@ pub fn review(self: *Agent, target: evidence.Target, base_name: ?[]const u8, creconst 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 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 local: std.ArrayList(@import("pr_local_checks.zig").State.Receipt) = .empty;+ const repository = try @import("pr_local_checks.zig").repositoryRoot(self, target.cwd);+ for (self.publication_checks.recent.items) |receipt| {+ if (std.mem.eql(u8, receipt.repository, repository)) try local.append(self.arena, receipt);+ }+ const packet = try std.json.Stringify.valueAlloc(self.arena, .{+ .repository = repo,+ .base_tip = base,+ .committed_inputs = input,+ .observed_local_checks = local.items,+ .local_check_limit = if (local.items.len == 0) "no local check receipt was observed for this repository in the current or restored session" else "receipts are bounded observations; head_after and tracked_tree_clean_after do not prove immutable execution",+ .observed_head_ci = @tagName(ci),+ .observed_pr_checks = pr_checks,+ }, .{});+ if (packet.len > 256 * 1024) return error.ReviewTooLarge;var hash: [32]u8 = undefined;- std.crypto.hash.sha2.Sha256.hash(serialized, &hash, .{});+ std.crypto.hash.sha2.Sha256.hash(packet, &hash, .{});const key = std.fmt.bytesToHex(hash, .lower);if (remembered(self.io, key)) return .{ .verdict = .supported, .reason = "same immutable inputs already reviewed" };var judge: Agent = .{@@ -90,6 +104,7 @@ pub fn review(self: *Agent, target: evidence.Target, base_name: ?[]const u8, cre\\Check boundary cases asserted in the PR description against tests and implementation.\\Do not infer execution or remote CI from prose. The harness supplies observed_head_ci separately.\\This review does not certify execution or CI coverage beyond the supplied observations.+ \\If support_omitted is true, use support_limit to identify the missing evidence and return unresolved when it is required.\\If required callers or tests are missing, return unresolved. If a claim exceeds supported scope,\\return unsupported with a concrete counterexample or missing coverage. Do not accept claims\\just because the body says dispatch, integration, verified, or end-to-end.@@ -97,7 +112,6 @@ 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, .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 f595954e..cec2ce0d 100644--- a/src/pr_local_checks.zig+++ b/src/pr_local_checks.zig@@ -101,7 +101,7 @@ pub fn batchGate(root: anytype, calls: []const ToolCall, call: ToolCall) !?ExecRpub const State = struct {const Entry = struct { cwd: []const u8, command: []const u8, repository: ?[]const u8 = null };- pub const Receipt = struct { repository: []const u8, command: []const u8, head_after: []const u8, tracked_tree_clean_after: bool, output: []const u8, failed: bool, completed: bool, output_truncated: bool = false };+ pub const Receipt = struct { repository: []const u8, command: []const u8, head_after: []const u8, tracked_tree_clean_after: bool, output: []const u8, failed: bool, completed: bool, command_truncated: bool = false, output_truncated: bool = false };observation_mutex: std.Io.Mutex = .init,failed: std.ArrayList(Entry) = .empty,recent: std.ArrayList(Receipt) = .empty,@@ -118,12 +118,15 @@ pub const State = struct {pub fn recordReceipt(self: *State, arena: Allocator, receipt: Receipt) !void {var owned = receipt;owned.repository = try arena.dupe(u8, receipt.repository);- owned.command = try arena.dupe(u8, receipt.command);+ var command_end = @min(receipt.command.len, 1024);+ while (command_end > 0 and !std.unicode.utf8ValidateSlice(receipt.command[0..command_end])) command_end -= 1;+ owned.command_truncated = receipt.command_truncated or command_end < receipt.command.len;+ owned.command = try arena.dupe(u8, receipt.command[0..command_end]);owned.head_after = try arena.dupe(u8, receipt.head_after);- owned.output_truncated = receipt.output.len > 4096;+ owned.output_truncated = receipt.output_truncated or receipt.output.len > 4096;var end = @min(receipt.output.len, 4096);while (end > 0 and !std.unicode.utf8ValidateSlice(receipt.output[0..end])) end -= 1;- owned.output_truncated = end < receipt.output.len;+ owned.output_truncated = owned.output_truncated or end < receipt.output.len;owned.output = try arena.dupe(u8, receipt.output[0..end]);if (self.recent.items.len == 8) _ = self.recent.orderedRemove(0);try self.recent.append(arena, owned);@@ -151,6 +154,8 @@ pub const State = struct {pub fn write(self: *const State, writer: anytype) !void {try writer.objectField("publication_failed_checks");try writer.write(self.failed.items);+ try writer.objectField("publication_recent_checks");+ try writer.write(self.recent.items);}pub fn mixFingerprint(self: *const State, fingerprint: anytype) void {@@ -160,16 +165,25 @@ pub const State = struct {fingerprint.text(entry.command);fingerprint.text(entry.repository orelse entry.cwd);}+ fingerprint.num(self.recent.items.len);+ for (self.recent.items) |receipt| {+ fingerprint.text(receipt.repository);+ fingerprint.text(receipt.command);+ fingerprint.text(receipt.head_after);+ fingerprint.text(receipt.output);+ fingerprint.num(@intFromBool(receipt.tracked_tree_clean_after));+ fingerprint.num(@intFromBool(receipt.failed));+ fingerprint.num(@intFromBool(receipt.completed));+ fingerprint.num(@intFromBool(receipt.command_truncated));+ fingerprint.num(@intFromBool(receipt.output_truncated));+ }}pub fn restore(self: *State, arena: Allocator, object: std.json.ObjectMap) !void {var restored: State = .{};- const saved = object.get("publication_failed_checks") orelse {- self.* = restored;- return;- };- if (saved != .array) return error.InvalidPublicationChecks;- for (saved.array.items) |item| {+ const saved = object.get("publication_failed_checks") orelse .null;+ if (saved != .null and saved != .array) return error.InvalidPublicationChecks;+ if (saved == .array) for (saved.array.items) |item| {if (item != .object) return error.InvalidPublicationChecks;const cwd = item.object.get("cwd") orelse return error.InvalidPublicationChecks;const command = item.object.get("command") orelse return error.InvalidPublicationChecks;@@ -179,6 +193,25 @@ pub const State = struct {if (repository != .null and (repository != .string or !std.fs.path.isAbsolute(repository.string)))return error.InvalidPublicationChecks;try restored.failed.append(arena, .{ .cwd = try arena.dupe(u8, cwd.string), .command = try arena.dupe(u8, command.string), .repository = if (repository == .string) try arena.dupe(u8, repository.string) else null });+ };+ const receipts = object.get("publication_recent_checks") orelse .null;+ if (receipts != .null and receipts != .array) return error.InvalidPublicationChecks;+ if (receipts == .array) {+ if (receipts.array.items.len > 8) return error.InvalidPublicationChecks;+ for (receipts.array.items) |item| {+ if (item != .object) return error.InvalidPublicationChecks;+ const repository = item.object.get("repository") orelse return error.InvalidPublicationChecks;+ const command = item.object.get("command") orelse return error.InvalidPublicationChecks;+ const head = item.object.get("head_after") orelse return error.InvalidPublicationChecks;+ const output = item.object.get("output") orelse return error.InvalidPublicationChecks;+ const clean = item.object.get("tracked_tree_clean_after") orelse return error.InvalidPublicationChecks;+ const failed = item.object.get("failed") orelse return error.InvalidPublicationChecks;+ const completed = item.object.get("completed") orelse return error.InvalidPublicationChecks;+ const command_truncated = item.object.get("command_truncated") orelse std.json.Value{ .bool = false };+ const truncated = item.object.get("output_truncated") orelse return error.InvalidPublicationChecks;+ if (repository != .string or !std.fs.path.isAbsolute(repository.string) or command != .string or command.string.len == 0 or command.string.len > 1024 or head != .string or head.string.len > 64 or output != .string or output.string.len > 4096 or clean != .bool or failed != .bool or completed != .bool or command_truncated != .bool or truncated != .bool) return error.InvalidPublicationChecks;+ try restored.recordReceipt(arena, .{ .repository = repository.string, .command = command.string, .head_after = head.string, .tracked_tree_clean_after = clean.bool, .output = output.string, .failed = failed.bool, .completed = completed.bool, .command_truncated = command_truncated.bool, .output_truncated = truncated.bool });+ }}self.* = restored;}@@ -268,6 +301,7 @@ test "failed checks survive serialization and malformed state is not a clean resconst a = arena.allocator();var original: State = .{};try original.failed.append(a, .{ .cwd = "/fixture", .command = "zig build test" });+ try original.recordReceipt(a, .{ .repository = "/fixture", .command = "zig build test", .head_after = "head", .tracked_tree_clean_after = true, .output = "1 test passed", .failed = false, .completed = true });var output: std.Io.Writer.Allocating = .init(a);var writer: std.json.Stringify = .{ .writer = &output.writer };try writer.beginObject();@@ -277,6 +311,8 @@ test "failed checks survive serialization and malformed state is not a clean resvar resumed: State = .{};try resumed.restore(a, saved.object);try std.testing.expectEqualStrings("zig build test", resumed.unresolved("/fixture").?);+ try std.testing.expectEqual(@as(usize, 1), resumed.recent.items.len);+ try std.testing.expectEqualStrings("1 test passed", resumed.recent.items[0].output);const malformed = try std.json.parseFromSliceLeaky(std.json.Value, a, "{\"publication_failed_checks\":false}", .{});try std.testing.expectError(error.InvalidPublicationChecks, resumed.restore(a, malformed.object));try std.testing.expect(resumed.unresolved("/fixture") != null);@@ -300,12 +336,14 @@ test "claim review local receipts retain bounded owned output and explicit limitdefer arena.deinit();var state: State = .{};var text: [4100]u8 = @splat('x');- for (0..10) |_| try state.recordReceipt(arena.allocator(), .{ .repository = "/repo", .command = "pytest", .head_after = "head", .tracked_tree_clean_after = false, .output = &text, .failed = false, .completed = false });+ for (0..10) |_| try state.recordReceipt(arena.allocator(), .{ .repository = "/repo", .command = &text, .head_after = "head", .tracked_tree_clean_after = false, .output = &text, .failed = false, .completed = false });text[0] = 'y';try std.testing.expectEqual(@as(usize, 8), state.recent.items.len);const last = state.recent.items[7];try std.testing.expectEqual(@as(u8, 'x'), last.output[0]);try std.testing.expectEqual(@as(usize, 4096), last.output.len);+ try std.testing.expectEqual(@as(usize, 1024), last.command.len);+ try std.testing.expect(last.command_truncated);try std.testing.expect(last.output_truncated);try std.testing.expect(!last.completed and !last.tracked_tree_clean_after);}diff --git a/src/pr_review_input.zig b/src/pr_review_input.zigindex de151a31..66548a5b 100644--- a/src/pr_review_input.zig+++ b/src/pr_review_input.zig@@ -10,14 +10,15 @@ fn repositoryPath(arena: A, dir: []const u8, name: []const u8) ![]const u8 {return std.mem.trimStart(u8, path, "/");}-pub const File = struct { path: []const u8, before: ?[]const u8, after: ?[]const u8 };+pub const File = struct { path: []const u8, before: ?[]const u8, after: ?[]const u8, change: ?[]const u8 = null };pub const Input = struct {- version: u8 = 1,+ version: u8 = 2,base: []const u8,head: []const u8,body: []const u8,files: []const File,support_omitted: bool = false,+ support_limit: ?[]const u8 = null,// 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",@@ -42,7 +43,8 @@ fn raw(gpa: A, io: std.Io, arena: A, cwd: []const u8, args: []const []const u8)const result = try runner.runCappedWithOptions(gpa, io, args, max_bytes + 1, 2048, 15_000, .{ .cwd = .{ .path = cwd } });defer gpa.free(result.stdout);defer gpa.free(result.stderr);- if (!runner.ranOk(result) or result.stdout_truncated or result.stderr_truncated) return error.EvidenceUnavailable;+ if (result.stdout_truncated) return error.ReviewTooLarge;+ if (!runner.ranOk(result) or result.stderr_truncated) return error.EvidenceUnavailable;return arena.dupe(u8, result.stdout);}@@ -68,16 +70,25 @@ const Support = struct {size: *usize,omitted: bool = false,packages: std.ArrayList([]const u8) = .empty,+ seen: std.StringHashMap(void),+ limit: ?[]const u8 = null,fn add(self: *Support, path: []const u8) !?[]const u8 {for (self.files.items) |file| if (std.mem.eql(u8, file.path, path)) return file.after;if (self.files.items.len >= max_files) {self.omitted = true;+ if (self.limit == null) self.limit = "support file count exceeded 32";return null;}- const after = try blob(self.gpa, self.io, self.arena, self.cwd, self.head, path) orelse return null;+ const after = blob(self.gpa, self.io, self.arena, self.cwd, self.head, path) catch |err| {+ if (err != error.ReviewTooLarge) return err;+ self.omitted = true;+ if (self.limit == null) self.limit = "a support file exceeded 128 KiB";+ return null;+ } orelse return null;if (self.size.* + after.len > max_bytes) {self.omitted = true;+ if (self.limit == null) self.limit = "support source exceeded the 128 KiB review budget";return null;}self.size.* += after.len;@@ -103,17 +114,30 @@ const Support = struct {}fn runners(self: *Support, dir: []const u8, text: []const u8) !void {- var words = std.mem.tokenizeAny(u8, text, " \t\r\n\"';&|");+ return self.walk(dir, text, 0);+ }++ fn walk(self: *Support, dir: []const u8, text: []const u8, depth: usize) !void {+ var words = std.mem.tokenizeAny(u8, text, " \t\r\n\"';&|(),{}[]");while (words.next()) |word| {- if (std.fs.path.isAbsolute(word) or std.mem.indexOfAny(u8, word, "$`*?()") != null) continue;+ if (std.fs.path.isAbsolute(word) or std.mem.indexOfAny(u8, word, "$`*?:") != null) continue;const ext = std.fs.path.extension(word);var source = false;- for ([_][]const u8{ ".js", ".mjs", ".cjs", ".ts", ".py", ".sh" }) |allowed| if (std.mem.eql(u8, ext, allowed)) {+ for ([_][]const u8{ ".js", ".mjs", ".cjs", ".jsx", ".ts", ".tsx", ".py", ".sh" }) |allowed| if (std.mem.eql(u8, ext, allowed)) {source = true;break;};if (!source) continue;- _ = try self.add(try repositoryPath(self.arena, dir, word));+ if (depth >= 5) {+ self.omitted = true;+ if (self.limit == null) self.limit = "test runner chain exceeded five levels";+ return;+ }+ const path = try repositoryPath(self.arena, dir, word);+ if (self.seen.contains(path)) continue;+ try self.seen.put(path, {});+ const contents = try self.add(path) orelse continue;+ try self.walk(std.fs.path.dirnamePosix(path) orelse "", contents, depth + 1);}}};@@ -128,14 +152,16 @@ pub fn gather(gpa: A, io: std.Io, arena: A, cwd: []const u8, base: []const u8, hwhile (paths.next()) |path| {if (path.len == 0) continue;if (files.items.len >= max_files) return error.ReviewTooLarge;- const before = try blob(gpa, io, arena, cwd, base, path);const after = try blob(gpa, io, arena, cwd, head, path);- size += (if (before) |text| text.len else 0) + (if (after) |text| text.len else 0);+ // A context diff carries the old lines; repeating the complete base+ // blob would charge unchanged source twice and crowd out test evidence.+ const change = try raw(gpa, io, arena, cwd, &.{ "git", "diff", "--no-ext-diff", "--no-renames", "--unified=3", base, head, "--", path });+ size += change.len + (if (after) |text| text.len else 0);if (size > max_bytes) return error.ReviewTooLarge;- try files.append(arena, .{ .path = path, .before = before, .after = after });+ try files.append(arena, .{ .path = path, .before = null, .after = after, .change = change });}if (files.items.len == 0) return error.NoChangedFiles;- var support: Support = .{ .gpa = gpa, .io = io, .arena = arena, .cwd = cwd, .head = head, .files = &files, .size = &size };+ var support: Support = .{ .gpa = gpa, .io = io, .arena = arena, .cwd = cwd, .head = head, .files = &files, .size = &size, .seen = std.StringHashMap(void).init(arena) };// Walk changed-file ancestors before generic root files: the closest// package defines the changed test's runner, often in a nested workspace.const changed = try arena.dupe(File, files.items);@@ -165,7 +191,7 @@ pub fn gather(gpa: A, io: std.Io, arena: A, cwd: []const u8, base: []const u8, h}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 };+ return .{ .base = base, .head = head, .body = body, .files = files.items, .support_omitted = support.omitted, .support_limit = support.limit };}test "claim review rejects branch names as immutable identities" {@@ -195,6 +221,47 @@ 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 budgets changed hunks instead of the complete base blob" {+ 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)];+ const gpa = std.testing.allocator;+ _ = try capture(gpa, io, a, cwd, &.{ "git", "init", "-q" });+ const source = try a.alloc(u8, 75 * 1024);+ @memset(source, 'a');+ for (source, 0..) |*byte, i| if (i % 80 == 79) {+ byte.* = '\n';+ };+ source[0] = 'x';+ source[source.len - 1] = '\n';+ try temp.dir.writeFile(io, .{ .sub_path = "large.txt", .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" });+ source[0] = 'y';+ try temp.dir.writeFile(io, .{ .sub_path = "large.txt", .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, 1), input.files.len);+ try std.testing.expect(input.files[0].before == null);+ try std.testing.expect(input.files[0].change != null);+ try std.testing.expectEqual(@as(u8, 'y'), input.files[0].after.?[0]);+ const oversized = try a.alloc(u8, max_bytes + 1024);+ @memset(oversized, 'z');+ try temp.dir.writeFile(io, .{ .sub_path = "large.txt", .data = oversized });+ _ = 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", "oversized" });+ const large_head = try capture(gpa, io, a, cwd, &.{ "git", "rev-parse", "HEAD" });+ try std.testing.expectError(error.ReviewTooLarge, gather(gpa, io, a, cwd, head, large_head, "claim"));+}+test "claim review includes unchanged callers that establish test reachability" {const io = std.testing.io;var temp = std.testing.tmpDir(.{});@@ -254,7 +321,8 @@ test "claim review includes committed nested package runners and workflow reachatry temp.dir.createDirPath(io, "apps/client/lib");try temp.dir.createDirPath(io, ".github/workflows");try temp.dir.writeFile(io, .{ .sub_path = "apps/client/package.json", .data = "{\"scripts\":{\"test\":\"node scripts/test-nested.mjs\"}}" });- try temp.dir.writeFile(io, .{ .sub_path = "apps/client/scripts/test-nested.mjs", .data = "import '../lib/view.test.mjs';\n" });+ try temp.dir.writeFile(io, .{ .sub_path = "apps/client/scripts/test-nested.mjs", .data = "import '../lib/suite.mjs';\n" });+ try temp.dir.writeFile(io, .{ .sub_path = "apps/client/lib/suite.mjs", .data = "import './view.test.mjs';\n" });try temp.dir.writeFile(io, .{ .sub_path = "apps/client/lib/view.test.mjs", .data = "old test\n" });try temp.dir.writeFile(io, .{ .sub_path = ".github/workflows/check.yml", .data = "run: cd apps/client && npm test\n" });_ = try capture(gpa, io, a, cwd, &.{ "git", "add", "." });@@ -266,19 +334,25 @@ test "claim review includes committed nested package runners and workflow reachaconst head = try capture(gpa, io, a, cwd, &.{ "git", "rev-parse", "HEAD" });try temp.dir.writeFile(io, .{ .sub_path = "apps/client/scripts/test-nested.mjs", .data = "uncommitted runner is not evidence" });const input = try gather(gpa, io, a, cwd, base, head, "Local: `npm test` passed.");- try std.testing.expectEqual(@as(usize, 4), input.files.len);+ try std.testing.expectEqual(@as(usize, 5), input.files.len);var bytes = input.body.len;+ var saw_suite = false;for (input.files) |file| {- bytes += if (file.before) |text| text.len else 0;+ bytes += if (file.change) |text| text.len else 0;bytes += if (file.after) |text| text.len else 0;if (std.mem.eql(u8, file.path, "apps/client/scripts/test-nested.mjs"))- try std.testing.expectEqualStrings("import '../lib/view.test.mjs';\n", file.after.?);+ try std.testing.expectEqualStrings("import '../lib/suite.mjs';\n", file.after.?);+ if (std.mem.eql(u8, file.path, "apps/client/lib/suite.mjs")) {+ saw_suite = true;+ try std.testing.expectEqualStrings("import './view.test.mjs';\n", file.after.?);+ }}+ try std.testing.expect(saw_suite);try std.testing.expect(bytes <= max_bytes and input.files.len <= max_files);try std.testing.expect(!input.support_omitted);var files: std.ArrayList(File) = .empty;var size: usize = max_bytes;- var support: Support = .{ .gpa = gpa, .io = io, .arena = a, .cwd = cwd, .head = head, .files = &files, .size = &size };+ var support: Support = .{ .gpa = gpa, .io = io, .arena = a, .cwd = cwd, .head = head, .files = &files, .size = &size, .seen = std.StringHashMap(void).init(a) };try std.testing.expect(try support.add("apps/client/package.json") == null);try std.testing.expect(support.omitted and files.items.len == 0 and size == max_bytes);}diff --git a/src/publish_gate.zig b/src/publish_gate.zigindex c9b7c8e1..224009e5 100644--- a/src/publish_gate.zig+++ b/src/publish_gate.zig@@ -58,8 +58,11 @@ fn observe(self: *Agent, cmd: []const u8) !?ExecResult {}if (pr_publish.decide(draft, ev) != .allow) return .{ .text = pr_publish.refuseText(self.arena, cmd, ev), .is_error = true };if (!draft) {- const review = @import("pr_claim_review.zig").review(self, target, command.flag("--base", "-B"), creating, ev.head_sha, ev.body, ev.head_status) catch- return .{ .text = "PR publication preflight: claim review could not establish readiness from the committed source and tests; write NOT performed. Keep a draft while evidence is unresolved.", .is_error = true };+ const review = @import("pr_claim_review.zig").review(self, target, command.flag("--base", "-B"), creating, ev.head_sha, ev.body, ev.head_status) catch |err|+ return .{ .text = if (err == error.ReviewTooLarge)+ "PR publication preflight: claim review input exceeded its size limit (128 KiB committed source budget or 256 KiB review packet); write NOT performed. Narrow the change or provide smaller relevant evidence."+ else+ "PR publication preflight: claim review could not establish readiness from the committed source and tests; write NOT performed. Keep a draft while evidence is unresolved.", .is_error = true };if (review.verdict != .supported) return .{ .text = try std.fmt.allocPrint(self.arena, "PR publication preflight: claim review is {s}: {s}. Write NOT performed; keep a draft or fix the unsupported claim and coverage.", .{ @tagName(review.verdict), review.reason }), .is_error = true };}@import("pr_verify.zig").arm(self, target, creating and command.flag("--head", "-H") == null) catch return .{ .text = "PR publication preflight: could not persist the CI verification obligation; write NOT performed", .is_error = true };