gitreins-tier2-verdict-stale-tree-judges-premerge-main-tree
Done. I diagnosed the problem against the actual gitreins 0.15.0 source (pulled from PyPI) and produced a verified solution.
~/gitreins-tier2-verdict-stale-tree.md (435 lines)
Root cause: get_workdir() (gitreins/cli.py:274) returns the process CWD's repo root. cmd_task_complete (:1351) and cmd_judge (:2063) use it for both the task store and the judge. When a task's work is on an unmerged worktree branch, it grades the main tree — which still has the baseline (the 1357 leak findings), so Tier 1 fails before the change is ever seen.
Three supporting facts made it worse:
- The verdict is stamped worktree/branch/commit of the graded tree (engine/persist.py:790), so a main-tree verdict is recorded with wrong provenance.
- WorktreeManager._matching_verdicts/_find_verdict (engine/worktree_manager.py:941,961) only accept verdicts matching the worktree path + branch + commit, so the stray FAIL also blocks the intended worktree merge path.
- Re-running inside the worktree doesn't work: .gitreins/tasks.yaml is gitignored and absent from linked worktrees → Task not found.
-p1 patch)_resolve_judgment_tree() — keeps the task store in canonical main, points the judge at the registered worktree (with --tree override)._warn_if_verdict_tree_mismatch() — on FAIL, compares judged HEAD vs worktree branch tip and labels mismatches STALE, so a wrong-tree verdict is never treated as a code failure..gitreins/tasks.yaml.lock in _is_clean so a completed task isn't blocked from merging.task complete from main → Overall: FAIL; from worktree → Task not found.task complete from main → Judging task worktree: … → Overall: PASS; forced --tree main → WARNING: FAIL verdict is STALE; worktree merge then fast-forwards and the leak is gone.tests/test_task_complete_worktree.py; full run of the new test + all three worktree suites = 78 passed.# Evidence - Problem class: gitreins-tier2-verdict-stale-tree-judges-premerge-main-tree - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-30T17:14:57.228Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "gitreins task complete fired from the MAIN tree while the task's work lived only on an unmerged worktree branch \u2014 tier2 judged the main checkout, found no work (grep=1357 leaks), and FAILed a fully verified change. Fix: run task complete only after the branch is merged into the tree the judge sees, or point the judge at the worktree; also re-verify FAIL verdicts against HEAD before treating them as code failures (known stale-tree verdict drift).", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "gitreins-tier2-verdict-stale-tree-judges-premerge-main-tree", "provider": "openrouter", "solved_at": "2026-09-30T17:14:57.231Z", "version": ""}Done. I diagnosed the problem against the actual gitreins 0.15.0 source (pulled from PyPI) and produced a verified solution.
~/gitreins-tier2-verdict-stale-tree.md (435 lines)
Root cause: get_workdir() (gitreins/cli.py:274) returns the process CWD's repo root. cmd_task_complete (:1351) and cmd_judge (:2063) use it for both the task store and the judge. When a task's work is on an unmerged worktree branch, it grades the main tree — which still has the baseline (the 1357 leak findings), so Tier 1 fails before the change is ever seen.
Three supporting facts made it worse:
- The verdict is stamped worktree/branch/commit of the graded tree (engine/persist.py:790), so a main-tree verdict is recorded with wrong provenance.
- WorktreeManager._matching_verdicts/_find_verdict (engine/worktree_manager.py:941,961) only accept verdicts matching the worktree path + branch + commit, so the stray FAIL also blocks the intended worktree merge path.
- Re-running inside the worktree doesn't work: .gitreins/tasks.yaml is gitignored and absent from linked worktrees → Task not found.
-p1 patch)_resolve_judgment_tree() — keeps the task store in canonical main, points the judge at the registered worktree (with --tree override)._warn_if_verdict_tree_mismatch() — on FAIL, compares judged HEAD vs worktree branch tip and labels mismatches STALE, so a wrong-tree verdict is never treated as a code failure..gitreins/tasks.yaml.lock in _is_clean so a completed task isn't blocked from merging.task complete from main → Overall: FAIL; from worktree → Task not found.task complete from main → Judging task worktree: … → Overall: PASS; forced --tree main → WARNING: FAIL verdict is STALE; worktree merge then fast-forwards and the leak is gone.tests/test_task_complete_worktree.py; full run of the new test + all three worktree suites = 78 passed.# Evidence - Problem class: gitreins-tier2-verdict-stale-tree-judges-premerge-main-tree - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-30T17:14:57.228Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "gitreins task complete fired from the MAIN tree while the task's work lived only on an unmerged worktree branch \u2014 tier2 judged the main checkout, found no work (grep=1357 leaks), and FAILed a fully verified change. Fix: run task complete only after the branch is merged into the tree the judge sees, or point the judge at the worktree; also re-verify FAIL verdicts against HEAD before treating them as code failures (known stale-tree verdict drift).", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "gitreins-tier2-verdict-stale-tree-judges-premerge-main-tree", "provider": "openrouter", "solved_at": "2026-09-30T17:14:57.231Z", "version": ""}