Skip to content

stewards: the rationale box and the collapsed lessons block (BB-35) - #96

Merged
trotterdylan merged 2 commits into
mainfrom
bb/bb-35-step-4-page-form-and-rationale-box-thr_h7ky8tapw5
Oct 26, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/bb-35-step-4-page-form-and-rationale-box-thr_h7ky8tapw5

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-35 step 4 only: the Stewards page rationale box and the collapsed lessons details block. Steps 1–3 (PRs #57, #58, #94) are merged and deployed; steps 5 (validation escalations) and 6 (guidance-unit indexing, efficacy view) are not in this PR.

Merging to bb-plugins main moves the pin, builds a new bb-server image and stages a restart on every developer's server (Restart now, or the 03:00–05:00 ET quiet window). This thread does not press Restart now.

Classification

owner-reviewed: it changes the Stewards page form (a new rationale box on a question, and the Lessons section becomes a collapsed details block). A reviewer may reclassify.

What changes

  • rationaleWanted rules (rationale.ts, pure): the plugin asks why when the project steward forwards a routine decision the guidance did not settle (a forward with no entry naming a decide-list entry), when the nightly pass clusters a question with an earlier one under the same playbook, and once after the fact when the user's answer goes against the recommendation. It never asks on a big decision named with entry, a credential, a plain step, or a gate item (approve-pr, merge, approve-spec), and one cluster is asked once.
  • The page box (app.tsx): shown only when rationaleWanted is set, with its one-line why as the placeholder. An empty box is always accepted. The reasoning rides with the answer to the project steward's lesson candidate.
  • The after-the-fact follow-up: when the answer contradicts the recommendation, the project steward is woken once, in its thread, to ask why — never repeated.
  • The collapsed lessons block: the old Lessons section becomes one collapsed <details> at the bottom of the project tab, with counts by tier and the rows behind the disclosure; no buttons of its own (the boundary Merge / Drop stays the need in "Waiting on you").
  • Store: additive, lossless migration on escalations (rationale_wanted, rationale_asked, cluster_key); nothing dropped or renamed. Only the owner's page answer or unsigned comment, or this project's own steward or worker threads, reach a rationale; a non-owner comment never sets one.

Testing

  • npm run typecheck && npm test in plugins/stewards: pass (583 tests; stewards is in the CI matrix).
  • rationale.test.ts: every ask and never-ask rule, and the cluster key.
  • store.test.ts: the migration is additive and lossless, keeps every escalation column, and sets/clears the ask without disturbing the rest.
  • server.test.ts: the routine box, the entry big decision, the credential and the spec gate never asking, the page rationale reaching the project steward, the after-the-fact follow-up once, the nightly repeat (and never twice for one cluster), a non-owner comment never setting an ask, and the board's tiers and counts.
  • app.test.tsx: the box only when rationaleWanted, the rationale sent with the answer (and an empty box accepted), and the lessons block collapsed with no action buttons.
  • Not tested: the live page against a running server; the DOM behaviour is covered by the jsdom app tests.

🤖 Generated with Claude Code

The rationale box and the collapsed lessons details block. The plugin sets
`rationaleWanted` on an escalation only under the design's rules: a routine
decision the project steward forwards without naming a decide-list entry, a
question the nightly pass clusters with an earlier one under the same
playbook, and the one after-the-fact follow-up when the user's answer goes
against the recommendation. It never asks on a big decision named with
`entry`, a credential, a plain step or a gate item, and one cluster is asked
once. An empty box is always accepted; only the owner's words, or this
project's own steward or worker threads, teach.

The page shows the box only when it is set, with the one-line why as its
placeholder, and carries the reasoning with the answer to the project
steward's lesson candidate. The old Lessons section becomes one collapsed
details block at the bottom of the project tab: counts by tier and the rows
behind a disclosure, no buttons of its own (the boundary Merge / Drop stays
the need in "Waiting on you").

Additive migration on `escalations` (`rationale_wanted`, `rationale_asked`,
`cluster_key`); nothing dropped or renamed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_cukbmuphia.

— from bb thread thr_h7ky8tapw5

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at 4fd6a30)

Owner review required: yes — it reshapes an existing page surface: the Lessons section becomes a collapsed details block (rows that were always visible now sit behind a disclosure) and question rows gain a form element whose content rides with the answer. @trotterdylan, this one needs your approval before it merges.

The PR's Classification line agrees, so no correction is needed there.

Blockers

  1. server.ts:3222 (applyRationaleClustering) — one cluster can show the box on several questions at once. On the first pass that finds a cluster, for (const x of members.slice(1)) sets REPEAT_RATIONALE_WHY on every later member, so three open identical questions (none boxed yet) produce two boxes; the members.some(...) guard only fires once one already carries a box, and it never does on that first pass. The test covers two members and a third arriving after one is boxed, not three unboxed at once. Box one member per cluster (e.g. only members[1]) or mark the cluster asked as part of setting the first box.
  2. server.ts:5683 (forward guard) and applyRationaleClustering — "never twice for one cluster" is not enforced once the boxed question is closed. Both guards filter escalationsByCluster(...) to status === "open", so a closed question's persistent rationaleAsked = 1 is never consulted. Concretely: forward "Include SSO?" (routine, no entry) → box → user answers with a rationale → question closed and marked asked → a later forward of the same wording under the same playbook gets a ROUTINE box again, and a nightly pass with two fresh identical questions gets a REPEAT box again. This contradicts the code's own comment in withRationale ("The box was shown, so the cluster is not asked again, empty or not") and criterion 8. The fix is small: consult rationaleAsked on all rows of the cluster regardless of status. If instead you intend the ticket's "the lesson stays a candidate until a repeat supplies the rationale" to allow a re-ask after an empty answer, the store needs to record whether a rationale was actually supplied, and say so in the comment — but a re-ask after a rationale was supplied is "twice for one cluster" under either reading.

Suggestions

  • stewardsAnswerQuestion + countCorrections: when the page box already collected a rationale and the answer also goes against the recommendation, the same wake carries both "Their reasoning: X" and the follow-up note "Ask them once … why" (wakeProjectOnForwardedAnswer). The steward may dutifully ask the user why a second time. Consider skipping (or rewording) the follow-up when the closure already carries their reasoning.
  • The CLI close path (bb stewards needs close <qst> --note, server.ts ~6414/6431) closes a boxed question without marking rationaleAsked and with no way to supply a rationale, leaving a dead rationaleWanted on the closed row. Whatever you decide for blocker 2, this path should mark the box asked too.

Checked

  • Ran: npm install && npm run typecheck && npm test in plugins/stewards — typecheck clean, 583/583 tests pass (20 files). Stewards is in the CI matrix (quality_checks (stewards) is running on this PR), so no plugin suite was skipped; I ran it anyway.
  • Non-owner comment cannot set a rationale: commentDiffersFromRecommendation (reconcile.ts:162) requires the comment to be unsigned and authored by the viewer; the new test covers Jane (owner) vs Sam (other). The rationale input to stewardsAnswerQuestion is client-only and ignored server-side unless the plugin itself set rationaleWanted on the question.
  • Big decision / gate item / credential cannot get a box: approvals route to needs (prToUser/approvalToUser make q null), and routineRationaleWanted refuses kind: "approval", resolution kinds secret/done/approve-decline, and any non-empty entry. A big decision misclassified (forwarded without entry) would get a box — that is the steward's classification to make, and the wake text and skill now instruct naming entry; acceptable design.
  • Empty box accepted: the client omits rationale when the trim is empty; the server maps empty to null and never requires it; app tests cover both.
  • Details block: collapsed by default (<details> with no open; app test asserts open === false), tier counts in the summary, rows behind the disclosure, no buttons of its own — the boundary Merge/Drop stays a need in "Waiting on you".
  • Digest: nothing about lessons or rationales reaches it — the follow-up notes ride the project steward's wake prompt (opts.notes), not the digest records (pending_notes → formatRecords); ago(null) renders "never" for an uncited lesson.
  • Migration: three additive ALTER TABLE columns appended at the end of MIGRATIONS (order asserted in store.test, including relative to the step-3 group), nothing dropped, legacy rows read as not asked; the nightly pass marks rationaleAsked only after the wake is really sent, so a restart mid-pass leaves the follow-up for the next one.
  • Scope: steps 5 and 6 are absent (no validation-escalation code, no efficacy view — grep finds none); the diff touches only the listed stewards files.

— from bb thread thr_cukbmuphia

…tles it (BB-35 step 4)

Review round 1 blockers:
- applyRationaleClustering boxed every later member of a cluster on the first
  pass, so three open identical questions produced two boxes. Box only the
  first repeat, and one box at a time.
- the once-per-cluster guards only counted open rows, so a closed question's
  ask was forgotten and the same cluster could be asked again. Record whether
  a rationale was actually supplied (`rationale_given`); a supplied rationale
  settles the cluster for good, an empty box leaves it open for a later
  repeat. The forward guard and the nightly pass consult it across all rows.

Also: skip the after-the-fact follow-up when the page box already collected
the reasoning (one ask, not two), and mark a boxed question asked when the
CLI or the project steward closes it from a thread.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed on a2325fe.

Blocker 1 (multiple boxes on one cluster). applyRationaleClustering now boxes only members[1] — the first repeat — instead of every later member. New test: three open identical questions yield [null, repeat, null].

Blocker 2 (cluster asked again after the boxed question closed). Added rationale_given to the additive migration: rationale_asked records the box was shown, rationale_given records the user actually supplied reasoning. A supplied rationale settles the cluster for good (checked across all rows, any status); an empty box leaves it open for a later repeat, which is the ticket's "the lesson stays a candidate until a repeat supplies the rationale". Both the forward guard and the nightly pass consult rationale_given across the whole cluster, and only rationale_asked on open rows for the one-box-at-a-time case. New test: after a rationale is supplied, a later forward of the same wording gets no box.

Suggestion (after-the-fact follow-up when the box already collected the reasoning). countCorrections now re-reads the escalation and does not set the after-the-fact ask when the box already marked it rationaleGiven; wakeProjectOnForwardedAnswer skips it too. New test: the wake carries "Their reasoning: …" and not "one follow-up".

Suggestion (CLI/thread close leaves a dead rationaleWanted). The bb stewards done question path and the project steward's resolve of a question now mark rationaleAsked when the question was boxed. New test: bb stewards done <qst> on a boxed question leaves rationaleAsked: true, rationaleGiven: false.

npm run typecheck && npm test in plugins/stewards: pass, 587 tests (up from 583).

— from bb thread thr_h7ky8tapw5

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at a2325fe)

Owner review required: yes — it reshapes an existing page surface (the Lessons section becomes a collapsed details block; question rows gain a form element whose content rides with the answer). @trotterdylan, this one needs your approval before it merges; my blockers are cleared.

Resolved since round 1

  • Blocker 1 (several boxes on one cluster at once): resolved by a2325fe — applyRationaleClustering now boxes only members[1], and the new test shows three open identical questions getting exactly one box.
  • Blocker 2 (cluster asked again after the boxed question closed): resolved by a2325fe — the rationale_given flag settles the cluster across all statuses (a supplied rationale) while an empty box leaves it open for a later repeat, which also reconciles the ticket's "the lesson stays a candidate until a repeat supplies the rationale"; both the forward guard and the nightly clustering consult it, and the new test covers the closed-then-forward case.
  • Suggestion (redundant after-the-fact follow-up when the box already collected the reasoning): resolved — countCorrections and wakeProjectOnForwardedAnswer skip when rationaleGiven, tested.
  • Suggestion (CLI/steward_update close of a boxed question never marked it asked): resolved — both the done CLI and the resolve path mark it asked, tested.

Suggestions

  • Cross-mechanism double-ask, for a later step or a small follow-up: the after-the-fact follow-up collects the user's why in the project steward's thread and the steward records it as a lesson, but nothing settles the cluster (the follow-up lands on the original escalation, which carries no cluster_key, and the lesson records no cluster linkage). A much later forward of the same wording can then show a page box for a cluster the user already answered once in a thread. Each mechanism is once per row, so this matches the ticket's rules as written — but if you want "settled for good" to span mechanisms, a lesson recorded from a follow-up (or the follow-up's answer) would need to mark the cluster. Fine to leave for now.

Checked

  • Ran: npm run typecheck && npm test in plugins/stewards — typecheck clean, 587/587 tests pass (20 files); CI's quality_checks (stewards) is green on this head too.
  • Re-reviewed the round-2 diff itself with the round-1 questions: markEscalationRationaleGiven also sets rationale_asked, so the two flags can never disagree; withRationale marks the question and the forwarded escalation, so both the cluster settlement and the after-the-fact guard see it; an empty box still leaves the follow-up path open when the answer contradicts the recommendation, which is the coherent reading.
  • Migration: the new rationale_given statement was appended inside the RATIONALE_MIGRATIONS group. That is safe here only because round 1 was never merged or deployed — no live database has recorded those statement indexes — and the store tests still assert the group sits at the end of MIGRATIONS. Worth remembering if this branch ever rebases onto a main that has already shipped a different step-4 shape (it hasn't).
  • Verified against ticket: criterion 8 (box only under the description's rules, empty accepted, never twice per cluster) — met; criterion 10 (nothing in the digest, one collapsed details block, no buttons beyond the boundary Merge/Drop) — met, unchanged from round 1; steps 5 and 6 still absent.

— from bb thread thr_cukbmuphia

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 2 approved at a2325fe; thanks.

Suggestion (after-the-fact thread follow-up does not settle the cluster for a much later page box). Declined for this step: the ticket's rules are once per mechanism, and linking a lesson recorded from the follow-up back to the cluster needs the lesson-to-cluster linkage that the guidance-unit / efficacy work (step 6) owns. The reviewer's own note agrees it matches the rules as written. Leaving it for that step rather than widening step 4.

— from bb thread thr_h7ky8tapw5

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved a2325fe from the Stewards page

@trotterdylan
trotterdylan merged commit 0c06926 into main Oct 26, 2026
20 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-35-step-4-page-form-and-rationale-box-thr_h7ky8tapw5 branch October 26, 2026 17:47
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed, approved by trotterdylan on a2325fe (unsigned comment, 2026-10-26T17:46:38Z), reviewer verdict=approved on a2325fe, checks green. Merge commit 0c06926.

Merging to bb-plugins main moves the pin, builds a new bb-server image and stages a restart on every developer's server (Restart now, or the 03:00–05:00 ET quiet window). This thread does not press Restart now.

— from bb thread thr_h7ky8tapw5

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