fix(mcp): QoL — @-path guard, cache-handle errors, recommended_max_plans#14
Merged
Conversation
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>
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.
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 hangsA leading
@is a reserved YAML indicator and almost always means the caller mistookyaml_contentfor an at-path reference.parse_yaml_sourcenow fast-fails with a directive error pointing atyaml_path/degree_id, instead of handing it to the parser (which stalled the full MCP timeout).Issue 6 — intermittent
cache_yamltimeoutYamlCache::insertran 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+CacheLookupso an expired handle (valid but aged out → "re-cache") reports distinctly from an unknown one (typo / server restarted). Also fixed thecache_yamldescription'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
AnalysisResponsegainsrecommended_max_plans— the structured companion to the truncation follow-up:Nonefor 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 sharedcomplexity_cv/next_max_plans/recommend_max_planshelpers (DRY with the existing follow-up prose) plus abuild_response_noteshelper.Verification
@-prefix rejection (+ leading-whitespace), cachelookupunknown/expired/hit, andrecommended_max_planstracking truncation on a select-1-of-4 degree (Somewhen capped at 1,Noneat 50).cargo fmt --check,cargo clippy --all-targets --all-features -D warnings, a cleancargo docunderRUSTFLAGS/RUSTDOCFLAGS=-D warnings, andcargo test --all-featuresall green.🤖 Generated with Claude Code