graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix: pin the learn kit with Dir.hardLink and let the detached bootstrap settle
Rach Pradhan08bb57c1e320
diff --git a/scripts/test-learn-auto-init.py b/scripts/test-learn-auto-init.pyindex c5fb0368..320e04d1 100644--- a/scripts/test-learn-auto-init.py+++ b/scripts/test-learn-auto-init.py@@ -12,6 +12,7 @@ import jsonimport osimport sysimport tempfile+import timefrom codex_ws_mock import CodexMock, turn_eventsfrom pty_harness import PtySession@@ -102,9 +103,14 @@ def main() -> None:text = run_session(tmp, port, prompts=MINIMUM_CALLS)workspace = os.path.join(tmp, "workspace")active = os.path.join(workspace, ".graff", "learn", "refs", "active.json")+ # The bootstrap is detached (ADR 0044): the session exits without+ # waiting on suite generation, so the store lands seconds later.+ deadline = time.monotonic() + 120.0+ while not os.path.exists(active) and time.monotonic() < deadline:+ time.sleep(1.0)if not os.path.exists(active):raise AssertionError(f"no learning store was configured\n{text[-3000:]}")- if "learning on for this workspace" not in text:+ if "learning setup started in the background" not in text:raise AssertionError(f"the session never said it turned learning on\n{text[-3000:]}")if not os.path.exists(os.path.join(workspace, ".graff", "learn-auto-init")):raise AssertionError("the one-shot bootstrap marker was not claimed")@@ -114,15 +120,21 @@ def main() -> None:if not config.get("auto", {}).get("enabled"):raise AssertionError("a self-configured store cannot promote anything")- # The bootstrapping session counts as the first toward the cadence,- # and must not itself spend a trial's worth of model calls.+ # The bootstrap is detached, so the cadence starts with the NEXT+ # session that finds the store (ADR 0044): one short session must+ # land exactly one on the counter, and neither session may spend a+ # trial's worth of model calls.+ run_session(tmp, port, prompts=1)auto_json = os.path.join(workspace, ".graff", "learn", "refs", "auto.json")+ deadline = time.monotonic() + 30.0+ while not os.path.exists(auto_json) and time.monotonic() < deadline:+ time.sleep(1.0)with open(auto_json, encoding="utf-8") as fh:record = json.load(fh)if record.get("sessions_since_trial") != 1:- raise AssertionError(f"bootstrapping session was not counted: {record}")+ raise AssertionError(f"the session after the bootstrap was not counted: {record}")if record.get("trials_started"):- raise AssertionError(f"a trial ran on the bootstrapping session: {record}")+ raise AssertionError(f"a trial ran before the cadence was due: {record}")print("ok a working session configured its own store and started the cadence")finally:mock.stop()diff --git a/src/learn_bootstrap.zig b/src/learn_bootstrap.zigindex 7cf33667..db1675c9 100644--- a/src/learn_bootstrap.zig+++ b/src/learn_bootstrap.zig@@ -129,7 +129,12 @@ fn pinExecutable(io: Io, source_path: []const u8, dir: Io.Dir, name: []const u8)if (stat.kind != .file) return error.NotRegularFile;if (stat.size > store_mod.max_program_bytes) return error.FileTooBig;dir.deleteFile(io, name) catch {};- source.hardLink(io, dir, name, .{}) catch {+ // File.hardLink goes through Io.Threaded's fileHardLink, which is only+ // implemented for linux (`error.OperationUnsupported` elsewhere), so it+ // degraded every macOS pin to a full copy. Dir.hardLink's dirHardLink+ // path linkat()s by name and works on macOS; an absolute source path+ // ignores the old_dir handle.+ Io.Dir.cwd().hardLink(source_path, dir, name, io, .{}) catch {try copyExecutableBytes(io, source, stat.size, dir, name);};}