Repository navigation
test: the suite does not start real @opencode-ai/plugin installs - #1872
Conversation
A test that writes a tool or plugin file into a config dir makes the app start an `npm install` of `@opencode-ai/plugin` there. The install runs inside the test process and is not awaited, so it outlives the test. Several pile up, starve the event loop, and the tests that run next time out or the job is killed. This made the `TypeScript` shards fail on `main` and every PR from 2026-12-01. - `ConfigPlugin.shouldInstallDependencies` returns false when `ALTIMATE_DISABLE_DEPENDENCY_INSTALL=1`. Without the variable nothing changes. - `test/preload.ts` sets it for the suite. - The config and TUI tests that check when an install is requested clear it. They use a recording installer and never reach the network. - One new test covers the switch. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
| /** `ALTIMATE_DISABLE_DEPENDENCY_INSTALL=1` skips the install. The test suite sets it: an install | ||
| * started by one test is not awaited, outlives the test, and runs inside the test process. */ | ||
| function installDisabled(): boolean { | ||
| const v = process.env["ALTIMATE_DISABLE_DEPENDENCY_INSTALL"]?.toLowerCase() |
There was a problem hiding this comment.
[SUGGESTION]: Reuse the shared env-flag parsers
installDisabled() is a copy of truthy() in packages/core/src/flag/flag.ts:23 (case-insensitive true/1), and this file already imports from that module, which also exports env() and killSwitchSet().
It also picks the opposite rule from the other ALTIMATE_DISABLE_* switches: ALTIMATE_DISABLE_WORKSPACE and ALTIMATE_DISABLE_SCHEMA_VALUES fail closed (killSwitchSet: trimmed, and anything except 0/false/empty counts as set). So ALTIMATE_DISABLE_DEPENDENCY_INSTALL=yes silently does nothing while ALTIMATE_DISABLE_WORKSPACE=yes works. The shared parser keeps every test as written (1/0 parse identically) and removes the local helper:
function installDisabled(): boolean {
return killSwitchSet(env('ALTIMATE_DISABLE_DEPENDENCY_INSTALL'))
}Since this is read on the shipped path, it also belongs next to those two rows in the env table in docs/docs/usage/cli.md.
| fs.mkdirSync(path.join(dir, "node_modules")) | ||
| saved = process.env[ENV_KEY] | ||
| delete process.env[ENV_KEY] | ||
| expect(process.env["ALTIMATE_DISABLE_DEPENDENCY_INSTALL"]).toBe("1") |
There was a problem hiding this comment.
[SUGGESTION]: Assert the flag, not the preload's value
The case is named ALTIMATE_DISABLE_DEPENDENCY_INSTALL=1 suppresses installation, but nothing here sets the variable: this line asserts whatever test/preload.ts happened to leave. That couples the case to a harness detail (it fails for the wrong reason if the preload value changes or a new suite-level hook clears it) and leaves the documented true spelling untested. Set and restore the value inside the test so it proves the gate itself:
const off = process.env.ALTIMATE_DISABLE_DEPENDENCY_INSTALL
process.env.ALTIMATE_DISABLE_DEPENDENCY_INSTALL = '1'
try {
expect(ConfigPlugin.needsDependencies(dir, undefined)).toBe(true)
expect(ConfigPlugin.shouldInstallDependencies(dir, undefined)).toBe(false)
} finally {
if (off === undefined) delete process.env.ALTIMATE_DISABLE_DEPENDENCY_INSTALL
else process.env.ALTIMATE_DISABLE_DEPENDENCY_INSTALL = off
}
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Incremental pass over Verified:
Files Reviewed (1 file)
Previous Review Summaries (4 snapshots, latest commit 33cb412)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 33cb412)Status: No Issues Found | Recommendation: Merge Incremental pass over Verified:
Files Reviewed (6 files)
Previous review (commit 2229e0e)Status: No Issues Found | Recommendation: Merge This incremental pass covers Verified in current HEAD:
Files Reviewed (1 file)
Previous review (commit 65ccba1)Status: No Issues Found | Recommendation: Merge This incremental pass covers Verified in current HEAD:
Files Reviewed (3 files)
Previous review (commit 0e8e862)Status: 2 Issues Found | Recommendation: Address before merge Overview
Both findings are non-blocking. The switch covers the shipped in-process install paths: Issue Details (click to expand)SUGGESTION
Files Reviewed (5 files)
Reviewed by deepseek-v4.1-flash-1017 · Input: 52.5K · Output: 8.7K · Cached: 1M Review guidance: REVIEW.md from base branch |
… document it - `ALTIMATE_DISABLE_DEPENDENCY_INSTALL` is read with `killSwitchSet`, as the other `ALTIMATE_DISABLE_*` switches are: any value but empty, `0` or `false` turns the install off. - Its test sets and restores the variable itself, and covers both sides. - The variable has a row in the CLI environment table. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
2 similar comments
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
2 similar comments
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
hkaltai
left a comment
There was a problem hiding this comment.
Requesting changes for one coverage regression. The production gate is small and correct: it reads the variable when called, through killSwitchSet, and both Config and TuiConfig go through shouldInstallDependencies.
MAJOR: the preload switch is inherited by CLI subprocesses, so it hides the cold-start regression test (see the inline comment on test/preload.ts).
MINOR: inline comments on the masked OPENCODE_PURE=1 case and on the missing layer-level suppression test.
Nits (consolidated):
src/config/plugin.ts:81-89: the existing "PURE mode skips dependency installs… Fold that check in here…" comment now sits aboveinstallDisabled()rather thanshouldInstallDependencies. MoveinstallDisabled()and its JSDoc above that comment.src/config/plugin.ts:86-88: the sibling kill switches (ALTIMATE_DISABLE_WORKSPACE,ALTIMATE_DISABLE_SCHEMA_VALUES) are getters onFlagthat read at call time. Consider addingFlag.ALTIMATE_DISABLE_DEPENDENCY_INSTALLfor consistency.test/config/tui.test.ts:98: the matrix sets the switch to"0".withEnv("ALTIMATE_DISABLE_DEPENDENCY_INSTALL", undefined, …)would exercise the unset default that users actually run with.test/config/tui.test.ts:98,134:withEnv("…", "0", withEnv(/)),is not formatter-shaped. Run prettier on the file.test/skill/release-v0.11.1-adversarial.test.ts:252-281: the save/delete/restore logic is written out by hand twice. A describe-levelbeforeEach/afterEach, as inconfig.test.ts, would be simpler.
Scope: no linked issue, but all six files match the stated intent. No unrelated files.
Reviewed by independent Claude and Codex (Sol 6.1) reviewers, plus a lead pass, with one convergence round.
| // app start a real `npm install` of `@opencode-ai/plugin` there, in this process and not awaited. | ||
| // It outlives the test: several pile up, starve the event loop, and the tests that run next time | ||
| // out. Tests that check the install itself clear this and inject an installer. | ||
| process.env["ALTIMATE_DISABLE_DEPENDENCY_INSTALL"] = "1" |
There was a problem hiding this comment.
MAJOR — this hides the cold-start subprocess regression test.
process.env["ALTIMATE_DISABLE_DEPENDENCY_INSTALL"] = "1"The CLI test helpers pass the runner's environment to every child: test/lib/cli-process.ts:240 uses extendEnv: true, and lines 365 and 459 use env: { ...process.env, ...env, ...opts?.env }. As a result, test/cli/serve/fresh-start.test.ts (the only subprocess test that sets OPENCODE_PURE: "0" to run a real cold start) also gets ALTIMATE_DISABLE_DEPENDENCY_INSTALL=1. Its checks (expect(requests).toEqual([]), no background dependency install failed in stderr, no node_modules/package.json in the config dirs) now pass whether or not needsDependencies decides correctly. If it ever regressed to installing into every config dir, this test would stay green.
Fix: opt that test back in, the same way it already does for PURE:
env: {
OPENCODE_PURE: "0",
ALTIMATE_DISABLE_DEPENDENCY_INSTALL: "0",
...Its fake registry returns 503, and npm_config_fetch_retries is 0, so this cannot reintroduce the hang.
There was a problem hiding this comment.
Fixed in 33cb412. fresh-start.test.ts now sets ALTIMATE_DISABLE_DEPENDENCY_INSTALL: "0" for its child, next to OPENCODE_PURE: "0". Checked by breaking the code: with needsDependencies forced to return true the test fails, and without the new line it passes, which is the gap you described.
| saved = process.env[ENV_KEY] | ||
| delete process.env[ENV_KEY] | ||
| expect(ConfigPlugin.shouldInstallDependencies(dir, undefined)).toBe(true) | ||
| // The suite's preload switches the install off; this case is about the product default. |
There was a problem hiding this comment.
MINOR: the OPENCODE_PURE=1 case in this describe no longer tests PURE.
// The suite's preload switches the install off; this case is about the product default.This case clears the switch, but the case just above it (OPENCODE_PURE=1 suppresses installation even when needsDependencies would be true, lines 238-244) does not. With the switch still set by preload, shouldInstallDependencies returns false whether or not PURE is respected, so that case no longer shows that PURE suppresses the install. Clear the switch there too, or better, do it once in the describe's beforeEach/afterEach so every case in this block runs with the switch unset.
There was a problem hiding this comment.
Fixed in 33cb412. The describe now clears both OPENCODE_PURE and the install switch in beforeEach and restores them in afterEach, so every case starts with both unset. Checked by removing the PURE check from shouldInstallDependencies: the PURE case fails.
| describe("config dir plugin dependency install", () => { | ||
| const npmIt = testEffect(Layer.mergeAll(infra, FSUtil.defaultLayer)) | ||
|
|
||
| // The suite's preload switches the background install off. These cases check when the app |
There was a problem hiding this comment.
MINOR: no layer-level test shows that the switch actually stops the install.
// The suite's preload switches the background install off. These cases check when the app
// asks for one, through a recording installer that never reaches the network.The new test calls ConfigPlugin.shouldInstallDependencies directly. No case goes through the Config (or TuiConfig) layer with the switch set to 1 and a tool/ file present and checks that the recording installer receives nothing (npm.dirs / installs is []). Both call sites use the shared gate today, so this is about guarding that wiring rather than a current bug. A single case here and one in the TUI matrix would cover it.
There was a problem hiding this comment.
Added in 33cb412. One Config case sets the switch to 1 with a tools/ file present and expects the recording installer to receive nothing, and the TUI matrix has the same case. Checked by making the code ignore the switch: both fail, along with the switch's own test.
… switch is covered at both call sites - `fresh-start.test.ts` sets `ALTIMATE_DISABLE_DEPENDENCY_INSTALL=0` for its child process. The child inherited the suite's switch, so the test passed whether or not the install decision was right. - The `OPENCODE_PURE` cases clear the switch in `beforeEach`, so the PURE case tests PURE again. - One Config case and one TUI case check that with the switch set and a tool file present the recording installer receives nothing. The TUI matrix runs with the switch unset, as users do. - The switch is a getter on `Flag`, like the other `ALTIMATE_DISABLE_*` switches. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thanks for the review. All points are addressed in 33cb412 and e1ea0f6; the three inline threads have replies. Nits
One thing I corrected after your review: prettier had also reformatted two unrelated places in Linked issue: none is filed yet; the CI is green on e1ea0f6 (21 checks). |
🤖 Code Review — OpenCodeReview (Gemini) — No Issues FoundNo comments generated. Looks good to me. |
hkaltai
left a comment
There was a problem hiding this comment.
Peer review: APPROVE
Reviewers: Claude (lead), Claude (independent claude -p), Codex gpt-6.1-sol. All three approve; one convergence round, no disagreement.
The fix is small and in the right place:
- The flag is read at call time with the shared
killSwitchSetparsing, which matches the docs. - It sits in
shouldInstallDependencies, the single gate for bothConfigandTuiConfig, sowaitForDependenciesjust joins an empty list, as it already does underOPENCODE_PURE. - The env var is restored correctly everywhere. The
fresh-startchild opts back in with0, the recording installers never reach the network, and no assertions were weakened. - Unset behavior is unchanged.
One minor docs point is inline.
Nits:
packages/core/src/flag/flag.ts:153-158: the JSDoc explains the flag by why the test suite sets it. Describe what it does for users; the test reasoning is already intest/preload.ts.packages/opencode/test/skill/release-v0.11.1-adversarial.test.ts:230: thedescribe("shouldInstallDependencies — Flag.OPENCODE_PURE fold")title now also covers the new flag. Something like"— kill-switch folds"would fit.- No committed cases for surrounding whitespace or mixed-case values (
" 1 ","FALSE"), even though the docs promise trimming and case-insensitive parsing.
Scope: no ticket filed, so this can't be checked against one; the diff matches the PR's stated scope. Unrelated files: none.
| | `ALTIMATE_CLI_DISABLE_MODELS_FETCH` | Don't fetch models from models.dev | | ||
| | `ALTIMATE_DISABLE_WORKSPACE` | Set to `1` to turn off every workspace feature (linking, skill and memory sync, the workspace engine, and the project lookup each session makes). The value is trimmed and read without regard to case; anything other than `0`, `false` or an empty value counts as set. Workspaces are on by default | | ||
| | `ALTIMATE_DISABLE_SCHEMA_VALUES` | Set to `1` to turn off `schema_inspect`'s column value profiles for every call, whatever the model passes as `values`, so no cell values are sampled or sent to the model provider. The value is trimmed and read without regard to case; anything other than `0`, `false` or an empty value counts as set | | ||
| | `ALTIMATE_DISABLE_DEPENDENCY_INSTALL` | Set to `1` to skip the background install of `@opencode-ai/plugin` into config directories that hold custom tools or plugins. Use it where that package is already provided or the npm registry is not reachable; custom tools or plugins that import the package then need it installed some other way. The value is trimmed and read without regard to case; anything other than `0`, `false` or an empty value counts as set | |
There was a problem hiding this comment.
MINOR · documentation — the flag covers less than this row suggests
|
ALTIMATE_DISABLE_DEPENDENCY_INSTALL| Set to1to skip the background install of@opencode-ai/plugininto config directories ... Use it where that package is already provided or the npm registry is not reachable; ...
The flag only gates the config-dir @opencode-ai/plugin install (ConfigPlugin.shouldInstallDependencies). Other installs still run with it set:
- npm plugin specs:
BunProc.installinsrc/plugin/index.ts:141andNpm.addinsrc/plugin/shared.ts:213 - provider SDKs:
BunProc.installinsrc/provider/provider.ts:2272
So an operator who sets it because the registry is unreachable, with "plugin": ["some-plugin@1.0.0"] in their config, still gets a registry install attempt at startup.
Suggested: state in this row that npm plugin and provider SDK installs are not affected. Or rename the flag to match its scope, e.g. ALTIMATE_DISABLE_PLUGIN_SDK_INSTALL.
|
🔁 @RaghwendraSingh — this change was promoted to the help-docs hub: https://github.com/AltimateAI/help-docs/pull/197 — please review/merge to keep the docs in sync. |
Issue for this PR
No issue is filed yet. This fixes the CI failure that has affected main and every PR since 2026-12-01. The evidence is in draft PR #1871.
Type of change
What does this PR do?
The problem. Some tests create a project that contains a custom tool file. When the app sees such a file, it starts an npm install of the plugin package into that project, because a custom tool may import it. The install is real: it downloads about 80 packages from the npm registry. It runs inside the test process, and the app does not wait for it.
So the install is still running when the test ends. The next test starts another one. With eight running at once, the test process stops making progress. Whichever tests run next then time out after minutes, or the job runs out of memory and is killed. Which tests fail changes from run to run, because they are only the ones that happen to come next.
The fix.
ALTIMATE_DISABLE_DEPENDENCY_INSTALLis set. When it is not set, the app behaves exactly as before.What this does not change. Users still get the background install, and it can still slow the app while it runs. That is a product change for a separate PR.
What is not known. Why this started failing on 2026-12-01. The same tests have always started these installs, and the packages installed have not changed since 2026-11-17. The likely explanation is that the installs became slow enough to overlap, but that is not confirmed.
How did you verify your code works?
Draft PR #1871 runs the test shards on CI with a script that reports every stall and every request to the npm registry.
This PR's own CI passes, including the four test shards that were failing. With the variable set and no other change, exactly the 17 install-request tests failed and no others, so no test depended on the real install.
Cost side effects
None.
Screenshots / recordings
Not a UI change.
Checklist
🤖 Generated with Claude Code
Summary by CodeRabbit
ALTIMATE_DISABLE_DEPENDENCY_INSTALLenvironment setting. When enabled, automatic installation of plugin dependencies in configuration directories containing custom tools or plugins is skipped.