MCPcopy
hub / github.com/codeaashu/claude-code / checkResumeConsistency

Function checkResumeConsistency

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

logEventFunction · 0.85

Tested by

no test coverage detected