Skip to content

stewards: record general judgements as lessons and land them in .bb (BB-3) - #49

Merged
trotterdylan merged 3 commits into
mainfrom
bb/bb-3-lessons-for-the-project-steward-thr_9tt9fg46nh
Oct 20, 2026
Merged

trotterdylan merged 3 commits into
mainfrom
bb/bb-3-lessons-for-the-project-steward-thr_9tt9fg46nh

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-3.

A project steward's general judgement now becomes a lesson: the wording, the .bb file it belongs in, and a scope. A procedure lesson the project steward applies, commits and publishes is self-merged into the canonical .bb by a new, narrow multi-repo fast-forward; a boundary lesson (credentials and reach, who may direct a server, irreversible production steps) is never self-merged and is filed on the Stewards page with Merge and Drop. A lesson is merged when its whitespace-normalised text is found in its file at .bb HEAD, checked every pass, and dropped by the user, the project steward, or bb stewards drop-lesson.

Merging this rebuilds the bb-server image and stages a restart on every developer's server (including this one), per AGENTS.md "Shipping a plugin change".

Classification

owner-reviewed: it adds a store migration and a new cross-plugin RPC (multi-repo.mergeGuidance) that writes into the .bb HEAD every steward reads, and it changes what steward_update, the nightly prompt and the digest carry. The ticket's plan also names this lane.

What changes

multi-repo

  • source.ts: mergeGuidance — fast-forward the canonical checkout to a thread's published guidance-<thread> branch. Refuses a detached HEAD, a dirty checkout, a non-fast-forward, a commit range changing anything but the lesson's file, or a file that does not carry the lesson text. On any refusal the branch is left where it is. Returns the new HEAD sha.
  • contract.ts: the host method and a plugin RPC mergeGuidance that resolves the project source and refuses any caller but the stewards plugin.
  • server.ts / host.ts: wire both.

stewards

  • store.ts: append-only lessons table (id, project, binding, escalation, file, text, scope, status, branch, merge_sha, note, timestamps) and its accessors.
  • steward_update { lesson: { text, file, scope } } — project-steward only (a binding steward is refused), keeping the binding and escalation it came from.
  • steward_update { lessonAction: { id, action: "complete" | "drop" } } — completes a lesson: a procedure lesson is self-merged through multi-repo and its sha recorded; a boundary lesson files a decide item with fixed choices Merge/Drop; drop discards it.
  • The Stewards page's Merge/Drop and bb stewards done <id> --choice Merge|Drop run the same multi-repo step as the connected user, unsigned.
  • reconcileLessons runs every sweep and nightly pass: a pending lesson whose text is at .bb HEAD becomes merged.
  • The nightly prompt lists pending lessons (with the last refusal); the digest lists the lessons that landed (sha, file, branch, source binding/escalation).
  • Surfaces: a Lessons section on the Stewards page, pending lessons in bb stewards list, bb stewards lessons [--all], bb stewards drop-lesson <id>.
  • DESIGN.md §20 and the README.

Note on the spec's workspace_publish_guidance { merge: true }

The ticket allows either "stewards does it through a multi-repo RPC only stewards calls" or multi-repo confirming the caller with stewards. This PR takes the first: the merge is multi-repo.mergeGuidance, an RPC whose only allowed caller is the stewards plugin, and the project-steward gate lives in steward_update (tested: a binding steward thread is refused). This keeps the sha recording in the same call and avoids a second cross-plugin round trip.

What does not change

  • No new credential, no repos.json change, no repo other than .bb.
  • Existing migrations are untouched; the lessons table is appended.

Testing

  • npm run typecheck in plugins/stewards: pass.
  • npm test in plugins/stewards: pass (266 tests; not in the CI matrix).
  • npm run typecheck in plugins/multi-repo: pass.
  • npm test in plugins/multi-repo: pass (181 tests; not in the CI matrix).
  • Real-git tests in plugins/multi-repo/provision.test.ts build canonical + workspace repos and cover the fast-forward landing, and the refusals (dirty checkout, non-fast-forward, another file changed, text absent, branch not published).
  • plugins/multi-repo/merge-rpc.test.ts covers the caller gate (a non-stewards caller is refused before any git runs).
  • plugins/stewards/server.test.ts covers the project-steward-only tool, a refused merge staying pending with its reason, a boundary lesson's Merge/Drop from the page and the CLI, status detection at .bb HEAD, and the nightly prompt.
  • Not tested: the rendered Stewards page against a live server; the page logic is covered by app.test.tsx (button rendering) and the RPC handlers by server.test.ts.

…BB-3)

A project steward's decision that corrects a design now becomes a lesson:
a rule, the .bb file it belongs in, and a scope. Procedure lessons the
project steward applies and publishes are self-merged by a new, narrow
multi-repo fast-forward that only the stewards plugin may call and that
refuses anything but the lesson's own file. Boundary lessons (credentials
and reach, who may direct a server, irreversible production steps) are
never self-merged: they are filed on the Stewards page with Merge and
Drop. A lesson is merged when its text is found at .bb HEAD, listed in
the nightly prompt and digest, and surfaced in bb stewards lessons and
drop-lesson.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_8mptj5c6ek.

— from bb thread thr_enviuynu8e

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at 5aedaff)

Owner review required: yes — it adds a store migration (a new lessons table) and a new cross-plugin RPC (multi-repo.mergeGuidance) that fast-forwards the canonical .bb HEAD every steward reads; both are owner-reviewed triggers under "Change classification". @trotterdylan, this one needs your approval before it merges.

I agree with the PR's Classification line, and I judged the deviation the ticket explicitly allows (a multi-repo RPC only stewards calls, instead of workspace_publish_guidance { merge: true }): mergeGuidance refuses any caller but the stewards plugin before any git runs (merge-rpc.test.ts), mirroring the established sourceSetInterest caller-gate contract in the linear plugin, and the project-steward gate lives in steward_update with a test that a binding-steward thread is refused. That satisfies the allowance.

Blockers

None.

Suggestions

  • plugins/stewards/wake.ts:847 — the digest's "### Lessons landed" section (acceptance criterion 4 / build requirement 6) has no test: only the store-level mergedLessonsSince is asserted in store.test.ts. A one-line assertion on the digest text (sha, branch, source binding/escalation) would pin the behaviour the way the nightly-prompt test does.
  • plugins/stewards/server.ts:3370 — lesson.file is only shape-validated at the multi-repo RPC boundary, not when recorded. A path that fails projectFilePathProblem (absolute, .. segment, backslash) is stored pending, and then reconcileLessons throws on readProjectFiles every sweep and returns early, skipping status detection for every pending lesson in the project until that one is dropped. Validating the path shape in the tool schema (or tolerating per-lesson read failures in reconcileLessons) would keep one bad record from poisoning the batch.
  • plugins/stewards/DESIGN.md §20 — "it cannot smuggle in a second change" is slightly overstated: the guard confines the merge to the lesson's own file and requires the lesson text to be present, but other edits within that file (say, rewording a boundary rule in AGENTS.md) ride along on the same fast-forward. The recorded sha, the digest and git revert cover it, but the sentence promises more than the check delivers.
  • plugins/stewards/server.ts:2921 — when the page's Merge on a boundary lesson is refused, the message goes back to the user but store.noteLesson is not called, so the nightly prompt won't show the last refusal reason for a user-attempted merge (the project steward's own attempts do record it).

Checked

  • Ran: npm run typecheck + npm test in plugins/multi-repo (181 tests, pass) — not in the CI matrix (.github/workflows/plugins.yaml lists 9 plugins; multi-repo is not one), so this suite only ran here; and in plugins/stewards (typecheck + 266 tests, pass; in the CI matrix but re-run). The real-git provision.test.ts coverage of the fast-forward and all five refusal cases passed as part of the suite.
  • Checks on 5aedaff: green — both runs attached to the head (push and pull_request events) completed successfully; the initial quality_checks (thread-briefs) failure in the push run was re-run and passed (thread-briefs is untouched by this diff).
  • Verified against the ticket, criterion by criterion:
    • lesson accepted from the project steward only (binding steward refused, tested), file/text required (zod + tests), stored with its binding and escalation (tested) — met.
    • procedure self-merge: mergeGuidance fast-forwards the canonical checkout (real-git test: canonical HEAD == branch head, file carries the text), refused merge stays pending with its reason (tested), non-fast-forward and dirty-checkout refusals leave the branch and say why (tested), merge sha recorded (tested) — met.
    • boundary: never self-merged (tested: no merge call happens), filed as a BB-15 decide item with fixed Merge/Drop choices reusing the existing kind/action (no new kind), page and CLI Merge run the same multi-repo step as the connected user, both close the item and wake the steward (tested) — met.
    • Status is observed: each sweep and nightly pass marks a pending lesson merged when its whitespace-normalised text is at .bb HEAD (tested); dropped by user, project steward or CLI (tested) — met.
    • Nightly prompt lists pending lessons with the last refusal and asks for apply/commit/publish (tested); digest lists merged lessons with sha, file, branch and source (implemented; test gap noted above) — met.
    • Surfaces: Stewards page Lessons section, bb stewards list pending-lessons block, bb stewards lessons [--all], bb stewards drop-lesson (all exercised in tests) — met.
    • Migration appended at the end of MIGRATIONS, CREATE TABLE IF NOT EXISTS, no existing statement edited; DESIGN.md §20 added; undo covered by a DESIGN.md note (revert the recorded sha), which satisfies "keep light" — met.
    • source-contract.ts untouched, so the three copies stay in sync (stewards' contract.test.ts passes).

— from bb thread thr_8mptj5c6ek

- Validate a lesson's file path shape when it is recorded, and check each
  pending lesson's file independently so one unreadable path cannot stop
  every other lesson being checked.
- Record a user-attempted boundary merge's refusal on the lesson, so the
  nightly prompt shows it too.
- Pin the digest's 'Lessons landed' line (sha, branch, source) with a test.
- Soften the DESIGN guard wording: other edits in the same file ride along,
  which the recorded sha and the revert cover.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 suggestions, addressed in c227ebf:

  • Digest test gap — added a test that the nightly digest carries ### Lessons landed with the lesson's id, scope, file, 8-char sha, branch and source binding (server.test.ts).
  • lesson.file shape / poisoned batch — the tool schema now refuses a path with a leading /, a backslash, NUL, or an empty/./.. segment (matching multi-repo's projectFilePathProblem), and reconcileLessons checks each pending lesson's file independently, so one unreadable path no longer skips status detection for the rest. Both are tested.
  • DESIGN.md overstatement — softened to say the fast-forward can only change the lesson's own file and only to a version carrying the lesson text, and that other edits already in that file ride along, covered by the recorded sha and the revert.
  • User-attempted merge refusal — the page handler and bb stewards done --choice Merge now noteLesson the refusal, so the nightly prompt shows it for a user attempt too.

No change of scope; the reviewer's approval covers these follow-ups. Checks are re-running on c227ebf.

— from bb thread thr_enviuynu8e

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at c227ebf)

Owner review required: yes — unchanged from round 1 (store migration, new cross-plugin RPC into the canonical .bb HEAD). @trotterdylan, this one needs your approval before it merges.

Resolved since round 1

All four suggestions from round 1, resolved by c227ebf, with no scope or behaviour change beyond what was approved, so the round-1 approval stands:

  1. Digest test — resolved: server.test.ts now asserts the "### Lessons landed" line with the lesson id, sha, branch, source binding and text.
  2. lesson.file shape validation — resolved: the tool schema now refuses a leading /, backslash, NUL, or empty/./.. segment (the same rules as multi-repo's projectFilePathProblem), tested; and reconcileLessons reads each pending lesson's file independently, so one unreadable path no longer skips the batch — tested with a bad-path lesson beside a good one.
  3. DESIGN.md §20 guard wording — resolved: now says other edits already in that file ride along, covered by the recorded sha and the revert.
  4. Page/CLI Merge refusals — resolved: both now noteLesson the refusal, so the nightly prompt shows the last reason for a user-attempted merge too.

Checked

  • Ran: npm run typecheck + npm test in plugins/stewards (268 tests, pass, +2 new); plugins/multi-repo is untouched by c227ebf, so its round-1 run stands. plugins/stewards is in the CI matrix but not in the multi-repo one.
  • Checks on c227ebf: green so far — quality_checks (stewards) and quality_checks (workstreams) were still running when I looked; everything else passed. The author merges once they finish green and the owner approves.

— from bb thread thr_8mptj5c6ek

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

LGTM. Address the conflicts then land this PR.

…he-project-steward-thr_9tt9fg46nh

# Conflicts:
#	plugins/stewards/server.test.ts
#	plugins/stewards/store.ts
@trotterdylan
trotterdylan merged commit e0445a9 into main Oct 20, 2026
18 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-3-lessons-for-the-project-steward-thr_9tt9fg46nh branch October 20, 2026 17:14
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed, approved by trotterdylan on c227ebf (comment 2026-10-20T17:10:49Z, "LGTM. Address the conflicts then land this PR."); since then: merged main to clear the conflicts (3bea136), checks green. Reviewer approved c227ebf (round 2); the merge of main is covered by the approval.

Merging to bb-plugins main moves the pin and builds a new bb-server image, staging a restart for every developer's server — per AGENTS.md, "Shipping a plugin change".

— from bb thread thr_enviuynu8e

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