(chain: Message[])
| 2382 | * /share or log-listing chain rebuilds. |
| 2383 | */ |
| 2384 | export function checkResumeConsistency(chain: Message[]): void { |
| 2385 | for (let i = chain.length - 1; i >= 0; i--) { |
| 2386 | const m = chain[i]! |
| 2387 | if (m.type !== 'system' || m.subtype !== 'turn_duration') continue |
| 2388 | const expected = m.messageCount |
| 2389 | if (expected === undefined) return |
| 2390 | // `i` is the 0-based index of the checkpoint in the reconstructed chain. |
| 2391 | // The checkpoint was appended AFTER messageCount messages, so its own |
| 2392 | // position should be messageCount (i.e., i === expected). |
| 2393 | const actual = i |
| 2394 | logEvent('ncode_resume_consistency_delta', { |
| 2395 | expected, |
| 2396 | actual, |
| 2397 | delta: actual - expected, |
| 2398 | chain_length: chain.length, |
| 2399 | checkpoint_age_entries: chain.length - 1 - i, |
| 2400 | }) |
| 2401 | return |
| 2402 | } |
| 2403 | } |
| 2404 | |
| 2405 | /** |
| 2406 | * Builds a filie history snapshot chain from the conversation |
no test coverage detected