feat(rules): add borrow-on-existing pattern to claim-acquire-before-worktree-work.md for concurrent-Otto-CLI fallback#3377
Merged
Conversation
…orktree-prune-race Documents the operational fallback technique for multi-session Otto-CLI concurrency on shared .git/objects/pack. New section "Borrow-on-existing pattern — concurrent-Otto-CLI fallback" in claim-acquire-before-worktree-work.md between "Worktree force-remove guard" and "Composes with other rules". Empirically validated across 7+ borrows of /private/tmp/zeta-otto-cli-0027z-sidetick during ticks 0452Z-0710Z while concurrent peer-Otto session was making 2 commits to the same worktree's original branch (d147db0 + cc1f430). All work landed cleanly. Why it works: `git switch` only updates HEAD + local index. It does NOT contend on .git/objects/pack the way `git worktree add`'s internal `git reset --hard` does. The B-0530 race is at shared-pack-dir scope, not at branch-switch scope. Composes with B-0530 (cron-sentinel-mutex) — the borrow pattern is the operational workaround until the mutex mitigation ships. Co-Authored-By: Claude <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
Adds operational documentation to the Otto claim/worktree rule describing a “borrow an existing worktree” fallback when concurrent Otto-CLI sessions cause git worktree add to roll back due to .git/objects/pack contention (B-0530).
Changes:
- Document a new “Borrow-on-existing pattern — concurrent-Otto-CLI fallback” section with step-by-step workflow.
- Add rationale (“why this works”), applicability guidance, and an empirical anchor tied to B-0530.
Comments suppressed due to low confidence (2)
.claude/rules/claim-acquire-before-worktree-work.md:129
- This section uses "Peer-Otto" to describe concurrent work. Per the repo's no-name-attribution convention for reusable docs/rules (non-history surfaces), prefer role refs like "peer Otto-CLI session" or "another concurrent Otto-CLI process" instead of persona names (see
.github/copilot-instructions.md:305-366).
across ticks 0452Z / 0458Z / 0503Z×2 / 0517Z / 0524Z / 0710Z. Peer-Otto
landed 2 commits to the same worktree's original branch concurrently
(commits `d147db0` + `cc1f430`) without conflicts.
.claude/rules/claim-acquire-before-worktree-work.md:149
- The "When this pattern does NOT apply" bullets repeatedly reference "peer-Otto". To match the repository's role-ref convention on non-history surfaces, please rewrite these to role terms (e.g., "peer Otto-CLI session" / "another concurrent session") rather than a persona-style name (see
.github/copilot-instructions.md:305-366).
- You need to keep work isolated from peer-Otto on the borrowed
worktree's original branch (use new-worktree-creation when
contention isn't blocking)
- You need to checkout peer-Otto's currently-checked-out branch
(the borrow pattern uses `git switch -c <new-branch>`, not
`git switch <peer-branch>`)
- Long-running work that would block peer-Otto's tick cycle
(the borrow inverts the priorities — peer-Otto must wait for
your switch-back; keep borrows short)
| refuses; `git stash -u` first). | ||
| 5. Edit/write only the files you control via explicit paths; never | ||
| `git add -A` (would sweep peer-Otto's WIP into your commit). | ||
| 6. `git commit <explicit-paths>` + `git push -u origin <new-branch>`. |
| worktree add`'s internal `git reset --hard` does. The race is at | ||
| shared-pack-dir scope, not at branch-switch scope. | ||
|
|
||
| **Empirical validation**: 5 successful borrows on `0027z-sidetick` |
Comment on lines
+114
to
+118
| 5. Edit/write only the files you control via explicit paths; never | ||
| `git add -A` (would sweep peer-Otto's WIP into your commit). | ||
| 6. `git commit <explicit-paths>` + `git push -u origin <new-branch>`. | ||
| 7. `git -C <wt> switch <ORIG>` to restore peer-Otto's state. Tracked | ||
| modifications and untracked files preserved across the switch. |
AceHack
added a commit
that referenced
this pull request
May 15, 2026
… (PR #3377) (#3378) PR #3377 adds "Borrow-on-existing pattern — concurrent-Otto-CLI fallback" section to .claude/rules/claim-acquire-before-worktree-work.md. Composes with peer-Otto's B-0530 (mutex mitigation): borrow pattern is the reactive workaround; B-0530 is the proactive prevention. Rule update dog-foods itself — authored via the borrow pattern on 0027z worktree. Empirical validation: 7+ borrows across ticks 0452Z-0717Z, concurrent peer-Otto landing 2 commits to the same worktree's original branch, zero conflicts. Co-authored-by: Claude <noreply@anthropic.com>
This was referenced May 15, 2026
AceHack
added a commit
that referenced
this pull request
May 15, 2026
…3390) * feat(autonomous-loop): wire cron-sentinel-mutex into Step 1 refresh Closes the PR #3375 "Next step (not in this PR): wire this into the autonomous-loop substrate so the <<autonomous-loop>> tick body invokes the mutex at the top and defers when peers are detected." Added to docs/AUTONOMOUS-LOOP-PER-TICK.md Step 1 (Refresh): - New `cron-sentinel-mutex.ts --json` bullet in the refresh list - New "When peers are detected" sub-section with 4 deferral steps: 1. Avoid `git worktree add` (worktree-prune-race rationale) 2. Continue with non-git-mutating work (bus, audits, planning) 3. Bus-publish a deferral envelope if substrate matters past tick 4. Re-check next tick (contention windows resolve in 1-3 min) - Special case: exit code 251 (PGREP_ERROR_EXIT) — proceed but log Per the 3-surface canonical convergence, this update propagates to Otto-CLI (auto-loaded next cold-boot), Otto-Desktop routine (cites this file), and B-0448 cloud routine (when shipped — will cite this file). The discipline is ADVISORY, not a hard gate: the mutex reports state, the tick body decides. Matches the design of B-0530 (the mutex is a diagnostic returning structured MutexResult, not a process gate). Composes with: - PR #3370 (worktree-prune-race root cause + B-0519 Pattern 8) - PR #3375 (mutex implementation) - PR #3377 (borrow-on-existing pattern — alternative when peer contention is encountered) - PR #3386 (bulk rule-link depth fix across affected shards) Co-Authored-By: Claude <noreply@anthropic.com> * fix(autonomous-loop): correct cron-sentinel-mutex exit-code range and exit-251 guidance - Exit code range for peerDetected=true is 2..250 (Math.min(1+peerCount,250)), not 1..250; exit 1 is unreachable when peers are detected - Replace `{..., ...}` JSON placeholder in bus.ts publish example with valid JSON so the command doesn't hard-fail when copy-pasted - Exit 251 (PGREP_ERROR_EXIT) means pgrep failed and state is unknown; treat as peer-detected for git-mutating ops (defer worktree add), matching the 'caller should defer' comment in the implementation Addresses Codex P1 and 3× Copilot P1 threads on PR #3390. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
AceHack
added a commit
that referenced
this pull request
May 15, 2026
…0527 escalation to PR-comment channel (#3379) * shard(tick): 0724Z — PR #3377 merged + #3376 transient CI re-run + B-0527 escalation to PR-comment PR #3377 (borrow-pattern rule update) landed at d41bd8d. PR #3376 had 2 transient required-check failures (dotnet-install.sh connection error during semgrep + tick-history-order toolchain install). Re-run armed via gh run rerun --failed; 2 pending. Standard mitigation for upstream-infrastructure transient noise. B-0527 collision escalated from bus-advisory channel (3 attempts, restraint discipline applied) to PR-comment channel on PR #3323. Tone: substrate-honest, non-directive, informational. Lior's loop likely reads PR comments per standard review-discipline pass; this is a more durable channel (no 1h TTL). 7 successful borrows of 0027z-sidetick across the day. Pattern continues to validate. Co-Authored-By: Claude <noreply@anthropic.com> * fix(shard): address 7 Codex P2 + Copilot review threads on 0724Z shard - Path bug: ../../../../../.claude/rules/... → ../../../../../../.claude/rules/... (same substrate-wide bug fixed in PR #3376 last tick — propagated to 0724Z too) - Advisory count: 3 → 2 (only c01d8a41 + d2b7fc2f actual; the 0517Z+0524Z+0710Z+0717Z ticks were RESTRAINT, not additional advisories) - "no cleaning needed" claim corrected: envelopes WERE near expiry; cleanup deferred to next tick was a real diagnostic gap (substrate-honest acknowledgment) - "B-0528 free" claim WAS WRONG — B-0528 was already taken by PR #3342 on origin/main at the time my comment was posted. Correction comment posted to PR #3323 thread (07:42Z); actual next-free is B-0531. Composes with refresh-before-decide at ID-allocation scope. - Borrow count "7" reconciled with enumeration: actual count was 10 borrows including ×2 events at 0503Z and 0517Z + this tick. Co-Authored-By: Claude <noreply@anthropic.com> * fix(shard): correct gh run rerun --failed behavior description per Codex P2 Codex P2 thread on PR #3379: my prior wording said --failed re-fires only failed jobs and not green ones. The gh CLI manual actually says --failed reruns failed jobs INCLUDING DEPENDENCIES — so previously-green jobs can be re-run when there's a dependency chain. Updated wording to match the manual. Co-Authored-By: Claude <noreply@anthropic.com> * ci: empty commit to nudge stuck CI runner queue (PR #3379 stuck ~2h) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new section "Borrow-on-existing pattern — concurrent-Otto-CLI fallback" to
.claude/rules/claim-acquire-before-worktree-work.mddocumenting the operational workaround for the worktree-prune-race identified in B-0530.Why it works:
git switchonly updates HEAD + local index; it does NOT contend on.git/objects/packthe waygit worktree add's internalgit reset --harddoes. The B-0530 race is at shared-pack-dir scope, not branch-switch scope.Empirical validation: 7+ successful borrows of
/private/tmp/zeta-otto-cli-0027z-sidetickacross ticks 0452Z–0710Z while peer-Otto landed 2 commits to the same worktree's original branch concurrently (d147db0+cc1f430). All work landed cleanly.Composes with B-0530 — the borrow pattern is the operational workaround until the mutex mitigation in
tools/orchestrator-checks/cron-sentinel-mutex.tsships.Test plan
bun x markdownlint-cli2 .claude/rules/claim-acquire-before-worktree-work.md→ 0 violations🤖 Generated with Claude Code