Skip to content

Fix queued seat wakes and refused starts - #60

Open
andreisavu wants to merge 1 commit into
mainfrom
codex/work-on-remaining-tasks-from-pr-48
Open

andreisavu wants to merge 1 commit into
mainfrom
codex/work-on-remaining-tasks-from-pr-48

Conversation

@andreisavu

Copy link
Copy Markdown
Contributor

Motivation

  • Prevent race conditions where a wake landing during an activation release could start or steer a second activation, and ensure a refused start does not leave a name registered as running.

Description

  • Keep a seat occupied through the lease release and mark the activation over while the release is in flight to ensure wakes in that window queue instead of starting or steering another activation (packages/ambion/src/seat/seat.ts).
  • Replace the single queued wake with an ordered, deduplicated array so multiple wakes queue in order and each only once, and add enqueue logic and ordered draining (packages/ambion/src/seat/seat.ts).
  • Preserve the initiating run() until the queued wakes drain in order (packages/ambion/src/seat/seat.ts).
  • Free a session name when an asynchronous startSession or resumeSession fails so a refused composition does not keep the name reserved, using a guarded free helper to avoid deleting a newer run (packages/ambion/src/session.ts).
  • Reject deliveries addressed to the assistant seat when its attention is none to avoid messages that no seat can read (packages/ambion/src/session.ts).
  • Add and adjust tests covering release-window wakes, ordered and deduplicated queue draining, refused starts freeing names, assistant-directed deliveries, and stale-before-missed commit ordering (packages/ambion/test/seat.test.ts, packages/ambion/test/session.test.ts, packages/ambion/test/assistant.test.ts).

Testing

  • Ran unit tests for the changed areas: pnpm --filter @ambionframework/ambion exec vitest run test/seat.test.ts test/session.test.ts, which passed (18 tests passed).
  • Ran the specific regression scenario: pnpm --filter @ambionframework/ambion exec vitest run test/assistant.test.ts -t 'composes nothing for a question', which passed.
  • Ran project checks: pnpm check (build, type checks, lint/knip, test); succeeded apart from transient TypeScript diagnostics in test/live sources noted during build, and final test run succeeded.
  • Ran formatting check: pnpm check:format and prettier fixes where needed; formatting is clean.

Codex Task

andreisavu added a commit that referenced this pull request Sep 10, 2026
…a name a refused start took (#61)

Three faults a review of the branch found are still open, and this
commit fixes them.

The seat actor held one queued wake, so a second wake that landed while
an activation ran overwrote the first, and the room waited out the
resend window for work the seat had already been sent. The queue is an
array now: every wake queues once, keeps the place the first one took,
and runs in turn.

A wake that landed while an activation released its lease was steered
into that activation. It reads nothing more, so the steer went nowhere.
The activation is marked over for the length of its release, and a wake
that lands then runs as an activation of its own.

A start whose composition the record refuses kept the name for the life
of the runtime, unless the host stopped the handle it holds. The name
comes free when the start is refused, and the next start takes it.

A delivery directed at the assistant is refused. The assistant sits at
the narrow end of attention and wakes for nothing said, so such a
delivery is a message nobody reads.

The seat tests pin the two seat faults, and the session tests pin the
freed name, the refused delivery, and a commit from a lease that ended,
which is answered stale before what the record moved past. That last
test comes from #60, which took the same three fixes in parallel.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SJjjR3S6iwqEbDXsRDJgiq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant