Repository navigation
perf(shared): lazily materialize RPC contract Zod v4 schemas on first use - #49897
Merged
Merged
Conversation
nwparker
changed the base branch from
perf/cache-unchanged-list-environments-stat
to
main
November 26, 2026 12:29
nwparker
force-pushed
the
perf/lazy-rpc-param-zod-schemas
branch
from
November 26, 2026 12:32
7fa2658 to
7443d37
Compare
joei4cm
added a commit
to joei4cm/orca
that referenced
this pull request
Nov 27, 2026
stablyai#49406 added this schema bare on top of stablyai#49897's lazy migration, leaving the eager-schema ratchet one over baseline: every PR touching src/main or src/shared now fails the ratchets job. Wrap it like its siblings. Co-Authored-By: Claude Code <[email protected]>
11 tasks done
DoozyX
added a commit
to DoozyX/orca
that referenced
this pull request
Nov 27, 2026
Merges stablyai/orca 7030f25 (320 commits) into fork main 3e499a0. Conflict resolutions: - Antigravity usage (stablyai#50137): upstream stops reading agy usage for account safety. Carried into the fork's per-account status bar: dropped the Antigravity usage menu, accounts prop and checked-item setup flag from AccountUsageDetailsMenu, StatusBarUsageArea, the controller and provider visibility (and its fork-retained test); the omp slot stays, including in the rate-limit full cycle and the usage-tracking doc. - Lazy Zod schemas (stablyai#49897): took upstream's lazyZodSchema wrapping and kept the fork's ProjectGroupUpdate.claudeAccountId, the omp status-bar item and _ompStatusBarDefaultAdded, and the federated release receipt's currentOwnerDispatchId/terminalReleaseState. Fork-only omp usage and AccountHome schemas are now lazy too; baseline pruned. Feature-interaction schemas stay in the fork's feature-interaction-params.ts, now lazy too. - Git graph: openGitGraph keeps the fork's options object (afterOpen) and takes upstream's placementWorkspaceId (stablyai#49629, stablyai#50017) as an option; callers and upstream's test use it. The fork's branches/tags dock passes the folder placement too (same bug as stablyai#49597), and it and the graph tab share a new useGitGraphRefsEpoch hook (keeps git-graph-tab under 400). Source control keeps the fork's branches/tags dock beside upstream's file-list header; fork git-graph rendering tests pass the new tabId. - Claude background tasks: upstream skips ambient artifact monitors; the fork's monitored-work rows and untyped-row handling stay. - Claude managed hook: local POSIX keeps the fork's runtime-home wrapped command; getPosixManagedEventHook takes the command, so upstream's PreToolUse timeout applies to both local and remote entries. - local-worker-start: keep the fork's reminted pane handle (#29) and add upstream's retained-chat assertStarting and launch warnings. - Mobile web bundle fence: keep the fork's 11.25 MiB (above upstream's 11 MiB + 16 KiB). - en.json: union of the fork's ProjectGroupSettingsDialog and upstream's AutoNameFailed keys. - Skills: regenerate bundled guides (upstream's shared CLI paragraph), union the add-only digest ledger, regenerate manifest and sources. - tracked-upstream-cache test: fixed far-future expiry instead of Date.now() for upstream's new wall-clock ratchet. Claude-Session: https://claude.ai/code/session_01BPjp5wba1X5fDbTK4YStHM
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.
Summary
Defers Zod v4 schema construction across 151
src/shared/rpc-contract/files (~880 schemas) until first property access so unused RPC contracts do not eagerly allocate thousands of live Zod v4 schema, closure, andtraitsSetobjects at startup:src/shared/schema/lazy-zod-schema.tslazyZodSchema<T extends ZodType>(factory: () => T): Tbacked by aProxy+WeakMap<object, () => ZodType>resolver, preserving===object identity (required bygenerate-rpc-params-catalog.mjs),z.infer,instanceof ZodType, and full Zod v4 composition (extend,partial,discriminatedUnion, nested objects).unwrapLazyZodSchemasozod.compilealways clones and AOT-compiles the real underlyingZodTypeinstance.src/main/schema-validation/zod-schema-compilation.tsunwrapLazyZodSchema(schema)beforecompile()ingetCompiledSchema.src/shared/rpc-contract/**/*.ts(151 files)lazyZodSchema(() => ...).Performance
Measured on an isolated clone of a 1,280-worktree heavy profile (
xray-t75-full.mjs) and a standalone Zod v4 microbenchmark (1,000 eager z.object=22.16 MiBvs1,000 lazyZodSchema=0.46 MiB, -98%):heapUsed(t+75s): 90.30 MiB → 86.34 MiB (-3.96 MiB)zod.compilefast path.Verification
pnpm check:changed --base=perf/cache-unchanged-list-environments-stat: 29/29 passed (includingrpc params catalog,typecheck,unit tests,changed-code quality)pnpm run build:electron-vite: succeeded