Repository navigation
spec(12): replication-history modes -- per-table SCD2 history and replication-log-only, specified from the 2.11.0 code with a Lean model (Domain 12, Replication.History) - #1507
Merged
minguyen9988 merged 1 commit intoSep 26, 2026
Conversation
…g-only, with Lean model
Two of the three operating modes had no single specification: per-table SCD2
history (replication.history.enable=true) was scattered over 04.04 s3.2,
02.01 s3.5, 08.05, 06.05, 06.09 and 05.02, and replication-log-only
(replication.history.replication_log_only=true) had none at all. This adds
Domain 12 and a Lean module that follow the 2.11.0 implementation exactly and
record its defects as gaps with machine-checked witnesses, so they can be
debugged at the spec level before the code changes. No src/main change.
specs/12-replication-history/
01-operating-modes.md enable x log_only matrix, per-batch writes,
database routing (every table -> history db),
startup, the degenerate combination
02-scd2-table-shape.md columns, sentinel 2100-01-01, engine,
PARTITION BY toDate(_valid_to),
ORDER BY (pk, _valid_to), TTL; record-path
vs DDL-path differences D-1..D-3
03-scd2-write-protocol.md INSERT binding, UPDATE 3-SELECT and DELETE
2-SELECT statements, versions, key predicate,
inline UPDATE vs flushed DELETE; gaps
G-12.03-1..6
04-binlog-history-audit-table.md the 19-colu
8000
mn audit table: DDL, per-column
values, DML and DDL rows, TTL
05-replication-log-only.md audit rows only, DDL translated not
executed, what the offset certifies,
single-threaded parity gap
formal_specs/lean/Replication/History.lean (new lakefile root)
SCD2 row sets over the FINAL view at (pk, _valid_to):
update_supersedes_open_row, delete_hides_open_row, closed_row_continuity,
at_most_one_live_row_per_sort_key; gap witnesses
staged_insert_writes_no_closed_row (UPDATE runs inline without the flush the
DELETE path performs), closed_history_row_depends_on_insert_order (close row
and before copy tie on sorting key and version),
update_only_closes_after_image_key (key predicate from the after image);
log-only gating and routing on both executors (writer_path_ignores_log_only,
routing_diverges_on_log_only_alone). lake build clean, no sorry.
Registration: specs/README.md, CONSTITUTION.md s4/s5, 11.03 module list,
04.04 s3.2 pointer, formal_specs/lean/README.md, validate_specs.py
EXPECTED_DOMAINS (+12-replication-history).
Verification: scripts/validate_specs.py --lake PASSED (65 specs, 622
citations, lake build exit 0); scripts/tests 39 passed.
This was referenced Sep 26, 2026
minguyen9988
added a commit
to minguyen9988/clickhouse-sink-connector
that referenced
this pull request
Sep 26, 2026
…odes Upstream squash-merged the Domain 12 specification as 7396c3c (Altinity#1507) and then landed Altinity#1508-Altinity#1510; the ten add/add conflicts were the squash artefact (upstream copies byte-identical to the spec commit) and were resolved to the corrected specs and Lean model of this branch. The Java merges were automatic and orthogonal (ResumeReplayLogSummary hooks in DebeziumChangeEventCapture, writer-connection close in ClickHouseBatchRunnable). Both modules compile; the history/DDL/clamp unit suites and the resume-replay and close-connection suites are green; validate_specs.py --lake passes (68 specs, 748 citations). Destructive-Op-Check: sites=0; result=pass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two of the three operating modes had no single specification. Per-table SCD2 history (replication.history.enable=true) was described in fragments across 04.04 s3.2, 02.01 s3.5, 08.05, 06.05, 06.09 and 05.02, and replication-log-only (replication.history.replication_log_only=true) had no spec coverage at all: it existed only as a config doc string, one integration test and two commented lines in the sample configs. This PR adds Domain 12 and the Lean module Replication.History, written from the 2.11.0 code on this branch, and registers both everywhere the validator and the governance documents expect. No src/main change. Every defect found while reading the code is RECORDED as a gap (house style: Gap, not fixed here) with a machine-checked Lean witness where the property is expressible, so the fixes can be reasoned about at the spec level first (Constitution Law 1/2/4).
Files
Gaps recorded, each with its Lean witness
Properties proved for the protocol as shipped: update_supersedes_open_row, delete_hides_open_row, closed_row_continuity, no_open_row_after_delete_marker, at_most_one_live_row_per_sort_key, plus the mode gating and routing theorems log_only_runnable_writes_no_data_rows, log_only_history_still_written, log_only_flag_alone_is_standard_on_runnable, scd2_routes_every_table_to_history_database, standard_mode_writes_no_history.
Verification
Assumptions
Follow-ups (not in this PR)
Fix PRs for G-12.03-1 (flush before the inline UPDATE, mirroring the DELETE branch), G-12.03-2 (a distinct version or key for the before copy), G-12.05-1 (the log_only skip on the single-threaded writer) and D-1..D-3 (unify the two creation paths). Each should first turn the corresponding Lean witness into the corrected property and update 12.x, then change the code.