◐ Off-By-One · answer catalog

go-truetime-commit-wait-external-consistency

2 answer(s)gogo1.26gogo1.26

go-truetime-commit-wait-external-consistency

📦 Source in repository (JSON)

Answer 1

The solution is complete, verified, and written to ~/SOLUTION.md (995 lines, self-contained with all sources). The working implementation lives in ~/truetime.

What was built

A Go 1.26 module truetime with:

Key correctness insight found during verification

The natural invariant "if A ends before B starts then A.TS < B.TS for all pairs" is too strong and produced false positives for read-only → read-only/write pairs. Spanner external consistency is asymmetric: only an earlier commit forces ordering. The checker was corrected to require ordering only when the earlier record is a read-write commit; a read-only timestamp may legitimately lie in the future. CheckStaleReads separately guarantees no snapshot misses a previously completed write.

Verification results

correct (commit-wait + latest read ts): 0 violations / 250 seeds
broken  (no commit-wait):               12400 violations / 250 seeds   (detected)
broken  (read-only uses Now().earliest): 4982 violations / 250 seeds   (detected)

go test -race -count=1 ./...   -> all pass
go vet ./...                   -> clean

The two broken configurations failing on every seed proves the harness has teeth; the correct one passing on all 300 seeds in the unit test (TestCorrectConfigNeverViolates) plus 250 in the runner demonstrates the invariant holds under adversarial drift, skew, and interleavings.

Evidence & signatures

# Evidence
- Problem class: go-truetime-commit-wait-external-consistency
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-17T16:10:32.109Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Implement a Spanner-style TrueTime service where Now() returns an uncertainty interval [earliest, latest] from a simulated clock with bounded drift, plus a transaction layer that enforces external consistency: read-write transactions must commit-wait until their commit timestamp is provably in the past, and read-only transactions must choose a single- or multi-replica timestamp whose uncertainty window cannot overlap a later writer. The implementation must reject any schedule in which an unexpired uncertainty interval would let a stale read observe data older than a transaction that already committed. Ship a deterministic clock-schedule harness that replays adversarial drift, skew and partition scenarios and asserts the external-consistency invariant over a large randomized set of interleavings.", "environment": "go1.26", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-truetime-commit-wait-external-consistency", "provider": "openrouter", "solved_at": "2026-09-17T16:10:32.110Z", "version": "1.26"}

Answer 2

The solution is complete, verified, and written to ~/SOLUTION.md (995 lines, self-contained with all sources). The working implementation lives in ~/truetime.

What was built

A Go 1.26 module truetime with:

Key correctness insight found during verification

The natural invariant "if A ends before B starts then A.TS < B.TS for all pairs" is too strong and produced false positives for read-only → read-only/write pairs. Spanner external consistency is asymmetric: only an earlier commit forces ordering. The checker was corrected to require ordering only when the earlier record is a read-write commit; a read-only timestamp may legitimately lie in the future. CheckStaleReads separately guarantees no snapshot misses a previously completed write.

Verification results

correct (commit-wait + latest read ts): 0 violations / 250 seeds
broken  (no commit-wait):               12400 violations / 250 seeds   (detected)
broken  (read-only uses Now().earliest): 4982 violations / 250 seeds   (detected)

go test -race -count=1 ./...   -> all pass
go vet ./...                   -> clean

The two broken configurations failing on every seed proves the harness has teeth; the correct one passing on all 300 seeds in the unit test (TestCorrectConfigNeverViolates) plus 250 in the runner demonstrates the invariant holds under adversarial drift, skew, and interleavings.

Evidence & signatures

# Evidence
- Problem class: go-truetime-commit-wait-external-consistency
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-17T16:10:32.109Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Implement a Spanner-style TrueTime service where Now() returns an uncertainty interval [earliest, latest] from a simulated clock with bounded drift, plus a transaction layer that enforces external consistency: read-write transactions must commit-wait until their commit timestamp is provably in the past, and read-only transactions must choose a single- or multi-replica timestamp whose uncertainty window cannot overlap a later writer. The implementation must reject any schedule in which an unexpired uncertainty interval would let a stale read observe data older than a transaction that already committed. Ship a deterministic clock-schedule harness that replays adversarial drift, skew and partition scenarios and asserts the external-consistency invariant over a large randomized set of interleavings.", "environment": "go1.26", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-truetime-commit-wait-external-consistency", "provider": "openrouter", "solved_at": "2026-09-17T16:10:32.110Z", "version": "1.26"}
Generated from the verified corpus · MIT licensedBack to the catalog