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
21 changes: 21 additions & 0 deletions src/acp-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,27 @@ export function handleAcpStatus(args: Record<string, unknown>, ctx: AcpStatusCtx
extra.push("");
extra.push(`DEAD REFS — ${deadRefs.length} ref(s) no longer back any visible or folded message (the client history no longer carries them — host-native compaction or a bulk rewrite). Ranges citing them can NEVER compress; target only the live refs listed above: ${formatDeadRefSpans(deadRefs)}`);
}
// #4458: host-native compaction landed under this session — an explicit per-session
// marker so an operator/agent can tell "the host compacted this conversation" from
// "bili folded it" BEFORE a follow-up call burns a ref minted before the boundary.
// Display-only; the boundary record is set server-side by every prepare/relay path in
// BOTH compression modes, so the marker is lane-neutral (hermes/codex/omp/...).
const nativeBnd = ctx.session.metadata.nativeCompactionBoundary;
if (nativeBnd && typeof nativeBnd === "object") {
const bnd = nativeBnd as { at?: number; pendingRebase?: boolean; rebasedAt?: number };
if (typeof bnd.at === "number") {
const lane = conflictClientOf(ctx.session);
const atIso = new Date(bnd.at).toISOString();
if (bnd.pendingRebase === true) {
extra.push("");
extra.push(`HOST-NATIVE COMPACTION — the client (${lane ?? "unknown lane"}) compacted this conversation natively at ${atIso}; bili has NOT yet rebased onto the compacted view (the rebase lands on the next turn). Refs minted before this boundary stop resolving once it completes — compress only live refs.`);
} else {
const rebasedIso = typeof bnd.rebasedAt === "number" ? new Date(bnd.rebasedAt).toISOString() : "?";
extra.push("");
extra.push(`HOST-NATIVE COMPACTION — the client (${lane ?? "unknown lane"}) compacted this conversation natively at ${atIso} and bili rebased onto it at ${rebasedIso}. Refs minted before that boundary no longer resolve — compress only the live refs listed above (DEAD REFS names which ones died).`);
}
}
}
if (breaker) {
extra.push("");
extra.push(`COMPRESS CIRCUIT BREAKER: ARMED — consecutiveFailures: ${breaker.n} / ${breaker.threshold}. Disarms on one successful compress or ${breaker.decayMinutes} min without further failures.`);
Expand Down
22 changes: 22 additions & 0 deletions tests/acp-status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,25 @@ test("acp_status renders the ACTIVE SURFACE line from the session's pack stamp",
assert.ok(line, "ACTIVE SURFACE line present once stamped");
assert.ok(line!.startsWith("ACTIVE SURFACE: pack=lean | host=billion-context "), `host identity rendered (got: ${line})`);
});

test("acp_status marks host-native compaction landings per session (#4458)", () => {
const clean = handleAcpStatus({}, makeCtx12()).text;
assert.ok(!clean.includes("HOST-NATIVE COMPACTION"), "negative gate: no marker when no native-compaction landing was recorded");

const pending = makeCtx12();
const t0 = Date.now() - 30_000;
pending.session.metadata.pluginAgent = "hermes";
pending.session.metadata.nativeCompactionBoundary = { at: t0, pendingRebase: true };
const outPending = handleAcpStatus({}, pending).text;
assert.ok(outPending.includes("HOST-NATIVE COMPACTION"), "marker present when a landing is recorded");
assert.ok(outPending.includes("(hermes)"), "names the resolved client/lane");
assert.ok(outPending.includes("NOT yet rebased"), "pending-rebase state surfaced");

const done = makeCtx12();
const t1 = Date.now() - 90_000;
done.session.metadata.clientHint = "codex";
done.session.metadata.nativeCompactionBoundary = { at: t1, pendingRebase: false, rebasedAt: Date.now() - 60_000 };
const outDone = handleAcpStatus({}, done).text;
assert.ok(outDone.includes("rebased onto it at"), "rebased state surfaced");
assert.ok(outDone.includes("(codex)"), "codex lane resolved from clientHint");
});
Loading