Skip to content

agentHost: settle the session artifact removal fixture before reading session.db - #342096

Merged
Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
agents/fix-flaky-artifact-removal-idempotent
Oct 16, 2026
Merged

Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
agents/fix-flaky-artifact-removal-idempotent

Conversation

@sandy081

Copy link
Copy Markdown
Member

Follow-up to #341001 and #342060.

Problem

'removing an already-absent id is idempotent and leaves the collection unchanged' failed in CI on #342054 with the same key-order diff in persisted. #342060 made the session state store repair session.db after a replayed catalog write, but it does that on the store's coalesced flush. This test, and 'persists removal and publishes metadata…', read session.db right after the removal, before that flush.

The interleaving comes from the fixture itself. Its seeded setSessionMeta is flushed as a summary change 100 ms later, in the middle of the test on a slow agent. That queues a background catalog write after the removal, which replays the removal's sync.

On current main (with #342060), holding the first artifact catalog write until a summary flush reproduces the CI diff for both tests.

Fix (test only)

  • createFixture waits for its seeded summary change, the background catalog write it queues, and the store's mirror before returning. This is an event fence, not a timeout, and no fixture timer remains pending inside a test.
  • Every read of a store-owned key from session.db (sessionArtifacts, agentHost.pendingRecordedPullRequests) goes through readPersisted, which first waits for whenIdle(session) on the store.
  • 'keeps a removal durable when a summary change is flushed while it is persisting' still forces the interleaving and remains the regression test for agentHost: keep replayed catalog writes from claiming the session.db mirror #342060.

Audit: the other agentHost tests that read sessionArtifacts from session.db either parse it (agentService.test.ts artifact round-trip, the PR checkout test, agentHostPullRequestOperationProvider.test.ts) or drive the ordered writes explicitly (agentService.test.ts ordered and deferred overrides). None depends on a pending summary flush.

Validation

  • Forced interleaving: a temporary copy of the suite holds each test's first artifact catalog write while a summary change is flushed.
    • On current main, the idempotent and first-removal tests fail with the CI diff.
    • With this change, every persisted assertion passes. The remaining failures in the copy come from the extra _meta changes the harness itself injects (actions and published labels).
  • Mutations, each failing the forced idempotent test and 'summary flushed while persisting' with the CI key-order diff:
  • npm run transpile-client: passed.
  • 200 consecutive runs of mocha test/unit/node/index.js --delay --ui=tdd --exit --run src/vs/platform/agentHost/test/node/sessionArtifactRemoval.test.ts plus the forced copy: 200/200 passed.
  • agentHost node suite (all 357 src/vs/platform/agentHost/test/node/**/*.test.ts files): 11642 passing, 75 pending, 14 failing. All 14 are in copilotAgent.test.ts, and the list is identical on unmodified origin/main (750 passing, 14 failing), so they are pre-existing.
  • npm run eslint and build/hygiene.ts on the changed file: passed, and the pre-commit hygiene hook passed.

… session.db

The fixture's seeded summary change was flushed 100 ms later, in the middle
of whichever test was running. On a slow agent its background catalog write
replays the removal's sync, and session.db briefly keeps the caller's
serialization of the artifacts until the session state store mirrors its
own. Tests that read session.db right away (the idempotent removal test in
CI, and the first removal test) then see a different key order.

Wait for the seeded summary change and its background write in the fixture,
and read store-owned keys from session.db only once the store has mirrored
them. The dedicated summary-flush test still forces that interleaving.

Follow-up to #341001

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 15:45
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.143.0 milestone Oct 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No actionable findings remain; the test-only synchronization preserves regression coverage without changing production behavior.

0 open findings

What changed in this PR

Stabilizes session artifact removal tests by settling fixture initialization and waiting for persisted state, following #342060.

Changes:

  • Waits for seeded summary changes, background catalog writes, and store mirroring.
  • Centralizes persisted reads behind the store’s idle fence.
  • Preserves the forced-interleaving regression test and existing assertions.
File Description
src/​vs/​platform/​agentHost/​test/​node/​sessionArtifactRemoval.test.ts Adds fixture synchronization and fenced persistence reads.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 3629e03c Current: 269e5f82

Changed (1)

sessions/sessionActivityBar/sessionActivityBar/SubmenuOpen/Light
Before After
before after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants