GeezerVison is showing github.com — test: migrate prompt tests to HTTP mock LLM server by kitlangton · Pull Request #20304 · anomalyco/opencode
Conversation
kitlangton
commented
Mar 31, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
- replace the Bun-based mock LLM with an Effect HTTP mock server and migrate the prompt/session tests to run against the HTTP-backed provider path
- add
it.live(...) support to the shared Effect test helper, consolidate the prompt provider coverage into prompt-effect.test.ts, and add regression coverage around InstanceState context behavior
- propagate
InstanceRef through Effect-backed runtime boundaries and deferred database callbacks so prompt/session flows keep the correct instance context after async escapes
- break the
db -> installation -> run-service -> instance -> project -> db cycle by extracting installation metadata into a leaf module used by db.ts
- make scoped test tempdir cleanup more robust on Windows by using the retrying cleanup path already used by the async tmpdir fixture
Verification
bun typecheck
bun test test/session/prompt-effect.test.ts test/effect/instance-state.test.ts
bun run build (from packages/sdk/js)
- PR CI
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Replace Bun.serve with Effect HTTP server using NodeHttpServer
- Add TestLLMServer service for mock LLM testing with SSE responses
- Update prompt-provider.test.ts to use testEffect pattern with provideTmpdirInstance
- Remove redundant test/fixture/effect.ts (using existing test/lib/effect.ts instead)
Default the shared effect test helper to support both test-clock and live execution, and switch the current opencode effect tests to the live path for real integration behavior.
Switch the basic assistant reply prompt-effect test to the HTTP-backed mock LLM server while keeping the more stream-sensitive cases on the in-process fake for now.
Add fixture support for tmpdir-backed mock server tests, extend the mock LLM server DSL for failure and hanging cases, and migrate the next prompt tests to the HTTP-backed path.
Migrate the next prompt-effect cases to the HTTP-backed mock server path, keep the shell handoff cases on short live timeouts, and leave the stream-failure case on the in-process fake until the server DSL matches it.
…ceRef
Add a ServiceMap.Reference that carries InstanceContext through the
Effect service graph so child fibers retain instance context even when
resumed by external I/O events outside the ALS boundary.
- Add InstanceRef to instance-state.ts; InstanceState.get/has/invalidate
try the Reference first, fall back to ALS
- makeRuntime automatically captures ALS into InstanceRef at the boundary
- provideInstance (test fixture) sets InstanceRef for Effect.runPromiseWith
- Remove all redundant provideInstance(dir) wrappers from prompt tests
- Fix test/lib/effect.ts type params (drop unnecessary S/T generics)
Migrate 16 direct Instance.directory/worktree/project reads inside
Effect code to use InstanceState.directory/context helpers that check
the InstanceRef first and fall back to ALS.
- Export InstanceState.directory and InstanceState.context helpers
- bus/index.ts: GlobalBus.emit uses InstanceState.directory
- session/prompt.ts: 5 callsites migrated to InstanceState.context
- session/index.ts: 4 callsites migrated
- session/compaction.ts: 1 callsite migrated
- config/config.ts: 1 callsite migrated
- format/index.ts: 1 callsite migrated
- worktree/index.ts: 5 callsites migrated
- storage/db.ts: Database.effect preserves Instance ALS via Instance.bind
- test/lib/llm-server.ts: add wait/hold/fail SSE stream support
- Remove most provideInstance(dir) wrappers from prompt tests
(5 remain due to Instance.state sync ALS dependency)
- makeRuntime.provide reads InstanceRef from current Effect fiber when
ALS is unavailable, bridging static function calls (like Bus.publish)
that create new fibers from inside Effect code
- Database.transaction preserves Instance ALS via Instance.bind on the
bun:sqlite transaction callback (native fn loses ALS)
- Instance.restore helper for bridging Effect→sync code with ALS
- InstanceState.withALS bridges InstanceRef back to ALS for sync callers
- prompt.ts: InstructionPrompt.clear wrapped with withALS
- Remove ALL provideInstance(dir) wrappers from prompt-effect tests
Uh oh!
There was an error while loading. Please reload this page.
byeonghwankwak1
added a commit
to team-monolith-product/enk-opencode
that referenced
this pull request
Apr 10, 2026
Effect.promise(setTimeout) 기반 waitMs는 Effect 스케줄러와 협조하지
않아 CI에서 forked fiber가 50ms 안에 진행되지 못해 race가 발생.
upstream PR anomalyco#20304 과 동일하게 모든 waitMs(N)을
Effect.sleep(N)으로 변환하고 헬퍼 정의 삭제.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
byeonghwankwak1
added a commit
to team-monolith-product/enk-opencode
that referenced
this pull request
Apr 10, 2026
Effect.promise(setTimeout) 기반 waitMs는 Effect 스케줄러와 협조하지
않아 CI에서 forked fiber가 50ms 안에 진행되지 못해 race가 발생.
upstream PR anomalyco#20304 과 동일하게 모든 waitMs(N)을
Effect.sleep(N)으로 변환하고 헬퍼 정의 삭제.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Rwanbt
pushed a commit
to Rwanbt/unifia
that referenced
this pull request
May 5, 2026
AIALRA-0
pushed a commit
to AIALRA-0/opencode-turn-engine
that referenced
this pull request
Jun 10, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|