
























@@ -25,7 +25,7 @@ import {
2525loadWorkspaceBootstrapFiles,
2626resolveWorkspaceBootstrapStatus,
2727resolveDefaultAgentWorkspaceDir,
28-resolveWorkspaceAttestationPath,
28+resolveWorkspaceAttestationPaths,
2929WORKSPACE_VANISHED_ERROR_CODE,
3030type WorkspaceBootstrapFile,
3131} from "./workspace.js";
@@ -68,6 +68,14 @@ describe("resolveDefaultAgentWorkspaceDir", () => {
6868const WORKSPACE_STATE_PATH_SEGMENTS = ["openclaw-workspace-state.json"] as const;
6969const LEGACY_WORKSPACE_STATE_PATH_SEGMENTS = [".openclaw", "workspace-state.json"] as const;
707071+function resolveCurrentWorkspaceAttestationPath(dir: string): string {
72+const [attestationPath] = resolveWorkspaceAttestationPaths(dir);
73+if (!attestationPath) {
74+throw new Error("expected current workspace attestation path");
75+}
76+return attestationPath;
77+}
78+7179async function readWorkspaceState(dir: string): Promise<{
7280version: number;
7381bootstrapSeededAt?: string;
@@ -170,7 +178,9 @@ describe("ensureAgentWorkspace", () => {
170178it("refuses to re-seed a recently attested workspace after the directory disappears", async () => {
171179const tempDir = await makeTempWorkspace("openclaw-workspace-");
172180await ensureAgentWorkspace({ dir: tempDir, ensureBootstrapFiles: true });
173-await expect(fs.access(resolveWorkspaceAttestationPath(tempDir))).resolves.toBeUndefined();
181+await expect(
182+fs.access(resolveCurrentWorkspaceAttestationPath(tempDir)),
183+).resolves.toBeUndefined();
174184175185await fs.rm(tempDir, { recursive: true, force: true });
176186@@ -228,7 +238,7 @@ describe("ensureAgentWorkspace", () => {
228238const tempDir = await makeTempWorkspace("openclaw-workspace-");
229239const oldGeneratedAgents = "old generated agents\n";
230240await fs.writeFile(path.join(tempDir, DEFAULT_AGENTS_FILENAME), oldGeneratedAgents);
231-const attestationPath = resolveWorkspaceAttestationPath(tempDir);
241+const attestationPath = resolveCurrentWorkspaceAttestationPath(tempDir);
232242await fs.mkdir(path.dirname(attestationPath), { recursive: true });
233243await fs.writeFile(
234244attestationPath,
@@ -364,7 +374,7 @@ describe("ensureAgentWorkspace", () => {
364374await ensureAgentWorkspace({ dir: tempDir, ensureBootstrapFiles: true });
365375await fs.rm(tempDir, { recursive: true, force: true });
366376const staleDate = new Date(Date.now() - 25 * 60 * 60 * 1000);
367-await fs.utimes(resolveWorkspaceAttestationPath(tempDir), staleDate, staleDate);
377+await fs.utimes(resolveCurrentWorkspaceAttestationPath(tempDir), staleDate, staleDate);
368378369379await ensureAgentWorkspace({ dir: tempDir, ensureBootstrapFiles: true });
370380@@ -399,7 +409,7 @@ describe("ensureAgentWorkspace", () => {
399409"refuses to re-seed when a recent owned marker becomes unreadable",
400410async () => {
401411const tempDir = await makeTempWorkspace("openclaw-workspace-");
402-const attestationPath = resolveWorkspaceAttestationPath(tempDir);
412+const attestationPath = resolveCurrentWorkspaceAttestationPath(tempDir);
403413await ensureAgentWorkspace({ dir: tempDir, ensureBootstrapFiles: true });
404414await fs.chmod(attestationPath, 0o000);
405415await fs.rm(tempDir, { recursive: true, force: true });
@@ -418,7 +428,7 @@ describe("ensureAgentWorkspace", () => {
418428"refuses to re-seed when the state marker directory is unreadable",
419429async () => {
420430const tempDir = await makeTempWorkspace("openclaw-workspace-");
421-const attestationDir = path.dirname(resolveWorkspaceAttestationPath(tempDir));
431+const attestationDir = path.dirname(resolveCurrentWorkspaceAttestationPath(tempDir));
422432await ensureAgentWorkspace({ dir: tempDir, ensureBootstrapFiles: true });
423433await fs.chmod(attestationDir, 0o000);
424434await fs.rm(tempDir, { recursive: true, force: true });
@@ -437,7 +447,7 @@ describe("ensureAgentWorkspace", () => {
437447"ignores symlinked attestation markers without overwriting the target",
438448async () => {
439449const tempDir = await makeTempWorkspace("openclaw-workspace-");
440-const attestationPath = resolveWorkspaceAttestationPath(tempDir);
450+const attestationPath = resolveCurrentWorkspaceAttestationPath(tempDir);
441451const symlinkTargetPath = `${attestationPath}-target`;
442452const targetContent = "outside-marker\n";
443453await fs.mkdir(path.dirname(attestationPath), { recursive: true });
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。