pingqiuandClaude Opus 4.7 dea8481bb6 BlockStore: gate walHead update on lsn > walHead (round-43 substrate hardening, defense-in-depth)
Pre-T4d-1 hotfix per architect-ratified kickoff sequencing
(round-44 governance call): substrate-level guard lands ahead of
the larger T4d-2 replica recovery apply gate work. Closes a
production storage-contract violation independent of the larger
T4d batch.

Bug (round-41 architect-identified, round-43 demo-confirmed):

  core/storage/store.go:264 set s.walHead = lsn unconditionally.
  Older-LSN ApplyEntry regressed walHead, violating
  LogicalStorage contract §3 rule 3 ("stable frontier never goes
  backward").

  Empirically demonstrated live at round-43:
    ApplyEntry(LSN=10) → walHead=10
    ApplyEntry(LSN=5)  → walHead=5  ← REGRESSION

Fix:

  if lsn > s.walHead {
      s.walHead = lsn
  }

Same monotonic-update pattern as walstore.ApplyEntry:544 and
smartwal.ApplyEntry:358 already use. Brings BlockStore in line.

Architectural placement (round-43 sign):

  Replica recovery apply gate (T4d-2 primary fix) is the primary
  correctness boundary; this guard is defense-in-depth for paths
  that may bypass the gate (live duplicate, retry, future
  cross-substrate scenarios). Inline godoc comment names the
  T4d-2 gate as the primary boundary so the role is clear.

Test (un-skipped from round-41/43 adversarial set):

  TestComponent_BlockStore_ApplyEntry_OldLSN_DoesNotRegressWalHead
  (renamed from TestComponent_Adversarial_BlockStoreApplyEntry
  RegressesWalHead — the bug name no longer applies).

  Pre-fix: t.Skip + T4d TODO. Post-fix: passes; pins the
  monotonic guard against regression.

Zero semantic change to any code that worked before. T4d-1 / T4d-2
will not conflict with this hotfix — different files, different
layers.

go test ./... -count=1 → 22 packages green (regression test
passes; no other test affected).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 15:52:39 -07:00
Languages
Go 84.5%
Rust 7.9%
Shell 2.7%
templ 1.6%
Java 1%
Other 2%