QKeyDB chain history tracks the wrong frame as the last anchor
chainHistory.lastAnchorSeq reflects a commit frame's sequence instead of the actual last anchor frame's sequence
UnitedQkeyEngine's hydrateChainHistoryFromLedger read chainHistory.lastAnchorSeq from metrics.latestHeader.anchorseq, which reflects the most recent frame of ANY type (commit, header, or anchor) - not necessarily an anchor frame. When an anchor was emitted before a later commit frame, lastAnchorSeq incorrectly jumped to the commit's sequence number, breaking anchor emission interval calculations that depend on knowing when the last real anchor actually happened.
Root Cause
metrics.latestHeader tracks the single most recent frame regardless of type. Anchor-interval logic needs the most recent ANCHOR specifically, which requires a separate metrics.lastAnchor field rather than reusing the generic latestHeader.
Solution Steps
- In hydrateChainHistoryFromLedger, change the assignment to prefer metrics.lastAnchor?.anchorseq, falling back to metrics.latestHeader?.anchor_seq only if no dedicated anchor metric exists, then to 0.
- Run the dedicated anchor-emission smoke test in isolation.
Validation
[object Object]
Rollback
[object Object]
Ecosystem: qkeydb
License: CC-BY-4.0
Last updated: Jul 6, 2026