Stale local clones never updated: preflight false-negatives (CLAUDE.md) + work runs on ancient code #226
Labels
No labels
Agent
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
joshtronic/igor#226
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
Filed an
Agentissue onjoshtronic/porksicle.com(#43). The agent blocked it with "CLAUDE.md is missing at the repo root" — butCLAUDE.mdis present onorigin/master(and has been since early in the project).Root cause: stale local clone, never updated
The agent's clone at
~/.local/state/agent/repos/joshtronic/porksicle.comis pinned at the initial commit (c059255"Initial commit") and was never fetched/reset since it was first cloned.CLAUDE.md(and ~everything else — the repo is ~100 commits pastc059255) is absent in that snapshot.The visible bug is an API-vs-clone inconsistency:
CLAUDE.mdpresent → passes, so the issue is discovered + claimed.bin/tick.sh~L3416,[ ! -f "$REPO_PATH/CLAUDE.md" ]) checks the stale local clone → file absent → blocks with the misleading message.Deeper problem: even if CLAUDE.md weren't the tripwire, the worktree (step 14) is cut from the stale clone, so the agent would work on a months-old codebase. Architecture step 12 only clones if missing and never updates an existing clone.
Fix
Before preflight/work — in the claim/clone step (around where
default_branch/R_BASEis resolved, tick.sh ~L3293) or just before the worktree — sync the clone to the remote default-branch tip, e.g.:(or a fast-forward). That fixes both the false CLAUDE.md negative and the work-on-stale-code problem, for every repo, not just this one.
Impact / repro
Any repo whose local clone predates its current HEAD.
joshtronic/porksicle.com#43is blocked by this right now. Workaround to unstick a specific repo:git -C <clone> fetch origin && git -C <clone> reset --hard origin/<default_branch>.Resolved by #227 (merged) -- same bug, independently diagnosed. The API-vs-clone inconsistency you pinned down is exactly right, and
porksicle.com#43was the live casualty.Preflight false-negative: fixed. #227 changes preflight to read
CLAUDE.mdfromorigin/$PR_BASE(the ref the worktree is actually carved from) via a fetch +git cat-file -e, instead of the stale clone working tree. Verified on the real clones:porksicle.comanddevopsafterdark.comflip BLOCK -> PASS, while a genuinely-missing repo (flipflopfrenzy.com) correctly stays blocked.On the "deeper problem" (work runs on ancient code): that part is actually not a bug. Every worktree -- issue work (
tick.shL3441), maintenance (L1281), PR review (L2824) -- is cut fromorigin/<ref>(git worktree add ... "origin/${PR_BASE}"), never from the clone's working tree. The fetch refreshes that ref, so work always runs on current code. The stale clone checkout was only ever read by that one preflight-ftest.On the proposed
git reset --hard origin/$DEFAULT_BRANCH: went surgical ("read origin/ref") instead, because the clone is a deliberate fetch-only anchor (see CLAUDE.md gotchas) -- every surface carves a disposable worktree offorigin/<ref>and nothing should mutate the clone's working tree (areset --hardwould fight the worktree model). Reading the ref we already use keeps that invariant.Closing as fixed by #227. Good catch -- we landed on the same bug from opposite ends.