graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(integration): repair four cross-branch breaks the individual branches could not see
Rach Pradhan3183cc63f603
diff --git a/src/agent_compact.zig b/src/agent_compact.zigindex 6e5d3e9a..e2feec57 100644--- a/src/agent_compact.zig+++ b/src/agent_compact.zig@@ -11,6 +11,11 @@ const main_mod = @import("main.zig");const agent_mod = @import("agent.zig");const Agent = agent_mod.Agent;const goal_flow = @import("goal_flow.zig");+// #445 needs this back: #411 dropped the alias as unused in the same release,+// having moved the last compact_instruction reference into handoff_note, while+// #445 added noteSessionCompacted call sites that reach through it. Neither+// branch could see the other, so the break only appeared at integration.+const prompts = @import("prompts.zig");const handoff_note = @import("compact_handoff_note.zig"); // #411: both halves of "what survives a compaction"const compact_note_glue = @import("compact_note_glue.zig"); // #391diff --git a/src/prompt_snapshot_tests.zig b/src/prompt_snapshot_tests.zigindex faa144ee..d96a3520 100644--- a/src/prompt_snapshot_tests.zig+++ b/src/prompt_snapshot_tests.zig@@ -332,9 +332,11 @@ test "#445: the transcript line is absent until the first compaction, then ridesconst saved = prompts.g_session_compacted;defer prompts.g_session_compacted = saved;defer prompts.armSessionTranscript(a, "", .{}, false); // leave the global as the rest of the suite expects it+ defer prompts.armCompactNotes(""); // #391's store is a process global: never leak an armed session into another testvar agent: agent_mod.Agent = undefined;agent.sub = false;+ agent.io = std.testing.io; // the note block reads the fs when armed; a stub's undefined io segfaultsagent.session_name = "session-445";prompts.g_session_compacted = false;@@ -390,9 +392,11 @@ test "#445: /new and /clear disarm the transcript line again, and a later compacconst saved = prompts.g_session_compacted;defer prompts.g_session_compacted = saved;defer prompts.armSessionTranscript(a, "", .{}, false); // leave the global as the rest of the suite expects it+ defer prompts.armCompactNotes(""); // #391's store is a process global: never leak an armed session into another testvar agent: agent_mod.Agent = undefined;agent.sub = false;+ agent.io = std.testing.io; // the note block reads the fs when armed; a stub's undefined io segfaultsagent.session_name = "session-long";prompts.g_session_compacted = false;prompts.armSessionTranscript(a, agent.session_name, .{}, false);@@ -455,9 +459,11 @@ test "#445: /resume disarms the transcript line and leaves no stale session pathconst saved = prompts.g_session_compacted;defer prompts.g_session_compacted = saved;defer prompts.armSessionTranscript(a, "", .{}, false); // leave the global as the rest of the suite expects it+ defer prompts.armCompactNotes(""); // #391's store is a process global: never leak an armed session into another testvar agent: agent_mod.Agent = undefined;agent.sub = false;+ agent.io = std.testing.io; // the note block reads the fs when armed; a stub's undefined io segfaultsagent.session_name = "session-before";prompts.g_session_compacted = false;prompts.armSessionTranscript(a, agent.session_name, .{}, false);diff --git a/src/prompts.zig b/src/prompts.zigindex 23340505..2eed0c51 100644--- a/src/prompts.zig+++ b/src/prompts.zig@@ -170,11 +170,26 @@ pub var g_session_compacted: bool = false;/// bare `Agent` with an `undefined` Io out of the filesystem.var g_note_session: []const u8 = "";+/// Backing store for the above. The global OWNS its name rather than borrowing+/// the caller's: in production every session name is arena-owned for the life+/// of the process, but a unit test hands over a short-lived buffer, and the+/// first test to arm one left every later composition dereferencing freed+/// memory — a segfault inside `compact_note.pathFor`, far from the cause.+/// Copying makes the hazard structurally impossible instead of a rule callers+/// must remember. Names longer than this disarm rather than truncate: a+/// truncated name would silently read a DIFFERENT session's notes.+var g_note_session_buf: [256]u8 = undefined;+/// Armed by setRootSystemPrompts, and re-armed by the note writer itself so a/// `/save <name>` mid-session cannot leave the injection reading a store the/// writer has stopped writing to.pub fn armCompactNotes(session_name: []const u8) void {- g_note_session = session_name;+ if (session_name.len == 0 or session_name.len > g_note_session_buf.len) {+ g_note_session = "";+ return;+ }+ @memcpy(g_note_session_buf[0..session_name.len], session_name);+ g_note_session = g_note_session_buf[0..session_name.len];}/// One line naming the durable transcript. Deliberately NOT described as@@ -435,6 +450,13 @@ test "setSystemPrompts (#326): derives all four variants from base, composing uldefer arena_state.deinit();const a = arena_state.allocator();var agent: Agent = undefined;+ // #391's note block reads the filesystem whenever a session is armed, and+ // g_note_session is a PROCESS global: another test in this binary can leave+ // it armed, at which point this stub's undefined `io` segfaults inside+ // compact_note.load. A real io makes the read miss harmlessly instead, and+ // disarming keeps this test from depending on suite order either way.+ agent.io = std.testing.io;+ armCompactNotes("");try setSystemPrompts(&agent, "BASE-A", a);try std.testing.expectEqualStrings("BASE-A", agent.sys_normal);