[codex] Structure ACP schema generator errors#3362
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This PR improves error handling in internal code generation scripts by adding structured error classes and comprehensive tests. Changes are isolated to developer tooling with no runtime application impact. No code changes detected at You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
Summary
Validation
vp test packages/effect-acp/scripts/generate.test.ts --no-cachevp check(passes with pre-existing warnings)vp run typecheckvpr typecheckOverlap audit
No current open PR touches either changed path, including previous filenames.
Note
Low Risk
Dev-tooling and error-shape changes in the generator script only; no runtime auth, data, or production API impact.
Overview
Replaces the single generic generator failure type with Effect Schema tagged errors that carry URL, output path, pipeline stage, document kind, formatter command/args, and exit codes while preserving underlying causes.
Download and decode paths map HTTP, filesystem, and JSON decode failures into distinct error classes; schema/metadata decoding goes through exported helpers that attach file path context. Formatting is centralized in
formatGeneratedFiles, and malformed generated type/const pairs now fail with dedicated invariant errors instead of plainError.Operational tweaks: downloaded upstream asset cleanup is registered before the HTTP fetches so partial runs still remove temp files, and the CLI only runs when
import.meta.mainis true so tests can import the module safely.Adds Vitest coverage for failed HTTP download, write-to-directory failure, document decode context, and nonzero formatter exit codes.
Reviewed by Cursor Bugbot for commit 15152d6. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure ACP schema generator errors into tagged error classes
GenerateCommandErrorinterface with seven tagged error classes (AcpGeneratorDownloadError,AcpGeneratorDownloadFileError,AcpGeneratorDocumentDecodeError,AcpGeneratorFormatProcessError,AcpGeneratorFormatExitError,AcpGeneratorSchemaValueDeclarationMissingError,AcpGeneratorSchemaNameParseError) in generate.ts, each carrying structured context (stage, file path, exit code, etc.).decodeUpstreamSchemaDocumentanddecodeMetaDocumenthelpers so decode failures carry document type and file path context.formatGeneratedFiles, which maps spawn/exit failures to structured errors including exit code.Command.runentrypoint in animport.meta.mainguard so importing the module no longer triggers execution.Macroscope summarized 15152d6.