Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/protocols/codex-operating-layer.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"records Platform observations for cached dynamic read callbacks",
"lets Codex dynamic tool callbacks wait for user approval instead of auto-denying",
"preserves Platform joins for denied Codex dynamic callbacks",
"returns workflow-state errors from cached dynamic callbacks",
"returns workflow-state errors from repeated dynamic callbacks",
"withTimeout",
"action_approval_required",
"ActionApprovalService(\"prompt\")",
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"ci:plan": "node scripts/plan-ci-checks.mjs",
"pr:ready": "node scripts/pr-ready-to-merge.mjs",
"pr:feedback": "node scripts/pr-feedback-audit.mjs",
"verify:runtime-deps": "node scripts/check-runtime-deps.js && node scripts/check-docker-runtime-workspaces.mjs",
"verify:runtime-deps": "node scripts/check-runtime-deps.js && node scripts/check-docker-runtime-workspaces.mjs && node scripts/check-packed-bundled-workspaces.mjs",
"tui": "npm run cli",
"verify": "npm run format && npm run lint && npm run test && npm run build && npm run smoke && npm run telemetry:report",
"smoke": "node scripts/smoke-cli.js",
Expand Down Expand Up @@ -161,8 +161,6 @@
"@aws-sdk/client-bedrock-runtime": "^3.1020.0",
"@crosscopy/clipboard": "^0.2.8",
"@daytonaio/sdk": "^0.155.0",
"@evalops/contracts": "^0.10.20",
"@evalops/tui": "^0.10.20",
"@modelcontextprotocol/sdk": "^1.29.0",
"@opentelemetry/api": "^1.9.1",
"@opentelemetry/auto-instrumentations-node": "^0.75.0",
Expand Down
86 changes: 86 additions & 0 deletions scripts/check-packed-bundled-workspaces.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env node
// @ts-check

import { spawnSync } from "node:child_process";
import { mkdtempSync, readdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import {
getWorkspacePackages,
loadRootPackage,
} from "./workspace-utils.js";

const rootPackage = loadRootPackage();
const bundled = Array.isArray(rootPackage.bundleDependencies)
? rootPackage.bundleDependencies
: [];
const workspacePackages = await getWorkspacePackages(rootPackage);
const workspaceNames = new Set(
workspacePackages.map((workspacePackage) => workspacePackage.name),
);
const bundledWorkspaceNames = bundled.filter((name) => workspaceNames.has(name));

if (bundledWorkspaceNames.length === 0) {
console.log("No bundled workspace packages declared.");
process.exit(0);
}

const packDir = mkdtempSync(join(tmpdir(), "maestro-packed-workspaces-"));

try {
const pack = spawnSync(
"npm",
["pack", "--silent", "--pack-destination", packDir],
{
cwd: process.cwd(),
encoding: "utf-8",
stdio: ["ignore", "pipe", "pipe"],
},
);
if (pack.status !== 0) {
console.error("npm pack failed while checking bundled workspaces.");
if (pack.stdout) console.error(pack.stdout.trim());
if (pack.stderr) console.error(pack.stderr.trim());
process.exit(pack.status ?? 1);
}

const tarballs = readdirSync(packDir).filter((file) => file.endsWith(".tgz"));
if (tarballs.length !== 1) {
console.error(
`Expected npm pack to create one tarball, found ${tarballs.length}.`,
);
process.exit(1);
}

const tarballPath = join(packDir, tarballs[0]);
const listing = spawnSync("tar", ["-tzf", tarballPath], {
encoding: "utf-8",
stdio: ["ignore", "pipe", "pipe"],
});
if (listing.status !== 0) {
console.error(`Failed to inspect packed tarball ${tarballs[0]}.`);
if (listing.stderr) console.error(listing.stderr.trim());
process.exit(listing.status ?? 1);
}

const entries = new Set(listing.stdout.split(/\r?\n/).filter(Boolean));
const missing = bundledWorkspaceNames.filter(
(name) => !entries.has(`package/node_modules/${name}/package.json`),
);
if (missing.length > 0) {
console.error("Packed tarball is missing bundled workspace packages:");
for (const name of missing.sort()) {
console.error(`- ${name}`);
}
process.exit(1);
}

console.log(
`Verified packed tarball includes bundled workspaces: ${bundledWorkspaceNames
.slice()
.sort()
.join(", ")}.`,
);
} finally {
rmSync(packDir, { recursive: true, force: true });
}
83 changes: 8 additions & 75 deletions src/agent/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,6 @@
["status", ["path", "paths", "cwd"]],
]);

const GIT_SCOPED_REUSABLE_TOOL_RESULT_KEY_PREFIX = "git:";
const RUN_SCOPED_REUSABLE_TOOL_RESULT_KEY_PREFIX = "run:";

const REQUIRED_REPO_PATH_ARGUMENT_TOOLS = new Set(["read", "ls", "list"]);

function collectStringValues(value: unknown): string[] {
Expand Down Expand Up @@ -308,28 +305,24 @@
}
}

function isToolCallIncludingIgnoredPaths(toolCall: ToolCall): boolean {
const toolName = toolCall.name.toLowerCase();
function isStatusCallIncludingIgnored(toolCall: ToolCall): boolean {
if (toolCall.name.toLowerCase() !== "status") {
return false;
}
const args = toolCall.arguments;
if (!args || typeof args !== "object" || Array.isArray(args)) {
return false;
}
const record = args as Record<string, unknown>;
if (toolName === "status") {
return record.includeIgnored === true || record.include_ignored === true;
}
if (toolName === "search" || toolName === "parallel_ripgrep") {
return record.useGitIgnore === false || record.use_git_ignore === false;
}
return false;
return record.includeIgnored === true || record.include_ignored === true;
}

Check failure on line 318 in src/agent/transport.ts

View workflow job for this annotation

GitHub Actions / unresolved-review-threads / unresolved-review-threads

unresolved P1 review thread

Comment on lines +308 to 318

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exclude no-ignore searches from reusable result caching

This refactor now treats only status calls as “ignored-path” reads, so search/parallel_ripgrep with useGitIgnore: false can be cached as git-snapshot-reusable. That is unsafe because the snapshot key in computeReusableToolResultSnapshot is based on git-tracked state plus untracked non-ignored files (git status --untracked-files=all and ls-files --exclude-standard), so edits under gitignored paths do not change the snapshot. In practice, repeated search calls that intentionally include ignored files can return stale cached results across turns.

Useful? React with 👍 / 👎.


function hasRepoScopedReusableArguments(
toolCall: ToolCall,
cwd: string,
): boolean {
const toolName = toolCall.name.toLowerCase();
if (isToolCallIncludingIgnoredPaths(toolCall)) {
if (isStatusCallIncludingIgnored(toolCall)) {
return false;
}
const argumentNames = REPO_PATH_ARGUMENTS_BY_TOOL.get(toolName) ?? [];
Expand Down Expand Up @@ -475,26 +468,10 @@
"reusableToolResultCwd" in tools
? tools.reusableToolResultCwd
: process.cwd();
if (!tool || tool.annotations?.destructiveHint === true) {
return undefined;
}
if (!isReadOnlyTool(tool.name, tool.annotations, tool.source)) {
if (!tool || !isGitSnapshotReusableToolCall(tool, toolCall, cwd)) {
return undefined;
}
const toolName = tool.name.toLowerCase();
const cacheKey = `${toolCall.name}:${stableStringify(toolCall.arguments)}`;
if (isGitSnapshotReusableToolCall(tool, toolCall, cwd)) {
return `${GIT_SCOPED_REUSABLE_TOOL_RESULT_KEY_PREFIX}${cacheKey}`;
}
if (
tool.source !== undefined ||
GIT_SNAPSHOT_REUSABLE_TOOL_NAMES.has(toolName) ||
tool.annotations?.openWorldHint === true ||
tool.executionLocation === "client"
) {
return undefined;
}
return `${RUN_SCOPED_REUSABLE_TOOL_RESULT_KEY_PREFIX}${cacheKey}`;
return `${toolCall.name}:${stableStringify(toolCall.arguments)}`;
}

function isReadOnlyToolCallForCacheInvalidation(
Expand Down Expand Up @@ -638,43 +615,6 @@
cacheGeneration.value += 1;
}

function clearRunScopedReusableToolResultState(
cache: Map<string, ReusableToolResultEntry>,
pending: Map<string, Promise<ToolExecutionOutcome>>,
policyCheckedKeys: Set<string>,
pendingSafetyChecks: Map<string, number>,
cacheGeneration: ReusableToolResultCacheGeneration,
): void {
let cleared = false;
for (const key of cache.keys()) {
if (key.startsWith(RUN_SCOPED_REUSABLE_TOOL_RESULT_KEY_PREFIX)) {
cache.delete(key);
cleared = true;
}
}
for (const key of pending.keys()) {
if (key.startsWith(RUN_SCOPED_REUSABLE_TOOL_RESULT_KEY_PREFIX)) {
pending.delete(key);
cleared = true;
}
}
for (const key of policyCheckedKeys) {
if (key.startsWith(RUN_SCOPED_REUSABLE_TOOL_RESULT_KEY_PREFIX)) {
policyCheckedKeys.delete(key);
cleared = true;
}
}
for (const key of pendingSafetyChecks.keys()) {
if (key.startsWith(RUN_SCOPED_REUSABLE_TOOL_RESULT_KEY_PREFIX)) {
pendingSafetyChecks.delete(key);
cleared = true;
}
}
if (cleared) {
cacheGeneration.value += 1;
}
}

function invalidateReusableToolResultsAfterMutation(
toolCall: ToolCall,
tools: ToolDefinitionLookup | ToolMetadataCache,
Expand Down Expand Up @@ -1180,13 +1120,6 @@
this.pendingReusableToolSafetyChecks;
const reusableToolResultCacheGeneration =
this.reusableToolResultCacheGeneration;
clearRunScopedReusableToolResultState(
reusableToolResults,
pendingReusableToolResults,
policyCheckedReusableToolResultKeys,
pendingReusableToolSafetyChecks,
reusableToolResultCacheGeneration,
);
const pendingDynamicToolExecutions: PendingExecution[] = [];
const platformToolExecutionBridge = resolvePlatformToolExecutionBridge(
this.options.platformToolExecutionBridge,
Expand Down
Loading
Loading