Skip to content

fix(mcp): QoL — @-path guard, cache-handle errors, recommended_max_plans#14

Merged
lionelle merged 1 commit into
mainfrom
fix/mcp-qol
Jun 10, 2026
Merged

fix(mcp): QoL — @-path guard, cache-handle errors, recommended_max_plans#14
lionelle merged 1 commit into
mainfrom
fix/mcp-qol

Conversation

@lionelle

@lionelle lionelle commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Third and final phase of the MCP tester feedback fixes — the quality-of-life issues (5–8). Independent of #12/#13 (different files).

Issue 5 — yaml_content="@/path" silently hangs

A leading @ is a reserved YAML indicator and almost always means the caller mistook yaml_content for an at-path reference. parse_yaml_source now fast-fails with a directive error pointing at yaml_path / degree_id, instead of handing it to the parser (which stalled the full MCP timeout).

Issue 6 — intermittent cache_yaml timeout

YamlCache::insert ran an O(n) expiry sweep on every write while holding the cache mutex. It now sweeps only once the cache passes a soft threshold (64 entries), so the common-case write holds the lock briefly while growth is still bounded.

Issue 7 — vague expired/unknown cache-handle error

Added YamlCache::lookup + CacheLookup so an expired handle (valid but aged out → "re-cache") reports distinctly from an unknown one (typo / server restarted). Also fixed the cache_yaml description's stale "about 1 hour" TTL → 24 h (the constant has been 24 h and is test-guarded).

Issue 8 — no machine-readable plan-count guidance

AnalysisResponse gains recommended_max_plans — the structured companion to the truncation follow-up: None for a full-population run, the current cap when complexity is CV-stable (widening won't change the conclusions), else the doubled-and-capped next value. Extracted shared complexity_cv / next_max_plans / recommend_max_plans helpers (DRY with the existing follow-up prose) plus a build_response_notes helper.

Verification

  • New tests: @-prefix rejection (+ leading-whitespace), cache lookup unknown/expired/hit, and recommended_max_plans tracking truncation on a select-1-of-4 degree (Some when capped at 1, None at 50).
  • cargo fmt --check, cargo clippy --all-targets --all-features -D warnings, a clean cargo doc under RUSTFLAGS/RUSTDOCFLAGS=-D warnings, and cargo test --all-features all green.

🤖 Generated with Claude Code

Issues 5–8 from the MCP tester report (quality-of-life):

- 5: parse_yaml_source fast-fails when yaml_content starts with `@` (a caller
  mistaking it for an at-path reference). A leading `@` is a reserved YAML
  indicator and previously stalled the parser for the full MCP timeout; now it
  returns a directive error pointing at yaml_path / degree_id.
- 6: YamlCache::insert only runs the O(n) expiry sweep once the cache passes a
  soft threshold (64) instead of on every write, so the write lock is held
  briefly in the common case (the intermittent cache_yaml timeouts).
- 7: add YamlCache::lookup + CacheLookup so an aged-out handle reports
  "expired" distinctly from a never-minted "unknown" one (with re-cache hints);
  fix the cache_yaml description's stale "about 1 hour" TTL → 24 h.
- 8: AnalysisResponse gains recommended_max_plans — the machine-readable
  companion to the truncation followup (None for full population, the current
  cap when CV-stable, else the doubled-and-capped next). Extracted shared
  complexity_cv / next_max_plans / recommend_max_plans helpers (DRY with the
  followup path) and a build_response_notes helper.

Tests: @-prefix rejection, cache lookup unknown/expired/hit, and
recommended_max_plans tracking truncation on a select-1-of-4 degree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lionelle lionelle merged commit 6845949 into main Jun 10, 2026
4 checks passed
@lionelle lionelle deleted the fix/mcp-qol branch June 10, 2026 00:12
@lionelle lionelle mentioned this pull request Jun 10, 2026
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