Skip to content

feat(rules): add borrow-on-existing pattern to claim-acquire-before-worktree-work.md for concurrent-Otto-CLI fallback#3377

Merged
AceHack merged 1 commit into
mainfrom
feat/rule-borrow-pattern-otto-cli-2026-05-15
May 15, 2026
Merged

feat(rules): add borrow-on-existing pattern to claim-acquire-before-worktree-work.md for concurrent-Otto-CLI fallback#3377
AceHack merged 1 commit into
mainfrom
feat/rule-borrow-pattern-otto-cli-2026-05-15

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 15, 2026

Summary

Adds a new section "Borrow-on-existing pattern — concurrent-Otto-CLI fallback" to .claude/rules/claim-acquire-before-worktree-work.md documenting the operational workaround for the worktree-prune-race identified in B-0530.

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 branch-switch scope.

Empirical validation: 7+ successful borrows of /private/tmp/zeta-otto-cli-0027z-sidetick across 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.ts ships.

Test plan

  • bun x markdownlint-cli2 .claude/rules/claim-acquire-before-worktree-work.md → 0 violations
  • Pattern dog-fooded: this PR itself authored via the borrow pattern on the 0027z worktree
  • Linked rule + backlog refs
  • CI required checks pass
  • Auto-merge fires

🤖 Generated with Claude Code

…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>
Copilot AI review requested due to automatic review settings May 15, 2026 07:21
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@AceHack AceHack enabled auto-merge (squash) May 15, 2026 07:22
@AceHack AceHack merged commit d41bd8d into main May 15, 2026
23 checks passed
@AceHack AceHack deleted the feat/rule-borrow-pattern-otto-cli-2026-05-15 branch May 15, 2026 07:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants