fix(core): break filesystem cycle in compiled prompts - #48397
kernel-oops wants to merge 1 commit into
Conversation
|
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. |
|
Independent confirmation of this fix on macOS arm64, which I think is the platform gap left by the verification above (Linux x64/glibc). I hit #48372 after a routine Environment
The undefined dependency is directly observableRather than driving a full prompt, the bad dependency can be observed at the graph level. Forcing the hazardous evaluation order (search before filesystem) and bundling is enough: import "./src/filesystem/search"
import { FileSystem } from "./src/filesystem"
const deps = (FileSystem.node as any).dependencies
console.log(deps.map((d: any) => d?.name ?? "<UNDEFINED>"))Before (unpatched With this PR's That { cache, resolve: (node) => replacementMap.get(node.name) ?? node }
Note this only manifests bundled. Run from source, the same cycle throws the much clearer Also checked, with this PR applied
This appears to be the only instance of the patternSince the failure class is "a Across 669 modules under Possible lighter-weight regression testThe bundle probe above needs no provider, credentials, network, or session, and runs in about a second. It may be worth considering alongside (or instead of) the full compiled runner, since it asserts the actual invariant — no A related thought for a separate change: ImpactWorth noting this is a full outage on the affected build — every prompt fails before any provider request, and the surfaced error is a generic |
|
Thanks @vidit19sharma — this independent reproduction and before/after validation materially close the macOS arm64 validation gap. The direct graph observation is particularly useful: it matches the compiled-dependency invariant this fix protects — every dependency entry must be a defined node. The source/bundled difference also explains the misleading symptom: source execution catches the premature access with a temporal-dead-zone The lighter bundle probe is a strong candidate to complement the full compiled runner: it checks the graph invariant directly and cheaply, while the runner retains end-to-end coverage of the compiled prompt/tool path. Thanks also for your scan across 669 modules finding only this hazard and none after the patch; that is useful additional evidence, though I have not independently reproduced the scan. Agreed that dependency validation in |
https://build.opensuse.org/request/show/1377875 by user pluskalm + anag_factory opencode 1.18.30: two fixes, supersedes 1377865 (same patch, one more change). - Every prompt failed with "undefined is not an object (evaluating 'a.name')" (boo#1280159): circular import between core/src/filesystem.ts and filesystem/search.ts, which bun 1.4.2's bundler orders so a layer dependency is undefined. Backport of upstream PR anomalyco/opencode#48397 (search.ts only). Reproduced on the Factory:ARM RPM in a Tumbleweed container; the patched build answers the same prompt. - NO_BRP_STRIP_DEBUG=true in %install: brp-15-strip-debug runs binutils strip (not %__strip) on any ELF `file` calls "not stripped", which the compiled binary is whenever the bun it was copied from kept its .symtab (any project without the debuginfo flag); that drops the appended payload and %check prints bun's ver
Issue for this PR
Fixes #48372. Related to #44946; this complements that Bun upgrade rather than duplicating its runtime pin change. The upgrade is useful for fixes such as oven-sh/bun#35356 (GC timer CPU usage), but compiled prompt preparation also needs checking.
Type of change
What does this PR do?
Remove the runtime import from filesystem search back to the filesystem service. Schema constructors now come directly from the schema package; service input imports remain type-only.
The service depends on the search node. With Bun 1.4.2, the compiled cycle can capture an undefined dependency: health passes, but the first prompt fails in
SystemPrompt.environmentwithTypeError: undefined is not an object (evaluating 'a.name'), before any provider request.Add an isolated compiled regression and a path-filtered Linux CI job using Bun 1.4.2. The runner exercises authenticated session creation, a streamed request for the actual
readtool, completion, persisted tool output and a second turn. All provider responses are deterministic and local.How did you verify your code works?
Fresh upstream
devat193de13a88d62a6409c6d385831180f1def527dc, Linux x64/glibc, Bun 1.4.2, native minified/split builds with embedded web UI:Soak update: the operator reports a few days of normal server and TUI use with excellent CPU usage and no noticed issues. This is the custom
1.18.30-kernel-oops-bun142-promptfix1build with Bun 1.4.2, now used for normal projects, not pristine upstream or a controlled multi-day test. The clean-upstream regression results above are separate.Windows runner support, other binary targets, real providers and CPU benchmarks were not tested by this PR's isolated regression. Broader platform coverage and upstream review remain outstanding.
Screenshots / recordings
Not applicable.
Checklist