Repository navigation
feat(pi): add persistent supervision branch model selection - #3028
Merged
Merged
Conversation
Supervision is an easier job than the captain's own conversation, so the Pi supervision branch does not need main's model. A new /supervision-model command opens Pi's own selector over Pi's own catalog of credentialed models, plus a "Follow main" entry, and persists the pick as one <provider>/<model-id> line in this home's gitignored config/supervision-branch-model. Firstmate keeps no model catalog of its own. The branch resolves the pin at every branch build - the first wake of a cold start and the reopen after /new, /resume, /fork, or reload - so the choice survives all of them, and picking also releases the live branch so the next wake reopens the same persistent branch conversation under the new model. An absent, unreadable, or unparseable file means no pin and keeps today's behavior byte for byte: no model option is passed and Pi picks the branch's model exactly as before. A pin naming a model Pi cannot hand back is never silently downgraded onto main's model: the branch refuses to build and the wake falls back to the captain-facing main path naming the unusable pin, which is the extension's existing failure direction. The choice is home-local and not part of secondmate inherited configuration, matching the Pi Calm preference precedent. docs/configuration.md owns the operator-facing schema. Portable regressions cover pin-present on create and reopen, pin-absent default, the command's persistence, cancellation, and live rebind, and both unusable and unparseable pins. The opt-in real-SDK guard proves the vendor surface the pin reads and that an explicit model wins over the model a reopened session recorded.
Clearing the pin with "Follow main" removed the file but the next branch build reopened the persistent branch session with no explicit model override, so Pi restored the model that session had recorded - the old pinned model - while the command reported that the branch now follows main. The same gap meant an absent pin did not reliably mean same-model-as-main once a home had pinned once. The pin file's current state now decides the model on every branch build, create and reopen alike, overriding Pi's session-state restore. With a pin, that model. With no pin, main's own current model is applied explicitly, tracked from the contexts Pi already hands the extension plus its model_select event, since the branch is built at wake time with no context of its own. Only when main's model is unknown, or this home's stored credentials cannot run it in the isolated branch runtime, does a build fall back to passing no override at all, which is the behavior from before the pin existed; the branch is never refused over model choice. The command's notification now reports the model actually applied, and says plainly when clearing the pin could not apply main's model instead of claiming a change that did not take effect. No credential handling changes: the branch still relies entirely on the stored credentials its own runtime already holds, and the picker stays restricted to models that runtime can resolve. Colocated regressions cover pin present on create and reopen, clearing the pin returning a reopened branch to main's model and specifically not the old pinned one, an unparseable pin behaving as no pin, and the unknown-main-model fallback to no override.
kunchenguid
force-pushed
the
fm/fm-supervision-branch-model-r1
branch
from
August 25, 2026 07:26
688cf90 to
730ab67
Compare
Confidence Score: 5/5The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issue identified. The model pin is applied through the shared branch creation path, stale builds are rejected through revision tracking, live replacement is serialized behind active work, and failure paths preserve wake fallback and provide accurate operator notifications. Reviews (1): Last reviewed commit: "no-mistakes(document): Correct supervisi..." | Re-trigger Greptile |
Intent
Add a Pi slash command that lets an operator pick and persist a cheaper model for the supervision-branch session, stored in this Firstmate home's gitignored config/ directory.
WHY: people are adopting the Pi main+supervision-branch design, and supervision is an easier job than main, so running the branch on a cheaper model saves cost. The captain wants operators to configure a different model for the supervision session.
ACCEPTED REQUIREMENTS, all deliberate:
CAPTAIN DECISIONS MADE DURING REVIEW OF AN EARLIER ROUND, all now implemented and all binding:
REPO CONVENTIONS required and followed (this edits Firstmate's shared tracked material): the firstmate-coding-guidelines skill was loaded first; one full sentence per line in tracked Markdown; plain dash never an em dash; no agent name as a commit co-author; colocated tests extended in tests/ rather than a new runner; tests exercise executable interfaces and observable behavior rather than implementation source text; harness-dependent behavior is proven against the real vendor SDK with the dated result recorded in docs/verification/runtime-backends.md.
TESTS, all behavioral, in tests/fm-pi-branch-extension.test.sh: the current pin state binding every create and reopen; clearing the pin returning a reopened branch to main's model and specifically NOT the old pinned one; an unparseable pin behaving as no pin; the unknown-main-model fallback to no override; the picker's offered contents including the exclusion of a main-session-only provider and the preservation of OAuth credential type; persisted bytes and 0600 mode; live-branch rebind; the in-flight build race; cancellation leaving the pin untouched; a runtime load failure leaving the old pin and emitting no success notice; and unusable-pin fallback to main. The follow-main wiring was mutation-checked to confirm the tests fail without it. The opt-in real-SDK guard tests/fm-pi-branch-live-e2e.test.sh gained two probes against the real installed pi-coding-agent: the extension reading an unresolvable pin through a real ModelRegistry, and a credential-free precedence probe using a local never-contacted fake provider proving an explicit model is applied on create, wins over the model a reopened session recorded, and is absent-pin-restorable.
While updating the dated verification record I also corrected its stale claim that the installed signed pi CLI was 0.84.1; this machine has 0.82.0, and the npm package pinned by the guard and typecheck is 0.81.1.
README.md gained one pointer sentence next to the existing /calm sentence for discoverability, with docs/configuration.md remaining the single owner of the schema per the repo's one-owner rule. AGENTS.md gained one line in its config inventory, and docs/pi-supervision-branch.md gained one-line cross-references in its components, cost-model, and verification sections.
What Changed
/supervision-modelto select an isolated-runtime-compatible model from Pi’s catalog and persist the pin atomically with private permissions.Risk Assessment
✅ Low: The model-selection changes are scoped, preserve branch isolation and credential semantics, and address live and in-flight rebinding without introducing a substantiated correctness issue.
Testing
Inspected the model-selection change, ran focused behavioral and strict type tests, and verified against the real Pi 0.81.1 SDK that explicit models override reopened session state. Pin persistence, Follow main, live-follow rebinding, pinned-model stability, picker filtering, OAuth preservation, race handling, and honest failure notifications all worked. No screenshot was captured because the Pi selector was exercised through its headless command interface.
Evidence: Focused supervision-branch behavioral test transcript
Source: Focused supervision-branch behavioral test transcript
Evidence: Real Pi 0.81.1 SDK end-to-end transcript
Source: Real Pi 0.81.1 SDK end-to-end transcript
Evidence: Strict Pi extension typecheck transcript
Source: Strict Pi extension typecheck transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
.pi/extensions/fm-branch-supervision.ts:859- The required absent-pin “follow main” behavior is not maintained when main changes models.model_selectonly updatesmainModel; it neither invalidates an in-flight build nor releases an existing unpinned branch. Concrete path: build an unpinned branch on model A, switch main to B, then dispatch another wake; the persistent branch still runs A indefinitely. This contradicts the criterion that “with no pin, main's own current model is applied EXPLICITLY.” When no valid pin exists, bump the model-selection revision and release the branch at this event boundary so an in-flight or live A session cannot survive the switch..pi/extensions/fm-branch-supervision.ts:933- The post-clear model resolution is outside error handling. IfModelRuntime.create()succeeds for the picker but fails after the operator selects Follow main, the pin has already been removed and the branch released, then the command rejects without the required honest warning. This contradicts “the command ... says plainly when clearing the pin could not apply main's model.” Catch this resolution failure and emit the same warning path with its reason.🔧 Fix: Make unpinned supervision follow main model changes
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
git status --shortand target diff inspectionbash tests/fm-pi-branch-extension.test.shbash tests/fm-pi-primary-types.test.shFM_PI_BRANCH_LIVE_E2E=1 bash tests/fm-pi-branch-live-e2e.test.sh✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.