Repository navigation
perf(cli/mcp): decouple analysis view contracts and defer tshark PATH probes - #13316
Merged
Merged
Conversation
Codex Review Summary: ✅ CompletedThis 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. |
Contributor
[Medium impact] The PR appears safe to merge; no actionable regression was found. SummarySplits shared contracts and summary schemas into smaller modules. Diagnostic services and evidence-delivery modules now load when requested.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
CLI["CLI command"] --> Contracts["Small contracts and options"]
CLI -->|"handler runs"| Service["Selected diagnostic service"]
CLI -->|"summary with evidence_output"| View["AnalysisViewService"]
CLI -->|"evidence_output"| Bundle["EvidenceBundleCommands"]
Server["createServer"] -->|"later binary_session request"| Policy["Availability policy"]
Policy -->|"default policy and artifact advertised"| Probe["tshark PATH lookup"]
Reviews (3) · Last reviewed commit: "test(cli): separate one-shot import suit..." · Reviewed by Greptile |
… paths and defer tshark PATH probes
morluto
force-pushed
the
perf/cli-bundle-decoupling-and-lazy-probes
branch
from
November 22, 2026 14:42
8427825 to
8ddedbb
Compare
Owner
Author
|
@greptileai review |
morluto
enabled auto-merge (squash)
November 22, 2026 14:52
9 of 22 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Decouples global CLI/contract barrel imports (
openBinaryToolContract,analysisViewResultsummary schemas,nativeTargetOption,analysisEvidenceDeliveryOptions), splitssrc/composition/binaryDiagnostics.tsfor handler-time lazy imports, and deferstshark(tsharkLocatable)PATHprobes out ofcreateServerstartup (Refs #13275):129files):openBinaryOutputSchema&OPEN_BINARY_TOOL_CONTRACTinto openBinaryToolContract.ts (re-exported fromsessionToolContracts.tsand shared withtoolOutputSchemaGroups.ts).NATIVE_OPEN_HELP&nativeTargetinto nativeTargetOption.ts andanalysisEvidenceDeliveryOptions/cliEvidenceDeliveryInputErrorinto analysisEvidenceDeliveryOptions.ts; switched analysisEvidenceDelivery.ts to dynamicawait import(...)forAnalysisViewService,EvidenceBundleCommands,AnalysisEvidenceSources, andevidenceBundle(loadingAnalysisViewServiceonly whenevidenceOutput !== undefined && input.detail === "summary").byteEntropyOutputSchemato byteEntropyOutputSchema.ts andelectronFuseOutputSchemasto electronFuseOutputSchema.ts.analysisViewResult.tssummary schemas (48domain-scoped modules):artifactSchema,viewResultBaseFields, andsummaryViewResultBaseinto analysisViewBase.ts (zero dependency onNATIVE_INVENTORY_OPERATIONS/NATIVE_OBSERVATION_OPERATIONS).src/domain/analysisView/summarySchemas/*.ts, re-exported by analysisViewResult.ts for backward compatibility while repointing domain*ToolContracts.ts,toolOutputSchemaGroups.ts, and ArtifactComparisonEvidence.ts so onlyanalysisViewToolContracts.tspulls inanalysisViewResult.ts.binaryDiagnosticsservice handlers & deferredtsharkLocatableprobe:inspectWithService/deliverWithServicein contractCommand.ts to accept() => EvidenceInspectionService | Promise<EvidenceInspectionService>.src/composition/binaryDiagnostics/*.tsand switched binaryDiagnosticsCommands.ts to dynamicawait import(...)per command handler.OptionalAvailabilityFeatures/observeOptionalFeaturesto CapabilityAvailability.ts, movedpacketCapture(tsharkLocatable) out of eagercreateServerstartup probes in capabilityServices.ts, and evaluated it only in default sessionAvailabilityPolicy.ts when"artifact"is advertised (createServer.ts).Problem and expected behavior
inspect-binary-hardening) andcreateServerstartup eagerly pulled inanalysisViewResult.ts(~1.3 MB bundled chunks), all 20 binary diagnostics composition services, andEvidenceBundle/AnalysisViewServicegraphs (~6 MB static ESM chunks across 193 modules), whilecreateServerran a subprocesstsharkPATHlookup even when the"artifact"family was not advertised or a custom availability policy was active.AnalysisViewsummary schemas, and capability availability diagnostics with 67.5% smaller static CLI module graphs and zero eagertsharkspawn on server startup.Change and scope
analysisView/summarySchemas/, compositionbinaryDiagnostics/, server availability, and tests.analysisViewResult.tsview-projector internals and*View.tsmodules untouched (handled separately in perf(analysis-view): retain frozen snapshots across parent readers and index view lookups #13315).Follow the contribution scope.
Not applicable (internal module-graph decoupling, dynamic handler imports, and lazy capability availability within existing CLI/MCP boundaries).
Contract and boundary impact
cliContractCommandParity,cliContractSchemaParity,cliToolCoverage, anddocs:checkall pass).tsharkLocatabledeferred to"artifact"family policy evaluation; 3 Linux-only availability cases skipped on darwin).analysisViewResult.tsre-exports all extracted schemas identically).binaryDiagnosticsCliCleanup.test.ts,pwntoolsCliRemediation.test.ts,pwntoolsCliFinalization.test.tsto target direct module ownersbinaryLayout.js/recordedCrash.js).docs/public/product-catalog.json), package, or installation impact: verified vianpm run build:cachedandnpm run docs:check.Expected effects:
Evidence and regression coverage
tsharkLocatabledetection onbinary_sessionand confirms skipping when"artifact"is unadvertised or customavailabilityPolicyis supplied.dist/cli-runtime/, Apple M5 arm64, Nodev24.22.1):193chunks (6,079,227 B) ->118chunks (1,974,876 B) (-38.9% chunks, -67.5% / -4,104,351 B)binaryDiagnosticsCommandsstatic ESM graph:154chunks (5,395,355 B) ->66chunks (1,193,860 B) (-57.1% chunks, -77.9% / -4,201,495 B)node scripts/rea.mjs inspect-binary-hardening <sample.bin> --json: loadeddist/cli-runtime/chunks194 -> 147(6,089,776 B -> 2,283,357 B, -62.5%); cold495.2 ms -> 346.7 ms, warm median735.7 ms -> 343.9 ms(2.14x faster).tsharkprobe on startup.For evidence-bearing changes:
Validation performed
npm run format:check(8,676files) — passednpm run build:cached(3/3in8.744s) — passednpm run check:fast(typecheck,lint,verify:architecture-guardsacross3,018source files) — passednpm run verify:module-boundaries(4,680files) &npm run docs:check(8/8) — passednpm run test:focused(14compiled boundary suites includingpacketCaptureAvailability.test.ts&cliLazyRegistration.test.ts) —14/14files,1,016passed |3Linux-only skipped (it.runIf(linux))npm run test:focused(unsandboxed CLI startup/cleanup suites:tests/boundary/cli/cliStartupImports.test.ts6/6,tests/process-global/pwntoolsCliFinalization.test.ts13/13) —2/2files,19/19passednpm run test:local(35non-HTTP server/view/contract/cli unit suites) —35/35files,293passed |3pre-existingwin32skipsnpm run test:local(unsandboxed HTTP server suites:serveEnvironmentState.test.ts25/25,serveStreamableHttp.test.ts69/69,serveEnvironment.test.ts12/12,nodeHttpBridge.test.ts9/9) —4/4files,115/115passedCompatibility, safety, and release
analysisViewResult.tsandbinaryDiagnostics.tspreserve re-exports for existing consumers).v24.22.1CLI/MCP compiled-runtime suites on darwin.verify:module-boundariesanddocs:checkpass across all updated modules.tsharkLocatablerespectshostRestrictedAvailabilitypolicies and does not alter capability authorization semantics.Author readiness
Human owner:
Before merge
type(scope): outcome.