Skip to content

test(sdk): record that the runtime does not fence a second owner - #399

Open
ChrisKrawczyk wants to merge 1 commit into
mainfrom
fix/runtime-second-owner-test
Open

ChrisKrawczyk wants to merge 1 commit into
mainfrom
fix/runtime-second-owner-test

Conversation

@ChrisKrawczyk

Copy link
Copy Markdown
Collaborator

Problem

copilot-runtime-migration.test.js › "refuses a resume while another process owns an active turn", added in #364, fails intermittently under load.

The test's premise is false. Runtime 1.0.112 writes inuse.<pid>.lock into the session directory, but it does not stop a second process from taking the same session:

  • Before the first runtime flushes events.jsonl: a resume from a second process fails with Failed to load session events: Session not found. That is why the test usually passed.
  • After the flush: the second process resumes the session while the first still holds a turn, and the first turn still completes. A loaded machine reaches this state first, so the test fails. The unhandled rejection "The requested run was aborted" comes from the test's own first.stop() after that failure.

I confirmed this with a probe in a Linux container, using SDK 1.0.34 and runtime 1.0.112, which listed the session directory before and after the flush.

Change

  • The test: it waits until assistant.turn_start is on disk and checks that inuse.<pid>.lock exists. It then records that a second process can resume the session while the first turn is held, and that the first turn still completes. If a later runtime adds fencing, this test fails and the notes below can be revised.
  • The migration notes (copilot-sdk-migration-1.0.34.md): they now say the runtime does not fence a second owner, so PilotSwarm must keep one owner per session itself.

#376 carries the same two hunks, byte for byte. Whichever PR merges first, the other's copy becomes a no-op when it is rebased.

This PR changes only a test and documentation: no runtime code, no migration and no orchestration change.

Validation

  • At this head (on 0.8.18, 1f6af957), the test file passes 12 of 12 on Linux (Node 24.22.1).
  • Before the rebase, it passed 5 out of 5 runs on Linux under load (load average about 30), 11 of 11 tests each run.
  • npm run check:privacy passes.

The real-runtime test added in #364 expected a second Copilot process to be
refused while another process held an active turn. Runtime 1.0.112 writes
inuse.<pid>.lock but does not fence: once the active turn's events are on
disk, a second process resumes the session and the first turn still
completes. The test only passed when the resume raced the first
events.jsonl flush and failed with "Session not found", so it failed under
load.

Wait until assistant.turn_start is on disk, then record that a second
process can resume the session, so a runtime that adds fencing is noticed.
Correct the migration notes: PilotSwarm must keep one owner per session
itself.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: cc944a13-3e0b-43de-8040-5863182bbdb0

This branch has not been deployed

No deployments
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.

2 participants