Repository navigation
feat(mods): gate the Claude Code Calm mod on its own FM_CALM_ENABLED flag - #24
Merged
Merged
Conversation
…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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
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
firstmate-calmmod's activation gate inregister.tsnow reads the firstmate-ownedFM_CALM_ENABLEDvariable instead ofCLAUDE_CODE_ENABLE_FUNCTION_HOOKS. The mod does nothing at all unless the gate is1. IfFM_CALM_ENABLEDholds any non-empty value, that value alone decides, soFM_CALM_ENABLED=0turns Calm off even when the old flag is still exported. Only whenFM_CALM_ENABLEDis unset or empty does the mod fall back toCLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1as a deprecated alias.docs/calm.md, theAGENTS.mdlayout line,README.md,CONTRIBUTING.mdand the plugin/hooks manifest descriptions to describe the new gate and how to migrate from the old flag.docs/calm.mdno 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.mdgets a new 2026-10-06 record for the rename, anddocs/configuration.mdsays thatconfig/calmis not the activation gate.FM_CALM_ENABLED=0winning over it. Every live-e2e gate constant now pinsFM_CALM_ENABLED.tmux send-keys -lor by a bracketedtmux 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 oftests/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.🤖 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 --continuekeeps 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.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)
Evidence: Full live e2e trace (tmux-driven real TUI)
Source: Full live e2e trace (tmux-driven real TUI)
Evidence: Plugin validation + mod suites
Source: Plugin validation + mod suites
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 throughenvinto 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.
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.