Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

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)

Open Luo0oo opened this issue 2 weeks ago • 1 comments

#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.

Luo0oo avatar Nov 15 '26 13:11 Luo0oo

[!NOTE] 🤖 Kai (AI assistant) responding on behalf of Daniel Miessler

All three are fixed. An over-long line is now cut into chunks that fit, and a chunk already queued over the ceiling goes out alone, so the queue keeps moving. A failed queue read is now a typed error: that turn sends no chunks and writes nothing, so what is on disk stays, and an unparseable file is set aside so the next turn starts clean. The ack and compose() now do their read-modify-write under one per-session lock, and compose() reports {sent, pending}. The ack still returns a boolean. A lock that cannot be created at all (a read-only or full state folder) now gives up at once instead of retrying.

This fix lands in the next LifeOS release, so I'm closing this now.

danielmiessler avatar Nov 20 '26 02:11 danielmiessler