refactor(test): extract shared SessionPrompt layer to test/lib/prompt-harness (F2)#5
Closed
tesdal wants to merge 1 commit intophase-ab-basefrom
Closed
refactor(test): extract shared SessionPrompt layer to test/lib/prompt-harness (F2)#5tesdal wants to merge 1 commit intophase-ab-basefrom
tesdal wants to merge 1 commit intophase-ab-basefrom
Conversation
…-harness Both prompt.test.ts and subagent-hang-regression.test.ts composed the same ~85-line Layer graph with identical MCP/LSP/Summary stubs. The regression test's 'copied verbatim' comment explicitly called out the duplication. Extracts to makePromptLayer() in test/lib so the composition can't drift. Addresses audit finding F2 (both diamond reviewers, 2026-04-22).
There was a problem hiding this comment.
Pull request overview
This PR addresses audit finding F2 by extracting the shared Effect/Layer composition used by SessionPrompt loop tests into a single reusable test harness, eliminating duplicated stub/service wiring across multiple test suites.
Changes:
- Added
makePromptLayer()in a new shared test harness (test/lib/prompt-harness.ts) containing the common SessionPrompt Layer graph and MCP/LSP/Summary stubs. - Refactored
prompt.test.tsto remove the inline Layer graph and importmakePromptLayer()instead. - Refactored
subagent-hang-regression.test.tssimilarly, removing the prior “Copied verbatim” duplication and using the shared harness.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/opencode/test/lib/prompt-harness.ts |
New shared helper exporting makePromptLayer() with consolidated stubs and SessionPrompt Layer composition. |
packages/opencode/test/session/prompt.test.ts |
Removes duplicated Layer/stub setup; now uses makePromptLayer() from the harness. |
packages/opencode/test/session/subagent-hang-regression.test.ts |
Removes duplicated Layer/stub setup; now uses makePromptLayer() from the harness. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
Author
|
Copilot review: no comments. All three reviewers (codex-5.3 spec 9/9 after reproducibility override, Opus quality APPROVE WITH NITS fixed, Copilot clean) agree. Merging --no-ff into local/integration-v2. PR closed as review-only. |
tesdal
added a commit
that referenced
this pull request
Apr 23, 2026
…harness Diamond review: codex-5.3 spec 9/9 (initial false-positive hook-timeout flake verified non-reproducing 4/4 runs), Opus quality APPROVE WITH NITS (duplicate import merge applied), Copilot clean. Closes audit finding F2. Copilot review PR #5 (closed as review-only).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Audit finding F2 from 2026-04-22 diamond audit:
prompt.test.tsandsubagent-hang-regression.test.tsboth composed the same ~85-line Effect Layer graph with identical MCP/LSP/Summary stubs. Regression test explicitly called this out with a "Copied verbatim" comment. Task 2 extracts the shared graph into a single helper.Changes
packages/opencode/test/lib/prompt-harness.tsexportingmakePromptLayer(). Contains the three inline stubs (summary/mcp/lsp) plus module-scopestatus/runState/infraconstants and the fullSessionPrompt.layercomposition.packages/opencode/test/session/prompt.test.ts: deleted inline stubs + constants +makeHttp()function; now importsmakePromptLayerfrom the new harness.packages/opencode/test/session/subagent-hang-regression.test.ts: same deletions, "Copied verbatim" comment removed, now importsmakePromptLayer.Net −120 LOC (147 added in harness, 267 removed across both test files).
Verification
bun typecheck— cleanbun test test/session/subagent-hang-regression.test.ts— 2/2 pass, verified 4/4 clean runs on this branch + 1 clean run on base for sanitybun test test/session/prompt.test.ts— 42 pass / 2 fail. Both failures are in the known-flaky PT0 pattern (cancel tests spawningsleep 30shells with 3sit.livetimeout). Failure count is within / below the documented 3–11 range. Refactor cannot introduce new failures — it's pure Layer-composition reuse, no test-body changes. See anomalyco/opencode#24060.Diamond review status
test/lib/. One actionable nit (duplicateimport from \"../../src/tool\") — fixed and amended into the commit. Other nits (naming, module-scope constant inlining) are judgement calls, left as specified.Context
Part of 14-task audit remediation plan (
docs/superpowers/plans/2026-04-23-audit-remediation.md). Basephase-ab-baseis2309cc89d(F1 merge onlocal/integration-v2). Draft PR opened for Copilot review only — merge target is local integration branch, not upstream.