Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions plugins/stewards/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,11 @@ Plugin code. No model turn.
the worker, since it waits on that result). BB-329: a worker says it is
waiting with the `worker_park` tool, not with prose; a finish without that
call is a plain finish, archived like any other, whatever its final text
says. And a
says. BB-389: a parked finish stays a quiet note even when the steward's
own `waitingOn` or typed `worker` wait named the worker — the park is not
over, so there is no hand-off prompt; the steward is woken by the worker's
resume or by the pull request changing, and a binding following through
still hears the worker as before. And a
terminal state the steward's own last report already named ends the
binding from the mechanical tier, with the wrap-up written from that
report and no wrap-up wake; a terminal state someone else set still wakes.
Expand Down Expand Up @@ -696,7 +700,10 @@ decide-list mark and the recorded project approvals the `approvals.ts` path
omits), the worker state (an explicit `parked`, distinct from `running`) and
the liveness (wake source, idle, stall from the observable rows, not the
stored `noWakeSource` flag, which only a reconcile writes, for every binding
kind, an ops binding included (BB-375). `compare`
kind, an ops binding included (BB-375). BB-333 made the stored typed `wait`
the source of liveness, judged by its kind; BB-389 made it additive: a live
structured source is never overridden by a non-live wait, and a parked worker
is itself a source. `compare`
runs the predicates the assessment will replace and returns every
disagreement.
- `reconcile.ts` calls it on every binding inside a try/catch that can never
Expand Down Expand Up @@ -1945,11 +1952,12 @@ it reads after the red phrases and ahead of the other quiet ones); `held behind
running` counting only workers whose worker-table status is `running` (a busy
steward or reviewer with no running worker falls through, rather than reading
`0 workers running`); the lost hand-off when `waitingOn` names a finished
worker or a loud hand-off note is pending (BB-152); `worker finished, next look
<time>` when the binding has a pending quiet worker-finish note and no running
worker (BB-83 — the status summary a finished worker left behind must not keep
the row, and the time is the binding's `requeueAt`); a dated wait as
`waiting on <text> until <date>` (BB-247); the newest deployment watch's state
worker or a loud hand-off note is pending (BB-152 — a parked worker is not
finished, so a wait naming it is not a lost hand-off, BB-389); `worker
finished, next look <time>` when the binding has a pending quiet worker-finish
note and no running worker (BB-83 — the status summary a finished worker left
behind must not keep the row, and the time is the binding's `requeueAt`); a
dated wait as `waiting on <text> until <date>` (BB-247); the newest deployment watch's state
(`deploying`, `deployed`, `deploy failed`), ahead of the free-text `nextAction`
whatever the actor (BB-86); the status `nextAction` verbatim, with `the other
party` standing in for an `other` actor that has no report (an external wait is
Expand Down
43 changes: 24 additions & 19 deletions plugins/stewards/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ install on a stock bb: one repository, no Linear, no hooks service.
binding's worker threads' branches, or a worker named its URL — and quiets
three more causes: a state move between the build and review stages, a
worker turn ending parked with `worker_park` (only a question or a gone
thread wakes), and a terminal state the steward's own last report already
named (the binding ends from the mechanical tier). A foreign pull request
wakes on its link and keeps its activity actionable. Everything not
thread wakes; a parked finish is a quiet note even when the steward's own
`waitingOn` named the worker, BB-389), and a terminal state the steward's
own last report already named (the binding ends from the mechanical tier).
A foreign pull request wakes on its link and keeps its activity actionable. Everything not
actionable is kept as a quiet note and shown in "What changed" at the next
turn something else makes due, and `bb stewards show` lists it as a pending
note.
Expand Down Expand Up @@ -508,17 +509,20 @@ install on a stock bb: one repository, no Linear, no hooks service.
- **A wait with no wake source (BB-154).** A steward's free-text `waitingOn`
can name something the plugin never delivers, so the binding wakes only by
requeue. On every reconcile the plugin asks whether any structured source is
live on the binding: an open `holdBehind`, a deployment watch in
`merged`/`deploying`, a running worker, an open escalation or need, or a
pull-request watch. With none, the binding is marked `noWakeSource`: its
row reads `waiting, no wake source`, `bb stewards list`/`show` say so, and
the next wake carries one paragraph telling the steward to name what will
deliver the wait (a binding to hold behind, a pull request, a deployment
target, a worker) or re-examine it. The reconcile is the column's only
writer (BB-375), for every binding kind including ops: a `steward_report`
derives the same sentence for its reply in the turn the wait is set, so the
steward can act then, but stores nothing. The mark clears when a source
appears or the wait is cleared.
live on the binding: an open `holdBehind` or stack-wait, a merge hold, a
deployment watch in `merged`/`deploying`, a running or parked worker
(BB-389), an open escalation or need, or a pull-request watch. A typed
`wait` (BB-333) may add liveness but never removes it (BB-389): a binding
with any live source is not marked, whatever the wait says, and a wait the
plugin cannot deliver no longer masks a source that can. With none, the
binding is marked `noWakeSource`: its row reads `waiting, no wake source`,
`bb stewards list`/`show` say so, and the next wake carries one paragraph
telling the steward to name what will deliver the wait (a binding to hold
behind, a pull request, a deployment target, a worker) or re-examine it.
The reconcile is the column's only writer (BB-375), for every binding kind
including ops: a `steward_report` derives the same sentence for its reply in
the turn the wait is set, so the steward can act then, but stores nothing.
The mark clears when a source appears or the wait is cleared.
Separately, the plugin counts consecutive wakes
whose reason was `requeue` and whose report ended with the same trimmed
`waitingOn`; at two (one plugin constant, not a `project.json` key) it
Expand Down Expand Up @@ -616,11 +620,12 @@ thread button (BB-184, BB-198).
entity key in bold and the title on line one; the kind (`ticket`, `pull
request`, `review`, `ops`), the entity's phase when it has one, and the status
phrase on line two (first match wins: `needs you`, a hold,
`stuck`, `N worker(s) running`, a lost hand-off, a quiet worker finish,
`waiting, no wake source`, the deployment state, then the report's
`nextAction` verbatim). A free-text `waitingOn` is a plain line on the effort
card, never a block or a phrase prefix (BB-109). A row that needs you adds its prompt and one-click actions
under line two, in the same row. The glyph is one of four, in precedence order
`stuck`, `N worker(s) running`, a lost hand-off (a parked worker is not one,
BB-389), a quiet worker finish, `waiting, no wake source`, the deployment
state, then the report's `nextAction` verbatim). A free-text `waitingOn` is a
plain line on the effort card, never a block or a phrase prefix (BB-109). A
row that needs you adds its prompt and one-click actions under line two, in
the same row. The glyph is one of four, in precedence order
`you › blocked › running › quiet`: a solid yellow dot when it waits on you, an
empty red ring when blocked, a blue ring that pulses slowly while a worker or
reviewer runs (CSS only, off under `prefers-reduced-motion`), and an empty grey
Expand Down
2 changes: 1 addition & 1 deletion plugins/stewards/assessed-gate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const tickets: Playbook = (() => {

const head = "aaaaaaa1";
const green = { checks: { state: "success", failing: [] } };
const noSources: WakeSourceInput = { hold: null, holdBehind: [], mergeBehind: [], holdStack: [], deployments: {}, runningWorkers: 0, openEscalations: 0, openNeeds: 0, pullRequestWatch: false };
const noSources: WakeSourceInput = { hold: null, holdBehind: [], mergeBehind: [], holdStack: [], deployments: {}, runningWorkers: 0, parkedWorkers: 0, openEscalations: 0, openNeeds: 0, pullRequestWatch: false };

const noReviewMarker = comment({ id: "m1", author: "trotterdylan", body: `<!-- bb-review round=1 sha=${head} verdict=approved lane=no-review -->`, signedBy: "thr_reviewer", createdAt: "2026-10-14T16:00:00Z" });
const ownerMarker = comment({ id: "m2", author: "trotterdylan", body: `<!-- bb-review round=1 sha=${head} verdict=approved lane=owner-reviewed approver=project -->`, signedBy: "thr_reviewer", createdAt: "2026-10-14T16:00:00Z" });
Expand Down
71 changes: 64 additions & 7 deletions plugins/stewards/assessment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const projectApprovalMarker = (id: string) => comment({ id, author: "trotterdyla
// The owner's unsigned approval, as the Stewards page posts it (BB-279).
const ownerUnsignedApproval = comment({ id: "oa", author: "jane", body: `Approved ${head} from the Stewards page`, signedBy: null, createdAt: "2026-10-14T17:00:00Z" });

const noSources: WakeSourceInput = { hold: null, holdBehind: [], mergeBehind: [], holdStack: [], deployments: {}, runningWorkers: 0, openEscalations: 0, openNeeds: 0, pullRequestWatch: false };
const noSources: WakeSourceInput = { hold: null, holdBehind: [], mergeBehind: [], holdStack: [], deployments: {}, runningWorkers: 0, parkedWorkers: 0, openEscalations: 0, openNeeds: 0, pullRequestWatch: false };

/** A gate-met own pull request (no-review, green) plus the reviewer marker. */
const gateMetPull = (key: string, url: string) => pull({ key, url, comments: [noReviewMarker] }, { headSha: head, ...green });
Expand Down Expand Up @@ -83,8 +83,10 @@ function input(over: Partial<AssessmentInput> = {}): AssessmentInput {
/**
* BB-266: a gate-met own pull request, a parked `finished` worker, and (unless
* `secondOpen` says the test is about its absence) a second open own pull
* request. `sources` is the report path's, with no tracked source, so the
* parked worker is not a wake source.
* request. `sources` is the report path's input shape; the fixture passes it
* without the parked worker so `compare` still pins the BB-292
* `hasLiveWakeSource` divergence. The report path itself counts the parked
* worker since BB-389 (`wakeSourcesFor`), so the row cannot fire in production.
*/
function bb266(secondOpen: boolean): AssessmentInput {
const first = gateMetPull("acme/web#7", "https://github.com/acme/web/pull/7");
Expand Down Expand Up @@ -358,10 +360,13 @@ describe("the shadow assessment: the typed wait (BB-333)", () => {
expect(a.liveness.idle).toBe(false);
});

it("derives a stalled external wait even when an unrelated source is live", () => {
// BB-389: the typed wait may add liveness but never removes it. An external
// (or otherwise non-live) wait beside a live structured source is not stalled.
it("does not stall a non-live external wait while a structured source is live", () => {
const a = assess(withWait({ kind: "external", ref: "the vendor" }, { sources: { ...noSources, pullRequestWatch: true } }));
expect(a.liveness.waitLive).toBe(false);
expect(a.liveness.stalled).toBe(true);
expect(a.liveness.live).toBe(true);
expect(a.liveness.stalled).toBe(false);
});

it("derives a review wait live only until the review is given", () => {
Expand All @@ -378,10 +383,14 @@ describe("the shadow assessment: the typed wait (BB-333)", () => {
expect(a.liveness.waitLive).toBe(true);
});

it("derives a worker wait live only while the worker runs", () => {
it("derives a worker wait live while the worker runs or is parked", () => {
const running = assess(withWait({ kind: "worker", ref: "thr_w1" }, { workers: [{ threadId: "thr_w1", status: "running" } as never] }));
expect(running.liveness.waitLive).toBe(true);
const finished = assess(withWait({ kind: "worker", ref: "thr_w1" }, { workers: [parkedWorker({ threadId: "thr_w1" })] }));
// BB-389: a parked worker is still waiting, so the wait is live.
const parked = assess(withWait({ kind: "worker", ref: "thr_w1" }, { workers: [parkedWorker({ threadId: "thr_w1" })] }));
expect(parked.liveness.waitLive).toBe(true);
// A plainly finished worker (no park) is over, so the wait is not live.
const finished = assess(withWait({ kind: "worker", ref: "thr_w1" }, { workers: [parkedWorker({ threadId: "thr_w1", parkedWaitingOn: null })] }));
expect(finished.liveness.waitLive).toBe(false);
});

Expand Down Expand Up @@ -432,6 +441,54 @@ describe("the shadow assessment: the typed wait (BB-333)", () => {
});
});

// BB-389: a typed wait may add liveness but never removes it. Each row is one
// healthy wait from the ticket's table that read `waiting, no wake source`
// because a non-live typed wait (or a parked worker) overrode the live source.
// The ticket's five rows all have a typed `external` wait or none at all.
describe("BB-389: a live structured source is never overridden by a typed wait", () => {
const external: NonNullable<AssessmentInput["binding"]["wait"]> = { kind: "external", ref: "thr_vyvrsvpt9r" };
const withWait = (over: Partial<AssessmentInput>) => assess(input({ binding: binding({ wait: external }), ...over }));

it("row 1: an open schedule escalation is live with an external wait", () => {
const a = withWait({ sources: { ...noSources, openEscalations: 1 } });
expect(a.liveness.waitLive).toBe(false);
expect(a.liveness.live).toBe(true);
expect(a.liveness.stalled).toBe(false);
});

it("row 2: a parked worker is live with an external wait", () => {
const a = withWait({ sources: { ...noSources, parkedWorkers: 1 } });
expect(a.liveness.live).toBe(true);
expect(a.liveness.stalled).toBe(false);
});

it("row 3: a pull-request watch is live with an external wait (checks on the PR)", () => {
const a = withWait({ sources: { ...noSources, pullRequestWatch: true } });
expect(a.liveness.stalled).toBe(false);
});

it("row 4: the reviewer's pull-request watch is live with an external wait (a stored reviewer thread)", () => {
const a = withWait({ sources: { ...noSources, pullRequestWatch: true } });
expect(a.liveness.stalled).toBe(false);
});

it("row 5: an open approval escalation and approve-pr need are live with an external wait", () => {
const a = withWait({ sources: { ...noSources, openEscalations: 1, openNeeds: 1 } });
expect(a.liveness.stalled).toBe(false);
});

// The BB-154 true positive is unchanged: a free-text or `external` wait with
// no live source still flags.
it("still flags a non-live external wait with no structured source", () => {
const a = withWait({ sources: { ...noSources } });
expect(a.liveness.waitLive).toBe(false);
expect(a.liveness.live).toBe(false);
expect(a.liveness.stalled).toBe(true);
const freeText = assess(input({ binding: binding({ status: status("the vendor") }) }));
expect(freeText.liveness.stalled).toBe(true);
});
});

// BB-351: the per-kind wait budget. `overdue` is true only when the stored
// wait is live, its kind has a budget, and `now - waitSince` exceeds it.
describe("the shadow assessment: the wait budget (BB-351)", () => {
Expand Down
10 changes: 8 additions & 2 deletions plugins/stewards/assessment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ export function typedWaitLive(wait: Wait, input: AssessmentInput): boolean {
return key !== null && Object.values(input.binding.deployments).some((w) => lc(w.key) === key && (w.state === "merged" || w.state === "deploying"));
}
case "worker":
return input.workers.some((w) => w.threadId === wait.ref && w.status === "running");
// BB-389: a parked worker is still waiting, so a `worker` wait naming it
// is live until its next turn clears the park. A plainly finished, failed
// or stopped worker is not.
return input.workers.some((w) => w.threadId === wait.ref && (w.status === "running" || (w.status === "finished" && w.parkedWaitingOn !== null)));
case "binding":
return input.hasOpenBinding?.(wait.ref) ?? false;
case "date":
Expand Down Expand Up @@ -357,7 +360,10 @@ export function assess(input: AssessmentInput, composed?: ComposedAssessment): A
// the idle wake; a stalled or external one does not (BB-333).
idle: wait !== null && waitLive === true ? false : idleBase,
stuck: stuckDue(binding, playbook, [...escalations], now) !== null,
stalled: wait === null ? observedStall(binding, live, now) : waitLive !== true && !dateAhead,
// BB-389: the typed wait may add liveness but never removes it. A binding
// with any live structured source is not stalled whatever the wait says;
// only a non-live wait (or none) can stall.
stalled: wait === null ? observedStall(binding, live, now) : !live && waitLive !== true && !dateAhead,
reportedNoWakeSource: binding.noWakeSource,
overdue: overdueMs !== null,
overdueMs,
Expand Down
2 changes: 1 addition & 1 deletion plugins/stewards/characterization-assessment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const tickets: Playbook = (() => {

const head = "aaaaaaa1";
const green = { checks: { state: "success", failing: [] } };
const noSources: WakeSourceInput = { hold: null, holdBehind: [], mergeBehind: [], holdStack: [], deployments: {}, runningWorkers: 0, openEscalations: 0, openNeeds: 0, pullRequestWatch: false };
const noSources: WakeSourceInput = { hold: null, holdBehind: [], mergeBehind: [], holdStack: [], deployments: {}, runningWorkers: 0, parkedWorkers: 0, openEscalations: 0, openNeeds: 0, pullRequestWatch: false };

const noReviewMarker = comment({ id: "m1", author: "trotterdylan", body: `<!-- bb-review round=1 sha=${head} verdict=approved lane=no-review -->`, signedBy: "thr_reviewer", createdAt: "2026-10-14T16:00:00Z" });
const ownerMarker = comment({ id: "m2", author: "trotterdylan", body: `<!-- bb-review round=1 sha=${head} verdict=approved lane=owner-reviewed approver=project -->`, signedBy: "thr_reviewer", createdAt: "2026-10-14T16:00:00Z" });
Expand Down
7 changes: 4 additions & 3 deletions plugins/stewards/characterization-wait-derivation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const tickets: Playbook = (() => {
return p.value;
})();

const noSources: WakeSourceInput = { hold: null, holdBehind: [], mergeBehind: [], holdStack: [], deployments: {}, runningWorkers: 0, openEscalations: 0, openNeeds: 0, pullRequestWatch: false };
const noSources: WakeSourceInput = { hold: null, holdBehind: [], mergeBehind: [], holdStack: [], deployments: {}, runningWorkers: 0, parkedWorkers: 0, openEscalations: 0, openNeeds: 0, pullRequestWatch: false };

/** A second open own pull request, so the binding-shaped fixture is not a lone PR (BB-291). */
const secondOpenPull = pull({ key: "acme/web#8", url: "https://github.com/acme/web/pull/8" }, { headSha: "bbbbbbb2" });
Expand Down Expand Up @@ -125,9 +125,10 @@ describe("typedWaitLive: the deployment, worker, binding and person kinds", () =
expect(waitLive({ kind: "deployment", ref: "acme/web#9" })).toBe(false);
});

it("worker: live only while the named worker is running", () => {
it("worker: live while the named worker is running or parked (BB-389), not once plainly finished", () => {
expect(waitLive({ kind: "worker", ref: "thr_w1" }, { workers: [{ threadId: "thr_w1", status: "running" } as never] })).toBe(true);
expect(waitLive({ kind: "worker", ref: "thr_w1" }, { workers: [parkedWorker({ threadId: "thr_w1" })] })).toBe(false);
expect(waitLive({ kind: "worker", ref: "thr_w1" }, { workers: [parkedWorker({ threadId: "thr_w1" })] })).toBe(true);
expect(waitLive({ kind: "worker", ref: "thr_w1" }, { workers: [parkedWorker({ threadId: "thr_w1", parkedWaitingOn: null })] })).toBe(false);
expect(waitLive({ kind: "worker", ref: "thr_w1" })).toBe(false);
});

Expand Down
Loading