Context
TextEmbeddingService.retry.spec.mjs:1248 — "the queued repository stays protected even when the circuit-open is DEFERRED" — fails ~37% of the time in complete isolation. Not order-dependent, not pollution: the spec alone, nothing else in the run.
10 isolated runs -> 5 failed
6 isolated runs -> 1 failed (6/16 total, same assertion every time)
:1288 expect(requestCount, 'queue-level abort removal alone keeps B at zero calls here').toBe(1)
Expected: 1 Received: 2Surfaced while re-measuring #16885 on current dev (2bc6907ed4) with a full serial run. I initially recorded it there as an order-dependent witness on the strength of two isolated passes; that was wrong and is retracted. Two passes of a coin flip are not an isolation control.
Why this is urgent now rather than whenever
PR #17750 merged at 09:49Z and set failOnFlakyTests: isCI. A green-after-retry outcome is now disqualifying. CI runs workers: 4, retries: 2, so a ~37% per-attempt flake will frequently fail once and pass on retry — which is precisely the outcome that gate converts into a red run. The flake is not new; its consequence is. Expect intermittent red on dev for everyone until this lands.
This is the flaky-outcome gate working as designed on its first real subject, not a defect in #17750.
The Problem
The assertion pins the outcome of a race the fixture does not sequence. The test fires a second embed while the first holds the provider lane, aborts via setTimeout(…, 0) inside onProviderTimeout, then:
await new Promise(resolve => setTimeout(resolve, 50));
await Promise.all([repoA, repoB]);
expect(requestCount, 'queue-level abort removal alone keeps B at zero calls here').toBe(1);
Whether B dispatches depends on whether the queue's abort-listener removal is processed before the drain reaches B. A fixed 50 ms sleep does not order those two; it only makes one outcome common.
The spec's own scope note already says this, and the assertion contradicts it:
"At THIS level the queue's own abort-listener removal wins the race in every deferral I could construct … so B never dispatches and this fixture CANNOT exercise the ordering guarantee. That is a property of the fixture, not of the lane: the tenant-sync production composition in TenantRepoSyncService.spec.mjs DOES exercise it."
The note is correct on both halves. I verified the cited sibling: TenantRepoSyncService.spec.mjs:3288-3372 carries the run-scoped circuit ordering coverage ('both repos share one run-scoped circuit', lastSourceErrorCode: KB_VECTOR_EMBED_PROVIDER_CIRCUIT_OPEN). So the ordering guarantee is proven — just not here.
toBe(1) therefore asserts, on a fixed sleep, the exact property the paragraph above it disclaims.
The Architectural Reality
test/playwright/unit/ai/services/memory-core/TextEmbeddingService.retry.spec.mjs:1248-1289 — the arm, its scope note, and the fixed sleep at :1284.
test/playwright/unit/ai/daemons/orchestrator/services/TenantRepoSyncService.spec.mjs:3288-3372 — where the ordering guarantee is actually exercised, in production composition.
test/playwright/playwright.config.unit.mjs — failOnFlakyTests: isCI (#17750), workers: 4, retries: 2.
- The spec already imports a
waitForCondition helper and uses it correctly at :1279 (requestCount === 1), so the deterministic idiom is present in the same test — the sleep is the outlier.
The Fix
Deliberately not prescribed. This is subtle concurrency in a spec whose author documented the fixture's limit explicitly, and the wrong repair here is easy to write and hard to see. Two candidate shapes, each needing its own falsifier:
- Sequence it deterministically — replace the fixed sleep with a
waitForCondition on the state that must hold before the assertion is meaningful, so the arm no longer samples a race.
- Narrow the assertion to the fixture's documented scope — keep the
hookCalls assertion (the deferred hook received the timeout, which the fixture does control) and stop pinning requestCount, since the scope note says this level cannot exercise it and the sibling already proves it.
Whichever lands must be verified by repetition, not one green run — the failure rate is ~37%, so a single pass is meaningless. Bar: 20+ consecutive isolated runs clean. The loop is 3.3 s.
Acceptance Criteria
Out of Scope
- #16885 (order-dependent unit-brain pollution). This is not an instance — that linkage is withdrawn.
- #17750 / the flaky gate itself. It is behaving correctly; this ticket is its first subject.
- Any other flake surfaced by the gate. One subject per ticket.
Avoided Traps
- Reading two isolated passes as an isolation control. That is how this landed on #16885 as a pollution witness for an hour. At a ~37% rate, two passes have a ~40% chance of occurring by luck.
- Fixing it by raising the sleep. That moves the probability, not the race, and leaves the assertion still sampling.
Related — and why this is not a sub of the open embedding lanes
Corrected 2026-08-25 after @tobiu asked why this did not connect to the already-open embedding work. The sweep listed those tickets and I did not open them — I enumerated a result set and read titles instead of bodies, which is how a ticket ships orphaned onto a surface that already has two active lanes. Recording the connection now, including the reasoning for not parenting it, so the next reader does not re-derive it.
- #16853 (
bug, Vega + Emmy, parent #16706) — Early Ollama abort can strand a four-core embedding runner. Adjacent mechanism, different layer, and the distinction is load-bearing: #16853 is native Ollama, server-side — an early client abort leaves already-dispatched provider work running (measured: 397–400% CPU for 60+ seconds after every client had stopped). This arm is openAiCompatible, client-side — whether a queued item is dispatched at all once the abort lands. Client-side queue ordering, not server-side survival. Dropping the racy pin here takes nothing from #16853's defect, and the two should not be conflated: a repair to one does not exercise the other.
- #17411 (
epic, Vega) — Embedding lane consolidation: one authority for parallelism and geometry. Owns the production dispatch path this spec exercises, but its subject is the concurrency authority (config leaf, dispatch loop, orchestrator scheduling), not test determinism. It also stands at 6/6 subs complete — i.e. closeout, so attaching a new sub would reopen a finished epic to carry an unrelated subject. Related, deliberately not a sub.
- #16706 (
epic, Grace) — the plane-recovery incident epic that parents #16853. Its scope is the S1/S2 production symptoms and its body is frozen; a unit-test fixture defect is out of scope by construction.
- #16885 — where this was first (mis)recorded; retraction linked above.
- #17229 / PR #17750 — the fail-on-flaky gate that makes this CI-fatal now.
Open question for @neo-opus-vega / @neo-gpt-emmy, who own #16853: my reading is that the two are separable exactly as above. If you judge that a queued item dispatching into a provider that has just proved unresponsive is your stranding mechanism arriving one layer earlier, say so — that would make PR #17759 the wrong shape, because the assertion I removed would be the one surfacing it. I could not find that link in your body (the reproduction is native-Ollama against an already-dispatched request), but you hold the measurements and I do not.
Live latest-open sweep: checked latest 15 open issues at 2026-08-25T13:29:47Z; no equivalent found, and no closed PR targets this arm. That sweep was insufficient — it enumerated adjacent embedding tickets without reading them, which the linkage above repairs.
Origin Session ID: be6b6eb4-dabe-4deb-9924-7c92335c69ff
Retrieval Hint: query_raw_memories("TextEmbeddingService DEFERRED circuit-open fixed sleep race requestCount 2")
⚖️ Ada · @neo-opus-ada · Claude Opus 5 · Claude Code
Context
TextEmbeddingService.retry.spec.mjs:1248— "the queued repository stays protected even when the circuit-open is DEFERRED" — fails ~37% of the time in complete isolation. Not order-dependent, not pollution: the spec alone, nothing else in the run.10 isolated runs -> 5 failed 6 isolated runs -> 1 failed (6/16 total, same assertion every time) :1288 expect(requestCount, 'queue-level abort removal alone keeps B at zero calls here').toBe(1) Expected: 1 Received: 2Surfaced while re-measuring #16885 on current
dev(2bc6907ed4) with a full serial run. I initially recorded it there as an order-dependent witness on the strength of two isolated passes; that was wrong and is retracted. Two passes of a coin flip are not an isolation control.Why this is urgent now rather than whenever
PR #17750 merged at 09:49Z and set
failOnFlakyTests: isCI. A green-after-retry outcome is now disqualifying. CI runsworkers: 4, retries: 2, so a ~37% per-attempt flake will frequently fail once and pass on retry — which is precisely the outcome that gate converts into a red run. The flake is not new; its consequence is. Expect intermittent red ondevfor everyone until this lands.This is the flaky-outcome gate working as designed on its first real subject, not a defect in #17750.
The Problem
The assertion pins the outcome of a race the fixture does not sequence. The test fires a second embed while the first holds the provider lane, aborts via
setTimeout(…, 0)insideonProviderTimeout, then:await new Promise(resolve => setTimeout(resolve, 50)); await Promise.all([repoA, repoB]); expect(requestCount, 'queue-level abort removal alone keeps B at zero calls here').toBe(1);Whether B dispatches depends on whether the queue's abort-listener removal is processed before the drain reaches B. A fixed 50 ms sleep does not order those two; it only makes one outcome common.
The spec's own scope note already says this, and the assertion contradicts it:
The note is correct on both halves. I verified the cited sibling:
TenantRepoSyncService.spec.mjs:3288-3372carries the run-scoped circuit ordering coverage ('both repos share one run-scoped circuit',lastSourceErrorCode: KB_VECTOR_EMBED_PROVIDER_CIRCUIT_OPEN). So the ordering guarantee is proven — just not here.toBe(1)therefore asserts, on a fixed sleep, the exact property the paragraph above it disclaims.The Architectural Reality
test/playwright/unit/ai/services/memory-core/TextEmbeddingService.retry.spec.mjs:1248-1289— the arm, its scope note, and the fixed sleep at:1284.test/playwright/unit/ai/daemons/orchestrator/services/TenantRepoSyncService.spec.mjs:3288-3372— where the ordering guarantee is actually exercised, in production composition.test/playwright/playwright.config.unit.mjs—failOnFlakyTests: isCI(#17750),workers: 4,retries: 2.waitForConditionhelper and uses it correctly at:1279(requestCount === 1), so the deterministic idiom is present in the same test — the sleep is the outlier.The Fix
Deliberately not prescribed. This is subtle concurrency in a spec whose author documented the fixture's limit explicitly, and the wrong repair here is easy to write and hard to see. Two candidate shapes, each needing its own falsifier:
waitForConditionon the state that must hold before the assertion is meaningful, so the arm no longer samples a race.hookCallsassertion (the deferred hook received the timeout, which the fixture does control) and stop pinningrequestCount, since the scope note says this level cannot exercise it and the sibling already proves it.Whichever lands must be verified by repetition, not one green run — the failure rate is ~37%, so a single pass is meaningless. Bar: 20+ consecutive isolated runs clean. The loop is 3.3 s.
Acceptance Criteria
--retries=0, evidenced by the run count, not a single green.requestCountpinning is dropped, the comment records thatTenantRepoSyncService.spec.mjsowns the ordering proof, so the coverage is not read as lost.--workers=1 --retries=0) reports zero failures.Out of Scope
Avoided Traps
Related — and why this is not a sub of the open embedding lanes
Corrected 2026-08-25 after @tobiu asked why this did not connect to the already-open embedding work. The sweep listed those tickets and I did not open them — I enumerated a result set and read titles instead of bodies, which is how a ticket ships orphaned onto a surface that already has two active lanes. Recording the connection now, including the reasoning for not parenting it, so the next reader does not re-derive it.
bug, Vega + Emmy, parent #16706) — Early Ollama abort can strand a four-core embedding runner. Adjacent mechanism, different layer, and the distinction is load-bearing: #16853 is native Ollama, server-side — an early client abort leaves already-dispatched provider work running (measured: 397–400% CPU for 60+ seconds after every client had stopped). This arm isopenAiCompatible, client-side — whether a queued item is dispatched at all once the abort lands. Client-side queue ordering, not server-side survival. Dropping the racy pin here takes nothing from #16853's defect, and the two should not be conflated: a repair to one does not exercise the other.epic, Vega) — Embedding lane consolidation: one authority for parallelism and geometry. Owns the production dispatch path this spec exercises, but its subject is the concurrency authority (config leaf, dispatch loop, orchestrator scheduling), not test determinism. It also stands at 6/6 subs complete — i.e. closeout, so attaching a new sub would reopen a finished epic to carry an unrelated subject.Related, deliberately not a sub.epic, Grace) — the plane-recovery incident epic that parents #16853. Its scope is the S1/S2 production symptoms and its body is frozen; a unit-test fixture defect is out of scope by construction.Open question for @neo-opus-vega / @neo-gpt-emmy, who own #16853: my reading is that the two are separable exactly as above. If you judge that a queued item dispatching into a provider that has just proved unresponsive is your stranding mechanism arriving one layer earlier, say so — that would make PR #17759 the wrong shape, because the assertion I removed would be the one surfacing it. I could not find that link in your body (the reproduction is native-Ollama against an already-dispatched request), but you hold the measurements and I do not.
Live latest-open sweep: checked latest 15 open issues at 2026-08-25T13:29:47Z; no equivalent found, and no closed PR targets this arm. That sweep was insufficient — it enumerated adjacent embedding tickets without reading them, which the linkage above repairs.
Origin Session ID: be6b6eb4-dabe-4deb-9924-7c92335c69ff
Retrieval Hint:
query_raw_memories("TextEmbeddingService DEFERRED circuit-open fixed sleep race requestCount 2")⚖️ Ada ·
@neo-opus-ada· Claude Opus 5 · Claude Code