graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
docs: REPL, TUI, and GUI share engine messaging
justrachc703d3d158f0
diff --git a/AGENTS.md b/AGENTS.mdindex 1a14e222..a43360eb 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -79,6 +79,14 @@ click missed (overlay, prompt-origin, mid-origin).- If a touched file is already over 600 LOC, do not grow it; move it toward the limit before adding more behavior.- Generated files, vendored dependencies, lockfiles, and machine-produced artifacts are exempt; change their generator or source instead of hand-editing them.+## Engine features are the same on REPL, TUI, and GUI++Messaging (`peer_message`, idle peer mail, Accord live wake) and other+engine-side behavior (turns, tools, compaction, goals) must work the same on+the line REPL, the fullscreen TUI, and the desktop GUI (`graff acp`). Surface+chrome can differ; the engine path cannot. If you add a wake, a latch, or a+delivery rule, wire it on all three in the same change.+## Tests must be reachable- `zig build test` only runs the tests in files the test root pulls in. A new module's `test {}` blocks compile to nothing until something references it, and the suite still reports green.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2d8a79ea..05b4dce2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,7 +12,9 @@ current is part of cutting a release.## Unreleased-- Accord Unix 0600 is a standing duplex per live session (`GRAFF_ACCORD=0` opts out); JSONL stays the durable room (ADR 0134).+- Accord Unix 0600 is a standing duplex per live session (`GRAFF_ACCORD=0` opts out); JSONL stays the durable room (ADR 0134). `/debug` reports Accord session count and RSS.+- Engine messaging (idle peer mail, #1007) is the same latch on line REPL, TUI, and `graff acp`. `/debug` reports Accord session count and RSS.+- Engine messaging (idle peer mail, #1007) is the same latch on line REPL, TUI, and `graff acp`.- `#1001`: idle TUI and line REPL start a turn when the durable peer room has new unread mail (one auto-turn per batch; inbox consume resets).- `#1007`: idle `graff acp` sessions start that same turn; `peer_message` no longer claims delivery waits for a step boundary.- `#1006`: rendered views sit in the transcript without product chrome; desktop appearance tokens ride the turn (ADR 0135).diff --git a/src/obs.zig b/src/obs.zigindex a6be2a03..83c83198 100644--- a/src/obs.zig+++ b/src/obs.zig@@ -334,6 +334,7 @@ pub fn renderHud(w: *Io.Writer) !void {}}try @import("prompt_cache_hud.zig").renderLine(w);+ try @import("presence_accord.zig").renderLine(w);try w.writeAll(" last events\n");var recs: [ring_cap]Record = undefined;const n = recent(&recs);diff --git a/src/peer_idle.zig b/src/peer_idle.zigindex 16562f35..10450c5d 100644--- a/src/peer_idle.zig+++ b/src/peer_idle.zig@@ -1,6 +1,7 @@-//! #1001: idle roots start a turn when the durable room has unread peer mail.-//! JSONL drain is the source of truth; Accord Unix (ADR 0134) is opt-in live-//! on post. One auto-turn per new unread batch — inbox consume resets.+//! #1001 / #1007: idle roots start a turn when the durable room has unread+//! peer mail. Same latch on line REPL, TUI, and graff acp (GUI). JSONL drain+//! is the source of truth; Accord Unix (ADR 0134) is the standing live wake.+//! One auto-turn per new unread batch — inbox consume resets.const std = @import("std");const Io = std.Io;diff --git a/src/presence_accord.zig b/src/presence_accord.zigindex 7fcbf73e..a3a81e15 100644--- a/src/presence_accord.zig+++ b/src/presence_accord.zig@@ -45,6 +45,64 @@ pub fn takePing() bool {return g_ping.swap(false, .acq_rel);}+pub const Stats = struct {+ on: bool,+ inbound: usize = 0,+ outbound: usize = 0,+ connects: u32 = 0,+ session_bytes: usize = 0,+ proc_rss_bytes: usize = 0,+};++/// Accord-held Sessions plus process RSS (for /debug). Session bytes are the+/// standing duplex cost; proc RSS is the whole process, just in case.+pub fn stats() Stats {+ if (!enabled()) return .{ .on = false, .proc_rss_bytes = processRssBytes() };+ var inbound: usize = 0;+ var outbound: usize = 0;+ if (g_io) |io| {+ g_mu.lockUncancelable(io);+ inbound = g_ins.items.len;+ outbound = g_outs.items.len;+ g_mu.unlock(io);+ }+ const n = inbound + outbound;+ return .{+ .on = true,+ .inbound = inbound,+ .outbound = outbound,+ .connects = g_connects.load(.monotonic),+ .session_bytes = n * @sizeOf(accord.Session),+ .proc_rss_bytes = processRssBytes(),+ };+}++pub fn renderLine(w: *Io.Writer) !void {+ const s = stats();+ if (!s.on) {+ try w.writeAll(" accord off\n");+ return;+ }+ try w.print(+ " accord {d} in · {d} out · {d} connects · ~{d} KB sessions · rss {d} KB\n",+ .{+ s.inbound,+ s.outbound,+ s.connects,+ s.session_bytes / 1024,+ s.proc_rss_bytes / 1024,+ },+ );+}++fn processRssBytes() usize {+ if (builtin.os.tag == .windows) return 0;+ var ru: std.c.rusage = std.mem.zeroes(std.c.rusage);+ if (std.c.getrusage(std.c.rusage.SELF, &ru) != 0) return 0;+ const rss: usize = @intCast(@max(ru.maxrss, 0));+ return if (builtin.os.tag == .linux) rss * 1024 else rss;+}+fn sockPath(buf: []u8, chan_name: []const u8) ?[]const u8 {_ = chan_name;if (builtin.is_test) return test_sock;@@ -342,6 +400,17 @@ const Pair = struct {test "Accord live path is off in tests unless enabled" {try std.testing.expect(!test_enabled);try std.testing.expect(!enabled());+ const s = stats();+ try std.testing.expect(!s.on);+}++test "Accord stats report session RSS when enabled" {+ test_enabled = true;+ defer test_enabled = false;+ const s = stats();+ try std.testing.expect(s.on);+ try std.testing.expectEqual(@as(usize, 0), s.inbound);+ try std.testing.expectEqual(@as(usize, 0), s.outbound);}test "listen binds a 0600 sock and stop unlinks it" {diff --git a/src/readline.zig b/src/readline.zigindex a079d0f5..28690673 100644--- a/src/readline.zig+++ b/src/readline.zig@@ -186,9 +186,11 @@ pub fn readLine(input_util.g_shine_phase +%= 1;redraw(out, buf.items, cur, marks.items, &pastes, &rstate, prompt_col);}- // #1001: empty composer polls so peer mail can start a turn without a key.+ // #1001 / #1007: empty composer polls so peer mail can start a turn+ // without a key — same latch as TUI idleWakeCb and graff acp.if (buf.items.len == 0) {- while (!inputPendingTimed(200)) {+ const idle_ms: i32 = if (@import("presence_accord.zig").enabled()) 50 else 200;+ while (!inputPendingTimed(idle_ms)) {var wake_buf: [512]u8 = undefined;if (peer_idle.takeIdleWake(root.io, &wake_buf)) |wake| {buf.appendSlice(gpa, wake) catch break;diff --git a/src/tui_launch.zig b/src/tui_launch.zigindex a1a692d2..17f3b953 100644--- a/src/tui_launch.zig+++ b/src/tui_launch.zig@@ -214,6 +214,7 @@ fn idleWakeCb(ctx: ?*anyopaque, buf: []u8) ?[]const u8 {if (job_notify.takeIdleWake(c.io, buf)) |t| return t; // an idle stop waits for a real step boundary (#199)if (schedule.takeWake(c.io, buf)) |t| return t;if (channel_worker.takeWake(c.io, buf)) |t| return t;+ _ = @import("presence_accord.zig").takePing(); // standing link; JSONL is still the drainreturn peer_idle.takeIdleWake(c.io, buf);}