Repository navigation
fix(validators): validate fixed schemas without runtime code generation - #182575
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
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. |
|
|
Codex review: needs changes before merge. What this changesThis PR replaces runtime compilation of fixed schemas with generated JavaScript predicates while retaining canonical schemas and validation diagnostics. Example: Validate {"type":"req","id":"request-1","method":"health"}.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 3 items remain Keep open: the maintainer-approved precompilation change is useful, but incomplete caller and extraction cutovers break tests and maintainer tooling, and a new schema export breaks the source-contract check. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway, worker, Codex, and other fixed-schema owners receive untrusted values and return typed values or diagnostics; build-time generators now supply their predicates. flowchart LR
A[Canonical schemas] --> B[Build-time generators]
B --> C[Shared standalone emitter]
C --> D[Generated predicates]
D --> E[Existing validation owners]
A --> E
E --> F[Typed values or diagnostics]
Technical reviewBest possible solution: Keep the shared emitter and existing validation owners, complete both remaining compiler-consumer migrations, ship the wrapper’s full import closure, and distinguish the registry schema export. Do we have a high-confidence way to reproduce the issue? Current main visibly compiles fixed schemas at first use; exact-head CI independently reproduces the introduced missing-helper and extracted-wrapper failures, while this review ran no target code. Is this the best way to solve the issue? Generating predicates through the existing shared emitter is a coherent complete stage, and the owner accepted its measured performance costs; the remaining defects are missed consumers and packaging dependencies rather than a reason to redesign it. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1f67a66bbead. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 24, 2026, 8:39 AM ET / 12:39 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…on (openclaw#182575) * perf(validators): precompile fixed schema checks * fix(validators): complete fixed schema integration
What Problem This Solves
Gateway and other fixed-schema validation currently compile functions at runtime, repeating work known at build time and making validation depend on string code generation.
User Impact
Gateway messages, Codex app-server replies, model registry entries, themes, TypeSafe payloads, computer-use contracts, and participant identities keep their existing validation and diagnostics with checks generated during development/build. No protocol, configuration, or dependency changes are required.
Accepted tradeoffs: retaining the full Gateway validator namespace increases its probe bundle from 1.77 MB to 2.70 MB, while a two-check consumer shrinks from 1.11 MB to 0.81 MB. Measured total CPU through first checks rises 8.1% on Node, 5.1% on Bun, and 6.10 ms (26.1%) on default AOT. Some JIT and cold-start tail metrics also regress. I accept these bounded costs for removing runtime compilation and the measured 6.9–8.1× warmed AOT improvement; this is not a universal startup or JIT speedup claim.
Why This Change Was Made
One shared standalone emitter generates predicates from the canonical schemas. Gateway uses a tree-shakeable predicate pool; every caller of its private runtime compiler moves to generated guards and that compiler is removed. The existing owners retain prechecks, cold diagnostics, schema identity, and mutable last-error behavior. Codex also generates normalized diagnostic schema data instead of normalizing it on first use. CI checks generated freshness, and native protocol input tracking includes the generated JavaScript.
This follows the shared-emitter repair in #182373. Fixed schemas are the complete stage here; arbitrary fetched/plugin/MCP schemas remain outside this change. Zod's standalone bootstrap already configures jitless before creating schemas, so no global Node/Bun setting changes.
Evidence
pnpm test <files> --maxWorkers=1.pnpm buildpasses in 370.30 s, including 100 plugins and the production UI build. UI startup/chat size warnings reproduce on the exact base: gzip bytes 282,279→282,269 and 1,277,371→1,276,569. New-page gzip changes 767,138→767,249 with identical raw size, within its 797,395-byte budget. No budget was raised.712f7d2bfd73354de2d3cc681e7a3034a46e5689(same timeout and cleanup error). Codex feature-flag and hook-newline mismatches have unchanged test/owner source on main. These are tracked separately from the repaired compiler, naming, and extraction failures.Exact-Head CI Disposition
The repaired head
cd978b01cd9cad28362b47d492ae1668a7b83f61completed CI run 40097026999: 154 jobs pass, 17 skip, eight test jobs fail, followed by the failed aggregate gate. Security and PostgreSQL conformance pass. No CI rerun was requested.All eight failures are inherited: workflow CHECK-count expectations; Codex reasoning feature-flag expectation; directive replay timeout and catalog-loading expectation; live-only model lookup; hook newline expectation; cron timeout/cleanup; Goal retry conflicts; and the skill-worker fixture's immediate-completion assumption. Native inherited-failure admission retains each failed job, exact tested merge/base/head, unchanged causal inputs, and baseline logs or source-contract evidence. The workflow/test files have unrelated changed hunks; the two executed workflow steps and the complete failing assertion block are byte-identical, with those whole-file edits explicitly disclosed.
A clean main checkout at
8cab2fd3dfbbbcbd9a3a16239996f985fb7fca7breproduces the concurrent Goal retry failure (38 pass / four fail, 176.33 s). The skill-worker full-flow baseline instead fails earlier waiting for test-node inventory (502.84 s, including its required normal runtime build); this is not a matching full-flow reproduction. Its unchanged authoring fixture expectsokafter one wait, although the productionagent.waitcontract returns an immediatepending/queueresult. The existing handler contract tests pass on that clean main (two pass, 70.21 s) and assert the exact response observed in CI. Neighboring fixture paths already poll that valid pending state. The retained baseline setup/cleanup failure is not counted as passing proof.The final seven-file integration repair also completed independent Codex review without actionable findings. Local provisioning timeouts and inherited CI reds remain reported as failures; this PR requires the native inherited-failure landing exception.
Gateway workload, distributions, and accepted regressions
Exact baseline:
2a9740a251b464585d2519288143d7ba95d8f3ac. The committedscripts/bench-gateway-validators.mtsworkload checks positive/negative controls before timing. Five interleaved fresh-process pairs reverse order between pairs; warm checks use 20,000 warmup calls and five 100,000-call batches. Cold namespace and warm two-check consumers are separate. Acceptance requires identical validation behavior, removal of fixed runtime compilation, faster AOT checks, and investigation/disclosure of any regression above 20%.Cold namespace measurements
Milliseconds: median / p95 [min, max]. With five processes, p95 is the maximum. Whole-process values include runtime startup before the timed owner import.
Warm check CPU
Nanoseconds per check: median / p95 [min, max] across 25 batches.
Every median/p95 regression above 20%
The rows below retain every such cell in cold, first-check, and warm summaries. Full min/max ranges remain in the JSON summaries and tables above.
Warm default AOT CPU improves 6.91× for requests and 8.14× for host stats; acceleration-off improves 51.27× and 47.29×. Default AOT cold CPU increases 23.410→29.509 ms. Most of that shift is before owner import (11.283→15.487 ms); import CPU rises 9.698→10.153 ms while first-check medians improve. This identifies the component but does not establish noise or attribute it solely to checks. Initial AOT process launches take 770.6/843.3 ms, subsequent launches 25.7–55.7 ms; no sample was discarded. Shared-host load averaged 32–35 on 32 CPUs. The bounded cold and tail regressions above are explicitly accepted; no application startup improvement is claimed. Dynamic-RegExp warnings remain in schema/diagnostic helpers, so this does not claim entirely interpreter-free execution.