mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-14 08:04:17 +00:00
test: stop seeding memory transcripts in session dirs
This commit is contained in:
@@ -263,7 +263,9 @@ The remaining cleanup is mostly consolidation and deletion:
|
||||
files; reset only rotates the SQLite session row and transcript identity.
|
||||
- Memory-core dreaming no longer prunes session rows by probing for missing
|
||||
JSONL files. Subagent cleanup goes through the session runtime API instead of
|
||||
filesystem existence checks.
|
||||
filesystem existence checks. Its transcript-ingestion tests seed SQLite rows
|
||||
through neutral test locators instead of creating `agents/<id>/sessions`
|
||||
fixtures.
|
||||
- Sandbox container/browser registries now use the shared
|
||||
`sandbox_registry_entries` SQLite table. Doctor imports legacy monolithic and
|
||||
sharded JSON registry files and removes successful sources.
|
||||
|
||||
@@ -6,7 +6,6 @@ import { RequestScopedSubagentRuntimeError } from "openclaw/plugin-sdk/error-run
|
||||
import {
|
||||
appendSqliteSessionTranscriptEvent,
|
||||
replaceSqliteSessionTranscriptEvents,
|
||||
resolveSessionTranscriptsDirForAgent,
|
||||
} from "openclaw/plugin-sdk/memory-core-host-runtime-core";
|
||||
import {
|
||||
resolveMemoryCorePluginConfig,
|
||||
@@ -291,6 +290,10 @@ async function readPhaseSignalStoreForTest(workspaceDir: string, nowMs: number)
|
||||
);
|
||||
}
|
||||
|
||||
function createTestTranscriptPath(workspaceDir: string, agentId: string, fileName: string): string {
|
||||
return path.join(workspaceDir, ".state", "transcript-fixtures", agentId, fileName);
|
||||
}
|
||||
|
||||
function parseTestTranscriptPath(transcriptPath: string):
|
||||
| {
|
||||
workspaceDir: string;
|
||||
@@ -299,19 +302,16 @@ function parseTestTranscriptPath(transcriptPath: string):
|
||||
| undefined {
|
||||
const parts = path.normalize(path.resolve(transcriptPath)).split(path.sep);
|
||||
const stateIndex = parts.lastIndexOf(".state");
|
||||
const agentsIndex = parts.lastIndexOf("agents");
|
||||
const sessionsIndex = parts.lastIndexOf("sessions");
|
||||
if (
|
||||
stateIndex <= 0 ||
|
||||
agentsIndex !== stateIndex + 1 ||
|
||||
sessionsIndex !== agentsIndex + 2 ||
|
||||
!parts[agentsIndex + 1]
|
||||
parts[stateIndex + 1] !== "transcript-fixtures" ||
|
||||
!parts[stateIndex + 2]
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
workspaceDir: parts.slice(0, stateIndex).join(path.sep) || path.sep,
|
||||
agentId: parts[agentsIndex + 1],
|
||||
agentId: parts[stateIndex + 2],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -793,9 +793,7 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "dreaming-main.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(workspaceDir, "main", "dreaming-main.jsonl");
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
[
|
||||
@@ -902,12 +900,8 @@ describe("memory-core dreaming phases", () => {
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
|
||||
const mainSessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
const subagentSessionsDir = resolveSessionTranscriptsDirForAgent("agi-ceo");
|
||||
await fs.mkdir(mainSessionsDir, { recursive: true });
|
||||
await fs.mkdir(subagentSessionsDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(mainSessionsDir, "main-session.jsonl"),
|
||||
createTestTranscriptPath(workspaceDir, "main", "main-session.jsonl"),
|
||||
[
|
||||
JSON.stringify({
|
||||
type: "message",
|
||||
@@ -921,7 +915,7 @@ describe("memory-core dreaming phases", () => {
|
||||
"utf-8",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(subagentSessionsDir, "subagent-session.jsonl"),
|
||||
createTestTranscriptPath(workspaceDir, "agi-ceo", "subagent-session.jsonl"),
|
||||
[
|
||||
JSON.stringify({
|
||||
type: "message",
|
||||
@@ -991,9 +985,7 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "dreaming-main.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(workspaceDir, "main", "dreaming-main.jsonl");
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
[
|
||||
@@ -1065,9 +1057,11 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "dreaming-narrative.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(
|
||||
workspaceDir,
|
||||
"main",
|
||||
"dreaming-narrative.jsonl",
|
||||
);
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
[
|
||||
@@ -1161,9 +1155,11 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "dreaming-narrative.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(
|
||||
workspaceDir,
|
||||
"main",
|
||||
"dreaming-narrative.jsonl",
|
||||
);
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
[
|
||||
@@ -1250,9 +1246,7 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "cron-run.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(workspaceDir, "main", "cron-run.jsonl");
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
[
|
||||
@@ -1335,9 +1329,7 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "ordinary-session.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(workspaceDir, "main", "ordinary-session.jsonl");
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
[
|
||||
@@ -1434,11 +1426,13 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
|
||||
await fs.writeFile(
|
||||
path.join(sessionsDir, "ordinary.checkpoint.11111111-1111-4111-8111-111111111111.jsonl"),
|
||||
createTestTranscriptPath(
|
||||
workspaceDir,
|
||||
"main",
|
||||
"ordinary.checkpoint.11111111-1111-4111-8111-111111111111.jsonl",
|
||||
),
|
||||
JSON.stringify({
|
||||
type: "message",
|
||||
message: {
|
||||
@@ -1450,7 +1444,7 @@ describe("memory-core dreaming phases", () => {
|
||||
"utf-8",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(sessionsDir, "ordinary.jsonl"),
|
||||
createTestTranscriptPath(workspaceDir, "main", "ordinary.jsonl"),
|
||||
[
|
||||
JSON.stringify({
|
||||
type: "message",
|
||||
@@ -1598,9 +1592,11 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "dreaming-narrative.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(
|
||||
workspaceDir,
|
||||
"main",
|
||||
"dreaming-narrative.jsonl",
|
||||
);
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
[
|
||||
@@ -1685,9 +1681,7 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "dreaming-main.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(workspaceDir, "main", "dreaming-main.jsonl");
|
||||
const oldMessage = "Move backups to S3 Glacier.";
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
@@ -1803,9 +1797,7 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "dreaming-main.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(workspaceDir, "main", "dreaming-main.jsonl");
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
[
|
||||
@@ -1884,9 +1876,7 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "dreaming-main.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(workspaceDir, "main", "dreaming-main.jsonl");
|
||||
const lines: string[] = [];
|
||||
for (let index = 0; index < 160; index += 1) {
|
||||
lines.push(
|
||||
@@ -1964,9 +1954,7 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "dreaming-main.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(workspaceDir, "main", "dreaming-main.jsonl");
|
||||
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
@@ -2062,9 +2050,7 @@ describe("memory-core dreaming phases", () => {
|
||||
const workspaceDir = await createDreamingWorkspace();
|
||||
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", path.join(workspaceDir, ".state"));
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const transcriptPath = path.join(sessionsDir, "dreaming-main.jsonl");
|
||||
const transcriptPath = createTestTranscriptPath(workspaceDir, "main", "dreaming-main.jsonl");
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
[
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
listRegisteredMemoryEmbeddingProviderAdapters as listRegisteredAdapters,
|
||||
registerMemoryEmbeddingProvider as registerAdapter,
|
||||
} from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
||||
import { resolveSessionTranscriptsDirForAgent } from "openclaw/plugin-sdk/memory-core-host-runtime-core";
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { replaceSqliteSessionTranscriptEvents } from "../../../../src/config/sessions/transcript-store.sqlite.js";
|
||||
import { closeOpenClawAgentDatabasesForTest } from "../../../../src/state/openclaw-agent-db.js";
|
||||
@@ -341,7 +340,10 @@ describe("memory index", () => {
|
||||
now?: number;
|
||||
}): string {
|
||||
const transcriptPath = path.join(
|
||||
resolveSessionTranscriptsDirForAgent("main"),
|
||||
workspaceDir,
|
||||
".state",
|
||||
"transcript-fixtures",
|
||||
"main",
|
||||
`${params.sessionId}.jsonl`,
|
||||
);
|
||||
replaceSqliteSessionTranscriptEvents({
|
||||
|
||||
Reference in New Issue
Block a user