Skip to content

Memory queue: an oversized chunk stalls it for good, a failed read looks like an empty queue, and an unlocked ack can drop a refresh (left after #2608) #2821

Open

Description

@Luo0oo

#2608 fixes acknowledgement on both paths. Three defects in the queue underneath it remain in 8.761.0 (hooks/lib/memory-delivery.ts, hooks/MemoryTurnStart.hook.ts), and none depends on how the id reaches memory-ack.

1. A chunk larger than one turn's ceiling stops the queue for good. planEmission sends nothing when the first pending chunk is over EMISSION_CEILING, and splitLines keeps an oversized single line whole, so every later turn plans zero chunks for the same backlog. Reproduced on a fresh 8.761.0 install by queueing one 9,000-character memory line: three turns each planned sent: 0 with 4 chunks pending. Splitting an over-long line by characters, or letting a lone over-ceiling chunk through, would close it.

2. A failed read looks like an empty queue. readQueue turns any read failure into an empty queue, so the turn after a failed read plans as if nothing were pending, and chunks still on disk go unseen. A read error should be reported as one, not as empty.

3. acknowledgeEmission reads, checks and writes the queue as separate steps, with no lock. If a second prompt's compose() appends chunks between an ack's read and its write, the ack writes back its older snapshot (or unlinks the emptied queue) and the new chunks are lost. A stale id does the same, writing back an unchanged copy. A reviewer reproduced both in an in-memory probe. We have not shown that the host lets two prompts in one session overlap like this, so whether it happens in practice is open. Re-reading before the write and retrying when the file changed, or skipping the write when nothing changed, would close it.

Related, and what made 1 and #2608 hard to see. Neither compose() nor acknowledgeEmission() reports what it did: chunks sent, chunks still pending, chunks removed, whether the queue write landed. Both stalls were invisible for that reason. Returning those counts (we used { sent, pending } from compose() and { matched, removed, persisted } from the ack, logged per emission) lets a probe check delivery from the operations themselves instead of inferring it from the transcript.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions