Skip to content

T3: persisted per-(sink,partition) watermark store keyed by logical path#155

Merged
philcunliffe merged 1 commit into
integration/incremental-sink-readsfrom
task/incremental-sink-reads/T3
Jun 25, 2026
Merged

T3: persisted per-(sink,partition) watermark store keyed by logical path#155
philcunliffe merged 1 commit into
integration/incremental-sink-readsfrom
task/incremental-sink-reads/T3

Conversation

@philcunliffe

Copy link
Copy Markdown
Contributor

Implements task T3 of incremental-sink-reads (LLP 0042).

Adds src/core/sinks/watermarks.js: the shared per-(sink instance, partition) incremental-read watermark store at <stateDir>/watermarks/<dataset>/<partition-key>.json, keyed by the stable LOGICAL partition path (not the physical tableDir), with atomic write-rename. Includes types and a unit suite. Consumed by T4 (forward sink) and T5 (blob sink).

Checks: npm test (1418 pass), npm run typecheck (clean), npm run lint (clean).

Task-Id: T3

Add `src/core/sinks/watermarks.js`, the shared incremental-read watermark
store for the forward and blob sinks (LLP 0042 task T3). Files live at
`<stateDir>/watermarks/<dataset>/<partition-key>.json` and carry the
versioned `{ continuation, exportedRowCount, updatedAt }` record.

The key is derived from the partition's stable LOGICAL path
(`datasets/<dataset>/<partition...>` relative to cacheRoot), never the
physical `tableDir` inside it — the hinge of design constraint (B): the
watermark reads straight through a compaction generation swap and a
retention front-prune. `write` is atomic write-rename (the
`writeCursor`/`writeProgress`/`ingest-seq.js` idiom); a corrupt or absent
record reads back as null so a sink re-exports from the start
(at-least-once + downstream dedup) rather than silently skipping rows.

Adds `SinkWatermarkKey`/`SinkWatermarkRecord`/`SinkWatermarkStore` types,
anchors LLP 0040 §3 (`#watermark-contract`), and a unit suite covering key
derivation (logical-not-tableDir, nesting, sanitize, sentinel, escape
guard), round-trip, in-place advance, atomic-no-temp, malformed-token
rejection, and corrupt-file null.

@ref LLP 0040#watermark-contract

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Task-Id: T3
@philcunliffe philcunliffe merged commit 88d6841 into integration/incremental-sink-reads Jun 25, 2026
6 checks passed
@philcunliffe philcunliffe deleted the task/incremental-sink-reads/T3 branch June 25, 2026 23:40
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