Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
223 lines
7.4 KiB
TypeScript
223 lines
7.4 KiB
TypeScript
// Upgrade Survivor Assertions tests cover upgrade survivor assertions script behavior.
|
|
import { execFileSync } from "node:child_process";
|
|
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { DatabaseSync } from "node:sqlite";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const ASSERTIONS_PATH = "scripts/e2e/lib/upgrade-survivor/assertions.mjs";
|
|
|
|
function writeJson(path: string, value: unknown): void {
|
|
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
|
|
}
|
|
|
|
function writeMigratedSessionState(stateDir: string): void {
|
|
const agentSessionsDir = join(stateDir, "agents", "main", "sessions");
|
|
const agentDbDir = join(stateDir, "agents", "main", "agent");
|
|
const mainSessionFile = join(agentSessionsDir, "upgrade-main-session.jsonl");
|
|
const directSessionFile = join(agentSessionsDir, "upgrade-direct-session.jsonl");
|
|
const groupSessionFile = join(agentSessionsDir, "upgrade-group-session.jsonl");
|
|
mkdirSync(agentSessionsDir, { recursive: true });
|
|
mkdirSync(agentDbDir, { recursive: true });
|
|
writeFileSync(mainSessionFile, '{"type":"main"}\n');
|
|
writeFileSync(directSessionFile, '{"type":"direct"}\n');
|
|
writeFileSync(groupSessionFile, '{"type":"group"}\n');
|
|
writeJson(join(agentSessionsDir, "sessions.json"), {
|
|
"agent:main:main": {
|
|
sessionFile: mainSessionFile,
|
|
sessionId: "upgrade-main-session",
|
|
skillsSnapshot: {
|
|
prompt: "legacy prompt survives as metadata",
|
|
},
|
|
},
|
|
"agent:main:+15551234567": {
|
|
sessionFile: directSessionFile,
|
|
sessionId: "upgrade-direct-session",
|
|
},
|
|
"agent:main:slack:channel:cupgrade": {
|
|
sessionFile: groupSessionFile,
|
|
sessionId: "upgrade-group-session",
|
|
},
|
|
});
|
|
|
|
const db = new DatabaseSync(join(agentDbDir, "openclaw-agent.sqlite"));
|
|
try {
|
|
db.exec(`
|
|
CREATE TABLE IF NOT EXISTS cache_entries (
|
|
scope TEXT NOT NULL,
|
|
key TEXT NOT NULL,
|
|
value_json TEXT,
|
|
blob BLOB,
|
|
expires_at INTEGER,
|
|
updated_at INTEGER NOT NULL,
|
|
PRIMARY KEY (scope, key)
|
|
);
|
|
`);
|
|
const insert = db.prepare(`
|
|
INSERT INTO cache_entries (scope, key, value_json, updated_at)
|
|
VALUES (?, ?, ?, ?)
|
|
`);
|
|
insert.run(
|
|
"session_entries",
|
|
"agent:main:main",
|
|
JSON.stringify({
|
|
sessionFile: mainSessionFile,
|
|
sessionId: "upgrade-main-session",
|
|
skillsSnapshot: {
|
|
prompt: "legacy prompt survives as metadata",
|
|
},
|
|
}),
|
|
1710000000000,
|
|
);
|
|
insert.run(
|
|
"session_entries",
|
|
"agent:main:+15551234567",
|
|
JSON.stringify({
|
|
sessionFile: directSessionFile,
|
|
sessionId: "upgrade-direct-session",
|
|
}),
|
|
1710000000100,
|
|
);
|
|
insert.run(
|
|
"session_entries",
|
|
"agent:main:slack:channel:cupgrade",
|
|
JSON.stringify({
|
|
sessionFile: groupSessionFile,
|
|
sessionId: "upgrade-group-session",
|
|
}),
|
|
1710000000200,
|
|
);
|
|
} finally {
|
|
db.close();
|
|
}
|
|
}
|
|
|
|
function assertConfiguredPluginState(params: { installPath?: string } = {}): void {
|
|
const root = mkdtempSync(join(tmpdir(), "openclaw-upgrade-survivor-"));
|
|
try {
|
|
const stateDir = join(root, "state");
|
|
const workspace = join(root, "workspace");
|
|
const matrixInstallDir = params.installPath ?? join(stateDir, "extensions", "matrix");
|
|
mkdirSync(join(stateDir, "agents", "main", "sessions"), { recursive: true });
|
|
mkdirSync(join(stateDir, "plugins"), { recursive: true });
|
|
mkdirSync(matrixInstallDir, { recursive: true });
|
|
mkdirSync(workspace, { recursive: true });
|
|
writeFileSync(join(workspace, "IDENTITY.md"), "# survivor\n");
|
|
writeJson(join(stateDir, "agents", "main", "sessions", "legacy-session.json"), {
|
|
id: "legacy-session",
|
|
});
|
|
writeMigratedSessionState(stateDir);
|
|
writeJson(join(matrixInstallDir, "package.json"), {
|
|
name: "@openclaw/matrix",
|
|
});
|
|
writeJson(join(stateDir, "plugins", "installs.json"), {
|
|
installRecords: {
|
|
matrix: {
|
|
source: "clawhub",
|
|
spec: "clawhub:@openclaw/matrix",
|
|
installPath: matrixInstallDir,
|
|
clawhubPackage: "@openclaw/matrix",
|
|
clawhubChannel: "official",
|
|
artifactKind: "npm-pack",
|
|
},
|
|
},
|
|
plugins: [{ pluginId: "matrix", enabled: true }],
|
|
});
|
|
const coveragePath = join(root, "coverage.json");
|
|
writeJson(coveragePath, {
|
|
acceptedIntents: ["configured-plugin-installs"],
|
|
skippedIntents: [],
|
|
});
|
|
|
|
execFileSync(process.execPath, [ASSERTIONS_PATH, "assert-state"], {
|
|
env: {
|
|
...process.env,
|
|
OPENCLAW_STATE_DIR: stateDir,
|
|
OPENCLAW_TEST_WORKSPACE_DIR: workspace,
|
|
OPENCLAW_UPGRADE_SURVIVOR_CONFIG_COVERAGE_JSON: coveragePath,
|
|
OPENCLAW_UPGRADE_SURVIVOR_SCENARIO: "configured-plugin-installs",
|
|
},
|
|
stdio: "pipe",
|
|
});
|
|
} finally {
|
|
rmSync(root, { force: true, recursive: true });
|
|
}
|
|
}
|
|
|
|
describe("upgrade survivor assertions", () => {
|
|
it("accepts the ACPX OpenClaw tools bridge scenario during seed", () => {
|
|
const root = mkdtempSync(join(tmpdir(), "openclaw-upgrade-survivor-acpx-"));
|
|
try {
|
|
const stateDir = join(root, "state");
|
|
const workspace = join(root, "workspace");
|
|
mkdirSync(stateDir, { recursive: true });
|
|
mkdirSync(workspace, { recursive: true });
|
|
|
|
execFileSync(process.execPath, [ASSERTIONS_PATH, "seed"], {
|
|
env: {
|
|
...process.env,
|
|
OPENCLAW_STATE_DIR: stateDir,
|
|
OPENCLAW_TEST_WORKSPACE_DIR: workspace,
|
|
OPENCLAW_UPGRADE_SURVIVOR_SCENARIO: "acpx-openclaw-tools-bridge",
|
|
},
|
|
stdio: "pipe",
|
|
});
|
|
} finally {
|
|
rmSync(root, { force: true, recursive: true });
|
|
}
|
|
});
|
|
|
|
it("asserts the ACPX OpenClaw tools bridge config survived", () => {
|
|
const root = mkdtempSync(join(tmpdir(), "openclaw-upgrade-survivor-acpx-config-"));
|
|
try {
|
|
const configPath = join(root, "openclaw.json");
|
|
const coveragePath = join(root, "coverage.json");
|
|
writeJson(configPath, {
|
|
plugins: {
|
|
allow: ["acpx"],
|
|
entries: {
|
|
acpx: {
|
|
enabled: true,
|
|
config: {
|
|
openClawToolsMcpBridge: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
writeJson(coveragePath, {
|
|
acceptedIntents: ["acpx-openclaw-tools-bridge"],
|
|
skippedIntents: [],
|
|
});
|
|
|
|
execFileSync(process.execPath, [ASSERTIONS_PATH, "assert-config"], {
|
|
env: {
|
|
...process.env,
|
|
OPENCLAW_CONFIG_PATH: configPath,
|
|
OPENCLAW_UPGRADE_SURVIVOR_CONFIG_COVERAGE_JSON: coveragePath,
|
|
OPENCLAW_UPGRADE_SURVIVOR_SCENARIO: "acpx-openclaw-tools-bridge",
|
|
},
|
|
stdio: "pipe",
|
|
});
|
|
} finally {
|
|
rmSync(root, { force: true, recursive: true });
|
|
}
|
|
});
|
|
|
|
it("accepts official ClawHub npm-pack installs for configured external plugins", () => {
|
|
expect(() => assertConfiguredPluginState()).not.toThrow();
|
|
});
|
|
|
|
it("rejects ClawHub npm-pack installs outside the managed extensions root", () => {
|
|
const root = mkdtempSync(join(tmpdir(), "openclaw-upgrade-survivor-outside-"));
|
|
try {
|
|
expect(() =>
|
|
assertConfiguredPluginState({ installPath: join(root, "outside-matrix") }),
|
|
).toThrow(/managed extensions root/);
|
|
} finally {
|
|
rmSync(root, { force: true, recursive: true });
|
|
}
|
|
});
|
|
});
|