Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/epoch-confirm-lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ for (const shape of ["one-interior-survivor", "all-missing", "small-zombie"] as
if (shape === "all-missing") {
assert.equal(session.state.blocks.length, 1);
assert.equal(session.state.blocks[0].active, false);
assert.equal(session.metadata.foldEpochConfirmPending === true, false);
// #3641 boundary 4 / MESSAGE-IDENTITY.md epoch-confirm gate: total collapse latches
// like partial coverage — the kernel deactivates the zero-coverage block, but the
// snapshot is retained and folding pauses until realignment or a user-confirmed epoch.
assert.equal(session.metadata.foldEpochConfirmPending === true, pass >= 3);
}
}
assert.equal(session.blockContents.get(blockId)?.full.text, original);
Expand Down
31 changes: 19 additions & 12 deletions tests/issue2915-order-centric-reconcile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ describe("gap resolution tiers (owner rule 2026-10-12: any channel → flanks

describe("escalation latch recovery (review gap ②) — upgrade-in-place heals", () => {
test("3 total-loss passes latch once; a healthy resend clears the latch; post-recovery churn still repairs", () => {
_setStoreForTest(new SessionStore({ enabled: false })); // escalation reaps via markDirty
_setStoreForTest(new SessionStore({ enabled: false }));
const originals = history();
const session = fakeSession(originals.map((m) => m.id as string));
const logs: { level: string; msg: string }[] = [];
Expand All @@ -360,21 +360,28 @@ describe("escalation latch recovery (review gap ②) — upgrade-in-place heals"
assert.equal(logs.filter((l) => l.msg.includes("fold epoch confirmation required")).length, 1,
"#2297: exactly ONE error line per episode");

// healthy resend of the ORIGINAL bytes: missing=0 → noop, and the
// streak reset clears the latch — the upgrade-in-place recovery path.
// healthy resend of the ORIGINAL bytes: nothing missing, no claims —
// a plain resend receipt — and the streak reset clears the latch
// (#4260/#3641: alignment recovery is how the epoch pause ends).
const healthy = reconcileFoldCoverage(session, originals, opts(log));
assert.equal(healthy.kind, "noop");
assert.equal(healthy.kind, "resend");
assert.equal(healthy.missing, 0);
assert.equal(healthy.reaped, 0);
assert.ok(session.metadata.foldDriftEscalated === undefined, "latch cleared on recovery");
assert.ok(session.metadata.foldDriftStreak === undefined, "streak cleared on recovery");

// Escalation reaped the destroyed block (#2695 zombie-carrier reap) —
// so after the latch clears the ledger is a CLEAN SLATE, not a repair
// target: nothing is covered, nothing missing, and the next fold
// cycle starts fresh. That is the upgrade-in-place contract: a
// v0.1.192→v0.1.196 upgrade with a latched ledger heals instead of
// dead-looping the doomed preflight.
assert.equal((session.state.blocks as unknown[]).length, 0, "destroyed substrate reaped at escalation");
// Post-#3641 contract (MESSAGE-IDENTITY.md epoch-confirm gate):
// escalation LATCHES, it does not reap — the snapshot is the
// conversation body and nothing is deleted. Recovery therefore
// restores a LIVE ledger, not a clean slate: the retained block
// re-anchors onto ordinary id churn instead of rebuilding from zero,
// and the lane never dead-loops the doomed preflight.
assert.equal((session.state.blocks as unknown[]).length, 1, "epoch-protected substrate retained at escalation");
const r = reconcileFoldCoverage(session, remint(originals, "g9"), opts(log));
assert.equal(r.kind, "noop", "clean slate — the lane lives, folds rebuild on the next compress cycle");
assert.equal(r.kind, "reanchored", "retained block re-anchors onto re-minted ids");
assert.equal(r.unmatched, 0);
assert.ok(session.metadata.foldDriftEscalated === undefined, "ordinary churn after recovery never re-escalates");
const stable = reconcileFoldCoverage(session, remint(originals, "g9"), opts(log));
assert.equal(stable.kind, "resend", "repeat of the same history is quiet — healed, not looping");
});
});
Loading