feat(autonomous-loop): wire cron-sentinel-mutex into Step 1 refresh#3390
Merged
AceHack merged 2 commits intoMay 15, 2026
Merged
Conversation
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>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99b0f1ea6a
ℹ️ 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 canonical autonomous-loop per-tick discipline to include the new cron-sentinel-mutex diagnostic during Step 1 “Refresh worldview”, and documents the expected tick behavior when concurrent peer sessions are detected.
Changes:
- Adds
bun tools/orchestrator-checks/cron-sentinel-mutex.ts --jsonto the Step 1 refresh checklist with backlog cross-references. - Documents a “When peers are detected” decision flow (avoid
git worktree add, do non-git-mutating work, optionally bus-publish deferral, re-check next tick). - Documents a special-case behavior for mutex exit code 251 (
PGREP_ERROR_EXIT).
… 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>
3 tasks
AceHack
added a commit
that referenced
this pull request
May 15, 2026
…ex empirically operational (#3414) 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
Closes the deferred follow-up from PR #3375: wire the cron-sentinel-mutex (now on main as
tools/orchestrator-checks/cron-sentinel-mutex.ts) into the canonical per-tick discipline so the<<autonomous-loop>>tick body invokes it during Step 1 refresh.What changes
docs/AUTONOMOUS-LOOP-PER-TICK.mdStep 1 gains:bun tools/orchestrator-checks/cron-sentinel-mutex.ts --jsongit worktree add(worktree-prune-race rationale, PR shard(tick): 0615Z — worktree-prune-race root cause identified (multi-Otto-CLI self-contention) #3370)PGREP_ERROR_EXIT) — proceed but logDesign choice: advisory, not gate
The discipline reports peer state; the tick body decides. Matches the mutex's design in PR #3375 (returns structured
MutexResult, not a process kill). Lets the tick body do non-conflicting parallel work (bus envelopes, read-only audits) even when peer Otto-CLI is mid-worktree-add.3-surface canonical convergence
Per the file's existing role, this update propagates to:
docs/AUTONOMOUS-LOOP-PER-TICK.mdfromtools/routines/autonomous-loop/SKILL.md)Composes with
Test plan
🤖 Generated with Claude Code