Files
adolf/test/scripts/audit-seams.test.ts
alvis bedb527145
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
Vendor OpenClaw source as Adolf fork baseline
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
2026-07-05 09:36:54 +00:00

156 lines
5.9 KiB
TypeScript

// Audit Seams tests cover audit seams script behavior.
import { describe, expect, it } from "vitest";
import {
HELP_TEXT,
describeSeamKinds,
determineSeamTestStatus,
} from "../../scripts/audit-seams.mjs";
describe("audit-seams cron seam classification", () => {
it("detects cron agent handoff and outbound delivery boundaries", () => {
const source = `
import { runCliAgent } from "../../agents/cli-runner.js";
import { runWithModelFallback } from "../../agents/model-fallback.js";
import { registerAgentRunContext } from "../../infra/agent-events.js";
import { deliverOutboundPayloads } from "../../infra/outbound/deliver.js";
import { buildOutboundSessionContext } from "../../infra/outbound/session-context.js";
export async function runCronIsolatedAgentTurn() {
registerAgentRunContext({});
await runWithModelFallback(() => runCliAgent({}));
await deliverOutboundPayloads({ payloads: [{ text: "done" }] });
return buildOutboundSessionContext({});
}
`;
expect(describeSeamKinds("src/cron/isolated-agent/run.ts", source)).toEqual([
"cron-agent-handoff",
"cron-outbound-delivery",
]);
});
it("detects scheduler-state seams in cron service orchestration", () => {
const source = `
import { recomputeNextRuns, computeJobNextRunAtMs } from "./jobs.js";
import { ensureLoaded, persist } from "./store.js";
import { armTimer, runMissedJobs } from "./timer.js";
export async function start(state) {
await ensureLoaded(state);
recomputeNextRuns(state);
await persist(state);
armTimer(state);
await runMissedJobs(state);
return computeJobNextRunAtMs(state.store.jobs[0], Date.now());
}
`;
expect(describeSeamKinds("src/cron/service/ops.ts", source)).toContain("cron-scheduler-state");
});
});
describe("audit-seams subagent seam classification", () => {
it("detects subagent spawn and cleanup handoff boundaries", () => {
const source = `
import { callGateway } from "../gateway/call.js";
import { emitSessionLifecycleEvent } from "../sessions/session-lifecycle-events.js";
import { registerSubagentRun } from "./subagent-registry.js";
export async function spawnSubagentDirect() {
const response = await callGateway({ method: "agent.run", params: { task: "do it" } });
registerSubagentRun({ childSessionKey: "agent:main:subagent:child" });
await callGateway({ method: "sessions.delete", params: { key: "agent:main:subagent:child" } });
emitSessionLifecycleEvent({ sessionKey: "agent:main:subagent:child", type: "spawned" });
return response;
}
`;
expect(describeSeamKinds("src/agents/subagent-spawn.ts", source)).toEqual([
"subagent-lifecycle-registry",
"subagent-session-cleanup",
"subagent-session-spawn",
]);
});
it("detects subagent lifecycle registry and announce delivery seams", () => {
const source = `
import { resolveContextEngine } from "../context-engine/registry.js";
import { captureSubagentCompletionReply, runSubagentAnnounceFlow } from "./subagent-announce.js";
import { emitSubagentEndedHookOnce } from "./subagent-registry-completion.js";
import { persistSubagentRunsToDisk } from "./subagent-registry-state.js";
export async function completeRun(entry) {
await resolveContextEngine({});
await captureSubagentCompletionReply(entry.childSessionKey);
await emitSubagentEndedHookOnce({ runId: entry.runId });
persistSubagentRunsToDisk(new Map());
return runSubagentAnnounceFlow({ childSessionKey: entry.childSessionKey });
}
`;
expect(describeSeamKinds("src/agents/subagent-registry.ts", source)).toEqual([
"subagent-announce-delivery",
"subagent-lifecycle-registry",
]);
});
it("detects parent-stream seams for ACP spawn relays", () => {
const source = `
import { onAgentEvent } from "../infra/agent-events.js";
import { requestHeartbeat } from "../infra/heartbeat-wake.js";
import { enqueueSystemEvent } from "../infra/system-events.js";
export function startAcpSpawnParentStreamRelay() {
onAgentEvent("agent-output", () => {});
requestHeartbeat({
source: "acp-spawn",
intent: "event",
reason: "acp:spawn:stream",
sessionKey: "agent:main",
});
enqueueSystemEvent("progress", { sessionKey: "agent:main", contextKey: "stream" });
return { streamTo: "parent" };
}
`;
expect(describeSeamKinds("src/agents/acp-spawn-parent-stream.ts", source)).toEqual([
"subagent-parent-stream",
]);
});
});
describe("audit-seams status/help", () => {
it("keeps cron seam statuses conservative when nearby tests exist", () => {
expect(
determineSeamTestStatus(
["cron-agent-handoff"],
[{ file: "src/cron/service.issue-regressions.test.ts", matchQuality: "path-nearby" }],
),
).toEqual({
status: "partial",
reason:
"Nearby tests exist (best match: path-nearby), but this inventory does not prove cross-layer seam coverage end to end.",
});
});
it("keeps subagent seam statuses conservative when nearby tests exist", () => {
expect(
determineSeamTestStatus(
["subagent-session-spawn"],
[{ file: "src/agents/subagent-spawn.workspace.test.ts", matchQuality: "direct-import" }],
),
).toEqual({
status: "partial",
reason:
"Nearby tests exist (best match: direct-import), but this inventory does not prove cross-layer seam coverage end to end.",
});
});
it("documents cron and subagent seam coverage in help text", () => {
expect(HELP_TEXT).toContain("cron orchestration seams");
expect(HELP_TEXT).toContain("subagent seams");
expect(HELP_TEXT).toContain("announce delivery");
expect(HELP_TEXT).toContain("parent streaming");
});
});