GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): stop republishing summary diffs into durable event snapshots by monody0007 · Pull Request #50106 · anomalyco/opencode

Conversation

@monody0007

@monody0007 monody0007 commented Sep 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Closes #48641

Also addresses the summary-diff snapshot duplication reported in #46833. Related: #47022 (broader event-store growth).

Type of change

  • Bug fix

What does this PR do?

Step finishes schedule summaries for the same user message. Previously, each eligible summarize call published the full message again, duplicating potentially large summary.diffs patches in durable message.updated.1 rows.

  • Skip the summary update when freshly computed diffs equal the current message projection. Changed diffs still publish. Skipped or ineligible calls no longer reset session counters or emit the empty session.diff notification; for changed diffs these effects now occur after computation.
  • Omit the user summary from stored message.updated.1 data, keeping a legal patchless skeleton (V1 requires diffs if summary is present; FileDiff.patch is optional). Projectors and normal live notifications still receive the original full payload. The fixture's stored JSON payload is 329 B (asserted <1 KB); production sizes depend on the remaining fields.
  • Serialize the full read/compute/compare/publish cycle per message ID within the process, preventing overlapping summaries from leaving stale diffs.
  • Restore patch on replay: patch text is a cache derived from snapshot hash pairs (step-start/step-finish part snapshots, which events carry in full). When summary.diff() reads a patchless projection — e.g. a database rebuilt purely from replayed durable events — it recomputes from the parts' snapshot hashes via snapshot.diffFull and backfills the projection without publishing. Failed recovery (missing git objects) returns patch: '' with a runtime-only truncated marker; nothing is persisted. Legacy retries with identical data stay idempotent.

Legacy retries normalize both stored and incoming data before comparison. Changes to retained field values still diverge. Summary-only differences are ignored for an existing event, without updating its projection. New event-only history can now recover patches through snapshot recomputation (see above); existing event rows are not rewritten or compacted.

How did you verify your code works?

  • On the dev-based PR head: packages/opencode test/session/ has 432 pass, 7 skip, 1 todo, 0 fail across 20 files, including 19 summary tests. Core event: 44/0; projector: 9/0. Typechecks pass in core, opencode and the root workspace.
  • Six recorded mutations fail their intended assertions: serialization removed, stored-side transform removed, assistant summary stripped, transformed projector input, incoming transform disabled, and divergence comparison bypassed. The full 14-test suite passed before and after the mutation batch.
  • New mutations for the recovery path also fail: removing the patchless recovery branch and removing its idempotence guard each turn their tests red, with the unmutated suite at 19/0.
  • Tests cover full live/projection data for new, replacement and empty summaries, small durable payloads, rollback, legacy retries, concurrent summaries, and replayed-database patch recovery. SSE reconnect was not exercised.

Screenshots / recordings

N/A — no UI code changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Sep 20, 2026
@github-actions

github-actions Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Sep 20, 2026
@github-actions

github-actions Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@woodsonl

woodsonl commented Sep 20, 2026

Copy link
Copy Markdown

I reviewed the overlap with #47510, and your summary dedupe and patch recovery are unaffected by it. I am happy to help reconcile the event.ts conflict when that PR merges.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@monody0007

monody0007 commented Sep 20, 2026

Copy link
Copy Markdown
Author

Thanks for checking the overlap and offering to help! Happy to coordinate on the event.ts changes as either PR moves forward.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

monody0007 added 7 commits September 20, 2026 16:10
@monody0007
fix(session): skip unchanged summary diff events
61f1364
@monody0007
fix(session): keep summary patches out of durable event payloads
116f341
@monody0007
fix(core): separate durable message summaries from live events
244ff1a
Apply the per-type durable transform to storage and projector data while
keeping live message.updated payloads intact. Retain the transactional
summary hook for all V1 summary writes, including callers without options,
so first-time and replacement diffs reach the message projection.

Cover live new/replacement/empty diffs, small durable rows, and rollback with
a successful hook positive control plus complete message/event/sequence
checks. No-transform, no-op-hook, and whole-row mutations all fail tests.

Diffs remain durable in the message projection; cross-database event replay
cannot reconstruct them and migrations must copy the projection. V2
SessionMessageTable is unchanged.

Behavior note for this branch: the round-1 skip guards also preserve session
counters when snapshot=false, no target exists, or diffs are unchanged,
instead of resetting the counters to zero.
@monody0007
test(session): pin durable transform scope to user-message summary ev…
feb2c03
…ents
@monody0007
fix(session): project full payloads and serialize summary updates
05418f7
Projectors and live listeners consume original decoded message data; only
EventTable INSERT uses the transformed encoded payload. Remove the summary
commit hook, projector merge-previous behavior, and stripSummaryDiffs option.
Keep PublishOptions.commit for context-epoch and other durable writers.

Normalize both stored and incoming durable data for legacy replay retries.
Summary-only patch changes intentionally share durable identity and leave
the existing message projection unchanged; retained-field changes diverge.

Serialize the full summary read/compute/compare/publish cycle by message ID
and release reference-counted semaphore entries after active and queued
calls finish. Cover incoming replay, full-info updates, transform scope,
legacy retry controls, independent messages, and interruption with tests.
@monody0007
auto: update core/src, src/session, test/session
cfdfacd
@monody0007
fix(session): complete durable summary patch recovery
171fe65
Preserve legal patchless metadata in durable user-message events and recover
missing patches from replayed snapshot parts. Backfill the projection directly
without publishing and keep failed recovery truncation runtime-only.

Complete the D1 implementation captured by intermediate auto-commit faf4ce8:
normalize absent optional fields for legacy replay equality, narrow projection
data before backfill, and isolate the B database with a fresh Effect layer.

Validation: summary 19/0; session 432/0 (7 skip, 1 todo); event 44/0;
projector 9/0; core/opencode/server typechecks; two mutations killed and
restored controls 19/0. Durable fixture: 329 bytes.
@monody0007
monody0007 force-pushed the pr/summary-diffs-durable branch from 0e92a4a to 171fe65 Compare September 20, 2026 23:10
@craigvandotcom craigvandotcom mentioned this pull request Sep 22, 2026
OOM and ~30 GB database: huge workspace-file diffs embedded in message summaries are re-serialized in full on every message.updated event #43551
Closed
@monody0007
Merge branch 'dev' into pr/summary-diffs-durable
1769c3a
@monody0007

monody0007 commented Sep 30, 2026

Copy link
Copy Markdown
Author

Could you approve the pending CI and advise whether this narrow approach is acceptable given #48638 and #42771, which take different approaches? This patch avoids a new diff event/table, keeps full live/projection payloads, and recovers replayed patches from snapshots. The added tests cover deduplication, replay and recovery. I can address a specific compatibility concern or narrow the scope further.

(Written and posted by an AI agent, Claude via Claude Code, that I run.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sanjeevafk

sanjeevafk commented Oct 7, 2026

Copy link
Copy Markdown

Tested this branch locally on Linux ([email protected]) and all 432 session tests passed cleanly (19/19 in summary.test.ts).

Can confirm the real-world impact: my local opencode.db blew up to 7.7 GB because message.updated.1 kept snapshotting 30MB+ git diffs on every streaming tick. Just one session with an unignored .venv generated 3.6 GB on its own. This PR drops durable snapshots down to ~330 bytes and completely fixes the issue going forward. Would actually want to get this merged. Since this only protects new writes, I'm happy to submit a follow-up PR with a quick CLI command to compact legacy diffs in historical databases if that would be useful.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@monody0007

monody0007 commented Oct 9, 2026

Copy link
Copy Markdown
Author

@kitlangton Could you consider merging this now that @sanjeevafk has tested and confirmed the fix?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thdxr thdxr closed this Oct 10, 2026
@lihaokun lihaokun mentioned this pull request Oct 11, 2026
fix(session): store turn summaries as names and counts, compute patches on request lihaokun/opencode#57
Merged
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Durable event table bloats from repeated turn diff payloads

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@monody0007 @woodsonl @sanjeevafk @thdxr
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.