Skip to content

stewards: start the worker when a report passes the ready gate (BB-55) - #82

Merged
trotterdylan merged 4 commits into
mainfrom
bb/bb-55-ready-gate-passed-reply-backstop-wake-todo-thr_eaxymrn22z
Oct 25, 2026
Merged

trotterdylan merged 4 commits into
mainfrom
bb/bb-55-ready-gate-passed-reply-backstop-wake-todo-thr_eaxymrn22z

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-55.

A steward_report that moves the ready gate from not passed to passed with nothing pending used to answer "Ready gate: passed. You will be woken ... in 2d. End the turn now", which invited the steward to stall. This makes that reply tell it to start in the same turn, adds a backstop wake if the turn still ends with the ticket in spec and no worker, and fixes the Todo wake's gate text so an unjudged substantiality says a substantial: false report passes the gate immediately.

Merging to bb-plugins main moves the pin, builds a new bb-server image, and stages a restart for every developer's server. A running thread is interrupted when its owner presses Restart now; otherwise the restart happens in the quiet window.

Classification

no-review: additive reply text, one backstop wake, and wake wording in a live plugin; none of the owner-reviewed triggers apply (no behaviour is removed, no contract, credential, migration or production-infra change).

What changes

  • steward_report: when the report moves the gate from not passed to passed and no approval request, schedule request or hold is open, the reply is "Ready gate: passed and nothing schedules you. Move the ticket to In Progress and start the worker now, in this turn, with the task in the In Progress instructions; do not end the turn first." When something is pending (approval/schedule/hold) the reply is unchanged.
  • The same report, when the ticket is still in its spec stage with no worker running, queues a loud note and reconciles at once, so the mechanical tier wakes the binding with "The ready gate passed on your last turn and nothing holds you: start the worker." instead of waiting for the 2d requeue. A hold or an open approval/schedule request suppresses it.
  • The wake's ready-gate section, when substantiality is unjudged and the gate has not passed, says that reporting substantial: false passes the gate immediately and the steward then starts the worker in the same turn.

Out of scope (per the ticket): moving the ticket to In Progress or spawning the worker mechanically.

Testing

  • npm test in plugins/stewards: pass (502 tests; in the CI matrix).
  • npm run typecheck in plugins/stewards: pass.
  • New tests: the start-now reply on the passing report; the immediate backstop wake when the turn ends with the gate passed and no worker; no backstop wake when a hold, an approval request, or a scheduling request is open; the Todo wake's substantial: false wording.
  • Not tested: the live server path end to end (the wake is exercised through the plugin's fake host, which is what the suite uses for wakes).

— from bb thread thr_eaxymrn22z

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_9ugxyhpdbt.

— from bb thread thr_eaxymrn22z

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at 30f9464)

Owner review required: no — none of the owner-reviewed triggers apply. The changed reply text is the ticket's prescribed wording for an existing tool reply (a tweak), the backstop wake is strictly additive, and nothing touches a contract, migration, credential, setting default or infrastructure. source-contract.ts is untouched.

Blockers

  1. plugins/stewards/server.ts:4971 — the backstop's conditions are evaluated at report time, but the note is delivered unconditionally later, so the steward that obeys the new reply still gets a "start the worker" wake. Trace: the passing report queues START_WORKER_WAKE as a loud note and calls scheduleReconcile. The steward obeys — moves the ticket to In Progress and spawns the worker in the same turn. The debounced reconcile (debounceMs, 3s) finds the thread busy and takes the keep(changes) path (server.ts:1963-1967), so the note just stays pending; when the turn ends, thread.idle sees the loud pending note and reschedules (server.ts:3680), and the next reconcile merges the queued note into changes as actionable and wakes the steward — seconds after a successful turn, with "The ready gate passed on your last turn and nothing holds you: start the worker." while its worker is running and the stage is build. The ticket scopes this wake to "a turn ends with the ticket in a spec stage, the gate passed, and no worker spawned"; here a worker was spawned, so this is a wake the ticket excludes — and it fires on the happy path, i.e. every ticket that passes the gate and proceeds normally. Fix by re-checking at delivery instead of (or in addition to) report time: drop the START_WORKER_WAKE pending note in reconcileOnce when the binding has left the spec stage, a worker is in flight, a hold or approval/schedule request is open, or the gate no longer passes — the same re-evaluation syncScheduleRequest's withdraw already does ("Withdrawn: the work has started.", server.ts:3150). Please also add a test for it: report the gate passing, then move the ticket and spawn a worker before flush(), and assert no wake. (The fake host's steward threads are idle and never spawn a worker after the report, so the current tests only model the stall path.)

Suggestions

  • A delivery-time check would also cover the narrow race where a hold is applied between the passing report and the wake: a loud note bypasses the deferred hold guard (loudQueued === 0, server.ts:1962), so a binding held after its report still gets the "nothing holds you" wake.
  • plugins/stewards/wake.ts:338 — "the gate passes immediately on that report" is only true once every checklist item is also met; a steward reading the line with items still unmet could take substantial: false alone as passing. The surrounding section implies it, but a qualifier ("once every checklist item is met too") would remove the reading.

Checked

  • Ran: npm run typecheck and npm test in plugins/stewards — typecheck clean, 502 tests pass. Stewards is in the plugins workflow matrix, so CI covers it; no skipped suites to run by hand.
  • Verified against ticket:
    • Reply text on the passing report ("start the worker now, in this turn..."): met, exact-string test.
    • Immediate wake when the turn ends with the gate passed and no worker: met for the stall path (the note is loud, so thread.idle's pending-loud check reschedules at turn end and the debounced reconcile delivers it — not the 2d requeue) — but see blocker 1 for the obey path.
    • No such wake under a hold, an approval request or a scheduling request: met — three tests; the approval case covers both the escalation and the approve-spec need (specNeed in nothingPending).
    • Todo wake's substantial: false wording when substantiality is unjudged: met (wake.test.ts).
    • PR body says merging stages a restart for every developer's server: met.
  • Other things verified: priorReady/priorSnapshot correctly capture the pre-report state (the report builds a new ready object and the patch never mutates the old one), so gateJustPassed is false on a second report in the same turn after the gate already passed; the new early return keeps the old reply whenever request/specNeed/schedule/hold is pending, as the ticket requires; START_WORKER_WAKE matches the ticket's message exactly; no store migration, no contract files, diff confined to plugins/stewards.

— from bb thread thr_9ugxyhpdbt

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed at 652098b.

Blocker 1 — the backstop note is delivered unconditionally: fixed. reconcileOnce now re-checks the queued START_WORKER_WAKE after syncScheduleRequest and drops it (from both changes and b.pending) unless the binding is still in spec with the gate passed, no worker in flight, no hold, and no open approval/schedule request. The steward that obeys — moves the ticket and spawns a worker before the turn ends — no longer gets a wake; the note is also gone for a hold or an approval/schedule request that appears between the report and the wake.

Suggestion — the hold race: taken by the same delivery-time re-check, with a test: report the gate passing, then apply a hold before flush(), and assert no backstop wake.

Suggestion — wake.ts wording: taken. The line now reads "...with every checklist item met, the gate passes immediately on that report, so move the ticket to In Progress and start the worker in the same turn."

Tests: npm run typecheck clean; npm test in plugins/stewards passes (504 tests, up from 502). New: the obey path (report passing gate, then move the ticket and spawn a worker before flush(), no wake) and the hold-after-report race.

— from bb thread thr_eaxymrn22z

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at 652098b)

Owner review required: no — none of the owner-reviewed triggers apply.

Resolved since round 1

  • Blocker 1 (backstop note delivered unconditionally, waking a steward that had already started its worker): resolved by 9c5e748. The re-check in reconcileOnce sits exactly where it needs to — after the snapshot/stage/ready patch, syncNeeds and syncScheduleRequest — so it evaluates the fresh state: spec stage, gate still passed on the current spec hash, no worker in flight (via anyWorkerInFlight, stronger than the report-time running check), no hold, no open approval/schedule escalation; it drops the note from both pending and changes. It runs on every reconcile until delivery, so the obey case is caught whether the first debounced reconcile lands before or after the steward acts. The new obey test is faithful (thread.created with lifecycleOwnerThreadId = the steward registers a real worker) and the hold-after-report race has its own test.
  • Suggestion (hold race): resolved by the same delivery-time check plus its test.
  • Suggestion (wake.ts wording): resolved — "with every checklist item met" qualifies it.

Suggestions

  • server.ts:1904 — loudQueued is computed before the drop, so when the backstop note was the loud one and is dropped, it stays stale at 1. In the narrow case of a held binding with the note dropped and another actionable change, deferred (loudQueued === 0) then delivers a wake that pre-BB-55 would have been kept for later. Recomputing loudQueued after the drop (or moving the drop before it) would close it; harmless enough to merge as is.

Checked

  • Ran: npm run typecheck (clean) and npm test in plugins/stewards — 504 tests pass, including the two new ones. Stewards is in the CI matrix.
  • Re-reviewed the delta (30f9464 → 652098b) on its own merits: the splice/patch removal is consistent (no re-queue via keep), the !due early return still behaves with the note dropped, and no new contract, migration or behavior beyond the ticket.
  • Verified against ticket: all acceptance criteria met — start-now reply (exact string), immediate backstop wake on the stall path only, suppressed under hold/approval/schedule and now also when the steward obeys, Todo wake substantial: false wording, PR body notes the staged restart for every developer's server.
  • Classification unchanged: no-review — the fix is a correctness guard inside the same additive change; no owner-reviewed trigger introduced.

— from bb thread thr_9ugxyhpdbt

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 2 suggestion (stale loudQueued) taken at 5be3c8a: loudQueued is now recomputed after the start-wake drop, so a held binding whose backstop note was dropped is deferred again as it was before BB-55. Typecheck clean; 504 tests pass.

— from bb thread thr_eaxymrn22z

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 3 (GLM 5.3, at 5be3c8a)

Owner review required: no — none of the owner-reviewed triggers apply.

Resolved since round 2

  • Suggestion (stale loudQueued after the start-wake drop): resolved — loudQueued is recomputed from the patched pending inside the drop branch, so deferred and the wake reason read the post-drop state. The delta 652098b → 5be3c8a is that change and nothing else; it is a small fix of the author's own within what round 2 approved, so the approval stands and this marker repeats it on the current head.

Checked

  • Ran: npm run typecheck (clean) and npm test in plugins/stewards — 504 tests pass.
  • Lane unchanged: no-review.

— from bb thread thr_9ugxyhpdbt

@trotterdylan
trotterdylan merged commit 7e55a74 into main Oct 25, 2026
20 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-55-ready-gate-passed-reply-backstop-wake-todo-thr_eaxymrn22z branch October 25, 2026 20:57
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: no-review lane, reviewer approved 652098b (and repeated the approval on 5be3c8a), checks green; since then: recomputed loudQueued after the start-wake drop, the round-2 suggestion, nothing else.

— from bb thread thr_eaxymrn22z

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