graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(playbook): let a user retire a standing constraint (#638)
Cursor Agent74eda29dc893
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b28be757..90f016dc 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,10 @@ current is part of cutting a release.from the first call. `graff serve` is not required (#637).- `graff acp` emits mid-turn `session/update`s for thought, text, and`tool_call` / `tool_call_update` (ADR 0032). Protocol version stays 1.+ After `session/new` it advertises `/never` via `available_commands_update`.+- A user can retire a standing constraint from ACP or the REPL:+ `/never rm <id-or-text>`, or an explicit forget/override in the next+ message (ADR 0033, #638). The model still cannot.- Existing Tauri `gui/` is unchanged. No `v0.0.279` tag until asked.## v0.0.278 (2026-08-26)diff --git a/README.md b/README.mdindex be9926ad..73aa676e 100644--- a/README.md+++ b/README.md@@ -624,7 +624,8 @@ gateway rollouts appear without a restart./loop [30m] <prompt> the same autonomous run as /goal, without adopting a standing objective/review <target or instructions>run one isolated read-only review pass; no edits, delegation, or workflows-/never [<text>|rm <id>] standing constraints that ride every subagent brief and survive compaction; bare lists them, rm <id> retires one (alias /constraint)+/never [<text>|rm <id-or-text>]+ standing constraints that ride every subagent brief and survive compaction; bare lists them, rm <id-or-text> retires one (alias /constraint)/tell <session|all> <text>message a running graff: <session> is a DM (only it hears, any folder); all broadcasts to every graff on this device; /sessions lists who's around/peek <session> see what a live co-resident session is doing right now (its transcript tail)diff --git a/apps/native/lib/acp-client.ts b/apps/native/lib/acp-client.tsindex 4a75f6b0..6579475b 100644--- a/apps/native/lib/acp-client.ts+++ b/apps/native/lib/acp-client.ts@@ -99,6 +99,7 @@ export const STARTER_PROMPTS = [{ id: "readme", label: "Summarize README.md", prompt: "Read README.md and summarize it in a short paragraph." },{ id: "review", label: "Review the last commit", prompt: "Review HEAD against the previous commit. Stay read-only." },{ id: "todos", label: "What's on the checklist?", prompt: "Read the current todo list and tell me what's open." },+ { id: "never", label: "List standing constraints", prompt: "/never" },] as const;export const MODELS = [diff --git a/docs/adr/0032-acp-streams-mid-turn.md b/docs/adr/0032-acp-streams-mid-turn.mdindex 9ea2e691..f5d074d2 100644--- a/docs/adr/0032-acp-streams-mid-turn.md+++ b/docs/adr/0032-acp-streams-mid-turn.md@@ -31,7 +31,11 @@ A stub turn that emits no events still writes one finaltext returns `""` so the final chunk is not duplicated.Between prompts both writers are null (stdout stays JSON-RPC). Protocol-version stays 1 for Zed. `session/cancel` sets `esc_cancel`.+version stays 1 for Zed (we speak the+[v1 session/update shapes](https://agentclientprotocol.com/protocol/v1/tool-calls),+not the v2 upsert). `session/cancel` sets `esc_cancel` and the prompt+result uses `stopReason: cancelled` when that latch is set. After+`session/new` the agent advertises `/never` via `available_commands_update`.`session/request_permission` is not implemented: unattended + `--yolo` ishow a UI that wants tools from the first call runs the agent.diff --git a/docs/adr/0033-user-can-retire-a-standing-constraint.md b/docs/adr/0033-user-can-retire-a-standing-constraint.mdnew file mode 100644index 00000000..48eda9c5--- /dev/null+++ b/docs/adr/0033-user-can-retire-a-standing-constraint.md@@ -0,0 +1,36 @@+# 0033. Only the user can retire a standing constraint; `/never` works over ACP++Status: accepted 2026-08-26++## Context++`note_constraint` is append-only on purpose (#381): a model that finds a+rule inconvenient must not be able to delete it. The documented retire+path was `/never rm <id>` in the REPL. ACP clients (Zed, the native+app) send `/never` as a `session/prompt` body, so it was forwarded to+the model and the ledger never moved. A later user override then sat+under a still-injected `HARD CONSTRAINTS` block (#638).++## Decision++The model still cannot retire a constraint. The user can, three ways:++1. `/never` / `/constraint` in the REPL, as before.+2. The same line as an ACP `session/prompt` (intercepted locally; not a+ model turn). After `session/new` the agent advertises these as ACP+ `available_commands_update` entries (v1 schema).+3. An explicit override in the current user message (`forget` /+ `override` / `retire` / …) that names an id `pb-…` or uniquely+ matches one live item. The ledger is tombstoned and the prefix+ refreshed *before* the model turn, so the stale rule is gone from+ `HARD CONSTRAINTS`.++`/never rm` accepts an id **or** a unique text fragment. Ambiguous+matches refuse rather than pick.++## Consequences++- A native/Zed user can list and drop constraints without the REPL.+- A vague "do it anyway" does **not** retire a rule; the user must+ name it or use retire language plus a unique match.+- `note_constraint` stays append-only.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex aa6b60a9..83e9148f 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -43,6 +43,7 @@ record only when you need the evidence or the edge cases.| [0030](0030-rlm-late-showcase.md) | Small turns hide `rlm` (and sPTC). Showcase on `--rlm`, a ≥4 native batch, context ≥50% of compactAt, or an explicit load — never on MCP fan-out or the prefix. || [0031](0031-xai-hosted-x-search.md) | xAI Responses splices hosted `x_search` onto tools turns. It is not a catalog function; `GRAFF_XAI_X_SEARCH=0` opts out. || [0032](0032-acp-streams-mid-turn.md) | `graff acp` streams thought / tool / text `session/update`s mid-turn. The native app is an ACP client; it does not need `graff serve`. |+| [0033](0033-user-can-retire-a-standing-constraint.md) | Only the user retires a standing constraint: `/never` (REPL or ACP prompt) or an explicit override in the current message. The model cannot. |## When to write onediff --git a/docs/releases/v0.0.279.md b/docs/releases/v0.0.279.mdindex 279eeb0e..27c34c68 100644--- a/docs/releases/v0.0.279.md+++ b/docs/releases/v0.0.279.md@@ -46,8 +46,17 @@ cd apps/native && npm install && npm run devThe existing Tauri app in `gui/` is unchanged.+## Standing constraints (#638)++`/never` is an ACP slash command (`available_commands_update` after+`session/new`) and is intercepted as a local prompt, so a native/Zed+user can list and retire rules without the REPL. `rm` accepts an id or+a unique text fragment. An explicit "forget / override that rule" in+the next user message tombstones the matching item before the model+turn (ADR 0033). `note_constraint` stays append-only.+## TestsUnit suite grows by the ACP translator cases (`kindFor`, thought/text-chunks, minted tool ids, EventSink). Floor stays **1683** from the 278-ratchet (slack 25).+chunks, minted tool ids, EventSink) plus the #638 retire/override+cases. Floor stays **1683** from the 278 ratchet (slack 25).diff --git a/src/acp.zig b/src/acp.zigindex c0d07c8f..1b688443 100644--- a/src/acp.zig+++ b/src/acp.zig@@ -29,6 +29,7 @@ const telemetry = @import("telemetry.zig");const util = @import("util.zig");const proto = @import("acp_protocol.zig");const stream = @import("acp_stream.zig");+const playbook_glue = @import("playbook_glue.zig");pub const protocol_version = proto.protocol_version;pub const err_method_not_found = proto.err_method_not_found;@@ -78,6 +79,16 @@ fn promptTurn(d: *Dispatch, arena: Allocator, w: *Io.Writer, req: Request) !void};if (d.live) |live| live.session_id = sid;const text = try flattenPrompt(arena, if (obj) |o| o.get("prompt") else null);+ if (playbook_glue.isCommand(text)) {+ if (d.live) |live| {+ var aw: Io.Writer.Allocating = .init(arena);+ _ = try playbook_glue.command(live.root, arena, text, &aw.writer);+ const plain = try stripSgr(arena, aw.writer.buffered());+ if (plain.len > 0) try writeSessionUpdate(w, sid, plain);+ return respond(w, req, .{ .stopReason = "end_turn" });+ }+ }+ if (d.live) |live| _ = playbook_glue.applyUserOverride(live.root, arena, text);const final = d.turn(d.ctx, arena, text) catch |err| {if (err == error.RunBudgetExhausted)return respond(w, req, .{ .stopReason = "max_turn_requests" });@@ -87,19 +98,42 @@ fn promptTurn(d: *Dispatch, arena: Allocator, w: *Io.Writer, req: Request) !void// publish the final answer as one chunk. A live turn that already// streamed `agent_message_chunk` returns "" so we do not duplicate.if (final.len > 0) try writeSessionUpdate(w, sid, final);- try respond(w, req, .{ .stopReason = "end_turn" });+ const stop: []const u8 = if (agent_mod.Agent.esc_cancel.load(.acquire)) "cancelled" else "end_turn";+ try respond(w, req, .{ .stopReason = stop });+}++fn stripSgr(arena: Allocator, s: []const u8) ![]const u8 {+ var buf: std.array_list.Managed(u8) = .init(arena);+ var i: usize = 0;+ while (i < s.len) {+ if (s[i] == 0x1b and i + 1 < s.len and s[i + 1] == '[') {+ i += 2;+ while (i < s.len and (s[i] < '@' or s[i] > '~')) i += 1;+ if (i < s.len) i += 1;+ continue;+ }+ try buf.append(s[i]);+ i += 1;+ }+ return buf.items;}pub fn handleLine(d: *Dispatch, arena: Allocator, w: *Io.Writer, line: []const u8) !void {const req = parseRequest(arena, line) orelse return;if (std.mem.eql(u8, req.method, "initialize")) return respond(w, req, .{.protocolVersion = negotiateVersion(req.params),- .agentCapabilities = .{ .loadSession = false, .promptCapabilities = proto.PromptCapabilities{} },+ .agentCapabilities = .{+ .loadSession = false,+ .promptCapabilities = proto.PromptCapabilities{},+ },+ .agentImplementation = proto.AgentImplementation{ .version = main_mod.harness_version },});if (std.mem.eql(u8, req.method, "session/new")) {d.created += 1;d.session_id = try std.fmt.allocPrint(arena, "acp-{x}-{d}", .{ d.seed, d.created });- return respond(w, req, .{ .sessionId = d.session_id.? });+ try respond(w, req, .{ .sessionId = d.session_id.? });+ try proto.writeAvailableCommands(w, d.session_id.?, proto.slashCommands());+ return;}if (std.mem.eql(u8, req.method, "session/cancel")) {agent_mod.Agent.esc_cancel.store(true, .release);@@ -291,14 +325,19 @@ test "handleLine: initialize, session/new, then a prompt turn" {var d: Dispatch = .{ .turn = echoTurn, .ctx = undefined, .seed = 0xabc };try handleLine(&d, a, &w, "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":9,\"clientCapabilities\":{\"fs\":{}}}}");- try testing.expectEqualStrings(- "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"protocolVersion\":1,\"agentCapabilities\":{\"loadSession\":false,\"promptCapabilities\":{}}}}\n",- w.buffered(),- );+ const init_line = w.buffered();+ try testing.expect(std.mem.indexOf(u8, init_line, "\"protocolVersion\":1") != null);+ try testing.expect(std.mem.indexOf(u8, init_line, "\"embeddedContext\":true") != null);+ try testing.expect(std.mem.indexOf(u8, init_line, "\"name\":\"graff\"") != null);+ try testing.expect(std.mem.indexOf(u8, init_line, "\"loadSession\":false") != null);w = .fixed(&buf);try handleLine(&d, a, &w, "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"session/new\",\"params\":{\"cwd\":\"/tmp\"}}");- try testing.expectEqualStrings("{\"jsonrpc\":\"2.0\",\"id\":2,\"result\":{\"sessionId\":\"acp-abc-1\"}}\n", w.buffered());+ var new_lines = std.mem.splitScalar(u8, w.buffered(), '\n');+ try testing.expectEqualStrings("{\"jsonrpc\":\"2.0\",\"id\":2,\"result\":{\"sessionId\":\"acp-abc-1\"}}", new_lines.next().?);+ const cmds = new_lines.next().?;+ try testing.expect(std.mem.indexOf(u8, cmds, "available_commands_update") != null);+ try testing.expect(std.mem.indexOf(u8, cmds, "\"name\":\"never\"") != null);try testing.expectEqualStrings("acp-abc-1", d.session_id.?);w = .fixed(&buf);diff --git a/src/acp_protocol.zig b/src/acp_protocol.zigindex 512197ee..11beacb6 100644--- a/src/acp_protocol.zig+++ b/src/acp_protocol.zig@@ -14,8 +14,27 @@ pub const protocol_version: i64 = 1;pub const err_method_not_found: i32 = -32601;pub const err_internal: i32 = -32603;-/// ACP's `promptCapabilities` — named empty struct, not `.{}` (that is a tuple).-pub const PromptCapabilities = struct {};+/// ACP v1 `promptCapabilities` (https://agentclientprotocol.com/protocol/v1/schema).+/// Missing keys default to false; we send the three named fields so a client+/// does not have to guess. `embeddedContext` is on because flattenPrompt+/// already lifts `resource_link` blocks into the user text.+pub const PromptCapabilities = struct {+ image: bool = false,+ audio: bool = false,+ embeddedContext: bool = true,+};++pub const AgentImplementation = struct {+ name: []const u8 = "graff",+ title: []const u8 = "graff",+ version: []const u8,+};++pub const AvailableCommand = struct {+ name: []const u8,+ description: []const u8,+ input: struct { hint: []const u8 },+};pub const Request = struct {id: ?Value = null,@@ -122,3 +141,29 @@ pub fn writeSessionUpdate(w: *Io.Writer, session_id: []const u8, text: []const u},});}++/// ACP v1 slash-command advertisement (`available_commands_update`).+pub fn writeAvailableCommands(w: *Io.Writer, session_id: []const u8, commands: []const AvailableCommand) !void {+ try writeNotification(w, "session/update", .{+ .sessionId = session_id,+ .update = .{+ .sessionUpdate = "available_commands_update",+ .availableCommands = commands,+ },+ });+}++pub fn slashCommands() []const AvailableCommand {+ return &.{+ .{+ .name = "never",+ .description = "List, add, or retire a standing constraint. Bare lists them; `rm <id-or-text>` retires one.",+ .input = .{ .hint = "[<text>|rm <id-or-text>]" },+ },+ .{+ .name = "constraint",+ .description = "Alias for never.",+ .input = .{ .hint = "[<text>|rm <id-or-text>]" },+ },+ };+}diff --git a/src/cli.zig b/src/cli.zigindex 133424b0..e46a41f9 100644--- a/src/cli.zig+++ b/src/cli.zig@@ -23,7 +23,8 @@ pub const changelog_text =\\──────────\\0.0.279\\ • native Beautiful UI app speaks ACP: thinking and tool chips stream mid-turn (ADR 0032)- \\ • graff acp emits thought / tool_call / text session/update; graff serve is not required+ \\ • graff acp emits thought / tool_call / text session/update; /never is an ACP slash command+ \\ • a user can retire a standing constraint from ACP or /never rm (ADR 0033, #638)\\\\0.0.278\\ • deleted composer screenshots are not sent: submit keeps [Image #N] / @[path] only (#634)diff --git a/src/command_catalog.zig b/src/command_catalog.zigindex 8c35ddf2..31fccf00 100644--- a/src/command_catalog.zig+++ b/src/command_catalog.zig@@ -29,7 +29,7 @@ pub const commands = [_]Item{.{ .name = "/goal", .usage = "/goal [30m] [text|pause|resume|status|clear]", .desc = "set a standing objective and work it autonomously; an optional 30s/30m/2h budget paces the run; pause/resume steering, status shows state, clear removes it" },.{ .name = "/loop", .usage = "/loop [30m] <prompt>", .desc = "the same autonomous run as /goal, without adopting a standing objective" },.{ .name = "/review", .usage = "/review <target or instructions>", .desc = "run one isolated read-only review pass; no edits, delegation, or workflows" },- .{ .name = "/never", .usage = "/never [<text>|rm <id>]", .desc = "standing constraints that ride every subagent brief and survive compaction; bare lists them, rm <id> retires one (alias /constraint)" },+ .{ .name = "/never", .usage = "/never [<text>|rm <id-or-text>]", .desc = "standing constraints that ride every subagent brief and survive compaction; bare lists them, rm <id-or-text> retires one (alias /constraint)" },.{ .name = "/tell", .usage = "/tell <session|all> <text>", .desc = "message a running graff: <session> is a DM (only it hears, any folder); all broadcasts to every graff on this device; /sessions lists who's around" },.{ .name = "/peek", .usage = "/peek <session>", .desc = "see what a live co-resident session is doing right now (its transcript tail)" },.{ .name = "/routes", .usage = "/routes [<set>|add <set> <frontier|mid|small> <provider/model>]", .desc = "your own priced model lanes across providers — view the set and which seat wins each lane now" },diff --git a/src/playbook.zig b/src/playbook.zigindex 20c5aec1..1e2c9cc8 100644--- a/src/playbook.zig+++ b/src/playbook.zig@@ -221,6 +221,25 @@ pub fn find(items: []const Item, id: []const u8) ?Item {return null;}+/// Unique live item whose normalized text contains `query`, or whose text+/// is contained in `query`. Ambiguous / too-short queries return null so a+/// caller can ask for an id instead of retiring the wrong rule (#638).+pub fn findByUniqueText(items: []const Item, query: []const u8) ?Item {+ var qbuf: [max_text]u8 = undefined;+ const q = normalize(&qbuf, query);+ if (q.len < 4) return null;+ var found: ?Item = null;+ for (items) |item| {+ var ibuf: [max_text]u8 = undefined;+ const it = normalize(&ibuf, item.text);+ if (it.len == 0) continue;+ if (std.mem.indexOf(u8, it, q) == null and std.mem.indexOf(u8, q, it) == null) continue;+ if (found != null) return null;+ found = item;+ }+ return found;+}+/// Append one already-serialized record. Positional write at the current end/// of file so a whole line lands at once (serve_events.EventLog's shape).fn appendLine(io: Io, line: []const u8) bool {diff --git a/src/playbook_glue.zig b/src/playbook_glue.zigindex ee9c2db5..f86ef15e 100644--- a/src/playbook_glue.zig+++ b/src/playbook_glue.zig@@ -81,20 +81,81 @@ fn list(io: Io, arena: Allocator, out: *Io.Writer) !void {}try out.print("{s}playbook{s} — {s}\n", .{ style.bold, style.reset, playbook.path });for (items) |item| try out.print(" {s} {s:<9} {s}\n", .{ item.id, @tagName(item.source), item.text });- try out.print("{d} item(s) · /never <text> adds one · /never rm <id> retires one\n", .{items.len});+ try out.print("{d} item(s) · /never <text> adds one · /never rm <id-or-text> retires one\n", .{items.len});try out.flush();}+pub fn isCommand(line: []const u8) bool {+ const t = std.mem.trim(u8, line, " \t\r");+ for ([_][]const u8{ "/never", "/constraint" }) |name| {+ if (std.mem.eql(u8, t, name)) return true;+ if (std.mem.startsWith(u8, t, name) and t.len > name.len and t[name.len] == ' ') return true;+ }+ return false;+}++fn wantsRetire(text: []const u8) bool {+ var nbuf: [playbook.max_text]u8 = undefined;+ const n = playbook.normalize(&nbuf, text);+ for ([_][]const u8{+ "retire",+ "forget",+ "override",+ "supersede",+ "never mind",+ "no longer",+ "stop following",+ "you can now",+ "drop the constraint",+ "remove the constraint",+ "ignore the",+ "ignore that",+ }) |verb| {+ if (std.mem.indexOf(u8, n, verb) != null) return true;+ }+ return false;+}++fn extractPlaybookId(text: []const u8) ?[]const u8 {+ const start = std.mem.indexOf(u8, text, "pb-") orelse return null;+ const rest = text[start..];+ if (rest.len < 11) return null;+ for (rest[3..11]) |c| if (!std.ascii.isHex(c)) return null;+ return rest[0..11];+}++/// When the current user message explicitly asks to drop a standing rule,+/// tombstone the matching live item and refresh the prefix (#638). The+/// model still cannot retire a constraint on its own — only this user+/// message, or `/never rm`, can. Returns how many items left the ledger.+pub fn applyUserOverride(root: *Agent, arena: Allocator, user_text: []const u8) usize {+ if (root.sub or !wantsRetire(user_text)) return 0;+ const items = playbook.load(root.io, arena);+ if (items.len == 0) return 0;+ var n: usize = 0;+ if (extractPlaybookId(user_text)) |id| {+ if (playbook.retire(root.io, arena, id)) n += 1;+ } else if (playbook.findByUniqueText(items, user_text)) |item| {+ if (playbook.retire(root.io, arena, item.id)) n += 1;+ }+ if (n > 0) {+ @import("prompt_cache_hud.zig").noteBust(.playbook);+ refreshRoot(root, arena);+ }+ return n;+}+/// `/never` (alias `/constraint`). Returns false when `line` is neither, so/// the caller falls through to the rest of the command chain.////// /never list the live ledger/// /never <text> record a user constraint-/// /never rm <id> retire one (the ONLY removal path there is)+/// /never rm <id|text> retire one (id, or a unique text fragment)pub fn command(root: *Agent, arena: Allocator, line: []const u8, out: *Io.Writer) !bool {+ const trimmed = std.mem.trim(u8, line, " \t\r");const rest = for ([_][]const u8{ "/never", "/constraint" }) |name| {- if (std.mem.eql(u8, line, name)) break "";- if (std.mem.startsWith(u8, line, name) and line.len > name.len and line[name.len] == ' ') break line[name.len + 1 ..];+ if (std.mem.eql(u8, trimmed, name)) break "";+ if (std.mem.startsWith(u8, trimmed, name) and trimmed.len > name.len and trimmed[name.len] == ' ') break trimmed[name.len + 1 ..];} else return false;const arg = std.mem.trim(u8, rest, " \t");if (arg.len == 0) {@@ -102,12 +163,14 @@ pub fn command(root: *Agent, arena: Allocator, line: []const u8, out: *Io.Writerreturn true;}if (std.mem.startsWith(u8, arg, "rm ") or std.mem.startsWith(u8, arg, "remove ")) {- const id = std.mem.trim(u8, arg[if (arg[0] == 'r' and arg[1] == 'm') 3 else 7..], " \t");+ const needle = std.mem.trim(u8, arg[if (arg[0] == 'r' and arg[1] == 'm') 3 else 7..], " \t");+ const items = playbook.load(root.io, arena);+ const id = if (playbook.find(items, needle) != null) needle else if (playbook.findByUniqueText(items, needle)) |item| item.id else needle;if (playbook.retire(root.io, arena, id)) {@import("prompt_cache_hud.zig").noteBust(.playbook);refreshRoot(root, arena);try out.print("retired {s} — it no longer rides new briefs (the record stays in the log as a tombstone)\n", .{id});- } else try out.print("no live playbook item with id '{s}' — /never lists them\n", .{id});+ } else try out.print("no live playbook item matching '{s}' — /never lists them (id or unique text)\n", .{needle});try out.flush();return true;}diff --git a/src/playbook_tests.zig b/src/playbook_tests.zigindex 56d0f000..2e773909 100644--- a/src/playbook_tests.zig+++ b/src/playbook_tests.zig@@ -351,6 +351,28 @@ test "/never (#381): bare lists, text adds, rm retires — and a non-/never line}.body);}+test "/never rm matches unique text and applyUserOverride honors an explicit forget (#638)" {+ try inScratch(struct {+ fn body(io: Io, arena: std.mem.Allocator) !void {+ var aw: Io.Writer.Allocating = .init(arena);+ var root = stubRoot(std.testing.allocator, arena, &aw.writer);+ try std.testing.expect(try glue.command(&root, arena, "/never no navigation dots or scroll hints", &aw.writer));+ try std.testing.expectEqual(@as(usize, 1), playbook.load(io, arena).len);++ aw.clearRetainingCapacity();+ try std.testing.expect(try glue.command(&root, arena, "/never rm navigation dots", &aw.writer));+ try std.testing.expect(std.mem.indexOf(u8, aw.writer.buffered(), "retired") != null);+ try std.testing.expectEqual(@as(usize, 0), playbook.load(io, arena).len);++ try std.testing.expect(try glue.command(&root, arena, "/never never use emojis in comments", &aw.writer));+ try std.testing.expectEqual(@as(usize, 0), glue.applyUserOverride(&root, arena, "please add a comment"));+ try std.testing.expectEqual(@as(usize, 1), playbook.load(io, arena).len);+ try std.testing.expectEqual(@as(usize, 1), glue.applyUserOverride(&root, arena, "forget the standing rule: never use emojis in comments"));+ try std.testing.expectEqual(@as(usize, 0), playbook.load(io, arena).len);+ }+ }.body);+}+test "note_constraint (#381): appends user items only, is idempotent, and can never retire one" {try inScratch(struct {fn body(io: Io, arena: std.mem.Allocator) !void {diff --git a/src/schema.zig b/src/schema.zigindex 24e75608..def811a2 100644--- a/src/schema.zig+++ b/src/schema.zig@@ -138,8 +138,8 @@ const meta_specs = [_]ToolSpec{// #381: the durable-rejection capture surface. Root-only, and APPEND-ONLY// by construction — there is no retire/edit/list operation here at all,// so a model that finds a constraint inconvenient has no mechanism to- // widen it; only the user can, with /never rm <id>.- .{ .name = "note_constraint", .desc = "Record a standing user constraint in this project's playbook (.graff/playbook.jsonl). Call it the moment the user rejects, forbids or vetoes something, passing ONE short imperative line stating what must not happen (e.g. never add scroll hints or progress dots). The recorded line is injected verbatim into every later subagent, workflow and pipeline brief and into your own system context, in this session and in future ones, so it survives compaction and reaches fresh agents that never saw the rejection. Append-only: this tool cannot edit, retire or list items - only the user can, with /never. Recording the same constraint twice is harmless and does nothing.", .schema = "{\"type\": \"object\", \"properties\": {\"text\": {\"type\": \"string\", \"description\": \"One short imperative line in the user's own terms, stating what must not happen\"}}, \"required\": [\"text\"]}" },+ // widen it; only the user can, with /never rm <id-or-text> (#638).+ .{ .name = "note_constraint", .desc = "Record a standing user constraint in this project's playbook (.graff/playbook.jsonl). Call it the moment the user rejects, forbids or vetoes something, passing ONE short imperative line stating what must not happen (e.g. never add scroll hints or progress dots). The recorded line is injected verbatim into every later subagent, workflow and pipeline brief and into your own system context, in this session and in future ones, so it survives compaction and reaches fresh agents that never saw the rejection. Append-only: this tool cannot edit, retire or list items. Only the user can retire one, with /never rm <id-or-text> (REPL or ACP prompt) or by explicitly asking to forget/override that rule in their next message. Recording the same constraint twice is harmless and does nothing.", .schema = "{\"type\": \"object\", \"properties\": {\"text\": {\"type\": \"string\", \"description\": \"One short imperative line in the user's own terms, stating what must not happen\"}}, \"required\": [\"text\"]}" },.{.name = "ask_user",.desc = "Ask the human a question and wait for their reply (typed text and/or pasted images). Images reach you as vision blocks on the next request, same as a normal prompt. Use for a decision, clarification, or missing information.",