feat(rules): replace local find with git ls-tree on origin/main for ID-allocation discipline#3384
Conversation
…D-allocation Empirical anchor: tick 0742Z on 2026-05-15. Otto-CLI's primary worktree was stuck on detached HEAD (65c7865) from an 8h-stale Lior rebase. The local `find docs/backlog` returned B-0526 as the top, missing B-0527 + B-0528 already on origin/main. My "B-0528 is free" advisory comment to Lior on PR #3323 was wrong as a result. Caught by Copilot review on PR #3379. The fix: use `git fetch origin main` + `git ls-tree -r origin/main` for the merged-state check. This bypasses the local worktree's HEAD and reads actual merged state from the remote ref. Local `find` is now explicitly called out as the wrong tool with the 0742Z incident as the empirical anchor. Composes with refresh-before-decide.md (the invariant) at the per-ID-allocation scope. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a5e7eed34
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Updates the Otto ID-allocation rule to prefer merged-state inspection from origin/main over stale local worktree scans.
Changes:
- Replaces the local
find docs/backlogexample with agit fetch+git ls-treepipeline. - Adds an empirical incident note explaining why local worktree state is unsafe for backlog ID allocation.
- Keeps the in-flight PR check as the second required allocation surface.
Comments suppressed due to low confidence (1)
.claude/rules/otto-channels-reference-card.md:76
- The trace path cited here does not exist in the tree (
docs/hygiene-history/ticks/2026/05/15/0742Z.mdis absent; this directory currently has 0710Z, 0717Z, and 0729Z but no 0742Z). This leaves the new empirical anchor unverifiable from the rule.
See `docs/hygiene-history/ticks/2026/05/15/0742Z.md` for the trace.
…ical anchor Codex P2 catch on PR #3384: my anchor cited docs/hygiene-history/ticks/2026/05/15/0742Z.md, but that file doesn't exist on this branch (#3384's commit predates PR #3381 merge). Chicken-and-egg between cross-PR file refs. Fix: cite PRs #3381 + #3323 (durable on GitHub regardless of branch state) instead of file path. The PR #3381 description contains the file content; readers can navigate to the shard via the PR. Co-Authored-By: Claude <noreply@anthropic.com>
…aint discipline (#3387) * shard(tick): 0813Z — PR #3384 Codex P2 fix (cross-PR file-ref chicken-and-egg); restraint discipline Co-Authored-By: Claude <noreply@anthropic.com> * fix(shard): correct forward-predicted (PR #3386) → actual (PR #3387) Forward-prediction failed: peer-Otto or other PR creation snagged #3386 between my pipe-row write and gh pr create. Follow-up sed-fix to reflect actual PR number. Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
…ion per Copilot Two Copilot threads on PR #3384: 1. git fetch origin main only updates FETCH_HEAD; may leave refs/remotes/origin/main stale under some configs (refspec overrides, partial-clone). Switched to (no branch arg) which updates all configured refs reliably. 2. Name attribution 'Lior' in body prose violates the no-name-in-rule-body convention. Replaced with generic 'peer-agent' (preserves operational meaning; specific attribution lives in the linked tick shard). Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d7c427b3f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| git fetch origin | ||
| git ls-tree -r origin/main -- docs/backlog/ \ | ||
| | awk '{print $4}' | grep -oE "B-[0-9]+" | sort -u -t- -k2 -n | tail -5 |
There was a problem hiding this comment.
Short-circuit ID lookup when fetch fails
The new origin/main check runs git ls-tree even if git fetch origin fails, because the commands are separate lines. In offline/auth-error cases this silently falls back to a stale origin/main, which recreates the exact stale-state ID collision this change is trying to prevent. Make the lookup conditional on a successful fetch (e.g., &&) or add an explicit failure guard before reading origin/main.
Useful? React with 👍 / 👎.
| (which lands `docs/hygiene-history/ticks/2026/05/15/0742Z.md` carrying | ||
| the full trace), plus the correction comment on |
| # `git fetch origin` (no branch arg) updates ALL configured remote-tracking | ||
| # refs reliably; the form `git fetch origin main` updates FETCH_HEAD but | ||
| # may not refresh refs/remotes/origin/main under all configs (refspec | ||
| # overrides, partial-clone, etc.). | ||
| git fetch origin |
| # `git fetch origin` (no branch arg) updates ALL configured remote-tracking | ||
| # refs reliably; the form `git fetch origin main` updates FETCH_HEAD but | ||
| # may not refresh refs/remotes/origin/main under all configs (refspec | ||
| # overrides, partial-clone, etc.). |
…chive active (#3388) * shard(tick): 0820Z — PR #3385 merged; PR #3384 2-Copilot-thread fix; Lior archive automation observed active Co-Authored-By: Claude <noreply@anthropic.com> * fix(shard): close (PR TBD) → (PR #3388) per post-PR-create discipline Co-Authored-By: Claude <noreply@anthropic.com> * fix(shard): add explicit links for 'named attribution lives in linked tick shard' per Copilot P2 Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
Summary
Updates the ID-allocation discipline in `.claude/rules/otto-channels-reference-card.md` to use `git fetch origin main` + `git ls-tree -r origin/main` instead of local `find docs/backlog`. Empirical anchor: tick 0742Z's "B-0528 free" misallocation that reached a public PR comment before Copilot caught it.
Root cause of the failure mode: when Otto-CLI's primary worktree is stuck on a stale HEAD (detached from an abandoned rebase, a feature branch behind main, etc.), local `find docs/backlog` returns stale state. The fix queries the remote ref directly so the answer is independent of local worktree state.
Test plan
🤖 Generated with Claude Code