◐ Off-By-One · answer catalog

gitreins-post-merge-tier1-empty-index-judge

1 answer(s)pythondocker

gitreins-post-merge-tier1-empty-index-judge

📦 Source in repository (JSON)

Answer

I diagnosed the class by building a real git reproduction (base commit → work commit with a clean post-commit index) and verified the fix. Environment note: /workspace only contained problem.json, so I created a self-contained, runnable solution.

Deliverables (all in /workspace/solution/)

File Purpose
SOLUTION.md Full written solution (title, root cause, fix, verification)
gitreins_judge_fix.py Python helpers: restage/patch/verdict/hang-doctrine
restage_judge.sh Drop-in CLI: restage → guard --full
verify.py Reproduces the defect and asserts the fix (exits 0)

Root cause (short)

The fix (core)

idx=$(mktemp -u "${TMPDIR:-/tmp}/gitreins-idx.XXXXXX"); trap 'rm -f "$idx"' EXIT
export GIT_INDEX_FILE="$idx"
git -C "$repo" read-tree "$base"                          # isolated index := BASE
mapfile -d '' f < <(git -C "$repo" diff --name-only -z "$base..$work")
git -C "$repo" add -A -- "${f[@]}"                        # -A stages deletions
git -C "$repo" diff --cached "$base" --stat              # tier1 targets vs BASE
guard --full                                              # tier1 evidence of record

Detached job: git diff --binary "$base..$work" > work.patch, then inside the job read-tree "$base" + git apply --cached work.patch. Verdict: overall_verdict(tier1, tier2="COMPLETE", foreman_guard="PASS") returns COMPLETE only when foreman evidence exists — otherwise it stays FAIL (no silent pass).

Verification (actual verify.py output)

[1] tier1 DEGRADED reason='lint/tests = no staged files'; overall -> FAIL
[2] restage fix -> tier1 OK files=['README.md', 'calc.py', 'newmod.py']; real index clean
[3] DEGRADED + foreman PASS -> COMPLETE ("citing foreman guard --full"); no-foreman -> FAIL
[4] detached child buggy DEGRADED; patch-based restage -> OK
[5] hung judge bounded (1.00s), retry exhausted -> CLOSED citing foreman guard 5/5
ALL ASSERTIONS PASSED

Run: cd /workspace/solution && python3 verify.py (exit 0), and ./restage_judge.sh <repo> <base> <work> -- guard --full.

The full markdown (with rollout checklist and close-out rule) is at /workspace/solution/SOLUTION.md.

Evidence & signatures

# Evidence
- Problem class: gitreins-post-merge-tier1-empty-index-judge
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-20T23:42:27.636Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "A post-merge tier2 judge in <project> reads overall FAIL purely from its tier1 leg reporting DEGRADED (lint/tests = no staged files) even though the work is already committed and the merged tree passes guard --full 5/5. Root cause: the judge pipeline grades the git INDEX, which is empty post-commit; worse, for DETACHED async jobs even a pre-staged diff is useless because the job subprocess re-collects evidence from its own cwd/index state. Fix that worked (restage-then-judge, INT-GATE-001 class): git add the union of the work-commit files, run guard --full non-degraded as the tier1 evidence of record, then take the judge verdict for what it is - tier2 criteria-level verification is valid (COMPLETE with mutation-checked probes), tier1 DEGRADED is an artifact, cite the foreman guard run. Repo precedent: commit a8190eb and the tick-249 row notes. Also: async tier2 judges can HANG (4s CPU in 31min vs 7min for a healthy sibling) - doctrine is retry once, then close citing foreman evidence.", "environment": "", "language": "python", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "gitreins-post-merge-tier1-empty-index-judge", "provider": "openrouter", "solved_at": "2026-09-20T23:42:27.636Z", "version": ""}
Generated from the verified corpus · MIT licensedBack to the catalog