Diff-apply hardening + drop dead mcp.allow_motion#9
Merged
Conversation
Hardware-motion safety is now the host's per-session consent gate, not a persistent toggle. Drops the allow_motion field + its (tautological) test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
str.splitlines also breaks on \f/\x85/U+2028 — characters that can sit inside string literals — so the apply path's rejoin rewrote them into the dominant terminator, corrupting lines the diff never touched. Both the diff and the source now split on LF/CRLF/CR only. parse_unified_diff previously ignored the @@ header line counts, so a trailing blank line in the diff text became a phantom empty-context line that spuriously rejected a clean diff. Counts (defaulting to 1) now bound the hunk body: stray blank lines beyond them are tolerated, anything else errors. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M7tEqGhaTqJV6ZxCXgMpFU
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.
Fixes from the MCP-stack adversarial review (waldoctl side):
parse_unified_diff/_apply_unified_diffused barestr.splitlines(), which also breaks on\f/\x85/U+2028 — the rejoin rewrote them into the dominant terminator, silently corrupting string literals on lines the diff never touched (a Python literal split across two physical lines is a SyntaxError). Both now split on LF/CRLF/CR only.@@", so a trailing blank line in LLM-emitted diff text became an empty context line that spuriously rejected a clean diff. The@@header counts (defaulting to 1) now bound the hunk body; stray blank lines beyond them are tolerated, anything else errors.mcp.allow_motionwas documented as "consulted on every motion tool call" but nothing reads it — superseded by per-session GUI consent in Waldo-Commander. Removed (cherry-picked from feat/mcp-server).All red-first regression tests in
tests/test_programs.py; suite 87/87. WC-mcp suites (249 non-browser + 27 browser) ran green against this branch.Release intent: tag v0.6.0 after merge (field removal = breaking pre-1.0 minor). WC PR Jepson2k/Waldo-Commander#17 will pin it.
🤖 Generated with Claude Code
https://claude.ai/code/session_01M7tEqGhaTqJV6ZxCXgMpFU