Repository navigation
test(opencode): wait for the v2 transform callback, not a fixed 100 ms - #1468
Merged
Merged
Conversation
The v2 late-callback test slept 100 ms and hoped setup had caught up. It now waits for the line setup logs after transform() resolves and the pending hooks settle. That line is the point where setup judges the providers. The wait is bound at 25 s with a named failure message. The pending-timing list is now empty. The file and its header stay. Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5
amiddavid
force-pushed
the
test/fix-opencode-v2
branch
from
November 26, 2026 14:21
09868e2 to
3afc796
Compare
Collaborator
Author
|
Local tests: waived (owner rule) |
If the transform callback does nothing, the test failed on a bare ENOENT from reading install.json. It now asserts the file exists first, with a message that names the cause. Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5
amiddavid
commented
Nov 26, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 3afc796fd8fe |
approve |
Verdict: approve
Findings
None.
Non-blocking
opencode-plugin/test/v2.test.mjs:271— if setup fails before the verdict line (for example, command registration throws), the test waits the full 25 s bound and reports "timed out waiting for setup to finish its pass", not the real error. Diagnostic quality only. The failure is still caught and named.opencode-plugin/test/v2.test.mjs:275— the guard against "no Anthropic or OpenAI provider is configured" checks a line only the v1confighook logs (opencode-plugin/index.js:1366, throughsafeLog). The v2 path never prints it, so the assertion cannot fail today. Harmless as a regression guard.
What I checked
- Read the full diff:
opencode-plugin/test/v2.test.mjsandscripts/release/pending-timing-fixes.txt. One commit, test only. - Read the whole test file and
opencode-plugin/test/helpers.mjs, includingwaitFor(25 s bound, 100 ms poll, named failure). - Read
setupV2inopencode-plugin/index.jsend to end. The wait condition is deterministic: the mock'sctx.provider.transformstores the callback inrunand returns,setupV2then awaitsPromise.all(pendingHooks)on an empty list and logs the verdict line atopencode-plugin/index.js:1512.runis assigned inside the transform call, before the verdict line, so it is always set when the test calls it. - Checked the
try/finallyaround the wait:console.logis restored even whenwaitForfails. The old code restored it only after the fixed sleep. - Checked that no other line matches the wait regex before the verdict point, and that no fixed-time wait remains in this test (
waitUntilUnhealthypolls on a connection-refused condition). - Checked
pending-timing-fixes.txt: the file keeps its header and is now empty of entries. The removal follows the file's own rule — a PR that fixes a listed test removes its line in the same PR. Commit e0ad5c5 (#1452) did the same for the picker test. - Repo rules: test-only change, so no behavior change to name, no data-dependence row, no host-boundary or client-rule question. The commit has DCO sign-off and
Assisted-Byattribution.
amiddavid
commented
Nov 26, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 3afc796fd8fe |
approve |
Verdict: approve
Findings
None.
Non-blocking
opencode-plugin/test/v2.test.mjs:275— The negative assertion checks for "no Anthropic or OpenAI provider is configured". Only the v1 server path logs that line (index.js:1366, via theconfighook). The v2 mock never calls that hook, so the assertion cannot fail today. It is a regression guard. Pre-existing, not changed by this PR.scripts/release/pending-timing-fixes.txt— The removed entry named the test as "v2: setup waits for the host transform callback before judging providers". That title never matched the real test title ("v2: hooks work when the provider callback runs after transform() has resolved"), against the file's rule that node tests use the test title. The line is now deleted, so the mismatch is gone. No action needed.
What I checked
- Read the full diff (2 files) and the code around each change.
- The wait target is real:
index.js:1512logs "no Anthropic or OpenAI provider routed so far" afterctx.provider.transform(...)resolves andawait Promise.all(pendingHooks)settles (index.js:1508-1512). That line is the verdict point the test needs. The regex in the test matches the log text exactly. - In this test,
hookedis empty when the line prints: the mock stores the transform callback and does not run it, andhookProviderruns only inside that callback. So the line always appears, and it appears exactly once setup has judged the providers. waitFor(helpers.mjs:121-127) is the established pattern:failopen.test.mjs:358,458,520waits on log lines and ports the same way. It polls the condition, fails with a named message at 25 s, and does not hang.- The
finallyrestoresconsole.logeven when the wait times out. The old code restored it unconditionally outside afinally, so this is stricter than before. - The test needs no
timingOnlygating. It waits on a condition; the 25 s deadline is a safety net. CLAUDE.md says: do not gate a test that uses a long timeout as a safety net.scripts/dev/timing-tests-needed.shalso prints "skip" for this diff: no timing marker changed andv2.test.mjsholds none at head. - The list removal follows the file's own rule: "A PR that fixes a listed test removes its line in the same PR". After this PR the list holds only the header, as the commit message says.
- Process checks: test-only change, so no behavior change, no data-dependence row, no host-boundary or client-rule question, no binary.
- Live tests were not run (not approved for this review).
Collaborator
Author
|
Round-1 follow-up: a named assertion that |
amiddavid
commented
Nov 26, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | d64bb4e186c8 |
approve |
Verdict: approve
Findings
None.
Earlier findings
- My round-1 non-blocking note about the 25 s
waitForburn when setup fails before the verdict line: not addressed. It stays non-blocking. The new commit does improve the naming of the other failure mode (a callback that runs but starts no proxy), which was the sharper diagnostic gap. - My round-1 non-blocking note about the vacuous "is configured" guard: rejected by no one, left as is. Reviewer 2 raised the same point and called it a harmless regression guard. I agree. No action needed.
- Reviewer 2's two non-blocking notes: checked both. The pending-list title mismatch is gone with the deleted line. Agree, nothing to add.
Non-blocking
opencode-plugin/test/v2.test.mjs:278— the new existence check does not rule out a staleinstall.jsonleft by an earlier failed run in the same state directory. In that case the assertion passes on the old file and the test fails later, at the base-URL assertion. It still fails, so this is diagnostic quality only.
What I checked
- Last review: round 1, 3afc796, 2026-11-26T14:24:25Z.
- New commits read: 1 —
d64bb4e1"test(opencode): wait for the v2 transform callback, not a fixed 100 ms" (follow-up: "name the failure when the v2 callback starts no proxy"). - Read in full: 2 reviews, 2 comments, 0 inline comments (from the three saved files).
- New items since my last review: reviewer 2's round-1 review (agree with its two notes, both checked); the "Local tests: waived (owner rule)" comment (the interim rule's marker, present); the "Round-1 follow-up" comment naming the new assertion; the commit
d64bb4e1itself. - The new commit adds one line:
assert.ok(existsSync(join(state, "install.json")), "the transform callback did not start the proxy")before thereadFileSync. Checked thatexistsSyncandjoinare already imported (v2.test.mjs:3,5). Checked the placement: afterawait done, so the callback has finished and the file must exist if the proxy started. - Re-read the changed test in full at the new head. The round-1 verdict still holds: the wait condition is the verdict line at
opencode-plugin/index.js:1512,runis assigned before it, and thetry/finallyrestoresconsole.log. - Repo rules: still test-only, so no behavior change, no data-dependence row, no host-boundary or client-rule question. The new commit has DCO sign-off and
Assisted-Byattribution.
amiddavid
commented
Nov 26, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | d64bb4e186c8 |
approve |
Verdict: approve
Findings
None.
Earlier findings
- Reviewer 1, non-blocking (25 s wait can mask an early setup failure): the author fixed the narrower case in the same spirit. If the transform callback starts no proxy, the test now fails at once with a named message, not a bare ENOENT. An early setup failure still costs the 25 s bound, but that stays a diagnostic-quality point, not a defect. Accepted as fixed enough.
- Reviewer 1, non-blocking, and my round-1 note (the "is configured" guard watches a v1-only log line): no action taken. Both reviews called it a harmless regression guard. Agreed, nothing to do.
- My round-1 note (the removed list entry had a title that never matched the test): no action needed. The line is deleted, so the mismatch is gone.
Non-blocking
opencode-plugin/test/v2.test.mjs:278— The new assertion can pass on a staleinstall.jsonleft by an earlier run of the same test, because the directory/tmp/context-guru-project-v2-lateis not cleaned between runs. The next assertion (baseURLequals the proxy URL) still catches that case, and the stale-file exposure predates this PR. Diagnostic quality only.
What I checked
- Last review: round 1, 3afc796, 2026-11-26T14:25:57Z.
- New commits read: 1 — d64bb4e "test(opencode): name the failure when the v2 callback starts no proxy".
- Read in full: 2 reviews, 2 comments, 0 inline comments (from the three files
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review:
- Comment by amiddavid at 2026-11-26T14:27:10Z: names the round-1 follow-up. Checked against the commit; it describes exactly what the commit does.
- Commit d64bb4e: adds one line,
assert.ok(existsSync(join(state, "install.json")), "the transform callback did not start the proxy"), before thereadFileSync. Reviewed as a first review:- Placement is right: after
await run()andawait done, before the read that used to fail with ENOENT. - The assertion cannot false-fail:
startProxywritesinstall.jsonbefore it returns (index.js:1135,writeAtomic(recordPath, ...)at the end of the start path), and the reuse branch returns early only when the file already exists and holds a healthy record. - Imports:
existsSyncandjoinare already imported in the file and used by other tests in it. - Test-only change: no behavior change, no data-dependence row, no host-boundary or client-rule question, no binary. Commit has DCO sign-off and
Assisted-Byattribution.
- Placement is right: after
- The older comment at 2026-11-26T14:21:50Z is the owner-rule waiver line ("Local tests: waived (owner rule)"), which CLAUDE.md accepts.
- Live tests were not run (not approved for this review).
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
opencode-plugin/test/v2.test.mjs. This PR does not wait for it.What changed
opencode-plugin/test/v2.test.mjs: replace the sleep withwaitForon the log line setup writes aftertransform()resolves and the pending hooks settle. Restoreconsole.login afinally.scripts/release/pending-timing-fixes.txt: remove the last entry. The file and header stay.approval-still-valid_test.shpasses with the empty list.How it was tested
Tests ran on macOS, Go 1.27.4.
node --testinopencode-plugin: 114 pass, 0 fail, 7 skipped.v2.test.mjs10 times in a loop: 10 of 10 pass.index.js(scratch edit, reverted), the test fails after 25 s withtimed out waiting for setup to finish its pass after transform() resolved. It does not hang.go test ./internal/timingguard/: pass (the guard scans Go only).Refs #1291