Skip to content

refactor(cli): project JSON-text options and pwntools inspectors from contracts - #10589

Merged
morluto merged 1 commit into
mainfrom
refactor/cli-contract-json-options
Nov 15, 2026
Merged

morluto merged 1 commit into
mainfrom
refactor/cli-contract-json-options

Conversation

@morluto

@morluto morluto commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Summary

Third slice of plan W1, stacked on #10576 (base refactor/cli-contract-artifact-inspectors; retarget after #10571 and #10576 merge). Refs #10583 (the projection stays framework-neutral).

It adds a JSON-text option projection to the contract command description and migrates inspect-binary-layout and inspect-recorded-crash, deleting their hand-written options and input spreads.

Problem and expected behavior

Structured contract fields such as producer_limits reach the CLI as one JSON text argument. Each command wired that by hand through producerLimitsOption(<schema copy>) and then mapped the decoded value back by hand. The derived projection must keep:

  • the flag names: --producer-limits, and --debugger-context for include_debugger_context;
  • the advertised object schema;
  • the argv-time refusal message producer-limits must be a JSON object.

Change and scope

  • contractCliDescription.ts: new projection list jsonText: [field]. The parameter admits text, decodes it with safeParseJson, and pipes the value into the contract field's own schema, so --schema advertises the contract's structure. Parameters gain a jsonText fact for renderers.
  • Migrated:
    • inspect-binary-layout: detail is omitted with a reason, as before.
    • inspect-recorded-crash: --debugger-context is a rename of include_debugger_context.
    • Both keep their inspectAndClose + withEvidenceCallerInputPath handler.
  • Parity guard: JSON-text fields are probed with valid, malformed and contract-refused JSON ({"input_bytes":0}, unknown keys, [], null).
  • Not included, as follow-ups:
    • inspect-rust-binary, inspect-python-pyc, inspect-erlang-beam and inspect-model-artifact. Their --view is a delivery selection decoded at run time with command-specific messages, and it is validated with per-operation delivery schemas and view kinds (rust also derives the detail default from view). That needs a view-delivery projection, not just JSON text.
  • Contribution scope: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the CLI argv projection (describeContractCommand).
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract:
    • MCP: unchanged.
    • CLI --schema: semantically identical for both commands.
    • Help: lists the same lines, with --producer-limits moved after the timeout option (contract order).
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged (same services and inspectAndClose).
  • Generated metadata, package, or installation impact: none.

Expected effects:

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

(No effect changes: the migrated commands keep their existing behavior.)

Evidence and regression coverage

  • Tests added or updated: parity guard JSON-text probes; it now covers 20 projected commands.
  • Base reproduction or other evidence: captured --schema --format json and --help before and after. --schema is semantically equal for both commands; help differs only in option order.
  • User-visible CLI/MCP output: help option order only.
  • Remaining proof gaps: no real pwntools run on this host beyond the process-global CLI tests listed below.

Validation performed

  • npm run typecheck: passed.
  • npm run check:fast: exit 0.
  • npm run knip: no findings.
  • npm run test:focused -- 7 files: 7 passed; 228 tests passed.
    • Parity guard.
    • Local-path admission (acceptance).
    • pwntools CLI remediation and finalization (process-global).
    • Lazy registration, integer arguments and help default annotations (CLI boundary).

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: no change in authority or side effects.

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

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T01:17:15.247192Z 1a19726 New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no actionable regression was found.

Summary

Adds JSON-text options to describeContractCommand and migrates inspect-binary-layout and inspect-recorded-crash to shared command registration.

  • The two pwntools inspectors now derive their options from tool contracts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Contract["Contract field schema"] --> Projection["describeContractCommand"]
  Argv["JSON-text option"] --> Decode["safeParseJson"]
  Projection --> Check["Contract field checks"]
  Decode --> Check
  Check --> Map["toContractInput"]
  Map --> Inspect["inspectAndClose"]
  Inspect --> Evidence["Evidence with caller path"]
Loading

Reviews (2) · Last reviewed commit: "refactor(cli): project JSON-text options..." · Reviewed by Greptile

@morluto
morluto force-pushed the refactor/cli-contract-artifact-inspectors branch from 377a0ba to 8c0e8ab Compare November 14, 2026 20:33
@morluto
morluto force-pushed the refactor/cli-contract-json-options branch from 07d25a2 to 793dfbb Compare November 14, 2026 20:33
@morluto
morluto force-pushed the refactor/cli-contract-artifact-inspectors branch from 8c0e8ab to 377a0ba Compare November 14, 2026 20:33
@morluto
morluto force-pushed the refactor/cli-contract-artifact-inspectors branch from 377a0ba to 8c0e8ab Compare November 14, 2026 20:33
@morluto
morluto deleted the branch refactor/cli-contract-artifact-inspectors November 15, 2026 01:15
@morluto morluto closed this Nov 15, 2026
@morluto morluto reopened this Nov 15, 2026
@morluto
morluto changed the base branch from refactor/cli-contract-artifact-inspectors to main November 15, 2026 01:15
… contracts

Add a jsonText declaration to the contract command description: a
structured contract field is taken as one JSON text argument, decoded at
argv parsing, and admitted by the contract field's own schema, so
--schema advertises the contract's structure. This generalizes the
per-command producerLimitsOption wiring.

Migrate inspect-binary-layout and inspect-recorded-crash (producer_limits
as JSON text; recorded-crash keeps --debugger-context for
include_debugger_context) and delete their hand-written options and input
spreads.

The parity guard probes JSON-text fields with valid, malformed and
contract-refused JSON.
@morluto
morluto force-pushed the refactor/cli-contract-json-options branch from 793dfbb to 1a19726 Compare November 15, 2026 01:15
@morluto
morluto merged commit 79cc07e into main Nov 15, 2026
52 checks passed
@morluto
morluto deleted the refactor/cli-contract-json-options branch November 15, 2026 04:34
@morluto morluto added area: cli CLI adapter and one-shot commands provider: pwntools Analysis provider / engine: pwntools labels 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 provider: pwntools Analysis provider / engine: pwntools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant