Repository navigation
perf: compile measured nested tool validation - #147971
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: blocked before merge. Reviewed September 14, 2026, 7:44 PM ET / 23:44 UTC (Revision 28). ClawSweeper reviewWhat this changesThe PR reduces repeated validation work in nested tool history, recommendations, Workboard events, and memory events, documents measurements, and stabilizes supporting test fixtures. Merge readiness⛔ Blocked before merge - 1 item remains The optimization remains useful and is not present on inspected main. No blocking defect was found. The earlier migration blocker does not apply: the patch preserves persisted formats, validation rules, and storage operations. Priority: P2 Review scores
Verification
How this fits togetherNested tool activity records carry tool inputs and results into session history and Gateway display projections. Their validator checks those records before creation or reading; the other changed readers normalize recommendations and event data. flowchart TD
A[Completed nested tool call] --> B[Bound and clone payload]
B --> C[Lazy compiled validator]
D[Transcript row] --> E{Nested activity?}
E -->|Yes| C
E -->|No| F[Ordinary history path]
C --> G[Validated activity]
G --> H[Session history and display]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +11, Tests +151. Total +162 across 11 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain selective compilation at the existing nested-activity owner and ordinary schema reuse elsewhere, preserving browser CSP and persisted-data contracts. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug reproduction: this is a performance optimization supported by reported synthetic measurements. This read-only review did not execute benchmarks or tests. Is this the best way to solve the issue? Yes. The final patch keeps one validation owner, avoids global compiler activation, and preserves existing parsing and storage contracts; the earlier migration request has no supporting introduced change. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 04aa9a8e318c. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (27 earlier review cycles; latest 8 shown)
|
fbc7b2c to
3ac5219
Compare
|
The final revision compiles only nested tool activity, once at first use; ordinary transcript rows bypass it. Three other readers reuse ordinary schemas. The PR body records measured gains, cold cost, rejected candidates and the limits of synthetic measurements. Schema definitions, defaults, parsed and serialized output, stored formats, permissions and dependency versions are unchanged. The memory-event diff only reuses three array schemas. No data-model migration is needed; the latest review’s technical evidence confirms the existing storage contract is retained, so its generic migration checkbox does not apply. Final head |
694397d to
7eee505
Compare
fa13a6a to
948fc7a
Compare
Enable native lazy Zod compilation across core, plugins, workers, and tooling. Preserve existing schemas, parse results, and runtime fallbacks for unsupported schemas and strict-CSP browsers. Warm synthetic validation improves while first-use compilation adds CPU and memory cost.
Cache stable recommendation, dashboard, memory-event, and Workboard schemas so repeated reads do not repeat compilation. Preserve validation and serialized output, and resolve side-effect imports in the relocated updater survival fixture.
Load the Discord voice runtime before its realtime sibling so their shared async audio mock completes once. Concurrent imports can otherwise return separate export objects and leave WAV writer spies disconnected from the running consumer. Preserve every assertion and timeout.
Keep gateway-lock within the existing line limit by inlining its temporary cmdline string. Remove a duplicate wizard recovery entry introduced by overlapping database-worker routing fixes, preserving its canonical fork ownership. Apply the existing wizard choice-button interaction from #148444 while retaining typed answer, session rotation, and no-replay assertions. Validation: 175 tooling/config, 46 gateway-lock, and 53 UI lifecycle/render/submission cases passed; focused formatting/lint and independent P2 review passed. No schema, policy, deadline, threshold, or expectation changes.
Replace process-wide Zod compiler activation with one lazy compiled schema at the nested-tool activity owner. Ordinary transcript rows bypass compilation and the parsed-output contract is unchanged. Keep measured schema reuse for recommendation reads, Workboard event normalization, and memory event storage normalization. Config, transcript-entry, and relay-frame compilation did not justify their caller or first-use costs. Synthetic Node 26.8.2/Zod 4.5.4 measurements: nested reads 0.483 to 0.061 microseconds; 512 mixed rows 28.2 to 6.95 microseconds; approximately 1.42 ms compilation cost and 0.174 ms additional first-read cost. Full session-load results did not establish a compilation win. Schema reuse reduced representative reads from 6.16 to 1.77, 12.02 to 5.30, and 4.51 to 2.95 microseconds without compilation. These are measured boundaries, not aggregate Gateway throughput. Validation: 232 focused tests, including persistence, history projection, Workboard and strict-CSP browser startup; core/extension typechecks, targeted lint, formatting, and independent P2 review. Preserve schema definitions, serialized output, stored formats, permissions, and dependency versions.
Preserve the reviewed production optimization unchanged while integrating current main. Keep main's cloud reply identity and startup-discovery fixtures alongside the provider close-entry synchronization. Restore one canonical wizard recovery test registration after overlapping upstream deduplication changes removed the last entry. The unregistered test reproduced a host-broker admission failure; all eight cases pass with fork routing restored. Validation: 18 integration cases across wizard recovery, provider lifecycle, and cloud reconciliation; formatting, PR-diff whitespace checks, and fresh independent P2 review passed. Frozen dependencies match main's Vitest patch. Earlier measured production behavior and 232-case selective proof remain unchanged and scoped; final CI is required.
Keep the six generic provider-auth URL-routing cases in core. Move the two registered Radius device-flow cases to the existing root plugin integration test surface, which admits the real plugin entrypoint and is checked outside core TypeScript graphs. Preserve device destination, code and expiry, browser suppression, cancellation, awaited settlement, and single-fetch assertions. No production changes or boundary exceptions. Validation: 31 behavior and boundary tests, the complete core TypeScript boundary guard, root test typecheck, scoped lint, formatting, and independent P2 review passed.
Prepare each isolated real Gateway and Claude CLI fixture in beforeEach under the existing fixture-hook budget. Keep the six ordered account transitions, real restart, and every auth/history assertion inside the unchanged 90-second behavior deadline. Register cleanup before awaiting acquisition, join acquisition and case work, and close the current Gateway after restart. Failed preparation cleans partial resources; the cancellation regression exercises the same preparation owner. CI exposed cold setup consuming the account test's deadline. A restored local phase probe measured 39.74 seconds for initial Gateway startup, 10.92 seconds for the first turn, and 4.21 seconds for the remaining five turns; shutdown was brief. No timeout values, mocks, or assertions are relaxed. Validation: all six cases pass with the explicit CI configuration, including cancellation; gateway test types, lint, formatting, and independent P2 review pass.
Integrate current main, retain the measured Zod optimization, and remove the Radius test copy now owned by main. Start the scripted plugin theme fixture only after bootstrap publishes its existing sandbox policy. All theme and no-reload assertions remain unchanged.
Retain main’s equivalent native Bash assertion diagnostics and remove the superseded PR delta. All three policy cases and their assertions remain unchanged; focused verification and independent review pass.
|
Merged via squash.
|
What Problem This Solves
Nested tool activity history repeatedly validates one schema; three readers rebuild stable array schemas. These costs are avoidable, but compiling every schema adds first-use work many callers cannot recover.
User Impact
Compile only nested tool activity validation with Zod 4.5.4's
z.compile(schema). ThecustomTypeprecheck skips ordinary transcript rows. First matching read or creation initializes one compiled schema, shared across Gateway turns. Payload bounds, cloning and validation contracts stay unchanged.ClawHub recommendations, Workboard events and memory events reuse ordinary schemas. Browser-shared schemas remain uncompiled for strict CSP: explicit compilation attempts code generation even with
jitless. No global compiler hook, dependency change, migration orz.validatecutover is introduced.Why This Change Was Made
Config compilation raised first parsing 9.13 → 157.38 ms; cached config reads avoid parsing. Against uncompiled boolean validation, compiled validation left 4,096-row session-manager JSONL loading unchanged at 18.70 → 18.71 ms (existing
safeParse: 20.07 ms); first 20-row loading rose 3.35 → 7.26 ms. Neither boolean-validation variant is adopted. Relay compilation added 0.41 ms initially, with inconsistent larger-exchange gains. All three compilation candidates were rejected.Nested compilation costs 1.42 ms, conservatively recovered after 3,400 matching reads or 67 scans of 512 mixed rows. The separately measured incremental first-read penalty was 0.174 ms; baseline first parsing already pays initialization cost. Production call frequency remains unmeasured.
Evidence
Synthetic measurements used Node 26.8.2 / Zod 4.5.4:
Nested reads improved 7.3–8.3×. Parity passed for 18 nested, 19 relay, 46 reuse and 534 codec cases. Nested measurements call exported APIs; reuse measurements extract reader closures. Workboard uses
jitlessin Node. Reuse first-call costs were mixed. These are not whole-Gateway throughput or startup measurements.Published
3749e163passes three Bash cases and fresh independent P2 review, retaining main's exact diagnostic test. Prior6b6e1fafpassed 15 focused cases, build, Gateway/UI types and lint/formatting; these were not rerun. The four optimization owners, Workboard references and remaining PR test diffs are unchanged. Its CI 34906851601 completed SUCCESS: 132 successes and 13 skips, including theme and real-Gateway checks. Final-head CI 34908142383 also completed SUCCESS: 132 successes, 13 skips, zero failures.The previous normal run failed one theme case plus its aggregate. The hosted fallback also failed desktop reconnection and Windows startup checks. Neither failed run qualifies the new head; no gates or budgets were changed.
Retained fixture repairs
The Reports theme fixture visits
/chat, waits for bootstrap to publishembedSandboxMode: scripts, then opens Reports. CI captured the fixture script blocked by the initial strict sandbox; the isolated original case passed locally. This fixes fixture ordering without changing production CSP.CLI-auth initial acquisition uses the standard 180-second hook budget, preserving the 90-second body, six native transitions, real restart and the original 30 assertions within main's expanded 34-assertion coverage. Cleanup joins acquisition/body work and closes the current Gateway. Other retained repairs cover Discord mock initialization and memory close-entry synchronization. Main owns Bash diagnostics, wizard routing, Radius relocation, cloud, Custodian, website and SDK pooling fixes.