mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-16 03:31:44 +01:00
fix(runner): bound ACPX instructions only where the sandbox delivers them (#21646)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The Runner prepares a private sandbox for each ACPX agent before it
opens the provider session
> - `validateProviderPolicy` in that sandbox stage refuses system
instructions over 32 KiB for every ACPX agent
> - Only Pi gets the text from the sandbox stage. Claude, Codex, Grok
and Antigravity do not use it there. The host accepts 256 KiB
> - An agent with a large instruction bundle fails every run at
`session.open`. The error says only `classification=admission_sandbox`,
so the operator cannot see the cause
> - This pull request applies the 32 KiB sandbox bound only to Pi, and
gives every instructions rejection its own closed admission code
> - The benefit is that Claude and Codex agents with large instructions
can start, and an over-bound rejection names its real cause
## Linked Issues or Issue Description
Fixes: #20814
Refs #14430 (this pull request added the 32 KiB check, with no stated
reason for the other providers)
Related: #21644 (also fixes #20814, but only for Claude, and does not
change the classification)
**What happened?**
Every run of a Claude ACPX agent failed with
`provider_session_open_rejected`. The message was `ACPX sidecar command
session.open was rejected (retryable=false,
classification=admission_sandbox)`. A reproduction in a sandbox from the
same image showed that all the filesystem steps of
`prepareAcpxRuntimeSandbox` succeed. The real cause: the agent's
instructions entry file was 54,734 bytes. That is more than the 32 KiB
check in `validateProviderPolicy`. The host bound (`boundedInstructions`
in `runtime-host.ts`) is 256 KiB. Agents with smaller instructions (12.7
KB) work.
**Expected behavior**
The sandbox stage must refuse only the text that it delivers. #14430
added the check when only Pi consumed `systemInstructions` in the
sandbox (as the `PAPERCLIP_PI_SYSTEM_INSTRUCTIONS` env var). The check
runs before any per-provider branch, so it also refuses Claude, Codex,
Grok and Antigravity. Those providers get the text in the session
request. When a bound refuses the text, the error must name the
instructions, not the sandbox.
**Steps to reproduce**
1. Create a Claude ACPX agent whose composed instructions are more than
32 KiB (for example, an `AGENTS.md` of 54 KB).
2. Start a run of the agent on the Paperclip Runner.
3. See that `session.open` fails with
`classification=admission_sandbox`.
**Paperclip version/commit**
`master` at 163d9f323c.
**Deployment mode**
Paperclip Runner with ACPX providers (any deployment).
Where each provider consumes `systemInstructions` today:
| Provider | Delivery | Bound |
| --- | --- | --- |
| Pi | `PAPERCLIP_PI_SYSTEM_INSTRUCTIONS` env var (sandbox) | 32 KiB in
`validateProviderPolicy` (kept) |
| Cursor | `PAPERCLIP_CURSOR_INSTRUCTIONS` env var (sandbox) | 32 KiB in
`cursorInstructionBinding` |
| Kimi | `PAPERCLIP_KIMI_INSTRUCTIONS` env var (sandbox) | 32 KiB in
`kimiInstructionBinding` |
| Copilot | `copilot-instructions.md` (host, after the sandbox stage) |
32 KiB in `composeCopilotSystemInstructions` and
`refreshCopilotSystemInstructions` |
| Claude, Codex, Grok, Antigravity | session request
(`systemPrompt.append` or the provider's own session admission) | host
bound, 256 KiB |
## What Changed
- `runtime-sandbox.ts`: `validateProviderPolicy` gets the agent. It
applies the 32 KiB bound only to Pi. The type and NUL checks stay for
all agents. Cursor, Kimi and Copilot keep their own 32 KiB checks.
- `admission-diagnostics.ts`: new closed admission code
`ACPX_ADMISSION_INSTRUCTIONS`, and `acpxInstructionsAdmissionError`,
which tags the error with that code. The tag wins over the stage code
that the host records later.
- The instructions bound and NUL rejections in `runtime-sandbox.ts`,
`runtime-host.ts` (`boundedInstructions`), `cursor-instructions.ts`,
`kimi-instructions.ts` and `copilot-profile.ts` use the new tagged
error. The messages contain no instruction text and no provider output.
- `acpx_sidecar_transport.rs`: `ACPX_ADMISSION_INSTRUCTIONS` maps to
`classification=admission_instructions`. The classification set stays
closed.
- `antigravity-connection-probe.ts`: the closed classification pattern
accepts `admission_instructions`.
- `copilot-installation.test.ts`: the v70 identity test compared two
historical source hashes with the live files. Since #18325, Runner
source changes do not advance profile identities. The test now pins the
hashes that the v70 record holds.
## Verification
- Red-green: the new tests failed on `master` (11 failed) and pass with
the fix.
- `cd packages/paperclip-runner && npx vitest run
src/drivers/acpx/runtime-sandbox.test.ts
src/drivers/acpx/runtime-host.test.ts
src/drivers/acpx/kimi-instructions.test.ts
src/drivers/acpx/cursor-instructions.test.ts
src/drivers/acpx/copilot-profile.test.ts
src/drivers/acpx/copilot-runtime-host.test.ts
src/drivers/acpx/pi-acp-runtime.test.ts src/cli`: 29 files, 489 tests
pass.
- New tests:
- The sandbox admits 54,734-byte instructions for Claude, Codex, Grok
and Antigravity, and does not put them in the launch environment.
- The host opens a Claude runtime with 54,734-byte instructions and
passes the full text to the provider.
- Pi and Cursor sandboxes refuse more than 32 KiB with
`ACPX_ADMISSION_INSTRUCTIONS`. NUL also gives that code.
- Through the host and the sidecar error mapping
(`acpxSidecarErrorCode`), oversized Pi (32 KiB + 1), Copilot (32 KiB +
1) and Claude (256 KiB + 1) instructions give
`ACPX_ADMISSION_INSTRUCTIONS` before the provider launches.
- The Rust classification test maps `ACPX_ADMISSION_INSTRUCTIONS` to
`admission_instructions`.
- The Antigravity probe logs `admission_instructions` as a closed
classification.
- `cargo test -p paperclip-runner-core --lib
classifies_only_allowlisted_internal_sidecar_failures` passes. `cargo
fmt --check` passes.
- `tsc -p packages/paperclip-runner/tsconfig.json --noEmit` passes.
- `cd server && npx vitest run
src/__tests__/antigravity-connection-probe.test.ts`: 11 tests pass.
- I did not do a live provider run. I did not run the full local suite.
CI supplies that coverage.
## Risks
- Low risk. The bound gets less strict only for providers that do not
get the text from the sandbox stage. Those providers stay under the host
bound (256 KiB). Pi, Cursor, Kimi and Copilot keep 32 KiB.
- An over-bound rejection now reports `admission_instructions` and not
`admission_sandbox` (or `admission_configuration` for Copilot). A
dashboard or alert that matches the old classification for this case
must also match the new one. Server code that checks a specific
classification does not check these values, except the Antigravity
probe, which this pull request updates.
- The NUL rejection message in `validateProviderPolicy` changes from
"exceed their bounded size" to "are invalid".
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
code execution.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ecdeed5e7e
commit
c603f591dc
12 files changed
+86
-14
No files matched your search
@@ -1297,6 +1297,7 @@ fn response_error_classification(error: &ResponseError) -> &'static str {
|
||||
"ACPX_ADMISSION_TOOL_BRIDGE" => return "admission_tool_bridge",
|
||||
"ACPX_ADMISSION_RUNTIME" => return "admission_runtime",
|
||||
"ACPX_ADMISSION_IDENTITY" => return "admission_identity",
|
||||
"ACPX_ADMISSION_INSTRUCTIONS" => return "admission_instructions",
|
||||
"ACPX_RUNTIME_PACKAGE_MISSING" => return "runtime_package_missing",
|
||||
"ACP_MODEL_UNSUPPORTED" => return "requested_model_unsupported",
|
||||
"AGENT_STARTUP_FAILED" => return "agent_startup_failed",
|
||||
@@ -1665,6 +1666,7 @@ mod tests {
|
||||
("ACPX_ADMISSION_SANDBOX", "admission_sandbox"),
|
||||
("ACPX_ADMISSION_CREDENTIAL", "admission_credential"),
|
||||
("ACPX_ADMISSION_RUNTIME", "admission_runtime"),
|
||||
("ACPX_ADMISSION_INSTRUCTIONS", "admission_instructions"),
|
||||
(
|
||||
"GROK_EFFORT_ACKNOWLEDGEMENT_MISSING",
|
||||
"grok_effort_acknowledgement_missing",
|
||||
|
||||
@@ -10,6 +10,7 @@ export const ACPX_ADMISSION_CODES = {
|
||||
tool_bridge: "ACPX_ADMISSION_TOOL_BRIDGE",
|
||||
runtime: "ACPX_ADMISSION_RUNTIME",
|
||||
identity: "ACPX_ADMISSION_IDENTITY",
|
||||
instructions: "ACPX_ADMISSION_INSTRUCTIONS",
|
||||
} as const;
|
||||
|
||||
const failures = new WeakMap<Error, keyof typeof ACPX_ADMISSION_CODES>();
|
||||
@@ -20,6 +21,12 @@ export function recordAcpxAdmissionFailure(error: unknown, stage: keyof typeof A
|
||||
return error;
|
||||
}
|
||||
|
||||
export function acpxInstructionsAdmissionError(message: string): Error {
|
||||
const error = new Error(message);
|
||||
failures.set(error, "instructions");
|
||||
return error;
|
||||
}
|
||||
|
||||
export function acpxAdmissionFailureCode(error: Error): string | undefined {
|
||||
const stage = failures.get(error);
|
||||
return stage === undefined ? undefined : ACPX_ADMISSION_CODES[stage];
|
||||
|
||||
@@ -177,9 +177,10 @@ describe("Copilot build-owned installation", () => {
|
||||
"admissionDiagnosticsSourceSha256", "agentProfileVersion", "grokAdmissionSourceSha256",
|
||||
"profileCompatibilitySourceSha256", "runtimeHostSourceSha256", "sidecarErrorSourceSha256",
|
||||
]);
|
||||
for (const [name, field] of [["admission-diagnostics.ts", "admissionDiagnosticsSourceSha256"], ["grok-effort.ts", "grokAdmissionSourceSha256"]]) {
|
||||
expect(current.declaration[field]).toBe(createHash("sha256").update(readFileSync(new URL(name!, import.meta.url))).digest("hex"));
|
||||
}
|
||||
expect(current.declaration).toMatchObject({
|
||||
admissionDiagnosticsSourceSha256: "df8f1aa4f2d1bc63b2635bdd09cb8165c8b7681ddcc2618435c7c08ca90475af",
|
||||
grokAdmissionSourceSha256: "f1e46cf2e1e36b7704bd797b678e3db8db2003f97bdb9d827cfa3d7662698777",
|
||||
});
|
||||
expect(isSupportedAcpxProfileVersion("copilot", 69)).toBe(true);
|
||||
await expect(verifyCopilotInstallation({ ...QUALIFIED_ACPX_PROFILES.copilot,
|
||||
agentProfileVersion: 69, commandDigest: prior.commandDigest })).rejects.toThrow("exact pinned");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { isAbsolute, resolve } from "node:path";
|
||||
import { acpxInstructionsAdmissionError } from "./admission-diagnostics.js";
|
||||
|
||||
/** This is an admission candidate, not a claim of live qualification. */
|
||||
export const COPILOT_VERSION = "1.0.88" as const;
|
||||
@@ -11,7 +12,7 @@ export const COPILOT_TASK_ORIENTATION_INSTRUCTIONS = "At the start of every task
|
||||
export function composeCopilotSystemInstructions(instructions: string): string {
|
||||
const composed = `${instructions}\n\n# Paperclip task orientation\n${COPILOT_TASK_ORIENTATION_INSTRUCTIONS}`;
|
||||
if (composed.includes("\0") || Buffer.byteLength(`${composed}\n`) > 32 * 1024) {
|
||||
throw new Error("Provider runtime instructions exceed their bounded size");
|
||||
throw acpxInstructionsAdmissionError("Provider runtime instructions exceed their bounded size");
|
||||
}
|
||||
return composed;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { acpxInstructionsAdmissionError } from "./admission-diagnostics.js";
|
||||
import { admitAcpxSessionContext } from "./session-context-admission.js";
|
||||
|
||||
const SCHEMA = "paperclip.cursor.instructions.v1";
|
||||
@@ -6,7 +7,7 @@ const MAX_BYTES = 32 * 1024;
|
||||
|
||||
export function cursorInstructionBinding(content: string): { payload: string; digest: string; byteLength: number } {
|
||||
if (typeof content !== "string" || content.includes("\0") || Buffer.byteLength(content) > MAX_BYTES) {
|
||||
throw new Error("Cursor instructions exceed their bounded size or contain NUL");
|
||||
throw acpxInstructionsAdmissionError("Cursor instructions exceed their bounded size or contain NUL");
|
||||
}
|
||||
const digest = `sha256:${createHash("sha256").update(content, "utf8").digest("hex")}`;
|
||||
return { payload: JSON.stringify({ schema: SCHEMA, content, digest }), digest, byteLength: Buffer.byteLength(content) };
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { acpxInstructionsAdmissionError } from "./admission-diagnostics.js";
|
||||
|
||||
const SCHEMA = "paperclip.kimi.instructions.v1";
|
||||
const MAX_BYTES = 32 * 1024;
|
||||
|
||||
export function kimiInstructionBinding(content: string) {
|
||||
if (typeof content !== "string" || content.includes("\0") || Buffer.from(content).toString("utf8") !== content || Buffer.byteLength(content) > MAX_BYTES) {
|
||||
throw new Error("Kimi Code instructions exceed their bounded size or contain NUL");
|
||||
throw acpxInstructionsAdmissionError("Kimi Code instructions exceed their bounded size or contain NUL");
|
||||
}
|
||||
const digest = `sha256:${createHash("sha256").update(content).digest("hex")}`;
|
||||
const byteLength = Buffer.byteLength(content);
|
||||
|
||||
@@ -256,6 +256,31 @@ describe("ACPX runtime host", () => {
|
||||
expect(openRuntime).not.toHaveBeenCalled();
|
||||
expect(fixture.commandClose).not.toHaveBeenCalled();
|
||||
});
|
||||
it("admits Claude instructions larger than the provider-delivered bound and passes them to the provider", async () => {
|
||||
const fixture = await hostFixture();
|
||||
const systemInstructions = "x".repeat(54_734);
|
||||
const openRuntime = vi.fn(async (_options: { systemInstructions?: string }) => runtimePort({ getStatus: async () => ({ models: { currentModelId: "claude-sonnet-5" } }) }));
|
||||
const host = await AcpxRuntimeHost.open({ ...fixture.options, agent: "claude", model: "claude-sonnet-5", permissionMode: "approve-all",
|
||||
providerPolicy: { readOnly: false }, systemInstructions }, fixture.dependencies({ openRuntime }));
|
||||
try {
|
||||
expect(openRuntime).toHaveBeenCalledOnce();
|
||||
expect(openRuntime.mock.calls[0]![0].systemInstructions).toBe(systemInstructions);
|
||||
} finally { await host.close({ reason: "instructions admitted" }); }
|
||||
});
|
||||
it.each([
|
||||
{ agent: "pi" as const, model: "anthropic/claude-sonnet-5", bytes: 32 * 1024 + 1, extra: { piThinkingLevel: "low" as const } },
|
||||
{ agent: "copilot" as const, model: "gpt-5.6-sol", bytes: 32 * 1024 + 1, extra: { environment: { COPILOT_GITHUB_TOKEN: "synthetic-test-token" } } },
|
||||
{ agent: "claude" as const, model: "claude-sonnet-5", bytes: 256 * 1024 + 1, extra: {} },
|
||||
])("reports oversized $agent instructions as instructions admission before launch", async ({ agent, model, bytes, extra }) => {
|
||||
const fixture = await hostFixture();
|
||||
const openRuntime = vi.fn(async () => runtimePort());
|
||||
const failure = await AcpxRuntimeHost.open({ ...fixture.options, agent, model, permissionMode: "approve-all",
|
||||
providerPolicy: { readOnly: false }, systemInstructions: "x".repeat(bytes), ...extra }, fixture.dependencies({ openRuntime })).catch(error => error);
|
||||
expect(failure).toBeInstanceOf(Error);
|
||||
expect(failure.message).toMatch(/instructions exceed their bounded size/);
|
||||
expect(acpxSidecarErrorCode(failure)).toBe("ACPX_ADMISSION_INSTRUCTIONS");
|
||||
expect(openRuntime).not.toHaveBeenCalled();
|
||||
});
|
||||
it.each(["installation", "sandbox", "credential", "runtime"] as const)("retains the failed %s admission stage through the sidecar boundary", async stage => {
|
||||
const fixture = await hostFixture();
|
||||
const failure = new Error("private-token-canary");
|
||||
|
||||
@@ -2,7 +2,7 @@ import { retainAcpxCredentialRefresh } from "./credential-refresh.js";
|
||||
import type { AcpxTurnDispatchJournal } from "./turn-dispatch-journal.js";
|
||||
import { assertAcpxExecutionAdmission, parseAcpxCandidateStartupAdmission, type AcpxCandidateStartupAdmission } from "./candidate-admission.js";
|
||||
import { resolveGrokDisableWebSearch } from "./grok-web-search.js";
|
||||
import { recordAcpxAdmissionFailure, type ACPX_ADMISSION_CODES } from "./admission-diagnostics.js";
|
||||
import { acpxInstructionsAdmissionError, recordAcpxAdmissionFailure, type ACPX_ADMISSION_CODES } from "./admission-diagnostics.js";
|
||||
import { composeCopilotSystemInstructions } from "./copilot-profile.js";
|
||||
import { resolveClaudeEffort } from "./claude-effort.js";
|
||||
import { resolveGrokEffort } from "./grok-effort.js";
|
||||
@@ -1418,7 +1418,7 @@ async function cleanupRuntimeResources(
|
||||
function boundedInstructions(value: string | undefined): string {
|
||||
const instructions = value ?? "";
|
||||
if (Buffer.byteLength(instructions) > 256 * 1024) {
|
||||
throw new Error("ACPX system instructions exceed their bounded size");
|
||||
throw acpxInstructionsAdmissionError("ACPX system instructions exceed their bounded size");
|
||||
}
|
||||
return instructions;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import { dirname, join } from "node:path";
|
||||
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
import { acpxSidecarErrorCode } from "../../cli/acpx-sidecar-input.js";
|
||||
import { resolveQualifiedAcpxProfile } from "./qualified-profiles.js";
|
||||
import { createAcpxRecoveryBinding } from "./recovery-identity.js";
|
||||
import {
|
||||
@@ -370,6 +371,27 @@ describe("ACPX runtime sandbox", () => {
|
||||
await expect(prepareAcpxRuntimeSandbox({ binding: fixture.binding, agent: "pi", providerPolicy: { readOnly: false, systemInstructions: "x".repeat(32 * 1024 + 1) } })).rejects.toThrow("bounded size");
|
||||
});
|
||||
|
||||
it.each(["claude", "codex", "grok", "antigravity"] as const)("admits %s instructions that the sandbox does not deliver, whatever their size", async (agent) => {
|
||||
const fixture = await sandboxFixture(agent);
|
||||
const systemInstructions = "x".repeat(54_734);
|
||||
const sandbox = await prepareAcpxRuntimeSandbox({ binding: fixture.binding, agent, providerPolicy: { readOnly: false, systemInstructions } });
|
||||
expect(Object.values(sandbox.launchEnvironment).some(value => value?.includes(systemInstructions))).toBe(false);
|
||||
});
|
||||
|
||||
it.each(["pi", "cursor"] as const)("rejects oversized %s instructions with the instructions admission code", async (agent) => {
|
||||
const fixture = await sandboxFixture(agent);
|
||||
const failure = await prepareAcpxRuntimeSandbox({ binding: fixture.binding, agent, providerPolicy: { readOnly: false, systemInstructions: "x".repeat(32 * 1024 + 1) } }).catch(error => error);
|
||||
expect(failure).toBeInstanceOf(Error);
|
||||
expect(failure.message).toMatch(/bounded size/);
|
||||
expect(acpxSidecarErrorCode(failure)).toBe("ACPX_ADMISSION_INSTRUCTIONS");
|
||||
});
|
||||
|
||||
it("rejects instructions containing NUL with the instructions admission code", async () => {
|
||||
const fixture = await sandboxFixture("claude");
|
||||
const failure = await prepareAcpxRuntimeSandbox({ binding: fixture.binding, agent: "claude", providerPolicy: { readOnly: false, systemInstructions: "a\0b" } }).catch(error => error);
|
||||
expect(acpxSidecarErrorCode(failure)).toBe("ACPX_ADMISSION_INSTRUCTIONS");
|
||||
});
|
||||
|
||||
it("re-prepares and re-synchronizes an existing private sandbox", async () => {
|
||||
const fixture = await sandboxFixture("claude");
|
||||
const first = await prepareAcpxRuntimeSandbox({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { kimiManagedConfiguration } from "./kimi-config.js";
|
||||
import { kimiInstructionBinding } from "./kimi-instructions.js";
|
||||
import { acpxInstructionsAdmissionError } from "./admission-diagnostics.js";
|
||||
import { AGENT_OBSERVABILITY_ENV_KEYS, codexObservabilityToml } from "../agent-observability.js";
|
||||
import { piProviderConfiguration } from "./pi-provider-config.js";
|
||||
import { CERTIFICATE_ENVIRONMENT_KEYS, configuredEnvironmentKeys } from "../../configured-environment.js";
|
||||
@@ -47,6 +48,7 @@ const PRIVATE_DIRECTORY_MODE = 0o700;
|
||||
const PRIVATE_FILE_MODE = 0o600;
|
||||
const MAX_SANDBOX_ENVIRONMENT_BYTES = 512 * 1024;
|
||||
const MAX_WORKSPACE_RECORD_BYTES = 64 * 1024;
|
||||
const MAX_PROVIDER_INSTRUCTIONS_BYTES = 32 * 1024;
|
||||
|
||||
export interface AcpxRuntimeSandbox {
|
||||
root: string;
|
||||
@@ -352,7 +354,7 @@ export async function prepareAcpxRuntimeSandbox(input: {
|
||||
if (input.agent === "pi" && (input.providerPolicy === undefined || typeof input.providerPolicy.readOnly !== "boolean")) {
|
||||
throw new Error("Pi admission requires an explicit task execution policy");
|
||||
}
|
||||
const policy = await validateProviderPolicy(input.providerPolicy);
|
||||
const policy = await validateProviderPolicy(input.providerPolicy, input.agent);
|
||||
const expectedRoot = input.binding.runtimeRoot;
|
||||
if (resolve(expectedRoot) !== expectedRoot) {
|
||||
throw new Error("ACPX runtime root must be an absolute normalized path");
|
||||
@@ -616,7 +618,7 @@ export async function prepareAcpxRuntimeSandbox(input: {
|
||||
};
|
||||
}
|
||||
|
||||
async function validateProviderPolicy(policy: AcpxProviderRuntimePolicy | undefined): Promise<{
|
||||
async function validateProviderPolicy(policy: AcpxProviderRuntimePolicy | undefined, agent: QualifiedAcpxAgent): Promise<{
|
||||
readOnly: boolean; readRoots: string[]; protectedPaths: string[]; systemInstructions: string;
|
||||
}> {
|
||||
if (policy !== undefined && typeof policy.readOnly !== "boolean") throw new Error("Provider task execution policy is invalid");
|
||||
@@ -629,7 +631,8 @@ async function validateProviderPolicy(policy: AcpxProviderRuntimePolicy | undefi
|
||||
}));
|
||||
};
|
||||
const systemInstructions = policy?.systemInstructions ?? "";
|
||||
if (typeof systemInstructions !== "string" || systemInstructions.includes("\0") || Buffer.byteLength(systemInstructions) > 32 * 1024) throw new Error("Provider runtime instructions exceed their bounded size");
|
||||
if (typeof systemInstructions !== "string" || systemInstructions.includes("\0")) throw acpxInstructionsAdmissionError("Provider runtime instructions are invalid");
|
||||
if (agent === "pi" && Buffer.byteLength(systemInstructions) > MAX_PROVIDER_INSTRUCTIONS_BYTES) throw acpxInstructionsAdmissionError("Provider runtime instructions exceed their bounded size");
|
||||
return {
|
||||
readOnly: policy?.readOnly ?? true,
|
||||
readRoots: await paths(policy?.readRoots, true),
|
||||
@@ -697,8 +700,8 @@ export async function refreshCopilotSystemInstructions(
|
||||
sandbox: Pick<AcpxRuntimeSandbox, "agentHomeDirectory">,
|
||||
instructions: string,
|
||||
): Promise<void> {
|
||||
if (instructions.includes("\0") || Buffer.byteLength(instructions) > 32 * 1024) {
|
||||
throw new Error("Provider runtime instructions exceed their bounded size");
|
||||
if (instructions.includes("\0") || Buffer.byteLength(instructions) > MAX_PROVIDER_INSTRUCTIONS_BYTES) {
|
||||
throw acpxInstructionsAdmissionError("Provider runtime instructions exceed their bounded size");
|
||||
}
|
||||
// Native Copilot reloads this file on session/load. Empty text clears old text.
|
||||
await writePrivateFile(
|
||||
|
||||
@@ -60,6 +60,15 @@ describe("Google Antigravity setup admission", () => {
|
||||
expect(JSON.stringify(result)).not.toMatch(/reconnect|sign in/i);
|
||||
});
|
||||
|
||||
it("logs the closed instructions admission classification without treating it as an installation failure", () => {
|
||||
const error = new Error("fixture-private-token");
|
||||
Object.defineProperty(error, "runnerCommandResult", { value: { commandType: "session.open", status: "failed",
|
||||
result: { code: "command_execution_failed", message: "failed to start ACPX provider: ACPX sidecar command session.open was rejected (retryable=false, classification=admission_instructions)" } } });
|
||||
expect(antigravityConnectionProbeFailure("company-1", error).checks[0].code).toBe("antigravity_admission_failed");
|
||||
expect(mocks.warn).toHaveBeenCalledExactlyOnceWith(expect.objectContaining({ commandCode: "command_execution_failed",
|
||||
classification: "admission_instructions", retryable: false }), "Antigravity runtime admission check failed");
|
||||
});
|
||||
|
||||
it("does not parse outer serialized errors or copy unknown codes, classes or native output", () => {
|
||||
const privateValue = "fixture-private-token /private/selected-google-home";
|
||||
for (const native of [{ code: privateValue, message: privateValue }, { code: "command_execution_failed",
|
||||
|
||||
@@ -21,7 +21,7 @@ export function antigravityConnectionProbeFailure(companyId: string, error: unkn
|
||||
const command = asRecord(asRecord(error)?.runnerCommandResult);
|
||||
const result = command?.commandType === "session.open" && command.status === "failed" ? asRecord(command.result) : null;
|
||||
const admission = result?.code === "command_execution_failed" && typeof result.message === "string" && result.message.length <= 2_048
|
||||
? /^failed to start ACPX provider: ACPX sidecar command (?:initialize|session\.open) was rejected \(retryable=(true|false), classification=(admission_(?:binding|installation|sandbox|credential|configuration|skills|command|tool_bridge|runtime|identity))\)$/.exec(result.message)
|
||||
? /^failed to start ACPX provider: ACPX sidecar command (?:initialize|session\.open) was rejected \(retryable=(true|false), classification=(admission_(?:binding|installation|sandbox|credential|configuration|skills|command|tool_bridge|runtime|identity|instructions))\)$/.exec(result.message)
|
||||
: null;
|
||||
const installation = admission?.[2] === "admission_installation";
|
||||
const code = installation ? "antigravity_installation_check_failed" : "antigravity_admission_failed";
|
||||
|
||||
Reference in new issue
Block a user