Skip to content

fix: negotiate supported protocol and reject raw JSON controls - #3

Merged
okgrit merged 2 commits into
mainfrom
fix/channel-negotiation-20261024
Oct 24, 2026
Merged

okgrit merged 2 commits into
mainfrom
fix/channel-negotiation-20261024

Conversation

@okgrit

@okgrit okgrit commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Two first-use checks gave misleading success responses:

  • initialize echoed any requested protocol string, including 2099-12-31. It now reports the implemented 2024-11-05 revision, following MCP version negotiation.
  • The shell client's raw JSON-control check used locale-sensitive string ordering. A response containing an unescaped newline could be accepted as a successful send. It now compares the numeric character value, preserving valid DEL, Unicode and escaped controls. The shared string reader also rejects malformed raw controls when reading replies.

The change stays within five files. Original test/helper ASTs and all 26 other tracked files are preserved.

Validation on follow-up bb4ee3c9dcd7bd030eff65f0e37e4c8e50c0a1cf:

  • Negotiation regression before the runtime fix: 5 failed / 7 passed; corrected channel suite: 34 passed.
  • New shell cases before the shell fix: 3 failed / 7 passed; only required negative cases failed.
  • Original and negotiation-only trees reproduced the same shell failure under the same inherited locale; both passed that case with explicit C locale. The fix changes the comparison, with no locale override.
  • Final native Linux Python 3.14.7 run: 351 passed, 37 skipped; Ruff and Bash syntax passed.
  • Independent source reviews approved the negotiation and shell corrections. A focused follow-up review approved the signed-byte range adjustment; its macOS CI condition is now met.
  • Final tracked-tree and reachable-history Gitleaks scans returned no findings. Three pre-existing source-pattern matches were retained with local test/character-allowlist role evidence.
  • A bounded Python Semgrep rule found no issues across nine runtime files; this does not cover Bash semantics or constitute a security audit.

The first head (c79c99d0) passed hosted Linux/Windows checks but failed three valid-Unicode cases on macOS. The follow-up rejects only nonnegative numeric values 0–31, preserving signed high-byte representations; its native Linux suite again passed 351 tests with 37 skips. A fresh base control on ca337264 passed the hosted matrix. Signed-byte handling is the supported explanation under review, not a directly logged host printf value. Current-head push and PR CI passed all six Linux/macOS/Windows × Python 3.10/3.13 jobs in each run, and CodeQL passed. The PR macOS 3.13 log reports 352 passed and 36 skipped. CodeRabbit's green check represents a skipped automatic review, not approval. These are synthetic protocol/HTTP tests, not a native ChatGPT/Claude trial. Bash 3.2-specific behavior and broader parser limitations need separate evidence; no universal compatibility or handshake-free MCP support is claimed.

Report the implemented MCP revision for unsupported requests. Compare raw JSON control characters numerically so shell response validation does not depend on collation. Preserve existing tests and valid Unicode/DEL values; no native client acceptance claim.
Copilot AI balanced review requested due to automatic review settings October 24, 2026 22:17
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d3f42031-f77f-4962-a6e8-620dc5a5e2cb
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fixes have relevant regression coverage, match the documented behavior, and have no identified blocking issues.

No open issues 🎉

What changed in this PR

This PR corrects protocol negotiation in the channel server and raw JSON control-character validation in the shell client.

Changes:

  • Report the implemented MCP 2024-11-05 revision instead of echoing unsupported versions.
  • Use numeric character checks to reject raw controls while preserving valid JSON strings.
  • Add regression coverage and document protocol compatibility limits.
File Description
tests/​test_scripts.py Tests raw-control rejection and valid string acceptance.
tests/​test_channel.py Tests protocol negotiation across supported, unsupported, and malformed values.
src/​dotline/​channel.py Returns the implemented MCP protocol revision.
README.md Documents version fallback and lack of handshake-free support.
clients/​dotline.sh Replaces locale-sensitive ordering with numeric control-character validation.

Review effort: Balanced

Reject only the nonnegative C0 control range. Keep valid multibyte values when an older shell represents high bytes as signed values. Existing tests remain unchanged; final hosted macOS checks are still required.
@okgrit
okgrit merged commit 4dbfff5 into main Oct 24, 2026
16 checks passed
@okgrit
okgrit deleted the fix/channel-negotiation-20261024 branch October 24, 2026 22:35
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.

2 participants