Skip to content
Open
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
18 changes: 17 additions & 1 deletion src/conflict-watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,17 @@ export function formatConflictSection(events: ConflictEvent[], now: number = Dat
// landing was fully rebased onto (#2372/#2432) — handled, no ongoing risk. Gated to the
// pure case so mixed ledgers keep their existing tier verbatim.
const handledNativeOnly = meaningful.length > 0 && meaningful.every((e) => e.kind === "native-compaction");
// #5786: a ledger whose every meaningful event is a cross-build id re-mint that
// fold-reconcile fully RE-ANCHORED (#4131/#3642) is bili's own recovery — no second
// compressor, no compaction boundary, no data loss. Gated to the pure case so mixed
// ledgers keep their existing tier verbatim (same discipline as #2912/#2802-review).
const churnAdoptOnly = meaningful.length > 0 && meaningful.every((e) => e.kind === "id-churn-adoption");
const activeConfirmed = confirmed.some((e) => now - e.at <= CONFLICT_ACTIVE_WINDOW_MS);
lines.push(`COMPRESSION CONFLICTS — ${events.length} event(s) in this session (${active.length} active · ${historical.length} historical; active = within ${CONFLICT_ACTIVE_WINDOW_MS / 86_400_000} days). ${foreignConfirmed || nativePresent
? "Two compressors on one conversation (bili + another compression plugin — third-party or bili's own sibling — or client native compaction) double-compress and corrupt message refs:"
: "Diagnostic evidence that something outside bili touched this conversation — how strong that evidence is is tiered below:"}`);
: churnAdoptOnly
? "Recorded evidence that bili itself re-minted message ids across builds and fully re-anchored them (no second compressor, no data loss):"
: "Diagnostic evidence that something outside bili touched this conversation — how strong that evidence is is tiered below:"}`);
for (const e of events.slice(-10)) {
lines.push(` [${fmtTime(e.at)}] ${e.kind} — ${e.detail}`);
}
Expand Down Expand Up @@ -247,6 +254,15 @@ export function formatConflictSection(events: ConflictEvent[], now: number = Dat
advice = active.length > 0
? "The events above are client-native compaction landings bili ALREADY rebased onto (#2372/#2432): each detected checkpoint rebuilt the fold base, so there is no ongoing double-compression risk and nothing to disable. If you did not expect these sessions to auto-compact, review the client's own auto-compaction setting; otherwise clear this ledger — Web UI conflict banner / session page, or POST /__bili/conflicts/clear?session=<id>."
: "All events above are client-native compaction landings older than 7 days (historical stock) that bili already rebased onto (#2372/#2432): handled at the time, no ongoing risk. Clear this ledger — Web UI conflict banner / session page, or POST /__bili/conflicts/clear?session=<id>.";
} else if (churnAdoptOnly) {
// #5786: bili's own cross-build id re-mint, fully adopted by fold-reconcile (every
// covered id re-anchored, 0 unmatched) with NO compaction boundary marked — the fold
// state survived intact. Not a second compressor and not auto-compaction: nothing to
// hunt for or disable. Say so plainly instead of routing the user into the
// [suspected]-plugin verify-first errand below.
advice = active.length > 0
? "The events above are cross-build id re-mints that bili itself adopted (#4131/#3642): fold-reconcile re-anchored every covered id (0 unmatched) and marked NO compaction boundary, so the fold state survived intact. There is NO second compressor and NO auto-compaction to disable — nothing to act on. Clear this ledger if you want it gone — Web UI conflict banner / session page, or POST /__bili/conflicts/clear?session=<id>."
: "All events above are cross-build id re-mints older than 7 days (historical stock) that bili already adopted (#4131/#3642): the fold state was re-anchored intact at the time, no ongoing risk. Clear this ledger — Web UI conflict banner / session page, or POST /__bili/conflicts/clear?session=<id>.";
} else if (orphanOnly) {
// A headerless replay does not prove that the original client moved.
// Older ledgers may contain tail-only matches; neither proves state loss.
Expand Down
8 changes: 6 additions & 2 deletions src/web/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ export const WEB_CLIENT = `(function () {
// as an unexplained rewrite (warned-on-impact policy, #2912).
const confirmedNativeN = kinds["native-compaction-inferred"] || 0;
const handledNativeN = kinds["native-compaction"] || 0;
const signalN = Math.max(0, c.events - pluginN - confirmedNativeN - handledNativeN);
// #5786: cross-build id re-mint that fold-reconcile fully RE-ANCHORED (#4131/#3642) —
// bili's own recovery, no compaction boundary marked. Recovered stock like
// handledNativeN: not a landed-unrecovered signal, so it must not light the alarm.
const churnAdoptN = kinds["id-churn-adoption"] || 0;
const signalN = Math.max(0, c.events - pluginN - confirmedNativeN - handledNativeN - churnAdoptN);
const whatParts = [];
if (confirmedTpN > 0) whatParts.push(t("conflict.what_plugin"));
if (suspectedN > 0) whatParts.push(t("conflict.what_suspected"));
Expand Down Expand Up @@ -320,7 +324,7 @@ export const WEB_CLIENT = `(function () {
// #2430/#2545: a ledger naming ONLY bili's own siblings or verified read-only viewers
// stands down completely — compatible family / non-compressors, not conflicts.
const siblingOnly = !hasConfirmed && suspectedN === 0 && signalN === 0 && siblingN > 0;
const neutralOnly = !hasConfirmed && suspectedN === 0 && signalN === 0 && (siblingN + displayOnlyN + handledNativeN) > 0; // #2912: fully-handled (recovered-native-only) ledger also stands down
const neutralOnly = !hasConfirmed && suspectedN === 0 && signalN === 0 && (siblingN + displayOnlyN + handledNativeN + churnAdoptN) > 0; // #2912/#5786: fully-handled (recovered-native / adopted-id-churn-only) ledger also stands down
// #3235 owner rule: the banner is an ALARM for interception FAILURE — evidence a
// history rewrite actually LANDED unrecovered (confirmed third-party / inferred
// native landing / unexplained rewrite signal). Co-residence alone (suspected
Expand Down
27 changes: 27 additions & 0 deletions tests/conflict-lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,30 @@ test("formatConflictSection: header age split + advice switches with liveness (#
assert.ok(susText.includes("Every event above is [suspected]"));
assert.ok(!susText.includes("Keep exactly ONE compressor"));
});

test("formatConflictSection: pure id-churn-adoption is bili's own recovery — no plugin hunt, no imperative (#5786/#4131)", () => {
const now = Date.now();
// The reporter's ledger from #5786: a single active, fully-re-anchored adoption.
const adopt: ConflictEvent[] = [
{ at: now - 60000, kind: "id-churn-adoption", detail: "980/2967 incoming message(s) carry pre-turn refs of 2960 known; fold-reconcile re-anchored every covered id (0 unmatched)" },
];
const text = formatConflictSection(adopt, now).join("\n");
assert.ok(text.includes("bili itself re-minted message ids across builds"), text);
assert.ok(!text.includes("something outside bili touched this conversation"), "not framed as external interference");
assert.ok(text.includes("cross-build id re-mints that bili itself adopted"), text);
assert.ok(text.includes("nothing to act on"), "a recovered adoption demands no corrective action");
assert.ok(!text.includes("Every event above is [suspected]"), "no verify-first plugin errand");
assert.ok(!text.includes("Keep exactly ONE compressor"), "no imperative without confirmed evidence");
assert.ok(!text.includes("disable the client's own auto-compaction"), "no per-client auto-compaction command for a self-recovery");
});

test("formatConflictSection: mixed id-churn-adoption + rewrite keeps the unconfirmed-signal tier verbatim (#5786)", () => {
const now = Date.now();
const mixed: ConflictEvent[] = [
{ at: now - 60000, kind: "id-churn-adoption", detail: "adopted churn" },
{ at: now - 30000, kind: "unannounced-rewrite", detail: "fresh rewrite" },
];
const text = formatConflictSection(mixed, now).join("\n");
assert.ok(text.includes("UNCONFIRMED signal"), "the genuine rewrite still drives the unconfirmed tier");
assert.ok(!text.includes("cross-build id re-mints that bili itself adopted"), "pure-case framing must not leak into a mixed ledger");
});
18 changes: 18 additions & 0 deletions tests/web-conflict-banner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,24 @@ test("#3235 landed tier: recovered-only ledger stays quiet; a rewrite signal alo
assert.strictEqual(rewrite.landed, true, "an observed history rewrite is a landed event by definition");
});

test("#5786 recovered cross-build id re-mint (id-churn-adoption) stays quiet — not a landed signal (#4131/#3642)", () => {
const sev = bannerSeverity();
// The reporter's exact ledger shape from #5786: one active id-churn-adoption event.
const r = sev({ events: 1, kinds: { "id-churn-adoption": 1 }, active: 1 });
assert.strictEqual(r.hasConfirmed, false);
assert.strictEqual(r.signalN, 0, "a fully-re-anchored adoption is not an unexplained rewrite");
assert.strictEqual(r.landed, false, "recovered id churn must not light the alarm banner");
assert.strictEqual(r.neutralOnly, true, "adopted-id-churn-only ledger stands down like recovered native-compaction");
});

test("#5786 mixed ledger: a genuine rewrite still alarms; adopted id-churn adds no false weight", () => {
const sev = bannerSeverity();
const mixed = sev({ events: 2, kinds: { "id-churn-adoption": 1, "unannounced-rewrite": 1 }, active: 2 });
assert.strictEqual(mixed.signalN, 1, "only the rewrite counts as a signal, not the adopted churn");
assert.strictEqual(mixed.onKey, "conflict.on_unconfirmed", "the genuine rewrite drives the unconfirmed tier");
assert.strictEqual(mixed.landed, true, "an observed history rewrite is a landed event by definition");
});

test("#3235 banner gate + dismiss + report buttons wired in the client source", () => {
assert.ok(WEB_CLIENT.includes("sev0.landed && !dismissed"), "gate requires landed-unrecovered evidence and no live dismissal");
assert.ok(WEB_CLIENT.includes('id="conflicts-dismiss-btn"'), "dismiss button rendered on the banner");
Expand Down
Loading