#13940

[Bug] analyze-javascript-application loads AnalysisViewService at CLI startup since #13861

OpenEntrpiopened 3d ago

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

CLI

Observed behavior

tests/boundary/cli/cliStartupImports.test.ts › "CLI one-shot command imports › loads summary projection and bundle delivery only when requested" fails on main. A plain rea analyze-javascript-application <dir> --json now loads AnalysisViewService and analysisViewResult at startup, although neither --detail summary nor --evidence_output was given:

- Expected
+ Received

  Set {
+   "analysis-view-result",
+   "analysis-view-service",
    "javascript-application",
  }
 ❯ tests/boundary/cli/cliStartupImports.test.ts:363:6

Pull requests whose CI runs this test fail on it. Four fork PRs did on 23 Nov: shard 11 or shard 5, plus Portable tests.

Reproduction

From a clean checkout with npm ci:

npm run build
npx vitest run tests/boundary/cli/cliStartupImports.test.ts -t "summary projection"

Results on macOS arm64 with Node 24.22.1, one run each:

CommitResult
c5361cbe8 (#13852)passes
97a95103d (#13861) parentpasses
97a95103d (#13861)fails
a023edf89 (#13867)fails
1d4fadcebfails
836cb8a01fails

Expected behavior

analyze-javascript-application --json loads only the javascript-application heavy module. The analysis-view and bundle-delivery modules load only with --detail summary or --evidence_output, as the test states.

Impact and scope

The impact is CLI startup cost and import isolation. I observed no change to results. Every CI run that includes this test fails until it is fixed. Other one-shot commands that reach a migrated service may load the same modules at startup; I did not test them.

REA version

source revision 836cb8a01

Runtime and platform

macOS arm64, Node.js 24.22.1; also GitHub Actions ubuntu-latest (CI)

Target and artifact context

a directory with one index.js (export const answer = 42;), as in the test

Interface

CLI

Earliest failure stage

Unknown

Relevant output or evidence

The test's own resolution hook reports the extra modules. A registerHooks resolve hook that logs the parent of each resolved dist/cli-runtime chunk shows this chain at 97a95103d, while the command runs with --json only:

cli-runtime/ArtifactInspectionExecution-*.js <- cli-runtime/electronFuses-*.js
cli-runtime/AnalysisViewService-*.js         <- cli-runtime/ArtifactInspectionExecution-*.js
cli-runtime/analysisViewResult-*.js          <- cli-runtime/AnalysisViewService-*.js

Analysis or suspected cause

This section is source-derived. src/application/ArtifactInspectionExecution.ts statically imports projectRetainedAnalysis, requireAnalysisViewRetention and AnalysisViewRetention from ./analysisView/AnalysisViewService.js. #13861 moved ElectronFuseService onto executeArtifactInspection, and the JavaScript application command reaches it through the electronFuses chunk. So the runner's static import now loads the analysis-view modules on that startup path.

A possible fix, not tried: load AnalysisViewService in the runner only when a request asks for retention or a view.

Additional context

Last known good: 97a95103d's parent. First known bad: 97a95103d (#13861). Main's own CI was green at c5361cbe8.

Activity

2
XiaoBinGan2d ago

Working on this — the startup graph should not pull AnalysisViewService for a plain analyze-javascript-application run. I will report the import edge that brings it in, plus the control that the deferred path still loads when --detail summary or --evidence_output asks for it.

XiaoBinGan2d ago

Checked this against current main (ca26f2ac8) before writing a patch, and the regression is no longer there — closing rather than shipping a fix for behaviour that is already absent.

Evidence:

  • tests/boundary/cli/cliStartupImports.test.ts on main: 10 passed (10), after npm run build:cached so the run uses a current dist (a stale dist/cliBuiltinArguments.js fails with classifyCliEntrypoint is not a function, which is an environment error rather than this assertion).
  • The case named in the report — loads summary projection and bundle delivery only when requested — asserts the set is exactly {javascript-application} for a plain --json run, and that same case passes here.
  • main CI at 09:41 succeeded, and the most recent red main run (09:31) failed in Deep static checks, not in this boundary suite.
  • The import edges that could pull the service in eagerly are typed or dynamic today: ArtifactInspectionExecution.ts carries import type { AnalysisViewRetention } (erased) and loads the service through await import(...).

For the forks that saw this: a branch based before ca26f2ac8 keeps the old startup graph, so rebasing onto current main should clear it. If it still reproduces on a current rebase, please reopen with the branch head and the shard, and I will take it from there.