Repository navigation
refactor(application): make remaining AnalysisViewService helpers async - #14759
Plastic-time wants to merge 3 commits into
Conversation
Remove the last four static AnalysisViewService imports in src/application/ so the AnalysisViewService chunk is loaded dynamically only when view projection is actually needed: - Make resolveArtifactComparisonEvidence async in ArtifactComparisonEvidence.ts, allow async record/source resolvers in evidenceFileSource.ts and EvidenceInputResolver.ts (preserving post-await cancellation checks), and dynamically import AnalysisViewService only when reprojecting an inspect_analysis_view summary. - Make deriveEnvironmentState, prepareServedState, planEnvironmentBundle, and compareEnvironment async and dynamically import AnalysisViewService inside deriveEnvironmentState and environmentBuild.ts; await them in environmentExport.ts and src/cli/environmentCommands.ts (preserving cancellation checks). - Remove the leftover unused static summarizeRetainedAnalysis import in FridaInstrumentationService.ts (line 297 already loads it dynamically). - Remove the now-empty static-analysis-view-import.json architecture guard baseline, update the guard comment/message in scripts/verify/architecture-guards.mjs, and add async cancellation and startup-import regression coverage. Addresses morluto#14112
…in evidenceFileSource
[Low impact] The reviewed changes appear safe to merge. SummaryDefers
No actionable correctness or security issues were found. Tests were not run during this review. Supersession status could not be confirmed because GitHub access was unavailable. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Application helper] --> B{View needed?}
B -->|No| C[Return without loading view service]
B -->|Yes| D[Check source and prerequisites]
D --> E[Await dynamic import]
E --> F[Project view]
F --> G[Caller awaits result]
G --> H[Check cancellation before next side effect]
Reviews (2) · Last reviewed commit: "refactor(application): check cancellatio..." · Reviewed by Greptile |
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. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Summary
Addresses #14112
Implement Option 1 of #14112 as a draft PR for maintainer review: convert the remaining synchronous view-projection helpers (
resolveArtifactComparisonEvidenceandderiveEnvironmentState/prepareServedState) toasync, switchenvironmentBuild.tsto dynamic import, and remove the unused staticsummarizeRetainedAnalysisimport left inFridaInstrumentationService.ts. Together these remove all four remaining staticAnalysisViewServiceimports insrc/application/(emptying and deletingscripts/verify/baselines/static-analysis-view-import.json), sodist/cli-runtime/has zero static imports of theAnalysisViewServicechunk.Problem and expected behavior
ArtifactComparisonEvidence.ts,environmentState.ts,environmentBuild.ts, andFridaInstrumentationService.tsstatically importedAnalysisViewService.js. In the bundled CLI (dist/cli-runtime/), four chunks (artifactCommands,fridaCommands,environmentState,application__environment__environmentBuild) statically importedAnalysisViewService-*.js, causing commands such asinspect-artifact, non-summarycompare-artifacts, andfrida-devices --helpto loadAnalysisViewServiceeven when no view projection occurred.AnalysisViewServicetoawait import("../analysisView/AnalysisViewService.js")on the branch that actually projects or summarizes a view. CLI/MCP behavior and output contracts are unchanged;dist/cli-runtime/emits zero static imports ofAnalysisViewService-*.js, andscripts/verify/baselines/static-analysis-view-import.jsonis retired.Change and scope
EvidenceFileRecordResolver(src/application/analysisView/evidenceFileSource.ts) andEvidenceSourceResolutionOptions.resolveEvidence(src/application/EvidenceInputResolver.ts) to returnResult | Promise<Result>(their callersreadEvidenceFileSourceandresolveEvidenceSourceare alreadyasync) and preserved post-awaitabort checks when a caller cancels mid-resolution.resolveArtifactComparisonEvidenceasyncinsrc/application/artifacts/ArtifactComparisonEvidence.ts, preserving post-awaitcancellation handling, and movedinspectAnalysisViewValidatedbehindawait import("../analysisView/AnalysisViewService.js")right before summary reprojection so non-summary inventories and early validation failures never loadAnalysisViewService.deriveEnvironmentStateandprepareServedStateasyncinsrc/application/environment/environmentState.ts, dynamically importingAnalysisViewServiceafterparseEvidenceFilesucceeds.EnvironmentBundleOptions.servedandplanEnvironmentBundle(src/application/environment/environmentBundle.ts) andcompareEnvironment(src/application/environment/environmentCompare.ts) toasync, preserving name-validation-before-state-derivation ordering.src/application/environment/environmentBuild.tsto dynamically importinspectAnalysisViewon the already-asyncbuild path andawaitprepareServedState/planEnvironmentBundle.src/application/environment/environmentExport.tsandsrc/cli/environmentCommands.ts(including a post-awaitcancellation check inloadServeInputs).import { summarizeRetainedAnalysis } from "../analysisView/AnalysisViewService.js"insrc/application/frida/FridaInstrumentationService.ts(line 297 already dynamically imports it on the summary branch).scripts/verify/baselines/static-analysis-view-import.jsonviaarchitecture-guards.mjs --shrink-baselines(zero remaining copies across 3155 source files) and updated the guard comment/message inscripts/verify/architecture-guards.mjs.tests/fixtures/environmentServe.tstoawaitthe async helpers, added an asyncresolveSelectedcancellation regression test insrc/application/analysisView/evidenceFileSource.test.ts, and addedAnalysisViewServicedeferral assertions intests/boundary/cli/cliStartupImports.test.ts.src/server/*) intentionally keep their staticAnalysisViewServiceimports.analysisViewResultschema imports (environmentSource.ts,toolContracts.ts) are tracked separately under [Design] Lazy per-family MCP composition, build-time compact schemas, and splitting the 1.3 MB analysisViewResult CLI chunk #13275.Follow the contribution scope.
#14112 carries the
designlabel with two open options (Option 1: async-ify both helpers; Option 2: accept the current composition). This draft PR implements Option 1 so maintainers can inspect the actual diff and bundle effect; CLI/MCP user contracts are unchanged.Contract and boundary impact
ArtifactComparisonEvidence.ts,environmentState.ts,environmentBuild.ts, andFridaInstrumentationService.tsretain their existing ownership while deferringAnalysisViewServiceloading to dynamicimport(). No duplicated ownership introduced; the stale static import inFridaInstrumentationService.tsand the retired guard baseline file are removed.designlabel; Option 1 vs Option 2). This draft PR provides a concrete Option 1 implementation for evaluation.docs/public/product-catalog.json), package, or installation impact: None.Expected effects:
Evidence and regression coverage
tests/boundary/cli/cliStartupImports.test.ts: extended single-command startup check to coverenvironment-serve,environment-compare,environment-export, andenvironment-build; addeddefers AnalysisViewService for artifact inspection, non-summary comparison, Frida, and environment modulesverifying--helpforinspect-artifact,compare-artifacts,frida-devices, real runs ofinspect-artifactand non-summary evidence-filecompare-artifacts, and importing compiledenvironmentState.jsandenvironmentBuild.jsdo not resolveanalysis-view-service.src/application/analysisView/evidenceFileSource.test.ts: added regression test confirming cancellation during an asyncresolveSelectedcallback returnsAnalysisCancelledErrorwith the caller's abort cause.tests/fixtures/environmentServe.ts,src/application/artifacts/ArtifactComparisonEvidence.test.ts,src/application/environment/environmentState.test.ts,src/application/environment/environmentBundle.test.ts,src/application/environment/environmentScenario.test.ts,src/application/environment/environmentCompare.test.ts,src/application/environment/environmentCompareBody.test.ts,src/application/environment/environmentCompareBulk.test.ts, andsrc/application/environment/environmentCompareIdsIntegration.test.ts.dist/cli-runtime/on clean base402771122vs this branch: static imports ofAnalysisViewService-*.jsdropped from 4 (application__environment__environmentBuild,artifactCommands,environmentState,fridaCommands) to 0.402771122: the newdefers AnalysisViewServicetest failed on base (inspect-artifactandcompare-artifacts --helpresolvedanalysis-view-service) and passes on this branch.402771122and this branch:environmentBuild.test.ts:165quotes backslashed Windows temp paths in thenexthint ('E:\...') andcliStartupImports.test.tsanalyze-javascript-applicationexits 1 under Windows temp paths.For evidence-bearing changes:
Validation performed
npm run check:fast(after mergingorigin/mainda129c00a:typecheck,lint, andverify:architecture-guardsacross 3,163 source files) — passednpm run build:cached— passed (compile,bundle-runtime,artifacts:skills; 0 staticAnalysisViewService-*imports indist/cli-runtime/)npm run verify:module-boundaries— passed (4875 source files checked)npm run verify:test-discovery— passed (3932 test files discovered exactly once)npm run format:check— passed (8952 files)npm run test:focused -- src/application/artifacts/ArtifactComparisonEvidence.test.ts src/application/artifacts/ArtifactComparisonPathSources.test.ts src/application/environment/environmentState.test.ts src/application/environment/environmentBundle.test.ts src/application/environment/environmentBuild.test.ts src/application/environment/environmentCompare.test.ts src/application/environment/environmentCompareBody.test.ts src/application/environment/environmentCompareBulk.test.ts src/application/environment/environmentCompareIdsIntegration.test.ts src/application/environment/environmentScenario.test.ts src/application/environment/environmentExport.test.ts src/application/analysisView/evidenceFileSource.test.ts src/application/frida/FridaInstrumentationService.test.ts— 12/13 files passed cleanly; 1 pre-existing Windows path-quoting mismatch inenvironmentBuild.test.ts:165(sameTreebyte-for-byte check passed)npx --no-install vitest run --project cli-boundary tests/boundary/cli/cliStartupImports.test.ts -t "Bundled heavy startup controls"— passed (3/3 tests)402771122(defers AnalysisViewService) — confirmed failed on base, passes on branchCompatibility, safety, and release
src/application/changed from synchronous toPromise-returning, matching [Refactor] Decide async conversion for the two synchronous view-projection helpers blocking the AnalysisView chunk split #14112 Option 1).awaitpoints inevidenceFileSource.ts,ArtifactComparisonEvidence.ts, andloadServeInputs.Author readiness
Human owner: @Plastic-time
Author checklist (completed by the PR author before requesting review)
type(scope): outcome.REA_runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.