graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Replicate claim ledger as Accord progress
justrach8bd4ccc83ee6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 34404a66..ef7a3a19 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,7 +12,7 @@ current is part of cutting a release.## Unreleased-- `#1088`: claims own one artifact. A conflict pings the owner on Accord (JSONL still durable); staging is not a lock; issue create and a new-branch push are not someone else's issue or PR.+- `#1088`: claims own one artifact. Conflicts ping Accord; acquire/release/handoff also replicate as replaceable Accord progress (file ledger stays canonical). Staging is not a lock.- `#1084`: gpt-6-astra `/effort medium` sends medium (no longer remapped to low).- Empty Enter-Enter while a turn is running interrupts (or steers the next queued prompt). It no longer required a queue to arm.- Desktop ACP workers can park after a quiet period (`GRAFF_ACP_IDLE_MS`, default 30s) and `--resume` with the saved cache id. Parking is skipped while a prompt or `session/idle` subscriber is live; tab close still reaps immediately.diff --git a/docs/adr/0145-live-claims-are-accord-progress.md b/docs/adr/0145-live-claims-are-accord-progress.mdnew file mode 100644index 00000000..98b3da46--- /dev/null+++ b/docs/adr/0145-live-claims-are-accord-progress.md@@ -0,0 +1,24 @@+# 0145. Live claim snapshots ride Accord progress; the file stays canonical++Status: accepted 2026-09-20++## Context++ADR 0144 pings the owner on conflict. Peers still had to read+`.graff/artifact-claims.json` to see who owns what. Accord already coalesces+replaceable `progress` frames. Putting the *only* copy of a claim on a Unix+socket would drop ownership when the duplex dies (Windows has no Accord;+`GRAFF_ACCORD=0` opts out).++## Decision++Acquire, release, and handoff still persist the JSON ledger. After a successful+write, the same JSON is sent as replaceable Accord `progress` to every live+peer sock. The file is canonical. Accord is the live replica. `GRAFF_ACCORD=0`+and tests skip the replica.++## Consequences++Live sessions see the newest ownership without polling the file. A dead socket+does not free the claim; pid liveness and the ledger still do. Revisit only if+Accord grows a durable store.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex f83099ae..c44ef9ed 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -164,6 +164,7 @@ record only when you need the evidence or the edge cases.| [0142](0142-zigzag-is-not-a-frontend.md) | Zigzag is not a frontend. TTY `graff repl` is `TUI/`; piped/CI uses a local scripted Model. Do not vendor zigzag. || [0143](0143-release-desktop-is-com-codegraff-app.md) | Packaged Codegraff.app is `com.codegraff.app`. `dev.*` identities are local rebuilds only. || [0144](0144-claim-asks-on-accord.md) | Claim conflicts ping the owner on Accord/JSONL; the model does not broker handoff in chat. |+| [0145](0145-live-claims-are-accord-progress.md) | Claim acquire/release/handoff replicate as replaceable Accord progress; the JSON ledger stays canonical. |## When to write onediff --git a/src/artifact_claim.zig b/src/artifact_claim.zigindex 07e167d5..38010fb5 100644--- a/src/artifact_claim.zig+++ b/src/artifact_claim.zig@@ -56,6 +56,11 @@ fn pingOwner(io: Io, arena: Allocator, owner: Owner, kind: Kind, key: []const u8_ = presence.postToDevice(io, arena, text, owner.session, false);}+fn announceLive(io: Io, arena: Allocator, ledger: *const Ledger) void {+ const json = persistJson(arena, ledger) catch return;+ @import("presence_accord.zig").liveClaim(io, json);+}+// --- process-global ledger (one worktree, many tests swap it) ---var g_ledger: Ledger = .{};@@ -219,6 +224,7 @@ pub fn handleToolIn(arena: Allocator, io: Io, action: []const u8, kind_s: []conselse => return .{ .text = "claim acquire failed", .is_error = true },};if (tx) |transaction| transaction.write(try persistJson(scratch.allocator(), ledger)) catch return .{ .text = "claim was NOT persisted; retry before publishing", .is_error = true };+ announceLive(io, scratch.allocator(), ledger);return .{ .text = msg, .is_error = false };}if (std.mem.eql(u8, action, "release")) {@@ -229,6 +235,7 @@ pub fn handleToolIn(arena: Allocator, io: Io, action: []const u8, kind_s: []cons.is_error = true,};if (tx) |transaction| transaction.write(try persistJson(scratch.allocator(), ledger)) catch return .{ .text = "claim was NOT persisted; retry before publishing", .is_error = true };+ announceLive(io, scratch.allocator(), ledger);return .{ .text = msg, .is_error = false };}if (std.mem.eql(u8, action, "handoff")) {@@ -253,6 +260,7 @@ pub fn handleToolIn(arena: Allocator, io: Io, action: []const u8, kind_s: []conselse => return .{ .text = "handoff failed", .is_error = true },};if (tx) |transaction| transaction.write(try persistJson(scratch.allocator(), ledger)) catch return .{ .text = "claim was NOT persisted; retry before publishing", .is_error = true };+ announceLive(io, scratch.allocator(), ledger);return .{ .text = msg, .is_error = false };}if (std.mem.eql(u8, action, "status")) {diff --git a/src/presence_accord.zig b/src/presence_accord.zigindex 2c306410..6d78a97e 100644--- a/src/presence_accord.zig+++ b/src/presence_accord.zig@@ -121,11 +121,23 @@ fn sockPath(buf: []u8, chan_name: []const u8) ?[]const u8 {/// Best-effort live send of the same JSONL line already appended to the room./// Never fails the durable write. Fans out to every peer sock in the live dir.pub fn livePost(io: Io, gpa: std.mem.Allocator, chan_name: []const u8, json_line: []const u8) void {+ fanout(io, gpa, chan_name, .msg, .none, json_line);+}++/// Latest claim ledger as replaceable progress. File JSON remains canonical+/// (ADR 0145); Accord coalesces to the newest snapshot.+pub fn liveClaim(io: Io, json: []const u8) void {+ if (builtin.is_test) return;+ const gpa = g_gpa orelse return;+ fanout(io, gpa, "", .progress, accord.Flags.replaceable, json);+}++fn fanout(io: Io, gpa: std.mem.Allocator, chan_name: []const u8, kind: accord.Kind, flags: accord.Flags, payload: []const u8) void {if (!enabled()) return;if (builtin.os.tag == .windows) return;var path_buf: [std.fs.max_path_bytes]u8 = undefined;if (sockPath(&path_buf, chan_name)) |path| {- sendLine(io, gpa, path, json_line) catch {};+ sendFrame(io, gpa, path, kind, flags, payload) catch {};return;}const dir_path = g_dir_path orelse return;@@ -137,7 +149,7 @@ pub fn livePost(io: Io, gpa: std.mem.Allocator, chan_name: []const u8, json_lineif (g_own_name) |own| if (std.mem.eql(u8, entry.name, own)) continue;if (dropDeadSock(io, dir_path, entry.name)) continue;const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir_path, entry.name }) catch continue;- sendLine(io, gpa, path, json_line) catch {};+ sendFrame(io, gpa, path, kind, flags, payload) catch {};}}@@ -308,12 +320,12 @@ fn dropInbound(sess: *accord.Session) void {gpa.destroy(sess);}-fn sendLine(io: Io, gpa: std.mem.Allocator, path: []const u8, json_line: []const u8) !void {+fn sendFrame(io: Io, gpa: std.mem.Allocator, path: []const u8, kind: accord.Kind, flags: accord.Flags, payload: []const u8) !void {const sess = ensureOut(io, gpa, path) orelse return;- sess.send(1, .msg, .none, json_line) catch {+ sess.send(1, kind, flags, payload) catch {dropOut(io, gpa, path);const retry = ensureOut(io, gpa, path) orelse return;- retry.send(1, .msg, .none, json_line) catch {};+ retry.send(1, kind, flags, payload) catch {};};}@@ -556,3 +568,8 @@ test "standing link carries msg, progress, and a reply on one session" {defer halt.deinit(gpa);try std.testing.expectEqual(accord.Kind.stop, halt.kind);}++test "liveClaim is a no-op when Accord is off" {+ test_enabled = false;+ liveClaim(std.testing.io, "[]");+}