Commit f8b5054
committed
test(memory): assert queue_depth delta to survive sibling spawn_manual_sync pollution
`memory_ingestion_status_reflects_initialized_client_snapshot` was
asserting `status.queue_depth == 1` against the process-global
`IngestionState`, on the assumption that the lock acquired at the top
of the test guarantees a clean baseline.
The two sibling tests (`memory_sync_channel_publishes_targeted_event`
and `memory_sync_all_publishes_broadcast_event`) call
`memory_sync_channel` / `memory_sync_all` → `spawn_manual_sync`, which
detaches a `tokio::spawn(...)` background task that runs
`composio::run_connection_sync`. That detached task can enqueue an
ingestion job via `MemoryClient::store_skill_sync` →
`IngestionQueue::submit` → `state.enqueue()`. By the time this test
acquires `GLOBAL_MEMORY_TEST_LOCK`, that background work may already
have bumped the global counter — so the equality assertion fires
with `left: 2, right: 1`.
CI hit this on #2720 (\"Rust Core Tests + Quality\") despite the lock
because the lock only serialises against tests that *also* acquire it
— not the detached worker that was spawned earlier and is still
draining. The same flake is reachable on `upstream/main` in CI with
a parallel-test ordering that puts the snapshot test directly after
one of the sync-channel tests; my PR's added vault sync tests didn't
cause it, but they shifted the ordering enough to expose it.
The principled fix is to snapshot the baseline `queue_depth` at the
start of the test and assert the delta. That keeps the test's
contract intact (an `enqueue + mark_running` round-trip must surface
in the snapshot) without depending on the rest of the suite leaving
the global state pristine.
Targeted run on the failure window passes:
cargo test --lib -- memory::ops::sync vault::sync
→ 9/9 pass1 parent b8bdb09 commit f8b5054
1 file changed
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
370 | 379 | | |
371 | 380 | | |
372 | 381 | | |
| |||
379 | 388 | | |
380 | 389 | | |
381 | 390 | | |
382 | | - | |
| 391 | + | |
383 | 392 | | |
384 | 393 | | |
385 | 394 | | |
| |||
0 commit comments