Repository navigation
fix: grant Pi trust and verify launch readiness - #7
Merged
Merged
Conversation
…narrow fixture corrections: deterministic Git identity, registered-project and readiness setup for Pi relaunch, and normalization of Pi’s per-launch busy generation in Herdr metadata comparisons. The trust, relaunch, and real-Herdr suites now pass; repository lint and diff checks also pass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Fix the recurring condition where workers sit indefinitely at “trust this folder” while the supervisor believes they launched. Trust is consistently granted for Firstmate-created isolated copies of registered projects; a fresh path must not require manual intervention or remain unnoticed. A worker launch is not successful until the worker is actually processing its instructions.
What Changed
Risk Assessment
✅ Low: Captain, the implementation is bounded to verified canonical Pi launches and now proves that the token-bearing launch message reached Pi’s processing lifecycle before reporting success; the surrounding cleanup, repository-identity, registry-validation, busy-state, and operator-documentation paths are internally consistent.
Testing
Inspected the target diff, ran focused behavioral and strict-registry checks, verified real Pi’s non-persistent approval semantics, drove successful and missing-readiness Firstmate launches plus adversarial project/command refusals, captured CLI and persisted-state evidence, and cleaned all transient test state; no screenshot was needed because the changed surface is a headless launch contract rather than visual layout.
fm-spawn-real-pi-authenticated.logandfm-spawn-real-pi-state.jsonshow the project extension loaded from the isolated Treehouse copy under policynever, while the saved trust store remained emp…fm-spawn-real-pi-state.jsonrecordsevent=launch-message-startand a readiness receipt matching the current busy generation beforefm-spawn-real-pi-authenticated.logreportsspawned.fm-spawn-real-pi.logrecords the bounded timeout and contains no successful spawn result when credential-empty Pi never began the launch message.fm-spawn-unregistered-refusal.logandfm-spawn-wrong-clone-refusal.logshow exit 1 before task metadata publication.fm-spawn-raw-harness-refusal.logshows the wrapped Pi command was rejected with exit 1 and no task metadata.pi-signedexecutable is installed on PATH. Provide the verified Pi-signed wrapper plus an authenticated model configuration, then rerun the live guard and product spawn.Evidence: Real Pi per-launch trust guard
Source: Real Pi per-launch trust guard
Evidence: Authenticated real Pi product launch
Source: Authenticated real Pi product launch
Evidence: Token-bound readiness and trust state
Source: Token-bound readiness and trust state
Evidence: Missing readiness evidence refusal
Source: Missing readiness evidence refusal
Evidence: Executable worker-command refusal
Source: Executable worker-command refusal
Evidence: Unregistered project refusal
Source: Unregistered project refusal
Evidence: Same-named wrong-clone refusal
Source: Same-named wrong-clone refusal
Evidence: Focused Pi trust/readiness behavior matrix
Source: Focused Pi trust/readiness behavior matrix
Evidence: Strict project-registry behavior
Source: Strict project-registry behavior
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 5 issues found → auto-fixed (11) ✅
bin/fm-spawn.sh:4685- The criterion “A worker launch is not successful until the worker is actually processing its instructions” is narrowed by this hunk to Pi/Pi-signed. A Codex or Claude worker that exits or waits for authentication after Enter still reaches the unconditionalspawnedreport without processing evidence. Enforce the required invariant before the shared success commit, or obtain explicit approval for Pi-only scope.bin/fm-spawn.sh:3330- Ordinary terminal widths prevent fresh trust from succeeding. Pi 0.85.1 word-wraps its explanation: at 100 columns,packages, and execute project extensions.spans two lines, so this match fails and the worker is killed after polling. Long paths also fail because line padding survives the newline removal inpi_trust_dialog_path_matches. These defects belong to the optional selector machinery identified in R4; removing that machinery in favor of per-launch trust is the smallest remedy.bin/fm-spawn.sh:3414- Ordinary conversation text overrides valid processing evidence. For example, a brief or response quoting “Do not trust” enters this branch even when the current generation already containspi-ext:agent-startoragent-settled. If that text remains visible through the polling window, spawn kills a successfully started worker. This is another defect in R4’s optional selector machinery; remove its screen-text veto while retaining the lifecycle readiness check.bin/fm-spawn.sh:1989- Simplification: persistent trust through an interactive selector is not required by the intent. Installed Pi supports--approvefor per-launch trust, as the added documentation acknowledges. The selector state machine, version allowlist, viewport prerequisite, and parallel live-test classifier add unnecessary restrictions: this preflight rejects even trusted Pi launches on cmux/Orca, and fresh paths on versions other than 0.85.1 require intervention. That contradicts “a fresh path must not require manual intervention.” Remove these components and grant trust at the validated launch boundary while retaining processing evidence.tests/fm-spawn-dispatch-profile.test.sh:759- The modified Pi-signed test retains six source-content-only assertions at lines 759–764: finding handler names,ctx.isIdle(), and generation arguments in generated TypeScript does not prove their behavior. These assertions are directly within the changed readiness test’s scope and violate the supplied test-quality rule. Remove the redundant string checks or execute the generated extension and assert lifecycle state, generation rejection, and notification effects using the existing behavioral driver.🔧 Fix applied.
5 issues (4 errors, 1 warning) still open:
bin/fm-spawn.sh:4685- The requirement “A worker launch is not successful until the worker is actually processing its instructions” remains narrowed by this hunk to Pi/Pi-signed ship/scout launches. A Claude or Codex worker waiting for authentication still reaches the unconditionalspawnedreport without processing evidence. Enforce the invariant before the shared success commit, or obtain explicit approval for narrower scope.bin/fm-spawn.sh:3330- Ordinary terminal widths prevent fresh trust from succeeding. Pi 0.85.1 wraps its explanation at 100 columns, splitting this required substring across lines; polling then expires and kills the worker. Wrapped paths also fail because removing newlines preserves Pi's per-line padding. These defects belong to R4's optional selector machinery; removing it in favor of per-launch trust is the smallest remedy.bin/fm-spawn.sh:3414- Conversation text overrides valid processing evidence. A worker investigating trust dialogs can produce a short reply containing “Do not trust”; this branch then ignores its current-generationagent-startoragent-settledreceipt. If the reply remains visible, spawn times out and kills the successfully started worker. Remove this screen-text veto with R4's optional selector machinery while retaining lifecycle readiness verification.bin/fm-spawn.sh:1989- Simplification: persistent trust through an interactive selector is unnecessary because installed Pi supports per-launch--approve. The selector state machine, version allowlist, viewport prerequisite, and parallel live-test classifier exceed the required scope. This preflight rejects even trusted launches on cmux/Orca, and fresh paths on other Pi versions need intervention, contradicting “a fresh path must not require manual intervention.” Remove these components and grant trust at the validated-copy launch boundary, retaining processing evidence.bin/fm-spawn.sh:3422- Pi's documenteddefaultProjectTrust="never", or a saved denial for a reused slot, returns untrusted without displaying a selector. The external-elifecycle extension still loads and emitsagent_start, so this branch reports success while project settings and extensions remain disabled. That contradicts “Trust is consistently granted for Firstmate-created isolated copies of registered projects.” Remove selector-based granting as proposed in R4 and explicitly grant per-launch trust at the validated-copy boundary.🔧 Fix applied.
4 errors still open:
bin/fm-spawn.sh:1738- The intent limits automatic trust to “isolated copies of registered projects,” but--approveis unconditional for canonical Pi workers.fm-spawn.shexplicitly permits unregistered projects via its no-mistakes fallback, so spawning an unregistered repository now executes its protected project extensions, settings, and packages without a registry-bound authorization check. Decide whether trust should extend to every explicitly dispatched repository; otherwise verify registration before granting approval and refuse before endpoint creation.bin/fm-spawn.sh:1979- The new raw-Pi refusal only recognizes the first non-assignment token. A supported raw command such asenv PI_OFFLINE=1 piis classified as harnessenv, bypasses this branch, receives neither--approvenor lifecycle verification, and still reaches the unconditionalspawnedreport. Decide whether raw commands are outside the Pi guarantee; otherwise reject them at a boundary shell wrappers cannot bypass. I recommend making canonical--harness pi|pi-signedthe only supported Pi worker path.bin/fm-spawn.sh:3313- A Pi readiness timeout during--relaunchcalls the generic backend kill, deleting the reusable tmux/Herdr endpoint. Because replacement metadata was already published, the control transaction retains a record pointing to that missing endpoint; another relaunch then cannot verify its working directory. On relaunch failure, stop and verify the Pi process using its control mechanics while preserving the endpoint; reserve endpoint deletion for failed fresh spawns.bin/fm-spawn.sh:4550- The new readiness wait has no abort-cleanup ownership. If the spawn receives SIGINT or SIGTERM during polling, the EXIT trap rolls back metadata and busy state but does not stop the already-launched Pi process, leaving an autonomous worker with no task record. Mark launch delivery as pending before Enter and perform kind-aware process/endpoint cleanup from the EXIT path until readiness commits.🔧 Fix applied.
3 errors still open:
bin/fm-spawn.sh:1744- The criterion “Trust is consistently granted for Firstmate-created isolated copies of registered projects” is contradicted by the unconditional--approve.fm-spawn.shaccepts arbitrary unregistered repositories (lines 2646–2651), so a Pi spawn now executes their project extensions, settings, and packages without establishing registry membership. Decide whether trust should cover every explicitly dispatched repository; otherwise verify registration before granting approval and refuse before endpoint creation.bin/fm-spawn.sh:1985- The raw-Pi refusal still examines only the first non-assignment token. For example,--harness "env PI_OFFLINE=1 pi"is classified as harnessenv, bypasses this branch, receives neither--approvenor lifecycle verification, and reaches the normalspawnedreport. Decide whether wrapped raw commands are outside the Pi guarantee; otherwise make canonical--harness pi|pi-signedthe only supported Pi worker path.bin/fm-spawn.sh:4650- Launch-cleanup ownership ends immediately after the lifecycle receipt, before the final metadata/backlog commit. If the backlog transition fails or the process is terminated between lines 4650 and 4745, the exit path rolls back the task record and busy state but leaves the autonomous Pi worker running untracked. KeepSPAWN_PI_DELIVERY_PENDINGset until the final commit succeeds, clearing it only once the worker has durable ownership.🔧 Fix applied.
4 issues (3 errors, 1 warning) still open:
bin/fm-spawn.sh:2589- The required criterion “Trust is consistently granted for Firstmate-created isolated copies of registered projects” is contradicted: this validates only the source clone, whilespawn_worktree_isolatednever verifies that the eventual worktree shares its Git common directory. Its own comments acknowledge that an unrelated checkout can pass, so a stale relaunch record or two matching transient path reads can launch there with--approve, executing that unrelated repository’s project extensions. Enforce repository identity at the shared worktree-validation boundary.bin/fm-spawn.sh:1916- The criterion “A worker launch is not successful until the worker is actually processing its instructions” remains bypassable because this is only a lexical Pi detector. For example,--harness 'p=pi; "$p"'skipsp=pias an assignment and never sees a literal Pi executable token; the pane then launches Pi without--approve, lifecycle wiring, or readiness verification and reaches the ordinaryspawnedreport. A guaranteed remedy requires choosing between removing raw worker commands or adding runtime identity verification.bin/fm-spawn.sh:3427- Pi cleanup relinquishes ownership before endpoint closure is proven. Fresh cleanup delegates torovo_endpoint_cleanup, which masks every backend-kill failure with|| true; after a readiness or final backlog-commit failure, metadata and busy state are rolled back even if Pi remains running. Propagate and verify closure, and retain recovery metadata until the endpoint is confirmed stopped.tests/fixtures.sh:153- The fake backend parses generated.pi-ext.tssource withsedto discover the busy-event command and then fabricatesagent-start. This is a newly added source-content-only assertion: dead or commented matching text can pass, while a behavior-preserving TypeScript refactor can fail. Pass explicit fixture parameters or execute the generated extension and assert its observable receipt.🔧 Fix applied.
2 issues (1 error, 1 warning) still open:
bin/fm-spawn.sh:3307- The changed readiness check treats any current-generation Piagent_startoragent_settledevent as proof that the launch brief began. With--approve, a registered project's trustedsession_startextension can callpi.sendUserMessage()before Pi processes its positional launch message; that unrelated run produces this receipt, allowing spawn to commit while the launch brief is delayed or never processed. This contradicts “A worker launch is not successful until the worker is actually processing its instructions.” Bind readiness evidence to the exact launch brief or a unique launch token before accepting its following agent-start event.bin/fm-spawn.sh:2365- The change introduces a second project-registry matcher even thoughfm-project-mode.shalready owns this parsing. No intent requirement needs parallel parsing, and the two definitions now disagree on duplicates: the established parser accepts the first match while this path requires exactly one. Remove this matcher and expose strict registration validation through the existing registry owner.🔧 Fix applied.
2 issues (1 error, 1 warning) still open:
bin/fm-project-mode.sh:84---strictvalidates only the derived mode and yolo values, not the declared registry grammar. For example,- project [no-mistakes +bogus] - descriptionsucceeds because the unknown token is ignored;fm-spawn.shthen treats the project as verified and launches Pi with--approve. Reject malformed brackets and annotation tokens outside one valid mode plus optional+yolobefore strict validation succeeds..agents/skills/secondmate-provisioning/SKILL.md:94- The canonical-only harness parser now rejects every raw launch command, but this required operator skill still says local secondmate routes accept one;bin/fm-spawn.shlines 255–256 also retain raw-command guidance. A firstmate following the documented procedure will issue a command that now fails before launch. Update both descriptions to the exact verified-adapter contract.🔧 Fix applied.
1 warning still open:
bin/fm-spawn.sh:1938- The exact-token rejection leaves the public--helpcontract wrong: Usage lines 4–6 still advertiselaunch-commandfor every spawn form. An operator following that help will choose a documented command that now always refuses. Remove|launch-commandfrom those Usage lines.🔧 Fix applied.
1 error still open:
bin/fm-spawn.sh:4106- The R15 fix expanded “bind readiness to a unique per-launch token” into an in-memory prerequisite for every later busy event. Pi reloads explicit-eextensions during/reloadand rebuilds them on/newand/fork, resettinglaunchEstablished=false; subsequent prompts lack the one-time marker, so lines 4106 and 4110 silently discard every busy/idle transition and the supervisor can report idle while work runs. Revert this overreach to the minimal accepted fix: use the marker only for the causally matched launch-readiness receipt, while lateragent_startandagent_settledevents retain normal busy tracking.🔧 Fix applied.
1 error still open:
bin/fm-spawn.sh:4099-launchPendingis one global latch shared by every prompt, whileagent_startcarries no prompt identity. A trusted projectbefore_agent_starthandler can fire-and-forget an unmarkedpi.sendUserMessage()while handling the marked launch prompt: the nested unmarked callback sets the latch false, the original marked callback sets it true, and the nested run'sagent_startcan then consume that true value and emitlaunch-agent-start. Line 3308 accepts this as readiness although Pi is processing the extension message and the launch brief may never start. This contradicts “A worker launch is not successful until the worker is actually processing its instructions.” Bind readiness directly to a lifecycle event carrying the token-bearing user message, such as Pi'smessage_start, or another per-run-correlated event instead of bridging independent callbacks through a boolean.🔧 Fix applied.
1 error still open:
tests/fake-pi-worker.sh:28- The shared fake Pi executable still invokeshandlers.before_agent_start, but the generated extension now registers readiness throughmessage_startand no longer defines that handler. Every approved invocation therefore throws before emitting readiness; the four real-Herdr suites using this fixture time out and fail. Emit the token-bearing usermessage_startafteragent_startinstead.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
fm-spawn-real-pi-authenticated.logandfm-spawn-real-pi-state.jsonshow the project extension loaded from the isolated Treehouse copy under policynever, while the saved trust store remained emp…fm-spawn-real-pi-state.jsonrecordsevent=launch-message-startand a readiness receipt matching the current busy generation beforefm-spawn-real-pi-authenticated.logreportsspawned.fm-spawn-real-pi.logrecords the bounded timeout and contains no successful spawn result when credential-empty Pi never began the launch message.fm-spawn-unregistered-refusal.logandfm-spawn-wrong-clone-refusal.logshow exit 1 before task metadata publication.fm-spawn-raw-harness-refusal.logshows the wrapped Pi command was rejected with exit 1 and no task metadata.pi-signedexecutable is installed on PATH. Provide the verified Pi-signed wrapper plus an authenticated model configuration, then rerun the live guard and product spawn.bin/fm-spawn.sh --helpplus version/availability probes for Pi 0.85.1, Herdr 0.9.1, Treehouse 2.3.0, Node, and jqbin/fm-test-run.sh tests/fm-pi-trust-readiness.test.shFM_PI_TRUST_READINESS_LIVE=1 bin/fm-test-run.sh tests/fm-pi-trust-readiness-live-e2e.test.shRealfm-spawn.shlaunch with--harness pi,defaultProjectTrust=never, an authenticated OpenAI Codex model, and an isolated Herdr lab sessionRealfm-spawn.shrefusal checks for an unregistered project, a same-named wrong clone, and--harness "env PI_OFFLINE=1 pi"bin/fm-test-run.sh tests/fm-task-delivery.test.shRemoved the isolated Herdr session, disposable credential copy, temporary project copies, Treehouse copy, and task temp directories; verified the source worktree remained clean✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.