Skip to content

refactor(capabilities): declare standalone and host-gated availability on the contract - #11270

Merged
morluto merged 1 commit into
mainfrom
refactor/capability-availability-declarations
Nov 15, 2026
Merged

morluto merged 1 commit into
mainfrom
refactor/capability-availability-declarations

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Part of plan W1 (one owner for adding a tool). The capability inventory decided most tools' availability with name === "..." branches in src/application/CapabilityInventory.ts (56 on main), so a new tool needed both a contract and a hand-written branch. Most branches said one of two things: the tool is a standalone workflow that is always available, or it is an optional host integration gated by host support and one configuration flag.

Contracts now declare that with availability: "standalone" or availability: { host: <feature> }, and the inventory interprets the declaration once. 44 contracts declare it; the inventory has 17 name === checks left, all named rules that do not fit the two shapes.

Refs #10583

Problem and expected behavior

Expected: a new standalone or host-gated tool is reported correctly by list_capabilities/get_session_status from its contract alone. Before (from reading the source, not run): without a matching branch, such a tool fell through to the provider rules for its kind, for example provider_missing for a native-provider tool that needs no deep provider.

Change and scope

  • src/contracts/toolAvailability.ts (new): ToolAvailabilityDeclaration ("standalone" | { host: HostRestrictedFeature }). HOST_RESTRICTED_FEATURES moves here from the application layer so contracts can name a feature; sessionAvailabilityPolicy.ts imports it from here.
  • ToolContract.availability? is declared on:
    • 31 standalone contracts: byte entropy, the PE/ELF/kernel/devicetree/Apple IPS/shortcut/hardening/release-exposure diagnostics, the artifact inspectors (APK signature, desktop application, Go, IL2CPP, model, GPU code objects, Rust, Python pyc, Erlang BEAM, V8 code cache, Electron fuses), the JavaScript application analysis and runtime reconciliation, and the two caller-endpoint web runtime tools.
    • 13 host-gated contracts: GDB/Rizin sessions (persistentDebugger), JavaScript recovery, binary layout, recorded crash, packet capture (2), signal recording (2), pcap capture, EVM interface, firmware inspection and extraction.
  • CapabilityInventory.ts:
    • HOST_FEATURES gives each feature's configuration flag and remediation (the remediation strings are unchanged). hostFeatureAvailability applies it through the existing hostRestrictedAvailability, so an unsupported host still takes precedence over configuration.
    • The standalone check stays where the byte-entropy/web-runtime early return was, ahead of optional-provider load failures, and is repeated in the workflow rules so resource-only sessions treat these tools as before.
    • Named rules kept, as plain functions: SQLite's Node version, web module literal-resolution modes (webModuleImportAvailability), Wasm/WABT, the EVM limiter after its host check (evmLimiterAvailability), Android/ADB/Apktool/JEB owner probes, browser/electron/runtime providers, process capture, navigation context, and composed enhanced workflows.
    • The superseded per-name branches, javascriptApplicationAvailability and the firmware-kind branch are deleted.

Not included: toolEffects.ts still holds the effect audit per tool name; folding it into the contract declaration is the next W1 step, and the MCP binding loop is #11264.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the contract declares availability, and CapabilityInventory is the only interpreter. The superseded name branches are removed.
  • Contribution scope fit and linked maintainer decision: not applicable (internal refactor within existing boundaries).
  • CLI and MCP/tool-catalog contract: no availability result changes. availability is an internal contract field; it is not part of any advertised schema, and npm run verify:advertised-schemas reports the summary current.
  • Provider, bridge, target-format, or platform compatibility: unchanged; host restrictions keep their per-platform policy.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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/application/CapabilityInventory.test.ts adds "declared contract availability", which is driven by the declarations themselves:
    • Every standalone contract is available with no target, no provider and every optional provider failing to load.
    • Every host-gated contract reports unsupported_host with a remediation when its feature's host is unsupported.
  • Base reproduction or other evidence: refactor; the existing availability tests (packet capture, debugger host, EVM limiter, remediation inventory, session target requirements, resource sessions) pass unchanged.
  • User-visible CLI/MCP output (if applicable): none changed.
  • Remaining proof gaps: real Linux-only integrations (TShark, sigrok, pwntools, Wakaru, binwalk) were not exercised; their availability is decided from policy and covered by the tests above.

Validation performed

  • npm run test:focused -- src/application/CapabilityInventory.test.ts src/application/CapabilityInventory.optionalReads.test.ts src/application/binary/BinarySessionLiveness.test.ts src/application/binary/BinarySessionRefusalAlternatives.test.ts src/application/binary/BinarySessionStatus.test.ts tests/boundary/providers/readinessRemediationInventory.test.ts tests/boundary/providers/ida/idaCapabilityInventory.test.ts tests/boundary/mcp/serverIdentity.test.ts tests/boundary/mcp/sessionTargetRequirements.test.ts tests/boundary/evm/evmLimiterAvailability.test.ts tests/boundary/mcp/capabilityRemediationMcp.test.ts tests/boundary/mcp/debuggerHostAvailability.test.ts tests/boundary/mcp/packetCaptureAvailability.test.ts tests/boundary/mcp/sessionAvailabilityRecovery.test.ts tests/boundary/mcp/callRelationshipAvailability.test.ts tests/boundary/mcp/firmwareMcp.test.ts tests/boundary/mcp/signalRecordingMcp.test.ts tests/boundary/mcp/javascriptRecoveryMcp.test.ts tests/boundary/mcp/recordedCrashMcp.test.ts tests/boundary/mcp/pcapMcp.test.ts: 19 files passed and 2 skipped; 185 tests passed and 8 skipped.
  • npx oxfmt --check .: passed.
  • npm run check:fast: passed.
  • node scripts/verify/architecture-guards.mjs: passed.
  • npm run verify:advertised-schemas: passed.

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. Host restrictions and remediation text are unchanged.

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.

…y on the contract

Contracts declare availability: "standalone" or { host: <feature> }, and CapabilityInventory interprets the declaration once through one feature table, replacing 39 per-name branches. HOST_RESTRICTED_FEATURES moves to the contracts layer.
@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-15T15:15:52.330449Z
We couldn’t complete this review. Comment @codex review to try again.
b3c8ac7 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

[Low impact] The PR appears safe to merge; no actionable issues were found.

Summary

Moves availability declarations onto 44 tool contracts and replaces repeated name checks with shared rules in CapabilityInventory.

  • Capability reports now follow availability declared in each tool contract.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Contracts["ToolContract.availability"] --> Inventory["CapabilityInventory"]
  Policy["Host, configuration, and provider facts"] --> Inventory
  Inventory --> Standalone["Standalone rules"]
  Inventory --> Hosted["Host checks and EVM limiter"]
  Inventory --> Existing["Existing named and provider rules"]
  Standalone --> Result["Reported tool availability"]
  Hosted --> Result
  Existing --> Result
Loading

Reviews (1) · Last reviewed commit: "refactor(capabilities): declare standalo..." · Reviewed by Greptile

@morluto
morluto merged commit d167582 into main Nov 15, 2026
14 checks passed
@morluto
morluto deleted the refactor/capability-availability-declarations branch November 15, 2026 15:52
Plastic-time added a commit to Plastic-time/rea that referenced this pull request Nov 15, 2026
Main morluto#11264 registers service-backed MCP tools through one binding table,
and morluto#11270 declares tool availability on the contract. The merge takes
main's createServer.ts and CapabilityInventory.ts, then:

- binds inspect_pe_rich_header in serviceToolBindings.ts and passes the
  service to registerServiceTools, like inspect_pe_imports;
- marks the contract "standalone";
- removes registerPeRichHeaderTool.ts, as main removed its siblings.
@morluto morluto added the area: domain Domain logic, errors, and pure functions label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant