feat(bin): enforce deterministic profiles for delegated Pi#877
Open
BazsaX254 wants to merge 7 commits into
Open
feat(bin): enforce deterministic profiles for delegated Pi#877BazsaX254 wants to merge 7 commits into
BazsaX254 wants to merge 7 commits into
Conversation
added 7 commits
July 22, 2026 20:22
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
Implement FirstMate-owned deterministic delegated Pi profile enforcement for Pi workers, scouts, helper routes, batches, supported secondmates, and recovery across tmux, Herdr, Zellij, Orca, and cmux, while leaving the primary Pi path xhigh. The opt-in operator-owned home profile must pin Pi 0.81.1, an exact model and effective context metadata, explicit medium thinking, and compaction at exactly 60 percent using reserveTokens = contextWindow - floor(0.60 * contextWindow), failing closed before launch on ambiguity, hostile environment/project/extension surfaces, raw launch wrappers, override/model cycling, or unsupported routes. Preserve only required FirstMate extensions, keep existing backend refusals, avoid KING-specific shared policy, and provide provider-free portable tests with overridable Pi/package/compiler discovery, exact local 272000 context and 108800 reserve proof, strict greater-than boundary behavior, resume stability, primary xhigh separation, and full backend coverage. Do not invoke a model or live Pi worker, mutate Herdr lifecycle, global Pi state, production configuration, or add an agent co-author.
What Changed
Risk Assessment
✅ Low: The change is well-bounded, closes the previously identified environment and secondmate fail-open paths, and introduces no remaining material source-verifiable risk.
Testing
Repository inspection, provider-free automated profile/dispatch tests, manual launch/refusal evidence, primary xhigh separation, secondmate inheritance, and all five backend families were exercised without invoking a model or live Pi worker; the intended behavior passed, with only unchanged environment-dependent checks blocked by missing
tasks-axi, root permission semantics, and an unavailable TypeScript compiler.Evidence: Delegated Pi user-experience transcript
Evidence: Primary xhigh separation transcript
Evidence: Compaction and profile proof
Evidence: Spawn dispatch proof
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 1 issue found → auto-fixed ✅
tests/fm-spawn-dispatch-profile.test.sh- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Review** - 2 issues found → auto-fixed (2) ✅
bin/fm-spawn.sh:791- The required criterion says to fail closed on “hostile environment ... surfaces,” but this launch inheritsPI_PACKAGE_DIR. Pi 0.81.1 uses that variable to derive its package metadata, application name, and agent-directory variable; a hostile package manifest can therefore make Pi ignore the pinnedPI_CODING_AGENT_DIR, while the guard validates the intended directory instead of the one Pi actually uses. Clear package/runtime overrides during both validation and launch.bin/fm-spawn.sh:744- The required criterion calls for enforcement across supported secondmates, but profile propagation failure only warns and launch continues. Ifpi-delegated-profilespecifically fails or is skipped—such as when a secondmate could not fast-forward to the new ignore rule—the home can later launch Pi workers using a stale or absent profile. When the primary profile is active, require proof that this item converged before launching or recovering the secondmate.🔧 Fix: Captain: Harden delegated Pi environment and inheritance
1 error still open:
bin/fm-pi-profile.sh:97- The required hostile-environment hardening remains incomplete: this clearsPI_PACKAGE_DIRbut still inheritsNODE_OPTIONSwhile executing the pinned JavaScript CLI. A hostile preload can run before Pi 0.81.1, restore package redirection or alter validation/runtime state; the rendered launch atfm-spawn.sh:813has the same gap. Run validation and launch with Node preload/runtime injection variables cleared or explicitly allowlisted.🔧 Fix: Captain: Block Node injection in delegated Pi launches
✅ Re-checked - no issues remain.
tasks-axi, preventing unrelated teardown assertions in unchanged backend tests from completing. The inheritance suite also contains a chmod-based assertion that cannot work when executed as root; a non-root retry was blocked because the workspace is beneath/root. Neither failure occurred in files changed by this commit.git status --short --branchandgit diff 51404137e8c4729670233cc31ff43eeae527b77c..66f0add70fcdf3b160fb56b470a9d7c09358d2c6bash tests/fm-pi-compaction-profile.test.shbash tests/fm-spawn-dispatch-profile.test.shManual fake-terminal delegated Pi spawn capturing CLI output, persisted metadata, exact launch command, and conflicting-override refusalManual no-profile Pi launch capturing persisted xhigh metadata and the exact--thinking 'xhigh'commandbin/fm-test-run.sh tests/fm-shared-captain-inheritance.test.sh tests/fm-secondmate-harness.test.sh tests/fm-spawn-batch.test.sh tests/fm-spawn-worktree-settle.test.sh tests/fm-backend.test.sh tests/fm-backend-herdr.test.sh --json /tmp/no-mistakes-evidence/01KY5QVYG55970Z4HTME2WGJVG/adjacent-tests.jsonbin/fm-test-run.sh tests/fm-backend-zellij.test.sh tests/fm-backend-orca.test.sh tests/fm-backend-cmux.test.sh --json /tmp/no-mistakes-evidence/01KY5QVYG55970Z4HTME2WGJVG/remaining-backends.jsonrunuser -u nobody -- bash tests/fm-shared-captain-inheritance.test.sh(environment retry; workspace traversal denied)Finalgit status --shortand generated-directory inspection✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.