refactor: migrate validators to TypeBox#86639
Conversation
Dependency Changes DetectedThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
|
Codex review: needs real behavior proof before merge. Reviewed May 25, 2026, 11:29 PM ET / 03:29 UTC. Summary PR surface: Source +1371, Tests +1652, Config -1, Other -3. Total +3019 across 31 files. Reproducibility: not applicable. this is a refactor PR, not a bug report. Current-main evidence shows the central validator surfaces still use Ajv, so the PR is active rather than obsolete. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance: Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land only after maintainers accept the dependency and validator-parity risk and the contributor adds redacted real runtime proof; otherwise keep the Ajv-backed implementation until a narrower parity migration is ready. Do we have a high-confidence way to reproduce the issue? Not applicable; this is a refactor PR, not a bug report. Current-main evidence shows the central validator surfaces still use Ajv, so the PR is active rather than obsolete. Is this the best way to solve the issue? Unclear: the TypeBox approach is plausible and covered by targeted tests, but the merge-ready solution still needs real runtime proof and an explicit dependency-review record because validator and package contracts changed together. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 17ab9b967c63. Label changesLabel justifications:
Evidence reviewedPR surface: Source +1371, Tests +1652, Config -1, Other -3. Total +3019 across 31 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
4e6b08c to
e75d924
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e75d924543
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| export async function loadEmbeddedToolRuntimeFromPackage( | ||
| options: LoadEmbeddedToolRuntimeFromPackageOptions = {}, | ||
| ): Promise<EmbeddedToolRuntime> { | ||
| installLobsterAjvCompileCache(); | ||
|
|
||
| const importModule = | ||
| options.importModule ?? |
There was a problem hiding this comment.
Reinstall Lobster Ajv compile cache before runtime import
loadEmbeddedToolRuntimeFromPackage no longer installs the Lobster Ajv compile cache before importing @clawdbot/lobster, which removes the content-hash/LRU dedup guard that previously bounded compiled-schema growth. Because the bundled Lobster runtime still depends on Ajv (extensions/lobster/npm-shrinkwrap.json), repeated tool calls that produce equivalent-but-new schema objects can now accumulate validators and increase memory/compile overhead over time in long-lived sessions.
Useful? React with 👍 / 👎.
e75d924 to
3a1b860
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a1b860eaa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const packageEntryPath = resolvePackageEntry("@clawdbot/lobster"); | ||
| await installLobsterAjvCompileCache(packageEntryPath); |
There was a problem hiding this comment.
Defer package entry resolution until fallback import
Calling resolvePackageEntry("@clawdbot/lobster") before attempting the primary @clawdbot/lobster/core import introduces an early-fail path: if package-root resolution throws (for example when only the core subpath is resolvable or a custom loader is used), runtime loading now aborts before trying the primary import route that previously ran first. This is a behavior regression in loadEmbeddedToolRuntimeFromPackage and can break environments where core is loadable but root resolution is not.
Useful? React with 👍 / 👎.
3a1b860 to
4977d52
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4977d52c4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (key === "$dynamicRef" && normalizedSchema.$ref === undefined) { | ||
| return ["$ref", value]; |
There was a problem hiding this comment.
Preserve
$dynamicRef semantics in normalized schemas
Rewriting $dynamicRef to $ref here changes draft-2020-12 behavior from dynamic to static reference resolution, so schemas that rely on dynamic anchor rebinding (for example recursive/extensible tool-output schemas from external MCP catalogs) can validate differently than before this refactor. The previous implementation used Ajv 2020-12 support directly, but createBundleMcpJsonSchemaValidator now compiles normalized schemas through this helper, so this conversion can cause valid payloads to be rejected (or invalid ones accepted) whenever $dynamicRef and $dynamicAnchor are used beyond trivial local cases.
Useful? React with 👍 / 👎.
* refactor: migrate validators to typebox * fix: preserve json schema resource refs * chore: clean schema preflight recursion * refactor: remove lobster ajv shim * fix: support schema array refs * fix: validate schema dependencies * fix: preserve schema contract checks * fix: support same-document schema refs * fix: preserve untyped map defaults * fix: preserve schema default semantics * test: avoid thenable schema literals * test: build conditional schema key * fix: defer resource id refs to typebox * fix: reject invalid schema enum metadata * fix: preserve default branch semantics * fix: resolve schema resource refs * fix: narrow conditional default fallback * fix: preserve uri format validation * fix: preserve validator compatibility * test: avoid ajv cache lint violation * fix: preserve typebox validation diagnostics * fix: validate defaulted conditional schemas * fix: normalize mcp draft schemas * fix: preserve tuple schema defaults * fix: resolve relative schema refs * fix: scope typebox format semantics * fix: align conditional format defaults * fix: decode schema pointer refs * fix: filter grouped secretref diagnostics * fix: preserve default conditional compatibility * fix: preserve nullable schema compatibility * fix: settle defaults before conditionals * fix: preserve default validation invariants * fix: validate dynamic schema refs * fix: reject malformed nullable schemas
* refactor: migrate validators to typebox * fix: preserve json schema resource refs * chore: clean schema preflight recursion * refactor: remove lobster ajv shim * fix: support schema array refs * fix: validate schema dependencies * fix: preserve schema contract checks * fix: support same-document schema refs * fix: preserve untyped map defaults * fix: preserve schema default semantics * test: avoid thenable schema literals * test: build conditional schema key * fix: defer resource id refs to typebox * fix: reject invalid schema enum metadata * fix: preserve default branch semantics * fix: resolve schema resource refs * fix: narrow conditional default fallback * fix: preserve uri format validation * fix: preserve validator compatibility * test: avoid ajv cache lint violation * fix: preserve typebox validation diagnostics * fix: validate defaulted conditional schemas * fix: normalize mcp draft schemas * fix: preserve tuple schema defaults * fix: resolve relative schema refs * fix: scope typebox format semantics * fix: align conditional format defaults * fix: decode schema pointer refs * fix: filter grouped secretref diagnostics * fix: preserve default conditional compatibility * fix: preserve nullable schema compatibility * fix: settle defaults before conditionals * fix: preserve default validation invariants * fix: validate dynamic schema refs * fix: reject malformed nullable schemas
* refactor: migrate validators to typebox * fix: preserve json schema resource refs * chore: clean schema preflight recursion * refactor: remove lobster ajv shim * fix: support schema array refs * fix: validate schema dependencies * fix: preserve schema contract checks * fix: support same-document schema refs * fix: preserve untyped map defaults * fix: preserve schema default semantics * test: avoid thenable schema literals * test: build conditional schema key * fix: defer resource id refs to typebox * fix: reject invalid schema enum metadata * fix: preserve default branch semantics * fix: resolve schema resource refs * fix: narrow conditional default fallback * fix: preserve uri format validation * fix: preserve validator compatibility * test: avoid ajv cache lint violation * fix: preserve typebox validation diagnostics * fix: validate defaulted conditional schemas * fix: normalize mcp draft schemas * fix: preserve tuple schema defaults * fix: resolve relative schema refs * fix: scope typebox format semantics * fix: align conditional format defaults * fix: decode schema pointer refs * fix: filter grouped secretref diagnostics * fix: preserve default conditional compatibility * fix: preserve nullable schema compatibility * fix: settle defaults before conditionals * fix: preserve default validation invariants * fix: validate dynamic schema refs * fix: reject malformed nullable schemas
* refactor: migrate validators to typebox * fix: preserve json schema resource refs * chore: clean schema preflight recursion * refactor: remove lobster ajv shim * fix: support schema array refs * fix: validate schema dependencies * fix: preserve schema contract checks * fix: support same-document schema refs * fix: preserve untyped map defaults * fix: preserve schema default semantics * test: avoid thenable schema literals * test: build conditional schema key * fix: defer resource id refs to typebox * fix: reject invalid schema enum metadata * fix: preserve default branch semantics * fix: resolve schema resource refs * fix: narrow conditional default fallback * fix: preserve uri format validation * fix: preserve validator compatibility * test: avoid ajv cache lint violation * fix: preserve typebox validation diagnostics * fix: validate defaulted conditional schemas * fix: normalize mcp draft schemas * fix: preserve tuple schema defaults * fix: resolve relative schema refs * fix: scope typebox format semantics * fix: align conditional format defaults * fix: decode schema pointer refs * fix: filter grouped secretref diagnostics * fix: preserve default conditional compatibility * fix: preserve nullable schema compatibility * fix: settle defaults before conditionals * fix: preserve default validation invariants * fix: validate dynamic schema refs * fix: reject malformed nullable schemas
Summary
Verification
pnpm test src/config/config.plugin-validation.test.ts src/config/validation.policy.test.ts src/gateway/server.auth.default-token.test.ts src/gateway/protocol/index.test.ts src/plugins/schema-validator.test.ts src/agents/pi-bundle-mcp-runtime.test.ts -- --reporter=verboseenv -u OPENCLAW_TESTBOX -u OPENCLAW_TESTBOX_REMOTE_RUN pnpm check:changed.agents/skills/autoreview/scripts/autoreview --mode branch --base origin/mainorigin/mainReal behavior proof
Behavior addressed: Direct Ajv validator usage is removed from root/Codex/Lobster-owned validation paths while TypeBox preserves plugin/config/MCP JSON Schema behavior.
Real environment tested: Local macOS checkout on branch
refactor/typebox-validators, rebased ontoorigin/mainat2e17003165.Exact steps or command run after this patch:
pnpm test src/config/config.plugin-validation.test.ts src/config/validation.policy.test.ts src/gateway/server.auth.default-token.test.ts src/gateway/protocol/index.test.ts src/plugins/schema-validator.test.ts src/agents/pi-bundle-mcp-runtime.test.ts -- --reporter=verbose;env -u OPENCLAW_TESTBOX -u OPENCLAW_TESTBOX_REMOTE_RUN pnpm check:changed;.agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main.Evidence after fix: Focused validator/config/gateway/MCP shards passed;
check:changedpassed; autoreview reported no accepted/actionable findings.Observed result after fix: TypeBox validates the migrated surfaces, preserves Ajv-compatible defaults/ref/nullable/dynamic-ref behavior covered by regression tests, and rejects malformed externally supplied schemas.
What was not tested: Full release packaging or live external MCP server execution beyond the local MCP runtime validator coverage.