Mcp(fix[safety]): Narrow on a typo instead of widening - #7
Open
tony wants to merge 1 commit into
Open
Conversation
why: TMUX_MCP_SAFETY fell back to the default on any value it did not recognise, and the default is mutating. An operator who wrote read_only or ro got a server offering send_keys and every creating tool on a socket they had meant to be read-only. The flag refuses such a name; the variable cannot, because it is read from wherever the process was started -- but falling back and falling back *upward* are different decisions, and only the first was intended. Safety::from_env's own documentation said widening on a typo would be the wrong way to fail, while the code did exactly that. The two directions do not cost the same. Narrowing costs a restart and is visible in the startup line, which names the tier in force. Widening hands an agent authority nobody granted and says nothing. what: - Add Safety::from_value, resolving a tier from an optional value; unset takes the default, set-and-unrecognised takes ReadOnly - Reduce Safety::from_env to reading the variable and calling it, the split CallerIdentity::from_env already uses so parsing is testable without a process-wide environment - Cover the fallback in both directions, including the empty string - Correct the cli.rs test comment that described the old fallback - Say in the README how the variable and the flag differ, and where a typo becomes visible
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.
TMUX_MCP_SAFETYfell back to the default tier on any value it did not recognise, and that default ismutating. An operator who wroteread_onlyorrogot a server advertisingsend_keysand every creating tool on a socket they had meant to be read-only, with nothing saying so.--safetyrefuses an unknown name outright. The variable cannot, because it is read from wherever the process was started — but falling back and falling back upward are different decisions, and only the first was intended.Safety::from_env's own documentation said widening on a typo would be the wrong way to fail while the code did exactly that.The two directions do not cost the same. Narrowing costs a restart, and the startup line names the tier in force, so the typo is visible. Widening hands an agent authority nobody granted and says nothing.
What changed
Safety::from_valueresolves a tier from an optional value the way an environment supplies one. Unset takes the default; set and unrecognised takesSafety::ReadOnly.Safety::from_envreduces to reading the variable and calling it — the splitCallerIdentity::from_envalready uses, so the fallback is testable without a process-wide environment no test can hold alone.--safetyis unchanged. A flag is typed on purpose, so a wrong one stays aStop::Misuse.tmux-mcpREADME says how the variable and the flag differ, and where a typo becomes visible.Tests
an_unrecognised_tier_narrows_rather_than_widenscoversread only,read_only,ro,yolo, and the empty string.an_unset_tier_takes_the_defaultanda_tier_is_read_by_namepin the other two paths.Note that
read-onlywas never affected:Safety::parsehas always accepted it as an alias forreadonly.Scope
tmux-mcponly.crates/libtmux/docs/public-api.txtrecords thelibtmuxsurface and is untouched.