bug(pi): writes committed after 3000 ms are reported as unknown outcome; mem_update and passive capture have no recovery lookup

Aperta
#2,513 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, sqlite, typescript

Direzione di ricerca

Start in plugin/pi/index.ts at ENGRAM_WRITE_TIMEOUT_MS, postObservationWithReplayRecovery, and the mem_update, mem_session_summary, and passive capture call sites named in the issue. Trace how operation IDs and /observations/save-result recovery work for mem_save, then check the existing or planned regression tests for delayed commits. Done means committed writes are confirmed or expose a recoverable result within a bounded time, without duplicate POSTs.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

status:needs-review type:bug
Existing Issue Search
  • I searched existing issues and will add evidence to a canonical tracker when applicable.
📝 Observed Consequence

Pi memory writes that the server commits are reported to the agent as failed with an unknown outcome:

  • mem_save: gentle-engram could not confirm the observation save. Its outcome is unknown — do NOT blindly retry with a new operation. Operation ID: …
  • mem_update, mem_session_summary and background passive capture: gentle-engram could not confirm the write after 3000ms. Its outcome is unknown …

Every case I checked had been committed. In one Pi session over about 28 h, 3 writes were reported unknown and all 3 were in the store:

  • the mem_save operation_id returns {"status":"committed"} from GET /observations/save-result;
  • the mem_session_summary observation exists with a matching timestamp;
  • the mem_update row's updated_at is about 2 s after the call.

The agent is told not to retry, has to verify by hand, and the status entry is cleared (#2512).

🔄 Steps to Reproduce
  1. Run engram serve on a local SQLite store (WAL, synchronous=FULL) on a disk under I/O load. Here: a WSL2 ext4 volume while pnpm install runs in another worktree.
  2. From Pi with gentle-engram 0.8.0, call mem_update (or mem_save).
  3. The commit takes longer than 3000 ms to answer.
✅ Expected Behavior

A write the server commits within a few seconds is confirmed. When the response is late, the client keeps checking for a bounded time, and mem_update and passive capture get a way to recover the result, as mem_save already does through its operation_id.

❌ Actual Behavior

On main at 11521f4f3776db6d94dc17c11731bad35b71c7bc, plugin/pi/index.ts:

  • Every write gets one attempt with a fixed 3000 ms budget (:70 ENGRAM_WRITE_TIMEOUT_MS = 3000, :284 maxAttempts: 1). No environment variable or setting changes it.
  • mem_save recovery (postObservationWithReplayRecovery, :582) has a 7500 ms total budget, but after the POST times out it makes a single 1000 ms save-result lookup (:662, :73). A commit that lands right after that lookup is reported as unknown.
  • mem_update, mem_session_summary and /observations/passive (:2617, :2850, :3394) have no operation id or recovery lookup, so a late but successful commit can only be reported as unknown.
Operating System

Windows (WSL)

Release Version (Report Context)

engram 3.7.0 core, gentle-engram 0.8.0 (code confirmed unchanged on main 11521f4)

Agent / Client

Other

📋 Relevant Logs
mem_update: gentle-engram could not confirm the write after 3000ms. Its outcome is unknown because the server may already have applied it — do NOT blindly retry it, or you may duplicate the write. Verify with mem_search or mem_doctor first.
Warning: [engram] background capture to /observations/passive failed: gentle-engram could not confirm the write after 3000ms. …

$ curl 'http://127.0.0.1:7437/observations/save-result?operation_id=<id from the mem_save error>'
{"id":16694,"status":"committed"}

Store context: 286 MB DB, freelist 0.4 %, WAL mode, synchronous=2, autosync healthy with no backlog, /health answering in under 1 ms at the same time.

💡 Additional Context

Client: Pi (Gentle Shell) with the gentle-engram companion.

Prior history: #1272 (closed) reported the same false negative for mem_save under the fixed 3 s budget. It was resolved by classifying the outcome as unknown (#1360) and adding replay-safe saves with a committed-result lookup (#1629, #1714, #1715). This is a follow-up on what that left uncovered, not a duplicate:

  • mem_save still makes a single 1000 ms lookup inside its budget;
  • mem_update, mem_session_summary and passive capture never got an operation id or lookup.

Possibly related server-side latency: #1967 (store opens serialize), #2393 (SQLite write transaction on the critical path).

Regression test plan:

  1. A fake server that commits a save but answers after more than 3 s: mem_save must end confirmed through bounded repeated save-result lookups, with no second POST.
  2. The same delay for mem_update: it must end confirmed or report a recoverable id, never a bare unknown for a committed write.
  3. If the budget becomes configurable, invalid values fall back to the default.
Lingua principale
Go
Stelle
7.1k
Fork
729
Merge medio
2h 19m
PR unite (30g)
167

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Gentleman-Programming/engram

Tutte le issue di Gentleman-Programming/engram

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.