graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Point claim fixtures at the Git common-dir ledger
justrach88070d681ca5
diff --git a/scripts/eval/claim_ledger.py b/scripts/eval/claim_ledger.pynew file mode 100644index 00000000..84df4db9--- /dev/null+++ b/scripts/eval/claim_ledger.py@@ -0,0 +1,14 @@+"""Locate the repository-wide claim ledger (#1092)."""+from pathlib import Path+import subprocess+++def path(work: Path) -> Path:+ common = subprocess.check_output(+ ["git", "-C", str(work), "rev-parse", "--git-common-dir"],+ text=True,+ ).strip()+ root = Path(common)+ if not root.is_absolute():+ root = work / root+ return root / "artifact-claims.json"diff --git a/scripts/regression-release-297.py b/scripts/regression-release-297.pyindex 6f853e8d..3c4c07bc 100644--- a/scripts/regression-release-297.py+++ b/scripts/regression-release-297.py@@ -20,6 +20,7 @@ ROOT = Path(__file__).resolve().parents[1]sys.path.insert(0, str(ROOT / "scripts" / "eval"))from mock_model import ScriptedModelfrom process_guard import run as bounded_run+from claim_ledger import path as claim_ledger_pathfrom github_fixture import GH, prepare_review@@ -164,7 +165,7 @@ def handoff(graff):if step == 1:acquired.set()assert primed.wait(35), "peer did not reach foreign claim gate"- ledger = json.loads((work / ".graff/artifact-claims.json").read_text())+ ledger = json.loads(claim_ledger_path(work).read_text())receiver = next(c["session"] for c in ledger if c["key"] == "independent")return peer("handoff", session=receiver)if step == 2:diff --git a/scripts/test-claim-lifecycle.py b/scripts/test-claim-lifecycle.pyindex 342e9b02..8072cb43 100644--- a/scripts/test-claim-lifecycle.py+++ b/scripts/test-claim-lifecycle.py@@ -14,6 +14,7 @@ import timesys.path.insert(0, str(Path(__file__).resolve().parent / 'eval'))from github_fixture import preparefrom mock_model import ScriptedModel+from claim_ledger import path as claim_ledger_pathdef tool(name, **arguments):@@ -128,11 +129,11 @@ def run(binary, recovery, evidence):caller.prompt('/resume claim-lifecycle')blocked_round('Repeat the claimed writes after resuming the saved conversation.')before_compact = len(model.requests)- ledger_before = (work/'.graff/artifact-claims.json').read_text()+ ledger_before = claim_ledger_path(work).read_text()model.caller_steps = [{'text':'COMPACTED_LIFECYCLE_FIXTURE: publication ownership remains with the live peer.'}]caller.prompt('/compact')assert len(model.requests) > before_compact, 'compaction did not request a summary'- assert (work/'.graff/artifact-claims.json').read_text() == ledger_before+ assert claim_ledger_path(work).read_text() == ledger_beforecompacted_turn = len(model.requests)blocked_round('Repeat the claimed writes after compacting the conversation.')assert 'COMPACTED_LIFECYCLE_FIXTURE' in json.dumps(model.requests[compacted_turn]), 'summary was not installed'@@ -163,9 +164,11 @@ def run(binary, recovery, evidence):(dest/'requests.json').write_text(json.dumps(model.requests,indent=2))for label,client in [('owner',owner),('caller',caller)]:if client: (dest/f'{label}-acp.json').write_text(json.dumps(client.events,indent=2))- for name in ['mutations.jsonl','gh-argv.jsonl','.graff/artifact-claims.json']:+ for name in ['mutations.jsonl','gh-argv.jsonl']:source=work/nameif source.exists(): (dest/source.name).write_text(source.read_text())+ ledger = claim_ledger_path(work)+ if ledger.exists(): (dest/'artifact-claims.json').write_text(ledger.read_text())if owner: owner.close()if caller: caller.close()model.stop()diff --git a/scripts/test-claim-repository.py b/scripts/test-claim-repository.pyindex 3eab09a6..5ee1aafb 100644--- a/scripts/test-claim-repository.py+++ b/scripts/test-claim-repository.py@@ -14,6 +14,7 @@ import threadingsys.path.insert(0, str(Path(__file__).resolve().parent / 'eval'))from github_fixture import prepare, prepare_reviewfrom mock_model import ScriptedModel+from claim_ledger import path as claim_ledger_pathdef tool(name, **arguments):@@ -64,7 +65,7 @@ class Model(ScriptedModel):assert 'claim released' in json.dumps(body), body(self.work/'release-done').touch()if c.get('legacy') and step == 1:- command = "python3 - <<'PYCLAIM'\nimport json\nfrom pathlib import Path\np=Path('.graff/artifact-claims.json')\nrows=json.loads(p.read_text())\nfor row in rows: row.pop('repo',None)\np.write_text(json.dumps(rows))\nPYCLAIM"+ command = "python3 - <<'PYCLAIM'\nimport json, subprocess\nfrom pathlib import Path\ncommon=subprocess.check_output(['git','rev-parse','--git-common-dir'], text=True).strip()\np=Path(common)/'artifact-claims.json'\nrows=json.loads(p.read_text())\nfor row in rows: row.pop('repo',None)\np.write_text(json.dumps(rows))\nPYCLAIM"return tool('bash', command=command)if c.get('rebind') and step == 2:return tool('peer_message', action='claim', kind=c.get('owner_kind','publication'), key=c['held'], repo=c['owner'])@@ -123,7 +124,7 @@ def run_case(binary, name, case, evidence):release_thread.start()done = subprocess.run(argv, cwd=work, env=env, input=json.dumps({'type': 'user', 'text': 'Claim the target branch and PR, then edit and mark it ready.'})+'\n', capture_output=True, text=True, timeout=45)events = [json.loads(line) for line in done.stdout.splitlines() if line.startswith('{')]- claims = json.loads((work/'.graff/artifact-claims.json').read_text())+ claims = json.loads(claim_ledger_path(work).read_text())mutations = (work/'mutations.jsonl').read_text().splitlines() if (work/'mutations.jsonl').exists() else []if evidence:dest = evidence/namediff --git a/src/artifact_claim.zig b/src/artifact_claim.zigindex b9f18a1e..55ba542e 100644--- a/src/artifact_claim.zig+++ b/src/artifact_claim.zig@@ -316,7 +316,7 @@ fn mergeLegacyFile(io: Io, arena: Allocator, ledger: *Ledger, path: []const u8)fn loadTransaction(io: Io, tx: @import("repo_transaction.zig").Transaction, ledger: *Ledger, cwd: []const u8) !void {if (try tx.read()) |text| try loadJson(tx.arena, ledger, text);if (builtin.is_test and !g_test_resolve_cwd) return;- if (cwd.len == 0 or std.mem.eql(u8, cwd, ".")) return;+ if (cwd.len == 0) return;const legacy = claim_path.legacyFile(tx.arena, cwd) orelse return;if (!claim_path.samePath(legacy, tx.path)) mergeLegacyFile(io, tx.arena, ledger, legacy);for (claim_path.siblingLegacyFiles(tx.arena, io, cwd, tx.path)) |other| {