Repository navigation
refactor(cli): project inspect-artifact and extract-artifact with open_binary target options - #10722
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] This PR appears safe to merge; no actionable issue was found. SummaryMoves
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["CLI artifact options"] --> B["Check opening contract"]
B --> C["Shared selection mapping"]
D["MCP open_binary input"] --> C
C -->|CLI| E["runProviderAnalysis"]
C -->|MCP| F["session.open"]
E --> G["Inspect or extract"]
G --> H["Deliver Evidence"]
Reviews (1) · Last reviewed commit: "refactor(cli): project inspect-artifact ..." · Reviewed by Greptile |
ee0ea16 to
6129b8e
Compare
ce4fa7c to
abd18b3
Compare
6129b8e to
5310117
Compare
abd18b3 to
05ed54d
Compare
5310117 to
589c9f3
Compare
e6f1711 to
0e105c7
Compare
589c9f3 to
f766b78
Compare
0e105c7 to
bd32c3d
Compare
519cfcf to
4255498
Compare
00fc8a2 to
eefe85d
Compare
4255498 to
d6b961c
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…n_binary target options A declared session target can now take fields of the contract an MCP client opens the target with as options. They are admitted by that contract, with the target as its path, before the target is opened, and the projection can narrow an enum to the values the command supports. inspect-artifact and extract-artifact are derived from their contracts with open_binary's format and ESP flash fields. MCP open_binary and the CLI share one mapping from those fields to the target selection. extract-artifact now runs under the command's cancellation signal.
eefe85d to
58a3b8b
Compare
d6b961c to
4ea8804
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. |
… its contract document (#10700) * refactor(cli): project observe-native-calls onto a session target and its contract document * refactor(cli): project endpoint comparison and browser scenario documents with delivery options (#10711) * refactor(cli): carry document command delivery as options and project endpoint and browser scenario commands A JSON-document projection can now take the contract's detail and view fields as --detail, --evidence_output and --view beside the document. The document refuses those fields with the option to use, and the delivery is admitted by the contract's own view schema before the document is read. compare-static-and-observed-endpoints, capture-browser-scenario and validate-browser-scenario now register from their contracts; validation projects the capture contract without detail. * fix(cli): admit the endpoint comparison document before reading its Evidence bundle The document command context carries the document's transport frame, so a handler that reads an Evidence bundle first can refuse a malformed document beforehand, as the hand-written command did. * refactor(cli): pass only object documents to the document field refusal * refactor(cli): project inspect-artifact and extract-artifact with open_binary target options (#10722) * refactor(cli): project inspect-artifact and extract-artifact with open_binary target options A declared session target can now take fields of the contract an MCP client opens the target with as options. They are admitted by that contract, with the target as its path, before the target is opened, and the projection can narrow an enum to the values the command supports. inspect-artifact and extract-artifact are derived from their contracts with open_binary's format and ESP flash fields. MCP open_binary and the CLI share one mapping from those fields to the target selection. extract-artifact now runs under the command's cancellation signal. * fix(cli): read open_binary from its session contract so startup stays lazy * build(lint): refuse value imports of the complete tool catalog in CLI startup modules
Summary
Next slice of plan W1, stacked on #10711 (base
refactor/cli-contract-document-delivery; retarget as the lower PRs merge). Refs #10583.A declared session target can now take fields of the contract an MCP client opens the target with (
open_binary) as options.inspect-artifactandextract-artifactare derived from their contracts withopen_binary's format and ESP flash fields. This is thesessionTarget.openextension designed in #10656.Problem and expected behavior
inspect-artifactandextract-artifactwere hand-written:--artifact-limitsJSON parser (producerLimitsOption).--target-format,--flash-offsetand--partition-table-offsetwere hand-written options. A private mapping (espFlashTargetSelection) duplicated the one the MCPopen_binaryhandler held.--flash-offsetwas refused only after the target was opened, by the target resolver.extract-artifactran without the command's cancellation signal.Expected behavior: the same arguments, options, defaults and help. The opening options are admitted by
open_binary's own input schema before the target is opened.Change and scope
contractCliDescription.ts:CliSessionTarget.opennames the opening contract and the fields taken as options. Each field keeps its own schema. A field projection may givevaluesto narrow an enum; registration checks that the contract admits each value.describeSessionTargetnow builds the target for both flag and document commands.admitOpeningadmits the selected fields with the opening contract, with the target as itspath. Issues name CLI keys.contractCommand.ts:opening.runOnSessionTargetpasses the opening selection torunProviderAnalysisand, forevidenceDelivery, publishes complete Evidence or a summary.sessionLifecycleInputs.ts: newopenBinaryTargetSelection, the one mapping fromopen_binaryfields to the target selection.registerSessionTools.ts(MCPopen_binary) uses it instead of its inline copy.artifactCommands.ts:inspect_artifactandextract_artifact.--target-formatadmits onlyesp-flash-image, as before.extract-artifactstill fills an omittedoutput_rootwithcreateArtifactExtractionDestination.sessionToolContracts.ts:open_binaryis exported asOPEN_BINARY_TOOL_CONTRACTand listed first inSESSION_TOOL_CONTRACTS, as before.artifactCommands.tsreads it there. Reading it throughtoolContractfromtoolContracts.tsloaded the complete tool catalog when the CLI registered its commands, whichtests/boundary/cli/cliStartupImports.test.tsrefuses..oxlintrc.json:src/cli*.tsandsrc/cli/**may not importcontracts/toolContracts.jsexcept as a type. Stacked PRs get no CI run (CI runs only for PRs intomainorrelease/*), and the startup test needs a build, so the regression was not caught before. The lint rule runs in the pre-pushcheck:fast.producerLimitsOption.ts: the unusedproducerLimitsOptionis removed (jsonTextreplaces it); the help constant stays.output_rootstays absolute-only on the CLI, as before. Admitting caller-relative paths waits for test(cli): report CLI fields that admit values their contract refuses #10575 (W1 item 5).inspect-artifactEvidence (W1 step 7).runDirectAnalysisrunner with provider, architecture, entry point and snapshot options.Contract and boundary impact
openBinaryTargetSelectionowns the field-to-selection mapping for MCP and CLI.extract-artifactlists the same options, descriptions and defaults;--output-rootnow shows the contract's description.--flash-offsetor--partition-table-offsetis now refused asinvalid_requestwith issue pathflashOffset/partitionTableOffset, before the target is opened. The message is the sameespFlashSelectionErrortext.extract-artifactnow runs underwithCommandCancellation, and the analysis receives the command's signal.Expected effects (unchanged from the existing commands; left for the human owner to check: reads the artifact, and
extract-artifactwrites files to its destination):(
extract-artifactwrites the selected files to its destination, as before.)Evidence and regression coverage
cliContractCommandParity.test.ts):admitOpeningreturns them in contract spelling.flashOffset.--target-formatadmits onlyesp-flash-image.pathopening field, or narrows to a value the contract refuses, throws.espFlashImageCli.test.ts: unpaired refusal message, automatic guess, caller-selected offset.espFlashImageMcp.test.ts,rawBinaryMcp.test.ts,gamecubeDolSessionMcp.test.ts,artifactMcp.test.ts: the MCPopen_binarymapping.extract-artifact t.zip --output-root <abs>: extracteda.txt.extract-artifact t.zip --flash-offset 0x1000:invalid_requestatflashOffset.inspect-artifact t.zip --detail summary:invalid_request, summary needs--evidence_output.extract-artifactduring extraction is not exercised by a new test.Validation performed
npm run test:focused -- tests/boundary/cli/cliContractCommandParity.test.ts tests/acceptance/espFlashImageCli.test.ts: 306 passed.npm run test:focused --17 artifact and ESP files (espFlashImageMcp,artifactReaderLimitsCli,artifactArmSlicesCli,emptyLocalTargetAdmission,emptyArtifactBundleTargetCli,javascriptIntegrityPolicyCli,artifactZipCurrentDirectory,artifactCallerSelection,cliOutput,analysisViewCli,artifactZipIntegrity,espImageCli,godotPck,nodeSeaCli,unityFsCli,artifactZstandardWindow,artifactExtractionCoverage): 233 passed, 2 skipped.npm run test:focused -- tests/boundary/mcp/rawBinaryMcp.test.ts tests/boundary/mcp/gamecubeDolSessionMcp.test.ts tests/boundary/mcp/artifactMcp.test.ts: 26 passed, 2 skipped.npm run check:fast: passed.npm run test:focused -- tests/boundary/cli/cliStartupImports.test.ts: 6 passed; with the oldartifactCommands.tsit fails ("does not load command-specific code to register the command catalog").npx oxlintreports the old import asno-restricted-importsand admits a type-only import.npm run check:fast: passed.npm run knip: no findings, after removingproducerLimitsOption.npm run docs:check: passed.node scripts/rea.mjs extract-artifact --helpand the smoke runs above: as described.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.