Skip to content

test(agent-state): catch rewriting checks and look inside every container in the schema walker - #35797

Merged
nwparker merged 1 commit into
mainfrom
nwparker/agent-state-walker-checks
Oct 29, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/agent-state-walker-checks

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​55
Prod 0 0 0 0

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 in def.checks with check === '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:

    • intersection left/right;
    • object 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:

    • trim, lowercase, overwrite, and a trim check on a literal;
    • a rewrite hidden on each side of an intersection, in a catchall, in a map value, in a map key, and in a record value.

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's Literal field 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 inspect def.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), and ast-grep-gates all pass.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

User-risk: none (test-only).

Flag-off: not applicable.

SSH: no impact, test-only.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5ac010fb-7687-4692-bf29-ae406619215a
Commits

Reviewing files that changed from the base of the PR and between 7fa3f9c and 8389f93.

Files selected for processing: 1
  • src/main/runtime/agent-state-rules/agent-state-rules-catalog.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This test-only change appears safe to merge.

Summary

Strengthens the test that guards against bundled agent-state rules changing during parsing.

  • The catalog test catches more ways a schema can change parsed values.

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

@nwparker
nwparker merged commit e6980de into main Oct 29, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant