Repository navigation
fix(mcp)!: bound validation work before tool dispatch - #7905
Conversation
Use the pinned SDK's element admission for eager and deferred MCP servers. Share a finite configurable default across HTTP, stdio and saved setup env. Normalize the SDK refusal with the configured limit and preserve canonical schemas, ordinary diagnostics and admitted input values. Fixes #7882 BREAKING CHANGE: MCP arguments now default to at most 65,536 combined array elements and object members. Select REA_MCP_MAX_INPUT_ELEMENTS at launch for workloads requiring a different finite allowance. Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The reviewed changes appear safe to merge. SummaryAdds a finite MCP input allowance before schema validation and tool execution. The latest changes share a 65,536-element allowance across verification workflows while leaving the 1,024-element production default unchanged.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Tool arguments"] --> B["SDK counts elements and members"]
B -->|"Over selected allowance"| C["Return bounded transport error"]
B -->|"Within allowance"| D["Load runtime if deferred"]
D --> E["Check canonical schema"]
E -->|"Valid input"| F["Run tool"]
Reviews (7) · Last reviewed commit: "test(mcp): preserve trace parity coverag..." · Reviewed by Greptile |
Missing required fields multiply diagnostics without increasing object member counts. A bounded canonical probe produced 16,384 issues and about 26 MiB heapUsed delta from 1,024 empty Evidence objects. Lower the default allowance to 16,384 combined elements, preserve selected operator allowances, and verify rejection before structured validation. Check the calibration refusal's error kind before considering larger input. Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62d3b90388
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Set the default allowance to 1,024 elements using measured missing-field expansion rather than extrapolating a scalar array measurement. Exercise the actual build_call_path HTTP registration at its exact admitted boundary and one element beyond, including subsequent successful requests. Select finite fixture allowances in existing SQLite, portable capture, native matching and deep trace tests so their stronger downstream capacity, identity and validation assertions continue to execute. BREAKING CHANGE: MCP defaults to 1,024 combined array elements and object members per tool call. Select REA_MCP_MAX_INPUT_ELEMENTS and restart for larger inline workloads, or use retained/file selectors where available. Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
Complete-Evidence workflow fixtures need an explicit input allowance after the new transport default. Own that finite selection in the application and file-scoped MCP harnesses, preserve caller overrides, and share the same selection with their direct stdio scenarios. Keep depth and configuration regressions reaching their original producing boundaries. Preserve their existing assertions and leave dedicated admission and real TShark default-policy proof servers on the production default. Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
The native Apple verifier also resends complete inventory Evidence through its independent stdio harness. Move the finite verification environment to a dependency-free JS/TS module and use it in that harness as well as the existing workflow fixtures. Remove the superseded TypeScript-only owner. Keep production admission at 1,024 elements. Verify the real portable ZIP workflow, unchanged source bytes, paging, and shared fixture cleanup locally; the existing native Apple scenario continues to own macOS verification. Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
Select the shared finite conformance allowance in the independent stdio identity fixture. Its complete inline operands must reach the existing identity and integrity checks, including retained and mixed source forms. Keep all original assertions and production admission unchanged. Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
Select the shared finite inline-Evidence allowance in the trace comparison fixture so the original 200-event diagnostic reaches its domain validation. Keep production admission and all existing parity assertions unchanged. Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
morluto#7905 bounds MCP arguments at 1,024 elements by default, which two inline ESP flash-dump inventories exceed, so the ESP flash comparison test now compares the Evidence its session retained. morluto#7981 reports an input issue at its field path with zod's reason, so the Rizin decoder-input refusal is `invalid_format` at `asm_cpu`.
This branch carried morluto#7498's pre-squash commits, which upstream merged as squash 64196b0 with maintainer commits. The merge therefore used the absorbed prototype ea2b386 as its base, so the result differs from main only in this branch's own changes; git's own base reported every morluto#7498 region as a conflict. Adaptations to main: - morluto#8054 describes formats in one registry. The esp-flash-image descriptor in artifactFormats.ts now owns the reader construction, admission, classification retention, container role, extraction and reader limitation that this branch had spread over createArtifactReader, classify, ArtifactGraphConstruction, ArtifactExtraction and the inventory reader. EspFlashAdmission joins ArtifactFormatAdmission. - morluto#7498 moved the ESP image fixture to tests/fixtures/espImage.ts; the ESP flash tests import it from there. - morluto#7481's vocabulary guard expected every caller-selected format hint to name an executable target; an ESP flash dump is read as an archive. - morluto#7905 bounds MCP arguments at 1,024 elements by default, which the inline flash-dump inventories exceed, so the ESP flash comparison test compares the Evidence its session retained.
Summary
Fixes #7882. On tested main, a 16,542-byte malformed argument object produced 8,192 diagnostics and a 556,706-byte MCP error. Reuse SDK 2.3.1's existing admission counter before validation expands those diagnostics.
REA_MCP_MAX_INPUT_ELEMENTSselects another positive decimal safe-integer allowance at startup; invalid values fail explicitly. Setup forwards an explicitly selected value through its existing approval/backup workflow.resource_constraint/transportwithreported_limits.max_input_elements. Validation, lazy runtime loading and tool execution do not start for them; no complete input count is claimed.Breaking change: larger previously valid inline MCP calls require a higher finite allowance and restart, or retained/file selectors where supported. Input is never silently truncated. This is a per-call transport policy, not an exact heap guarantee or complete denial-of-service protection.
Scope: repair existing admission; no new target execution, mutation, exposure or configuration-writing authority.
Expected effects:
Validation performed
Final local head:
c762ffaee, based on main37827af59. Production behavior is unchanged from655d83965; subsequent commits migrate verification fixtures to explicit finite allowances while preserving their original assertions. Default-policy HTTP/native proofs keep the production allowance.npm run verify:packagepassed: actual archive/install, CLI analysis/Evidence, setup/backup/readback/uninstall, idempotence, failure recovery, extracted plugin MCP, 231 tools / 6 prompts, and verified cleanup. 301.002 s elapsed / 330.403 s CPU / 1335.7 MiB sampled family RSS.npm run check:ci:fastpassed: types, lint, format and module boundaries — 53.927 s / 84.873 s CPU / 5365.5 MiB RSS.npm run docs:checkpassed, including 9 tests — 4.047 s / 4.732 s CPU / 522.9 MiB.5db72c85f: 21,421 source tests passed / 15 skipped, all four SQLite Node combinations and four native package platforms passed. Real macOS CLI/MCP validated 6 bundles across directory/ZIP/DMG, detached the DMG and preserved Mach-O bytes. Its previous inventory-admission failure was repaired in the shared artifact verifier. Current-head checks qualify the final fixture follow-up.Resource evidence and limits
Missing fields amplify too: direct canonical validation of 1,024 empty Evidence objects produced 16,384 issues / about 26 MiB heapUsed delta before formatting. This drove the conservative default. Actual bulk validation is exercised through
build_call_path;find_changed_behavioralready authenticates items individually, so its advertised schema alone does not establish public-path amplification.build_call_path, default boundaryLocal runners use two CPUs and a 3-GiB Node heap allowance. HTTP/stdio/TShark capacity-proof servers explicitly use that heap allowance; other fixture/verifier children retain their existing limits. The input-capacity and portable-artifact proof runs additionally use a 2-GiB/120-s family guard; other recorded local gates use a 12-GiB/1200-s family guard. One mixed-file run triggered that guard and was stopped; separated proof runs passed. RSS is sampled every 50 ms and can count shared pages twice.
No overall speedup claim; model-token costs are unmeasured. Processes are fresh, but filesystem/code-cache warmth is uncontrolled. Catalog size remains 3,804,043 bytes; client schema-compilation cost is unchanged. Ordinary admitted errors can still be large. Native local proof is Linux; CI establishes the stated platform coverage, rather than full licensed Hopper GUI behavior.
Full measurements, commands and executed limitations: validation record.
Author readiness
Human owner: @gensokyo-dev
Before merge