MCPcopy Create free account
hub / github.com/WJX20/claude-code / checkResumeConsistency

Function checkResumeConsistency

src/utils/sessionStorage.ts:2225–2244  ·  view source on GitHub ↗
(chain: Message[])

Source from the content-addressed store, hash-verified

2223 * /share or log-listing chain rebuilds.
2224 */
2225export function checkResumeConsistency(chain: Message[]): void {
2226 for (let i = chain.length - 1; i >= 0; i--) {
2227 const m = chain[i]!
2228 if (m.type !== 'system' || m.subtype !== 'turn_duration') continue
2229 const expected = m.messageCount as number | undefined
2230 if (expected === undefined) return
2231 // `i` is the 0-based index of the checkpoint in the reconstructed chain.
2232 // The checkpoint was appended AFTER messageCount messages, so its own
2233 // position should be messageCount (i.e., i === expected).
2234 const actual = i
2235 logEvent('tengu_resume_consistency_delta', {
2236 expected,
2237 actual,
2238 delta: actual - expected,
2239 chain_length: chain.length,
2240 checkpoint_age_entries: chain.length - 1 - i,
2241 })
2242 return
2243 }
2244}
2245
2246/**
2247 * Builds a filie history snapshot chain from the conversation

Callers 1

Calls 1

logEventFunction · 0.85

Tested by

no test coverage detected