Review: Bug: pre-spawn-freshness hook corrupts git index when on main
Verdict: NEEDS_REFINEMENT
Template Completeness
- [x] Type — Bug
- [x] Lineage — Standalone, discovered during palinks session
- [x] Repo —
ldraney/claude-custom - [x] What Broke — detailed, includes root cause (
update-refmoves ref without updating index/working tree) - [x] Repro Steps — 5 clear steps
- [x] Expected Behavior — clear
- [x] Environment — Linux + macOS, specific hook and line number
- [x] Acceptance Criteria — 4 criteria
- [x] Related — project-pal-e-agency, reflog evidence
All 9 required bug template sections present.
Traceability
- [x] story:agent-reliability label — present on board item
- [ ] story note MISSING — [SCOPE]
story:agent-reliabilitydoes not exist inproject-pal-e-agencyuser-stories section. Available stories: superuser-manage, superuser-onboard, pm-scope, dev-execute, qa-review, validation-execute, dottie-docs. Create user story entry or reassign to an existing story (e.g.story:superuser-manage). - [x] arch:claude-hooks label — present on board item
- [ ] arch note MISSING — [SCOPE]
arch-claude-hooksnote does not exist in pal-e-docs (404). Create architecture notearch-claude-hooksfor the hooks subsystem. Note: issue #236 tracks creating missing arch notes but does not specifically coverarch-claude-hooks. - [x] Forgejo issue — ldraney/claude-custom#296, open
File Targets
- [x]
hooks/pre-spawn-freshness.shline 64 — verified: containsgit -C "$CWD" update-ref refs/heads/main "$REMOTE_SHA" "$LOCAL_SHA" 2>/dev/null || exit 0 - [x] Confirmed: hook does NOT check which branch the user is on before running
update-ref(nosymbolic-refor branch detection) - [x] Confirmed: hook does NOT source
forgejo-helper.shand does NOT call_sync_working_tree
Repo Placement
Correct. Issue filed on
ldraney/claude-custom, fix targets hooks/pre-spawn-freshness.sh in the same repo. Single repo, no cross-repo concerns.Dependencies
No blocking items found on the board. Related but non-blocking:
- Issue #294 — "SOP: Enforce worktree-first — never develop on main" (complementary prevention, not a dependency)
- Issue #248 — "Add hook to block destructive git commands" (tangentially related)
Acceptance Criteria
4 criteria, all agent-verifiable:
- AC1: When on main, use
git merge --ff-only— testable by checking out main, creating upstream commits, and verifying behavior - AC2: When on feature branch, keep
update-ref— testable by checking out a branch and verifying code path - AC3: No phantom staged changes — testable via
git statusafter hook runs - AC4: Fail-open on errors — testable by simulating network/merge failures
Criteria are well-scoped. No missing criteria detected.
Blast Radius
post-mcp-merge-rebase.sh(line 68) — uses identicalupdate-refpattern but is ALREADY PATCHED: it calls_sync_working_tree()fromforgejo-helper.sh(line 74) to reset the working tree afterupdate-ref.forgejo-helper.sh(lines 472-494) — already has a_sync_working_tree()helper that detects if user is on the default branch and doesgit reset --hard HEADif no uncommitted changes. This is an alternative fix approach the implementing agent should be aware of.- The issue proposes
merge --ff-only(which updates HEAD + index + working tree atomically) rather thanupdate-ref+reset --hard. Both approaches solve the problem;merge --ff-onlyis arguably cleaner as it avoids the destructivereset --hard.
Decomposition Assessment
1 file target, 1 repo, 4 acceptance criteria, estimated agent work under 5 minutes. No decomposition needed.
Recommendations
[SCOPE]Create user story entrystory:agent-reliabilityonproject-pal-e-agencyuser-stories section, or reassign to existingstory:superuser-manage.[SCOPE]Create architecture notearch-claude-hooksfor the hooks subsystem in pal-e-docs.[BODY]Add note in Related section referencingforgejo-helper.sh:_sync_working_tree()as existing art for the implementing agent's awareness.