fix(scripts): resolve import/intersection/mapped types in JSON Schema walker - #356
Conversation
… walker The `Publish schema` workflow throws `Unsupported type` on every PR since #326 because the walker's `type()` fallback is strict — refusing any node kind it doesn't recognize. As slices G/N/P/S landed, spec.ts started referencing `import('./budget.js').HeaderBudget`, `VerificationSpec['type']`, intersections, mapped types, and utility-type transformations like `Parameters<...>`, none of which the walker handled. Widen the walker minimally without weakening the schema: - ImportTypeNode: preload budget.ts alongside spec.ts + output-schema.ts, and treat `import(module).Name` as a plain reference to Name. - IndexedAccessTypeNode: for `T['key']`, walk unions and interfaces to collect the property's type; fall back to an open object when the target is external or the index is numeric/computed. - IntersectionTypeNode: merge properties across arms; fall back to an open object if any arm isn't itself a plain object schema. - MappedTypeNode: emit `additionalProperties: true` — dynamic keys can't be statically enumerated for JSON Schema. - Utility types (Parameters, ReturnType, Extract, Exclude, Pick, Partial, Required, Readonly, NonNullable, Awaited, ThisParameterType, InstanceType, ConstructorParameters): emit an open object. These are transformations, not authored surfaces. - Unknown external references: emit an open object rather than crash. Regenerated schema now compiles cleanly and is idempotent. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Session-Id: efeda5df-9b7c-48d4-b2ce-957f5bef0a82
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 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 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5bf35ba. Configure here.
| "title": "budget alternative 2", | ||
| "description": "See HeaderBudget." | ||
| } | ||
| ] |
There was a problem hiding this comment.
Budget union rejects empty object
Low Severity
FlowSpec.budget encodes BudgetSpec | HeaderBudget as oneOf, but both object alternatives accept an empty object. A valid empty budget therefore fails published schema validation even though parseBudget accepts it.
Reviewed by Cursor Bugbot for commit 5bf35ba. Configure here.
maintainability lens — FAILNow I have enough context. Let me write the review. Maintainability review — PR #356 (schema regen + generator refactor) Blockers
Concerns
Notes
REVIEW_FAILED |
history lens — PASSBlockers: none. At PR head The schema additions track capabilities already present in the recent history: budget headers (#315), deployment (#337), deterministic leases (#350), YAML helpers (#349), and named verification gates (#353). In The helper definitions at Concerns: Notes: I could not independently confirm generation or idempotence because TypeScript is unavailable locally. From an isolated copy of the PR-head generator, the first command was: node scripts/generate-json-schema.mjs first.jsonCaptured error: The subsequent comparison commands did not execute. This leaves the reproducibility claim unverified here; it does not establish that the claim is false. No repository files were changed. REVIEW_PASSED |
structure lens — MISSING |
|
🎯 review-swarm: FAILED (M:fail H:pass S:missing) Lens transcripts posted as sibling comments above. |


Summary
The
Publish schemaworkflow (scripts/generate-json-schema.mjs) has been failing on every PR since #326 withUnsupported type import('./budget.js').HeaderBudget. Every merge since (18+ spec PRs) shipped with this workflow red — accepted because it's not a real merge gate, but it means the published JSON schema is stale.As slices G/N/P/S landed,
spec.tsstarted using type shapes the walker didn't handle: import types, indexed access on unions, intersections, mapped types, and utility transformations (Parameters<...>,Extract<...>,Pick<...>, ...).Widen the walker minimally without weakening authored-time validation:
ImportTypeNode→ preloadbudget.tsand treatimport(module).Nameas a reference toNameIndexedAccessTypeNode→ forT['key'], walk unions/interfaces to collect the property type; open-object fallback when unresolvableIntersectionTypeNode→ merge arm properties; open-object fallback when any arm isn't a plain objectMappedTypeNode→ open object (dynamic keys can't be statically enumerated)Regenerated
flows.schema.jsonis idempotent (second run produces no diff).Test plan
node scripts/generate-json-schema.mjsruns cleanly🤖 Generated with Claude Code
Note
Medium Risk
Published schema and IDE validation change materially (new gates, budget shapes, looser open-object fallbacks); runtime kernel behavior is unchanged but authors may see different schema errors until
flows checkcatches stricter rules.Overview
Fixes the Publish schema generator (
scripts/generate-json-schema.mjs) so it no longer crashes on newer SDK type shapes (e.g.import('./budget.js').HeaderBudget). The walker now preloadsbudget.ts, resolves import types, intersections, indexed access (T['key']), and uses open-object fallbacks for mapped types, TS utility types, and unknown external refs instead of failing the build.Regenerates
packages/schema/flows.schema.jsonto match currentspec.ts: e.g.FlowsJson.deploy, expanded verification (references_input,subprocess_gate,word_count_bounds,regex_matchviaNamedDataGate/ nestedVerificationSpec), budget header/kernel fields andFlowSpec.budgetasBudgetSpec | HeaderBudget,lease_mson deterministic steps, and YAML helper-related defs (YamlHelperParams, etc.). Some dynamic helper surfaces remain loosely typed (additionalProperties: true) by design.Reviewed by Cursor Bugbot for commit 5bf35ba. Bugbot is set up for automated code reviews on this repo. Configure here.