Repository navigation
refactor(cli): project reconstruction and source-to-bundle documents from their contracts - #10697
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge, with one non-blocking mismatch in the advertised path schema.
|
c61fa6d to
afb76d7
Compare
1fd7db5 to
dcc1991
Compare
afb76d7 to
63990e9
Compare
dcc1991 to
46f4815
Compare
fb146a1 to
cdb44f0
Compare
46f4815 to
85df160
Compare
cdb44f0 to
dfd85dd
Compare
85df160 to
2dd9aec
Compare
…om their contracts
… refuse omitted document fields
dfd85dd to
4fe7fd8
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
| export const cliJsonCallerPathSchema = localPathStringSchema.regex( | ||
| new RegExp(`^(?!${URL_REFERENCE_SOURCE})`, "u"), | ||
| "must be a local path, not a URL", | ||
| ); |
There was a problem hiding this comment.
Blank paths pass schema checks
cliJsonCallerPathSchema accepts whitespace-only paths such as " " and "\t". But resolveJsonPath leaves them unchanged, and the contract rejects them because they are not absolute paths. A document can therefore pass the new --schema check and still fail at reference.path; the other projected caller paths have the same mismatch.
Reject whitespace-only strings in the advertised schema without trimming valid filenames.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cliJsonInput.ts
Line: 276-279
Comment:
**Blank paths pass schema checks**
`cliJsonCallerPathSchema` accepts whitespace-only paths such as `" "` and `"\t"`. But `resolveJsonPath` leaves them unchanged, and the contract rejects them because they are not absolute paths. A document can therefore pass the new `--schema` check and still fail at `reference.path`; the other projected caller paths have the same mismatch.
Reject whitespace-only strings in the advertised schema without trimming valid filenames.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Summary
Next slice of plan W1, stacked on #10668 (base
refactor/cli-contract-json-document; retarget as the lower PRs merge). Refs #10583.Three more JSON-document commands are derived from their MCP contracts:
build-reconstruction-obligation-ledger,evaluate-reconstruction-coverageandcompare-source-to-bundle. Two fixes to the shared document projection come with them:--schemaas the CLI admits them.Problem and expected behavior
registerJsonCommand. It parsed withz.unknown()and advertised a separatedocumentSchema. That request envelope replaced the Evidence bundle (ledger) or the wholecoveragedocument with{}, so the CLI's--schemashowed less than the contract and accepted documents the command then refused.compare-source-to-bundleparsed with its owncompareSourceToBundleCliInputSchema, a copy of the contract with a relative-path file reference and withoutview. The service took the schema as a parameter to support both.registerContractDocumentCommand(refactor(cli): project JSON-document workflow commands from their contracts #10668) recordsomitreasons but did not enforce them. An omitted field passed through to an owner that might accept it. Fortrace-application-featurethe owner refused it with a generic strict-key error. Forcompare-source-to-bundleon the contract schema, the owner would silently ignoreview.callerPathsfield in a document is resolved against the working directory before admission. But--schemaadvertised the contract's absolute-path pattern (^/), so a relative path the command accepts looked invalid. This already affectedinspect-analysis-view(source.path),compare-artifacts(left/right.path) andcapture-electron-scenario(executable_path,application_path,application_root).Change and scope
applicationCommands.ts: ledger and coverage useregisterContractDocumentCommandwith their contracts.registerJsonCommandand itsdocumentSchemaoverride are deleted. Each service still parses its own envelope and reads the bundle itself.--schemanow advertises the contract input, as MCP does.compare-source-to-bundle:compare_source_to_bundle, withcallerPaths: [["reference","path"]]andviewomitted with a reason.compareSourceToBundleCliInputSchemais deleted.executeSourceToBundleComparisonalways parses with the contract schema; MCP no longer passes it.reference.pathasrequestedReferencePath, soreference_source.requested_pathstays the relative spelling.contractCommand.ts:omittedDocumentFieldErrorrefuses an omitted top-level field with<field> is not accepted by this command: <reason>.contractCliDescription.ts:admitDocumentCallerPathrewrites each caller-path leaf of the advertised document tocliJsonCallerPathSchema, through unions and wrappers. Clones keep their parent's registry metadata.cliJsonInput.ts: owns the CLI's URL rule (fix(cli): file URLs become invented local paths in Electron requests #2577) once.URL_REFERENCE_SOURCEfeeds both the resolver andcliJsonCallerPathSchema. That schema is a local path that is not afile:/scheme://URL, spelled case-insensitively, so--schemaadvertises exactly what the CLI resolves. A file literally namedfile:ref.jsonis selected as./file:ref.json, as for the other document commands.operationfor these three commands is now the contract operation (compare_source_to_bundle), not the command name, matching the other projected commands.compare-static-and-observed-endpointsandcapture-browser-scenario. They take contract fields (detail,view) as CLI flags next to the document, which the document projection cannot express yet.validate-browser-scenarioandobserve-native-calls.Contract and boundary impact
registerJsonCommand,documentSchemaandcompareSourceToBundleCliInputSchema.--schema:{}.compare-source-to-bundleis otherwise unchanged.viewis refused with its reason. Input-errordetails.operationuses the contract operation for the three migrated commands.reference_source.requested_pathstill keeps the caller's spelling (covered byapplicationWorkflowCli.test.ts).Expected effects:
(No effect changes.)
Evidence and regression coverage
jsonInputSchema.test.ts:coverageand a malformed embedded bundle.admitRelativePath).jsonInputStatus.test.ts:compare-source-to-bundleandtrace-application-featurerefuse an omittedviewwith its reason.file:ref.jsonis refused at["reference","path"].jsonInputSchema.test.tsalso checks that the advertised caller path acceptsref.json,./file:ref.jsonandC:\ref.json, and rejectsfile:,FILE:andhttps://spellings.cliContractCommandParity.test.ts: lists the two new document commands.contractCommand.tschange (2 failed).admitDocumentCallerPath. It showedallOf: [{pattern:"^[^\\x00]*$"},{pattern:"^\\/"}]forinspect-analysis-view,compare-artifacts,capture-electron-scenarioandcompare-source-to-bundle.node scripts/rea.mjs compare-source-to-bundle '{"reference":{"kind":"file","path":"ref.json"},"application":{},"view":{"kind":"summary"}}' --json):Validation performed
npm run typecheck: passed.npm run lint: 0 errors.npm run verify:module-boundaries: passed.npm run test:focused -- tests/boundary/cli/jsonInputSchema.test.ts tests/boundary/cli/jsonInputStatus.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/cli/analysisViewCli.test.ts tests/boundary/cli/artifactComparisonSources.test.ts tests/boundary/cli/electronCli.test.ts: passed (357 tests in the last combined run).npm run test:focused -- tests/boundary/filesystem/sourceToBundlePaths.test.ts tests/boundary/mcp/sourceToBundleViewsMcp.test.ts tests/acceptance/applications/applicationWorkflowCli.test.ts: passed. These ran together with the schema, status and parity tests (429 passed). The one status failure in that run was the expected operation-name change, fixed and rerun.npm run test:focused -- tests/process-global/sourceToBundleReferenceGuards.test.ts tests/boundary/cli/reconstructionCoverageCli.test.ts tests/boundary/cli/reconstructionObligationLedgerCli.test.ts tests/boundary/cli/inlineEvidenceBundleKind.test.ts: 38 passed.npm run test:focused -- tests/boundary/cli/jsonInputSchema.test.ts src/cliJsonPaths.test.tsandnpm run test:focused -- tests/boundary/cli/jsonInputStatus.test.ts tests/boundary/cli/cliContractCommandParity.test.ts: all passed.--no-verify; typecheck and lint were run manually as above.main(dropping refactor(cli): project JSON-document workflow commands from their contracts #10668's commits). The merge gate (briefs/local-gate.sh) failedcheck:faston theprovider-failure-classifierlint foromittedDocumentFieldError(…, document: unknown); it now takes anobjectand the caller narrows (the shape later stack PRs already use).npm run test:focused -- tests/boundary/cli/jsonInputSchema.test.tsfailed becausemainnow requiresevidence_format: 1in Evidence bundles; the coverage fixture now carries it, and 43 tests injsonInputSchema/jsonInputStatuspass.briefs/local-gate.sh 10697 refactor/cli-contract-reconstruction-documents: passed.Compatibility, safety, and release
compare-source-to-bundlealready refusedview(strict schema); it now names the reason.details.operationfor the three commands changes from the command name to the operation name, as for the other projected commands.Author readiness
Human owner:
Before merge
type(scope): outcome.