GeezerVison is showing github.com — fix(capture): preserve pending evidence across session deletion by Phototonic · Pull Request #479 · tickernelz/opencode-mem
Conversation
Phototonic
commented
Nov 2, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Addresses #476.
Delayed auto-capture depended on a live transcript, so deleting a session could lose observed work before capture ran. This change persists bounded final assistant text and terminal tool outcomes from delivered V1/V2 events, then summarizes ready evidence without fetching a deleted host session.
- Preserve prompt association: V1 binds assistant parent IDs; V2 freezes the delivered inbox input at step start so a later queued prompt cannot steal earlier results. Unknown/private inputs fail closed. Only narrowly recognized evidence events can use existing pending project ownership after host lookup fails.
- Add a pending-evidence table, idle/deleted readiness checkpoints, same-project startup replay, claim cleanup, and disposal draining. Older prompts without evidence cannot block later recoverable prompts, and a missing host lookup is not repeated throughout the batch.
- Redact private tags before storage, including across final text parts in one assistant message. Exclude reasoning, raw deltas, attachments, provider metadata, and tool arguments. Limits are 16 KiB per part, 16 parts per prompt, 256 parts globally (4 MiB text), and 64 KiB read per capture. Evidence expires after 24 hours and is pruned on later store access; capture/skip decisions and existing prompt deletion/retention clear it. Session deletion itself preserves pending memory evidence and previously captured memories. These are logical limits, not secure erasure of SQLite/WAL copies or backups.
- Use stable IDs for auto-capture additions so sequential crash/restart replay reuses the original per-project/prompt memory, including soft-deleted rows without resurrection. This does not provide distributed exactly-once semantics for optional semantic update/supersede operations or every multi-process crash interleaving.
- Retain the exact
Session.NotFoundError handling at the originating context lookup and meaningful error logging. When neither ready evidence nor live context exists, log an explicit skipped outcome and retain the request without spending its retry budget or inventing completed work.
Recovery requires evidence actually received, durably saved, and checkpointed ready by idle/deleted. The V2 stream is volatile: unseen events, unresolved association, eviction/expiry, or disconnect before a terminal checkpoint remain unrecoverable. Startup does not assume unfinished, uncheckpointed work is complete. This cannot reconstruct already deleted/unseen transcripts or revive exhausted retries. The README documents these limits.
Test plan
Verified in an isolated Linux cloud checkout with Bun 1.4.4:
- 68 focused tests across eight files passed, covering actual database and real plugin event flow; deletion before delayed capture; disposal/restart replay without host lookup; V1/V2 mappings; private tags; bounds/expiry; project isolation; duplicate handling; stable add-path replay; old-schema migration preserving prompts; and older-empty-prompt starvation.
bun test --timeout 30000: 1,057 passed, 4 skipped, 0 failed. The allowance accommodates pre-existing slow profile/auto-update tests previously reproduced on untouched upstream; no source timeout setting changed.
bun run build and bun run check passed, including formatting, ESLint, and typecheck.
An independent bounded code review identified the starvation edge case, which is now fixed and tested, with no remaining high-confidence blocking findings within the reviewed scope. Windows runtime behavior has not been personally reproduced; hosted CI provides platform checks.
- Exercised the change in the isolated Linux cloud checkout
- Noted known limitations above and in the README
Checklist
- Branch is based on
main
-
bun test passes with the timeout allowance described above
-
bun run typecheck passes (included in bun run check)
-
bun run check passes (format + lint + typecheck)
- Docs / README updated for the behavior change
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Phototonic
changed the title
fix(capture): retain pending prompts when session context is unavailable
fix(capture): preserve pending evidence across session deletion
Nov 2, 2026
Keep durable evidence as the deletion/startup fallback so normal idle
capture still uses the richer host transcript instead of bounded parts.
Prevent late buffered events from rebinding and clearing ready state,
keep observe non-rejecting so deleted-session capture still runs, and
cancel a pending idle timer when the session is deleted.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 2, 2026
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|