Skip to content

Expose materialization source metadata#155

Merged
Antonov548 merged 1 commit into
mainfrom
materialization-source-metadata
May 22, 2026
Merged

Expose materialization source metadata#155
Antonov548 merged 1 commit into
mainfrom
materialization-source-metadata

Conversation

@marcus-pousette
Copy link
Copy Markdown
Collaborator

@marcus-pousette marcus-pousette commented May 20, 2026

Summary

  • add optional source metadata to each materialization change
  • expose the causative operation as source.operation.id.{replica,counter} plus source.operation.lamport
  • preserve source through core coalescing and the SQLite/wa-sqlite and Postgres adapters
  • extend conformance coverage so local materialization events expose the operation that caused the visible change

Before:

{
  headSeq: 42,
  changes: [
    {
      kind: 'payload',
      node: '...',
      payload: new Uint8Array([...]),
    },
  ],
}

After:

{
  headSeq: 42,
  changes: [
    {
      kind: 'payload',
      node: '...',
      payload: new Uint8Array([...]),
      source: {
        operation: {
          id: {
            replica: new Uint8Array([...]),
            counter: 7,
          },
          lamport: 123,
        },
      },
    },
  ],
}

Notes

  • source.operation.id.replica is a low-level CRDT replica id, not auth/user identity
  • source.signer.publicKey is reserved in the TypeScript shape for a later auth-aware follow-up
  • source is optional because conservative catch-up can derive visible changes from rebuilt state instead of one exact operation
  • this gives apps enough metadata to maintain local projections such as lastUpdated or updatedBy without putting that bookkeeping into payload bytes

@marcus-pousette marcus-pousette force-pushed the materialization-source-metadata branch from 29384f0 to 54444ee Compare May 21, 2026 08:19
@marcus-pousette marcus-pousette marked this pull request as ready for review May 21, 2026 08:53
@marcus-pousette marcus-pousette force-pushed the materialization-source-metadata branch from 54444ee to 60950b7 Compare May 21, 2026 15:27
@Antonov548 Antonov548 merged commit 4bca56e into main May 22, 2026
3 checks passed
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.

2 participants