Skip to content

fix: validate dynamic schemas without code generation in AOT builds - #182856

Merged
steipete merged 2 commits into
mainfrom
fix/aot-dynamic-validation
Oct 24, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/aot-dynamic-validation

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes dynamic MCP schema validation depending on runtime JavaScript generation in AOT standalone hosts, and avoids generating unused checker source for plugin configuration and tool arguments in those hosts.

User Impact

Node, Bun and JIT standalone hosts keep their compiled validators. AOT hosts select a code-generation-free checker at each existing validation owner. MCP schemas retain draft-07/draft-2020-12 behavior, known-format policy, registered resources, relative references, encoded pointers and per-provider isolation. References identify schema resources and never trigger network requests.

AOT MCP validation requires actual input properties for __proto__, constructor and prototype; inherited JavaScript prototype members do not satisfy those requirements. This accounts for five documented legacy corpus differences. No new setting or dependency is introduced.

Why This Change Was Made

AOT is a runtime profile, not a reason to slow down ordinary Node/Bun validation. The existing owners select their engine once when preparing a validator and retain their caches, defaults, coercion and diagnostics. A small shared walker owns fresh per-value evaluation state; MCP resource preparation owns reference registration and dialect normalization.

The runtime-profile fact moves to a bootstrap-only module, reexported by the diagnostic owner. Reading the executing image's compiler-installed fact avoids pulling CLI filesystem discovery into validation. Build/sidecar diagnostics retain their existing owner. This preserves the AOT plugin, Code Mode and QA execution enabled by #182818, including its once-per-feature notices and actual-error guidance. The standalone builder already sets Zod jitless before schema creation; that ordering is preserved. The proposed bundled-plugin static registry was dropped because it failed the startup budget.

Evidence

  • Initial CI caught two metadata omissions: the new root module was missing from the duplicate-scan inventory, and the shortened helper retained a stale max-lines exception. The two-line repair adds scan coverage and removes the exception; both original failing guard entrypoints now pass. No runtime behavior or test threshold changes.
  • After integration with the runtime-profile owner, 112 selected owner/caller tests passed in 93.39s, including real Node Code Mode, fetched CJS/TypeScript plugins and QA expressions. The AOT probe closure has 777 unchanged executable inputs (one removed lint comment); the compiled proof below remains applicable.
  • 145 owning/sibling tests passed in 17.73s with pnpm test <files> --maxWorkers=1; 29 MCP caller tests passed in 66.08s. After extracting unchanged keyword helpers, 77 affected tests passed in 8.71s. Both profiles cover code-generation denial, references, formats/defaults, coercion and independent cached checks.
  • Actual MCP-owner corpus: 1,696 matching draft-07 outcomes plus the five prototype-policy differences above, and 1,246 matching draft-2020-12 outcomes. No additional candidate setup failures. Unsupported/unregistered external-resource groups remain outside the synchronous provider contract.
  • Final-source small AOT probes (under 0.9 MB emitted JS): candidate passes all 11 fixture groups with zero Function-constructor calls both normally and with string code generation denied. Baseline passes 9/11 normally (18 Function calls) and 4/11 when hardened (7 calls). Includes legacy anchors, ambiguous IDs, resource replacement, encoded references, plugin defaults and tool coercion. No full-application AOT build or interpreter-tripwire claim.
  • Targeted core/script/test/QA types, type-aware source/test lint and format pass after profile integration. Earlier unchanged-input wrapper-import closure and assertion/file-size ratchets passed; fresh Codex review covers the final implementation. The ordinary build before the mechanical keyword extraction completed in 463.73s, including 100 plugins and SDK exports; affected tests/types are rerun after extraction. It reports unchanged UI CSS budget overages (296.5 KiB gzip vs 296.3; 1558.7 KiB raw vs 1558.1); these are retained, not waived or increased.

Performance workload: scripts/bench-dynamic-validators.mts, five interleaved fresh baseline/candidate processes per fixture and runtime, each with five warm samples. The table gives CPU median (p95), with warm costs in ns. Node and Bun use compiled validation; AOT uses the profile-selected checker.

Host / flow Baseline through first check, ms Candidate, ms Baseline warm, ns Candidate warm, ns
node / mcp 19.552 (20.235) 19.742 (21.370) 78.739 (82.080) 79.951 (80.599)
node / plugin 13.104 (16.645) 13.505 (15.608) 442.740 (505.470) 441.380 (473.870)
node / llm 6.921 (7.258) 7.594 (8.273) 3405.350 (3633.380) 3422.030 (3466.770)
node / llm-coerce 7.200 (16.043) 7.721 (8.475) 3497.190 (4814.400) 3491.150 (3695.190)
bun / mcp 20.147 (35.709) 20.791 (24.686) 76.975 (85.144) 75.157 (76.574)
bun / plugin 8.213 (8.530) 6.854 (8.571) 421.020 (438.840) 408.650 (443.760)
bun / llm 7.250 (8.171) 8.018 (9.281) 2600.880 (2685.670) 2506.370 (2600.370)
bun / llm-coerce 6.886 (7.789) 7.468 (9.195) 2740.060 (2825.940) 2736.020 (3289.320)
aot / mcp 2.562 (10.371) 1.730 (5.521) 607.670 (619.370) 11513.990 (11654.020)
aot / plugin 1.658 (6.461) 1.601 (1.830) 2912.980 (3058.030) 2914.850 (3594.810)
aot / llm 0.688 (1.653) 3.885 (5.732) 9737.490 (10735.900) 9376.410 (9800.040)
aot / llm-coerce 0.696 (1.319) 0.485 (5.551) 9321.360 (10746.000) 9219.000 (9602.400)

The MCP Node warm median changes from 78.739 to 79.951 ns; Bun improves from 76.975 to 75.157 ns. The compiled warm requirement holds. The AOT MCP checker is approximately 19× slower on repeated calls than generated Ajv, while avoiding runtime code generation; this is the accepted profile-specific tradeoff. Bun tool-validator import CPU rises 3.708→4.594 ms. AOT tool cold samples are bimodal and include a 0.688→3.885 ms median through-first increase. The full adverse cells below are accepted and disclosed; this is not a universal performance win or a claim that wall-time tails improved.

Timing entries were frozen before the mechanical keyword-owner extraction. AST comparisons confirm unchanged moved function bodies and Set initializers; the added module wrapper was not separately timed. Final-source correctness/corpus/AOT probes and the affected tests were rerun after extraction. Raw sample ranges and provenance are retained in the task evidence.

Every observed ≥20% median or p95 regression

Numbers retain the metric's unit (Ms or Ns); no outlier was removed.

Host / flow / metric Statistic Before After Change
bun / llm / importCpuMs median 3.708 4.594 +23.9%
aot / mcp / warmCpuNs median 607.670 11513.990 +1794.8%
aot / mcp / warmWallNs median 608.387 11557.896 +1799.8%
aot / llm / importCpuMs median 0.136 0.925 +580.1%
aot / llm / importWallMs median 0.139 2.255 +1517.3%
aot / llm / setupCpuMs median 0.003 0.005 +66.7%
aot / llm / setupWallMs median 0.003 0.005 +44.9%
aot / llm / throughFirstCpuMs median 0.688 3.885 +464.7%
aot / llm / throughFirstWallMs median 0.692 8.884 +1183.0%
aot / llm-coerce / importCpuMs median 0.133 0.171 +28.6%
aot / llm-coerce / importWallMs median 0.136 0.173 +27.3%
bun / llm / importCpuMs p95 4.087 6.299 +54.1%
bun / llm / importWallMs p95 3.577 5.053 +41.3%
bun / llm-coerce / importCpuMs p95 3.956 5.264 +33.1%
bun / llm-coerce / importWallMs p95 3.202 4.905 +53.2%
bun / llm-coerce / warmWallNs p95 2488.384 3337.779 +34.1%
aot / mcp / warmCpuNs p95 619.370 11654.020 +1781.6%
aot / mcp / warmWallNs p95 622.751 11698.217 +1778.5%
aot / plugin / warmWallNs p95 3840.400 4675.339 +21.7%
aot / llm / importCpuMs p95 0.261 1.589 +508.8%
aot / llm / importWallMs p95 0.306 3.518 +1049.5%
aot / llm / setupCpuMs p95 0.005 0.008 +60.0%
aot / llm / setupWallMs p95 0.005 0.008 +57.4%
aot / llm / throughFirstCpuMs p95 1.653 5.732 +246.8%
aot / llm / throughFirstWallMs p95 2.395 14.566 +508.2%
aot / llm-coerce / importCpuMs p95 0.257 1.440 +460.3%
aot / llm-coerce / importWallMs p95 0.261 5.998 +2198.1%
aot / llm-coerce / setupCpuMs p95 0.007 0.010 +42.9%
aot / llm-coerce / setupWallMs p95 0.007 0.010 +42.2%
aot / llm-coerce / throughFirstCpuMs p95 1.319 5.551 +320.8%
aot / llm-coerce / throughFirstWallMs p95 1.323 17.842 +1249.1%

Exact-head CI

CI run 40130521726, attempt 1, tested 80e9ab0d980e03aeac0d66f17344a23c587190f8: 162 successful jobs, 19 skipped, six failed test jobs and their aggregate. Both repaired guard jobs, security, iOS screenshots, paired-worker lifecycle and wrapper overlap passed. CI remains failed; the six remaining jobs are independently attributed below.

Remaining failure Baseline evidence
Hooks CLI newline expectation Same failure on clean main ae180dc0ad66; 30.43s total.
Sandbox explain expects agent/session mismatch but receives Unknown agent alpha Same failure on clean main ae180dc0ad66; 28.17s total. The unchanged owner checks the unconfigured agent first.
Two Codex media request expectations omit features.reasoning_effort_override Unchanged producer adds it unconditionally, predating this change in #182397; source-proven expectation drift.
Discovered image model reports Unknown model: opencode/live-only-model Same scheduled-main failure in run 40090161405; identical test and executable owner code. Intervening edits remove only types.
Delayed session-catalog source expectation Same scheduled-main failure in run 40090161405; identical test/owner blobs.
Restored wake count and widget restart revision Both failures reproduced on clean main 20efafbed079: 483.80s including ordinary build, and 75.92s. Ten relevant test/owner/helper blobs match the tested merge.

The earlier paired-worker failure did not recur on this head. Its isolated and two-case main replays passed; neither is presented as a repair or matching-failure proof. The current CI merge contains exactly the 32 reviewed changed paths.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 24, 2026 20:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T20:21:14.634908Z 6a5d0fd Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts agents Agent runtime and tooling extensions: qa-lab size: XL labels Oct 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR selects code-generation-free dynamic schema validation in AOT hosts while retaining compiled validators on Node, Bun, and JIT hosts.

Example: An AOT MCP client receives an object schema requiring an email-valued name.

  • Before: Preparing its validator depends on runtime Function construction and fails when string code generation is denied.
  • After: The interpreted validator accepts name=[email protected] and rejects name=invalid without constructing a Function.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The source review supports the implementation and accepted product direction, while proof remains bounded to validation owners and CI disposition is incomplete.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its body records actual-owner AOT probes covering references, formats, defaults, coercion, and code-generation denial, alongside supporting tests and corpus comparisons.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Dynamic MCP schema preparation depends on runtime JavaScript generation in AOT hosts.
Reason: The maintainer-authored direction fixes an owned runtime limitation, introduces no setting or dependency, and explicitly accepts the measured profile-specific costs.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a remaining AOT validation gap, and no definite introduced defect was found. Exact-head CI remains unresolved, including a sandbox CLI failure without matching baseline evidence.

Priority: P2
Reviewed head: 80e9ab0d980e03aeac0d66f17344a23c587190f8

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied owner-level AOT probes do not qualify the full shipped standalone CLI or Gateway.
Agent review details

How this fits together

MCP results, plugin configuration, and model tool arguments enter their existing validation owners; the runtime profile selects a checker, and those owners return validated values or diagnostics.

flowchart TD
  A[Dynamic schemas and values] --> B[Existing validation owners]
  B --> C[Runtime profile]
  C --> D[Compiled validators]
  C --> E[Interpreted checks]
  D --> F[Validated values or diagnostics]
  E --> F
Loading

Technical review

Best possible solution:

Keep profile selection at the existing validation owners, preserve their schema semantics, and settle the remaining CI attribution before landing.

Do we have a high-confidence way to reproduce the issue?

Current-main source still prepares dynamic MCP validators through Ajv, and the supplied baseline/candidate AOT probes report the code-generation dependency; this read-only review ran no target code.

Is this the best way to solve the issue?

The implementation uses the existing validation owners and TypeBox evaluator, preserves compiled paths for ordinary hosts, and keeps MCP-specific resource and dialect policy separate from the generic checker.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 721cdadccb93.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +507, Tests +421, Docs +17, Config +9, Other +222. Total +1176 across 32 files. Added test files: 4.

View PR surface stats
Area Files Added Removed Net
Source 10 713 206 +507
Tests 9 445 24 +421
Docs 3 18 1 +17
Config 3 9 0 +9
Generated 0 0 0 0
Other 7 224 2 +222
Total 32 1409 233 +1176

Labels

Label changes:

  • add P2: This repairs dynamic validation in the AOT runtime profile while preserving the ordinary Node/Bun path; no urgent stable-release regression is established.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: This repairs dynamic validation in the AOT runtime profile while preserving the ordinary Node/Bun path; no urgent stable-release regression is established.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Establish matching baseline evidence for the sandbox CLI JSON failure before choosing its CI disposition.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 24, 2026, 4:54 PM ET / 20:54 UTC.

@steipete
steipete merged commit 4a38dbd into main Oct 24, 2026
269 of 279 checks passed
@steipete
steipete deleted the fix/aot-dynamic-validation branch October 24, 2026 21:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

steipete added a commit that referenced this pull request Oct 24, 2026
Consolidate command-name variants after state-read snapshotting and byte accounting moved to generic owners. Retain nested Unicode, arrays, numeric/boolean fields, prepared and queued mutation, and ACP batch coverage.

Remove 17 redundant cases and 215 net test lines across two suites. No production behavior changes. Focused baseline and candidate suites pass; static diagnostics add no findings.

The unrelated PostgreSQL interactive-setup fixture failure in CI run 40135535259 is inherited from #182856 and attributed by the campaign coordinator; the separate repair owner is handling it.
steipete added a commit that referenced this pull request Oct 24, 2026
Batch source metadata at the existing publication owner instead of issuing one UPSERT per source. Bound statements to 128 distinct keys and about 64 KiB, deduplicate repeated keys with final-header semantics, and preserve the existing transaction, tombstone checks, and chunk/vector ordering.

Source-header statements fall from 100 to 1 and from 129 to 2. SQLite owner tests and native PostgreSQL owner/publication tests pass. Exact-head CI type, lint, contract, and architecture jobs pass; seven unrelated onboarding fixture failures are attributed to #182856 and owned separately. No latency improvement is claimed.
steipete added a commit that referenced this pull request Oct 24, 2026
…ve-setup source runtime (#182990)

#182856 made the launcher import standalone-runtime-profile.mjs, but the interactive-setup integration fixture's createSourceRuntime copy list omitted it, so the onboarding/setup/crestodian child exited with a missing module before reporting ready (PostgreSQL conformance shard 2 on unrelated PRs). Adds the file to the shared fixture's copy list; all three SQLite handoffs pass again.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…penclaw#182856)

* fix(validation): validate dynamic schemas without codegen in AOT

* fix(ci): update dynamic validator guard inventories
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
Consolidate command-name variants after state-read snapshotting and byte accounting moved to generic owners. Retain nested Unicode, arrays, numeric/boolean fields, prepared and queued mutation, and ACP batch coverage.

Remove 17 redundant cases and 215 net test lines across two suites. No production behavior changes. Focused baseline and candidate suites pass; static diagnostics add no findings.

The unrelated PostgreSQL interactive-setup fixture failure in CI run 40135535259 is inherited from openclaw#182856 and attributed by the campaign coordinator; the separate repair owner is handling it.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…w#182935)

Batch source metadata at the existing publication owner instead of issuing one UPSERT per source. Bound statements to 128 distinct keys and about 64 KiB, deduplicate repeated keys with final-header semantics, and preserve the existing transaction, tombstone checks, and chunk/vector ordering.

Source-header statements fall from 100 to 1 and from 129 to 2. SQLite owner tests and native PostgreSQL owner/publication tests pass. Exact-head CI type, lint, contract, and architecture jobs pass; seven unrelated onboarding fixture failures are attributed to openclaw#182856 and owned separately. No latency improvement is claimed.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…ve-setup source runtime (openclaw#182990)

openclaw#182856 made the launcher import standalone-runtime-profile.mjs, but the interactive-setup integration fixture's createSourceRuntime copy list omitted it, so the onboarding/setup/crestodian child exited with a missing module before reporting ready (PostgreSQL conformance shard 2 on unrelated PRs). Adds the file to the shared fixture's copy list; all three SQLite handoffs pass again.
steipete added a commit that referenced this pull request Nov 5, 2026
Fixtures that stage package-root .mjs launcher modules kept hand-maintained copy lists, so a new sibling import (#182306, #182856) broke integration shards instead of a fast test. Fixtures now compute the closure of their entry modules, and a unit test checks the scanner against a module parser and that packaging includes every sibling import.
steipete added a commit that referenced this pull request Nov 5, 2026
…#188338)

Fixtures that staged package-root launcher modules kept about ten hand-maintained copy lists, so a new sibling import (#182306, #182856) broke integration shards instead of a fast test. Fixtures now name only their entry modules, and collectPackageRootModules computes the closure. vitestWorkerRuntimeAssets moved out of vitest-worker-declarations into the new module, so the trusted PR-wrapper inventory is unchanged. A unit test checks the scanner against an acorn parse and checks that package.json files includes every sibling import of each packaged root module. The docker harness also stages release-context.mjs (#192806). The test-line ceiling is raised by the exact measured gap: +25 lines for this coverage plus 49 lines of inherited debt.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…openclaw#188338)

Fixtures that staged package-root launcher modules kept about ten hand-maintained copy lists, so a new sibling import (openclaw#182306, openclaw#182856) broke integration shards instead of a fast test. Fixtures now name only their entry modules, and collectPackageRootModules computes the closure. vitestWorkerRuntimeAssets moved out of vitest-worker-declarations into the new module, so the trusted PR-wrapper inventory is unchanged. A unit test checks the scanner against an acorn parse and checks that package.json files includes every sibling import of each packaged root module. The docker harness also stages release-context.mjs (openclaw#192806). The test-line ceiling is raised by the exact measured gap: +25 lines for this coverage plus 49 lines of inherited debt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: qa-lab P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant