graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Forward ongoing review checkpoints through ACP
justrach0c938017dfc1
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 4fc687e3..29f2374b 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -122,6 +122,7 @@ jobs:python3 scripts/test-review-mode.py zig-out/bin/graffpython3 scripts/test-review-deadline.py zig-out/bin/graffpython3 scripts/test-review-acp.py zig-out/bin/graff+ python3 scripts/test-review-acp-checkpoint.py zig-out/bin/graff- name: Automatic learning bootstrap and its idle-workspace guardrun: python3 scripts/test-learn-auto-init.py zig-out/bin/graffdiff --git a/docs/review-guardrails.md b/docs/review-guardrails.mdindex cc2bcac9..f9aa01e9 100644--- a/docs/review-guardrails.md+++ b/docs/review-guardrails.md@@ -25,10 +25,11 @@ zig buildpython3 scripts/test-review-mode.py zig-out/bin/graffpython3 scripts/test-review-deadline.py zig-out/bin/graffpython3 scripts/test-review-acp.py zig-out/bin/graff+python3 scripts/test-review-acp-checkpoint.py zig-out/bin/graffpython3 scripts/eval-tier2.py --only review-checkpoint-preserves-unfinished-scope```-The three process regressions also run in CI. Set `GRAFF_REVIEW_EVIDENCE` to a private directory+The four process regressions also run in CI. Set `GRAFF_REVIEW_EVIDENCE` to a private directorywhen running the deadline test to retain its protocol events and harness traces.These are scripted-model regressions of the actual harness, not a claim aboutan unscripted model's review quality.@@ -38,3 +39,7 @@ matching start and finish record; failed or cancelled reviews remain failed inthe record. Recording happens before the isolated review context is restored.The ACP regression checks these records alongside read-only enforcement andnormal follow-up recovery.++ACP forwards checkpoint notices as ongoing progress. They do not end the turn+or replace the final answer; the long-review regression verifies additional+inspection after the notice and delivery of the eventual report.diff --git a/scripts/test-review-acp-checkpoint.py b/scripts/test-review-acp-checkpoint.pynew file mode 100644index 00000000..0a4fca19--- /dev/null+++ b/scripts/test-review-acp-checkpoint.py@@ -0,0 +1,135 @@+#!/usr/bin/env python3+"""Long review through real ACP transport, with scripted model replies."""++import importlib.util, json, os, pathlib, queue, signal, subprocess, sys, tempfile, threading, time++root = pathlib.Path(__file__).resolve().parents[1]+binary = (+ pathlib.Path(sys.argv[1]).resolve()+ if len(sys.argv) > 1+ else root / "zig-out/bin/graff"+)+out = (+ pathlib.Path(os.environ["GRAFF_REVIEW_EVIDENCE"])+ if os.environ.get("GRAFF_REVIEW_EVIDENCE")+ else None+)+if out:+ out.mkdir(parents=True, exist_ok=True)+sys.path.insert(0, str(root / "scripts"))+sys.argv = [str(root / "scripts/test-review-mode.py"), str(binary)]+spec = importlib.util.spec_from_file_location(+ "review_fixture", root / "scripts/test-review-mode.py"+)+f = importlib.util.module_from_spec(spec)+spec.loader.exec_module(f)+++def reply(r):+ if r.ordinal <= 21:+ return f.tool("read_file", {"path": "target.txt"}, r.ordinal)+ return f.message("Review result after the checkpoint.", r.ordinal)+++with tempfile.TemporaryDirectory(prefix="graff-review-acp-probe-") as tmp:+ pathlib.Path(tmp, "target.txt").write_text("original")+ mock = f.CodexMock(events_for_request=reply)+ port = mock.start()+ proc = subprocess.Popen(+ [+ str(binary),+ "acp",+ "--model",+ "codex",+ "--old",+ "--yolo",+ "--max-model-calls",+ "24",+ ],+ cwd=tmp,+ env=f.environment(tmp, port),+ stdin=subprocess.PIPE,+ stdout=subprocess.PIPE,+ stderr=subprocess.DEVNULL,+ text=True,+ start_new_session=True,+ )+ q = queue.Queue()+ events = []+ counter = 0++ def read():+ for l in proc.stdout:+ try:+ q.put(json.loads(l))+ except ValueError:+ pass+ q.put(None)++ threading.Thread(target=read, daemon=True).start()++ def call(method, params):+ global counter+ counter += 1+ proc.stdin.write(+ json.dumps(dict(jsonrpc="2.0", id=counter, method=method, params=params))+ + "\n"+ )+ proc.stdin.flush()+ end = time.monotonic() + 20+ while True:+ v = q.get(timeout=max(0.01, end - time.monotonic()))+ assert v is not None, "ACP stopped"+ events.append(v)+ if v.get("id") == counter:+ return v++ try:+ call("initialize", {"protocolVersion": 1})+ res = call("session/new", {})+ sid = res["result"]["sessionId"]+ response = call(+ "session/prompt",+ {+ "sessionId": sid,+ "prompt": [{"type": "text", "text": "/review target.txt"}],+ },+ )+ requests = [r.body for r in mock.recorded_requests()]+ result = dict(+ response=response,+ model_calls=len(requests),+ file=pathlib.Path(tmp, "target.txt").read_text(),+ events=events,+ )+ assert len(requests) == 22, len(requests)+ assert result["file"] == "original"+ assert response["result"]["stopReason"] == "end_turn"+ checkpoint = [+ i+ for i, v in enumerate(events)+ if "findings checkpoint was requested" in json.dumps(v)+ ]+ assert len(checkpoint) == 1, checkpoint+ later = [+ v.get("params", {}).get("update", {}).get("sessionUpdate")+ for v in events[checkpoint[0] + 1 :]+ ]+ assert "tool_call" in later, "Checkpoint prematurely ended review"+ assert "Review result after the checkpoint." in json.dumps(events), (+ "Final answer lost"+ )+ assert "Review checkpoint:" in json.dumps(requests[20]), (+ "Model did not receive checkpoint request"+ )+ if out:+ (out / "result.json").write_text(json.dumps(result, indent=2))+ (out / "requests.json").write_text(json.dumps(requests, indent=2))+ print(+ "PASS: ACP checkpoint is visible, the review continues inspecting, and the final answer arrives"+ )++ finally:+ os.killpg(proc.pid, signal.SIGTERM)+ proc.wait(timeout=5)+ mock.stop()diff --git a/src/acp_stream.zig b/src/acp_stream.zigindex b562f374..9a9a743c 100644--- a/src/acp_stream.zig+++ b/src/acp_stream.zig@@ -125,9 +125,17 @@ pub fn translateEvent(ev: Value,id_buf: *[64]u8,next_tool: *u32,-) !enum { none, thought, text, tool } {+) !enum { none, thought, text, tool, notice } {if (ev != .object) return .none;const typ = util.strFieldObj(ev.object, "type") orelse return .none;+ if (std.mem.eql(u8, typ, "review_checkpoint")) {+ const text = util.strFieldObj(ev.object, "text") orelse return .none;+ if (text.len == 0) return .none;+ try writeMessage(w, session_id, "\n\n");+ try writeMessage(w, session_id, text);+ try writeMessage(w, session_id, "\n\n");+ return .notice;+ }if (std.mem.eql(u8, typ, "reasoning")) {const text = util.strFieldObj(ev.object, "text") orelse return .none;if (text.len == 0) return .none;@@ -243,6 +251,10 @@ pub const EventSink = struct {self.saw_text.* = true;self.streamed_any = true;},+ .notice => {+ self.saw_text.* = false;+ self.streamed_any = true;+ },.tool => self.saw_text.* = false,else => {},}@@ -435,3 +447,19 @@ test "parallel tool results retain their own IDs including long IDs" {try std.testing.expectEqualStrings(id, update.object.get("toolCallId").?.string);}}++test "review checkpoints stream a notice without suppressing the final answer" {+ var output: Io.Writer.Allocating = .init(testing.allocator);+ defer output.deinit();+ var session_id: []const u8 = "review-session";+ var saw_text = true;+ var sink: EventSink = undefined;+ sink.init(testing.allocator, &output.writer, &session_id, &saw_text);+ defer sink.deinit();+ try sink.writer.writeAll("{\"type\":\"review_checkpoint\",\"text\":\"Review remains in progress.\",\"complete\":false}\n");+ try sink.writer.flush();+ try testing.expect(!saw_text);+ try testing.expect(sink.streamed_any);+ try testing.expect(std.mem.indexOf(u8, output.writer.buffered(), "Review remains in progress.") != null);+ try testing.expect(std.mem.indexOf(u8, output.writer.buffered(), "stopReason") == null);+}