Skip to content

feat(autonomous-loop): wire cron-sentinel-mutex into Step 1 refresh#3390

Merged
AceHack merged 2 commits into
mainfrom
feat/wire-cron-sentinel-mutex-into-tick-discipline-otto-cli-2026-05-15
May 15, 2026
Merged

feat(autonomous-loop): wire cron-sentinel-mutex into Step 1 refresh#3390
AceHack merged 2 commits into
mainfrom
feat/wire-cron-sentinel-mutex-into-tick-discipline-otto-cli-2026-05-15

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 15, 2026

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.md Step 1 gains:

  • A 4th bullet in the refresh list: bun tools/orchestrator-checks/cron-sentinel-mutex.ts --json
  • A new "When peers are detected" sub-section documenting 4 deferral steps:
    1. Avoid git worktree add (worktree-prune-race rationale, PR shard(tick): 0615Z — worktree-prune-race root cause identified (multi-Otto-CLI self-contention) #3370)
    2. Continue with non-git-mutating work (bus, audits, planning)
    3. Bus-publish a deferral envelope if substrate matters past this tick
    4. Re-check next tick (contention windows resolve in 1-3 min)
  • Special case: exit code 251 (PGREP_ERROR_EXIT) — proceed but log

Design 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:

  • Otto-CLI (auto-loaded next cold-boot)
  • Otto-Desktop routine (cites docs/AUTONOMOUS-LOOP-PER-TICK.md from tools/routines/autonomous-loop/SKILL.md)
  • B-0448 cloud routine (when shipped — will cite this file)

Composes with

  • PR #3370 — worktree-prune-race root cause + B-0519 Pattern 8
  • PR #3375 — mutex implementation
  • PR #3377 — borrow-on-existing pattern (alternative under peer contention)
  • PR #3386 — bulk rule-link depth fix on affected shards

Test plan

  • Markdownlint clean
  • Both relative links verified to resolve
  • CI green
  • Auto-merge fires

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 15, 2026 08:41
@AceHack AceHack enabled auto-merge (squash) May 15, 2026 08:41
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread docs/AUTONOMOUS-LOOP-PER-TICK.md Outdated
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

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 --json to 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).

Comment thread docs/AUTONOMOUS-LOOP-PER-TICK.md Outdated
Comment thread docs/AUTONOMOUS-LOOP-PER-TICK.md Outdated
Comment thread docs/AUTONOMOUS-LOOP-PER-TICK.md Outdated
… 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>
@AceHack AceHack merged commit 1f4b49e into main May 15, 2026
21 checks passed
@AceHack AceHack deleted the feat/wire-cron-sentinel-mutex-into-tick-discipline-otto-cli-2026-05-15 branch May 15, 2026 09:25
AceHack added a commit that referenced this pull request May 15, 2026
…ex empirically operational (#3414)

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