Skip to content

feat(calm): add flag-gated Claude Code Calm mode - #4565

Merged
kunchenguid merged 10 commits into
mainfrom
fm/fm-claude-calm-mod-r1
Sep 15, 2026
Merged

kunchenguid merged 10 commits into
mainfrom
fm/fm-claude-calm-mod-r1

Conversation

@kunchenguid

@kunchenguid kunchenguid commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner

Intent

Build the Firstmate Claude Code Calm and sailboat mod now and land it through no-mistakes. The mod must activate ONLY when the user is running a Claude Code Firstmate session with the experimental env var CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 turned on; it must NOT force-enable that flag in project settings for all sessions, and it must be a complete no-op when the flag is off (its default). Ship two things: (1) the flag-gated Calm and sailboat mod itself, and (2) an update to docs/calm-mode-feasibility.md recording the spike evidence. Reuse the Pi sprite math and the canonical operational-input parser rather than reinventing them.

Context: this follows the scout fm-claude-mods-calm-sailboat-s1, which proved on Claude Code 2.1.272 that the early-access "Claude Mods" (function hooks) API can host the sailboat working animation and most of Calm mode. Its report is at data/fm-claude-mods-calm-sailboat-s1/report.md and its proven throwaway spike (a working plugin: register.tsx plus the plugin/hooks/command files) is preserved at data/fm-claude-mods-calm-sailboat-s1/spike-reference/. Calm mode today exists only on Pi: the sailboat working animation lives in .pi/extensions/lib/fm-calm-working-ship.ts, the transcript-hiding presentation policy in .pi/extensions/fm-calm.ts and .pi/extensions/lib/fm-calm-visibility.ts, and operational-input construction and parsing in bin/fm-operational-input.sh; docs/calm.md and docs/calm-mode-feasibility.md own the current user-facing contract and the version-scoped feasibility evidence. The Claude Code mod should share the same per-home config/calm preference so one /calm choice works on either harness. The mod covers both the sailboat working animation (replacing the stock working row) and the Calm transcript hiding to the extent the report found feasible; the doc update records the feasible parts and the three bounded gaps honestly.

The substance of that scout report, which the ask refers to: on Claude Code 2.1.272 a Claude Mod is a plugin whose behavior lives in one hooks module exporting register(on, options); it hooks engine events such as session.start, command.run, turn.step, and ui.render; hooks modules load only when CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 or the default-off rollout flag turns them on, and only after workspace trust. The spike proved: a ui.render hook on the Spinner component replaces the stock working row with a two-row Raster sailboat animated through $.clock.every and $.ui.blit at the Pi cadence, width-aware on resize, appearing and disappearing with the turn; ui.render hooks on ToolUse, ToolResult, ToolGroup, UserMessage, and AssistantMessage hide tool rows, tool groups, mid-turn narration (text of a step that stopped for tool use), and exact FIRSTMATE_OP operational user rows at zero height with no gap, restore them on toggle-off, re-hide them retroactively on toggle-on through $.ui.invalidate("ui.render"), persist the toggle in $FM_HOME/config/calm, survive exit and claude --continue, and leave session storage and model context untouched; and a trusted project auto-loads the mod from its .claude/skills entry. The three bounded gaps the report found: the surface is early access and default-off with an API that may change between releases without notice; on the main-screen (non-fullscreen) layout a toggle redraws by clearing and reprinting, so the terminal's own scrollback keeps the previous rendering above it; and the Raster paints RGB through a quantized palette, so the boat renders as 256-color escapes rather than Pi's 16-color ANSI codes.

Later, the captain picked a working-ship palette on the design board and said "ship it": the "Claude native" palette, applied to the Claude mod's Raster path only, as dual dark/light truecolor RGB, water #93a5ff and boat #d77757 on a dark theme, water #5769f7 and boat #d77757 on a light theme, with two color classes only (the water one single color with no separate crest color, and the whole boat, sail, mast, and hull, one boat color with no separate hull-interior color), choosing the set by detecting Claude Code's active theme, dark versus light; the Pi extension stays on its standard ANSI colors, unchanged; the tests and docs that pin the working-ship palette follow the new values; and geometry, motion, cadence, and the flag gate stay unchanged, palette and presentation only.

What Changed

  • Add an exact-opt-in Claude Code mod that shares the Calm preference, hides operational transcript rows, and replaces the working indicator with a theme-aware animated sailboat.
  • Extract the sailboat geometry into a shared sprite core while preserving Pi’s existing ANSI presentation.
  • Add mod, plugin, live E2E, and Pi regression coverage, plus documentation of configuration, compatibility evidence, and bounded API gaps.

Risk Assessment

✅ Low: The opt-in mod is well-bounded, preserves Pi behavior through a shared sprite core, and includes focused coverage for activation, lifecycle, rendering, persistence, and parser parity.

Testing

Portable behavior checks, Claude Code 2.1.273 strict plugin validation, and all targeted engine-hosted plugin cases passed, including the light fallback palette, activation guard, Calm behavior, collision handling, and animation. A real TUI run and visual capture were not possible because the live gate was disabled and no scoped ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN was available; using the existing profile would write prohibited session/trust state outside the worktree.

  • Live validation: ⚠️ inconclusive - 1 of 7 scenarios driven live against the product
Scenario Result Live Evidence
A user validates the mod from both its physical folder and project auto-load path, and Claude Code accepts the declared hooks and capabilities ✅ pass live bash tests/fm-calm-claude-mod-plugin.test.sh; artifact “Claude Code strict validation and plugin engine transcript”
With the experimental flag absent or not exactly 1, the loaded mod remains completely inert ⏸️ untested no A real TUI requires an isolated Claude configuration with a scoped CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY. Neither credential was available, and using the existing profile would write session/tr…
With the flag exactly 1, /calm toggles transcript hiding and persists the shared per-home preference ⏸️ untested no Provide FM_CLAUDE_CALM_LIVE_E2E=1 together with an isolated Claude configuration and scoped CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY to exercise this in the real TUI.
Calm hides canonical operational inputs while preserving ordinary prompts and protocol near misses ⏸️ untested no No scoped Claude credential was available for a real model turn in an isolated TUI configuration.
The sailboat replaces the working row, animates at Pi cadence, resizes safely, and uses dark colors only for dark themes with the light palette as every fallback ⏸️ untested no Visual TUI evidence requires the credentialed live test. Supply a scoped Claude credential and enable FM_CLAUDE_CALM_LIVE_E2E; no screenshot was captured because that live surface could not be launche…
Genuine final replies remain visible across text collisions, transcript restoration, and same-process session replacement ⏸️ untested no These cases ran in Claude's plugin-test host with mocked session and rendering surfaces; an isolated authenticated real TUI was unavailable.
A user runs the real Claude Code TUI with the flag off and on, observes stock versus Calm rendering, toggles /calm, and resumes a hidden transcript with --continue ⏸️ untested no Set FM_CLAUDE_CALM_LIVE_E2E=1 and provide CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY for an isolated CLAUDE_CONFIG_DIR. The existing user profile cannot be used because it would write trust and sess…
Evidence: Portable Calm mod behavior transcript

Source: Portable Calm mod behavior transcript

ok - the Calm mod is one hooks module, linked into the project's auto-load path, with no command, skill, agent, or classic hook path that bypasses its exact opt-in
ok - the Pi working ship renders byte-for-byte the shared sprite core's frame painted in standard ANSI, at every width, cadence step, freeze, clamp, and reset
ok - the Raster packing lays the shared frame out row-major in Claude Code's dark or light theme palette, using light as the both-readable fallback, with plain padding, default backgrounds, BMP glyphs, clipping, and a standard base64 encoding
ok - the Calm policy resolves the shared preference exactly as Pi does, reads on, max, and off as Pi does, and classifies working notes by stop reason, tool use, and restored transcript shape
ok - the mod's operational-input classifier agrees with bin/fm-operational-input.sh on all 77 corpus cases: every current kind the owner encodes, every legacy shape, and every near miss
Evidence: Claude Code strict validation and plugin engine transcript

Source: Claude Code strict validation and plugin engine transcript

ok - Claude Code 2.1.273 (Claude Code) validates the Calm mod strictly at its folder and its auto-load path, hooking exactly the working row, tool, user, and assistant drawings and /calm
ok - Claude Code 2.1.273 (Claude Code) runs the Calm mod's plugin test suites clean: persisted toggle, hidden rows, working notes, and the clock-driven working ship
Evidence: Detailed Claude plugin test cases

Source: Detailed Claude plugin test cases


tests/calm.test.ts:
(pass) activation > is fully inert when the function-hooks opt-in is absent [38.26ms]
(pass) activation > is fully inert when the function-hooks opt-in is not exactly one [18.76ms]
(pass) activation > registers /calm at session start and stays a pass-through while off [19.90ms]
(pass) activation > reads a persisted on before session start, so restored rows never draw with a stale off [25.44ms]
(pass) activation > reads the legacy max value as on [59.19ms]
(pass) activation > reads an unrecognized value as off [36.20ms]
(pass) /calm > toggles on: persists on, toasts, redraws every hooked drawing, and leaves no output row [22.37ms]
(pass) /calm > toggles off: persists off and restores the engine's drawings [18.64ms]
(pass) /calm > keeps the current choice when the preference cannot be written [13.84ms]
(pass) /calm > writes under FM_CONFIG_OVERRIDE when that override names the config directory [13.74ms]
(pass) /calm > falls back to FM_ROOT_OVERRIDE, then the tracked code root above the plugin, when FM_HOME is unset [13.41ms]
(pass) /calm > derives the home from the plugin folder when nothing names it [117.47ms]
(pass) operational user rows > hides every canonically classified operational input while on [27.19ms]
(pass) operational user rows > keeps every near miss and genuine prompt visible while on [21.29ms]
(pass) operational user rows > leaves every user row to the engine while off [17.84ms]
(pass) mid-turn working notes > hides the text blocks of a step that stopped to call tools, and forwards the stream untouched [14.89ms]
(pass) mid-turn working notes > keeps a final reply visible when its text matches an earlier working note [14.11ms]
(pass) mid-turn working notes > keeps an earlier final reply visible when a later working note reuses its text [13.68ms]
(pass) mid-turn working notes > resets final-reply classifications when a new session starts [14.33ms]
(pass) mid-turn working notes > treats a response cut off while calling tools as a working note, but not a plain cut-off [57.67ms]
(pass) mid-turn working notes > ignores subagent steps, which never draw in the main transcript [21.30ms]
(pass) mid-turn working notes > records notes while off and hides them retroactively when toggled on [13.97ms]
(pass) mid-turn working notes > seeds notes from a restored transcript without hiding a colliding final reply [12.06ms]

tests/working-ship.test.ts:
(pass) the working ship > replaces the spinner with a two-row raster sized to the row inside the transcript margin [39.41ms]
(pass) the working ship > animates the water every tick and moves the hull one column every fourth, through blits of the mounted size [20.83ms]
(pass) the working ship > stops blitting a site the surface denies and resumes when the spinner is drawn again [19.78ms]
(pass) the working ship > never blits while off, and drops every site when toggled off [60.56ms]
(pass) the working ship > sizes to the raster limits: an unmeasured viewport reads as 80 columns, a wide one clips at 512, a narrow one falls back to one row [37.42ms]
(pass) the working ship > reflows to a new width on the redraw a resize causes, and blits at that width from then on [46.87ms]
(pass) the working ship > leaves a non-terminal surface to the engine [16.11ms]
(pass) the working ship > paints the light theme family's spinner blue for the water and the same Claude orange boat [13.08ms]
(pass) the working ship > paints the dark family for the theme value "dark-ansi" [12.54ms]
(pass) the working ship > paints the dark family for the theme value "dark-daltonized" [12.23ms]
(pass) the working ship > paints the light family for the theme value "light" [111.79ms]
(pass) the working ship > paints the light family for the theme value "light-daltonized" [24.05ms]
(pass) the working ship > paints the light family for the theme value "light-ansi" [21.70ms]
(pass) the working ship > paints the light family for the theme value "auto" [15.42ms]
(pass) the working ship > paints the light family for the theme value "custom:rose-pine" [11.81ms]
(pass) the working ship > re-paints in the new family after the theme changes, through the next drawing and every later blit [15.13ms]
(pass) the working ship > leaves a theme change to the engine while Calm is off, and paints the new family once Calm turns on [13.95ms]

 40 pass
 0 fail
Ran 40 tests across 2 files. [0.79s]
- Outcome: ⚠️ 1 warning across 1 run (1m1s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • 🚨 .claude/mods/firstmate-calm/lib/fm-calm-ship-raster.ts:58 - The required palette behavior says to choose colors by detecting Claude Code's active dark/light theme, but this newly introduced fallback classifies every auto, custom, missing, or non-string theme as dark. For example, when theme=auto resolves to a light appearance, the mod silently paints dark water #93a5ff instead of light water #5769f7; an automatic appearance change also emits no config.set for this code to observe. No intent requirement authorizes the fallback, so remove it and use an engine-supported resolved active-theme signal, or ask the user to explicitly authorize the narrower stored-setting behavior.

🔧 Fix applied.
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (1 of 7 scenarios were driven live against the product); untested: With the experimental flag absent or not exactly 1, the loaded mod remains completely inert, With the flag exactly 1, /calm toggles transcript hiding and persists the shared per-home preference, Calm hides canonical operational inputs while preserving ordinary prompts and protocol near misses, The sailboat replaces the working row, animates at Pi cadence, resizes safely, and uses dark colors only for dark themes with the light palette as every fallback, Genuine final replies remain visible across text collisions, transcript restoration, and same-process session replacement, A user runs the real Claude Code TUI with the flag off and on, observes stock versus Calm rendering, toggles /calm, and resumes a hidden transcript with --continue
  • Live validation: ⚠️ inconclusive - 1 of 7 scenarios driven live against the product
Scenario Result Live Evidence
A user validates the mod from both its physical folder and project auto-load path, and Claude Code accepts the declared hooks and capabilities ✅ pass live bash tests/fm-calm-claude-mod-plugin.test.sh; artifact “Claude Code strict validation and plugin engine transcript”
With the experimental flag absent or not exactly 1, the loaded mod remains completely inert ⏸️ untested no A real TUI requires an isolated Claude configuration with a scoped CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY. Neither credential was available, and using the existing profile would write session/tr…
With the flag exactly 1, /calm toggles transcript hiding and persists the shared per-home preference ⏸️ untested no Provide FM_CLAUDE_CALM_LIVE_E2E=1 together with an isolated Claude configuration and scoped CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY to exercise this in the real TUI.
Calm hides canonical operational inputs while preserving ordinary prompts and protocol near misses ⏸️ untested no No scoped Claude credential was available for a real model turn in an isolated TUI configuration.
The sailboat replaces the working row, animates at Pi cadence, resizes safely, and uses dark colors only for dark themes with the light palette as every fallback ⏸️ untested no Visual TUI evidence requires the credentialed live test. Supply a scoped Claude credential and enable FM_CLAUDE_CALM_LIVE_E2E; no screenshot was captured because that live surface could not be launche…
Genuine final replies remain visible across text collisions, transcript restoration, and same-process session replacement ⏸️ untested no These cases ran in Claude's plugin-test host with mocked session and rendering surfaces; an isolated authenticated real TUI was unavailable.
A user runs the real Claude Code TUI with the flag off and on, observes stock versus Calm rendering, toggles /calm, and resumes a hidden transcript with --continue ⏸️ untested no Set FM_CLAUDE_CALM_LIVE_E2E=1 and provide CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY for an isolated CLAUDE_CONFIG_DIR. The existing user profile cannot be used because it would write trust and sess…
  • bash tests/fm-calm-claude-mod.test.sh
  • bash tests/fm-calm-claude-mod-plugin.test.sh
  • CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude plugin test .claude/mods/firstmate-calm
  • Checked the live gate, scoped credential environment, Claude installation, tmux availability, and final worktree cleanliness.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Live Claude Code TUI validation: not run in this pipeline round

The credentialed live Claude Code TUI end-to-end guard, FM_CLAUDE_CALM_LIVE_E2E=1 tests/fm-calm-claude-mod-live-e2e.test.sh, did NOT run in this pipeline round, and nothing in this PR should be read as a fresh live behavioral pass of the head under review.
It could not run because interactive Claude Code requires session persistence and writes session and trust data under ~/.claude, which the pipeline's workspace boundary forbids, and no scoped CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY was available for an isolated CLAUDE_CONFIG_DIR.
The coverage this PR carries is: strict plugin validation by the installed Claude Code 2.1.273 (the mod is accepted from the project auto-load path with only its intended hooks, its exact environment reads, and no environment writes); the engine-hosted plugin-kit suites under claude plugin test, including the activation guard, Calm hide and toggle behavior, final-reply collision handling, the animation, and the light fallback palette; the portable Node checks; the 77-case operational-input parity corpus against bin/fm-operational-input.sh; the earlier accepted live behavior validation of the mod in a real Claude Code TUI, taken on a pre-fix head before this round's palette change; and the captain's visual approval of the option-B palette on the design board.
The palette change in this round is color-only, with geometry, motion, cadence, and the activation gate unchanged.
Follow-up task fm-calm-mod-live-e2e-verify-r2 will run the credentialed live guard against this head from an isolated Claude configuration when one is available.

…ction-hooks flag

Add .claude/mods/firstmate-calm, a Claude Code mod (function-hooks plugin) that
brings Calm to Claude Code: the sailboat replaces the stock working row through a
Raster repainted on the sprite's own tick, and tool, tool-group, mid-turn narration,
and canonically classified operational user rows draw at zero height. /calm is
registered by the hooks module itself and toggles the same per-home config/calm
preference the Pi extension uses, so one choice applies on either harness; rows
redraw retroactively on toggle and stay hidden across claude --continue.

The mod loads only while Claude Code's default-off CLAUDE_CODE_ENABLE_FUNCTION_HOOKS
flag is on. Nothing sets that flag in any settings file, and the plugin carries no
command file, skill, agent, or classic hook, so it is a complete no-op while the
flag is off. The trusted project auto-loads it through an .agents/skills symlink,
the only path Claude Code scans for project plugins.

Extract the working-ship geometry, bounce track, cadences, and freeze/resume state
into a harness-neutral sprite core inside the mod (Claude Code refuses hooks-module
imports from outside the plugin folder) and have the Pi widget paint that core's
frames as standard ANSI, byte for byte as before; the Pi suite stays green. Classify
operational rows through a port of bin/fm-operational-input.sh's classify command
guarded by a corpus parity test against the shell owner.

Tests: portable Node checks (plugin shape, sprite parity with Pi's rendering,
Raster packing, policy, classifier parity), the mod's own claude plugin test suites
behind a default-on wrapper, and an opt-in live TUI guard proving the flag-off no-op,
the moving boat, hidden rows, the persisted toggle, and resume on Claude Code 2.1.272.

Docs: record the version-scoped Claude Code evidence and the three bounded gaps in
docs/calm-mode-feasibility.md, describe the Claude Code contract in docs/calm.md,
and make the shared preference, layout, and contributor notes harness-neutral.
…colors

The captain picked the "Claude native" palette for the Claude Code mod's Raster:
every water cell takes the spinner blue of the active theme family (#93a5ff dark,
#5769f7 light) and the whole boat takes the Claude orange of the stock spinner
(#d77757), one water color and one boat color. The family follows the `theme`
setting's prefix, read at load through $.config.list and re-read on a
config.set of that row, with `auto` and custom themes falling back to the dark
set. The Pi extension keeps its standard ANSI blue and yellow, byte for byte.

Rename the shared sprite's color classes from hue names to `water` and `boat`,
since each harness now maps them to its own colors; geometry, motion, cadence,
and the activation gate are untouched.

Tests cover both palettes' packing and the family rule under Node, and the
plugin kit drives every theme value, a theme change mid-session, the Calm-off
pass-through, and inertness of the menu read while the flag is off. The docs
describe the Claude Code colors and record the guard passing on 2.1.273.
@kunchenguid
kunchenguid force-pushed the fm/fm-claude-calm-mod-r1 branch from 05531c3 to e80cd0e Compare September 15, 2026 22:29
@kunchenguid kunchenguid changed the title feat(calm): add flag-gated Claude Code Calm mod feat(calm): add flag-gated Claude Code Calm mode Sep 15, 2026
@kunchenguid
kunchenguid merged commit bdcacb9 into main Sep 15, 2026
16 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-claude-calm-mod-r1 branch September 15, 2026 23:10
mdc2122 added a commit to mdc2122/firstmate that referenced this pull request Sep 16, 2026
…ktree (#3)

* fix(bin): refuse teardown when a task's endpoint close fails (kunchenguid#4510)

* fix(teardown): refuse a cleanup whose endpoint close failed

bin/fm-teardown.sh discarded both the exit status and the stderr of every
fm_backend_kill call, so a close that genuinely failed was indistinguishable
from one that succeeded. Teardown continued past it, deleted the task's durable
records, returned its worktree, and reported the cleanup as completed. The
deleted metadata is the only record of which endpoint belongs to the task, so
such a close did not merely leave a stray session behind, it stranded one:
nothing was left on disk naming it.

The adapters could not carry that signal either. Driven against the real code,
every backend arm returned 0 for a genuine failure exactly as it did for an
already-exited endpoint, so there was nothing for the four call sites to
propagate even once they stopped swallowing it.

The tmux arm now resolves a close that did not succeed against the window's
exact recorded identity, since kill-window fails the same way for a window that
is gone and one that is still there. The Orca arm reports a close its missing
CLI never attempted. Both stay silent for an endpoint that is already
legitimately gone, and the remaining arms are unchanged: their close-command
timing cannot be established without the real Zellij, Orca, and cmux binaries,
and a gate that refused ordinary cleanup of an already-exited session would be
worse than the defect. docs/verification/runtime-backends.md records what each
backend can prove.

A reported close failure now reaches teardown's existing retain-and-stop
refusal before the records naming the endpoint are removed, matching where the
Herdr confirmed-gone gates already sit for the same hazard, and the retained
records let a rerun finish once the close works.

* no-mistakes(review): refuse unreadable tmux close re-read; honor --force override

* no-mistakes(review): drop unreachable Orca force arm; prove CLI-absent close

* no-mistakes(document): document endpoint-close refusal in its backend and retirement owners

* no-mistakes(ci): The two reported failing checks are NOT code defects. Both "CI" (run 34935529184) and "Require no-mistakes" (run 34935529206) returned conclusion=action_required with zero jobs and 0s duration (run_started_at == updated_at), which is this repo's workflow-approval gate holding the run before any job starts. No job executed, so nothing in the diff could have caused them; two unrelated branches (fm/captain-hold-json-nonref, fm/presenter-core-l1) show the identical shape in the same time window. Verified the change locally instead: bin/fm-lint.sh clean, bin/fm-test-run.sh --check-coverage ok, and all suites the diff touches pass (fm-teardown-endpoint-safety 25/25 including the five new endpoint-close cases, fm-backend-orca, fm-backend, fm-backend-tmux-smoke, fm-backend-cmux, fm-backend-zellij, fm-backend-herdr). Separately, I found and fixed a genuinely flaky test that the phase rules require me to make deterministic: tests/fm-tmux-agent-liveness.test.sh intermittently failed "an idle shell pane must classify dead" (verdict ambiguous, comms=[bash sleep]). It is selected by --changed for this diff, so it would run against this PR once CI is approved. Root cause, established by instrumenting the pane's process group: the idle window was created by `new-session` with no command, so it inherited tmux's default-shell, i.e. whoever runs the suite. ps on the pane tty showed `-zsh` -> `bash` -> `sleep`, all sharing pgid==tpgid, i.e. the host operator's shell configuration spawning a periodic helper directly into the pane's FOREGROUND process group, which is the one surface the classifier reads. `sleep` classifies as `other`, so fg_other=1 and the verdict became `ambiguous` instead of `dead` whenever that helper overlapped the 10s poll window. Every other window in the suite runs an explicit command via new_window; the idle case was the only one whose process group the host defined. Fix (smallest root-cause, test-only, 1 line + explanatory comment): create the idle window with an explicit bare `/bin/sh` (`-- /bin/sh`), the same shell the neighbouring background case already execs. Its foreground group is now exactly one process (verified: `/bin/sh` alone), so no host configuration can inject into it. This flake is pre-existing and NOT caused by this PR: an interleaved A/B showed base commit da5e658 failing the identical case (2/6 runs) alongside head (3/7 runs), and the diff only extracted the tmux inventory read into a helper with identical semantics while never touching fm_backend_tmux_foreground_comms. After the fix: 8/8 consecutive passes, with lint and the coverage guard still clean. Change left uncommitted in the working tree

* feat(calm): add flag-gated Claude Code Calm mode (kunchenguid#4565)

* feat(calm): ship the Claude Code Calm and sailboat mod behind the function-hooks flag

Add .claude/mods/firstmate-calm, a Claude Code mod (function-hooks plugin) that
brings Calm to Claude Code: the sailboat replaces the stock working row through a
Raster repainted on the sprite's own tick, and tool, tool-group, mid-turn narration,
and canonically classified operational user rows draw at zero height. /calm is
registered by the hooks module itself and toggles the same per-home config/calm
preference the Pi extension uses, so one choice applies on either harness; rows
redraw retroactively on toggle and stay hidden across claude --continue.

The mod loads only while Claude Code's default-off CLAUDE_CODE_ENABLE_FUNCTION_HOOKS
flag is on. Nothing sets that flag in any settings file, and the plugin carries no
command file, skill, agent, or classic hook, so it is a complete no-op while the
flag is off. The trusted project auto-loads it through an .agents/skills symlink,
the only path Claude Code scans for project plugins.

Extract the working-ship geometry, bounce track, cadences, and freeze/resume state
into a harness-neutral sprite core inside the mod (Claude Code refuses hooks-module
imports from outside the plugin folder) and have the Pi widget paint that core's
frames as standard ANSI, byte for byte as before; the Pi suite stays green. Classify
operational rows through a port of bin/fm-operational-input.sh's classify command
guarded by a corpus parity test against the shell owner.

Tests: portable Node checks (plugin shape, sprite parity with Pi's rendering,
Raster packing, policy, classifier parity), the mod's own claude plugin test suites
behind a default-on wrapper, and an opt-in live TUI guard proving the flag-off no-op,
the moving boat, hidden rows, the persisted toggle, and resume on Claude Code 2.1.272.

Docs: record the version-scoped Claude Code evidence and the three bounded gaps in
docs/calm-mode-feasibility.md, describe the Claude Code contract in docs/calm.md,
and make the shared preference, layout, and contributor notes harness-neutral.

* no-mistakes(review): Preserve colliding final replies and strengthen parser parity

* no-mistakes(review): Preserve final replies and strengthen canonical parity checks

* no-mistakes(review): Require exact function-hooks opt-in before Calm activation

* no-mistakes(review): Clarify Calm module loading and activation boundaries

* no-mistakes(review): Reset Calm presentation state across session starts

* no-mistakes(document): Refresh Calm session lifecycle documentation

* feat(calm): paint the Claude Code working ship in Claude's own theme colors

The captain picked the "Claude native" palette for the Claude Code mod's Raster:
every water cell takes the spinner blue of the active theme family (#93a5ff dark,
#5769f7 light) and the whole boat takes the Claude orange of the stock spinner
(#d77757), one water color and one boat color. The family follows the `theme`
setting's prefix, read at load through $.config.list and re-read on a
config.set of that row, with `auto` and custom themes falling back to the dark
set. The Pi extension keeps its standard ANSI blue and yellow, byte for byte.

Rename the shared sprite's color classes from hue names to `water` and `boat`,
since each harness now maps them to its own colors; geometry, motion, cadence,
and the activation gate are untouched.

Tests cover both palettes' packing and the family rule under Node, and the
plugin kit drives every theme value, a theme change mid-session, the Calm-off
pass-through, and inertness of the menu read while the flag is off. The docs
describe the Claude Code colors and record the guard passing on 2.1.273.

* no-mistakes(review): Use light palette for unresolved Claude themes

* no-mistakes(document): Refresh Claude Calm verification evidence

* fix(orca): validate uuid::path worktree identity against recorded worktree

* no-mistakes(document): Document Orca composite identity validation

* no-mistakes(review): Allow colons in valid Orca worktree paths

* test(orca): allow :: in composite worktree path half

The review fix removed the broad colon rejection so valid Unix paths
containing ':' or '::' are accepted when they match the recorded
worktree. Update the refusal case to a path half that does not match
worktree=, which is the malformed shape the guard must still reject.

* no-mistakes(test): Updated stale Orca fixture; targeted teardown test passes

---------

Co-authored-by: Amin Roudaki <[email protected]>
Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: mdc2122 <[email protected]>
mdc2122 added a commit to mdc2122/firstmate that referenced this pull request Sep 16, 2026
…ktree (#3)

* fix(bin): refuse teardown when a task's endpoint close fails (kunchenguid#4510)

* fix(teardown): refuse a cleanup whose endpoint close failed

bin/fm-teardown.sh discarded both the exit status and the stderr of every
fm_backend_kill call, so a close that genuinely failed was indistinguishable
from one that succeeded. Teardown continued past it, deleted the task's durable
records, returned its worktree, and reported the cleanup as completed. The
deleted metadata is the only record of which endpoint belongs to the task, so
such a close did not merely leave a stray session behind, it stranded one:
nothing was left on disk naming it.

The adapters could not carry that signal either. Driven against the real code,
every backend arm returned 0 for a genuine failure exactly as it did for an
already-exited endpoint, so there was nothing for the four call sites to
propagate even once they stopped swallowing it.

The tmux arm now resolves a close that did not succeed against the window's
exact recorded identity, since kill-window fails the same way for a window that
is gone and one that is still there. The Orca arm reports a close its missing
CLI never attempted. Both stay silent for an endpoint that is already
legitimately gone, and the remaining arms are unchanged: their close-command
timing cannot be established without the real Zellij, Orca, and cmux binaries,
and a gate that refused ordinary cleanup of an already-exited session would be
worse than the defect. docs/verification/runtime-backends.md records what each
backend can prove.

A reported close failure now reaches teardown's existing retain-and-stop
refusal before the records naming the endpoint are removed, matching where the
Herdr confirmed-gone gates already sit for the same hazard, and the retained
records let a rerun finish once the close works.

* no-mistakes(review): refuse unreadable tmux close re-read; honor --force override

* no-mistakes(review): drop unreachable Orca force arm; prove CLI-absent close

* no-mistakes(document): document endpoint-close refusal in its backend and retirement owners

* no-mistakes(ci): The two reported failing checks are NOT code defects. Both "CI" (run 34935529184) and "Require no-mistakes" (run 34935529206) returned conclusion=action_required with zero jobs and 0s duration (run_started_at == updated_at), which is this repo's workflow-approval gate holding the run before any job starts. No job executed, so nothing in the diff could have caused them; two unrelated branches (fm/captain-hold-json-nonref, fm/presenter-core-l1) show the identical shape in the same time window. Verified the change locally instead: bin/fm-lint.sh clean, bin/fm-test-run.sh --check-coverage ok, and all suites the diff touches pass (fm-teardown-endpoint-safety 25/25 including the five new endpoint-close cases, fm-backend-orca, fm-backend, fm-backend-tmux-smoke, fm-backend-cmux, fm-backend-zellij, fm-backend-herdr). Separately, I found and fixed a genuinely flaky test that the phase rules require me to make deterministic: tests/fm-tmux-agent-liveness.test.sh intermittently failed "an idle shell pane must classify dead" (verdict ambiguous, comms=[bash sleep]). It is selected by --changed for this diff, so it would run against this PR once CI is approved. Root cause, established by instrumenting the pane's process group: the idle window was created by `new-session` with no command, so it inherited tmux's default-shell, i.e. whoever runs the suite. ps on the pane tty showed `-zsh` -> `bash` -> `sleep`, all sharing pgid==tpgid, i.e. the host operator's shell configuration spawning a periodic helper directly into the pane's FOREGROUND process group, which is the one surface the classifier reads. `sleep` classifies as `other`, so fg_other=1 and the verdict became `ambiguous` instead of `dead` whenever that helper overlapped the 10s poll window. Every other window in the suite runs an explicit command via new_window; the idle case was the only one whose process group the host defined. Fix (smallest root-cause, test-only, 1 line + explanatory comment): create the idle window with an explicit bare `/bin/sh` (`-- /bin/sh`), the same shell the neighbouring background case already execs. Its foreground group is now exactly one process (verified: `/bin/sh` alone), so no host configuration can inject into it. This flake is pre-existing and NOT caused by this PR: an interleaved A/B showed base commit da5e658 failing the identical case (2/6 runs) alongside head (3/7 runs), and the diff only extracted the tmux inventory read into a helper with identical semantics while never touching fm_backend_tmux_foreground_comms. After the fix: 8/8 consecutive passes, with lint and the coverage guard still clean. Change left uncommitted in the working tree

* feat(calm): add flag-gated Claude Code Calm mode (kunchenguid#4565)

* feat(calm): ship the Claude Code Calm and sailboat mod behind the function-hooks flag

Add .claude/mods/firstmate-calm, a Claude Code mod (function-hooks plugin) that
brings Calm to Claude Code: the sailboat replaces the stock working row through a
Raster repainted on the sprite's own tick, and tool, tool-group, mid-turn narration,
and canonically classified operational user rows draw at zero height. /calm is
registered by the hooks module itself and toggles the same per-home config/calm
preference the Pi extension uses, so one choice applies on either harness; rows
redraw retroactively on toggle and stay hidden across claude --continue.

The mod loads only while Claude Code's default-off CLAUDE_CODE_ENABLE_FUNCTION_HOOKS
flag is on. Nothing sets that flag in any settings file, and the plugin carries no
command file, skill, agent, or classic hook, so it is a complete no-op while the
flag is off. The trusted project auto-loads it through an .agents/skills symlink,
the only path Claude Code scans for project plugins.

Extract the working-ship geometry, bounce track, cadences, and freeze/resume state
into a harness-neutral sprite core inside the mod (Claude Code refuses hooks-module
imports from outside the plugin folder) and have the Pi widget paint that core's
frames as standard ANSI, byte for byte as before; the Pi suite stays green. Classify
operational rows through a port of bin/fm-operational-input.sh's classify command
guarded by a corpus parity test against the shell owner.

Tests: portable Node checks (plugin shape, sprite parity with Pi's rendering,
Raster packing, policy, classifier parity), the mod's own claude plugin test suites
behind a default-on wrapper, and an opt-in live TUI guard proving the flag-off no-op,
the moving boat, hidden rows, the persisted toggle, and resume on Claude Code 2.1.272.

Docs: record the version-scoped Claude Code evidence and the three bounded gaps in
docs/calm-mode-feasibility.md, describe the Claude Code contract in docs/calm.md,
and make the shared preference, layout, and contributor notes harness-neutral.

* no-mistakes(review): Preserve colliding final replies and strengthen parser parity

* no-mistakes(review): Preserve final replies and strengthen canonical parity checks

* no-mistakes(review): Require exact function-hooks opt-in before Calm activation

* no-mistakes(review): Clarify Calm module loading and activation boundaries

* no-mistakes(review): Reset Calm presentation state across session starts

* no-mistakes(document): Refresh Calm session lifecycle documentation

* feat(calm): paint the Claude Code working ship in Claude's own theme colors

The captain picked the "Claude native" palette for the Claude Code mod's Raster:
every water cell takes the spinner blue of the active theme family (#93a5ff dark,
(#d77757), one water color and one boat color. The family follows the `theme`
setting's prefix, read at load through $.config.list and re-read on a
config.set of that row, with `auto` and custom themes falling back to the dark
set. The Pi extension keeps its standard ANSI blue and yellow, byte for byte.

Rename the shared sprite's color classes from hue names to `water` and `boat`,
since each harness now maps them to its own colors; geometry, motion, cadence,
and the activation gate are untouched.

Tests cover both palettes' packing and the family rule under Node, and the
plugin kit drives every theme value, a theme change mid-session, the Calm-off
pass-through, and inertness of the menu read while the flag is off. The docs
describe the Claude Code colors and record the guard passing on 2.1.273.

* no-mistakes(review): Use light palette for unresolved Claude themes

* no-mistakes(document): Refresh Claude Calm verification evidence

* fix(orca): validate uuid::path worktree identity against recorded worktree

* no-mistakes(document): Document Orca composite identity validation

* no-mistakes(review): Allow colons in valid Orca worktree paths

* test(orca): allow :: in composite worktree path half

The review fix removed the broad colon rejection so valid Unix paths
containing ':' or '::' are accepted when they match the recorded
worktree. Update the refusal case to a path half that does not match
worktree=, which is the malformed shape the guard must still reject.

* no-mistakes(test): Updated stale Orca fixture; targeted teardown test passes

---------

Co-authored-by: Amin Roudaki <[email protected]>
Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: mdc2122 <[email protected]>
mdc2122 added a commit to mdc2122/firstmate that referenced this pull request Sep 17, 2026
…ktree (#3)

* fix(bin): refuse teardown when a task's endpoint close fails (kunchenguid#4510)

* fix(teardown): refuse a cleanup whose endpoint close failed

bin/fm-teardown.sh discarded both the exit status and the stderr of every
fm_backend_kill call, so a close that genuinely failed was indistinguishable
from one that succeeded. Teardown continued past it, deleted the task's durable
records, returned its worktree, and reported the cleanup as completed. The
deleted metadata is the only record of which endpoint belongs to the task, so
such a close did not merely leave a stray session behind, it stranded one:
nothing was left on disk naming it.

The adapters could not carry that signal either. Driven against the real code,
every backend arm returned 0 for a genuine failure exactly as it did for an
already-exited endpoint, so there was nothing for the four call sites to
propagate even once they stopped swallowing it.

The tmux arm now resolves a close that did not succeed against the window's
exact recorded identity, since kill-window fails the same way for a window that
is gone and one that is still there. The Orca arm reports a close its missing
CLI never attempted. Both stay silent for an endpoint that is already
legitimately gone, and the remaining arms are unchanged: their close-command
timing cannot be established without the real Zellij, Orca, and cmux binaries,
and a gate that refused ordinary cleanup of an already-exited session would be
worse than the defect. docs/verification/runtime-backends.md records what each
backend can prove.

A reported close failure now reaches teardown's existing retain-and-stop
refusal before the records naming the endpoint are removed, matching where the
Herdr confirmed-gone gates already sit for the same hazard, and the retained
records let a rerun finish once the close works.

* no-mistakes(review): refuse unreadable tmux close re-read; honor --force override

* no-mistakes(review): drop unreachable Orca force arm; prove CLI-absent close

* no-mistakes(document): document endpoint-close refusal in its backend and retirement owners

* no-mistakes(ci): The two reported failing checks are NOT code defects. Both "CI" (run 34935529184) and "Require no-mistakes" (run 34935529206) returned conclusion=action_required with zero jobs and 0s duration (run_started_at == updated_at), which is this repo's workflow-approval gate holding the run before any job starts. No job executed, so nothing in the diff could have caused them; two unrelated branches (fm/captain-hold-json-nonref, fm/presenter-core-l1) show the identical shape in the same time window. Verified the change locally instead: bin/fm-lint.sh clean, bin/fm-test-run.sh --check-coverage ok, and all suites the diff touches pass (fm-teardown-endpoint-safety 25/25 including the five new endpoint-close cases, fm-backend-orca, fm-backend, fm-backend-tmux-smoke, fm-backend-cmux, fm-backend-zellij, fm-backend-herdr). Separately, I found and fixed a genuinely flaky test that the phase rules require me to make deterministic: tests/fm-tmux-agent-liveness.test.sh intermittently failed "an idle shell pane must classify dead" (verdict ambiguous, comms=[bash sleep]). It is selected by --changed for this diff, so it would run against this PR once CI is approved. Root cause, established by instrumenting the pane's process group: the idle window was created by `new-session` with no command, so it inherited tmux's default-shell, i.e. whoever runs the suite. ps on the pane tty showed `-zsh` -> `bash` -> `sleep`, all sharing pgid==tpgid, i.e. the host operator's shell configuration spawning a periodic helper directly into the pane's FOREGROUND process group, which is the one surface the classifier reads. `sleep` classifies as `other`, so fg_other=1 and the verdict became `ambiguous` instead of `dead` whenever that helper overlapped the 10s poll window. Every other window in the suite runs an explicit command via new_window; the idle case was the only one whose process group the host defined. Fix (smallest root-cause, test-only, 1 line + explanatory comment): create the idle window with an explicit bare `/bin/sh` (`-- /bin/sh`), the same shell the neighbouring background case already execs. Its foreground group is now exactly one process (verified: `/bin/sh` alone), so no host configuration can inject into it. This flake is pre-existing and NOT caused by this PR: an interleaved A/B showed base commit da5e658 failing the identical case (2/6 runs) alongside head (3/7 runs), and the diff only extracted the tmux inventory read into a helper with identical semantics while never touching fm_backend_tmux_foreground_comms. After the fix: 8/8 consecutive passes, with lint and the coverage guard still clean. Change left uncommitted in the working tree

* feat(calm): add flag-gated Claude Code Calm mode (kunchenguid#4565)

* feat(calm): ship the Claude Code Calm and sailboat mod behind the function-hooks flag

Add .claude/mods/firstmate-calm, a Claude Code mod (function-hooks plugin) that
brings Calm to Claude Code: the sailboat replaces the stock working row through a
Raster repainted on the sprite's own tick, and tool, tool-group, mid-turn narration,
and canonically classified operational user rows draw at zero height. /calm is
registered by the hooks module itself and toggles the same per-home config/calm
preference the Pi extension uses, so one choice applies on either harness; rows
redraw retroactively on toggle and stay hidden across claude --continue.

The mod loads only while Claude Code's default-off CLAUDE_CODE_ENABLE_FUNCTION_HOOKS
flag is on. Nothing sets that flag in any settings file, and the plugin carries no
command file, skill, agent, or classic hook, so it is a complete no-op while the
flag is off. The trusted project auto-loads it through an .agents/skills symlink,
the only path Claude Code scans for project plugins.

Extract the working-ship geometry, bounce track, cadences, and freeze/resume state
into a harness-neutral sprite core inside the mod (Claude Code refuses hooks-module
imports from outside the plugin folder) and have the Pi widget paint that core's
frames as standard ANSI, byte for byte as before; the Pi suite stays green. Classify
operational rows through a port of bin/fm-operational-input.sh's classify command
guarded by a corpus parity test against the shell owner.

Tests: portable Node checks (plugin shape, sprite parity with Pi's rendering,
Raster packing, policy, classifier parity), the mod's own claude plugin test suites
behind a default-on wrapper, and an opt-in live TUI guard proving the flag-off no-op,
the moving boat, hidden rows, the persisted toggle, and resume on Claude Code 2.1.272.

Docs: record the version-scoped Claude Code evidence and the three bounded gaps in
docs/calm-mode-feasibility.md, describe the Claude Code contract in docs/calm.md,
and make the shared preference, layout, and contributor notes harness-neutral.

* no-mistakes(review): Preserve colliding final replies and strengthen parser parity

* no-mistakes(review): Preserve final replies and strengthen canonical parity checks

* no-mistakes(review): Require exact function-hooks opt-in before Calm activation

* no-mistakes(review): Clarify Calm module loading and activation boundaries

* no-mistakes(review): Reset Calm presentation state across session starts

* no-mistakes(document): Refresh Calm session lifecycle documentation

* feat(calm): paint the Claude Code working ship in Claude's own theme colors

The captain picked the "Claude native" palette for the Claude Code mod's Raster:
every water cell takes the spinner blue of the active theme family (#93a5ff dark,
(#d77757), one water color and one boat color. The family follows the `theme`
setting's prefix, read at load through $.config.list and re-read on a
config.set of that row, with `auto` and custom themes falling back to the dark
set. The Pi extension keeps its standard ANSI blue and yellow, byte for byte.

Rename the shared sprite's color classes from hue names to `water` and `boat`,
since each harness now maps them to its own colors; geometry, motion, cadence,
and the activation gate are untouched.

Tests cover both palettes' packing and the family rule under Node, and the
plugin kit drives every theme value, a theme change mid-session, the Calm-off
pass-through, and inertness of the menu read while the flag is off. The docs
describe the Claude Code colors and record the guard passing on 2.1.273.

* no-mistakes(review): Use light palette for unresolved Claude themes

* no-mistakes(document): Refresh Claude Calm verification evidence

* fix(orca): validate uuid::path worktree identity against recorded worktree

* no-mistakes(document): Document Orca composite identity validation

* no-mistakes(review): Allow colons in valid Orca worktree paths

* test(orca): allow :: in composite worktree path half

The review fix removed the broad colon rejection so valid Unix paths
containing ':' or '::' are accepted when they match the recorded
worktree. Update the refusal case to a path half that does not match
worktree=, which is the malformed shape the guard must still reject.

* no-mistakes(test): Updated stale Orca fixture; targeted teardown test passes

---------

Co-authored-by: Amin Roudaki <[email protected]>
Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: mdc2122 <[email protected]>
mdc2122 added a commit to mdc2122/firstmate that referenced this pull request Sep 17, 2026
…ktree (#3)

* fix(bin): refuse teardown when a task's endpoint close fails (kunchenguid#4510)

* fix(teardown): refuse a cleanup whose endpoint close failed

bin/fm-teardown.sh discarded both the exit status and the stderr of every
fm_backend_kill call, so a close that genuinely failed was indistinguishable
from one that succeeded. Teardown continued past it, deleted the task's durable
records, returned its worktree, and reported the cleanup as completed. The
deleted metadata is the only record of which endpoint belongs to the task, so
such a close did not merely leave a stray session behind, it stranded one:
nothing was left on disk naming it.

The adapters could not carry that signal either. Driven against the real code,
every backend arm returned 0 for a genuine failure exactly as it did for an
already-exited endpoint, so there was nothing for the four call sites to
propagate even once they stopped swallowing it.

The tmux arm now resolves a close that did not succeed against the window's
exact recorded identity, since kill-window fails the same way for a window that
is gone and one that is still there. The Orca arm reports a close its missing
CLI never attempted. Both stay silent for an endpoint that is already
legitimately gone, and the remaining arms are unchanged: their close-command
timing cannot be established without the real Zellij, Orca, and cmux binaries,
and a gate that refused ordinary cleanup of an already-exited session would be
worse than the defect. docs/verification/runtime-backends.md records what each
backend can prove.

A reported close failure now reaches teardown's existing retain-and-stop
refusal before the records naming the endpoint are removed, matching where the
Herdr confirmed-gone gates already sit for the same hazard, and the retained
records let a rerun finish once the close works.

* no-mistakes(review): refuse unreadable tmux close re-read; honor --force override

* no-mistakes(review): drop unreachable Orca force arm; prove CLI-absent close

* no-mistakes(document): document endpoint-close refusal in its backend and retirement owners

* no-mistakes(ci): The two reported failing checks are NOT code defects. Both "CI" (run 34935529184) and "Require no-mistakes" (run 34935529206) returned conclusion=action_required with zero jobs and 0s duration (run_started_at == updated_at), which is this repo's workflow-approval gate holding the run before any job starts. No job executed, so nothing in the diff could have caused them; two unrelated branches (fm/captain-hold-json-nonref, fm/presenter-core-l1) show the identical shape in the same time window. Verified the change locally instead: bin/fm-lint.sh clean, bin/fm-test-run.sh --check-coverage ok, and all suites the diff touches pass (fm-teardown-endpoint-safety 25/25 including the five new endpoint-close cases, fm-backend-orca, fm-backend, fm-backend-tmux-smoke, fm-backend-cmux, fm-backend-zellij, fm-backend-herdr). Separately, I found and fixed a genuinely flaky test that the phase rules require me to make deterministic: tests/fm-tmux-agent-liveness.test.sh intermittently failed "an idle shell pane must classify dead" (verdict ambiguous, comms=[bash sleep]). It is selected by --changed for this diff, so it would run against this PR once CI is approved. Root cause, established by instrumenting the pane's process group: the idle window was created by `new-session` with no command, so it inherited tmux's default-shell, i.e. whoever runs the suite. ps on the pane tty showed `-zsh` -> `bash` -> `sleep`, all sharing pgid==tpgid, i.e. the host operator's shell configuration spawning a periodic helper directly into the pane's FOREGROUND process group, which is the one surface the classifier reads. `sleep` classifies as `other`, so fg_other=1 and the verdict became `ambiguous` instead of `dead` whenever that helper overlapped the 10s poll window. Every other window in the suite runs an explicit command via new_window; the idle case was the only one whose process group the host defined. Fix (smallest root-cause, test-only, 1 line + explanatory comment): create the idle window with an explicit bare `/bin/sh` (`-- /bin/sh`), the same shell the neighbouring background case already execs. Its foreground group is now exactly one process (verified: `/bin/sh` alone), so no host configuration can inject into it. This flake is pre-existing and NOT caused by this PR: an interleaved A/B showed base commit da5e658 failing the identical case (2/6 runs) alongside head (3/7 runs), and the diff only extracted the tmux inventory read into a helper with identical semantics while never touching fm_backend_tmux_foreground_comms. After the fix: 8/8 consecutive passes, with lint and the coverage guard still clean. Change left uncommitted in the working tree

* feat(calm): add flag-gated Claude Code Calm mode (kunchenguid#4565)

* feat(calm): ship the Claude Code Calm and sailboat mod behind the function-hooks flag

Add .claude/mods/firstmate-calm, a Claude Code mod (function-hooks plugin) that
brings Calm to Claude Code: the sailboat replaces the stock working row through a
Raster repainted on the sprite's own tick, and tool, tool-group, mid-turn narration,
and canonically classified operational user rows draw at zero height. /calm is
registered by the hooks module itself and toggles the same per-home config/calm
preference the Pi extension uses, so one choice applies on either harness; rows
redraw retroactively on toggle and stay hidden across claude --continue.

The mod loads only while Claude Code's default-off CLAUDE_CODE_ENABLE_FUNCTION_HOOKS
flag is on. Nothing sets that flag in any settings file, and the plugin carries no
command file, skill, agent, or classic hook, so it is a complete no-op while the
flag is off. The trusted project auto-loads it through an .agents/skills symlink,
the only path Claude Code scans for project plugins.

Extract the working-ship geometry, bounce track, cadences, and freeze/resume state
into a harness-neutral sprite core inside the mod (Claude Code refuses hooks-module
imports from outside the plugin folder) and have the Pi widget paint that core's
frames as standard ANSI, byte for byte as before; the Pi suite stays green. Classify
operational rows through a port of bin/fm-operational-input.sh's classify command
guarded by a corpus parity test against the shell owner.

Tests: portable Node checks (plugin shape, sprite parity with Pi's rendering,
Raster packing, policy, classifier parity), the mod's own claude plugin test suites
behind a default-on wrapper, and an opt-in live TUI guard proving the flag-off no-op,
the moving boat, hidden rows, the persisted toggle, and resume on Claude Code 2.1.272.

Docs: record the version-scoped Claude Code evidence and the three bounded gaps in
docs/calm-mode-feasibility.md, describe the Claude Code contract in docs/calm.md,
and make the shared preference, layout, and contributor notes harness-neutral.

* no-mistakes(review): Preserve colliding final replies and strengthen parser parity

* no-mistakes(review): Preserve final replies and strengthen canonical parity checks

* no-mistakes(review): Require exact function-hooks opt-in before Calm activation

* no-mistakes(review): Clarify Calm module loading and activation boundaries

* no-mistakes(review): Reset Calm presentation state across session starts

* no-mistakes(document): Refresh Calm session lifecycle documentation

* feat(calm): paint the Claude Code working ship in Claude's own theme colors

The captain picked the "Claude native" palette for the Claude Code mod's Raster:
every water cell takes the spinner blue of the active theme family (#93a5ff dark,
(#d77757), one water color and one boat color. The family follows the `theme`
setting's prefix, read at load through $.config.list and re-read on a
config.set of that row, with `auto` and custom themes falling back to the dark
set. The Pi extension keeps its standard ANSI blue and yellow, byte for byte.

Rename the shared sprite's color classes from hue names to `water` and `boat`,
since each harness now maps them to its own colors; geometry, motion, cadence,
and the activation gate are untouched.

Tests cover both palettes' packing and the family rule under Node, and the
plugin kit drives every theme value, a theme change mid-session, the Calm-off
pass-through, and inertness of the menu read while the flag is off. The docs
describe the Claude Code colors and record the guard passing on 2.1.273.

* no-mistakes(review): Use light palette for unresolved Claude themes

* no-mistakes(document): Refresh Claude Calm verification evidence

* fix(orca): validate uuid::path worktree identity against recorded worktree

* no-mistakes(document): Document Orca composite identity validation

* no-mistakes(review): Allow colons in valid Orca worktree paths

* test(orca): allow :: in composite worktree path half

The review fix removed the broad colon rejection so valid Unix paths
containing ':' or '::' are accepted when they match the recorded
worktree. Update the refusal case to a path half that does not match
worktree=, which is the malformed shape the guard must still reject.

* no-mistakes(test): Updated stale Orca fixture; targeted teardown test passes

---------

Co-authored-by: Amin Roudaki <[email protected]>
Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: mdc2122 <[email protected]>
vifar added a commit to vifar/firstmate that referenced this pull request Sep 17, 2026