Skip to content

stewards: read a worker's model from its first turn, not the project defaults - #65

Merged
trotterdylan merged 2 commits into
mainfrom
bb/hiringloop-host-fault-claude-code-workers-ignore-thr_etxdpdm5ef
Oct 23, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/hiringloop-host-fault-claude-code-workers-ignore-thr_etxdpdm5ef

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

What

validateWorkerSpawn (the post-spawn safety net) read the worker's model and reasoning level through threads.defaultExecutionOptions on thread.created. A just-created thread is pending until its first turn is admitted (136 s for one hiringloop review worker, under the concurrency limit) and has no execution recorded, so the server resolved the project's remembered defaults for the provider instead: the owner's own picker choices (claude-fable-5-1 / medium on hiringloop). Every claude-code worker spawned with the playbook's claude-opus-5-5 / high was recorded as Started with the wrong model claude-fable-5-1 instead of claude-opus-5-5, reasoning level medium instead of high; stopped, the stop on the pending thread did nothing, and the worker ran on with the right model. The project steward then diagnosed a host fault on barney and paused the hiringloop stewards on a question to the user.

Now the plugin reads the spawn's execution from the thread's own first client/turn/requested event. When that event is not there yet, provider and environment are checked at once and model and reasoning level when the thread goes active, which is when the first turn has been dispatched. A stop at that point also reaches a running thread. The wait is kept on the worker row (model_check_pending, an append-only migration), so a server restart while the worker is pending does not lose it.

Lane

Owner-reviewed: the change includes a store migration (WORKER_CHECK_MIGRATIONS, ALTER TABLE workers ADD COLUMN model_check_pending INTEGER NOT NULL DEFAULT 0, appended to MIGRATIONS), which is an owner-reviewed trigger whatever its shape. The runtime change itself is a narrow bug fix that makes the safety net do what it was already meant to do, with no contract, setting or default changes. @trotterdylan, this needs your approval before it merges.

Tests

  • npx tsc --noEmit clean.
  • npx vitest run in plugins/stewards: 375 passed, including new tests for a worker whose first turn is dispatched after creation (not stopped at creation even though defaultExecutionOptions answers with the project defaults; stopped when the model is wrong at thread.active, left alone when right, not re-checked on later turns) and for the pending flag surviving a reopened store and defaulting to false for pre-migration rows.

Shipping

Merging to main moves the bb-server pin, builds a new image and stages a restart for every developer's server (Settings → Plugins → Team setup, or the quiet window).

🤖 Generated with Claude Code

…defaults

validateWorkerSpawn ran on thread.created and asked the server for the
worker's defaultExecutionOptions. A just-created thread is pending until
its first turn is admitted (136 s for one hiringloop review worker under
the concurrency limit) and has no execution recorded yet, so the server
fell back to the project's remembered defaults for the provider: the
owner's own picker choices (claude-fable-5-1, medium on hiringloop). Every
claude-code worker spawned with the playbook's opus-5-5/high was recorded
as "Started with the wrong model claude-fable-5-1 ... reasoning level
medium; stopped", while the stop on the pending thread did nothing and
the worker ran on with the right model anyway. The stewards then paused
on a host fault that did not exist.

Read the spawn's execution from the thread's own first
client/turn/requested event instead. When it is not there yet, check
provider and environment now and the model when the thread goes active,
which is when the first turn has been dispatched.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_uwhhca7bxm.

_— from bb thread

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at a7d090f)

Owner review required: no — none of the owner-reviewed triggers apply. A narrow bug fix in a live plugin's runtime code that makes the existing safety net do what it was already meant to do; no contract, setting, default or migration changes. The PR body's classification matches.

Blockers

  1. plugins/stewards/server.ts:2866 — workerModelCheckPending is an in-memory Set, so the deferred model check does not survive a server restart. The pending window is not momentary: the PR body itself cites 136 s under the concurrency limit, and every plugin release plus the nightly quiet window restarts every developer's server. If the server restarts while a worker is pending its first turn, thread.created does not re-fire, the set comes back empty, and when the worker later goes active the model/reasoning check is silently skipped — a mis-spawned worker then runs its whole PR unchecked, which is exactly the hole this safety net exists to close. Workspace guidance is explicit that state must survive a restart. Fix: persist the "model not yet verified" fact on the worker row (the workers table is already durable — a nullable model_checked_at or similar), set it in validateWorkerSpawn, and read/delete it in the thread.active handler instead of the Set (keep clearing it in thread.deleted).

Suggestions

  • plugins/stewards/server.test.ts:169 — the mock's defaultExecutionOptions returns null for a pending thread, so no test reproduces the actual production fault (the server falling back to the project's remembered defaults and falsely stopping a correct worker at creation). The new test does fail if the change is reverted, so this is only about pinning the exact symptom; a mock variant that returns claude-fable-5-1/medium for pending threads and asserts the worker is not stopped at creation would do it.
  • plugins/stewards/server.ts:3175 — pending entries are not cleared on thread.failed/thread.archived. Harmless today (a failed worker that later goes active just gets re-validated, which is fine), but a one-line clear alongside the thread.deleted one would keep the set honest.

Checked

  • Ran: npm run typecheck and npx vitest run in plugins/stewards (373 passed, clean). Stewards is in the CI matrix (.github/workflows/plugins.yaml) and its check is green on this head; I ran the suite myself regardless.
  • Verified against ticket:
    • "reads model and reasoning level from the thread's own first client/turn/requested event, never defaultExecutionOptions" — met; workerExecution reads the first client/turn/requested event (order: "asc", limit: "1") and the only defaultExecutionOptions reference left is the test mock.
    • "checked for provider and environment at creation, model and reasoning level when it goes active; wrong model stopped, right one left alone and not re-checked" — met in the steady state, with a test covering all three branches (pending → not stopped; wrong model at active → stopped; right model → left alone and a later turn with a different model does not re-check). Not met across a server restart — blocker 1.
    • "typecheck and vitest pass" — met, reproduced locally.

The wait for a worker's first turn was an in-memory set, lost when the
server restarts while the worker is still pending; its model would then
never be checked. Keep it as model_check_pending on the workers table
(append-only migration), set in validateWorkerSpawn, read and cleared on
thread.active, cleared on archive and delete. The test fake now answers
defaultExecutionOptions for a pending thread with the project's picker
defaults, as the server does, so the test pins the production symptom.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed in acdee13.

  • Blocker 1 (in-memory set lost on restart): fixed. The wait is now model_check_pending on the workers row (append-only migration WORKER_CHECK_MIGRATIONS), set in validateWorkerSpawn, read and cleared on thread.active, cleared on archive and delete. Store tests cover a reopened store seeing the flag and pre-migration rows reading as not pending.
  • Suggestion 1 (mock should reproduce the fault): taken. The fake's defaultExecutionOptions now answers a pending thread with claude-fable-5-1/medium, as the server does, and the test asserts the worker is not stopped at creation.
  • Suggestion 2 (clear on failed/archived): taken for thread.archived (and thread.deleted). Declined for thread.failed: a failed worker that is retried still dispatches its first turn and goes active, and that is exactly when the check should run, so the flag stays.

_— from bb thread

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at acdee13)

Owner review required: yes — this round added a store migration (WORKER_CHECK_MIGRATIONS, ALTER TABLE workers ADD COLUMN model_check_pending), and a store migration is an owner-reviewed trigger whatever its shape. @trotterdylan, this one needs your approval. The migration itself is clean (see Checked), so this is about the lane, not the code.

Blockers

  1. PR body, "Lane" section — it still says "No-review: a narrow bug fix … No contract, setting, or default changes", but the diff now contains a store migration, which lands the PR in the owner-reviewed lane. On the claimed lane this would merge with no human ever seeing a live-database schema change; the body must be corrected to name the migration and the owner-reviewed lane.

Suggestions

  • None new.

Resolved since round 1

  • Blocker 1 (pending model check lost on restart): resolved by acdee13 — the flag now lives on the workers row (model_check_pending), set in validateWorkerSpawn, read and cleared in thread.active, cleared on stop/archive/delete; the store test proves a reopened store still sees it. The thread.active handler clears the flag before re-validating, so a passing check cannot loop.
  • Suggestion 1 (mock did not reproduce the production fault): resolved — the fake defaultExecutionOptions now answers pending threads with the project's remembered defaults (claude-fable-5-1/medium), so the "not stopped at creation" assertion pins the exact symptom and fails on the old code.
  • Suggestion 2 (stale pending entries): resolved for archived and deleted; the decline for thread.failed is accepted — a retried worker still dispatches turns, status failed is not stopped, so the check correctly still runs when it goes active.

Checked

  • Ran: npm run typecheck and npx vitest run in plugins/stewards on acdee13 — clean, 375 passed (two new store tests: reopen-after-restart sees the flag; pre-migration rows read as not pending). CI's stewards check is in the matrix; it was still running on this head when I reviewed, and I ran the suite myself regardless.
  • Migration safety: append-only (a new WORKER_CHECK_MIGRATIONS entry appended to MIGRATIONS, no existing entry edited), ADD COLUMN … NOT NULL DEFAULT 0 is safe on a live SQLite database, applied through bb.storage.migrate, legacy rows default to not-pending, and a previous build reading a migrated database just ignores the extra column.
  • Verified against ticket: all three acceptance criteria now met, including across a server restart.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 2 addressed: the PR body's Lane section now says owner-reviewed and names the store migration. No code change; head stays at acdee13. @trotterdylan, your approval is needed before this merges.

_— from bb thread

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 3 (GLM 5.3, at acdee13)

Owner review required: yes — store migration (WORKER_CHECK_MIGRATIONS). @trotterdylan, this one needs your approval; with that, the gate is met.

Resolved since round 2

  • Blocker 1 (PR body claimed No-review): resolved — the Lane section now says owner-reviewed and names the migration. No code changed; the head is the same sha round 2 reviewed, so no findings were re-opened and nothing new was introduced.

Checked

  • CI on acdee13: quality_checks (stewards) pass (I also ran typecheck and the full vitest suite on this sha in round 2 — 375 passed).
  • All three acceptance criteria met, including across a server restart.

No blockers remain. Owner approval (@trotterdylan) is the only thing between this PR and merge.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

LGTM

@trotterdylan
trotterdylan merged commit c3f0857 into main Oct 23, 2026
20 checks passed
@trotterdylan
trotterdylan deleted the bb/hiringloop-host-fault-claude-code-workers-ignore-thr_etxdpdm5ef branch October 23, 2026 15:19
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed, approved by trotterdylan on acdee13 (comment 2026-10-23T15:18:59Z), reviewer approved the same sha in round 3, checks green. Squash commit c3f0857 on main. This moves the bb-server pin: the next bb-gate bb-server tick builds a new image and stages a restart for every developer's server (Settings → Plugins → Team setup, or the quiet window).

_— from bb thread

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.

1 participant