feat(pi): adapt Calm mid-turn visibility and built-in tool ownership - #32
Merged
Conversation
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
Selectively adapt Pi Calm from upstream snapshot 6789876 to add newer mid-turn assistant visibility and built-in tool-ownership behavior. Preserve the fork's locally verified Pi 0.84.1 transcript-redraw and replay-window behavior, every PR 24 redraw regression, 0.84.1 version coverage, current config/calm on-off semantics, existing Calm presentation levels, the busy-state extension contract, exact operational acknowledgement/tool-reply behavior, and persisted transcript/export/model data. Mid-turn text must be presentation-only: hide completed toolUse text and length-limited text accompanied by a tool call, while leaving pending streams and final replies visible. On Pi 0.84.1, register no built-in wrappers during extension load; when Calm is already on at session_start or first activates, claim only uncontested built-in tool names from the real live registry, preserve and warn about foreign owners, and keep already-mounted or replayed built-in rows Calm-controllable through the exported ToolExecutionComponent presentation seam plus the existing forced-redraw seam. Require both portable regressions and genuine live Pi 0.84.1 proof for rendered visibility and ownership. Selectively reshape upstream behavior onto the diverged files; do not wholesale-copy the snapshot. Deliberately do not take upstream lines that remove 0.84.1 verification, transcript replay/origin/acknowledgement adaptations, pre-activation redraw guarantees, or replace local level semantics. Do not import Cursor, Muse, stow-tiering, startup-network, remote-worker changes, a Calm level redesign, AGENTS supervision edits, or unrelated cleanup. Keep AGENTS.md unchanged unless its single Calm config line genuinely needs a behavior correction. Ensure bin/fm-lint.sh is clean. In the PR body, state the imported visibility and ownership behavior, how it composes with the redraw seam, and which upstream lines were not taken because they would revert Pi 0.84.1 coverage or local guarantees. Do not merge.
What Changed
assistant-working-notetranscript class: Calm now hides text in completedtoolUseassistant messages and inlength-stopped messages that carry a tool call, while pending streams, final replies, and the exact "Captain, shipshape." operational tool-reply acknowledgement stay visible; the hidden text remains intact in session/transcript data.session_startor first activates, it claims only uncontested built-in names from the live registry viapi.getAllTools(), warns about (and never displaces) foreign owners, and reports later-observed ownership losses. Already-mounted or replayed built-in rows stay Calm-controllable through a newToolExecutionComponent.prototype.renderpresentation adapter that composes with the existing forced-redraw seam, so pre-activation rows follow Calm on the next redraw without touching their execution owner.docs/calm.md,docs/calm-mode-feasibility.md,docs/verification/runtime-backends.md) record the adaptation, and both the portable Calm regression suite and the genuine live Pi 0.84.1 tmux guard grew coverage for rendered mid-turn visibility and foreign-owner execution.Risk Assessment
✅ Low: Presentation-only change that verifiably preserves execution ownership, export/session data, and every intent-required local guarantee, backed by new portable regressions plus recorded genuine live Pi 0.84.1 proof; the only findings are a duplicated string literal and two informational notes.
Testing
Ran the portable Calm regression suite (11/11 ok) and the live Pi 0.84.1 Calm guard (ok), then manually reproduced the live scenario in tmux to capture rendered-TUI evidence: Calm activation warns about the foreign "read" owner, the finalized mid-turn note disappears from the rendered transcript while the final reply stays visible, the note remains in persisted session data, and the foreign tool owner still executes. The change is a terminal TUI, so pane text captures are the reviewer-visible rendering surface; the transient pending-stream-visible state was too brief to capture live but is asserted by the portable suite. All results passed with no product, setup, or flakiness issues.
Evidence: Live Pi 0.84.1 pane: Calm on, foreign built-in owner warning rendered
Evidence: Live Pi 0.84.1 pane: final reply visible, mid-turn note hidden from rendered transcript
RUN_CALM_LIVE_GUARD CALM_LIVE_FINAL_REPLY (pane also shows the foreign-owner warning; MIDTURN_LIVE_NOTE and the read tool row are absent from the rendered TUI)Evidence: Persisted session JSONL still contains the hidden mid-turn note
Evidence: Foreign built-in owner executed under Calm
foreign-read-executedEvidence: Portable Calm regression suite output (11 ok)
Evidence: Live Pi 0.84.1 Calm guard result
ok - Pi 0.84.1 live Calm guard hid persisted mid-turn text after forced redraw and preserved a foreign built-in ownerPipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
.pi/extensions/lib/fm-calm-assistant-layout.ts:63- isProtectedOperationalToolReply hardcodes the literal "Captain, shipshape." at line 63, duplicating the FIRSTMATE_NO_ACTION_ACKNOWLEDGEMENT constant declared at line 72. These must stay in sync for the working-note carve-out to keep matching the exact operational acknowledgement rule; move the constant above the helper and reference it to remove the drift hazard..pi/extensions/fm-calm.ts:170- The built-in-tool-row adapter probes only ToolExecutionComponent.prototype.render existence; the private instance fields it reads (toolName, imageComponents, imageSpacers) are unprobed, so a future Pi renaming them degrades silently to fully visible rows instead of emitting the per-adapter diagnostic docs/calm.md promises. The failure direction is safe (nothing over-hidden, no crash — the typeof toolName guard falls back to the original render), and instance fields cannot be probed at install time, so this is an accepted tradeoff worth noting, not a defect.docs/verification/runtime-backends.md:102- docs/verification/runtime-backends.md honestly records that the broader credentialed live run failed its pre-existing exact-HANDLED model-response assertion (the model replied "Watcher wake handled and acknowledged."). This nondeterministic-model assertion pre-dates this change and is not caused by it, but it is a live-test flakiness source worth a follow-up hardening (e.g. tolerant matching or a deterministic provider for that leg).✅ **Test** - passed
✅ No issues found.
bash tests/fm-calm-pi-extension.test.sh— full portable Calm regression suite (11 ok, exit 0), including the new built-in ownership regression and mid-turn working-note render/hide/restore assertionsFM_PI_LIVE_E2E=1 FM_PI_CALM_LIVE_ONLY=1 bash tests/fm-pi-primary-live-e2e.test.sh— genuine live Pi 0.84.1 tmux guard for rendered mid-turn visibility, forced redraw, session-data preservation, and foreign built-in owner execution (exit 0)Manual tmux reproduction of the live Calm guard on installed Pi 0.84.1 with pane captures saved as evidence: /calm activation warning, final-reply pane without the mid-turn note, session JSONL retaining MIDTURN_LIVE_NOTE, and the foreign read tool's execution marker fileVerifiedpi --version= 0.84.1 and the installed @earendil-works/pi-coding-agent package = 0.84.1, so live proof ran against the exact version the intent requiresVerifiedgit statusclean after testing and no transient lab directories left in the worktree✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.