Skip to content

feat(server): wake the watcher when an unsettled top-level thread fails - #205

Open
nullStack65 wants to merge 3 commits into
release/native-0.1.10from
feat/clo-1066-thread-failed
Open

nullStack65 wants to merge 3 commits into
release/native-0.1.10from
feat/clo-1066-thread-failed

Conversation

@nullStack65

Copy link
Copy Markdown
Owner

A failed top-level thread with no launching thread, including one a person created, tells nobody. Today only the 15-minute fleet watchdog finds it. This PR wakes the configured watcher thread (modelAlertWatcher) when that happens. The watchdog stays as it is.

Stacked on #204 (the release-branch hook baseline fix). The first two commits here are #204's. Merge #204 first; this PR's own change is the top commit, feat(server): wake the watcher when an unsettled top-level thread fails.

Change

  1. ThreadEventAlerts adds a thread-failed event, judged when a run ends. It fires only for a thread that:
    • has status failed, a latest run, and no live run;
    • is top-level (no parent lineage) and listed, not delegated (delegatedFrom) or a side chat;
    • is not archived, and not settled.
      The finding keys on the failed run's id, so replaying the same run is not a second wake. It stops holding once the thread's latest run changes.
  2. ModelAlertReactor delivers thread-failed to the watcher through the existing model-alert outbox, as next_turn, so an idle watcher starts a turn. After a delivered wake it holds further failure wakes for that thread for five minutes. It drops the wake when no watcher is configured or the failed thread is the watcher itself. Lane-ended events keep going to the launching thread. When the launcher is the watcher and the thread failed, only the failure wake is sent, not a duplicate lane event.
  3. Launch and delegation refuse a provider that is not ready, before any thread or run is created: unregistered, disabled, not installed, in error, signed out, or with no discovered models. providerReadinessConstraints in servedModel.ts is now the one readiness check shared by launch (provider_unavailable), delegation, placement evidence and the capabilities report. requireAdvertisedModel no longer accepts an empty model catalog.
  4. docs/operations/watcher-thread.md and the modelAlertWatcher setting description cover the new event.

Checks

  • Pre-commit hook: format, lint, Knip 3/3, with no --no-verify.
  • Pre-push check:changed: format, lint, Knip 2/2, GraphQL, typecheck (37 packages), nearby tests (12 files, 331 tests).
  • Focused suites pass (5 files, 210 tests): ThreadEventAlerts, ModelAlertReactor, OrchestratorMcpService, project handlers, placementEvidence.
  • Tests cover exclusion of settled, archived, delegated, child-lineage, side-chat, interrupted and still-running threads; the per-thread rate limit; per-run dedupe; and next_turn delivery, both local and remote.

Not covered by a test: the self-wake drop (the watcher's own failure). It is checked by reading the code only.

Deploy: fleet

Model: claude-opus-5-5
Task: CLO-1066

🤖 Generated with Claude Code

On release/native-0.1.10 the pre-commit hook fails on eight unused exports
and the pre-push check fails on a scenario typecheck error and a stale agent
context budget, so no code change can land without bypassing the hooks.

Seven unused exports are used only inside their own module and lose their
export. The client setThreadDelegationNudge wrapper has no caller and goes;
the server command and its MCP tool stay. The upstream ACP refresh scenario
imports rpcClient from scenarios/t3.ts, so the fork's identical helper moves
there as upstream has it. The MCP tool list budget takes the measured size
after the event subscription and delegation nudge tools landed.

Model: claude-opus-5-5
Task: CLO-1066
Agent: claude-code
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Git exports GIT_DIR to hooks. Under pre-push, the replay workspace
fixture inherited it, so its git init, config, add and commit ran
against the pushing worktree: it committed "initial" onto the branch
being pushed and wrote the test identity into the shared repository
config. Unset the inherited repository selectors, as the server's
VcsProcess already does for its own git calls.

Model: claude-opus-5-5
Task: CLO-1066
Agent: claude-code
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed top-level thread with no launching thread, including one a person
created, told nobody, so a 15-minute fleet watchdog had to find it.

A new thread-failed event starts a watcher turn through the existing model
alert delivery path. It fires once per failed run, only for an unsettled,
unarchived, top-level thread that is not a delegated or side-chat thread and
has no live run. Delivery uses next_turn so an idle watcher wakes, keys on
the run so a replay is not a second wake, waits five minutes per thread
after a delivered wake, and never wakes the watcher about itself. Lane
events keep going to the launching thread.

Launch and delegation also refuse a provider that is not ready, has
discovered no models or is signed out, before any thread or run is created,
using one readiness check shared with placement and capabilities.

Model: claude-opus-5-5
Task: CLO-1066
Agent: claude-code
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@nullStack65

Copy link
Copy Markdown
Owner Author

RESULT

Reviewer notes only, no verdict (t3code #205, CLO-1066 watcher wake on thread failure)

CTO took this PR out of the review queue because of known CI regressions. These are notes from a review that was already running and was asked to stop. This is not a gate record and not a merge verdict. It is a bot result (Claude Opus 5.5, read-only, isolated clone), not human approval. Head 016b15eaaf9c9cbd68fede1ac3bdf30eabe15b4d, on top of #204's head 7941765bfe77.

  1. Breaks an existing test that CI doesn't run. apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts:5208, "a lane's thread events reach the thread that launched it and never Lead", now fails with expected 5 to equal 1. It passes at 7941765bfe77. The PR's checks don't include a full server test job. The new behaviour matches CLO-1066's intent, so the assertion is probably the stale part.

  2. Usage-limit outages can flood the watcher. Failure wakes skip the usage-limit and auto-resume holds (ThreadEventAlerts.ts:227-243, ModelAlertReactor.ts:1250). If 20 threads fail on one usage limit, the watcher gets 20 separate next_turn wakes on top of the single grouped item. A thread waiting to auto-resume also wakes the watcher before the reset arrives. The default watcher is the CoS thread on the laptop, so each wake starts an agent turn there.

  3. Unrelated provider-readiness change bundled in. It touches servedModel.ts, placementEvidence.ts, handlers.ts and OrchestratorMcpService.ts:409,1662:

    • A provider with an empty model list now fails launch, delegation and placement with provider_unavailable.
    • The model check now also applies to inherited models.

    None of this is in CLO-1066. Suggest splitting it into its own PR.

  4. Two mutations went uncaught: adding occurredAt back to the alert id (ThreadEventAlerts.ts:390), and dropping the delivery-time runId re-check (:455).

  5. Uneven lane-ended routes. When the launcher isn't the watcher, both a lane-ended digest and a watcher wake go out (ModelAlertReactor.ts:1738-1749). This should be documented if it's intended.

The watcher can't wake itself. It is guarded twice: once when the wake is queued (:1695) and again when it is delivered (:1305-1312). Children, subagents, side-chats and delegated threads don't qualify. A scratch test confirmed this, and it catches removing both guards. The 15-minute watchdog is external and unchanged; the diff touches no timers.

Tests at the head: the four touched test files passed 209/209. DelegatedCompletionDelivery had 1 failure out of 67 (item 1). The shared checkout's .git/config and git status were confirmed unchanged afterwards.

Not verified: a watcher setting that points at a deleted thread; the usage-limit flood as a live run; whether older peers accept next_turn; the full server suite.

This branch has not been deployed

No deployments
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