Skip to content

[codex] fix persisted change log semantics#7

Open
pdurlej wants to merge 1 commit into
arthursoares:mainfrom
pdurlej:codex/fix-change-log-semantics
Open

[codex] fix persisted change log semantics#7
pdurlej wants to merge 1 commit into
arthursoares:mainfrom
pdurlej:codex/fix-change-log-semantics

Conversation

@pdurlej

@pdurlej pdurlej commented May 19, 2026

Copy link
Copy Markdown

Summary

  • return persisted change log rows as LoggedChange with the stored semantic ChangeType() instead of always returning UnknownChange
  • preserve /items outer-array server indexes on flattened Item values
  • use preserved server indexes when processing and logging changes, so multi-entity server items do not drift in change_log.server_index
  • add regression tests for logged change types and multi-entity server-index handling

Context

Sync() returns typed changes from fresh processing, but the persisted query APIs (ChangesSince, ChangesSinceIndex, ChangesForEntity) previously routed through scanChangeLog, which always returned UnknownChange. This made the stored change APIs much less useful for clients like OpenClaw.

This patch intentionally avoids pretending to reconstruct full concrete structs like TaskTitleChanged{OldTitle: ...} from existing rows, because the current schema stores only metadata plus the raw item payload. LoggedChange preserves the real stored change type and metadata without inventing fields that were not persisted.

The patch also fixes a related indexing issue: History.Items flattens each server item map into multiple Item values, but processItems used the flattened slice offset as the server index. Multiple entities from one server item can now share the same persisted server index.

Validation

  • go test ./...

@pdurlej pdurlej marked this pull request as ready for review May 19, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant