Skip to content

feat(mods): gate the Claude Code Calm mod on its own FM_CALM_ENABLED flag - #24

Merged
max-metaplanet merged 2 commits into
mainfrom
fm/calm-flag-rename
Oct 6, 2026
Merged

max-metaplanet merged 2 commits into
mainfrom
fm/calm-flag-rename

Conversation

@max-metaplanet

@max-metaplanet max-metaplanet commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Intent

Calm's self-gate reads CLAUDE_CODE_ENABLE_FUNCTION_HOOKS, which Claude Code 2.1.287+ ignores: mods are on by default, and the docs tell people to delete the flag.
Rename Calm's own activation gate to a firstmate-owned flag and refresh docs/calm.md and the AGENTS.md layout line accordingly, preserving 'complete no-op unless explicitly enabled' semantics and migrating anyone relying on the old flag.
Ship via the no-mistakes PR path.

Context, from a research report on Claude Code mods (section 3):
Every handler in .claude/mods/firstmate-calm/hooks/register.ts begins with an isActivated check that requires CLAUDE_CODE_ENABLE_FUNCTION_HOOKS === "1".
That variable is now meaningless to Claude Code 2.1.291; it is a firstmate-private switch that happens to share a dead platform flag's name.
It is currently set to 1 in the env block of every Claude settings file on this machine, so Calm is active today, but anyone tidying up a flag the platform docs call dead ("If you set CLAUDE_CODE_ENABLE_FUNCTION_HOOKS during early access, remove it") would silently turn Calm into a complete no-op with no error anywhere.
docs/calm.md also still calls the surface "early-access, default-off" and "verified on Claude Code 2.1.272".
The report suggested a name like FM_CALM_ENABLED.

What Changed

  • The firstmate-calm mod's activation gate in register.ts now reads the firstmate-owned FM_CALM_ENABLED variable instead of CLAUDE_CODE_ENABLE_FUNCTION_HOOKS. The mod does nothing at all unless the gate is 1. If FM_CALM_ENABLED holds any non-empty value, that value alone decides, so FM_CALM_ENABLED=0 turns Calm off even when the old flag is still exported. Only when FM_CALM_ENABLED is unset or empty does the mod fall back to CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 as a deprecated alias.
  • Updated docs/calm.md, the AGENTS.md layout line, README.md, CONTRIBUTING.md and the plugin/hooks manifest descriptions to describe the new gate and how to migrate from the old flag. docs/calm.md no longer calls the surface "early-access, default-off" and now says the mod is verified on Claude Code 2.1.291. docs/calm-mode-feasibility.md gets a new 2026-10-06 record for the rename, and docs/configuration.md says that config/calm is not the activation gate.
  • The mod's unit tests and the shell tests (plugin, mod and live e2e) now cover the new flag, the fallback to the old one, and FM_CALM_ENABLED=0 winning over it. Every live-e2e gate constant now pins FM_CALM_ENABLED.
  • Live coverage move, deliberate and decided: the live e2e no longer drives the zero-height operational-user-row case. On Claude Code 2.1.291 the composer strips the envelope's invisible marker on submit and asks for a second Enter, so the submitted text is plain ASCII that the canonical classifier correctly reads as non-operational - that row cannot be produced from a terminal at all, by tmux send-keys -l or by a bracketed tmux paste-buffer. The case is replaced by a tripwire phase that asserts the stripping itself, so the guard fails and says to restore the live case the moment Claude Code stops sanitizing. That row's coverage stays in the mod's own plugin suites and in the classifier parity corpus of tests/fm-calm-claude-mod.test.sh. Review raised this as the author's call and the decision was to keep it here rather than split it out.
  • Delivering that marker to a Claude pane is firstmate's own input concern rather than Calm's, and is not fixed here: on 2.1.291 a marked operational message sent to a Claude pane arrives unmarked and needs a second Enter. That deserves its own change.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The gate rename is a small change that keeps the no-op default and migrates old-flag users through a deprecated alias that FM_CALM_ENABLED overrides. The fix round pins FM_CALM_ENABLED to empty in GATE_OFF and GATE_LEGACY_ONLY, and the gate reads empty as unset. It also strips FM_CALM_ENABLED from the inherited environment. That covers the earlier unpinned-flag finding, and the fix round added nothing new.

Testing

I ran the credentialed live e2e once against the real Claude Code 2.1.291 TUI in an isolated tmux lab, using its own private socket rather than Herdr, and with FM_CALM_ENABLED=1 exported in the caller's shell as an adversarial case. All six phases passed: - With the gate off, the module loads but stays inert. - With FM_CALM_ENABLED=1, /calm exists, the sailboat shows and tool rows are hidden; /calm toggles them back and forth and persists the choice. - claude --continue keeps the hidden rows hidden. - The legacy alias alone still activates the mod. - FM_CALM_ENABLED=0 beats the alias. - The composer still strips the operational envelope's invisible marker. The plugin validation suite also passed. Docs wording was checked by reading. No transient files were left in the worktree.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Captain launches Claude Code with neither flag enabling Calm: the hooks module loads, but /calm is missing, the working row and tool rows are stock, and there is no boat ✅ pass live live-e2e-tap.txt line 1 (gate off)
Captain sets FM_CALM_ENABLED=1 with the old flag off: /calm exists, the sailboat replaces the working row, tool rows are hidden, and /calm restores and re-hides them while persisting config/calm ✅ pass live live-e2e-tap.txt line 2
Captain resumes with claude --continue: Calm's hidden rows stay hidden ✅ pass live live-e2e-tap.txt line 3
Unmigrated captain who has only CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 still gets Calm (migration path) ✅ pass live live-e2e-tap.txt line 4
Adversarial: FM_CALM_ENABLED=0 next to the old flag set to 1 leaves Calm inert, so the firstmate flag decides ✅ pass live live-e2e-tap.txt line 5
Adversarial: a host shell exporting FM_CALM_ENABLED=1 cannot leak into the gate-off or legacy-only phases (the review-round pinning fix) ✅ pass live The whole live run used FM_CALM_ENABLED=1 in the caller's environment, and phases 1 and 4 still passed (trace log)
Composer tripwire: Claude Code still strips the operational envelope's invisible marker (phase 5, kept per the user's decision) ✅ pass live live-e2e-tap.txt line 6
Evidence: Live e2e TAP results (Claude Code 2.1.291, host exports FM_CALM_ENABLED=1)

Source: Live e2e TAP results (Claude Code 2.1.291, host exports FM_CALM_ENABLED=1)

ok - Claude Code 2.1.291 (Claude Code) with the gate off: the hooks module loads and still does nothing - no /calm, stock working row, stock tool rows, no boat, preference on ignored
ok - Claude Code 2.1.291 (Claude Code) with FM_CALM_ENABLED=1 and the deprecated alias off: the mod auto-loads from .claude/skills, /calm exists, the sailboat replaces and moves in the working row, tool rows draw at zero height, and /calm restores and re-hides them while persisting the shared preference
ok - Claude Code 2.1.291 (Claude Code) resumes the transcript with Calm's hidden rows still hidden and the preference intact
ok - Claude Code 2.1.291 (Claude Code) activates the Calm mod on the deprecated CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 alone, so a session that has not moved to FM_CALM_ENABLED keeps Calm
ok - Claude Code 2.1.291 (Claude Code) leaves the Calm mod inert when FM_CALM_ENABLED=0 disagrees with the deprecated CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1, so the firstmate-owned flag decides
ok - Claude Code 2.1.291 (Claude Code) strips an exact operational envelope's invisible marker out of the composer, so the live zero-height operational-row case is unreachable from a terminal and its coverage stays in the mod's own suites
Evidence: Full live e2e trace (tmux-driven real TUI)

Source: Full live e2e trace (tmux-driven real TUI)

+ set -u
++ dirname tests/fm-calm-claude-mod-live-e2e.test.sh
+ . tests/lib.sh
++ '[' -n '' ']'
++ FM_TEST_LIB_SOURCED=1
++ umask 022
+++ dirname tests/lib.sh
++ . tests/git-config-helpers.sh
+++ export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1
+++ GIT_CONFIG_GLOBAL=/dev/null
+++ GIT_CONFIG_NOSYSTEM=1
++ export FM_GATE_REFUSE_BYPASS=1
++ FM_GATE_REFUSE_BYPASS=1
++ unset FM_TASK_ID
++ unset TASKS_AXI_FILE TASKS_AXI_BACKEND
++++ dirname tests/lib.sh
+++ cd tests/..
+++ pwd
++ ROOT=~/.no-mistakes/worktrees/61c6dd39b831/01M484S7FYAWMKYDWS3M3PAX8Y
++ FM_TEST_CLEANUP_DIRS=()
+++ mktemp /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//.fm-test-cleanup.93089.XXXXXX
++ FM_TEST_CLEANUP_REGISTRY=/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//.fm-test-cleanup.93089.MqFHBg
+++ fm_test_pid_identity 93089
+++ local pid=93089
+++ FM_STATE_OVERRIDE=/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/
+++ bash -c '. "$1"; fm_pid_identity "$2"' _ ~/.no-mistakes/worktrees/61c6dd39b831/01M484S7FYAWMKYDWS3M3PAX8Y/bin/fm-wake-lib.sh 93089
++ FM_TEST_OWNER_IDENTITY='Tue Oct  6 04:29:07 2026     bash -x tests/fm-calm-claude-mod-live-e2e.test.sh'
+++ mktemp /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//.fm-test-procevent.93089.XXXXXX
++ FM_TEST_PROCEVENT_REGISTRY=/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//.fm-test-procevent.93089.bn0BMQ
++ FM_TEST_STUB_MAX_BLOCK_SECONDS=120
++ export FM_TEST_STUB_MAX_BLOCK_SECONDS
++ trap fm_test_cleanup EXIT
++ trap 'fm_test_cleanup; exit 130' INT
++ trap 'fm_test_cleanup; exit 143' TERM
++ trap 'fm_test_cleanup; exit 129' HUP
++ trap 'fm_test_cleanup; exit 131' QUIT
++ FM_TEST_ORPHAN_MAX_AGE_SECONDS=3600
++ '[' 0 '!=' 1 ']'
++ fm_test_reap_orphans
++ local marker dir mtime now owner_pid owner_identity current_identity
+++ date +%s
++ now=1791275348
++ for marker in "${TMPDIR:-/tmp}"/fm-*/.fm-test-fixture
++ '[' -e /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-test-run-non-lane-schedule.0KE8Jz/.fm-test-fixture ']'
+++ sed -n 1p /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-test-run-non-lane-schedule.0KE8Jz/.fm-test-fixture
++ owner_pid=5923
+++ sed -n '2,$p' /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-test-run-non-lane-schedule.0KE8Jz/.fm-test-fixture
++ owner_identity='Tue Oct  6 04:18:07 2026     bash tests/fm-test-run.test.sh'
++ case "$owner_pid" in
+++ fm_test_pid_identity 5923
++ current_identity='Tue Oct  6 04:18:07 2026     bash tests/fm-test-run.test.sh'
++ '[' -n 'Tue Oct  6 04:18:07 2026     bash tests/fm-test-run.test.sh' ']'
++ '[' 'Tue Oct  6 04:18:07 2026     bash tests/fm-test-run.test.sh' = 'Tue Oct  6 04:18:07 2026     bash tests/fm-test-run.test.sh' ']'
++ continue
++ for marker in "${TMPDIR:-/tmp}"/fm-*/.fm-test-fixture
++ '[' -e /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-test-run-proven-schedule.txMBCX/.fm-test-fixture ']'
+++ sed -n 1p /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-test-run-proven-schedule.txMBCX/.fm-test-fixture
++ owner_pid=5923
+++ sed -n '2,$p' /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//fm-test-run-proven-schedule.txMBCX/.fm-test-fixture
++ owner_identity='Tue Oct  6 04:18:07 2026     bash tests/fm-test-run.test.sh'
++ case "$owner_pid" in
+++ fm_test_pid_identity 5923
++ current_identity='Tue Oct  6 04:18:07 2026     bash tests/fm-test-run.test.sh'
++ '[' -n 'Tue Oct  6 04:18:07 2026     bash tests/fm-test-run.test.sh' ']'
++ '[' 'Tue Oct  6 04:18:07 2026     bash tests/fm-test-run.test.sh' = 'Tue Oct  6 04:18:07 2026     bash tests/fm-test-run.test.sh' ']'
++ continue
+ fm_live_gate opt-in FM_CLAUDE_CALM_LIVE_E2E claude tmux
+ local policy=opt-in vars=FM_CLAUDE_CALM_LIVE_E2E
+ shift 2
+ local var value rest primary requested=0 disabled_by= tool
+ var_list=()
+ local -a var_list
+ case "$policy" in
+ rest=FM_CLAUDE_CALM_LIVE_E2E
+ '[' -n FM_CLAUDE_CALM_LIVE_E2E ']'
+ var=FM_CLAUDE_CALM_LIVE_E2E
+ '[' FM_CLAUDE_CALM_LIVE_E2E = FM_CLAUDE_CALM_LIVE_E2E ']'
+ rest=
+ '[' -n FM_CLAUDE_CALM_LIVE_E2E ']'
+ var_list+=("$var")
+ '[' -n '' ']'
+ '[' 1 -gt 0 ']'
+ primary=FM_CLAUDE_CALM_LIVE_E2E
+ for var in "${var_list[@]}"
+ value=1
+ case "$value" in
+ requested=1
+ '[' 1 -eq 0 ']'
+ for tool in "$@"
+ command -v claude
+ continue
+ for tool in "$@"
+ command -v tmux
+ continue
+ return 0
+ MOD=~/.no-mistakes/worktrees/61c6dd39b831/01M484S7FYAWMKYDWS3M3PAX8Y/.claude/mods/firstmate-calm
+ OPERATIONAL_INPUT=~/.no-mistakes/worktrees/61c6dd39b831/01M484S7FYAWMKYDWS3M3PAX8Y/bin/fm-operational-input.sh
++ claude --version
+ CLAUDE_VERSION='2.1.291 (Claude Code)'
+ '[' -n '2.1.291 (Claude Code)' ']'
++ fm_test_tmproot fm-calm-claude-live
++ local prefix=fm-calm-claude-live root tmp_base
++ tmp_base=/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/
++ tmp_base=/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T
+++ mktemp -d /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.XXXXXX
++ root=/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn
+++ cd -P -- /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn
+++ pwd -P
++ root=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn
++ printf '%s\n%s\n' 93089 'Tue Oct  6 04:29:07 2026     bash -x tests/fm-calm-claude-mod-live-e2e.test.sh'
++ printf '%s\n' /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn
++ printf '%s\n' /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn
+ LAB=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn
+ PROJECT=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/project
+ FM_HOME_DIR=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/fmhome
+ DEBUG_LOG_OFF=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-off.log
+ DEBUG_LOG_ON=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-on.log
+ DEBUG_LOG_RESUME=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-resume.log
+ DEBUG_LOG_LEGACY=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-legacy.log
+ DEBUG_LOG_DISAGREE=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-disagree.log
+ DEBUG_LOG_MARKER=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-marker.log
+ SOCKET=fm-calm-claude-93089
+ SESSION=fm-calm-claude-e2e
+ HULL=╲▁▁▁╱
+ SAIL=◿│◣
+ trap cleanup EXIT
+ mkdir -p /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/project/.claude/skills /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/fmhome/config
+ ln -s ~/.no-mistakes/worktrees/61c6dd39b831/01M484S7FYAWMKYDWS3M3PAX8Y/.claude/mods/firstmate-calm /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/project/.claude/skills/firstmate-calm
+ printf 'alpha\nbeta\ngamma\n'
+ printf 'on\n'
+ GATE_OFF='FM_CALM_ENABLED= CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=0'
+ GATE_ON='FM_CALM_ENABLED=1 CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=0'
+ GATE_LEGACY_ONLY='FM_CALM_ENABLED= CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1'
+ GATE_DISAGREEING='FM_CALM_ENABLED=0 CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1'
+ PROMPT='Run this exact bash command with the Bash tool: sleep 5; cat notes.txt   Then reply with one short sentence naming the three words.'
+ launch /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-off.log 'FM_CALM_ENABLED= CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=0'
+ local log=/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-off.log settings
++ settings_json 'FM_CALM_ENABLED= CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=0'
++ local gate pair json=
++ for gate in $1
++ pair='"FM_CALM_ENABLED":""'
++ json='"FM_CALM_ENABLED":""'
++ for gate in $1
++ pair='"CLAUDE_CODE_ENABLE_FUNCTION_HOOKS":"0"'
++ json='"FM_CALM_ENABLED":"","CLAUDE_CODE_ENABLE_FUNCTION_HOOKS":"0"'
++ printf '{\"feedbackDrafts\":\"off\"

... [719098 bytes truncated] ...


+ sleep 0.1
+ i=11
+ '[' 11 -lt 200 ']'
+ grep -q 'hooks module firstmate-calm@skills-dir loaded' /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-marker.log
+ sleep 0.1
+ i=12
+ '[' 12 -lt 200 ']'
+ grep -q 'hooks module firstmate-calm@skills-dir loaded' /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-marker.log
+ sleep 0.1
+ i=13
+ '[' 13 -lt 200 ']'
+ grep -q 'hooks module firstmate-calm@skills-dir loaded' /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-marker.log
+ sleep 0.1
+ i=14
+ '[' 14 -lt 200 ']'
+ grep -q 'hooks module firstmate-calm@skills-dir loaded' /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-marker.log
+ sleep 0.1
+ i=15
+ '[' 15 -lt 200 ']'
+ grep -q 'hooks module firstmate-calm@skills-dir loaded' /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-marker.log
+ grep -q 'hooks module firstmate-calm@skills-dir loaded' /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-marker.log
++ printf 'signal: %s/state/probe.status changed' /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn
++ ~/.no-mistakes/worktrees/61c6dd39b831/01M484S7FYAWMKYDWS3M3PAX8Y/bin/fm-operational-input.sh encode watcher
+ operational=$'\342\201\243FIRSTMATE_OP: v1 watcher: signal: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/state/probe.status changed'
+ send $'\342\201\243FIRSTMATE_OP: v1 watcher: signal: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/state/probe.status changed'
+ tmux -L fm-calm-claude-93089 send-keys -t fm-calm-claude-e2e -l $'\342\201\243FIRSTMATE_OP: v1 watcher: signal: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/state/probe.status changed'
+ enter
+ tmux -L fm-calm-claude-93089 send-keys -t fm-calm-claude-e2e Enter
+ wait_screen 'invisible character' 'the composer stripping the operational envelope'\''s marker; if Claude Code now submits it intact, restore phase 2'\''s live zero-height operational-row case' 200
+ local 'text=invisible character' 'what=the composer stripping the operational envelope'\''s marker; if Claude Code now submits it intact, restore phase 2'\''s live zero-height operational-row case' limit=200 i=0 shot
+ '[' 0 -lt 200 ']'
++ screen
++ tmux -L fm-calm-claude-93089 capture-pane -p -t fm-calm-claude-e2e
+ shot=$'\n ▐▛███▛█   Claude Code v2.1.291\n▝▜██████▀  Haiku 4.5 · Claude Team\n ▝▝   ▝▝   /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/project\n\n▎ Debug mode enabled · logging to /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-marker.log\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n                                                                                                Removed 1 invisible character · review and press Enter to send\n────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\n❯ FIRSTMATE_OP: v1 watcher: signal: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/state/probe.status changed\n────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\n  Haiku 4.5 | p/v/f/1/g/T/f/project | ⚙️60 | ⚡100% | P01=E04=U08=J17:32:07\n  -- INSERT -- ⏵⏵ bypass permissions on (shift+tab to cycle)'
+ case "$shot" in
+ dialog_open $'\n ▐▛███▛█   Claude Code v2.1.291\n▝▜██████▀  Haiku 4.5 · Claude Team\n ▝▝   ▝▝   /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/project\n\n▎ Debug mode enabled · logging to /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/debug-marker.log\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n                                                                                                Removed 1 invisible character · review and press Enter to send\n────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\n❯ FIRSTMATE_OP: v1 watcher: signal: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/state/probe.status changed\n────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\n  Haiku 4.5 | p/v/f/1/g/T/f/project | ⚙️60 | ⚡100% | P01=E04=U08=J17:32:07\n  -- INSERT -- ⏵⏵ bypass permissions on (shift+tab to cycle)'
+ case "$1" in
+ return 1
+ case "$shot" in
+ return 0
+ pass 'Claude Code 2.1.291 (Claude Code) strips an exact operational envelope'\''s invisible marker out of the composer, so the live zero-height operational-row case is unreachable from a terminal and its coverage stays in the mod'\''s own suites'
+ printf 'ok - %s\n' 'Claude Code 2.1.291 (Claude Code) strips an exact operational envelope'\''s invisible marker out of the composer, so the live zero-height operational-row case is unreachable from a terminal and its coverage stays in the mod'\''s own suites'
ok - Claude Code 2.1.291 (Claude Code) strips an exact operational envelope's invisible marker out of the composer, so the live zero-height operational-row case is unreachable from a terminal and its coverage stays in the mod's own suites
+ cleanup
+ local i=0
+ tmux -L fm-calm-claude-93089 kill-server
+ '[' 0 -lt 20 ']'
+ pgrep -f 'debug-file '\''/private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn/'
+ rm -rf /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn
+ true
+ fm_test_cleanup
+ local d
+ fm_test_reap_procevent_homes
+ local home claim_root $'seen=\n'
+ '[' -f /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//.fm-test-procevent.93089.bn0BMQ ']'
+ IFS=$'\t'
+ read -r home claim_root
+ rm -f /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//.fm-test-procevent.93089.bn0BMQ
+ for d in "${FM_TEST_CLEANUP_DIRS[@]:-}"
+ '[' -n '' ']'
+ '[' -f /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//.fm-test-cleanup.93089.MqFHBg ']'
+ IFS=
+ read -r d
+ '[' -n /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn ']'
+ rm -rf /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-calm-claude-live.qsUYQn
+ IFS=
+ read -r d
+ rm -f /var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T//.fm-test-cleanup.93089.MqFHBg
Evidence: Plugin validation + mod suites

Source: Plugin validation + mod suites

ok - Claude Code 2.1.291 (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.291 (Claude Code) runs the Calm mod's plugin test suites clean: the FM_CALM_ENABLED gate and its deprecated alias, the persisted toggle, hidden rows, working notes, and the clock-driven working ship

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • ⚠️ tests/fm-calm-claude-mod-live-e2e.test.sh:105 - GATE_OFF ('CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=0') and GATE_LEGACY_ONLY ('CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1') leave FM_CALM_ENABLED unpinned. unset_inherited only strips CLAUDECODE/CLAUDE_CODE_*/CLAUDE_CONFIG_DIR, so an FM_CALM_ENABLED exported in the captain's shell passes through env into claude. A host settings file that sets it would also merge in, because --settings only overrides the keys it defines. docs/calm.md tells captains to migrate by 'exporting FM_CALM_ENABLED=1 wherever that variable was set'. After a captain does that, phase 1 fails spuriously (the mod activates and /calm is listed) and phase 4's legacy-only case passes without testing the alias. This contradicts the header comment that 'no phase depends on what this machine's own settings export'. Fix: pin FM_CALM_ENABLED= (empty, which the gate reads as unset) in GATE_OFF and GATE_LEGACY_ONLY, and/or add FM_CALM_ENABLED to unset_inherited's strip list.
  • ⚠️ tests/fm-calm-claude-mod-live-e2e.test.sh:467 - The change goes beyond the flag rename in the intent. It removes the live zero-height operational-user-row case from phase 2, the /calm-off restore check, and the re-hide check. In their place it adds a new phase 5 'tripwire' that waits for the composer's 'invisible character' message, plus a feasibility-doc section about composer sanitizing. Nothing in the intent (rename the gate, refresh docs/calm.md and the AGENTS.md line, keep no-op semantics, migrate old-flag users) requires this. It also lowers live coverage and ties the guard to one Claude Code UI string. It may be justified by 2.1.291 behavior, but whether to keep that coverage cut and the new phase in this change is the author's call. The other option is to split it into a separate change.

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

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Captain launches Claude Code with neither flag enabling Calm: the hooks module loads, but /calm is missing, the working row and tool rows are stock, and there is no boat ✅ pass live live-e2e-tap.txt line 1 (gate off)
Captain sets FM_CALM_ENABLED=1 with the old flag off: /calm exists, the sailboat replaces the working row, tool rows are hidden, and /calm restores and re-hides them while persisting config/calm ✅ pass live live-e2e-tap.txt line 2
Captain resumes with claude --continue: Calm's hidden rows stay hidden ✅ pass live live-e2e-tap.txt line 3
Unmigrated captain who has only CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 still gets Calm (migration path) ✅ pass live live-e2e-tap.txt line 4
Adversarial: FM_CALM_ENABLED=0 next to the old flag set to 1 leaves Calm inert, so the firstmate flag decides ✅ pass live live-e2e-tap.txt line 5
Adversarial: a host shell exporting FM_CALM_ENABLED=1 cannot leak into the gate-off or legacy-only phases (the review-round pinning fix) ✅ pass live The whole live run used FM_CALM_ENABLED=1 in the caller's environment, and phases 1 and 4 still passed (trace log)
Composer tripwire: Claude Code still strips the operational envelope's invisible marker (phase 5, kept per the user's decision) ✅ pass live live-e2e-tap.txt line 6
  • env -u CLAUDECODE FM_CLAUDE_CALM_LIVE_E2E=1 FM_CALM_ENABLED=1 bash -x tests/fm-calm-claude-mod-live-e2e.test.sh (real Claude Code 2.1.291 TUI on a private tmux socket, isolated project and FM_HOME, Haiku turns, FM_CALM_ENABLED=1 exported in the caller's shell)
  • bash tests/fm-calm-claude-mod-plugin.test.sh (Claude Code strict plugin validation, plus the mod's own suites covering the FM_CALM_ENABLED gate and the alias matrix)
  • Manual check that docs/calm.md and the AGENTS.md layout line describe FM_CALM_ENABLED, the alias migration and precedence, with no 'early-access, default-off' or 2.1.272 claims left
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…flag

Claude Code 2.1.287 and later ignore CLAUDE_CODE_ENABLE_FUNCTION_HOOKS and
their own docs ask for it to be removed, so the mod's only activation check
was a dead platform flag: anyone tidying that flag away would have turned
Calm into a complete no-op with no error anywhere.

The mod now reads the firstmate-owned FM_CALM_ENABLED and keeps the old name
as a deprecated alias consulted only when FM_CALM_ENABLED is unset or empty,
so a session carrying only the old name keeps Calm while FM_CALM_ENABLED
decides alone whenever the two disagree. config/calm stays the shared
cross-harness on/off choice and no third switch is introduced: the gate must
be decided with no file read at all, and config/calm is also Pi's preference,
where Calm needs no gate.

Platform-describing prose moves to the installed 2.1.291 behavior, with the
2.1.272 record and table row kept as dated history and a new dated record
owning the current surface state. The live guard pins both names per launch
through --settings so no phase depends on the host's settings, and asserts
the hooks module loads while the mod stays inert, which is now the whole
no-op guarantee. Its zero-height operational-row case is replaced by a
tripwire: this Claude Code strips the envelope's invisible marker in the
composer, so that row is unreachable from a terminal and its coverage stays
in the mod's own suites and the classifier parity corpus.
@max-metaplanet
max-metaplanet merged commit 949ea83 into main Oct 6, 2026
22 checks passed
max-metaplanet added a commit that referenced this pull request Oct 6, 2026
…flag (#24)

* feat(calm): gate the Claude Code Calm mod on its own FM_CALM_ENABLED flag

Claude Code 2.1.287 and later ignore CLAUDE_CODE_ENABLE_FUNCTION_HOOKS and
their own docs ask for it to be removed, so the mod's only activation check
was a dead platform flag: anyone tidying that flag away would have turned
Calm into a complete no-op with no error anywhere.

The mod now reads the firstmate-owned FM_CALM_ENABLED and keeps the old name
as a deprecated alias consulted only when FM_CALM_ENABLED is unset or empty,
so a session carrying only the old name keeps Calm while FM_CALM_ENABLED
decides alone whenever the two disagree. config/calm stays the shared
cross-harness on/off choice and no third switch is introduced: the gate must
be decided with no file read at all, and config/calm is also Pi's preference,
where Calm needs no gate.

Platform-describing prose moves to the installed 2.1.291 behavior, with the
2.1.272 record and table row kept as dated history and a new dated record
owning the current surface state. The live guard pins both names per launch
through --settings so no phase depends on the host's settings, and asserts
the hooks module loads while the mod stays inert, which is now the whole
no-op guarantee. Its zero-height operational-row case is replaced by a
tripwire: this Claude Code strips the envelope's invisible marker in the
composer, so that row is unreachable from a terminal and its coverage stays
in the mod's own suites and the classifier parity corpus.

* no-mistakes(review): Pin FM_CALM_ENABLED in every live-e2e gate constant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant