Skip to content

Commit ff254a4

Browse files
committed
docs: document workspace transport tests
1 parent 22f2a91 commit ff254a4

6 files changed

Lines changed: 24 additions & 0 deletions

src/agents/transport-message-transform.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Transport message transform tests cover replay cleanup for provider-specific
2+
// tool-call/result sequencing before messages are sent back to transports.
13
import type { Api, Context, Model } from "openclaw/plugin-sdk/llm";
24
import { describe, expect, it } from "vitest";
35
import { transformTransportMessages } from "./transport-message-transform.js";
@@ -139,6 +141,8 @@ describe("transformTransportMessages synthetic tool-result policy", () => {
139141
});
140142

141143
it("moves displaced OpenAI transport results before synthesizing missing siblings", () => {
144+
// OpenAI requires tool results immediately after the assistant tool call;
145+
// displaced results are moved back before any missing siblings are aborted.
142146
const messages: Context["messages"] = [
143147
{
144148
...assistantToolCall("call_keep"),

src/agents/transport-stream-shared.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Transport stream shared tests cover payload sanitization, header merging, and
2+
// final/error stream termination helpers used by provider transports.
13
import { describe, expect, it, vi } from "vitest";
24
import {
35
failTransportStream,
@@ -74,6 +76,8 @@ describe("transport stream shared helpers", () => {
7476
});
7577

7678
it("marks transport stream failures and runs cleanup", () => {
79+
// Failure finalization mutates the output message before emitting it so
80+
// downstream transcript consumers see the same error state as the stream.
7781
const push = vi.fn();
7882
const end = vi.fn();
7983
const cleanup = vi.fn();

src/agents/workspace-run.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Workspace run tests cover runtime workspace resolution from explicit input,
2+
// agent config, session keys, and environment fallback.
13
import path from "node:path";
24
import { describe, expect, it } from "vitest";
35
import type { OpenClawConfig } from "../config/config.js";
@@ -104,6 +106,8 @@ describe("resolveRunWorkspaceDir", () => {
104106
});
105107

106108
it("throws for malformed agent session keys even when config has a default agent", () => {
109+
// Malformed agent-prefixed keys are configuration/data errors; default
110+
// agents should not mask them as legacy main-session keys.
107111
const mainWorkspace = path.join(process.cwd(), "tmp", "workspace-main-default");
108112
const researchWorkspace = path.join(process.cwd(), "tmp", "workspace-research-default");
109113
const cfg = {

src/agents/workspace.defaults.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Workspace default tests cover environment-variable precedence for the
2+
// built-in agent workspace location.
13
import path from "node:path";
24
import { afterEach, describe, expect, it, vi } from "vitest";
35
import { resolveDefaultAgentWorkspaceDir } from "./workspace.js";

src/agents/workspace.load-extra-bootstrap-files.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Extra bootstrap file tests cover glob/literal path loading, workspace
2+
// containment checks, symlink handling, and diagnostics for skipped files.
13
import fs from "node:fs/promises";
24
import os from "node:os";
35
import path from "node:path";
@@ -117,6 +119,8 @@ describe("loadExtraBootstrapFiles", () => {
117119
});
118120

119121
it("rejects hardlinked aliases to files outside workspace", async () => {
122+
// Hardlinks can look like in-workspace files by path; inode/realpath checks
123+
// keep outside bootstrap content from entering the prompt.
120124
if (process.platform === "win32") {
121125
return;
122126
}

src/agents/workspace.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Workspace tests cover bootstrap seeding, attestation safety, bootstrap file
2+
// filtering, and setup-completion state for agent workspaces.
13
import { createHash } from "node:crypto";
24
import fs from "node:fs/promises";
35
import os from "node:os";
@@ -90,6 +92,8 @@ async function expectWorkspaceVanished(
9092
action: Promise<unknown>,
9193
expected?: { attestationPath?: string },
9294
): Promise<void> {
95+
// Recently attested generated workspaces must not be silently recreated after
96+
// deletion or wipe; that could hide user data loss.
9397
await expect(action).rejects.toMatchObject({
9498
code: WORKSPACE_VANISHED_ERROR_CODE,
9599
name: "WorkspaceVanishedError",
@@ -221,6 +225,8 @@ describe("ensureAgentWorkspace", () => {
221225
});
222226

223227
it("accepts a recently attested workspace when customized AGENTS.md survives", async () => {
228+
// Custom instructions prove the directory is user-managed, so reseeding is
229+
// skipped and the workspace is accepted.
224230
const tempDir = await makeTempWorkspace("openclaw-workspace-");
225231
await ensureAgentWorkspace({ dir: tempDir, ensureBootstrapFiles: true });
226232
await fs.writeFile(path.join(tempDir, DEFAULT_AGENTS_FILENAME), "custom instructions\n");

0 commit comments

Comments
 (0)