[PR #5857] [CLOSED] fix(cli): read zod optionality for exactOptional inputs #7088

Closed
opened 2026-11-01 21:45:17 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5857
Author: @XiaoBinGan
Created: 10/21/2026
Status: ❌ Closed

Base: main ← Head: fix/cli-schema-exact-optional


📝 Commits (2)

  • a9f0a54 fix(cli): read zod optionality for exactOptional inputs
  • c5cb48e test(cli): guard the required-input optionality rule directly

📊 Changes

1 file changed (+14 additions, -1 deletions)

View changed files

📝 tests/boundary/cli/cliInputSchemaRequired.test.ts (+14 -1)

📄 Description

Summary

main is red: Test shard (4/8), Portable tests and CI required all fail on f801b2fbf with tests/boundary/cli/cliInputSchemaRequired.test.ts > require exactly the inputs whose omission the parser rejects - expected [ Array(1) ] to deeply equal [], reporting inspect-wasm-artifact options: advertised [], parser rejects [commandTimeoutMs].

The invariant decides "required" by parsing undefined against each parser field. exactOptional() rejects an explicit undefined value while still admitting omission, so that heuristic reports an optional CLI option as required. command_timeout_ms uses exactOptional() and the advertised schema correctly omits it from required, so the schema and parser agree and only the check misread them.

No issue is linked: this restores an existing required check rather than changing a user-visible contract, and the failure is reproducible on the current main.

Problem and expected behavior

  • Smallest trigger: run the CLI boundary check on f801b2fbf. The advertised inspect-wasm-artifact options schema has an empty required list, while Object.entries(schema.shape).filter(([, field]) => !field.safeParse(undefined).success) yields commandTimeoutMs.
  • Violated invariant: the check exists to prove the advertised JSON schema and the parser agree; a false positive blocks the required checks for every PR.
  • Expected: a field counts as required only when the parser rejects omission. exactOptional, optional and default all admit omission; only unmarked fields are required.

Change and scope

  • tests/boundary/cli/cliInputSchemaRequired.test.ts: omissionRejected reads zod's optionality marker (_zod.optin) instead of parsing undefined, with a comment recording why exactOptional() cannot be detected by value parsing.
  • No production schema changes: src/domain/wasm/wasmArtifact.ts keeps exactOptional(), and the advertised JSON schemas are byte-identical.
  • Not included: no change to the CLI inventory, no new options, no unrelated cleanup.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the CLI advertised-schema invariant check.
  • Contribution scope fit and linked maintainer decision: not applicable - restores a required check to green without changing a contract.
  • CLI and MCP/tool-catalog contract: unchanged; the check asserts the same invariant with a correct optionality test.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: none.
  • Generated metadata, package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Test added or updated: the existing invariant test itself is the regression check; it failed on f801b2fbf and passes with the corrected optionality test.
  • Base reproduction: npx vitest run tests/boundary/cli/cliInputSchemaRequired.test.ts fails on f801b2fbf with advertised [], parser rejects [commandTimeoutMs] and passes after the change (6 tests).
  • User-visible CLI/MCP output: none; --schema output is unchanged.
  • Remaining proof gaps: the other tests/boundary/cli cases in this checkout need a built dist/, so they were not run here; the changed file is self-contained and does not touch them.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run tests/boundary/cli/cliInputSchemaRequired.test.ts - 6 passed (fails on f801b2fbf).
  • npm run format:check - all matched files use the correct format.
  • npm run verify:test-discovery - all 1902 test files discovered exactly once.
  • npm run typecheck - no diagnostic in the changed file (the remaining errors in this checkout are pre-existing protobuf-module resolution failures).
  • npm run lint - 0 errors, module boundaries checked.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real target coverage: none claimed; this is a schema-consistency check.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none.

Author readiness

Human owner: @XiaoBinGan

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5857 **Author:** [@XiaoBinGan](https://github.com/XiaoBinGan) **Created:** 10/21/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/cli-schema-exact-optional` --- ### 📝 Commits (2) - [`a9f0a54`](https://github.com/morluto/rea/commit/a9f0a54c9b5f1178caed23e04b6c5f8f31030e0d) fix(cli): read zod optionality for exactOptional inputs - [`c5cb48e`](https://github.com/morluto/rea/commit/c5cb48eadfecd9609f5cd5d1d3cc4d828147e399) test(cli): guard the required-input optionality rule directly ### 📊 Changes **1 file changed** (+14 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `tests/boundary/cli/cliInputSchemaRequired.test.ts` (+14 -1) </details> ### 📄 Description ## Summary `main` is red: `Test shard (4/8)`, `Portable tests` and `CI required` all fail on `f801b2fbf` with `tests/boundary/cli/cliInputSchemaRequired.test.ts > require exactly the inputs whose omission the parser rejects` - `expected [ Array(1) ] to deeply equal []`, reporting `inspect-wasm-artifact options: advertised [], parser rejects [commandTimeoutMs]`. The invariant decides "required" by parsing `undefined` against each parser field. `exactOptional()` rejects an explicit `undefined` value while still admitting omission, so that heuristic reports an optional CLI option as required. `command_timeout_ms` uses `exactOptional()` and the advertised schema correctly omits it from `required`, so the schema and parser agree and only the check misread them. No issue is linked: this restores an existing required check rather than changing a user-visible contract, and the failure is reproducible on the current `main`. ## Problem and expected behavior - Smallest trigger: run the CLI boundary check on `f801b2fbf`. The advertised `inspect-wasm-artifact` options schema has an empty `required` list, while `Object.entries(schema.shape).filter(([, field]) => !field.safeParse(undefined).success)` yields `commandTimeoutMs`. - Violated invariant: the check exists to prove the advertised JSON schema and the parser agree; a false positive blocks the required checks for every PR. - Expected: a field counts as required only when the parser rejects omission. `exactOptional`, `optional` and `default` all admit omission; only unmarked fields are required. ## Change and scope - `tests/boundary/cli/cliInputSchemaRequired.test.ts`: `omissionRejected` reads zod's optionality marker (`_zod.optin`) instead of parsing `undefined`, with a comment recording why `exactOptional()` cannot be detected by value parsing. - No production schema changes: `src/domain/wasm/wasmArtifact.ts` keeps `exactOptional()`, and the advertised JSON schemas are byte-identical. - Not included: no change to the CLI inventory, no new options, no unrelated cleanup. ## Contract and boundary impact - Semantic owner and earliest changed stage: the CLI advertised-schema invariant check. - Contribution scope fit and linked maintainer decision: not applicable - restores a required check to green without changing a contract. - CLI and MCP/tool-catalog contract: unchanged; the check asserts the same invariant with a correct optionality test. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details: none. - Generated metadata, package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [x] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Test added or updated: the existing invariant test itself is the regression check; it failed on `f801b2fbf` and passes with the corrected optionality test. - Base reproduction: `npx vitest run tests/boundary/cli/cliInputSchemaRequired.test.ts` fails on `f801b2fbf` with `advertised [], parser rejects [commandTimeoutMs]` and passes after the change (6 tests). - User-visible CLI/MCP output: none; `--schema` output is unchanged. - Remaining proof gaps: the other `tests/boundary/cli` cases in this checkout need a built `dist/`, so they were not run here; the changed file is self-contained and does not touch them. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npx vitest run tests/boundary/cli/cliInputSchemaRequired.test.ts` - 6 passed (fails on `f801b2fbf`). - `npm run format:check` - all matched files use the correct format. - `npm run verify:test-discovery` - all 1902 test files discovered exactly once. - `npm run typecheck` - no diagnostic in the changed file (the remaining errors in this checkout are pre-existing protobuf-module resolution failures). - `npm run lint` - 0 errors, module boundaries checked. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real target coverage: none claimed; this is a schema-consistency check. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none. ## Author readiness Human owner: @XiaoBinGan - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:45:17 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7088
No description provided.