Skip to content

Implement centralized TSO phase D#1114

Open
bootjp wants to merge 1 commit into
design/dedicated-tso-fsmfrom
design/dedicated-tso-m7
Open

Implement centralized TSO phase D#1114
bootjp wants to merge 1 commit into
design/dedicated-tso-fsmfrom
design/dedicated-tso-m7

Conversation

@bootjp

@bootjp bootjp commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Author: bootjp

Summary

  • persist a one-way Phase D marker and floor after the production cutover marker
  • stop data-group HLC renewal and legacy/shadow timestamp issuance once Phase D is durable
  • validate caller-supplied cross-shard SSI timestamps at the current group-0 leader before allocating a commit timestamp or proposing writes
  • migrate adapter read-modify-write snapshots to dedicated TSO allocations while preserving single-shard and pre-Phase-D compatibility
  • retain the parent branch's same-term allocation fences and RawLatestCommitTS group_id/leader_fenced schema

Safety

  • activation commits cutover, Phase D, and the first post-Phase-D allocation in order
  • validation accepts only timestamps in the durable post-marker allocation interval and fails closed on inactive state, stale leadership, unsupported routing, or out-of-range values
  • leader term is revalidated after floor/marker work and after the allocation-floor commit
  • proto output was regenerated from the combined schema

Tests

  • make gen BREAKING_AGAINST='../.git#subdir=proto,branch=design/dedicated-tso-leader-routing'
  • go test ./kv ./adapter . -run 'TSO|PhaseD|RenewHLC|CrossShard|ValidateTimestamp|RawLatestCommitTS' -count=1
  • go test ./kv -run 'TestRaftTSOAllocator(RejectsTermChange|DropsCommittedWindow|CommitsPhaseD)' -count=1
  • go test ./adapter -run '^Test_consistency_satisfy_write_after_read_sequence$' -count=1 -timeout=10m
  • go test ./adapter -run '^TestRedis_StreamXReadLatencyIsConstant$' -count=1 -timeout=10m
  • golangci-lint run ./... --timeout=5m --allow-parallel-runners

The full parallel go test ./... run completed all packages except two long adapter stress tests after their test HLC ceilings expired under concurrent local load; both tests passed when rerun independently.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 60f01a05-0bf8-48b2-bf29-46e3ce1e05ed

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bootjp

bootjp commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (3a7b865):

  • distribution/catalog.go
  • distribution/catalog_test.go
  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements Phase D (M7) of the Centralized Timestamp Oracle (TSO) design, which closes the legacy compatibility window and retires legacy per-shard HLC issuance. Key changes include adding a ValidateTimestamp RPC to the Distribution service, updating GetTimestamp to support Phase-D activation, and modifying various adapter read-modify-write paths (DynamoDB, Redis, S3, SQS) to allocate and validate read timestamps via BeginReadTimestampThrough. There are no review comments to address, and I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3a7b865474

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kv/tso.go Outdated
Comment thread kv/tso_fsm.go Outdated
Comment thread kv/sharded_coordinator.go Outdated
Comment thread kv/tso.go
@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (c7955d3):

  • distribution/catalog.go
  • distribution/catalog_test.go
  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@bootjp

bootjp commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

Evidence for current HEAD c7955d3947029bf3408de7255400cb65b9eec3a4:

  • Preserves and validates applied read watermarks in Phase D; no fresh unapplied read snapshot is allocated.
  • Emits V3 TSO snapshots before the durable Phase-D marker and V4 afterward.
  • Validates caller-supplied cross-shard StartTS from allocator PhaseDRequired during activation.
  • Invalidates pre-Phase-D batch windows and discards claims that cross activation.
  • Caller audit: all 9 production BeginReadTimestampThrough call sites were traced to store/catalog applied watermarks, including sentinel fail-closed handling; no direct NextTimestamp, NextFenced, or Clock().Next input remains.
  • The centralized TSO design remains Partial until the dependency stack safety findings and latest-head reviews are clear.

Local verification:

  • go test ./kv ./distribution -count=1
  • go test ./adapter -run "Test(S3BeginTxnReadTimestampPhaseD|DistributionServerSplitRange_PhaseD)" -count=1
  • go test -race ./kv -run "Test(BeginReadTimestampThrough|BatchAllocatorDropsPrePhaseDWindowAfterActivation|TSOStateMachineSnapshot|ShardedCoordinatorDispatchTxn_PhaseD|ShardedCoordinatorDispatchTxn_PrePhaseD)" -count=1
  • golangci-lint run ./... --timeout=5m --allow-parallel-runners (0 issues)
  • make tla-check
  • buf generate

The broad go test ./adapter -count=1 run compiled the package but exceeded its 10-minute integration timeout; focused changed-path tests passed and current-head CI is running.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7955d3947

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kv/tso.go Outdated
Comment thread adapter/s3_upload_part.go Outdated
Comment thread kv/tso_raft.go Outdated
@bootjp
bootjp force-pushed the design/dedicated-tso-leader-routing branch from 93b8633 to 295b851 Compare July 19, 2026 12:32
@bootjp
bootjp force-pushed the design/dedicated-tso-m7 branch from c7955d3 to 1fbb3e9 Compare July 19, 2026 13:07
@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (1fbb3e9):

  • distribution/catalog.go
  • distribution/catalog_test.go
  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

bootjp commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

Evidence for current HEAD 1fbb3e94816b131555e7fe8f8d310c0e553b8b67:

  • Rebased onto tso: route durable timestamps through group leader #1108 HEAD 295b85152fdd88a9765e1eafae2e7c142e9397e8 and rebuilt as one PR-visible commit.
  • Phase-D read boundaries force activation by reserving and discarding a post-marker timestamp, but preserve the exact applied store/catalog watermark for reads. Audited pre-floor watermarks use a bounded one-use process-local voucher; unvouched external StartTS values remain fail-closed at group 0.
  • Pre-activation snapshots remain V3; V4 is emitted only after the durable marker. Allocation-floor, cutover, and Phase-D control entries use distinct exact versioned envelopes retaining the old fail-closed prefix.
  • S3 UploadPart performs its final metadata check at the latest applied watermark and includes uploadMetaKey in ReadKeys, closing abort/complete races.
  • Routed local timestamp validation retries and re-resolves transient leadership loss within the configured budget.
  • Caller audit covered every production BeginReadTimestampThrough site, direct NextTimestamp/NextFenced/Clock.Next issuance, voucher forwarding through coordinator decorators, all floor/cutover/Phase-D encoders, and the S3 upload metadata read set.
  • PR-visible author and committer are bootjp <contact@bootjp.me>; GitHub signature verification is verified: true. Final tree: 40aadeb91c21d7cc97a528c2f81c7da55b2af0e1.
  • The design remains Partial until the runtime-operations PR and dependency-stack latest-head reviews are clear.

Validation:

  • go test ./kv ./distribution -count=1 -timeout=10m
  • go test . -count=1 -timeout=10m
  • focused S3/Distribution adapter tests
  • compile-only go test ./... -run '^$' -count=1
  • focused race tests for Phase-D activation, vouchers, routed validation, snapshots, S3, and decorated coordinators
  • golangci-lint run ./... --timeout=5m --allow-parallel-runners (0 issues)
  • make gen (no generated diff)
  • make tla-check (all safe models pass; every gap model fails only at its expected invariant)
  • git diff --check

All three current review threads were replied to and resolved. Requesting a fresh latest-head review.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 1fbb3e9481

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@bootjp
bootjp force-pushed the design/dedicated-tso-leader-routing branch from 295b851 to 9182f37 Compare July 19, 2026 13:59
@bootjp
bootjp force-pushed the design/dedicated-tso-m7 branch from 1fbb3e9 to c801865 Compare July 19, 2026 14:04
@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (c801865):

  • distribution/catalog.go
  • distribution/catalog_test.go
  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

bootjp commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

Evidence for rebased current HEAD c8018656811d1a9511f0495b4c14a85678452bce:

  • Parent is the verified tso: route durable timestamps through group leader #1108 startup-gate fix 9182f378f75401617f38cfae9d80b92305c10c1b; this PR remains one verified bootjp contact@bootjp.me commit.
  • Phase-D read activation still reserves and discards the first post-marker timestamp while preserving the exact applied store/catalog watermark, with bounded one-use vouchers for audited pre-floor applied reads.
  • V3 snapshots remain compatible before Phase D and V4 is emitted only after the one-way marker. Cached pre-D windows are invalidated across activation.
  • S3 UploadPart uses a fresh final watermark and includes upload metadata in the read set. Local validation leadership loss uses bounded re-resolution.
  • The inherited startup-gate fix ensures follower-forwarded raw writes are stamped by group 0 rather than a data-group HLC.
  • Semantic caller audit covered all production begin-read paths, direct timestamp helpers, startup coordinator decorators, Internal.Forward, and TSO validation/routing call sites.

Current-head local verification:

  • focused root/kv tests for startup-gate wiring, Phase-D begin-read activation/vouchers, batch invalidation, routed validation, and follower deferral
  • focused race tests for the same shared paths
  • no conflict markers or diff-check errors
  • the previous HEAD passed full required CI and received a no-major review; fresh CI and review are required for this rebased HEAD

@codex review

Base automatically changed from design/dedicated-tso-leader-routing to design/dedicated-tso-fsm July 19, 2026 14:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c801865681

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread adapter/sqs_reaper.go
Comment thread adapter/sqs_messages.go
Comment thread adapter/redis_delta_compactor.go
Comment thread adapter/redis_txn.go
@bootjp
bootjp force-pushed the design/dedicated-tso-m7 branch from c801865 to 07460ec Compare July 19, 2026 15:28
@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (07460ec):

  • distribution/catalog.go
  • distribution/catalog_test.go
  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@bootjp

bootjp commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

Evidence for current HEAD 07460ec:\n\n- Rebased onto current dependency tip aa94f4e and rebuilt as one PR-visible commit.\n- Author and committer are bootjp contact@bootjp.me; the local GPG signature is good.\n- Applied pre-Phase-D read watermarks now carry a private timestamp-bound capability. Every reused OCC dispatch reserves exactly one one-use coordinator voucher immediately before dispatch; another timestamp is rejected and a current binding shadows any parent capability.\n- SQS live/tombstone reaping covers record, orphan-index, and dedup dispatches. Receive covers expiry, rotation, and DLQ redrive. Redis urgent/background compaction covers every collection and TTL-inline batch. EXEC retry state retains and re-vouches the exact first-attempt snapshot.\n- The design records per-dispatch voucher semantics and keeps arbitrary unvouched caller timestamps fail-closed at group 0.\n- Caller audit enumerated every production BeginReadTimestampThrough/beginTxnReadTimestamp caller and every NextTimestampThrough, NextTimestampAfterThrough, and TimestampAllocatorThrough caller. Other fanout paths either use one StartTS-bearing dispatch per snapshot or nontransactional batches; no additional shared applied-snapshot dispatch was found.\n- All four current review roots were replied to and resolved.\n- The centralized TSO design remains Partial in this dependency PR; implemented promotion stays in the runtime-operations PR only after the dependency stack is clear.\n\nValidation:\n- focused kv Phase-D/voucher tests: pass\n- focused adapter SQS/Redis compactor/EXEC tests: pass\n- focused kv and adapter race tests: pass\n- go test ./... -run ^$ -count=1: pass\n- golangci-lint run ./... --timeout=5m --allow-parallel-runners: 0 issues\n- make gen: pass, no generated diff\n- make tla-check: all safe models pass and every gap model fails only at its expected invariant\n- git diff --check: pass\n- Full local package reruns were additionally attempted; concurrent worktree tests exhausted the host filesystem and prolonged the existing Test_grpc_transaction HLC fixture. Changed-path tests remain green and current-head CI is the authoritative broad run.\n\n@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07460ec650

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread adapter/s3.go
Comment on lines +2447 to +2451
if readTS == ^uint64(0) {
if alloc, ok := kv.TimestampAllocatorThrough(s.coordinator); ok {
if phaseD, phaseDOK := alloc.(kv.TSOPhaseDState); phaseDOK && (phaseD.PhaseDRequired() || phaseD.PhaseDActive()) {
readTimestamp, err := kv.BeginReadTimestampThrough(ctx, s.coordinator, readTS, label)
return readTimestamp, errors.WithStack(err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Normalize empty S3 snapshots before Phase-D validation

When the S3 MVCC store has no commits, s.readTS() returns ^uint64(0) via snapshotTS, and S3 mutations such as createBucket now pass that value into this helper. In Phase-D mode this branch sends the sentinel to BeginReadTimestampThrough, which rejects ^uint64(0) with ErrTSOTimestampInvalid, so a fresh/empty S3 namespace cannot create its first bucket after Phase D is enabled. Normalize the empty-store sentinel to a concrete safe read/start timestamp (the other adapters use 1) before validation instead of failing the mutation.

Useful? React with 👍 / 👎.

Comment thread kv/sharded_coordinator.go
if !callerSupplied {
return nil
}
if c.consumeAppliedReadTimestampVoucher(startTS) || singleShard {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bind vouchers to the dispatch capability

Under Phase D, this accepts a pre-floor StartTS by consuming a process-wide counter keyed only by timestamp. When two requests read the same applied watermark (common while LastCommitTS is pinned at the Phase-D floor), an unbound direct Dispatch with that StartTS can consume the voucher registered by another ReadTimestamp and bypass group-0 validation, or make the legitimate dispatch fail/retry. The voucher should be tied to the ReadTimestamp/ctx capability, not just the numeric timestamp.

Useful? React with 👍 / 👎.

}

func (r *RedisServer) xaddReadTimestamp(ctx context.Context, key []byte) (uint64, error) {
readTS, err := r.beginTxnStartTS(ctx, "redis xadd: begin read timestamp")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve XADD vouchers for dedup retries

In Phase D, beginTxnStartTS can reserve the only voucher that admits an applied pre-floor watermark, but this path collapses it to a uint64. The first XADD dispatch consumes that voucher; if it returns a retryable/ambiguous error, reusableXAdd keeps only startTS and dispatchXAddReuse calls plain Dispatch, so stream writes whose meta/entry keys span shards fail on the retry with ErrTSOTimestampPrePhaseD instead of probing PrevCommitTS. Keep the ReadTimestamp and bind/re-vouch the reuse dispatch.

Useful? React with 👍 / 👎.

if err != nil {
return nil, nil, errors.WithStack(err)
}
readTS := readTimestamp.Timestamp()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep item-write vouchers for reuse attempts

In Phase D, this ReadTimestamp may contain the only voucher for a pre-floor applied watermark, but the dedup path immediately reduces it to readTS and stores only that number in reusableItemWrite. After the first cross-shard item/GSI dispatch consumes the voucher, itemWriteReuseAttempt reuses the same StartTS with plain Dispatch and fails group-0 validation instead of probing PrevCommitTS, so retryable item writes can stop at ErrTSOTimestampPrePhaseD. Retain the ReadTimestamp and re-bind it for reuse dispatches.

Useful? React with 👍 / 👎.

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