graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Fix recurrence reporting lifecycle and command delivery
yxlyx1099b2c3a324
diff --git a/build.zig b/build.zigindex aee1d528..211d69e9 100644--- a/build.zig+++ b/build.zig@@ -137,6 +137,9 @@ pub fn build(b: *std.Build) void {const acp_preauth_test = b.addSystemCommand(&.{ "python3", "scripts/test-acp-preauth.py" });acp_preauth_test.addArtifactArg(exe);test_step.dependOn(&acp_preauth_test.step);+ const issue_acp_test = b.addSystemCommand(&.{ "python3", "scripts/test-issue-acp.py" });+ issue_acp_test.addArtifactArg(exe);+ test_step.dependOn(&issue_acp_test.step);const acp_goal_test = b.addSystemCommand(&.{ "python3", "scripts/test-acp-goal.py" });acp_goal_test.addArtifactArg(exe);test_step.dependOn(&acp_goal_test.step);diff --git a/docs/adr/0298-recurrence-reports-update-issue-state.md b/docs/adr/0298-recurrence-reports-update-issue-state.mdnew file mode 100644index 00000000..317c7d5a--- /dev/null+++ b/docs/adr/0298-recurrence-reports-update-issue-state.md@@ -0,0 +1,32 @@+# 0298. Recurrence reports update the canonical issue's state++Status: accepted++## Context++[#1701](https://github.com/justrach/codegraff/issues/1701) exposed a gap in the+reporting instructions: searching closed issues and adding fresh evidence+avoided duplicates, but left unresolved recurrences classified as resolved.+The `/issue` brief also demanded a new issue even when a matching report existed.++## Decision++Ordinary reporting and `/issue` share issue-lifecycle guidance. Inspect the+matching issue's state, closure reason, and latest resolution. When current+reproduction evidence contradicts a resolved closure, reopen the canonical+issue and attach the evidence. Follow duplicate closures to their canonical+tracker; do not reopen deliberately rejected, withdrawn, or out-of-scope reports+merely because they receive comments. Confirm and accurately report the final+state, including a denied reopening that requires a maintainer. Custom and+learned root prompts retain this policy across replacement, as worker personas+already do. `/issue` expands the same reporting brief in the REPL and over ACP.++## Consequences++Duplicate detection is not evidence that reporting is complete. The agent+still needs to judge whether the new evidence contradicts the resolution;+automatically reopening every commented-on issue would undo intentional+closures. No GitHub-specific shell interception is introduced: the same rule+applies to CLI and connector reporting. The offline issue-reporting cases in+`evals/harness_behavior.jsonl` verify prompt delivery and stateful local CLI+roundtrips, not a live model's judgment about arbitrary reports.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 4fa549d2..35ad684b 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -315,6 +315,7 @@ record only when you need the evidence or the edge cases.| [0295](0295-worker-native-turns-share-the-chat-step.md) | Experimental Worker-native turns share the native chat step; JSPI supplies bounded host I/O, not a proxy or a second agent loop. || [0296](0296-worker-tasks-own-remote-sandbox-cleanup.md) | Worker/DO tasks retain the agent loop and delegate Linux execution to remote sandboxes with explicit ownership, deletion and bounded leases. || [0297](0297-sdk-managed-replay-reuses-the-relay.md) | The fetch-only managed SDK reuses account relay/device tapes; prompt retries are explicit, durability limits are stated, and content-free OTLP export remains opt-in and observational. |+| [0298](0298-recurrence-reports-update-issue-state.md) | A current unresolved recurrence reopens the canonical resolved issue; comments alone do not complete reporting, intentional closures remain respected, and final state is verified. |## When to write onediff --git a/evals/harness_behavior.jsonl b/evals/harness_behavior.jsonlindex 73188640..65e08e49 100644--- a/evals/harness_behavior.jsonl+++ b/evals/harness_behavior.jsonl@@ -134,3 +134,19 @@{"id": "headless-server-does-not-hold", "why": "Run until idle: a server never reports, so a turn that leaves one running in the background ends instead of waiting on it.", "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_HEARTBEAT_SECS": "1"}, "prompt": "Start the dev server in the background and confirm it launched.", "script": [{"tool": "bash", "arguments": {"command": "python3 -m http.server 0 --bind 127.0.0.1", "run_in_background": true}}, {"text": "The dev server is running."}], "assert": [{"request_count": 2}, {"final_text_contains": "The dev server is running."}]}{"id": "claude-conversation-import-resume", "why": "Imported history uses the configured graff route without Claude credentials, retaining dialogue and historical tool results.", "env": {"ANTHROPIC_API_KEY": ""}, "args": ["--resume", "claude-import-fixture"], "claude_transcripts": {"import-fixture.jsonl": "{\"type\": \"user\", \"uuid\": \"u1\", \"message\": {\"content\": \"import-retained-question-1495\"}}\n{\"type\": \"assistant\", \"uuid\": \"a1\", \"message\": {\"model\": \"claude-sonnet-4-5\", \"content\": [{\"type\": \"thinking\", \"thinking\": \"import-private-thinking-1495\", \"signature\": \"signed\"}, {\"type\": \"text\", \"text\": \"import-retained-answer-1495\"}, {\"type\": \"tool_use\", \"id\": \"tool-import-1495\", \"name\": \"Bash\", \"input\": {\"command\": \"echo imported\"}}]}}\n{\"type\": \"user\", \"message\": {\"content\": [{\"type\": \"tool_result\", \"tool_use_id\": \"tool-import-1495\", \"content\": \"import-retained-result-1495\"}]}}\n{\"type\": \"assistant\", \"isSidechain\": true, \"message\": {\"content\": [{\"type\": \"text\", \"text\": \"import-sidechain-1495\"}]}}\n{\"type\": \"assistant\", \"message\": {\"content\": [{\"type\": \"text\", \"text\": \"import-finished-1495\"}]}}\n"}, "controls_before_prompt": [{"type": "set_model", "provider": "lmstudio", "model": "mock"}], "prompt": "Continue the imported task.", "script": [{"text": "Imported history is available."}], "assert": [{"request_contains": {"index": 0, "text": "import-retained-question-1495"}}, {"request_contains": {"index": 0, "text": "import-retained-answer-1495"}}, {"request_contains": {"index": 0, "text": "import-retained-result-1495"}}, {"request_contains": {"index": 0, "text": "import-finished-1495"}}, {"request_lacks": {"index": 0, "text": "import-private-thinking-1495"}}, {"request_lacks": {"index": 0, "text": "import-sidechain-1495"}}, {"final_text_contains": "Imported history is available."}]}{"id": "screenshot-handoff-preserves-open-work-1531", "why": "#1531: a screenshot needed on the next prompt must end the current turn without a pause question, completion claim, verifier approval, or open-work retry, and resume with the unfinished checklist intact.", "args": ["--no-lean", "--goal", "fix the control after visual identification", "--eval", "printf \"0\\n\""], "prompt": "The question interface accepts text only. A screenshot is essential to identify the control. Stop this turn so I can attach it to my next prompt.", "second_prompt": "Continue with the new input. Read back the unfinished checklist before proceeding.", "script": [{"tool": "todo_write", "arguments": {"todos": [{"content": "identify the control from the screenshot", "status": "in_progress"}]}}, {"tool": "eval", "arguments": {}}, {"tool": "yield_turn", "arguments": {"message": "Stopping this turn so you can attach the screenshot to your next prompt. The task remains unfinished."}}, {"tool": "todo_read", "arguments": {}}, {"tool": "yield_turn", "arguments": {"message": "The checklist still has the unfinished visual identification item; this turn is stopping until the missing input arrives."}}], "assert": [{"request_contains": {"index": 0, "text": "explicitly supports attachments in question replies"}}, {"request_contains": {"index": 0, "text": "Do not ask for permission to pause"}}, {"request_lacks": {"index": 0, "text": "typed text and/or pasted images"}}, {"event": {"type": "turn", "api_calls": 3, "complete": true, "text": "Stopping this turn so you can attach the screenshot to your next prompt. The task remains unfinished."}}, {"events_at_least": {"match": {"type": "turn"}, "count": 2}}, {"events_at_most": {"match": {"type": "turn"}, "count": 2}}, {"no_event": {"type": "ask_user"}}, {"no_event": {"type": "tool_call", "name": "attempt_completion"}}, {"request_contains": {"index": 4, "text": "identify the control from the screenshot"}}, {"request_contains": {"index": 4, "text": "in_progress"}}, {"request_lacks": {"index": 4, "text": "Open-work reconciliation"}}, {"final_text_contains": "checklist still has the unfinished"}]}+{"id": "issue-recurrence-resolved-reopen", "why": "#1701: resolved-reopen. Deterministic scripted policy-delivery and local CLI roundtrip coverage; not live-model judgment. Independent issue-state and mutation assertions reject missing reopens, duplicate creation and inaccurate final-state claims.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Previously fixed fixture recurrence.", "state": "CLOSED", "stateReason": "COMPLETED", "comments": [], "url": "https://github.com/fixture/primary/issues/101"}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the current fixture recurrence against the existing local tracker issue. Search both open and closed issues, inspect the closure reason and canonical issue, preserve the new evidence and verify the final state. Use only the installed local gh fixture.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue reopen 101 --repo fixture/primary"}}, {"tool": "bash", "arguments": {"command": "gh issue comment 101 --repo fixture/primary --body-file recurrence.md"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Issue #101 is OPEN; recurrence evidence saved and final state verified."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Previously fixed fixture recurrence.\", \"state\": \"OPEN\", \"stateReason\": \"\", \"comments\": [{\"body\": \"**graff:** fixture (latest: fixture)\\\\n**Harness:** not used\\\\n**Surface:** terminal\\\\n**Platform:** fixture\\\\n\\\\n## Symptom\\\\nThe fixture failure recurs on the current fixture release.\\\\n\\\\n## Repro\\\\nRepeat the local fixture operation.\\\\n\"}], \"url\": \"https://github.com/fixture/primary/issues/101\", \"closedAt\": null}}')\ns=json.loads(p('gh-state.json').read_text())\nassert s['issues']==expected, ('issue state/evidence mismatch',s['issues'],expected)\nrows=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()]\nops=[r for r in rows if r[:1]==['issue']]\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[('reopen', '101'), ('comment', '101')], ('unexpected mutation/duplicate/reopen',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in ops), 'must search open and closed issues'\nassert any(r[:3]==['issue','view',str(101)] for r in ops), 'must inspect canonical issue'\nassert ops[-1][:3]==['issue','view',str(101)], 'must confirm final state after mutations'\nassert max(i for i,r in enumerate(ops) if r[1] in ('comment','reopen','create')) < len(ops)-1, 'state read must follow mutation'\nprint('Independent issue state, evidence, mutations and final state lookup verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"request_contains": {"index": -1, "text": "OPEN"}}, {"final_text_contains": "Issue #101 is OPEN; recurrence evidence saved and final state verified."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 5}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}]}+{"id": "issue-recurrence-already-open", "why": "#1701: already-open. Deterministic scripted policy-delivery and local CLI roundtrip coverage; not live-model judgment. Independent issue-state and mutation assertions reject missing reopens, duplicate creation and inaccurate final-state claims.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Previously fixed fixture recurrence.", "state": "OPEN", "stateReason": "", "comments": [], "url": "https://github.com/fixture/primary/issues/101"}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the current fixture recurrence against the existing local tracker issue. Search both open and closed issues, inspect the closure reason and canonical issue, preserve the new evidence and verify the final state. Use only the installed local gh fixture.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue comment 101 --repo fixture/primary --body-file recurrence.md"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Issue #101 remains OPEN; evidence saved without reopening or creating a duplicate."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Previously fixed fixture recurrence.\", \"state\": \"OPEN\", \"stateReason\": \"\", \"comments\": [{\"body\": \"**graff:** fixture (latest: fixture)\\\\n**Harness:** not used\\\\n**Surface:** terminal\\\\n**Platform:** fixture\\\\n\\\\n## Symptom\\\\nThe fixture failure recurs on the current fixture release.\\\\n\\\\n## Repro\\\\nRepeat the local fixture operation.\\\\n\"}], \"url\": \"https://github.com/fixture/primary/issues/101\"}}')\ns=json.loads(p('gh-state.json').read_text())\nassert s['issues']==expected, ('issue state/evidence mismatch',s['issues'],expected)\nrows=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()]\nops=[r for r in rows if r[:1]==['issue']]\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[('comment', '101')], ('unexpected mutation/duplicate/reopen',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in ops), 'must search open and closed issues'\nassert any(r[:3]==['issue','view',str(101)] for r in ops), 'must inspect canonical issue'\nassert ops[-1][:3]==['issue','view',str(101)], 'must confirm final state after mutations'\nassert max(i for i,r in enumerate(ops) if r[1] in ('comment','reopen','create')) < len(ops)-1, 'state read must follow mutation'\nprint('Independent issue state, evidence, mutations and final state lookup verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"request_contains": {"index": -1, "text": "OPEN"}}, {"final_text_contains": "Issue #101 remains OPEN; evidence saved without reopening or creating a duplicate."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 4}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}]}+{"id": "issue-recurrence-duplicate-open-canonical", "why": "#1701: duplicate-open-canonical. Deterministic scripted policy-delivery and local CLI roundtrip coverage; not live-model judgment. Independent issue-state and mutation assertions reject missing reopens, duplicate creation and inaccurate final-state claims.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Previously fixed fixture recurrence.", "state": "OPEN", "stateReason": "", "comments": [], "url": "https://github.com/fixture/primary/issues/101"}, "102": {"number": 102, "title": "recurrence fixture", "body": "Duplicate of #101; canonical issue is https://github.com/fixture/primary/issues/101.", "state": "CLOSED", "stateReason": "DUPLICATE", "comments": [], "url": "https://github.com/fixture/primary/issues/102"}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the current fixture recurrence against the existing local tracker issue. Search both open and closed issues, inspect the closure reason and canonical issue, preserve the new evidence and verify the final state. Use only the installed local gh fixture.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 102 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue comment 101 --repo fixture/primary --body-file recurrence.md"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Canonical issue #101 is OPEN with the new evidence; duplicate #102 remains CLOSED and was not reopened."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Previously fixed fixture recurrence.\", \"state\": \"OPEN\", \"stateReason\": \"\", \"comments\": [{\"body\": \"**graff:** fixture (latest: fixture)\\\\n**Harness:** not used\\\\n**Surface:** terminal\\\\n**Platform:** fixture\\\\n\\\\n## Symptom\\\\nThe fixture failure recurs on the current fixture release.\\\\n\\\\n## Repro\\\\nRepeat the local fixture operation.\\\\n\"}], \"url\": \"https://github.com/fixture/primary/issues/101\"}, \"102\": {\"number\": 102, \"title\": \"recurrence fixture\", \"body\": \"Duplicate of #101; canonical issue is https://github.com/fixture/primary/issues/101.\", \"state\": \"CLOSED\", \"stateReason\": \"DUPLICATE\", \"comments\": [], \"url\": \"https://github.com/fixture/primary/issues/102\"}}')\ns=json.loads(p('gh-state.json').read_text())\nassert s['issues']==expected, ('issue state/evidence mismatch',s['issues'],expected)\nrows=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()]\nops=[r for r in rows if r[:1]==['issue']]\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[('comment', '101')], ('unexpected mutation/duplicate/reopen',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in ops), 'must search open and closed issues'\nassert any(r[:3]==['issue','view',str(101)] for r in ops), 'must inspect canonical issue'\nassert ops[-1][:3]==['issue','view',str(101)], 'must confirm final state after mutations'\nassert max(i for i,r in enumerate(ops) if r[1] in ('comment','reopen','create')) < len(ops)-1, 'state read must follow mutation'\nprint('Independent issue state, evidence, mutations and final state lookup verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"request_contains": {"index": -1, "text": "OPEN"}}, {"final_text_contains": "Canonical issue #101 is OPEN with the new evidence; duplicate #102 remains CLOSED and was not reopened."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 5}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}, {"request_contains": {"index": 2, "text": "Duplicate of #101"}}]}+{"id": "issue-recurrence-denied-reopen", "why": "#1701: denied-reopen. Deterministic scripted policy-delivery and local CLI roundtrip coverage; not live-model judgment. Independent issue-state and mutation assertions reject missing reopens, duplicate creation and inaccurate final-state claims.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Previously fixed fixture recurrence.", "state": "CLOSED", "stateReason": "COMPLETED", "comments": [], "url": "https://github.com/fixture/primary/issues/101", "deny_reopen": true}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the current fixture recurrence against the existing local tracker issue. Search both open and closed issues, inspect the closure reason and canonical issue, preserve the new evidence and verify the final state. Use only the installed local gh fixture.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue reopen 101 --repo fixture/primary"}}, {"tool": "bash", "arguments": {"command": "gh issue comment 101 --repo fixture/primary --body-file recurrence.md"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Evidence saved on #101, but reopen was denied by permissions. Verified final state: CLOSED. A maintainer must reopen it; the recurrence report is not complete."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Previously fixed fixture recurrence.\", \"state\": \"CLOSED\", \"stateReason\": \"COMPLETED\", \"comments\": [{\"body\": \"**graff:** fixture (latest: fixture)\\\\n**Harness:** not used\\\\n**Surface:** terminal\\\\n**Platform:** fixture\\\\n\\\\n## Symptom\\\\nThe fixture failure recurs on the current fixture release.\\\\n\\\\n## Repro\\\\nRepeat the local fixture operation.\\\\n\"}], \"url\": \"https://github.com/fixture/primary/issues/101\", \"deny_reopen\": true}}')\ns=json.loads(p('gh-state.json').read_text())\nassert s['issues']==expected, ('issue state/evidence mismatch',s['issues'],expected)\nrows=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()]\nops=[r for r in rows if r[:1]==['issue']]\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[('reopen', '101'), ('comment', '101')], ('unexpected mutation/duplicate/reopen',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in ops), 'must search open and closed issues'\nassert any(r[:3]==['issue','view',str(101)] for r in ops), 'must inspect canonical issue'\nassert ops[-1][:3]==['issue','view',str(101)], 'must confirm final state after mutations'\nassert max(i for i,r in enumerate(ops) if r[1] in ('comment','reopen','create')) < len(ops)-1, 'state read must follow mutation'\nprint('Independent issue state, evidence, mutations and final state lookup verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"request_contains": {"index": -1, "text": "CLOSED"}}, {"final_text_contains": "Evidence saved on #101, but reopen was denied by permissions. Verified final state: CLOSED. A maintainer must reopen it; the recurrence report is not complete."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 5}}, {"event": {"type": "tool_call_finished", "name": "bash", "is_error": true}}, {"request_contains": {"index": 3, "text": "Resource not accessible by integration"}}]}+{"id": "issue-recurrence-not-planned", "why": "#1701: not-planned. Deterministic scripted policy-delivery and local CLI roundtrip coverage; not live-model judgment. Independent issue-state and mutation assertions reject missing reopens, duplicate creation and inaccurate final-state claims.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Closed intentionally as not planned; this behavior is rejected.", "state": "CLOSED", "stateReason": "NOT_PLANNED", "comments": [], "url": "https://github.com/fixture/primary/issues/101"}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the current fixture recurrence against the existing local tracker issue. Search both open and closed issues, inspect the closure reason and canonical issue, preserve the new evidence and verify the final state. Use only the installed local gh fixture.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue comment 101 --repo fixture/primary --body-file recurrence.md"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Issue #101 remains CLOSED; evidence saved but not reopened because it was intentionally not planned."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Closed intentionally as not planned; this behavior is rejected.\", \"state\": \"CLOSED\", \"stateReason\": \"NOT_PLANNED\", \"comments\": [{\"body\": \"**graff:** fixture (latest: fixture)\\\\n**Harness:** not used\\\\n**Surface:** terminal\\\\n**Platform:** fixture\\\\n\\\\n## Symptom\\\\nThe fixture failure recurs on the current fixture release.\\\\n\\\\n## Repro\\\\nRepeat the local fixture operation.\\\\n\"}], \"url\": \"https://github.com/fixture/primary/issues/101\"}}')\ns=json.loads(p('gh-state.json').read_text())\nassert s['issues']==expected, ('issue state/evidence mismatch',s['issues'],expected)\nrows=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()]\nops=[r for r in rows if r[:1]==['issue']]\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[('comment', '101')], ('unexpected mutation/duplicate/reopen',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in ops), 'must search open and closed issues'\nassert any(r[:3]==['issue','view',str(101)] for r in ops), 'must inspect canonical issue'\nassert ops[-1][:3]==['issue','view',str(101)], 'must confirm final state after mutations'\nassert max(i for i,r in enumerate(ops) if r[1] in ('comment','reopen','create')) < len(ops)-1, 'state read must follow mutation'\nprint('Independent issue state, evidence, mutations and final state lookup verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"request_contains": {"index": -1, "text": "CLOSED"}}, {"final_text_contains": "Issue #101 remains CLOSED; evidence saved but not reopened because it was intentionally not planned."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 4}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}, {"request_contains": {"index": 2, "text": "NOT_PLANNED"}}]}+{"id": "issue-recurrence-out-of-scope", "why": "#1701: out-of-scope. Deterministic scripted policy-delivery and local CLI roundtrip coverage; not live-model judgment. Independent issue-state and mutation assertions reject missing reopens, duplicate creation and inaccurate final-state claims.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Closed intentionally: this feature is out of scope, not a resolved bug.", "state": "CLOSED", "stateReason": "NOT_PLANNED", "comments": [], "url": "https://github.com/fixture/primary/issues/101"}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the current fixture recurrence against the existing local tracker issue. Search both open and closed issues, inspect the closure reason and canonical issue, preserve the new evidence and verify the final state. Use only the installed local gh fixture.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue comment 101 --repo fixture/primary --body-file recurrence.md"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Issue #101 remains CLOSED; evidence saved but not reopened because it was intentionally out of scope."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Closed intentionally: this feature is out of scope, not a resolved bug.\", \"state\": \"CLOSED\", \"stateReason\": \"NOT_PLANNED\", \"comments\": [{\"body\": \"**graff:** fixture (latest: fixture)\\\\n**Harness:** not used\\\\n**Surface:** terminal\\\\n**Platform:** fixture\\\\n\\\\n## Symptom\\\\nThe fixture failure recurs on the current fixture release.\\\\n\\\\n## Repro\\\\nRepeat the local fixture operation.\\\\n\"}], \"url\": \"https://github.com/fixture/primary/issues/101\"}}')\ns=json.loads(p('gh-state.json').read_text())\nassert s['issues']==expected, ('issue state/evidence mismatch',s['issues'],expected)\nrows=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()]\nops=[r for r in rows if r[:1]==['issue']]\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[('comment', '101')], ('unexpected mutation/duplicate/reopen',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in ops), 'must search open and closed issues'\nassert any(r[:3]==['issue','view',str(101)] for r in ops), 'must inspect canonical issue'\nassert ops[-1][:3]==['issue','view',str(101)], 'must confirm final state after mutations'\nassert max(i for i,r in enumerate(ops) if r[1] in ('comment','reopen','create')) < len(ops)-1, 'state read must follow mutation'\nprint('Independent issue state, evidence, mutations and final state lookup verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"request_contains": {"index": -1, "text": "CLOSED"}}, {"final_text_contains": "Issue #101 remains CLOSED; evidence saved but not reopened because it was intentionally out of scope."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 4}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}, {"request_contains": {"index": 2, "text": "NOT_PLANNED"}}]}+{"id": "issue-recurrence-duplicate-closed-canonical", "why": "#1701: duplicate-closed-canonical. Scripted policy delivery and local issue-state roundtrip, not live-model judgment. Independent verifiers reject incorrect state, missing evidence, extra mutations and missing final reads.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Previously fixed fixture recurrence.", "state": "CLOSED", "stateReason": "COMPLETED", "comments": [], "url": "https://github.com/fixture/primary/issues/101"}, "102": {"number": 102, "title": "recurrence fixture", "body": "Duplicate of #101. Follow the canonical tracking issue, not this copy.", "state": "CLOSED", "stateReason": "DUPLICATE", "comments": [], "url": "https://github.com/fixture/primary/issues/102"}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the supplied fixture findings using only the installed local gh. Inspect resolution and tested-version evidence, follow canonical duplicate tracking, avoid duplicate issues and report any failed operation accurately.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 102 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue reopen 101 --repo fixture/primary"}}, {"tool": "bash", "arguments": {"command": "gh issue comment 101 --repo fixture/primary --body-file recurrence.md"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Canonical issue #101 is OPEN; evidence saved. Duplicate #102 remains CLOSED."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Previously fixed fixture recurrence.\", \"state\": \"OPEN\", \"stateReason\": \"\", \"comments\": [{\"body\": \"**graff:** fixture (latest: fixture)\\\\n**Harness:** not used\\\\n**Surface:** terminal\\\\n**Platform:** fixture\\\\n\\\\n## Symptom\\\\nThe fixture failure recurs on the current fixture release.\\\\n\\\\n## Repro\\\\nRepeat the local fixture operation.\\\\n\"}], \"url\": \"https://github.com/fixture/primary/issues/101\", \"closedAt\": null}, \"102\": {\"number\": 102, \"title\": \"recurrence fixture\", \"body\": \"Duplicate of #101. Follow the canonical tracking issue, not this copy.\", \"state\": \"CLOSED\", \"stateReason\": \"DUPLICATE\", \"comments\": [], \"url\": \"https://github.com/fixture/primary/issues/102\"}}')\nstate=json.loads(p('gh-state.json').read_text())\nassert state['issues']==expected, ('issue state/evidence mismatch',state['issues'],expected)\nreads=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()] if p('gh-argv.jsonl').exists() else []\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[('reopen', '101'), ('comment', '101')], ('incorrect mutations',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in reads), 'must search all states'\nassert reads[-1][:3]==['issue','view','101'], 'must attempt final canonical state lookup'\nassert '--json' in reads[-1] and 'state' in reads[-1][reads[-1].index('--json')+1].split(','), 'final read must include state'\nprint('Independent extended issue lifecycle verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"final_text_contains": "Canonical issue #101 is OPEN; evidence saved. Duplicate #102 remains CLOSED."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 6}}, {"events_at_least": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}], "fixture_exit_codes": {}, "fixture_negative_omissions": ["issue list", "issue view 101", "issue comment", "issue reopen"]}+{"id": "issue-recurrence-duplicate-chain", "why": "#1701: duplicate-chain. Scripted policy delivery and local issue-state roundtrip, not live-model judgment. Independent verifiers reject incorrect state, missing evidence, extra mutations and missing final reads.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Previously fixed fixture recurrence.", "state": "CLOSED", "stateReason": "COMPLETED", "comments": [], "url": "https://github.com/fixture/primary/issues/101"}, "102": {"number": 102, "title": "recurrence fixture", "body": "Duplicate of #101. Follow the canonical tracking issue, not this copy.", "state": "CLOSED", "stateReason": "DUPLICATE", "comments": [], "url": "https://github.com/fixture/primary/issues/102"}, "103": {"number": 103, "title": "recurrence fixture", "body": "Duplicate of #102, which points to canonical #101.", "state": "CLOSED", "stateReason": "DUPLICATE", "comments": [], "url": "https://github.com/fixture/primary/issues/103"}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the supplied fixture findings using only the installed local gh. Inspect resolution and tested-version evidence, follow canonical duplicate tracking, avoid duplicate issues and report any failed operation accurately.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 103 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue view 102 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue reopen 101 --repo fixture/primary"}}, {"tool": "bash", "arguments": {"command": "gh issue comment 101 --repo fixture/primary --body-file recurrence.md"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Canonical issue #101 is OPEN; evidence saved. Duplicate chain #103 and #102 remains CLOSED."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Previously fixed fixture recurrence.\", \"state\": \"OPEN\", \"stateReason\": \"\", \"comments\": [{\"body\": \"**graff:** fixture (latest: fixture)\\\\n**Harness:** not used\\\\n**Surface:** terminal\\\\n**Platform:** fixture\\\\n\\\\n## Symptom\\\\nThe fixture failure recurs on the current fixture release.\\\\n\\\\n## Repro\\\\nRepeat the local fixture operation.\\\\n\"}], \"url\": \"https://github.com/fixture/primary/issues/101\", \"closedAt\": null}, \"102\": {\"number\": 102, \"title\": \"recurrence fixture\", \"body\": \"Duplicate of #101. Follow the canonical tracking issue, not this copy.\", \"state\": \"CLOSED\", \"stateReason\": \"DUPLICATE\", \"comments\": [], \"url\": \"https://github.com/fixture/primary/issues/102\"}, \"103\": {\"number\": 103, \"title\": \"recurrence fixture\", \"body\": \"Duplicate of #102, which points to canonical #101.\", \"state\": \"CLOSED\", \"stateReason\": \"DUPLICATE\", \"comments\": [], \"url\": \"https://github.com/fixture/primary/issues/103\"}}')\nstate=json.loads(p('gh-state.json').read_text())\nassert state['issues']==expected, ('issue state/evidence mismatch',state['issues'],expected)\nreads=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()] if p('gh-argv.jsonl').exists() else []\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[('reopen', '101'), ('comment', '101')], ('incorrect mutations',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in reads), 'must search all states'\nassert reads[-1][:3]==['issue','view','101'], 'must attempt final canonical state lookup'\nassert '--json' in reads[-1] and 'state' in reads[-1][reads[-1].index('--json')+1].split(','), 'final read must include state'\nprint('Independent extended issue lifecycle verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"final_text_contains": "Canonical issue #101 is OPEN; evidence saved. Duplicate chain #103 and #102 remains CLOSED."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 7}}, {"events_at_least": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}], "fixture_exit_codes": {}, "fixture_negative_omissions": ["issue list", "issue view 101", "issue comment", "issue reopen"]}+{"id": "issue-recurrence-no-new-evidence", "why": "#1701: no-new-evidence. Scripted policy delivery and local issue-state roundtrip, not live-model judgment. Independent verifiers reject incorrect state, missing evidence, extra mutations and missing final reads.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Resolved. The submitted finding repeats existing evidence with no current recurrence.", "state": "CLOSED", "stateReason": "COMPLETED", "comments": [], "url": "https://github.com/fixture/primary/issues/101"}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the supplied fixture findings using only the installed local gh. Inspect resolution and tested-version evidence, follow canonical duplicate tracking, avoid duplicate issues and report any failed operation accurately.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Issue #101 remains CLOSED; no new evidence or current recurrence, so no comment or reopening."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Resolved. The submitted finding repeats existing evidence with no current recurrence.\", \"state\": \"CLOSED\", \"stateReason\": \"COMPLETED\", \"comments\": [], \"url\": \"https://github.com/fixture/primary/issues/101\"}}')\nstate=json.loads(p('gh-state.json').read_text())\nassert state['issues']==expected, ('issue state/evidence mismatch',state['issues'],expected)\nreads=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()] if p('gh-argv.jsonl').exists() else []\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[], ('incorrect mutations',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in reads), 'must search all states'\nassert reads[-1][:3]==['issue','view','101'], 'must attempt final canonical state lookup'\nassert '--json' in reads[-1] and 'state' in reads[-1][reads[-1].index('--json')+1].split(','), 'final read must include state'\nprint('Independent extended issue lifecycle verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"final_text_contains": "Issue #101 remains CLOSED; no new evidence or current recurrence, so no comment or reopening."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 2}}, {"events_at_least": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}], "fixture_exit_codes": {}, "fixture_negative_omissions": ["issue list", "issue view 101"]}+{"id": "issue-recurrence-pre-fix-evidence", "why": "#1701: pre-fix-evidence. Scripted policy delivery and local issue-state roundtrip, not live-model judgment. Independent verifiers reject incorrect state, missing evidence, extra mutations and missing final reads.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Fixed in fixture version 2. The newly described incident ran version 1 and does not test the fix.", "state": "CLOSED", "stateReason": "COMPLETED", "comments": [], "url": "https://github.com/fixture/primary/issues/101"}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the supplied fixture findings using only the installed local gh. Inspect resolution and tested-version evidence, follow canonical duplicate tracking, avoid duplicate issues and report any failed operation accurately.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Issue #101 remains CLOSED; the incident predates the version 2 fix and does not establish a regression."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Fixed in fixture version 2. The newly described incident ran version 1 and does not test the fix.\", \"state\": \"CLOSED\", \"stateReason\": \"COMPLETED\", \"comments\": [], \"url\": \"https://github.com/fixture/primary/issues/101\"}}')\nstate=json.loads(p('gh-state.json').read_text())\nassert state['issues']==expected, ('issue state/evidence mismatch',state['issues'],expected)\nreads=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()] if p('gh-argv.jsonl').exists() else []\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[], ('incorrect mutations',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in reads), 'must search all states'\nassert reads[-1][:3]==['issue','view','101'], 'must attempt final canonical state lookup'\nassert '--json' in reads[-1] and 'state' in reads[-1][reads[-1].index('--json')+1].split(','), 'final read must include state'\nprint('Independent extended issue lifecycle verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"final_text_contains": "Issue #101 remains CLOSED; the incident predates the version 2 fix and does not establish a regression."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 2}}, {"events_at_least": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}], "fixture_exit_codes": {}, "fixture_negative_omissions": ["issue list", "issue view 101"]}+{"id": "issue-recurrence-withdrawn", "why": "#1701: withdrawn. Scripted policy delivery and local issue-state roundtrip, not live-model judgment. Independent verifiers reject incorrect state, missing evidence, extra mutations and missing final reads.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Withdrawn by reporter: the behavior is intentional, not an unresolved bug.", "state": "CLOSED", "stateReason": "NOT_PLANNED", "comments": [], "url": "https://github.com/fixture/primary/issues/101"}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the supplied fixture findings using only the installed local gh. Inspect resolution and tested-version evidence, follow canonical duplicate tracking, avoid duplicate issues and report any failed operation accurately.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Issue #101 remains CLOSED; the report was withdrawn and no contradictory new evidence was provided."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Withdrawn by reporter: the behavior is intentional, not an unresolved bug.\", \"state\": \"CLOSED\", \"stateReason\": \"NOT_PLANNED\", \"comments\": [], \"url\": \"https://github.com/fixture/primary/issues/101\"}}')\nstate=json.loads(p('gh-state.json').read_text())\nassert state['issues']==expected, ('issue state/evidence mismatch',state['issues'],expected)\nreads=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()] if p('gh-argv.jsonl').exists() else []\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[], ('incorrect mutations',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in reads), 'must search all states'\nassert reads[-1][:3]==['issue','view','101'], 'must attempt final canonical state lookup'\nassert '--json' in reads[-1] and 'state' in reads[-1][reads[-1].index('--json')+1].split(','), 'final read must include state'\nprint('Independent extended issue lifecycle verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"final_text_contains": "Issue #101 remains CLOSED; the report was withdrawn and no contradictory new evidence was provided."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 2}}, {"events_at_least": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 0}}], "fixture_exit_codes": {}, "fixture_negative_omissions": ["issue list", "issue view 101"]}+{"id": "issue-recurrence-denied-comment", "why": "#1701: denied-comment. Scripted policy delivery and local issue-state roundtrip, not live-model judgment. Independent verifiers reject incorrect state, missing evidence, extra mutations and missing final reads.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Previously fixed fixture recurrence.", "state": "CLOSED", "stateReason": "COMPLETED", "comments": [], "url": "https://github.com/fixture/primary/issues/101", "deny_comment": true}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the supplied fixture findings using only the installed local gh. Inspect resolution and tested-version evidence, follow canonical duplicate tracking, avoid duplicate issues and report any failed operation accurately.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue reopen 101 --repo fixture/primary"}}, {"tool": "bash", "arguments": {"command": "gh issue comment 101 --repo fixture/primary --body-file recurrence.md"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Issue #101 is OPEN, but saving the evidence failed: comment permission denied. No evidence was saved; a maintainer must attach it."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Previously fixed fixture recurrence.\", \"state\": \"OPEN\", \"stateReason\": \"\", \"comments\": [], \"url\": \"https://github.com/fixture/primary/issues/101\", \"deny_comment\": true, \"closedAt\": null}}')\nstate=json.loads(p('gh-state.json').read_text())\nassert state['issues']==expected, ('issue state/evidence mismatch',state['issues'],expected)\nreads=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()] if p('gh-argv.jsonl').exists() else []\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[('reopen', '101'), ('comment', '101')], ('incorrect mutations',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in reads), 'must search all states'\nassert reads[-1][:3]==['issue','view','101'], 'must attempt final canonical state lookup'\nassert '--json' in reads[-1] and 'state' in reads[-1][reads[-1].index('--json')+1].split(','), 'final read must include state'\nprint('Independent extended issue lifecycle verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"final_text_contains": "Issue #101 is OPEN, but saving the evidence failed: comment permission denied. No evidence was saved; a maintainer must attach it."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 5}}, {"events_at_least": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 1}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 1}}], "fixture_exit_codes": {"gh issue comment 101 --repo fixture/primary --body-file recurrence.md": 1}, "fixture_negative_omissions": ["issue list", "issue view 101", "issue reopen"]}+{"id": "issue-recurrence-denied-final-state", "why": "#1701: denied-final-state. Scripted policy delivery and local issue-state roundtrip, not live-model judgment. Independent verifiers reject incorrect state, missing evidence, extra mutations and missing final reads.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Previously fixed fixture recurrence.", "state": "CLOSED", "stateReason": "COMPLETED", "comments": [], "url": "https://github.com/fixture/primary/issues/101", "deny_view_after_mutation": true}}}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the supplied fixture findings using only the installed local gh. Inspect resolution and tested-version evidence, follow canonical duplicate tracking, avoid duplicate issues and report any failed operation accurately.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"tool": "bash", "arguments": {"command": "gh issue reopen 101 --repo fixture/primary"}}, {"tool": "bash", "arguments": {"command": "gh issue comment 101 --repo fixture/primary --body-file recurrence.md"}}, {"tool": "bash", "arguments": {"command": "gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url"}}, {"text": "Reopen and comment operations succeeded, but the final state lookup was denied. Final issue state is unverified; maintainer confirmation is required."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Previously fixed fixture recurrence.\", \"state\": \"OPEN\", \"stateReason\": \"\", \"comments\": [{\"body\": \"**graff:** fixture (latest: fixture)\\\\n**Harness:** not used\\\\n**Surface:** terminal\\\\n**Platform:** fixture\\\\n\\\\n## Symptom\\\\nThe fixture failure recurs on the current fixture release.\\\\n\\\\n## Repro\\\\nRepeat the local fixture operation.\\\\n\"}], \"url\": \"https://github.com/fixture/primary/issues/101\", \"deny_view_after_mutation\": true, \"closedAt\": null}}')\nstate=json.loads(p('gh-state.json').read_text())\nassert state['issues']==expected, ('issue state/evidence mismatch',state['issues'],expected)\nreads=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()] if p('gh-argv.jsonl').exists() else []\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[('reopen', '101'), ('comment', '101')], ('incorrect mutations',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in reads), 'must search all states'\nassert reads[-1][:3]==['issue','view','101'], 'must attempt final canonical state lookup'\nassert '--json' in reads[-1] and 'state' in reads[-1][reads[-1].index('--json')+1].split(','), 'final read must include state'\nprint('Independent extended issue lifecycle verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"final_text_contains": "Reopen and comment operations succeeded, but the final state lookup was denied. Final issue state is unverified; maintainer confirmation is required."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 5}}, {"events_at_least": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 1}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 1}}], "fixture_exit_codes": {"gh issue view 101 --repo fixture/primary --json number,title,body,state,stateReason,comments,url": [0, 1]}, "fixture_negative_omissions": ["issue list", "issue view 101", "issue comment", "issue reopen"]}+{"id": "issue-recurrence-search-failed", "why": "#1701: search-failed. Scripted policy delivery and local issue-state roundtrip, not live-model judgment. Independent verifiers reject incorrect state, missing evidence, extra mutations and missing final reads.", "scripted_only": true, "args": ["--old"], "env": {"GRAFF_NO_CODEDB_GUARD": "1", "GRAFF_AUTO_ISOLATE": "off"}, "github_fixture": {"repo": "fixture/primary", "issues": {"101": {"number": 101, "title": "recurrence fixture", "body": "Previously fixed fixture recurrence.", "state": "CLOSED", "stateReason": "COMPLETED", "comments": [], "url": "https://github.com/fixture/primary/issues/101"}}, "issue_list_denied": true}, "workspace_seed": {"recurrence.md": "**graff:** fixture (latest: fixture)\n**Harness:** not used\n**Surface:** terminal\n**Platform:** fixture\n\n## Symptom\nThe fixture failure recurs on the current fixture release.\n\n## Repro\nRepeat the local fixture operation.\n"}, "prompt": "Report the supplied fixture findings using only the installed local gh. Inspect resolution and tested-version evidence, follow canonical duplicate tracking, avoid duplicate issues and report any failed operation accurately.", "script": [{"tool": "bash", "arguments": {"command": "gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason"}}, {"text": "Issue search failed with permission denied. No issue was created, commented on or reopened; canonical tracking could not be verified."}], "verify_command": ["python3", "-c", "import json,pathlib\np=pathlib.Path\nexpected=json.loads('{\"101\": {\"number\": 101, \"title\": \"recurrence fixture\", \"body\": \"Previously fixed fixture recurrence.\", \"state\": \"CLOSED\", \"stateReason\": \"COMPLETED\", \"comments\": [], \"url\": \"https://github.com/fixture/primary/issues/101\"}}')\nstate=json.loads(p('gh-state.json').read_text())\nassert state['issues']==expected, ('issue state/evidence mismatch',state['issues'],expected)\nreads=[json.loads(x) for x in p('gh-argv.jsonl').read_text().splitlines()] if p('gh-argv.jsonl').exists() else []\nmutations=[json.loads(x) for x in p('mutations.jsonl').read_text().splitlines()] if p('mutations.jsonl').exists() else []\nassert [(r[1],r[2]) for r in mutations]==[], ('incorrect mutations',mutations)\nassert any(r[:2]==['issue','list'] and '--state' in r and r[r.index('--state')+1]=='all' for r in reads), 'must search all states'\nprint('Independent extended issue lifecycle verified')\n"], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"final_text_contains": "Issue search failed with permission denied. No issue was created, commented on or reopened; canonical tracking could not be verified."}, {"events_at_least": {"match": {"type": "tool_call", "name": "bash"}, "count": 1}}, {"events_at_least": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 1}}, {"events_at_most": {"match": {"type": "tool_call_finished", "name": "bash", "is_error": true}, "count": 1}}], "fixture_exit_codes": {"gh issue list --repo fixture/primary --state all --search 'recurrence fixture' --json number,title,body,state,stateReason": 1}, "fixture_negative_omissions": ["issue list"]}+{"why": "#1701: custom root prompts must retain issue lifecycle guidance; scripted policy-delivery coverage, not live-model judgment.", "scripted_only": true, "prompt": "Prepare a generic fixture report; do not publish anything.", "script": [{"text": "Fixture report prepared locally."}], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"request_contains": {"index": 0, "text": "CUSTOM_ROOT"}}, {"final_text_contains": "Fixture report prepared locally."}], "id": "issue-policy-custom-root-startup", "args": ["--system-prompt", "CUSTOM_ROOT"]}+{"why": "#1701: custom root prompts must retain issue lifecycle guidance; scripted policy-delivery coverage, not live-model judgment.", "scripted_only": true, "prompt": "Prepare a generic fixture report; do not publish anything.", "script": [{"text": "Fixture report prepared locally."}], "assert": [{"request_contains": {"index": 0, "text": "A comment alone does not complete a recurrence report."}}, {"request_contains": {"index": 0, "text": "CUSTOM_ROOT"}}, {"final_text_contains": "Fixture report prepared locally."}], "id": "issue-policy-custom-root-replaced", "controls_before_prompt": [{"type": "set_system_prompt", "text": "CUSTOM_ROOT"}]}diff --git a/scripts/eval-tier2.py b/scripts/eval-tier2.pyindex 732110e0..5d5308e1 100644--- a/scripts/eval-tier2.py+++ b/scripts/eval-tier2.py@@ -9,9 +9,10 @@ in the loop, which is why this tier is not in the pre-push hook.The cases are data - evals/harness_behavior.jsonl - and each one carries theregression it guards. A case scripts the model's replies, so the default run is-offline and free: scripts/eval/mock_model.py replays the script on the fixed-lmstudio port and records what the harness sent back. Point --provider/--model-at a real provider to run the same cases against one.+offline and free: scripts/eval/mock_model.py replays the script on --port and+records what the harness sent back. The default port uses lmstudio; other ports+use a workspace-local OpenAI-compatible router. Point --provider/--model at a+real provider to run the same cases against one.python3 scripts/eval-tier2.py every case, scripted modelpython3 scripts/eval-tier2.py --only todo-empty-write-noop@@ -170,6 +171,19 @@ def execute(case: dict[str, Any], graff: str, port: int,dest = pathlib.Path(workspace) / reldest.parent.mkdir(parents=True, exist_ok=True)dest.write_text(content, encoding="utf-8")+ selected_model = model or "lmstudio"+ if not provider and bound != 1234:+ # lmstudio has a fixed endpoint, not an LMSTUDIO_URL override.+ # Use the existing workspace router so chat AND catalog calls+ # stay on the bound loopback port (including --port 0).+ router = pathlib.Path(workspace) / ".graff" / ".config.router"+ router.parent.mkdir(parents=True, exist_ok=True)+ router.write_text(json.dumps({+ "id": "tier2", "base_url": f"http://127.0.0.1:{bound}/v1",+ "env_key": "TIER2_API_KEY", "default_model": selected_model,+ }), encoding="utf-8")+ env["TIER2_API_KEY"] = "local"+ selected_model = f"tier2/{selected_model}"if case.get("claude_transcripts"):canonical = str(pathlib.Path(workspace).resolve())slug = "".join(c if c.isascii() and c.isalnum() else "-" for c in canonical)@@ -195,7 +209,7 @@ def execute(case: dict[str, Any], graff: str, port: int,# any fixture — a forged record can never carry a live start-id.if case.get("live_peer"):peer = subprocess.Popen(- [graff, "--json", "--yolo", "--model", model or "lmstudio"],+ [graff, "--json", "--yolo", "--model", selected_model],cwd=str(pathlib.Path(workspace) / "nested") if case.get("peer_in_nested_worktree") else workspace, env=env, stdin=subprocess.PIPE,stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, text=True)live_dir = pathlib.Path(workspace) / ".graff" / "live"@@ -208,7 +222,7 @@ def execute(case: dict[str, Any], graff: str, port: int,time.sleep(0.1)if peer.poll() is not None or not live_dir.is_dir() or not any(live_dir.glob("*.json")):raise RuntimeError("Live-peer fixture did not announce before the deadline")- argv = [graff, "--json", "--yolo", "--model", model or "lmstudio"]+ argv = [graff, "--json", "--yolo", "--model", selected_model]if provider:argv += ["--subagent-provider", provider]argv += list(case.get("args", []))@@ -282,7 +296,7 @@ def execute(case: dict[str, Any], graff: str, port: int,peer.kill()if bound:scripted.stop()- # The port is fixed, so let the socket clear before the next case.+ # Let the socket clear before the next case reuses the port.time.sleep(0.05)@@ -363,7 +377,7 @@ def main() -> None:parser.add_argument("--only", action="append", default=[], help="case id (repeatable)")parser.add_argument("--list", action="store_true")parser.add_argument("--dump", help="run one case and print its events and requests")- parser.add_argument("--port", type=int, default=1234, help="scripted-model port")+ parser.add_argument("--port", type=int, default=1234, help="scripted-model port (0 selects a free port)")parser.add_argument("--evidence-dir", type=pathlib.Path, help="retain private events, requests, outcomes and harness traces")parser.add_argument("--provider", help="run against a real provider instead of the script")parser.add_argument("--model", help="model name for --provider")diff --git a/scripts/eval/github_fixture.py b/scripts/eval/github_fixture.pyindex c9dc4639..47352e5b 100644--- a/scripts/eval/github_fixture.py+++ b/scripts/eval/github_fixture.py@@ -7,7 +7,7 @@ import subprocessimport sysGH = r'''-import json, pathlib, subprocess, sys, time+import json, pathlib, subprocess, sys, time, urllib.parseroot=pathlib.Path(__file__).resolve().parent.parentstate=json.loads((root/'gh-state.json').read_text())args=sys.argv[1:]@@ -33,6 +33,75 @@ elif args[:2]==['run','list']:print(json.dumps([{'status':'queued' if status=='pending' else 'completed','conclusion':None if status=='pending' else status}]))elif args[:1]==['api']:print(state.get('base_sha', state['initial_head']) if '/heads/fixture-base' in ' '.join(args) else state.get('remote_head', head))+elif args[:1]==['issue'] and len(args)>1 and args[1] in ('list','view','comment','reopen','create'):+ # Stateful local issue tracker: unsupported operations fail closed, never+ # delegate to a real gh. Both successful and denied mutations are recorded.+ def option(*names, default=None):+ for name in names:+ if name in args:return args[args.index(name)+1]+ return default+ def save():+ (root/'gh-state.json').write_text(json.dumps(state))+ def emit(value):+ fields=option('--json')+ if fields:+ selected=fields.split(',')+ value=[{k:v.get(k) for k in selected} for v in value] if isinstance(value,list) else {k:value.get(k) for k in selected}+ query=option('--jq')+ if query:+ if query not in ('.state','.number','.url','.stateReason'):sys.exit(87)+ print(value[query[1:]])+ else:print(json.dumps(value))+ selected=option('--repo','-R',default=state.get('repo','fixture/primary'))+ if selected!=state.get('repo','fixture/primary'):sys.exit(86)+ issues=state.setdefault('issues',{})+ action=args[1]+ if action=='list':+ if state.get('issue_list_denied'):+ print('GraphQL: Resource not accessible by integration (search)',file=sys.stderr)+ sys.exit(1)+ wanted=option('--state','-s',default='open').upper()+ search=option('--search','-S',default='').lower()+ found=[v for v in issues.values() if (wanted=='ALL' or v['state']==wanted) and (not search or search in (v['title']+' '+v.get('body','')).lower())]+ emit(found[:int(option('--limit','-L',default='30'))])+ else:+ if action=='create':+ number=str(max([int(n) for n in issues]+[0])+1)+ else:+ selector=args[2]+ if '://' in selector:+ url=urllib.parse.urlsplit(selector)+ parts=url.path.strip('/').split('/')+ if url.scheme!='https' or url.netloc!='github.com' or len(parts)!=4 or parts[2]!='issues' or '/'.join(parts[:2])!=selected:sys.exit(86)+ number=parts[3]+ else:number=selector+ if not number.isdecimal() or number not in issues:sys.exit(85)+ if action=='view':+ if issues[number].get('deny_view_after_mutation') and (root/'mutations.jsonl').exists():+ print('GraphQL: Resource not accessible by integration (issue)',file=sys.stderr)+ sys.exit(1)+ emit(issues[number])+ else:+ with (root/'mutations.jsonl').open('a') as f:f.write(json.dumps(args)+'\n')+ if action=='reopen':+ if issues[number].get('deny_reopen'):+ print('GraphQL: Resource not accessible by integration (reopenIssue)',file=sys.stderr)+ sys.exit(1)+ issues[number].update(state='OPEN',stateReason='',closedAt=None)+ else:+ if action=='comment' and issues[number].get('deny_comment'):+ print('GraphQL: Resource not accessible by integration (addComment)',file=sys.stderr)+ sys.exit(1)+ body=option('--body','-b')+ if body is None:+ filename=option('--body-file','-F')+ if not filename:sys.exit(84)+ body=sys.stdin.read() if filename=='-' else pathlib.Path(filename).read_text()+ if action=='create':+ issues[number]=dict(number=int(number),title=option('--title','-t',default='fixture'),body=body,state='OPEN',stateReason='',comments=[],url='https://github.com/'+selected+'/issues/'+number)+ else:issues[number].setdefault('comments',[]).append({'body':body})+ save()+ print(issues[number].get('url','https://github.com/'+selected+'/issues/'+number))elif args[:2]==['pr','list']:print('[]')elif args[:2]==['pr','view']:diff --git a/scripts/eval/test_tier2_ports.py b/scripts/eval/test_tier2_ports.pynew file mode 100644index 00000000..da416e3e--- /dev/null+++ b/scripts/eval/test_tier2_ports.py@@ -0,0 +1,117 @@+#!/usr/bin/env python3+"""Scripted evals route custom ports through Graff's local router config."""+import importlib.util+import json+import os+from pathlib import Path+import subprocess+import tempfile+import unittest+from unittest.mock import Mock, patch++spec = importlib.util.spec_from_file_location('tier2_ports_runner', Path(__file__).parents[1] / 'eval-tier2.py')+tier2 = importlib.util.module_from_spec(spec)+spec.loader.exec_module(tier2)+++class ScriptedPorts(unittest.TestCase):+ def capture_launch(self, requested, bound, *, provider=None, model=None, peer=False):+ launches = []++ def capture(argv, **kwargs):+ router = Path(kwargs['cwd']) / '.graff' / '.config.router'+ launches.append((argv, kwargs['env'], json.loads(router.read_text()) if router.exists() else None))+ return subprocess.CompletedProcess(argv, 0, '', '')++ server = Mock()+ server.start.return_value = bound+ server.requests = []+ process = Mock()+ process.poll.return_value = None+ case = {'prompt': 'local test'}+ if peer:+ case.update(live_peer=True, workspace_seed={'.graff/live/fixture.json': '{}'})+ with patch.dict(os.environ, {}, clear=True), \+ patch.object(tier2, 'ScriptedModel', return_value=server), \+ patch.object(tier2.subprocess, 'run', side_effect=capture), \+ patch.object(tier2.subprocess, 'Popen', return_value=process) as popen:+ run = tier2.execute(case, '/fake/graff', requested, provider, model)+ self.assertEqual(run.exit_code, 0)+ if provider:+ server.start.assert_not_called()+ server.stop.assert_not_called()+ else:+ server.start.assert_called_once_with(requested)+ server.stop.assert_called_once()+ if peer:+ self.assertEqual(popen.call_args.args[0], launches[0][0])+ process.kill.assert_called_once()+ return launches[0]++ def assert_route(self, launch, bound, model='lmstudio'):+ argv, env, router = launch+ self.assertEqual(argv[argv.index('--model') + 1], f'tier2/{model}')+ self.assertEqual(router, {+ 'id': 'tier2', 'base_url': f'http://127.0.0.1:{bound}/v1',+ 'env_key': 'TIER2_API_KEY', 'default_model': model,+ })+ self.assertEqual(env[router['env_key']], 'local')++ def test_nondefault_port_reaches_graff_router_and_model_selection(self):+ self.assert_route(self.capture_launch(12681, 12681), 12681)++ def test_os_assigned_port_uses_bound_port_not_requested_zero(self):+ self.assert_route(self.capture_launch(0, 49173), 49173)++ def test_custom_model_stays_on_the_custom_port(self):+ self.assert_route(self.capture_launch(12681, 12681, model='local-model'),+ 12681, 'local-model')++ def test_live_peer_uses_the_same_local_route(self):+ self.assert_route(self.capture_launch(12681, 12681, peer=True), 12681)++ def test_default_port_preserves_lmstudio_behavior(self):+ argv, env, router = self.capture_launch(1234, 1234)+ self.assertEqual(argv[-1], 'lmstudio')+ self.assertIsNone(router)+ self.assertNotIn('TIER2_API_KEY', env)++ def test_provider_mode_is_not_rerouted_and_never_starts_mock(self):+ argv, env, router = self.capture_launch(12681, 0, provider='explicit', model='chosen')+ self.assertEqual(argv[-3:], ['chosen', '--subagent-provider', 'explicit'])+ self.assertIsNone(router)+ self.assertNotIn('TIER2_API_KEY', env)++ def test_independent_process_reaches_mock_on_ephemeral_port(self):+ # Stand-in reads the same documented router metadata as Graff. This+ # exercises a real child process and local HTTP server, with no binary+ # build or external provider needed. Real-Graff checks remain tier 2.+ source = '''#!/usr/bin/env python3+import http.client, json, os, pathlib, sys+from urllib.parse import urlsplit+router = json.loads(pathlib.Path('.graff/.config.router').read_text())+assert sys.argv[sys.argv.index('--model') + 1] == 'tier2/lmstudio'+assert os.environ[router['env_key']] == 'local'+url = urlsplit(router['base_url'])+assert url.hostname == '127.0.0.1' and url.port not in (0, 1234)+conn = http.client.HTTPConnection(url.hostname, url.port, timeout=5)+conn.request('POST', url.path + '/chat/completions', json.dumps({'model': router['default_model']}))+response = conn.getresponse()+assert response.status == 200+reply = json.loads(response.read())['choices'][0]['message']['content']+print(json.dumps({'type': 'turn', 'text': reply}))+conn.close()+'''+ with tempfile.TemporaryDirectory() as temp, patch.dict(os.environ, {}, clear=True):+ executable = Path(temp) / 'graff-standin'+ executable.write_text(source)+ executable.chmod(0o700)+ run = tier2.execute({'prompt': 'local test', 'script': [{'text': 'custom-port-ok'}]},+ str(executable), 0, None, None)+ self.assertEqual(run.exit_code, 0, run.stderr)+ self.assertEqual(run.requests, [{'model': 'lmstudio'}])+ self.assertEqual(run.final_text(), 'custom-port-ok')+++if __name__ == '__main__':+ unittest.main()diff --git a/scripts/test-issue-acp.py b/scripts/test-issue-acp.pynew file mode 100644index 00000000..be6e6119--- /dev/null+++ b/scripts/test-issue-acp.py@@ -0,0 +1,227 @@+#!/usr/bin/env python3+"""Offline #1701: real ACP and line REPL deliver the same /issue brief.++Run against an already-built binary (this script never builds):+ python3 scripts/test-issue-acp.py ./zig-out/bin/graff+All model requests use a temporary mocklocal router and loopback transport.+The scripted model never requests tools; no GitHub operations are performed.+"""+from __future__ import annotations++import json+import os+from pathlib import Path+import queue+import signal+import subprocess+import sys+import tempfile+import threading+import time++ROOT = Path(__file__).resolve().parents[1]+sys.path.insert(0, str(ROOT / "scripts" / "eval"))+from mock_model import ScriptedModel # noqa: E402++REPORT = "fixture recurrence"+REPLY = "Offline issue routing checked."+++def multiline(expression: str) -> str:+ """Read only Zig multiline literals, preserving their exact line breaks."""+ return "\n".join(line.lstrip()[2:] for line in expression.splitlines()+ if line.lstrip().startswith("\\\\"))+++def expected_user_text(report: str) -> str:+ # Compare the entire model-visible brief, not just one policy substring or+ # system-prompt text (which also carries the shared lifecycle guidance).+ source = (ROOT / "src" / "issue_cmd.zig").read_text()+ expression = source.split("pub const brief =", 1)[1].split("\n;", 1)[0]+ before, after = expression.split('++ @import("issue_reporting.zig").guidance ++')+ shared = (ROOT / "src" / "issue_reporting.zig").read_text()+ guidance = multiline(shared.split("pub const guidance =", 1)[1].split("\n;", 1)[0])+ assert "A comment alone does not complete a recurrence report." in guidance+ brief = multiline(before) + guidance + multiline(after)+ return f"{brief}\n\nReport: {report}"+++def environment(workspace: Path, port: int) -> dict[str, str]:+ # Do not inherit credentials, provider overrides, hooks, or real HOME state.+ env = {key: os.environ[key] for key in ("PATH", "TMPDIR", "LANG")+ if key in os.environ}+ config = workspace / ".graff"+ config.mkdir()+ (config / ".config.router").write_text(json.dumps({+ "id": "mocklocal", "base_url": f"http://127.0.0.1:{port}/v1",+ "env_key": "MOCKLOCAL_API_KEY", "default_model": "mock",+ }))+ mcp = workspace / "mcp.json"+ mcp.write_text('{"mcpServers":{}}')+ settings = workspace / ".harness"+ settings.mkdir()+ (settings / "settings.json").write_text(json.dumps({"ai_title": False}))+ env.update(HOME=str(workspace), MOCKLOCAL_API_KEY="local",+ GRAFF_MCP_CONFIG=str(mcp), GRAFF_NO_TELEMETRY="1",+ GRAFF_BEHAVIOR_UPLOAD="off", GRAFF_FLEET="off",+ GRAFF_LEARN_AUTO="off", GRAFF_NO_SMOLIFY="1",+ GRAFF_NO_CODEDB_GUARD="1", NO_COLOR="1")+ return env+++def last_user(request: dict) -> str:+ messages = [message for message in request["messages"]+ if message.get("role") == "user"]+ assert messages, "Model request has no user message"+ content = messages[-1]["content"]+ if isinstance(content, str):+ return content+ return "".join(part.get("text", "") for part in content)+++def terminate(process: subprocess.Popen) -> None:+ if process.poll() is None:+ try:+ os.killpg(process.pid, signal.SIGTERM)+ except ProcessLookupError:+ pass+ try:+ process.wait(timeout=5)+ except subprocess.TimeoutExpired:+ os.killpg(process.pid, signal.SIGKILL)+ process.wait(timeout=5)+ for pipe in (process.stdin, process.stdout):+ if pipe:+ pipe.close()+++def acp(binary: Path, model: ScriptedModel, workspace: Path, env: dict) -> str:+ process = subprocess.Popen(+ [str(binary), "acp", "--model", "mocklocal/mock", "--old", "--yolo",+ "--no-lean", "--no-telemetry"], cwd=workspace, env=env,+ stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,+ text=True, start_new_session=True,+ )+ events = queue.Queue()++ def read() -> None:+ for line in process.stdout:+ try:+ events.put(json.loads(line))+ except ValueError:+ pass+ events.put(None)++ threading.Thread(target=read, daemon=True).start()+ identifier = 0++ def call(method: str, params: dict) -> tuple[dict, list[dict]]:+ nonlocal identifier+ identifier += 1+ process.stdin.write(json.dumps(dict(jsonrpc="2.0", id=identifier,+ method=method, params=params)) + "\n")+ process.stdin.flush()+ deadline = time.monotonic() + 30+ updates = []+ while True:+ value = events.get(timeout=max(0.01, deadline - time.monotonic()))+ assert value is not None, "ACP stopped before its response"+ if value.get("id") == identifier:+ assert "error" not in value, value+ return value, updates+ updates.append(value)++ try:+ call("initialize", {"protocolVersion": 1})+ session, _ = call("session/new", {"cwd": str(workspace), "mcpServers": []})+ sid = session["result"]["sessionId"]++ def prompt(text: str) -> list[dict]:+ response, updates = call("session/prompt", {+ "sessionId": sid, "prompt": [{"type": "text", "text": text}],+ })+ assert response["result"]["stopReason"] == "end_turn", response+ return updates++ for bare in ("/issue", "/issue "):+ before = len(model.requests)+ updates = prompt(bare)+ assert len(model.requests) == before, "Bare /issue started a model turn"+ assert "usage: /issue <what went wrong>" in json.dumps(updates), updates++ before = len(model.requests)+ prompt(f"/issue {REPORT}")+ assert len(model.requests) == before + 1, "Expected exactly one /issue model turn"+ expanded = last_user(model.requests[-1])+ assert expanded == expected_user_text(REPORT), expanded+ assert not expanded.startswith("/issue"), "Literal command reached the model"++ before = len(model.requests)+ prompt(REPORT)+ assert len(model.requests) == before + 1+ assert last_user(model.requests[-1]) == REPORT, "Plain report was expanded"++ before = len(model.requests)+ prompt("/issue fixture whitespace\nsecond line ")+ assert len(model.requests) == before + 1+ assert last_user(model.requests[-1]) == expected_user_text(+ "fixture whitespace\nsecond line")++ # A nested command in a review target is still review input, not an+ # issue report. Review remains higher priority and isolated.+ before = len(model.requests)+ prompt("/review /issue review-fixture")+ assert len(model.requests) == before + 1+ assert last_user(model.requests[-1]) == "/issue review-fixture"+ assert "Perform one read-only, defect-first review pass" in json.dumps(+ model.requests[-1])+ return expanded+ finally:+ terminate(process)+++def repl(binary: Path, model: ScriptedModel, workspace: Path, env: dict) -> str:+ before = len(model.requests)+ # This is the actual line dispatcher, deliberately NOT --json or -p:+ # those surfaces treat slash input differently and would not prove parity.+ process = subprocess.Popen(+ [str(binary), "--model", "mocklocal/mock", "--old", "--yolo",+ "--no-lean", "--no-telemetry"], cwd=workspace, env=env,+ stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,+ text=True, start_new_session=True,+ )+ try:+ stdout, stderr = process.communicate(f"/issue {REPORT}\n/quit\n", timeout=45)+ assert process.returncode == 0, stderr+ assert REPLY in stdout + stderr, "Line REPL did not display the scripted reply"+ assert len(model.requests) == before + 1, "Expected one REPL model turn"+ return last_user(model.requests[-1])+ finally:+ terminate(process)+ if process.stderr:+ process.stderr.close()+++def main() -> None:+ binary = Path(sys.argv[1] if len(sys.argv) > 1 else ROOT / "zig-out/bin/graff").resolve()+ assert binary.is_file(), f"Build the binary separately before running: {binary}"+ model = ScriptedModel([], exhausted_text=REPLY)+ port = model.start(0)+ try:+ with tempfile.TemporaryDirectory(prefix="graff-issue-acp-") as temp:+ workspace = Path(temp)+ acp_workspace = workspace / "acp"+ repl_workspace = workspace / "repl"+ acp_workspace.mkdir()+ repl_workspace.mkdir()+ acp_text = acp(binary, model, acp_workspace, environment(acp_workspace, port))+ repl_text = repl(binary, model, repl_workspace, environment(repl_workspace, port))+ assert acp_text == repl_text == expected_user_text(REPORT)+ print("PASS /issue ACP/REPL full brief and lifecycle parity; bare usage, "+ "plain report, whitespace and review precedence")+ finally:+ model.stop()+++if __name__ == "__main__":+ main()diff --git a/scripts/test-issue-reporting.py b/scripts/test-issue-reporting.pynew file mode 100644index 00000000..2f9014ca--- /dev/null+++ b/scripts/test-issue-reporting.py@@ -0,0 +1,167 @@+#!/usr/bin/env python3+"""Offline #1701 recurrence-policy regression runner; never builds or uses real gh.++Default: run the focused tier-2 cases against an already-built graff.+ python3 scripts/test-issue-reporting.py --graff ./zig-out/bin/graff+Fixture-only: validate fake gh state transitions and independent assertions,+without starting graff or a model server:+ python3 scripts/test-issue-reporting.py --fixture-only++The model replies are scripted. These cases prove root-policy delivery and the+CLI roundtrip/state verification, NOT live-model judgment about when to reopen.+--fixture-only proves just fixture/verifier behavior, NOT policy delivery.+All issue reads/writes stay in fresh temporary directories; no network writes.+"""+import argparse+import json+import os+from pathlib import Path+import subprocess+import sys+import tempfile++REPO = Path(__file__).resolve().parents[1]+sys.path.insert(0, str(REPO / "scripts" / "eval"))+from github_fixture import GH, prepare++PREFIX = "issue-recurrence-"+POLICY = "A comment alone does not complete a recurrence report."+SUFFIXES = {+ "resolved-reopen", "already-open", "duplicate-open-canonical",+ "denied-reopen", "not-planned", "out-of-scope",+ "duplicate-closed-canonical", "duplicate-chain", "no-new-evidence",+ "pre-fix-evidence", "withdrawn", "denied-comment", "denied-final-state",+ "search-failed",+}+++def cases():+ rows = [json.loads(line) for line in+ (REPO / "evals" / "harness_behavior.jsonl").read_text().splitlines()+ if line.strip() and not line.startswith("//")]+ selected = [c for c in rows if c["id"].startswith(PREFIX)]+ assert {c["id"][len(PREFIX):] for c in selected} == SUFFIXES+ assert len(selected) == len(SUFFIXES), "duplicate case IDs"+ for c in selected:+ assert c.get("scripted_only"), "policy asserts require scripted request capture"+ assert {"request_contains": {"index": 0, "text": POLICY}} in c["assert"]+ assert c.get("verify_command"), "prose alone must not pass"+ assert POLICY not in c["prompt"], "must arrive in root policy, not user text"+ assert "live-model judgment" in c["why"]+ compile(c["verify_command"][2], c["id"] + " verifier", "exec")+ compile(GH, "fake gh", "exec")+ return selected+++def execute_fixture(case, omit=None):+ with tempfile.TemporaryDirectory(prefix="graff-issue-fixture-") as temp:+ work = Path(temp)+ env = dict(os.environ, HOME=temp, GRAFF_NO_TELEMETRY="1")+ prepare(work, env, case["github_fixture"])+ for name, content in case.get("workspace_seed", {}).items():+ (work / name).write_text(content)+ occurrences = {}+ for step in case["script"]:+ if "tool" not in step:+ continue+ assert step["tool"] == "bash"+ command = step["arguments"]["command"]+ if omit and omit in command:+ continue+ # Every replay command must resolve to our exact fake executable.+ assert command.startswith("gh issue "), command+ denied = "issue reopen" in command and case["github_fixture"]["issues"]["101"].get("deny_reopen")+ expected = case.get("fixture_exit_codes", {}).get(command, 1 if denied else 0)+ index = occurrences.get(command, 0)+ occurrences[command] = index + 1+ if isinstance(expected, list):+ expected = expected[index]+ command = '"' + str(work / "bin" / "gh") + '"' + command[2:]+ done = subprocess.run(command, shell=True, cwd=work, env=env,+ capture_output=True, text=True, timeout=10)+ assert done.returncode == expected, (command, done.stderr)+ if expected:+ assert "Resource not accessible by integration" in done.stderr+ result = subprocess.run(case["verify_command"], cwd=work, env=env,+ capture_output=True, text=True, timeout=10)+ assert (result.returncode != 0) == bool(omit), (case["id"], omit, result.stderr)+++def smoke_fixture():+ with tempfile.TemporaryDirectory(prefix="graff-issue-smoke-") as temp:+ work = Path(temp)+ env = dict(os.environ, HOME=temp)+ prepare(work, env, {"repo": "fixture/primary", "issues": {}})+ gh = str(work / "bin" / "gh")++ def run(*args, expected=0):+ done = subprocess.run([gh, *args], cwd=work, env=env, text=True,+ capture_output=True, timeout=10)+ assert done.returncode == expected, (args, done.stderr)+ return done.stdout.strip()++ (work / "body.md").write_text("local fixture evidence")+ url = run("issue", "create", "--repo", "fixture/primary", "--title",+ "fixture smoke", "--body-file", "body.md")+ assert url == "https://github.com/fixture/primary/issues/1"+ assert run("issue", "view", url, "--json", "state", "--jq", ".state") == "OPEN"+ run("issue", "comment", "1", "--body", "additional local evidence")+ assert json.loads(run("issue", "list", "--state", "closed")) == []+ rows = json.loads(run("--repo", "fixture/primary", "issue", "list",+ "--state", "all", "--search", "fixture smoke"))+ assert len(rows) == 1 and rows[0]["comments"] == [{"body": "additional local evidence"}]+ assert rows[0]["body"] == "local fixture evidence"+ run("issue", "delete", "1", expected=88) # unsupported: fail closed+ run("issue", "view", "999", expected=85)+ run("issue", "list", "--repo", "unrelated/repo", expected=86)+ run("issue", "view", "https://github.com/unrelated/repo/issues/1", expected=86)+ run("issue", "reopen", "https://github.com/unrelated/repo/issues/1", expected=86)+ run("issue", "view", "https://github.com/fixture/primary/pull/1", expected=86)+ run("issue", "view", "https://example.invalid/fixture/primary/issues/1", expected=86)+ run("issue", "view", "not-an-issue", expected=85)+ print("PASS fixture create/list/view/comment, URL selector, fields/jq and fail-closed behavior")+++def fixture_checks(selected):+ smoke_fixture()+ for case in selected:+ execute_fixture(case)+ # Missing evidence or final confirmation must fail even if final prose+ # still claims success. This is evaluated outside the scripted model.+ omissions = case.get("fixture_negative_omissions", ["issue comment", "issue view 101"])+ if case["id"].endswith("resolved-reopen"):+ omissions = omissions + ["issue reopen"]+ for omitted in omissions:+ execute_fixture(case, omit=omitted)+ print("PASS " + case["id"] + ": fixture outcomes and negative verifier controls")+++def main():+ parser = argparse.ArgumentParser(description=__doc__,+ formatter_class=argparse.RawDescriptionHelpFormatter)+ parser.add_argument("--fixture-only", action="store_true")+ parser.add_argument("--only", action="append", default=[])+ parser.add_argument("--graff", default=str(REPO / "zig-out" / "bin" / "graff"))+ parser.add_argument("--port", type=int, default=1234)+ parser.add_argument("--evidence-dir", type=Path)+ args = parser.parse_args()+ selected = cases()+ if args.only:+ unknown = set(args.only) - {c["id"] for c in selected}+ if unknown:+ parser.error("unknown focused cases: " + ", ".join(sorted(unknown)))+ selected = [c for c in selected if c["id"] in args.only]+ if args.fixture_only:+ fixture_checks(selected)+ return+ command = [sys.executable, str(REPO / "scripts" / "eval-tier2.py"),+ "--graff", str(Path(args.graff).resolve()), "--port", str(args.port)]+ for case in selected:+ command += ["--only", case["id"]]+ if args.evidence_dir:+ command += ["--evidence-dir", str(args.evidence_dir.resolve())]+ raise SystemExit(subprocess.run(command, cwd=REPO).returncode)+++if __name__ == "__main__":+ main()diff --git a/src/acp_live_turn.zig b/src/acp_live_turn.zigindex b4058f27..84d5a02a 100644--- a/src/acp_live_turn.zig+++ b/src/acp_live_turn.zig@@ -116,6 +116,7 @@ pub const LiveTurn = struct {try self.out.flush();}const review_prompt = review.promptFromLine(text);+ const issue_report = @import("issue_cmd.zig").promptFromLine(text);const parent_override = self.root.sys_override;const parent_review_mode = self.root.review_mode;self.root.review_mode = review_prompt != null;@@ -129,7 +130,9 @@ pub const LiveTurn = struct {defer if (context.restore(self.root)) self.root.rebaseContextMeter();if (@import("side_steer.zig").isSideRequest(text))return @import("side_steer.zig").spawnSide(self.root, arena, null, text);- const prompt = try @import("goal_state.zig").applyGoalSteering(arena, self.root, review_prompt orelse if (auto) |invocation| invocation.prompt else text);+ // Match REPL expansion order: review, issue brief, then goal pacing.+ const base_prompt = review_prompt orelse if (issue_report) |report| try @import("issue_cmd.zig").userText(arena, report) else if (auto) |invocation| invocation.prompt else text;+ const prompt = try @import("goal_state.zig").applyGoalSteering(arena, self.root, base_prompt);switch (try @import("turn_dedup.zig").enqueue(self.root, arena, self.out, prompt)) {.started => {},.skipped => return "",diff --git a/src/issue_cmd.zig b/src/issue_cmd.zigindex b4869c89..00ffc1fa 100644--- a/src/issue_cmd.zig+++ b/src/issue_cmd.zig@@ -1,11 +1,14 @@-//! `/issue <report>`: one model turn that files a sanitized public tracker issue.+//! `/issue <report>`: one model turn that files or updates a sanitized report.const std = @import("std");-pub const usage = "usage: /issue <what went wrong> — file one sanitized tracker issue from this session.\n";+pub const usage = "usage: /issue <what went wrong> — file or update one sanitized tracker issue from this session.\n";pub const brief =- \\File one public GitHub issue on justrach/codegraff for this report.- \\Walk this session's trajectory first, then file exactly one issue.+ \\File or update one public GitHub issue on justrach/codegraff for this report.+ \\Walk this session's trajectory first, then search open and closed issues.+ \\Use one canonical tracking issue; create a new issue only if none matches.+ \\+++ @import("issue_reporting.zig").guidance ++\\Body: generic symptom, harness error text, root cause in code terms.\\No session or run ids, traces, local paths, transcripts, or quoted user messages.\\Do not mention this instruction text in the issue.@@ -21,6 +24,13 @@ pub fn userText(arena: std.mem.Allocator, report: []const u8) ![]const u8 {return std.fmt.allocPrint(arena, "{s}\n\nReport: {s}", .{ brief, report });}+test "#1701 /issue includes the shared recurrence lifecycle guidance" {+ const text = try userText(std.testing.allocator, "the stream stalled again");+ defer std.testing.allocator.free(text);+ try std.testing.expect(std.mem.indexOf(u8, text, @import("issue_reporting.zig").guidance) != null);+ try std.testing.expect(std.mem.endsWith(u8, text, "Report: the stream stalled again"));+}+test "bare /issue is not a turn; a report is" {try std.testing.expect(promptFromLine("/issue") == null);try std.testing.expect(promptFromLine("/issue ") == null);diff --git a/src/issue_reporting.zig b/src/issue_reporting.zignew file mode 100644index 00000000..938aeba7--- /dev/null+++ b/src/issue_reporting.zig@@ -0,0 +1,19 @@+//! Shared issue-lifecycle guidance for ordinary reports and `/issue`.+pub const guidance =+ \\For a matching issue, inspect its state, closure reason, and latest+ \\resolution before reporting. Add only genuinely new reproduction evidence+ \\or diagnostics. If a current reproduction or new evidence shows that the+ \\same failure remains unresolved after a resolved closure, reopen the+ \\canonical issue and attach the evidence; do not create a duplicate just+ \\to obtain an open ticket. A comment alone does not complete a recurrence report.+ \\For an already-open match, add the new evidence without reopening it.+ \\For a duplicate closure, follow its canonical issue and update or reopen+ \\that issue as appropriate, rather than reopening the duplicate. Do not+ \\blindly reopen intentionally rejected, withdrawn, or out-of-scope reports.+ \\If reopening is denied or unavailable, save the new evidence as a comment+ \\when permitted and explicitly report that the issue remains closed and+ \\requires a maintainer; never claim reopening succeeded. Verify the final+ \\issue state and report it accurately, including any failed operation.+ \\No fresh evidence or unresolved recurrence means no automatic reopening.+ \\+;diff --git a/src/prompt_golden.zig b/src/prompt_golden.zigindex 1c815824..88425140 100644--- a/src/prompt_golden.zig+++ b/src/prompt_golden.zig@@ -77,9 +77,8 @@ pub const full_prompt =\\...`), never in the current working repository's issue tracker.\\Search open and closed issues there first, by the error text and the\\operation (`gh issue list --repo justrach/codegraff --state all --search- \\'...'`). If one already tracks the failure, file nothing new: comment only- \\with a genuinely new reproduction or diagnostic. If the search fails, keep- \\the finding in your reply instead of filing.+ \\'...'`). If one already tracks the failure, file nothing new.+ \\If the search fails, keep the finding in your reply instead of filing.\\Open the body with the versions it was seen on: the running graff's\\`--version` (inside Harness that is `~/.harness/bin/graff`, not the one on\\PATH) beside the latest release (`gh release view --repo justrach/codegraff@@ -111,6 +110,22 @@ pub const full_prompt =\\generic permission to file, delegate or publish is not disclosure approval.\\A worker unable to ask must return a sanitized draft or request approval\\through its orchestrator, not infer consent. Never disclose secrets.+ \\For a matching issue, inspect its state, closure reason, and latest+ \\resolution before reporting. Add only genuinely new reproduction evidence+ \\or diagnostics. If a current reproduction or new evidence shows that the+ \\same failure remains unresolved after a resolved closure, reopen the+ \\canonical issue and attach the evidence; do not create a duplicate just+ \\to obtain an open ticket. A comment alone does not complete a recurrence report.+ \\For an already-open match, add the new evidence without reopening it.+ \\For a duplicate closure, follow its canonical issue and update or reopen+ \\that issue as appropriate, rather than reopening the duplicate. Do not+ \\blindly reopen intentionally rejected, withdrawn, or out-of-scope reports.+ \\If reopening is denied or unavailable, save the new evidence as a comment+ \\when permitted and explicitly report that the issue remains closed and+ \\requires a maintainer; never claim reopening succeeded. Verify the final+ \\issue state and report it accurately, including any failed operation.+ \\No fresh evidence or unresolved recurrence means no automatic reopening.+ \\\\\\Publication work on a claimed branch, issue, commit, or PR is owned by\\one live session — acknowledge a handoff with peer_message action=handoff;diff --git a/src/prompt_snapshot_tests.zig b/src/prompt_snapshot_tests.zigindex daa29c75..843623e5 100644--- a/src/prompt_snapshot_tests.zig+++ b/src/prompt_snapshot_tests.zig@@ -114,6 +114,7 @@ test "#421: a gated-off capability's tool names disappear from the prompt entire"Never run git commands that discard work","Parallelize tool calls","Be direct and concise",+ "A comment alone does not complete a recurrence report.", // #1701: MCP can report without local tools}) |keep| {std.testing.expect(std.mem.indexOf(u8, out, keep) != null) catch |err| {std.debug.print("config '{s}' lost '{s}'\n", .{ row.name, keep });diff --git a/src/prompt_text.zig b/src/prompt_text.zigindex 7b1a98dc..c0537a22 100644--- a/src/prompt_text.zig+++ b/src/prompt_text.zig@@ -107,9 +107,8 @@ pub const harness_issue_note =\\...`), never in the current working repository's issue tracker.\\Search open and closed issues there first, by the error text and the\\operation (`gh issue list --repo justrach/codegraff --state all --search- \\'...'`). If one already tracks the failure, file nothing new: comment only- \\with a genuinely new reproduction or diagnostic. If the search fails, keep- \\the finding in your reply instead of filing.+ \\'...'`). If one already tracks the failure, file nothing new.+ \\If the search fails, keep the finding in your reply instead of filing.\\Open the body with the versions it was seen on: the running graff's\\`--version` (inside Harness that is `~/.harness/bin/graff`, not the one on\\PATH) beside the latest release (`gh release view --repo justrach/codegraff@@ -146,7 +145,8 @@ pub const public_write_note =\\generic permission to file, delegate or publish is not disclosure approval.\\A worker unable to ask must return a sanitized draft or request approval\\through its orchestrator, not infer consent. Never disclose secrets.-;+ \\+++ @import("issue_reporting.zig").guidance;/// Always present (#840): who may publish to a claimed target. PR readiness/// is not gated (ADR 0250); ownership of a claimed branch or issue still is.diff --git a/src/prompts.zig b/src/prompts.zigindex 96f292fd..1459bf13 100644--- a/src/prompts.zig+++ b/src/prompts.zig@@ -313,7 +313,10 @@ pub fn ultracodeActive(agent: *const Agent) bool {/// by setRootSystemPrompts below) so this stays a pure string funnel for the/// tests and for every non-root agent.pub fn setSystemPrompts(agent: *Agent, base: []const u8, arena: Allocator) !void {- const with_playbook = if (playbook.g_root_inject) playbook.composeRoot(agent.io, arena, base) else base;+ // #1701: custom/learned root personas and later replacements retain the+ // same publication policy as workers. Keep sys_base verbatim for refreshes.+ const protected = if (playbook.g_root_inject) text.withAuthority(arena, base) else base;+ const with_playbook = if (playbook.g_root_inject) playbook.composeRoot(agent.io, arena, protected) else protected;// #391: the pre-compaction note-to-self rides the SAME funnel, one rung// below the user's constraints — a rule outranks the agent's own working// state. Same arming discipline as the two blocks around it, so this staysdiff --git a/src/publication_policy_tests.zig b/src/publication_policy_tests.zigindex 841e4d53..3b7de83d 100644--- a/src/publication_policy_tests.zig+++ b/src/publication_policy_tests.zig@@ -70,6 +70,27 @@ test "#739 custom worker and review personas cannot remove standing policy" {try std.testing.expectEqualStrings(text.public_write_note ++ text.constraint_authority_note ++ text.claim_ownership_note, text.withAuthority(failing.allocator(), "CUSTOM_PERSONA"));}+test "#1701 custom and learned root bases retain lifecycle policy across replacements" {+ const playbook = @import("playbook.zig");+ const saved = playbook.g_root_inject;+ defer playbook.g_root_inject = saved;+ playbook.g_root_inject = true;+ var arena = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena.deinit();+ var agent: @import("agent.zig").Agent = undefined;+ agent.io = std.testing.io;+ for ([_][]const u8{ "CUSTOM_ROOT", "OLDER_LEARNED_ROOT", prompts.main_system_prompt }) |base| {+ try prompts.setSystemPrompts(&agent, base, arena.allocator());+ try std.testing.expectEqualStrings(base, agent.sys_base);+ for ([_][]const u8{ agent.sys_normal, agent.sys_strict, agent.sys_ultra, agent.sys_ultra_strict }) |policy| {+ try std.testing.expect(std.mem.startsWith(u8, policy, base));+ try std.testing.expectEqual(@as(usize, 1), std.mem.count(u8, policy, @import("issue_reporting.zig").guidance));+ try std.testing.expect(std.mem.indexOf(u8, policy, text.public_write_note) != null);+ try std.testing.expect(std.mem.indexOf(u8, policy, text.claim_ownership_note) != null);+ }+ }+}+test "#738 failed prompt allocation never installs only some variants" {const playbook = @import("playbook.zig");const saved = playbook.g_root_inject;