Skip to content

refactor(cli): declare CLI schema facts through the typed constraint helpers - #11205

Merged
morluto merged 3 commits into
mainfrom
refactor/cli-schema-annotations
Nov 15, 2026
Merged

morluto merged 3 commits into
mainfrom
refactor/cli-schema-annotations

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

This moves the last raw JSON Schema keywords in CLI .meta() calls onto the typed helpers from #10693, and makes the CLI read the root discriminator from its typed annotation. Since #10693 that annotation no longer reaches .meta(), so the CLI's check that a root discriminator is the delivery's had silently stopped running. W1 plan item 4.

Problem and expected behavior

  • src/cli/jsonInputArgument.ts (2 sites) and src/cli/utilityCommands.ts (1 site) still wrote raw keywords (contentMediaType/contentSchema, if/then) into .meta(), counted in the raw-json-schema-meta baseline.
  • src/cli/contractCliDescription.ts looked for the x-rea-root-discriminator keyword in inputSchema.meta(). feat(mcp)!: retire the full schema profiles and declare schema facts as typed annotations #10693 moved that fact to schemaAnnotations(...).rootDiscriminator, so the CLI no longer refused a contract whose root discriminator it does not project.

Expected: every CLI schema fact comes from a typed annotation or a schemaConstraints helper, the baseline is empty, and the root-discriminator check runs again.

Change and scope

  • src/domain/schemaConstraints.ts:
    • PresenceRule.requiresValue: the required property must hold exactly this value. It is checked at parse time and declared as if: {required: [when]}, then: {required: [requires], properties: {requires: {const}}}.
    • jsonDocumentText(schema, contentSchema?): declares contentMediaType: application/json and the decoded content's schema. JSON Schema's content* keywords are annotations, not assertions, so it adds no check; the command that decodes the text admits the content with the owning schema.
  • src/cli/utilityCommands.ts: import-reference-source options use requirePresence with the same rule, message and issue path (--outline-depth requires --detail summary).
  • src/cli/jsonInputArgument.ts: uses jsonDocumentText.
  • src/cli/contractCliDescription.ts: reads schemaAnnotations(contract.inputSchema)?.rootDiscriminator and refuses it at registration unless it is a delivery field. ROOT_DISCRIMINATOR is removed.
  • scripts/verify/baselines/raw-json-schema-meta.json: removed; the guard's baseline is empty.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/schemaConstraints.ts owns the check and its declaration; the CLI consumes the helpers.

  • Contribution scope fit and linked maintainer decision: not applicable (refactor within existing boundaries).

  • CLI and MCP/tool-catalog contract: CLI --schema output for these commands declares the same keywords as before. Runtime validation is unchanged. MCP is unchanged.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: none.

  • Target selection, authority, upstream behavior, and cleanup details: not applicable.

  • Generated metadata, package, or installation impact: none.

  • 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

  • Tests added or updated:
    • src/domain/schemaConstraints.test.ts: requiresValue declaration, parse issues, and Ajv agreement with parsing; jsonDocumentText declaration.
    • tests/boundary/cli/cliContractCommandParity.test.ts: "refuses a root discriminator that is not the delivery's".
  • Base reproduction: the new parity case fails against main's contractCliDescription.ts (no error is thrown) and passes with this change.
  • Remaining proof gaps: none known.

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

  • npm run test:focused -- tests/boundary/cli/cliContractCommandParity.test.ts: 558 passed. Against main's contractCliDescription.ts: 1 failed (the new case).
  • npm run test:focused -- src/domain/schemaConstraints.test.ts: 11 passed.
  • npm run test:focused -- tests/boundary/cli/referenceSourceSummary.test.ts tests/boundary/cli/cliInputSchemaRequired.test.ts tests/boundary/cli/cliDomainFieldSchema.test.ts tests/boundary/cli/jsonInputSchema.test.ts tests/boundary/cli/cliContractSchemaParity.test.ts: 61 passed.
  • npx oxfmt --check ., npm run check:fast, node scripts/verify/architecture-guards.mjs: passed.
  • Merged current main (merge 5e544ce), commit written without the pre-commit lint-staged pass so it carries no unrelated autofixes; pre-push hook ran. fix(native)!: report a target-selected plist against the target, not the unsent path input #10798 had widened the CLI's accepted root discriminator from the delivery's fields to every field the projection does not take from argv or that selects the input branch (discriminatorFields), still reading the dead x-rea-root-discriminator .meta() keyword. The resolution keeps this PR's typed schemaAnnotations(...).rootDiscriminator read and checks it against main's wider discriminatorFields set; the regression test is renamed to match. After the merge: npm run check:fast pass; npm run test:focused -- tests/boundary/cli/cliContractCommandParity.test.ts src/domain/schemaConstraints.test.ts 1053 passed; briefs/local-gate.sh 11205 refactor/cli-schema-annotations pass.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none.

Author readiness

Human owner:

  • 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.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T14:17:25.254755Z
We couldn’t complete this review. Comment @codex review to try again.
1687899 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The merged change appears safe to merge.

Summary

The merged change moves CLI schema declarations into shared typed helpers and restores the root-discriminator check through schemaAnnotations.

  • CLI JSON text arguments declare the shape of their decoded content.
  • Reference-source imports require summary detail when an outline depth is set.
  • Contract registration checks whether each root discriminator has a CLI projection.

Source review only; tests were not run. Whether another PR supersedes this one could not be checked because GitHub access requires authentication.

Reviews (6) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

…helpers

The last raw JSON Schema keywords in CLI .meta() calls move to src/domain/schemaConstraints helpers: requirePresence gains requiresValue (the --outline-depth rule) and jsonDocumentText declares JSON document arguments. contractCliDescription reads the root discriminator from its typed annotation; since #10693 the x-rea-root-discriminator keyword no longer reached .meta(), so the check that the discriminator is the delivery's was dead. The raw-json-schema-meta baseline is now empty.
@morluto
morluto force-pushed the refactor/cli-schema-annotations branch from 1687899 to 74c2345 Compare November 15, 2026 16:36
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai please review the latest commit: the branch was rebased on main after #11316 split the guard baselines into per-guard files, and the latest score predates that push.

@morluto
morluto force-pushed the refactor/cli-schema-annotations branch from 7d22179 to 5e544ce Compare November 15, 2026 21:23
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review — please review the latest commit (merge of current main).

@morluto
morluto merged commit 6cbfb9f into main Nov 15, 2026
7 of 9 checks passed
@morluto
morluto deleted the refactor/cli-schema-annotations branch November 15, 2026 21:49
@morluto morluto added the area: cli CLI adapter and one-shot commands label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant