Repository navigation
Conversation
|
Codex review: found issues before merge. Reviewed August 2, 2026, 3:01 AM ET / 07:01 UTC. ClawSweeper reviewWhat this changesThe branch preserves hidden session records for keep-mode subagent runs, lets transcript reads fall back to deleted archives, and adds a memory-core retry-read regression test so dream diaries can retain generated narrative text. Merge readiness⛔ Blocked by patch quality or review findings - 11 items remain Keep this PR open for a scoped redesign: its lifecycle direction addresses a real narrative-read race and has credible real-run evidence, but the patch makes explicitly deleted transcripts eligible for a reset-only history fallback and broadens hidden-session retention to every keep-mode subagent run. Priority: P1 Review scores
Verification
How this fits togetherMemory Core starts detached Gateway subagent runs for dream narratives, reads the resulting session transcript, then explicitly deletes the temporary session. Gateway lifecycle bookkeeping owns the hidden SQLite session record and the transcript reader selects live or reset-archive history for session reads. flowchart LR
A[Dreaming workspace] --> B[Memory Core narrative run]
B --> C[Gateway subagent lifecycle]
C --> D[Hidden session record]
C --> E[Session transcript]
D --> F[Post-run message read]
E --> F
F --> G[Dream diary entry]
F --> H[Explicit session deletion]
Decision needed
Why: The patch changes the semantics of deletion and transcript recovery across Gateway callers; choosing the permanent privacy and lifecycle boundary requires maintainer intent. Before merge
Findings
Agent review detailsSecurityNeeds attention: The deleted-transcript fallback weakens the expected deletion boundary by making archived content readable through a generic recovery path. PR surfaceSource +23, Tests +33. Total +56 across 3 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase onto current main and add a narrowly authenticated in-flight transcript-read path for host-owned narrative runs, while preserving reset-only archive fallback and retaining cleanup for keep-mode callers that have no explicit completion owner. Do we have a high-confidence way to reproduce the issue? Unclear for the exact current-main shape: the PR discussion contains a real A/B reproduction on the proposed head, and current source still shows the lifecycle/read boundary, but current main has since materially refactored the narrative session flow. Is this the best way to solve the issue? No. Fixing the lifecycle owner is preferable to the original trajectory workaround, but the current branch must not turn deleted archives into generic reset-history fallback or make all keep-mode callers retain hidden sessions. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 339b9ce0c25e. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
e7476f8 to
e25d440
Compare
|
Hi @bladin — reporter of #87182 here. We independently implemented the same trajectory-recovery approach as a local dist patch yesterday (before this PR existed) and have been running it in production for ~24 hours. Sharing concrete numbers in case "needs-real-behavior-proof" can be partially satisfied from a parallel implementation. Live metrics (two cron windows)Smoke after first apply (2026-05-27 07:18 UTC, manual cron of the nightly dreaming job):
Re-applied today after a packaging regression broke the patch (2026-05-28 19:30 UTC, same manual cron):
So in both runs ~70% of the workspaces×phases that would have hit the race were recovered with the actual model-generated narrative, not the snippet fallback. The recovered text matches what we'd see written directly to DREAMS.md on a healthy run (sample line lengths 200-500 chars, normal dream-diary content). Two latent bugs we hit you may want to pre-emptWhen porting this to our bundled dist (so caveats may not all apply to a clean TS source PR):
Lookup strategyWe index trajectories by Happy to share the exact diff if helpful for cross-checking. Will swap our local patch out as soon as this merges. Happy to re-test on the production target on request — a single manual cron run reproduces the recovery path deterministically against existing trajectory files. |
|
Corroborating evidence for the recovery approach (and the runId point) We hit this exact failure on OpenClaw 2026.6.5 with provider On the keying concern raised in review: in our capture the recoverable text was correctly associated with its own |
|
Maintainer review — the race is real (session archived before narrative extraction reads it) but the recovery shape can't land as-is, keeping open for redesign:
The lifecycle fix (option 2) is the shape most likely to be accepted — happy to re-review. |
Redesigned per maintainer review (@obviyus)The original trajectory-recovery approach has been replaced with the lifecycle fix (option 2 from the review), which removes the race at the source instead of patching around it. Changes1. Preserve session store entries for keep-mode subagent runs (
2. Include
3. Keeps The settled retry with 50/150/300/750 ms delays (from #89091) is preserved instead of the trajectory-based recovery, since the lifecycle fix removes the race at the source. 4. Removes The trajectory-based recovery with unkeyed filename scanning and no identity verification is removed entirely. If trajectory recovery is ever needed again, it must resolve by sessionId/runId and verify event identity before using text. TestAdded BranchThe redesigned code is at |
Two changes that together fix the race where the gateway archives a session transcript before the host plugin (memory-core dreaming) can read it: 1. Preserve session store entries for keep-mode subagent runs. completeCleanupBookkeeping now skips removeInternalSessionEffectsSession when cleanup=keep, so the host's getSessionMessages call still resolves the entry. The host's explicit deleteSession handles full cleanup. 2. Include .jsonl.deleted.<ISO> archives in transcript history fallback. listResetArchiveCandidatesForTranscriptAsync previously only matched .jsonl.reset.<ISO> files. Now it also resolves .jsonl.deleted.<ISO> so sessions.get can read archived transcripts when the live file is gone. Keeps readSettledNarrativeText (settled retry with 50/150/300/750 ms delays) instead of the trajectory-based recovery removed from the prior approach, since the lifecycle fix removes the race at the source.
e25d440 to
c87ceec
Compare
Third-party empirical A/B of Test env
Method Two conditions per sweep-count. Each sweep = one Actions / Outcomes
Why
Log excerpt (parent On Notes
Available on request: raw sweep logs ( |
|
Thanks for investigating this race and redesigning the fix. Our current-main run completed two scheduled dreaming sweeps and all six detached narrative writes without an empty-text fallback. The newer A/B evidence above also shows this PR still produces two no-text failures across ten fresh-workspace sweeps, so it does not fully close the race. Closing this PR; #87182 can remain the place for a deterministic fix if the failure is reproduced again. |
Summary
This PR fixes #87182 where the gateway's post-completion session cleanup races with memory-core's narrative extraction, causing model-generated narrative text to be silently discarded.
Root Cause
After subagent runs complete, the gateway immediately archives the session JSONL file (renames to
.deleted.<ISO>). However, memory-core'sgenerateAndAppendDreamNarrative()tries to read messages viagetSessionMessages()after this cleanup happens, resulting in empty message arrays and lost narrative text.Solution
Implement trajectory-based recovery as suggested in the issue:
extractNarrativeFromTrajectory(): Reads.trajectory.jsonlfiles which persist longer than session JSONL filesextractSessionIdFromMessages(): Extracts session ID for trajectory lookupgenerateAndAppendDreamNarrative(): Attempts trajectory recovery before falling back to snippet-based entriesChanges
extensions/memory-core/src/dreaming-narrative.ts: +163 linesVerification
The fix follows the workaround already proven effective in production (mentioned in #87182):
Real Behavior Proof
Will verify with:
Fixes: #87182
Type: Bug fix
Breaking: No
Migration: None required - backward compatible recovery mechanism