Repository navigation
test(agent-state): catch rewriting checks and look inside every container in the schema walker - #35797
Conversation
…iner in the schema walker The walker that proves bundled rule files need no parsing missed value rewriting checks (trim, toLowerCase, overwrite) and never entered intersections, object catchalls, maps or records. It now reports each, with a detection test per case.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
[Low impact] This test-only change appears safe to merge. SummaryStrengthens the test that guards against bundled agent-state rules changing during parsing.
No actionable issues found. Tests were not run during this review. Reviews (1) · Last reviewed commit: "test(agent-state): catch rewriting check..." · Reviewed by Greptile |
ELI5
Since #35768, Orca uses its bundled agent-state rule files as-is, without re-parsing them. A test proves that is safe by walking the rule-file schema and failing if anything in it could change a value during parsing. The walker had blind spots: it missed "tidy-up" checks like
.trim()and never looked inside a few kinds of container. This closes those gaps.What Changed
The test file is the only change:
src/main/runtime/agent-state-rules/agent-state-rules-catalog.test.ts.Value-rewriting checks: the walker now reports them. In zod v4,
.trim(),.toLowerCase(),.toUpperCase(),.normalize()and.overwrite()are entries indef.checkswithcheck === 'overwrite'. They change the parsed value without changing the schema kind, so the old kind-only walk missed them.Containers: the walker now also descends into:
left/right;catchall.Maps and records were already reached through
keyType/valueType; there are now tests proving it.Typed guards: two guards (
isZodSchema,isZodCheck) replace the previous cast and its suppression.New detection tests:
Why
Both reviewers of #35768 flagged these blind spots. Since the bundled files skip validation at load, this walker is the only guard that parsing would be a no-op.
Mutation check: adding
.trim()to the schema'sLiteralfield makes both guards fail with the extended walker. The walker reports['overwrite check', …], and the bundled files no longer parse to themselves. The previous walker didn't inspectdef.checks, so its walker assertion would have passed.Linked Issue
Follow-up to #35768.
Visual Proof
N/A: test-only.
Testing
pnpm test src/main/runtime/agent-state-rules/agent-state-rules-catalog.test.ts: 5/5 pass.The mutation above was applied locally, the failure confirmed, and then reverted.
pnpm tc,pnpm run typecheck:ci,pnpm run check:code-quality:changed, oxlint, the anti-slop oxlint (plugin synced), andast-grep-gatesall pass.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
User-risk: none (test-only).
Flag-off: not applicable.
SSH: no impact, test-only.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)