Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

fix(goal): close five gaps a /goal subsystem audit found

justrach7355f58b0907
diff --git a/scripts/eval/tier1-manifest.json b/scripts/eval/tier1-manifest.json
index 2f9e263b..8814b1fd 100644
--- a/scripts/eval/tier1-manifest.json
+++ b/scripts/eval/tier1-manifest.json
@@ -6,8 +6,11 @@
"test_count_baseline is a ratchet: the suite may grow, it may never shrink. A drop means a",
"module stopped being referenced from the test root and its tests silently vanished."
],
- "test_roots": ["src/main.zig", "src/repl.zig"],
- "test_count_baseline": 449,
+ "test_roots": [
+ "src/main.zig",
+ "src/repl.zig"
+ ],
+ "test_count_baseline": 498,
"required_invariants": [
{
"id": "goal-epochs",
diff --git a/src/agent_compact_test.zig b/src/agent_compact_test.zig
index 0d6ba103..d0b9036e 100644
--- a/src/agent_compact_test.zig
+++ b/src/agent_compact_test.zig
@@ -402,10 +402,10 @@ test "emergencyTrim preserves the authoritative meter after a partial cut" {
agent.sys_normal = "";
agent.sys_strict = "";
agent.tools_responses = "";
- // emergencyTrim now re-queues the standing goal state (#318), so the fields
- // that decision reads have to be real even in the no-goal case.
+ // emergencyTrim re-queues standing state (#318), gated on the LIST not the goal.
agent.review_mode = false;
agent.goal = null;
+ agent.todos = .empty;
agent.pending_goal_note = null;
const before = agent.fullInputEstimateTokens();
diff --git a/src/commands_session.zig b/src/commands_session.zig
index e8a4714a..bd84eef8 100644
--- a/src/commands_session.zig
+++ b/src/commands_session.zig
@@ -65,17 +65,39 @@ fn resetConversationSteering(root: *Agent) void {
root.pending_goal_note = null; // a queued supersession note dies with the conversation (#318)
root.goal_note_fp = 0;
root.goal_note_age = 0;
+ // A --goal objective is the USER's policy for the process, not a property
+ // of the conversation, so it outlives the conversation the way it outlives
+ // a resume. Without this, one /clear downgraded a standing goal to nothing,
+ // the user set a fresh /goal, got a RETIRABLE one, and the next
+ // attempt_completion ended their steering - #318 through the /clear door.
+ if (root.goal_flag) |g| root.goal = goal_flow.standingGoalFromFlag(g, null, root.todos.items, 0);
}
test "/clear + /new reset conversation steering — goal and ultracode_mode don't survive (#178)" {
var root: Agent = undefined;
root.goal = .{ .objective = "ultracode: index the statutes" };
root.ultracode_mode = true;
+ root.goal_flag = null; // no --goal: the conversation's goal dies with it
+ root.todos = .empty;
resetConversationSteering(&root);
try std.testing.expect(root.goal == null);
try std.testing.expect(!root.ultracode_mode);
}
+test "/clear keeps a --goal standing objective standing (#318 through the /clear door)" {
+ var root: Agent = undefined;
+ root.ultracode_mode = false;
+ root.todos = .empty;
+ root.goal_flag = "keep the tree green"; // the user passed --goal
+ root.goal = .{ .objective = "keep the tree green", .standing = true, .epoch = 1 };
+ resetConversationSteering(&root);
+ // Before this, /clear dropped it, the user typed a fresh /goal, got a
+ // RETIRABLE one, and the next attempt_completion ended their steering.
+ const g = root.goal orelse return error.TestExpectedNonNull;
+ try std.testing.expect(g.standing);
+ try std.testing.expectEqualStrings("keep the tree green", g.objective);
+}
+
/// Try to handle a session/environment slash command. Returns false (line
/// unhandled) if `line` doesn't match any command in this file — the caller
/// (handleCommand in main.zig) then tries the next peer module.
diff --git a/src/goal_flow.zig b/src/goal_flow.zig
index acf4a645..a970ea81 100644
--- a/src/goal_flow.zig
+++ b/src/goal_flow.zig
@@ -85,22 +85,36 @@ pub const snapshot_render_cap: usize = 2_000;
/// the goal. Allocates from `arena`, which MUST outlive compact()'s temporary
/// compaction arena - the text goes into the history that survives it.
pub fn compactionSnapshot(arena: Allocator, root: *Agent) !?[]const u8 {
- if (!goal_state.goalActive(root)) return null;
- const objective = root.goal.?.objective;
+ // The gate is the CHECKLIST, not the goal. Gating on goalActive left every
+ // todo_write user who never types /goal - most of them - with no
+ // restatement, which is the #318 failure this exists to stop; a paused goal
+ // needs it too, since it emits no steering note either. Subagents and
+ // review turns share the Agent but not the goal, so they still never do.
+ if (root.sub or root.review_mode) return null;
const rendered = goal_state.renderCurrent(root);
- if (rendered.len == 0)
- return try std.fmt.allocPrint(arena, "[standing state (harness-kept, survives context rewrites): goal: {s}. No checklist has been written for it yet - plan the work with todo_write, and read the list back with todo_read at any time.]", .{objective});
+ const objective: ?[]const u8 = if (root.goal) |g| g.objective else null;
+ if (rendered.len == 0) {
+ const obj = objective orelse return null; // no goal AND no checklist: nothing to restate
+ return try std.fmt.allocPrint(arena, "[standing state (harness-kept, survives context rewrites): goal: {s}. No checklist has been written for it yet - plan the work with todo_write, and read the list back with todo_read at any time.]", .{obj});
+ }
const open = goal_state.openCount(root.todos.items, goal_state.currentEpoch(root.goal));
- return try std.fmt.allocPrint(arena, "[standing state (harness-kept, survives context rewrites): goal: {s}. Checklist ({d} open):\n{s}\nThis list is live harness state, read it back with todo_read at any time. todo_write REPLACES the current goal's whole list; completed items you omit are kept automatically, open items you omit are dropped.]", .{ objective, open, try capRender(arena, rendered) });
+ const head = if (objective) |obj|
+ try std.fmt.allocPrint(arena, "goal: {s}. Checklist ({d} open)", .{ obj, open })
+ else
+ try std.fmt.allocPrint(arena, "Checklist ({d} open)", .{open});
+ return try std.fmt.allocPrint(arena, "[standing state (harness-kept, survives context rewrites): {s}:\n{s}\nThis list is live harness state, read it back with todo_read at any time. todo_write REPLACES the whole list; completed items you omit are kept automatically, open items you omit are dropped.]", .{ head, try capRender(arena, rendered) });
}
-/// Cut an oversized checklist render at a line boundary (never mid-item, never
-/// mid-codepoint) and say so, rather than pasting it whole.
+/// Cut an oversized checklist render at a line boundary and say so, rather
+/// than pasting it whole. Cuts from the FRONT: preserved completed items keep
+/// their original positions while new work appends, so cutting the tail threw
+/// away the live plan and kept a wall of finished history.
fn capRender(arena: Allocator, rendered: []const u8) ![]const u8 {
if (rendered.len <= snapshot_render_cap) return rendered;
- const head = utf8Prefix(rendered, snapshot_render_cap);
- const cut = std.mem.lastIndexOfScalar(u8, head, '\n') orelse head.len;
- return std.fmt.allocPrint(arena, "{s}\n[checklist truncated for the handoff - call todo_read for the full list]", .{rendered[0..cut]});
+ const start = rendered.len - snapshot_render_cap;
+ const tail = rendered[start..];
+ const cut = if (std.mem.indexOfScalar(u8, tail, '\n')) |i| i + 1 else 0;
+ return std.fmt.allocPrint(arena, "[earlier completed items truncated for the handoff - call todo_read for the full list]\n{s}", .{tail[cut..]});
}
pub const GoalSetResult = struct {
@@ -411,60 +425,6 @@ test "a cleared goal's OPEN items never become the next goal's work (#318)" {
try std.testing.expectEqualStrings("", goal_state.renderCurrent(&root)); // B never renders A's list
}
-test "compactionSnapshot: no live goal, no checklist, and a capped render (#318)" {
- var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena_state.deinit();
- const ar = arena_state.allocator();
- var root = flowRoot(ar);
-
- // No goal: nothing to restate, and the handoff stays byte-identical.
- try std.testing.expect((try compactionSnapshot(ar, &root)) == null);
-
- // A goal that has not planned yet gets the list-free variant - never the
- // "(no todos)" placeholder, which reads as a checklist that exists and is
- // empty rather than one the model still has to write.
- root.goal = .{ .objective = "ship phase 2", .epoch = 1 };
- const bare = (try compactionSnapshot(ar, &root)).?;
- try std.testing.expect(std.mem.indexOf(u8, bare, "ship phase 2") != null);
- try std.testing.expect(std.mem.indexOf(u8, bare, "Checklist (") == null);
- try std.testing.expect(std.mem.indexOf(u8, bare, "(no todos)") == null);
-
- // Only an ACTIVE root goal is restated: a paused goal is not steering, and
- // a review turn or subagent shares the Agent struct but not the objective.
- root.goal.?.status = .paused;
- try std.testing.expect((try compactionSnapshot(ar, &root)) == null);
- root.goal.?.status = .active;
- root.review_mode = true;
- try std.testing.expect((try compactionSnapshot(ar, &root)) == null);
- root.review_mode = false;
- root.sub = true;
- try std.testing.expect((try compactionSnapshot(ar, &root)) == null);
- root.sub = false;
-
- // Parked work never re-enters the handoff, and the open count is the
- // current epoch's.
- try root.todos.append(ar, .{ .content = "parked by an older goal", .status = "pending", .epoch = 0 });
- try root.todos.append(ar, .{ .content = "write the helper", .status = "completed", .epoch = 1 });
- try root.todos.append(ar, .{ .content = "test it", .status = "pending", .epoch = 1 });
- const snap = (try compactionSnapshot(ar, &root)).?;
- try std.testing.expect(std.mem.indexOf(u8, snap, "Checklist (1 open)") != null);
- try std.testing.expect(std.mem.indexOf(u8, snap, "[x] write the helper") != null);
- try std.testing.expect(std.mem.indexOf(u8, snap, "[ ] test it") != null);
- try std.testing.expect(std.mem.indexOf(u8, snap, "parked by an older goal") == null);
- try std.testing.expect(std.mem.indexOf(u8, snap, "todo_write REPLACES") != null);
-
- // A pathological list is cut at a line boundary instead of pasted whole:
- // the restatement must not undo the compaction it rides on.
- var i: usize = 0;
- while (i < 400) : (i += 1)
- try root.todos.append(ar, .{ .content = "a checklist item with some measurable length", .status = "pending", .epoch = 1 });
- const capped = (try compactionSnapshot(ar, &root)).?;
- try std.testing.expect(capped.len < snapshot_render_cap + 600);
- try std.testing.expect(std.mem.indexOf(u8, capped, "checklist truncated") != null);
- try std.testing.expect(std.mem.indexOf(u8, capped, "Checklist (401 open)") != null);
- try std.testing.expect(std.mem.endsWith(u8, capped, "are dropped.]")); // the REPLACES warning survives the cut
-}
-
test "a compaction does not move the goal note's diff-gate fingerprint (#318)" {
var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena_state.deinit();
diff --git a/src/goal_persist_tests.zig b/src/goal_persist_tests.zig
index 1cdcd0cf..a1644b82 100644
--- a/src/goal_persist_tests.zig
+++ b/src/goal_persist_tests.zig
@@ -48,6 +48,8 @@ fn blankRoot(arena: Allocator) Agent {
root.completed = null;
root.tool_calls_this_turn = 0;
root.goal_note_fp = 0;
+ root.pending_goal_note = null;
+ root.history_rewrites = 0;
root.loop_deadline_ms = null;
return root;
}
@@ -452,3 +454,80 @@ test "an accepted claim while paused still consumes the double-check arm (#318)"
root.goal.?.status = .active; // /goal resume
try std.testing.expect((try goal_state.completionGate(ar, &root)) != null); // fresh double-check
}
+
+test "compactionSnapshot: no live goal, no checklist, and a capped render (#318)" {
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ const ar = arena_state.allocator();
+ var root = blankRoot(ar);
+
+ // No goal: nothing to restate, and the handoff stays byte-identical.
+ try std.testing.expect((try goal_flow.compactionSnapshot(ar, &root)) == null);
+
+ // A goal that has not planned yet gets the list-free variant - never the
+ // "(no todos)" placeholder, which reads as a checklist that exists and is
+ // empty rather than one the model still has to write.
+ root.goal = .{ .objective = "ship phase 2", .epoch = 1 };
+ const bare = (try goal_flow.compactionSnapshot(ar, &root)).?;
+ try std.testing.expect(std.mem.indexOf(u8, bare, "ship phase 2") != null);
+ try std.testing.expect(std.mem.indexOf(u8, bare, "Checklist (") == null);
+ try std.testing.expect(std.mem.indexOf(u8, bare, "(no todos)") == null);
+
+ // A PAUSED goal still restates. It emits no steering note either, so
+ // gating it out left /goal resume returning to a model with amnesia about
+ // its own plan - the restatement follows the CHECKLIST, not the status.
+ root.goal.?.status = .paused;
+ try std.testing.expect((try goal_flow.compactionSnapshot(ar, &root)) != null);
+ root.goal.?.status = .active;
+ root.review_mode = true;
+ try std.testing.expect((try goal_flow.compactionSnapshot(ar, &root)) == null);
+ root.review_mode = false;
+ root.sub = true;
+ try std.testing.expect((try goal_flow.compactionSnapshot(ar, &root)) == null);
+ root.sub = false;
+
+ // Parked work never re-enters the handoff, and the open count is the
+ // current epoch's.
+ try root.todos.append(ar, .{ .content = "parked by an older goal", .status = "pending", .epoch = 0 });
+ try root.todos.append(ar, .{ .content = "write the helper", .status = "completed", .epoch = 1 });
+ try root.todos.append(ar, .{ .content = "test it", .status = "pending", .epoch = 1 });
+ const snap = (try goal_flow.compactionSnapshot(ar, &root)).?;
+ try std.testing.expect(std.mem.indexOf(u8, snap, "Checklist (1 open)") != null);
+ try std.testing.expect(std.mem.indexOf(u8, snap, "[x] write the helper") != null);
+ try std.testing.expect(std.mem.indexOf(u8, snap, "[ ] test it") != null);
+ try std.testing.expect(std.mem.indexOf(u8, snap, "parked by an older goal") == null);
+ try std.testing.expect(std.mem.indexOf(u8, snap, "todo_write REPLACES") != null);
+
+ // A pathological list is cut at a line boundary instead of pasted whole:
+ // the restatement must not undo the compaction it rides on. The cut takes
+ // the FRONT: preserved completed items keep their original positions while
+ // new work appends, so cutting the tail threw away the live plan and kept
+ // a wall of finished history - the opposite of what the model needs.
+ var i: usize = 0;
+ while (i < 400) : (i += 1)
+ try root.todos.append(ar, .{ .content = "a checklist item with some measurable length", .status = "pending", .epoch = 1 });
+ const capped = (try goal_flow.compactionSnapshot(ar, &root)).?;
+ try std.testing.expect(capped.len < goal_flow.snapshot_render_cap + 600);
+ try std.testing.expect(std.mem.indexOf(u8, capped, "truncated") != null);
+ try std.testing.expect(std.mem.indexOf(u8, capped, "Checklist (401 open)") != null);
+ try std.testing.expect(std.mem.endsWith(u8, capped, "are dropped.]")); // the REPLACES warning survives the cut
+ // The oldest completed item is what got cut, not the newest work.
+ try std.testing.expect(std.mem.indexOf(u8, capped, "[x] write the helper") == null);
+}
+
+test "goalPromptFromLine: an objective runs a turn, the lifecycle words do not" {
+ try std.testing.expectEqualStrings("ship phase 2", repl_glue.goalPromptFromLine("/goal ship phase 2 ").?);
+ try std.testing.expect(repl_glue.goalPromptFromLine("/goal ") == null); // bare /goal shows the objective
+ try std.testing.expect(repl_glue.goalPromptFromLine("/goal PAUSE") == null); // case-insensitive, like handleCommand
+ try std.testing.expectEqualStrings("clear the flaky tests", repl_glue.goalPromptFromLine("/goal clear the flaky tests").?); // merely STARTS with one
+}
+
+test "absolute path prompts are not mistaken for slash commands" {
+ try std.testing.expect(repl_glue.isSlashCommandLine("/"));
+ try std.testing.expect(repl_glue.isSlashCommandLine("/help"));
+ try std.testing.expect(repl_glue.isSlashCommandLine("/bash echo hi"));
+ try std.testing.expect(repl_glue.isSlashCommandLine("/not-a-command"));
+
+ try std.testing.expect(!repl_glue.isSlashCommandLine("/System/Library/PrivateFrameworks/StorageManagement.framework/PlugIns/StorageManagementService what causes this to start"));
+ try std.testing.expect(!repl_glue.isSlashCommandLine("/Users/blackfloofie/codedb/src/main.zig explain this"));
+}
diff --git a/src/goal_todo.zig b/src/goal_todo.zig
index e1adb736..064677d0 100644
--- a/src/goal_todo.zig
+++ b/src/goal_todo.zig
@@ -34,19 +34,23 @@ const goal_state = @import("goal_state.zig");
/// empty case): an empty replace here would leave only completed survivors,
/// an epoch that reads allDone off a write that did nothing (#318).
pub fn clearEpochForReplace(todos: *std.ArrayList(TodoItem), epoch: u64, incoming: []const []const u8) usize {
- var removed: usize = 0;
+ var dropped_open: usize = 0;
var i: usize = 0;
while (i < todos.items.len) {
const t = todos.items[i];
- const preserve = std.mem.eql(u8, t.status, "completed") and !mentions(incoming, t.content);
- if (t.epoch != epoch or preserve) {
+ const done = std.mem.eql(u8, t.status, "completed");
+ const mentioned = mentions(incoming, t.content);
+ if (t.epoch != epoch or (done and !mentioned)) {
i += 1;
continue;
}
+ // Open work the replacement did not mention is being ABANDONED. Count
+ // it so the caller can say so: every user-driven drop reports a count
+ // (/goal clear, /goal <new>), and only the model-driven one was silent.
+ if (!done and !mentioned) dropped_open += 1;
_ = todos.orderedRemove(i);
- removed += 1;
}
- return removed;
+ return dropped_open;
}
fn mentions(contents: []const []const u8, content: []const u8) bool {
@@ -54,7 +58,7 @@ fn mentions(contents: []const []const u8, content: []const u8) bool {
return false;
}
-pub const WriteResult = struct { text: []const u8, rejected: bool = false };
+pub const WriteResult = struct { text: []const u8, rejected: bool = false, dropped_open: usize = 0 };
/// The whole todo_write handler: replace the current epoch's checklist with
/// `list` (the tool call's "todos" argument, already parsed), preserving
@@ -75,7 +79,7 @@ pub fn applyTodoWrite(root: *Agent, list: ?Value) !WriteResult {
}
if (incoming.items.len == 0)
return .{ .text = "todo_write had no usable items; the list is unchanged. Each item needs a content string and a status. Send your full remaining plan - completed items you omit are kept automatically.", .rejected = true };
- _ = clearEpochForReplace(&root.todos, epoch, incoming.items);
+ const dropped_open = clearEpochForReplace(&root.todos, epoch, incoming.items);
goal_state.noteTodoWrite(root); // fresh evidence for the completion double-check, and this-process evidence for /loop (#318)
if (asArray(list)) |items| {
for (items) |item| {
@@ -88,7 +92,14 @@ pub fn applyTodoWrite(root: *Agent, list: ?Value) !WriteResult {
});
}
}
- return .{ .text = goal_state.renderTodos(root, epoch) };
+ const rendered = goal_state.renderTodos(root, epoch);
+ if (dropped_open == 0) return .{ .text = rendered };
+ // Name the abandonment. The model may well have meant it, but the user
+ // reading the transcript needs the same count they get from /goal clear.
+ return .{
+ .text = try std.fmt.allocPrint(root.arena, "{s}\n({d} open item(s) you left out were dropped; re-list one to keep it)", .{ rendered, dropped_open }),
+ .dropped_open = dropped_open,
+ };
}
fn asArray(list: ?Value) ?[]const Value {
@@ -146,7 +157,10 @@ test "a replace keeps omitted completed items and still drops omitted open ones"
const rendered = (try applyTodoWrite(&root, try todosArg(ar,
\\{"todos":[{"content":"wire it up","status":"in_progress"}]}
))).text;
- try std.testing.expectEqualStrings("[x] write the helper\n[x] test it\n[~] wire it up", rendered);
+ // The list itself is unchanged; the abandonment is NAMED after it, because
+ // a silent model-driven drop was the one deletion the user never saw.
+ try std.testing.expect(std.mem.startsWith(u8, rendered, "[x] write the helper\n[x] test it\n[~] wire it up"));
+ try std.testing.expect(std.mem.indexOf(u8, rendered, "1 open item(s) you left out were dropped") != null);
// The omitted OPEN item really is gone: a re-plan must be able to abandon work.
try std.testing.expect(std.mem.indexOf(u8, rendered, "abandoned idea") == null);
try std.testing.expectEqual(@as(usize, 1), goal_state.openCount(root.todos.items, 1));
@@ -194,7 +208,8 @@ test "the replace stays epoch-scoped: parked work of any status is untouched" {
const rendered = (try applyTodoWrite(&root, try todosArg(ar,
\\{"todos":[{"content":"B2","status":"pending"}]}
))).text;
- try std.testing.expectEqualStrings("[ ] B2", rendered); // B1 was open, so it dropped
+ try std.testing.expect(std.mem.startsWith(u8, rendered, "[ ] B2")); // B1 was open, so it dropped
+ try std.testing.expect(std.mem.indexOf(u8, rendered, "1 open item(s) you left out were dropped") != null);
try std.testing.expectEqual(@as(usize, 3), root.todos.items.len);
try std.testing.expectEqual(@as(u64, 3), root.todos.items[0].epoch);
try std.testing.expectEqual(@as(usize, 1), goal_state.parkedOpenCount(root.todos.items, 4));
diff --git a/src/mainloop.zig b/src/mainloop.zig
index 5852ef14..50eb9fc8 100644
--- a/src/mainloop.zig
+++ b/src/mainloop.zig
@@ -580,8 +580,10 @@ pub fn run(ctx: *Ctx) !void {
// Only work_done reaches `accepted`, so the loop drove the
// goal to done; a --goal standing objective outlives it (#318).
if (outcome == .accepted) _ = goal_flow.acceptLoopOutcome(ctx.root);
- try ctx.out.print("{s}↩ run stopped — {s}{s}\n", .{ style.dim, @tagName(outcome), style.reset });
+ const tone = if (outcome == .accepted) style.green else style.yellow; // success must not look like the four failures
+ try ctx.out.print("{s}↩ run stopped — {s}{s}\n", .{ tone, repl_glue.outcomeText(outcome, loop_iter_cap), style.reset });
try ctx.out.flush();
+ if (ctx.root.tracer) |t| t.note("loop", @tagName(outcome)); // every /goal transition is traced; the run's end was not
},
}
}
diff --git a/src/repl_glue.zig b/src/repl_glue.zig
index 89a1b764..5ddc8711 100644
--- a/src/repl_glue.zig
+++ b/src/repl_glue.zig
@@ -208,6 +208,22 @@ test "goalSteeringNote: active-only gate, completion contract, and no embedded c
/// #226 continuation gate — the outcome when a /loop turn finishes: the loop
/// either runs another turn or stops with a NAMED terminal state (surfaced in
/// the transcript so #219's ledger can later record it verbatim). Budget-free.
+/// One sentence per outcome, because the tag alone misleads: a user reading a
+/// dim "idle" at the end of an unattended run assumes success, when it means
+/// the model stopped WITHOUT finishing. Success and the four failure modes
+/// must not differ by one word.
+pub fn outcomeText(outcome: ContinuationOutcome, iter_cap: u32) []const u8 {
+ _ = iter_cap;
+ return switch (outcome) {
+ .accepted => "done - the work was completed",
+ .idle => "idle - the model stopped without finishing; the work is NOT done",
+ .exhausted => "out of turns - the iteration cap was reached with work still open",
+ .expired => "out of time - the budget ran out with work still open",
+ .blocked => "blocked - it needs you before it can continue",
+ .cancelled => "paused - you stepped in",
+ };
+}
+
pub const ContinuationOutcome = enum {
accepted, // the goal's checklist is complete (or the goal itself is complete)
idle, // the turn did no tool work and asserted nothing - the loop stops, but nothing is done (#318)
@@ -581,20 +597,3 @@ pub fn goalPromptFromLine(line: []const u8) ?[]const u8 {
if (std.ascii.eqlIgnoreCase(g, sub)) return null;
return g;
}
-
-test "goalPromptFromLine: an objective runs a turn, the lifecycle words do not" {
- try std.testing.expectEqualStrings("ship phase 2", goalPromptFromLine("/goal ship phase 2 ").?);
- try std.testing.expect(goalPromptFromLine("/goal ") == null); // bare /goal shows the objective
- try std.testing.expect(goalPromptFromLine("/goal PAUSE") == null); // case-insensitive, like handleCommand
- try std.testing.expectEqualStrings("clear the flaky tests", goalPromptFromLine("/goal clear the flaky tests").?); // merely STARTS with one
-}
-
-test "absolute path prompts are not mistaken for slash commands" {
- try std.testing.expect(isSlashCommandLine("/"));
- try std.testing.expect(isSlashCommandLine("/help"));
- try std.testing.expect(isSlashCommandLine("/bash echo hi"));
- try std.testing.expect(isSlashCommandLine("/not-a-command"));
-
- try std.testing.expect(!isSlashCommandLine("/System/Library/PrivateFrameworks/StorageManagement.framework/PlugIns/StorageManagementService what causes this to start"));
- try std.testing.expect(!isSlashCommandLine("/Users/blackfloofie/codedb/src/main.zig explain this"));
-}