Repository navigation
test(cli): gate live-tail embedding test on provider state, not wall clock - #263
Conversation
…clock TestTailLiveEmbeddingsKeepsCaptureAndWriterOwnership asserted each live upsert finished in under 1s and mixed 100ms sleeps, a 200ms fake embedding latency, a 5s Eventually and a 10s overall deadline, so it flaked on loaded machines. The fake provider now blocks on a release channel once a request is in flight. The test writes the first message, waits for that in-flight signal, then performs the remaining nine writes while the provider is still blocked (and asserts no gated request escaped via cancellation) before releasing it. Sync lock ownership, the DB writer lock, batch size <= 2 and all 10 embeddings landing are still asserted; the overall context is only a hang guard.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 1:44 AM ET / 05:44 UTC. ClawSweeper reviewWhat this changesThe branch changes the live-tail embedding test to hold a fake provider request in flight while checking that message capture continues, then waits for all embeddings to be stored. Merge readiness✅ Ready for maintainer review Current main still contains the load-sensitive test. This focused PR addresses that test without changing production behavior, and the review found no discrete patch defect. Priority: P3 Review scores
Verification
How this fits togetherDiscrawl's live tail saves Discord messages to a local archive. An optional background worker sends queued message text to an embedding provider and stores vectors for search while capture continues. flowchart LR
A[Discord events] --> B[Live tail capture]
B --> C[Archived messages and jobs]
C --> D[Background embedding worker]
D --> E[Embedding provider]
E --> F[Stored search vectors]
G[CLI integration test] --> B
G --> E
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep the provider-gated test so it checks capture progress and worker ownership without a scheduler-dependent timing assertion. Do we have a high-confidence way to reproduce the issue? No failing current-main run was performed during this read-only review. The one-second assertion remains in main, and the PR reports a measured failure under load. Is this the best way to solve the issue? Yes. Waiting for a provider request and holding it blocked checks the concurrency behavior directly while retaining the lock, batch-size, and stored-result checks. AGENTS.md: not found in the target repository. Codex review notes: model internal, reasoning high; reviewed against db4b140893ee. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Why
TestTailLiveEmbeddingsKeepsCaptureAndWriterOwnershipflakes on loaded machines. It asserted that every live upsert finished in under 1s (require.Less(t, time.Since(start), time.Second)), and mixed 100ms sleeps, a 200ms fake embedding latency, a 5sEventuallyand a 10s overall context. On a loaded Mac it failed about 1 in 30 to 1 in 100 at that line (for example "1.105s is not less than 1s"). At load ~75 the 10s context also expired during store open ("set schema version 1: context deadline exceeded").What changed (test only)
The fake embedding provider now blocks on a
releasechannel after signalling that a request is in flight. The live-tail step:tail.releaseis still open is the proof that capture is not blocked by the embedding worker. The test also asserts that no gated request escaped via context cancellation.tail, then releases the provider.message_embeddings, bounded only by the hang guard.After dispatch it asserts that no batch exceeded
BatchSize2 (recorded explicitly, not just returned as an error), thatrequestsis positive, and thattailCalls == 1. Notime.Sleepor elapsed-time assertions remain. The overall context is now a 2-minute hang guard, andreleaseis closed on every exit path.Sanity check: removing the release step makes the test fail at the hang guard with
got 0: context deadline exceeded, rather than hanging or passing.Proof
Each run used a
go test -cbinary with-test.run '^TestTailLiveEmbeddingsKeepsCaptureAndWriterOwnership$'on a shared Mac (32 cores, load average 58-88 throughout). "Busy" means a parallel loop ofgo test -count=1 ./internal/store/... ./internal/syncer/... ./internal/share/....-test.count=100< 1sassertion, 1.105s)-test.count=100taskpolicy -b), 20 eachThe old failure is rare (about 1 in 400 here), so pass counts alone cannot prove it is gone. The structural fix is that nothing in the test depends on elapsed time any more.
gofmt,go vet ./internal/cli, andgo test ./internal/cli -run 'TestTailLive|TestDeferredEmbedding'are clean.Test-only change; no changelog entry.