refactor(gateway): remove unused checkpoint wrappers

This commit is contained in:
Vincent Koc
2026-06-19 02:04:13 +08:00
parent 111018984c
commit 6b25ccc4b1
2 changed files with 1 additions and 62 deletions

View File

@@ -11,14 +11,11 @@ import { afterEach, describe, expect, test, vi } from "vitest";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import {
captureCompactionCheckpointSnapshotAsync,
captureRuntimeCompactionCheckpointSnapshotAsync,
cleanupCompactionCheckpointSnapshot,
forkCompactionCheckpointTranscriptAsync,
MAX_COMPACTION_CHECKPOINT_LEAF_SCAN_BYTES,
MAX_COMPACTION_CHECKPOINT_RETAINED_BYTES_PER_SESSION,
persistSessionCompactionCheckpoint,
readRuntimeSessionLeafIdFromTranscriptAsync,
readSessionLeafIdFromTranscriptAsync,
readSessionLeafStateFromTranscriptAsync,
resolveCompactionCheckpointTranscriptPosition,
} from "./session-compaction-checkpoints.js";
@@ -180,25 +177,6 @@ describe("session-compaction-checkpoints", () => {
});
});
test("runtime checkpoint probes do not create session metadata for missing transcripts", async () => {
const { storePath, sessionKey } = await makeTempSessionStore(
"openclaw-checkpoint-runtime-probe-",
"missing-session",
);
await fs.writeFile(storePath, "{}\n", "utf-8");
const scope = {
agentId: MAIN_AGENT_ID,
sessionId: "missing-session",
sessionKey,
storePath,
};
await expect(readRuntimeSessionLeafIdFromTranscriptAsync(scope)).resolves.toBeNull();
await expect(captureRuntimeCompactionCheckpointSnapshotAsync({ scope })).resolves.toBeNull();
expect(await fs.readFile(storePath, "utf-8")).toBe("{}\n");
});
test("async capture stores pre-compaction identity without copying the transcript", async () => {
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-checkpoint-async-"));
tempDirs.push(dir);
@@ -280,7 +258,7 @@ describe("session-compaction-checkpoints", () => {
const sessionManagerOpenSpy = vi.spyOn(SessionManager, "open");
let snapshot: Awaited<ReturnType<typeof captureCompactionCheckpointSnapshotAsync>> | undefined;
try {
expect(await readSessionLeafIdFromTranscriptAsync(sessionFile)).toBe(leafId);
expect((await readSessionLeafStateFromTranscriptAsync(sessionFile))?.leafId).toBe(leafId);
snapshot = await captureCompactionCheckpointSnapshotAsync({
sessionFile,
});
@@ -355,7 +333,6 @@ describe("session-compaction-checkpoints", () => {
"utf-8",
);
expect(await readSessionLeafIdFromTranscriptAsync(sessionFile)).toBe("active-tail");
expect(await readSessionLeafStateFromTranscriptAsync(sessionFile)).toEqual({
entryId: "post-leaf-metadata",
leafId: "active-tail",

View File

@@ -15,10 +15,6 @@ import type {
SessionEntry,
} from "../config/sessions.js";
import { isCompactionCheckpointTranscriptFileName } from "../config/sessions/artifacts.js";
import {
resolveSessionTranscriptRuntimeReadTarget,
type SessionTranscriptRuntimeScope,
} from "../config/sessions/session-accessor.js";
import { streamSessionTranscriptLines } from "../config/sessions/transcript-stream.js";
import { scanSessionTranscriptTree } from "../config/sessions/transcript-tree.js";
import { CURRENT_SESSION_VERSION } from "../config/sessions/version.js";
@@ -361,24 +357,6 @@ export async function readSessionLeafStateFromTranscriptAsync(
return null;
}
export async function readSessionLeafIdFromTranscriptAsync(
sessionFile: string,
maxBytes = MAX_COMPACTION_CHECKPOINT_LEAF_SCAN_BYTES,
): Promise<string | null> {
return (await readSessionLeafStateFromTranscriptAsync(sessionFile, maxBytes))?.leafId ?? null;
}
/**
* Reads the latest leaf id for a runtime transcript scope.
*/
export async function readRuntimeSessionLeafIdFromTranscriptAsync(
scope: SessionTranscriptRuntimeScope,
maxBytes = MAX_COMPACTION_CHECKPOINT_LEAF_SCAN_BYTES,
): Promise<string | null> {
const target = await resolveSessionTranscriptRuntimeReadTarget(scope);
return await readSessionLeafIdFromTranscriptAsync(target.sessionFile, maxBytes);
}
export async function forkCompactionCheckpointTranscriptAsync(params: {
sourceFile: string;
sourceLeafId?: string;
@@ -481,22 +459,6 @@ export async function captureCompactionCheckpointSnapshotAsync(params: {
};
}
/**
* Captures checkpoint metadata for a runtime transcript scope.
*/
export async function captureRuntimeCompactionCheckpointSnapshotAsync(params: {
sessionManager?: Pick<SessionManager, "getLeafId">;
scope: SessionTranscriptRuntimeScope;
maxBytes?: number;
}): Promise<CapturedCompactionCheckpointSnapshot | null> {
const target = await resolveSessionTranscriptRuntimeReadTarget(params.scope);
return await captureCompactionCheckpointSnapshotAsync({
sessionManager: params.sessionManager,
sessionFile: target.sessionFile,
maxBytes: params.maxBytes,
});
}
export async function cleanupCompactionCheckpointSnapshot(
snapshot: CapturedCompactionCheckpointSnapshot | null | undefined,
): Promise<void> {