Repository navigation
fix(contracts): refuse empty address and procedure selectors in the contracts - #10753
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; no actionable correctness or security issues were found. SummaryThe PR makes shared
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
CLI[CLI arguments] --> Projection[Contract-derived fields]
Projection --> Selection[Choose selector and operation]
Selection --> Admission[Check contract input]
MCP[MCP request] --> Admission
Admission -->|Empty selector| Refusal[Reject before provider work]
Admission -->|Accepted input| Provider[Run selected operation]
Reviews (6) · Last reviewed commit: "test(cli): drop the empty-selector admis..." · Reviewed by Greptile |
3bebed9 to
5dead85
Compare
175d82a to
2720e58
Compare
5dead85 to
bb60c95
Compare
de7d5ad to
f0671e1
Compare
f0671e1 to
5d54b49
Compare
b8f774f to
8b730fc
Compare
6c83ed9 to
8829bc3
Compare
314a029 to
74f1dec
Compare
313e44e to
b45a717
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
1 similar comment
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
b45a717 to
f580815
Compare
74f1dec to
e05806c
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
1 similar comment
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
e05806c to
59190c5
Compare
f580815 to
5e16992
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
1 similar comment
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
59190c5 to
a8bd2c7
Compare
5e16992 to
79b6610
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
1 similar comment
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
… as an alternative selector (#10756)
… the operation (#10761) * refactor(cli): project search from its contracts with --kind choosing the operation * fix(cli): check operation choices' option rules and bind errors to the selected contract
…session target (#10778) * refactor(cli): project decompile-all from its contract onto a native session target * refactor(cli): project native Mach-O, Swift and native UI commands from their contracts
…m their groups so startup stays lazy
79b6610 to
6244b57
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
… summary #10753 changed 26 tools' advertised input schemas without regenerating the committed catalog summary, so verify:advertised-schemas failed on main.
Summary
Next slice of plan W1, stacked on #10738 (which now also carries #10747). Refs #10583.
An empty
addressorprocedureis now refused by the tool contracts themselves, so MCP and the CLI agree. The CLI-only empty-selector rule added in #10738/#10747 is replaced by a check that every CLI selector field's contract already refuses"".Problem and expected behavior
xrefs.address,read_function_instructions.procedure,procedure_references.procedureand the other official fields built from the sharedaddress/procedurehelpers were plainz.string(). An MCP call such asxrefs {"address": ""}passed input validation and reached the provider. The CLI refused the same value only because the contract-derived selector projection added its own.min(1). The two adapters disagreed on what the contract admits.Expected: a selector names one object, so
""is refused at admission by the contract, for both adapters, before any provider work.Change and scope
src/contracts/toolContractHelpers.ts: the sharedaddressandprocedurefields are.min(1).optionalAddressstill admits omission (Hopper's cursor fallback is unchanged).src/contracts/functionInstructionContract.ts:read_function_instructions.procedurereuses the sharedprocedurefield instead of its own copy.src/cli/contractCliDescription.ts: the selector projection no longer adds.min(1). It throws at description time if a selector field's contract admits"", so a future selector cannot reintroduce a CLI-only rule or a silent CLI/MCP disagreement. (The build fails withxrefs.address admits an empty selectorif the contract change is reverted.)cliContractCommandParity.test.ts: the oracle's special case for empty selectors is removed; the contract decides.Not included: other contract string fields that might also be meaningless when empty (names, comments, patterns).
set_comment.commentandset_bookmark.namedeliberately use""to clear and are unchanged.Contribution scope: admission change approved by the maintainer for W1 (CLI and MCP must agree).
contractNamed(OFFICIAL_TOOL_CONTRACTS, …),ENHANCED_TOOL_CONTRACTS,NATIVE_TOOL_CONTRACTS,ELECTRON_TOOL_CONTRACTS,OPEN_BINARY_TOOL_CONTRACT) instead oftoolContractfromtoolContracts.ts, which loaded the complete catalog at CLI startup (tests/boundary/cli/cliStartupImports.test.ts). The lint rule added in refactor(cli): project inspect-artifact and extract-artifact with open_binary target options #10722 keeps it out.Contract and boundary impact
.min(1)and the parity oracle's empty-selector exception.addressorprocedurefield (for examplexrefs,next_address,prev_address,procedure_address,procedure_assembly,procedure_callees,procedure_callers,procedure_info,procedure_references,procedure_pseudo_code,read_function_instructions,resolve_containing_procedure,set_address_name,set_bookmark,set_comment,unset_bookmarkand the Hopper memory tools) now refuse""as an SDK input-validation error, and their advertised JSON Schema gainsminLength: 1. Omitting an optional address is unchanged.VALIDATION_ERROR).Expected effects (unchanged; left for the human owner to check):
Evidence and regression coverage
tests/boundary/mcp/enhancedTools.inputValidation.test.ts: MCP calls toxrefs,read_function_instructions,procedure_references,procedure_pseudo_codeandset_commentwith an empty selector are errors and never reach the provider;xrefs {}still runs.cliContractCommandParity.test.ts: the oracle now takes empty-selector admission from the contract.xrefs: expected undefined to be true). With only the contract change reverted, the build fails at the new guard (xrefs.address admits an empty selector).For evidence-bearing changes:
Validation performed
npm run test:focused -- tests/boundary/mcp/enhancedTools.inputValidation.test.ts tests/boundary/mcp/compactInputSchemaMcp.test.ts tests/boundary/mcp/mcpSchemaValidation.test.ts tests/boundary/mcp/toolSchemaValidity.test.ts tests/boundary/mcp/packageCatalogVerification.test.ts tests/boundary/cli/cliInputSchemaRequired.test.ts tests/boundary/cli/analysisSelectorCli.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/cli/cliDomainFieldSchema.test.ts tests/boundary/cli/rawBinaryCli.test.ts— 595 passed.npm run test:focused -- src/contracts/*.test.tsplus the three CLI selector/parity tests — 801 passed, 3 skipped.npm run check:fast— passed.npm run docs:check— passed.This branch now also carries refactor(cli): project decompile from its contract with --file-offset as an alternative selector #10756 (decompile from
procedure_pseudo_code, collapsed into it); see that PR for its validation.After rebasing onto
mainwith the startup-import fix:npm run check:fastpassed (pre-push) at this branch; at the top of the stacknpm run test:focused -- tests/boundary/cli/cliStartupImports.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/cli/nativePlistCli.test.ts tests/boundary/cli/nativePlistSelectionFailureCli.test.ts tests/boundary/cli/contractCommandInputFields.test.ts tests/boundary/cli/nativeMachoEvidenceDeliveryCli.test.ts: 660 passed.After the restack onto main with test(cli): report CLI fields that admit values their contract refuses #10575:
npm run test:focused -- tests/boundary/cli/cliContractSchemaParity.test.tsfailed because the four empty-selector mismatches this PR fixes (inspect-native-api options.procedure,inspect-native-data-type options.address/options.type,search-bytes options.cursor) were still in its shrinking baseline; removed them, then it passed (4 tests).Compatibility, safety, and release
""for one of these fields used to reach the provider (which had no defined meaning for it) and is now refused at input validation; callers that meant "current cursor" forxrefs/next_address/prev_addressshould omitaddress. Not marked breaking because""never selected an object.Author readiness
Human owner:
Before merge
type(scope): outcome.