fix: reject invalid memory parents and trim test facades (#121696)

* test(scripts): trim dead testing facades

* test(memory): align non-directory path contract

* test(discord): drop stale progress callback ids

* fix: repair current main validation failures

* fix(gateway): remove redundant setup admission generic

* test(gateway): await setup admission settlement
This commit is contained in:
Peter Steinberger
2026-08-10 12:58:30 -07:00
committed by GitHub
parent 084ed7f04b
commit 810c3510ee
9 changed files with 28 additions and 41 deletions
@@ -802,12 +802,10 @@ describe("processDiscordMessage draft streaming progress", () => {
dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => {
await params?.replyOptions?.onToolStart?.({
toolCallId: "call-1",
name: "exec",
phase: "start",
});
await params?.replyOptions?.onCommandOutput?.({
toolCallId: "call-1",
phase: "end",
title: "pnpm test -- --watch=false",
name: "exec",
@@ -19,7 +19,7 @@ async function createDirectorySymlink(target: string, linkPath: string): Promise
}
describe("readMemoryFile", () => {
it("returns empty text for missing files under extra path directories", async () => {
it("returns empty text for absent extra paths and rejects non-directory parents", async () => {
const tmpRoot = await fs.mkdtemp(path.join(os.tmpdir(), "memory-read-file-"));
try {
const workspaceDir = path.join(tmpRoot, "workspace");
@@ -47,10 +47,7 @@ describe("readMemoryFile", () => {
extraPaths: [extraDir],
relPath: nonDirectoryParentPath,
}),
).resolves.toEqual({
text: "",
path: path.relative(workspaceDir, nonDirectoryParentPath).replace(/\\/g, "/"),
});
).rejects.toThrow("path required");
} finally {
await fs.rm(tmpRoot, { recursive: true, force: true });
}
@@ -41,8 +41,8 @@ async function isAllowedAdditionalDirectoryPath(
}
try {
await assertNoSymlinkParents({ rootDir: additionalPath, targetPath: absPath });
} catch (err) {
return isFileMissingError(err);
} catch {
return false;
}
if (!isPathInsideWithRealpath(additionalPath, absPath)) {
try {
-3
View File
@@ -1007,7 +1007,6 @@ async function main() {
export const testing = {
cleanupPromptProbeTmpDir,
installGatewayPromptParentSignalHandlers,
matchesExtraUsage400,
promptProbeTmpResult,
readLogTail,
readRequestBody,
@@ -1015,8 +1014,6 @@ export const testing = {
runDirectPrompt,
startAnthropicProxy,
stopGatewayPromptChild,
summarizeCapture,
summarizeText,
};
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
-3
View File
@@ -542,11 +542,8 @@ const main = async (argv = process.argv.slice(2)) => {
export const testing = {
CLAUDE_COOKIE_HOST_SQL,
CLAUDE_FIREFOX_COOKIE_HOST_SQL,
FETCH_RESPONSE_MAX_BYTES,
browserRootLabel,
fetchAnthropicOAuthUsage,
mask,
parseArgs,
readBoundedResponseText,
resolveFetchTimeoutMs,
-2
View File
@@ -269,13 +269,11 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
}
export const testing = {
parsePositiveIntegerEnv,
resolvePackageTelegramOutputDir,
resolveCredentialRole,
resolveCredentialSource,
createRoundTripProbe,
prioritizeRoundTripProbeScenario,
projectExtendedStable2026_6_35QaConfig,
resolveRttOptions,
resolveTrustedOpenClawCommand,
shouldFailPackageTelegramRun,
+3 -4
View File
@@ -626,7 +626,7 @@ async function spawnText(
});
}
export async function renderBundledRootHelpText(
async function renderBundledRootHelpText(
_distDirOverride: string = distDir,
renderContext?: RootHelpRenderContext,
): Promise<string> {
@@ -755,7 +755,7 @@ async function renderSourceSubcommandHelpTextRecord(
) as PrecomputedSubcommandHelpText;
}
export async function writeCliStartupMetadata(options?: {
async function writeCliStartupMetadata(options?: {
distDir?: string;
outputPath?: string;
extensionsDir?: string;
@@ -981,10 +981,9 @@ export const testing = {
renderSourceRootHelpText,
signalCliStartupMetadataProcessTree,
spawnText,
writeCliStartupMetadata,
};
export { testing as __testing };
if (process.argv[1] && path.resolve(process.argv[1]) === scriptPath) {
await writeCliStartupMetadata();
process.exit(0);
+3 -2
View File
@@ -612,12 +612,13 @@ describe("createVerifiedSqliteSnapshot", () => {
linked = true;
}
});
vi.spyOn(fs, "lstat").mockImplementation(async (filePath) => {
vi.spyOn(fs, "lstat").mockImplementation(async (...args) => {
const [filePath] = args;
if (linked && !failedInspection && path.resolve(String(filePath)) === targetPath) {
failedInspection = true;
throw Object.assign(new Error("target inspection failed"), { code: "EIO" });
}
return await originalLstat(filePath);
return await originalLstat(...args);
});
await expectSnapshotFailureWithoutTarget(
+18 -18
View File
@@ -7,7 +7,7 @@ import { PassThrough } from "node:stream";
import { pathToFileURL } from "node:url";
import { describe, expect, it, vi } from "vitest";
import { resolveWindowsTaskkillPath } from "../../scripts/lib/windows-taskkill.mjs";
import { __testing, writeCliStartupMetadata } from "../../scripts/write-cli-startup-metadata.ts";
import { testing } from "../../scripts/write-cli-startup-metadata.ts";
import { createScriptTestHarness } from "./test-helpers.js";
vi.mock("node:child_process", async (importOriginal) => {
@@ -131,7 +131,7 @@ describe("write-cli-startup-metadata", () => {
});
});
const render = __testing.renderSourceRootHelpText();
const render = testing.renderSourceRootHelpText();
child.stdout.write("Usage: openclaw\n");
setImmediate(() => {
child.emit("close", 0, null);
@@ -156,7 +156,7 @@ describe("write-cli-startup-metadata", () => {
it("fails command help rendering when captured output exceeds the byte limit", async () => {
await expect(
__testing.spawnText(["--eval", "process.stdout.write('x'.repeat(2048))"], {
testing.spawnText(["--eval", "process.stdout.write('x'.repeat(2048))"], {
cwd: process.cwd(),
env: process.env,
failureMessage: "render failed",
@@ -174,7 +174,7 @@ describe("write-cli-startup-metadata", () => {
const spawnProcess = vi.fn(() => child as unknown as ReturnType<typeof spawn>);
const streamError = new Error(`${streamName} pipe failed`);
const render = __testing.spawnText(["--help"], {
const render = testing.spawnText(["--help"], {
cwd: process.cwd(),
env: process.env,
failureMessage: "render failed",
@@ -198,7 +198,7 @@ describe("write-cli-startup-metadata", () => {
it("preserves an output-limit failure when shutdown also errors a stream", async () => {
const child = createSpawnTextChild();
const spawnProcess = vi.fn(() => child as unknown as ReturnType<typeof spawn>);
const render = __testing.spawnText(["--help"], {
const render = testing.spawnText(["--help"], {
cwd: process.cwd(),
env: process.env,
failureMessage: "render failed",
@@ -219,7 +219,7 @@ describe("write-cli-startup-metadata", () => {
const childKill = vi.fn(() => true);
const runTaskkill = vi.fn(() => ({ error: undefined, status: 0 }));
__testing.signalCliStartupMetadataProcessTree({ pid: 123, kill: childKill }, "SIGTERM", {
testing.signalCliStartupMetadataProcessTree({ pid: 123, kill: childKill }, "SIGTERM", {
platform: "win32",
runTaskkill,
});
@@ -227,7 +227,7 @@ describe("write-cli-startup-metadata", () => {
stdio: "ignore",
});
__testing.signalCliStartupMetadataProcessTree({ pid: 123, kill: childKill }, "SIGKILL", {
testing.signalCliStartupMetadataProcessTree({ pid: 123, kill: childKill }, "SIGKILL", {
platform: "win32",
runTaskkill,
});
@@ -249,7 +249,7 @@ describe("write-cli-startup-metadata", () => {
.mockReturnValueOnce({ error: undefined, status: 1 })
.mockReturnValueOnce({ error: undefined, status: 0 });
__testing.signalCliStartupMetadataProcessTree({ pid: 123, kill: childKill }, "SIGTERM", {
testing.signalCliStartupMetadataProcessTree({ pid: 123, kill: childKill }, "SIGTERM", {
platform: "win32",
runTaskkill,
});
@@ -287,7 +287,7 @@ describe("write-cli-startup-metadata", () => {
].join("\n");
await expect(
__testing.spawnText(["--input-type=module", "--eval", parentScript], {
testing.spawnText(["--input-type=module", "--eval", parentScript], {
cwd: tempRoot,
env: process.env,
failureMessage: "render failed",
@@ -343,10 +343,10 @@ describe("write-cli-startup-metadata", () => {
tempRoot,
"runner.mjs",
[
`const { __testing } = await import(${JSON.stringify(
`const { testing } = await import(${JSON.stringify(
pathToFileURL(path.resolve("scripts/write-cli-startup-metadata.ts")).href,
)});`,
"void __testing.spawnText(",
"void testing.spawnText(",
` [${JSON.stringify(fastCommandPath)}],`,
" {",
` cwd: ${JSON.stringify(tempRoot)},`,
@@ -357,7 +357,7 @@ describe("write-cli-startup-metadata", () => {
" timeoutMs: 30_000,",
" },",
").catch(() => undefined);",
"void __testing.spawnText(",
"void testing.spawnText(",
` [${JSON.stringify(commandPath)}],`,
" {",
` cwd: ${JSON.stringify(tempRoot)},`,
@@ -438,7 +438,7 @@ describe("write-cli-startup-metadata", () => {
"utf8",
);
await writeCliStartupMetadata({
await testing.writeCliStartupMetadata({
distDir,
outputPath,
extensionsDir,
@@ -513,7 +513,7 @@ describe("write-cli-startup-metadata", () => {
"async function outputRootHelp() { process.stdout.write('Usage: bundled renderer\\n'); }\nexport { outputRootHelp };\n",
);
await writeCliStartupMetadata({
await testing.writeCliStartupMetadata({
distDir,
outputPath,
extensionsDir,
@@ -575,7 +575,7 @@ describe("write-cli-startup-metadata", () => {
throw new Error(`startup help renderers did not start concurrently: ${started.join(", ")}`);
};
const writePromise = writeCliStartupMetadata({
const writePromise = testing.writeCliStartupMetadata({
distDir,
outputPath,
extensionsDir,
@@ -631,7 +631,7 @@ describe("write-cli-startup-metadata", () => {
writeStartupMetadataSourceSignatureFixture(tempRoot);
writeFixtureFile(distDir, "root-help-fixture.js", "export function outputRootHelp() {}\n");
const writeMetadata = writeCliStartupMetadata({
const writeMetadata = testing.writeCliStartupMetadata({
distDir,
outputPath,
extensionsDir,
@@ -695,7 +695,7 @@ describe("write-cli-startup-metadata", () => {
writeFixtureFile(distDir, "root-help-fixture.js", "export function outputRootHelp() {}\n");
const writeMetadata = async (): Promise<void> => {
await writeCliStartupMetadata({
await testing.writeCliStartupMetadata({
distDir,
outputPath,
extensionsDir,
@@ -776,7 +776,7 @@ describe("write-cli-startup-metadata", () => {
writeFixtureFile(distDir, "root-help-fixture.js", "export function outputRootHelp() {}\n");
const writeMetadata = async (): Promise<void> => {
await writeCliStartupMetadata({
await testing.writeCliStartupMetadata({
distDir,
outputPath,
extensionsDir,