Skip to content

fix(store): bound message event history#72

Merged
steipete merged 1 commit into
mainfrom
codex/message-event-compaction
Jul 4, 2026
Merged

fix(store): bound message event history#72
steipete merged 1 commit into
mainfrom
codex/message-event-compaction

Conversation

@steipete

@steipete steipete commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • suppress consecutive identical message-event snapshots per message, source, and event type while preserving real transitions and reversions
  • add a lightweight schema-v4 event-head migration that avoids indexing or scanning multi-gigabyte history at startup
  • add preview-first purge --keep-message-events N compaction for retained messages, scoped by workspace and partitioned by source/type
  • document retention semantics, completions, generated SQL, snapshot-restore behavior, and contributor credit

Behavior proof

An isolated built CLI imported the same Slack snapshot twice and retained one event. Changing alpha to beta and back to alpha produced exactly three ordered events. A compaction preview reported two removals without changing the table; the forced command removed exactly two, retained the newest event, and preserved the canonical message. Zero retention was rejected and help exposed the new flag.

Validation

  • go mod verify
  • go test -count=1 ./...
  • go vet ./...
  • sqlc regeneration idempotence
  • focused store, CLI, and share tests
  • source-blind behavior contract: 6 passed, 0 failed
  • autoreview: clean after resolving the migration finding

Closes #68

@steipete steipete merged commit 6181fcb into main Jul 4, 2026
12 checks passed
@steipete steipete deleted the codex/message-event-compaction branch July 4, 2026 04:29

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3545f26c1a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/share/share.go
if _, err := tx.ExecContext(ctx, `delete from message_fts`); err != nil {
return Manifest{}, fmt.Errorf("clear message_fts: %w", err)
}
if _, err := tx.ExecContext(ctx, `delete from message_event_heads`); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Seed event heads after share imports

When a config has git-share auto-update plus live sync, sync runs autoUpdateShare before runSyncTargets (internal/cli/app.go:567-572). This import clears message_event_heads but then imports messages/message_events and never rebuilds the derived heads, so the following sync hits sql.ErrNoRows in appendMessageEvent and appends a duplicate unchanged event for every message it touches; repeated share updates can therefore re-amplify the history this change is meant to bound. Seed the heads after import, or include them in the snapshot, before returning.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

message_events getting huge when using desktop watch

2 participants