You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tla: reconcile the models with the implementation on main - #1348
Several passing TLC configs verified behaviour that the code on main does not have. For example, HLC.tla modelled the strategy (c) election-time Observe(maxAppliedHLC), which was never implemented. This PR changes each module to match the code. Where the code falls short of an invariant, the gap is now pinned by an expected-failure config, so a fix shows up as "unexpectedly passed" and forces the model to follow.
Module
Change
New configs
HLC
IssueTimestamp = NextFenced (no fence while the ceiling is 0; overflow past the ceiling is rejected). The election-time Observe is gone. IssuanceMode selects one of three allocators: TSO (allocation-floor handoff, strategy (a)), legacy Coordinate, or legacy ShardedCoordinator (any node stamps).
Watermark start (MaxUint64 on an empty store) for reading txns, fresh start for write-only ones. One-phase Allocate/Apply with the per-group commit-ts fence, a lock check, and read + write validation. 2PC with commit_ts settled before PREPARE and an unfenced COMMIT that does not revalidate. Raw writes. MultiGroup mode gives each key its own group, with the snapshot taken as the max over groups. New invariants: OCC8_NoWriteSkew and OCC3b_EmptyStoreReadStability.
Resumable compaction (pending watermark, per-key prune, finish) that keeps every version > minTS plus the newest <= minTS. Colliding timestamps overwrite on the raw apply path (MVCC5_AckedWriteNotOverwritten).
MCMVCC_collision_gap (MVCC-5, G10)
Composed
Pinned and unpinned txns, plus AutoPin (Dispatch-time pin). Composed-1 is asserted for pinned txns only. Composed-2 is documented as not modelled, since cross-group migration has shipped.
—
Routes
Comments now describe the watcher's bounded delta batches.
—
scripts/tla-check.sh gains pass_configs_for for extra expected-PASS configs. tla/README.md and the design doc are updated. The path filters and the ANCHORS regex of both TLA workflows are synced, and they also cover kv/tso*.go, kv/fsm_migration_serving.go, store/lsm_store.go and adapter/ts.go.
Behavior change: none in Go code. CI's tla-check now runs 24 TLC configs. Risk: model-only.
Test evidence
make tla-check → tla-check: all model-check outcomes match the design contract.
I read the counterexample traces of the G0, G1 and multi-group gap configs; they match the audit's mechanisms.
I re-confirmed G0 across groups on main with a throwaway FSM/store-level probe that is not committed. It uses two pebble-backed groups. A read at s = ShardStore.LastCommitTS() returns "old" and then "new" after a one-phase write at c1 < s applies on the lagging group. A one-phase commit with that key in ReadKeys then overwrites the write it never saw. The same schedule inside one group gets a write conflict.
Self-review
Data loss: no Go changes. The models now expose the overwrite on timestamp collision and the cross-group lost update, both pinned as gaps.
Concurrency: the models reorder one-phase apply and 2PC PREPARE/COMMIT, and check the leader-change handoff per issuance mode.
Performance: no runtime change. TLC runs stay small (the largest is about 150k states).
Data consistency: the invariants match what the code enforces, and known violations are pinned rather than hidden.
Test coverage: every new guard has both a passing config and an expected-failure config.
The change is documentation and verification only, so production behavior is unaffected. Two models do not yet track the implementation exactly, and some implementation files can change without triggering the TLA+ check or its review workflow. Fix these before relying on the models as a safety guarantee.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
タイトルは、TLA+モデルを実装に整合させるという変更の主目的を正確かつ簡潔に示しています。
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 1 files. (24 skipped: 24 unsupported.)
Finishing Touches
📝 Generate docstrings
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
The passing configs verified behaviour the code does not have. Make
each module describe main, and pin the known implementation gaps with
expected-failure configs so that a fix shows up as "unexpectedly
passed" and forces the model to follow.
- hlc: IssueTimestamp is NextFenced (no fence before the first
ceiling, overflow past the ceiling rejected). Drop the strategy (c)
election-time Observe, which was never implemented; model the TSO
allocation-floor handoff (strategy (a)) and the two legacy modes.
New configs: legacy_single (HLC-4) and legacy_sharded (HLC-3, G10).
- occ: watermark start_ts, read-set validation, one-phase
Allocate/Apply with the commit-ts fence, 2PC with commit_ts settled
before PREPARE and an unfenced COMMIT, raw writes, OCC-8 (no write
skew). New configs: onephase (pass), g0 (OCC-3), g1 (OCC-8).
- mvcc: resumable compaction keeping > minTS plus the newest <= minTS;
colliding timestamps overwrite on the raw path (MVCC-5, G10).
- composed: pinned / unpinned transactions; Composed-2 documented as
not modelled now that cross-group migration has shipped.
- routes: comments describe the watcher's bounded delta batches.
- scripts/tla-check.sh: extra expected-PASS configs (pass_configs_for).
- docs: design doc section 12 records the reconciliation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fm5modb5r8UZ544jvPnHis
Signed-off-by: bootjp <noreply@anthropic.com>
- composed: add AutoPin, the Dispatch-time pin
(maybeAutoPinObservedRouteVersion) at the then-current catalog
version; unpinned stays ObservedRouteVersion = 0.
- occ: an empty-store start is MaxUint64 (snapshotTS), modelled as
MaxTs. Such a txn reads the latest version, so OCC-3 is split: OCC-3
for watermark starts, OCC-3b for empty-store starts, pinned by
MCOCC_emptystore_gap.cfg.
- workflows: sync tla-spec-ai-review.yml paths / ANCHORS with
tla-check.yml, add kv/fsm_migration_serving.go to both, and drop the
strategy (c) wording from the AI review checklist.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fm5modb5r8UZ544jvPnHis
Signed-off-by: bootjp <noreply@anthropic.com>
The one-phase commit-ts fence compares commit_ts with the applying
group's own LastCommitTS, while adapter snapshots take the maximum over
groups (ShardStore.LastCommitTS). A one-phase write allocated earlier
and applied later on a lagging group therefore lands below a reader's
snapshot after the read (the audit's "Multi-group deployments" G0).
OCC.tla gains MultiGroup (one group per key, per-group watermark,
snapshot = max over groups, one-phase only for single-group txns).
MCOCC_multigroup_gap.cfg pins the OCC-3 violation; the other configs
keep one group. The doc's "unchecked" note becomes the confirmed gap.
Re-confirmed on main at the FSM / store level with two pebble-backed
groups: the read at s returns "old" then "new", and a one-phase commit
with the key in ReadKeys overwrites the write it never saw; the same
schedule inside one group is rejected by the fence.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fm5modb5r8UZ544jvPnHis
Signed-off-by: bootjp <noreply@anthropic.com>
- RawWrite is refused while a txn lock sits on the key
(validateRawMutationForApply → assertNoConflictingTxnLock).
- Prepare raises the touched groups' watermarks to start_ts: the lock
rows apply through ApplyMutationsRaftAt(startTS, startTS), which
advances LastCommitTS.
- Allocation requires commit_ts > start_ts under EnableSafety, as the
coordinator's resolveTxnCommitTS does before any proposal.
Every config keeps its expected outcome; the G0 and G1 traces still
show the audit's mechanisms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fm5modb5r8UZ544jvPnHis
Signed-off-by: bootjp <noreply@anthropic.com>
Split Abort into CancelTxn (nothing persisted), AbortPrepared (the
coordinator's rollback at a fresh timestamp, abortTimestamp) and
ResolverAbort (the lock resolver's rollback at abortTSFrom(start, 0) =
start + 1). Both rollbacks apply through ApplyMutationsRaftAt at the
abort timestamp (handleAbortRequest), which raises LastCommitTS, so a
pending one-phase entry at or below it is now fenced as in the code.
Every config keeps its expected outcome.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fm5modb5r8UZ544jvPnHis
Signed-off-by: bootjp <noreply@anthropic.com>
A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
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
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.
Design: docs/design/2026_05_28_implemented_tla_safety_spec.md (§12 added)
Summary
Several passing TLC configs verified behaviour that the code on
maindoes not have. For example, HLC.tla modelled the strategy (c) election-timeObserve(maxAppliedHLC), which was never implemented. This PR changes each module to match the code. Where the code falls short of an invariant, the gap is now pinned by an expected-failure config, so a fix shows up as "unexpectedly passed" and forces the model to follow.IssueTimestamp=NextFenced(no fence while the ceiling is 0; overflow past the ceiling is rejected). The election-time Observe is gone.IssuanceModeselects one of three allocators: TSO (allocation-floor handoff, strategy (a)), legacyCoordinate, or legacyShardedCoordinator(any node stamps).MCHLC_legacy_single_gap(HLC-4),MCHLC_legacy_sharded_gap(HLC-3, G10)MultiGroupmode gives each key its own group, with the snapshot taken as the max over groups. New invariants:OCC8_NoWriteSkewandOCC3b_EmptyStoreReadStability.MCOCC_onephase(pass),MCOCC_g0_gap(OCC-3, G0),MCOCC_g1_gap(OCC-8, G1),MCOCC_emptystore_gap(OCC-3b),MCOCC_multigroup_gap(OCC-3, G0 across groups)> minTSplus the newest<= minTS. Colliding timestamps overwrite on the raw apply path (MVCC5_AckedWriteNotOverwritten).MCMVCC_collision_gap(MVCC-5, G10)AutoPin(Dispatch-time pin). Composed-1 is asserted for pinned txns only. Composed-2 is documented as not modelled, since cross-group migration has shipped.scripts/tla-check.shgainspass_configs_forfor extra expected-PASS configs.tla/README.mdand the design doc are updated. The path filters and theANCHORSregex of both TLA workflows are synced, and they also coverkv/tso*.go,kv/fsm_migration_serving.go,store/lsm_store.goandadapter/ts.go.Behavior change: none in Go code. CI's
tla-checknow runs 24 TLC configs.Risk: model-only.
Test evidence
make tla-check→tla-check: all model-check outcomes match the design contract.mainwith a throwaway FSM/store-level probe that is not committed. It uses two pebble-backed groups. A read ats = ShardStore.LastCommitTS()returns "old" and then "new" after a one-phase write atc1 < sapplies on the lagging group. A one-phase commit with that key inReadKeysthen overwrites the write it never saw. The same schedule inside one group gets a write conflict.Self-review
🤖 Generated with Claude Code
https://claude.ai/code/session_01Fm5modb5r8UZ544jvPnHis