Skip to content

Diff-apply hardening + drop dead mcp.allow_motion#9

Merged
Jepson2k merged 2 commits into
mainfrom
fix/mcp-diff-hardening
Jul 9, 2026
Merged

Diff-apply hardening + drop dead mcp.allow_motion#9
Jepson2k merged 2 commits into
mainfrom
fix/mcp-diff-hardening

Conversation

@Jepson2k

@Jepson2k Jepson2k commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Fixes from the MCP-stack adversarial review (waldoctl side):

  • Exotic-separator corruption: parse_unified_diff / _apply_unified_diff used bare str.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.
  • Phantom trailing context: hunk extent was "everything until the next @@", 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.
  • Dead safety toggle: mcp.allow_motion was 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

Jepson2k and others added 2 commits July 8, 2026 20:20
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
@Jepson2k
Jepson2k merged commit bedefcf into main Jul 9, 2026
2 checks passed
@Jepson2k
Jepson2k deleted the fix/mcp-diff-hardening branch July 9, 2026 02:23
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