Repository navigation
Description
Summary
Operator decision, 2026-09-16 (@obasilakis): human-interactive chat goes on the durable queue — Open Question 7 resolves to the edge adapter. This issue builds the half that makes that safe on correctness.
Each conversation is a JSON-Lines transcript on the agent container's disk (~/.claude/projects/-home-developer/<session-uuid>.jsonl), and continuing a conversation means claude --resume <id>, which reads and appends to that same file. Today a Redis session lock guarantees one turn per conversation at a time. Once N independent workers pull from a shared queue, two turns of the same conversation can be claimed concurrently and both resume the same transcript — interleaved appends, corrupted history. That is the second problem #1989 names and marks unaddressed.
The requirement is mutual exclusion, NOT worker affinity
This distinction is the whole issue, and the obvious reading is the wrong one.
The naive fix is "pin a conversation to one worker." Do not build that. All N workers live inside the same agent container and share one filesystem, so there is no file-access reason to pin. Pinning actively defeats the sibling priority work: if the pinned worker is mid-way through a 30-minute batch turn, that person waits even though two other workers are idle.
What is actually required is only that two turns of one conversation never run at once — any free worker may serve it. That is what the existing lock already expresses; the work is carrying that guarantee across to a claim path where the claimer is chosen by the worker rather than assigned by the backend.
Affinity does become necessary if an agent ever runs as multiple containers (the replica_count > 1 / session-storage question, open question 5 / #927) — because then the transcript is single-container state. Out of scope here; worth a line in the spec so the next person does not conclude affinity was forgotten.
Scope
- A conversation-scoped claim guard so at most one turn per conversation is in flight, whichever worker holds it.
- A turn for a conversation that is already running must not block the whole queue — the worker skips it and claims the next eligible item rather than head-of-line blocking.
- The guard must release on every terminal path, including lease expiry and re-delivery, or a crashed worker silently locks a conversation out.
- Interaction with the existing Redis session lock stated: replaced, or retained and coordinated with. One mechanism, not two.
Acceptance criteria
- Two turns of one conversation are never in flight simultaneously — tested under concurrent claims on PostgreSQL, where the race is real
- A blocked conversation does not head-of-line-block the queue; other work is still claimed
- A worker that dies mid-turn releases the conversation guard (verified via the lease-expiry path)
- The transcript is intact after a burst of same-conversation turns — no interleaved or lost lines
- Multi-container affinity is explicitly out of scope and recorded as such, not silently omitted
Notes
- Parent: feat: pull / work-stealing coordination (push→pull dispatch) #1081 (Phase 4). Required by the decision recorded on Decide (on paper) whether human-interactive chat belongs in the pull queue — TARGET_ARCHITECTURE Open Question 7 #1989.
- Sibling: feat(pull): interactive turns jump the queue — the starvation half of Open Question 7 #2842 (interactive turns jump the queue). Priority is about when; this is about whether two may run at all. Chat cannot move to the queue until both land.
⚠️ Note the release path interacts with re-delivery: re-delivery deliberately reuses the same execution id, so the guard must key on the conversation and tolerate the same execution arriving twice.
Activity
docs: Open Question 7 is decided — chat joins the queue, push is dele…
docs: record the Open Question 7 decision on dev — chat joins the que…
obasilakis commentedon Sep 30, 2026
/claim
github-actions commentedon Sep 30, 2026
Claimed by @obasilakis. Label
status-in-progressadded.Next steps:
feature/2843-<short-slug>Fixes #2843feat(pull): interactive turns first, one turn per conversation (#2842, …
fix(queue): a claim keeps the admission instant, so a wait stays meas…
feat(execution): a queued head that stops moving says so within a min…
fix(queue-stall): priority per wait reason, a leased monitor with bou…