Symptom
status-config-e2e.test.ts > status/config: etcd watch source > clean config reports synced with revisions and resource counts intermittently fails:
AssertionError: expected undefined to be 1 // Object.is equality
at src/cases/status-config-e2e.test.ts:145 expect(cfg.applied.resource_counts.models).toBe(1)
The test waits until GET /status/config returns state === "synced", captures that response, then asserts applied.resource_counts.{models,provider_keys,api_keys} === 1. On the failing run, the same response had state: "synced" but applied.resource_counts.models was undefined — i.e. the state machine reported synced before/without the applied snapshot's resource_counts reflecting the loaded resources.
Frequency
Intermittent — passes ~3/3 on isolated local re-runs, failed once in isolation locally and once on a CI runner (slower runner makes it more likely). Pre-existing; not tied to any specific change (surfaced on an unrelated test-only PR's CI).
Suspected cause
/status/config may compute state and applied.resource_counts from a point where the derived state can read synced while resource_counts is empty/partial — i.e. the two fields aren't published atomically, or state flips to synced a beat before resource_counts is filled. Worth confirming whether state == synced should guarantee the applied snapshot (including resource_counts) is fully materialized in the same response.
Options
- DP: make
state == synced imply resource_counts is populated (publish atomically), OR
- Test: additionally gate on
applied.resource_counts.models >= 1 (not just state === synced) before asserting.
The DP fix is preferable if synced is meant to be a consistent point-in-time view.
Symptom
status-config-e2e.test.ts > status/config: etcd watch source > clean config reports synced with revisions and resource countsintermittently fails:The test waits until
GET /status/configreturnsstate === "synced", captures that response, then assertsapplied.resource_counts.{models,provider_keys,api_keys} === 1. On the failing run, the same response hadstate: "synced"butapplied.resource_counts.modelswasundefined— i.e. the state machine reported synced before/without the applied snapshot'sresource_countsreflecting the loaded resources.Frequency
Intermittent — passes ~3/3 on isolated local re-runs, failed once in isolation locally and once on a CI runner (slower runner makes it more likely). Pre-existing; not tied to any specific change (surfaced on an unrelated test-only PR's CI).
Suspected cause
/status/configmay computestateandapplied.resource_countsfrom a point where the derivedstatecan readsyncedwhileresource_countsis empty/partial — i.e. the two fields aren't published atomically, orstateflips to synced a beat beforeresource_countsis filled. Worth confirming whetherstate == syncedshould guarantee the applied snapshot (includingresource_counts) is fully materialized in the same response.Options
state == syncedimplyresource_countsis populated (publish atomically), ORapplied.resource_counts.models >= 1(not juststate === synced) before asserting.The DP fix is preferable if
syncedis meant to be a consistent point-in-time view.