Repository navigation
fix(pi): estender os seatbelts de comando ao modo notebook - #1
Merged
Merged
Conversation
shishiv
added a commit
that referenced
this pull request
Sep 28, 2026
shishiv
added a commit
that referenced
this pull request
Sep 28, 2026
… box Merges shishiv/firstmate main (8709a31) into local main (5bab8f1) as a true merge, so fork/main is an ancestor and publishing to the fork's main is a fast-forward. The fork's main was rewritten after the originally named commits: 7fcc62a (#1) and 6cba29f (#2) survive only on fork branches such as main-antes-20260928. fork/main carries their re-ports, c0ad743 (#1) and 8709a31 (#2), on top of an older age of the Kiro work (26e0caa, 4ae0ca5, aec0779) plus 056b9a0 (.kiro/skills). This accounting is against those real hashes. Resolution rule: in every conflicted file whose fork/main content equals local 28c5629 (the local-side twin of fork aec0779), the local side is the newer age of the same change, so local wins. That covers bin/fm-harness.sh, bin/fm-session-lock-lib.sh, bin/fm-primary-endpoint-lib.sh, bin/fm-kiro-turnend-hook.sh, docs/supervision-protocols/kiro-cli.md, docs/turnend-guard.md and operational-home-layout/SKILL.md. This keeps the shared harness/lock ancestry walk (ce770af) and the every-turn ensure doorbell (92ee7b2, 5bab8f1) intact. Kiro twins (26e0caa = 43a3714, aec0779 = 28c5629, 4ae0ca5 = d4ea5ad): - superseded by the local side, except the fork-only pieces below. - kept from 26e0caa: bin/fm-control.sh passes "$HARNESS" to fm_backend_composer_state on exit, which the Kiro reference documents (kiro-cli placeholder read as empty only under the recorded identity); tests/fm-gotmp.test.sh links fm-kiro-lib.sh. - discarded: the fork's extra `cp fm-path-lib.sh` in tests/fm-primary-endpoint.test.sh; local copies the whole bin tree, which already covers it. 056b9a0 (.kiro/skills): kept whole. .kiro/skills is a real tracked symlink to ../.agents/skills (mode 120000); the kiro.md Skill row and the fm-kiro-harness test that proves it resolves were re-applied onto the local versions. c0ad743 (#1, pi nested notebook shell guard): kept whole. That covers the .pi turn-end guard preflight with its single session_shutdown release, bin/fm-test-run.sh routing, docs/arm-pretool-check.md, docs/cd-guard.md, docs/verification/runtime-backends.md, tests/fm-arm-pretool-check.test.sh and the opt-in fm-pi-notebook-live e2e and fixture. None of it existed locally. 8709a31 (#2, process liveness and watcher continuity): kept whole. That covers bin/fm-branch-outcome-lib.sh and its callers (fm-branch-outcome, fm-inactive-reconcile, fm-wake-drain), the Pi watch extension and the turn-end guard's generation-owned restoration and marker rewrite, and the docs and tests. The only textual conflict was its guardGeneration declaration beside local's object-shaped LockOwnership; both are kept, and the merged guard equals fork/main's. The parts #2 had already dropped for upstream kunchenguid#4191 (Herdr process snapshot, shared process-kind vocabulary) stay dropped. Verification: bash -n on all 25 touched .sh files, and shellcheck -x plus bin/fm-lint.sh are clean. These pass with no failures: fm-kiro-harness, fm-primary-endpoint, fm-sessionstart-nudge, fm-omp-harness, fm-afk-return, fm-composer-lib, fm-turnend-guard, fm-watch-checkpoint, fm-arm-pretool-check, fm-backend-herdr, fm-branch-supervision, fm-gotmp, fm-inactive-reconcile, fm-pi-branch-extension, fm-pi-watch-extension, fm-home-summary-refresh and fm-control. fm-pi-notebook-live-e2e skips because it is opt-in and no fixture was supplied.
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.
Summary
Bridge Pi's optional Code/Notebook nested-shell preflight into the existing Firstmate command handler.
The actual evaluated command reaches the unchanged cd and watcher-arm classifiers; no JavaScript parsing, extra daemon, queue, runtime dependency or package installation is introduced.
Ordinary
bash, the turn-end guard and watcher implementation remain unchanged.Bounded protection, not a JavaScript/Deno sandbox: direct runtime subprocess APIs and cwd changes remain outside the nested-tool hook.
This boundary was reproduced, escalated and explicitly accepted for this bridge before implementation.
Behavior
exec_command.cmdand the package's legacycommandfallback use the same checks and denial reasons asbash.Published contract, not guessed tool names
Downloaded with
npm pack @howaboua/pi-codex-conversion --ignore-scriptsinto the isolated task copy.Inspected version 3.0.31, tarball SHA-1
015717bc4b7cb50877e0fb46fb54ba8dd903aadd.Paths are within that published tarball:
exec({code: string}); preflight attached to its execution contextsrc/tools/code-mode/public-tools.ts:39-41,65-93tools.exec_command({cmd,...})src/adapter/code-mode.ts:119-125src/tools/exec/command-tool.ts:15-23,49-57src/tools/code-mode/preflight-protocol.ts:3-14src/code-mode-preflight.ts:22-57,src/tools/code-mode/nested-tool-preflight.ts:23-93src/tools/code-mode/delegate-runtime.ts:277-288src/adapter/activation/runtime-plan.ts:154-187Red before the fix, green afterwards
Before production edits, a runnable probe imported the actual Firstmate guard plus the published broker, delegate, notebook bootstrap, HTTP bridge and Deno Jupyter kernel.
Actual notebook cells called a harmless shell fixture; the watcher stand-in only wrote a sentinel, never armed a real watcher.
Command:
mise exec node@26 -- node .no-mistakes/notebook-guard/red.mjs.Initial output, exit 1:
Afterwards, both extension orders returned:
The committed live regression goes further: real Pi TUI, published Notebook registration/runtime, the actual nested adapter and native shell executor, and the package-pinned Deno.
All four permutations passed: guard first/last ×
azure-anthropic/claude-opus-5/azure-openai-responses/gpt-5.6identities.Only provider responses are local deterministic fixtures, not Azure calls.
Supervision visibility: observed, not assumed
state=busyduring a five-second command,state=idleafter settlement.fm-spawnlaunch.turn_endtouched it; the real watcher emitted and queued its signal.exec_commandappended working and terminal status; the real watcher queuedworker.status.Ran; denial reasons and absent execution sentinels establish what actually happened.cmdvariables reached both existing classifiers; blocked sentinels remained absent and legitimate commands ran. A published completion observer saw four nested calls.exec; direct Deno subprocess/cwd operations were absent from nested completion events.Additional visibility gap: ordinary notebook updates did not refresh the existing native-harness
.progressmarker.Busy/idle still works, but the long-turn age bound is not refreshed by nested activity.
The smallest follow-up is to feed the package's published completion hook into the existing generation-bound progress writer; no daemon or parallel queue is needed.
A long silent cell would still have no intermediate completion to observe.
That worker-observer change is proposed, not silently included here.
Can direct runtime execution also be closed locally?
jupyter-kernel.ts:252-260uses fixedjupyter --kernel --connarguments. Realdeno jupyter --deny-runrejects the flag.shared-runtime.ts:16-20exposes only heap size, agent directory and profile.deno-binary.ts:38-51.session-startup.ts:60-81executes fixed bootstrap then restores state; no extension prelude callback is offered.revoke({name:"run"})changed granted→prompt, blocked bothDeno.Commandandnode:child_process; permission request then returned denied.Deno.chdirstill worked.Checks and counts
Node 26.8.1, ABI 147; Pi 0.85.1; published package 3.0.31.
Initial low-level reproduction used system Deno 2.9.6; the committed real-Pi matrix used package-pinned Deno 2.9.5, verified against its published SHA-256.
All test-runner invocations used
--jobs 1; live cases are serial.okchecksNo existing test was deleted or weakened.
The missing compiler was resolved only in the disposable task copy using unpacked TypeScript tooling; no personal installation/configuration was changed.
Final runner totals: 7 scripts, 0 failures, 1 Windows skip, plus 1 live script, 4 permutations, 0 failures/skips.
Also passed:
bin/fm-lint.sh(ShellCheck 0.11.0, actionlint 1.7.12), explicit lint of the new shell test, Node syntax check,git diff --check, documentation audience check (97 surfaces / 379 links), and test inventory coverage (195 scripts).The coverage check needed
LC_ALL=Cbecause its existing sort/comm sequence disagrees under the host'sen_US.UTF-8; no runner sorting policy was changed.Broad CI/full-suite execution is not claimed.
Windows, signed Pi, non-tmux backends, credentialed Azure transport, full package entry-point activation and production-home installation were not exercised.
The separate native Code Mode host was not launched; its common published preflight/delegate path was inspected, while the live matrix exercised Notebook Mode.
Repeatable commands and current evidence are recorded in
docs/verification/runtime-backends.md, with the transport contract indocs/arm-pretool-check.mdand a pointer fromdocs/cd-guard.md.