Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5e02e6d
fix(scans): coordinate result preservation and output archival
codex Oct 5, 2026
d001451
fix(scans): report cancellation persistence failure after cleanup
codex Oct 5, 2026
760d0d5
fix(scans): retain stopped responses and legacy archival compatibility
codex Oct 5, 2026
fc581af
fix: preserve parent cancellation after discovery finishes
codex Oct 5, 2026
2526d8f
Check saved scan state after interrupted lifecycle operations
codex Oct 5, 2026
aebb67a
fix(scans): preserve saved state and target integrity during registra…
codex Oct 5, 2026
d573b16
fix(scans): keep committed archive locations after interruption
codex Oct 5, 2026
28dc4cf
Merge main and retain scan lifecycle coverage
mldangelo-oai Oct 5, 2026
e8c0e63
Preserve output preparation archival API
codex Oct 5, 2026
4435602
fix(import): leave output archival to scan registration
codex Oct 5, 2026
a0cfb9a
Merge main into PR branch
mldangelo-oai Oct 5, 2026
51167c2
Merge latest main into PR branch
mldangelo-oai Oct 6, 2026
9a363da
Merge latest main into PR branch
mldangelo-oai Oct 6, 2026
78de19d
Merge latest main into PR branch
mldangelo-oai Oct 6, 2026
8f487b9
Merge latest main into PR branch
mldangelo-oai Oct 6, 2026
cf3e87c
Merge commit '3aa071c83287388fec84837df74bdb8c433565a6' into mdangelo…
codex Oct 6, 2026
cad3725
fix(scans): release SQLite writer admission during target hashing
codex Oct 6, 2026
e861fc8
fix(scans): retry writer admission without stale snapshots
codex Oct 6, 2026
92138e6
fix(scans): integrate current scan lifecycle contracts
mldangelo-oai Oct 7, 2026
66c627c
Merge commit '07429cf69631f1d3e560b3fee412c7036db3fcf3' into mdangelo…
mldangelo-oai Oct 7, 2026
db18093
Merge main dependency update into scan lifecycle
mldangelo-oai Oct 7, 2026
ff1ea34
Merge current main into scan lifecycle
mldangelo-oai Oct 7, 2026
9af1796
Merge current main into scan lifecycle
mldangelo-oai Oct 7, 2026
eeab0a2
Fix cancellation before scan archival
mldangelo-oai Oct 7, 2026
8fc3f6d
Preserve cancellation during import registration
mldangelo-oai Oct 7, 2026
cba86bf
Merge main while preserving scan registration cancellation
mldangelo-oai Oct 7, 2026
d76a4df
Align scan lifecycle test with workbench options
mldangelo-oai Oct 7, 2026
add6e44
fix(scans): preserve replacement results during concurrent ownership …
mldangelo-oai Oct 7, 2026
ceac689
fix(scans): ignore obsolete coordinator failure responses
mldangelo-oai Oct 7, 2026
a7734df
Merge main workbench commands into scan lifecycle repair
mldangelo-oai Oct 7, 2026
a668c9b
test(scans): release late archive fixture connections during cleanup
mldangelo-oai Oct 7, 2026
8b9046f
Merge main cache and worker context updates into scan lifecycle repair
mldangelo-oai Oct 7, 2026
77363c6
Merge main worker endpoint and evaluation updates into scan lifecycle…
mldangelo-oai Oct 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 56 additions & 30 deletions plugins/codex-security/mcp-app/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1243,9 +1243,18 @@ export function createCodexSecurityServer(): McpServer {
workspace = await runWorkbench(args);
},
);
if (!canceledLocally) workspace = await runWorkbench(args);
if (workspace === undefined) {
throw new Error(`Canceling scan ${scanId} did not return its workspace.`);
if (workspace === undefined && canceledLocally) {
workspace = (await runWorkbench(["get-scan", "--scan-id", scanId]))[
"workspace"
] as JsonObject;
}
const scan = workspace?.["results"];
const progress = isJsonObject(scan) ? scan["progress"] : undefined;
if (
workspace === undefined ||
(isJsonObject(progress) && progress["status"] === "running")
) {
workspace = await runWorkbench(args);
}
return workspaceResult(workspace as unknown as WorkspaceState);
};
Expand Down Expand Up @@ -2497,6 +2506,34 @@ async function executeWorkbench(
workbenchArgs.splice(userContextIndex, 2, "--user-context-stdin");
}
const workbenchInput = input ?? userContext;
const timeout = [
"begin-deep-scan",
"cancel-scan",
"fail-scan",
"claim-deep-scan-dedup",
"commit-deep-scan-dedup",
"complete-scan",
"export-findings",
"finish-deep-scan",
"get-scan",
"get-deep-scan",
"get-workspace",
"inspect-setup",
"list-findings",
"preserve-scan-results",
"recover-scan-results",
"request-finding-remediation",
"request-finding-remediation-action",
"save-workspace",
"set-finding-triage",
"set-finding-remediation",
"start-headless-standard-scan",
"start-prompt-only-scan",
"start-scan",
"upsert-deep-scan-worker",
].includes(args[0] ?? "")
? 300_000
: 30_000;
const execution = execFileAsync(
pythonCommand,
[workbenchScriptPath(), ...workbenchArgs],
Expand All @@ -2509,32 +2546,7 @@ async function executeWorkbench(
encoding: "utf8" as const,
// Artifact bytes are base64-encoded here; retain the existing file-size behavior.
maxBuffer: args[0] === "read-artifact" ? Infinity : 4 * 1024 * 1024,
timeout: [
"begin-deep-scan",
"claim-deep-scan-dedup",
"commit-deep-scan-dedup",
"complete-scan",
"export-findings",
"finish-deep-scan",
"get-scan",
"get-deep-scan",
"get-workspace",
"inspect-setup",
"list-findings",
"preserve-scan-results",
"recover-scan-results",
"request-finding-remediation",
"request-finding-remediation-action",
"save-workspace",
"set-finding-triage",
"set-finding-remediation",
"start-headless-standard-scan",
"start-prompt-only-scan",
"start-scan",
"upsert-deep-scan-worker",
].includes(args[0] ?? "")
? 300_000
: 30_000,
timeout,
},
);
if (workbenchInput !== undefined) {
Expand All @@ -2543,7 +2555,21 @@ async function executeWorkbench(
});
execution.child.stdin!.end(workbenchInput);
}
const { stdout } = await execution;
const { stdout } = await execution.catch((error: unknown) => {
if (
error instanceof Error &&
"killed" in error &&
error.killed === true &&
"signal" in error &&
error.signal === "SIGTERM"
) {
throw new Error(
`Codex Security workbench ${args[0]} timed out after ${timeout / 1000} seconds: ${error.message}`,
{ cause: error },
);
}
throw error;
});
const result = JSON.parse(stdout) as unknown;
if (!isJsonObject(result)) {
throw new Error("Codex Security workbench helper returned invalid JSON.");
Expand Down
59 changes: 12 additions & 47 deletions plugins/codex-security/mcp-app/src/artifact-io.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { canonicalDirectory } from "./artifact-context.js";
import { isRecord } from "./record.js";
import { randomUUID } from "node:crypto";
import { constants as fsConstants, promises as fs } from "node:fs";
import { promises as fs } from "node:fs";
import { dirname, isAbsolute, join, sep } from "node:path";

export interface DeepReducerWorkerContext {
Expand Down Expand Up @@ -249,19 +249,17 @@ export async function replaceArtifactText(
path: string,
content: string,
): Promise<void> {
await withArtifactLock(path, async () => {
const temporary = join(dirname(path), "." + randomUUID() + ".tmp");
try {
await fs.writeFile(temporary, content, {
encoding: "utf8",
mode: 0o600,
flag: "wx",
});
await fs.rename(temporary, path);
} finally {
await fs.rm(temporary, { force: true });
}
});
const temporary = join(dirname(path), "." + randomUUID() + ".tmp");
try {
await fs.writeFile(temporary, content, {
encoding: "utf8",
mode: 0o600,
flag: "wx",
});
await fs.rename(temporary, path);
} finally {
await fs.rm(temporary, { force: true });
}
}

export async function replaceArtifactJson(
Expand All @@ -281,39 +279,6 @@ export async function replaceArtifactJsonl(
await replaceArtifactText(path, content);
}

async function withArtifactLock(
path: string,
action: () => Promise<void>,
): Promise<void> {
const lockPath = path + ".lock";
let lock: fs.FileHandle | undefined;
for (let attempt = 0; attempt < 500; attempt += 1) {
try {
lock = await fs.open(
lockPath,
fsConstants.O_WRONLY |
fsConstants.O_CREAT |
fsConstants.O_EXCL |
fsConstants.O_NOFOLLOW,
0o600,
);
break;
} catch (error) {
if (!isNodeError(error) || error.code !== "EEXIST") throw error;
await new Promise<void>((done) => setTimeout(done, 20));
}
}
if (!lock) {
throw new Error("Timed out waiting for the artifact write lock.");
}
try {
await action();
} finally {
await lock.close();
await fs.rm(lockPath, { force: true });
}
}

function validateArtifactComponents(
components: readonly string[],
label: string,
Expand Down
Loading
Loading