Repository navigation
fix(test): make memory ingestion-status test residue-robust (queue_depth delta) - #2721
Conversation
…y sync test `memory_ingestion_status_reflects_initialized_client_snapshot` asserted `queue_depth == 1`, but `IngestionState.queue_depth` is an `AtomicUsize` on the process-global memory client that every `memory::ops` test shares (via `ensure_shared_memory_client`) and that is never reset between tests. `GLOBAL_MEMORY_TEST_LOCK` serializes the test bodies, but residue from a prior test's in-flight ingestion can still leave the queue non-zero, so the absolute assertion flakes under `cargo-llvm-cov`'s slower parallel timing (observed in CI: got 2, expected 1). Capture the baseline depth and assert `baseline + 1`. The snapshot fields set by `mark_running` are overwritten per call and stay deterministic, so only the additive `queue_depth` needed hardening. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR fixes a test flakiness issue in the memory ingestion sync module. The ChangesTest isolation for memory ingestion state
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Summary
memory::opsunit test that intermittently reds the Rust Core Coverage (cargo-llvm-cov) check.memory_ingestion_status_reflects_initialized_client_snapshotasserted an absolutequeue_depth == 1, but the queue is a process-globalAtomicUsizeshared (and never reset) across everymemory::opstest — so residue from a prior test's in-flight ingestion makes it flake (CI observed2, expected1).baseline_depth + 1) instead.Problem
memory::opstests share one process-global memory client (one SQLite DB, oneIngestionState) pinned byensure_shared_memory_client.GLOBAL_MEMORY_TEST_LOCKserializes the test bodies, butIngestionState.queue_depth(anAtomicUsize, read live bysnapshot()) is not reset between tests. A prior test that leaves the queue non-zero — or whose async ingestion outlives the body-lock — makes the absolutequeue_depth == 1assertion fail undercargo-llvm-cov's slower parallel timing. This is a real test-isolation bug, independent of any product code; the failing test passes deterministically in isolation.Solution
Capture
baseline_depth = state.snapshot().queue_depthbeforeenqueue(), then assertstatus.queue_depth == baseline_depth + 1. The other snapshot fields (running,current_document_id, …) are overwritten per call bymark_running, so they stay deterministic and were left unchanged — only the additivequeue_depthneeded hardening.Submission Checklist
cargo test --lib memory_ingestion_status_reflects_initialized_client_snapshot→ ok).diff-covergate validated in CI.## Related— N/A: no matrix rows affected.Closes #NNN— N/A: no tracked issue at open (a follow-up issue for the relatedtool_memorycontention facet is referenced below).Impact
Related
memory::ops::tool_memorytest DB-write contention on the same shared client, where the body-lock doesn't gate the SQLite connection / async client lifecycle. That needs a riskier isolation change (quiesce background ingestion under the lock, per-test isolated client, or SQLite busy-retry) and is not addressed here.AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
fix/memory-sync-queue-depth-flakee6670bc9Validation Run
pnpm --filter openhuman-app format:check— N/A: noapp/(TS) files changed.pnpm typecheck— N/A: no TS changed.cargo test --lib memory_ingestion_status_reflects_initialized_client_snapshot→ 1 passed.cargo fmtclean; compiles.app/src-taurichanges.Validation Blocked
command:fullpnpm test:rust/ coverage suite + Tauri shell pre-push checkerror:local env lacks vendored tauri-cef CLI + pnpm/node toolchain (documented project constraint)impact:focused test compiles + passes locally; full suite validated in CI.Behavior Changes
Parity Contract
Duplicate / Superseded PR Handling
fix/memory-ops-test-isolationbranch exists on the fork from earlier work; this PR uses a distinct branch and base).🤖 Generated with Claude Code
Summary by CodeRabbit