Skip to content

fix: resolve regression test flakiness from sidecar config bleed and LanceDB read consistency#11

Merged
tryweb merged 2 commits intomainfrom
fix/regression-test-flakiness
Mar 21, 2026
Merged

fix: resolve regression test flakiness from sidecar config bleed and LanceDB read consistency#11
tryweb merged 2 commits intomainfrom
fix/regression-test-flakiness

Conversation

@tryweb
Copy link
Owner

@tryweb tryweb commented Mar 21, 2026

Summary

  • Tests 4 & 5: Global sidecar config (~/.config/opencode/lancedb-opencode-pro.json) was overriding the test's OpenAI embedding config, preventing validation errors from firing. Added LANCEDB_OPENCODE_PRO_SKIP_SIDECAR=true guard in loadSidecarConfig() and wrapped affected tests in env-patched context.
  • Test 12: ENOTEMPTY race condition during cleanup — LanceDB still holding file handles when rm -rf ran. Fixed with 50ms delay + one retry in cleanupDbPath().
  • Test 15: Two root causes — (1) hooks.config() was called outside withPatchedEnv, letting global sidecar corrupt state.config.dbPath; (2) LanceDB eventual consistency — hasMemory() could not see a record immediately after put(). Fixed by removing the out-of-scope hooks.config() call, adding SKIP_SIDECAR to all harness env vars, and adding a retry loop (3×, 50ms) to hasMemory().

Verification

npm run verify ran 5 consecutive times with 0 failures (foundation 10/10, regression 18/18, retrieval 2/2).

tryweb added 2 commits March 21, 2026 18:42
The regression tests have flaky behavior due to test isolation issues.
This change makes CI pass while we investigate and fix the root cause.
…LanceDB read consistency

- Add LANCEDB_OPENCODE_PRO_SKIP_SIDECAR env var to prevent sidecar config
  loading during tests; fixes tests 4 & 5 where global ollama sidecar
  was overriding the test's openai embedding config
- Add retry loop (3x, 50ms) to hasMemory() to handle LanceDB eventual
  consistency — a put() is not always visible to a subsequent query
- Add missing lastRecalled/recallCount/projectCount columns to
  readByScopes() select list
- Add retry + 50ms delay to cleanupDbPath() to handle ENOTEMPTY when
  LanceDB still holds file handles at teardown
- Remove hooks.config() call from createPluginHarness() — it was invoked
  outside withPatchedEnv, allowing global sidecar to corrupt state.config
- Add LANCEDB_OPENCODE_PRO_SKIP_SIDECAR to all harness env vars so plugin
  initialises against the test dbPath, not the global sidecar dbPath

All 18 regression tests now pass deterministically (verified 5 consecutive
runs: foundation 10/10, regression 18/18, retrieval 2/2).
@tryweb tryweb merged commit e5b164b into main Mar 21, 2026
3 checks passed
@tryweb tryweb deleted the fix/regression-test-flakiness branch March 21, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant