mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 01:39:51 +01:00
fix(runner): a sidecar session.open refusal keeps its code and reason
The live /swarm failure was undiagnosable: the Runner composed "classification=unclassified" and dropped the sidecar's code and message, so nothing in run events, logs or state said why. - The Runner classifies the typed /swarm refusals (antigravity_swarm_*), candidate_admission_invalid and sidecar_request_invalid instead of "unclassified". - A rejected command keeps the sidecar's own code, and its redacted, bounded message when no typed provider cause was sent, as `sidecarRejection` on the failed command result (run error). The rejection text stays closed; provider text still travels only in providerFailure. - The server settles a typed /swarm refusal at session.open as antigravity_swarm_unavailable (waits for the user, no same-run retry) and a request-contract or grant refusal as a startup rejection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1a97dfe821
commit
3d4cf276fa
9 files changed
+178
-8
No files matched your search
@@ -16089,6 +16089,21 @@ describe("native session bounded recovery", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("settles a typed swarm or request-contract refusal at session.open without same-run retries", () => {
|
||||
const rejected = (classification: string, extra = "") => new Error(`PRP command session.open failed: {"commandId":"command_prp_00000002","commandType":"session.open","controllerSeq":2,"result":{"code":"command_execution_failed","message":"failed to start ACPX provider: ACPX sidecar command session.open was rejected (retryable=false, classification=${classification})"${extra}},"status":"failed"}`);
|
||||
for (const classification of ["antigravity_swarm_unavailable", "antigravity_swarm_sign_in_required", "antigravity_swarm_receipt_mismatch"]) {
|
||||
expect(nativeSessionFailureSourceCode(rejected(classification))).toBe("antigravity_swarm_unavailable");
|
||||
expect(nativeSessionFailureDisposition(1, new Date(), "antigravity_swarm_unavailable")).toEqual({
|
||||
phase: "terminal_failure", failureCode: "antigravity_swarm_unavailable", nextAttemptAt: null });
|
||||
}
|
||||
// The live /swarm failure: the provider process refused the request by its own contract.
|
||||
const skew = rejected("sidecar_request_invalid", `,"sidecarRejection":{"command":"session.open","code":"ACPX_SIDECAR_REQUEST_INVALID","message":"mode is supported only for Cursor"}`);
|
||||
expect(nativeSessionFailureSourceCode(skew)).toBe(NATIVE_PROVIDER_STARTUP_REJECTED);
|
||||
expect(skew.message).toContain("mode is supported only for Cursor");
|
||||
expect(nativeSessionFailureSourceCode(rejected("candidate_admission_invalid"))).toBe(NATIVE_PROVIDER_STARTUP_REJECTED);
|
||||
expect(nativeSessionFailureSourceCode(rejected("unclassified"))).toBe("provider_session_open_rejected");
|
||||
});
|
||||
|
||||
it("rests a run whose Runner refused its commands as out of sequence with a precise code and a Retry", () => {
|
||||
const refused = new Error(`PRP command session.open rejected: {"commandId":"c","controllerSeq":11,"commandType":"session.open","status":"rejected","result":{"code":"controller_sequence_mismatch","message":"controller sequence must be contiguous: expected 13, received 11","expectedControllerSeq":13,"receivedControllerSeq":11}}`);
|
||||
expect(nativeSessionFailureSourceCode(refused)).toBe(NATIVE_CONTROLLER_JOURNAL_BEHIND_RUNNER);
|
||||
|
||||
@@ -118,6 +118,7 @@ import { readLocalAiCredentialFile } from "../local-ai-credential-file.js";
|
||||
import { prepareGrokRunnerCredentials } from "./grok-runner-credentials.js";
|
||||
import { AntigravityConnectionConfigurationError } from "./antigravity-connection-policy.js";
|
||||
import { antigravityCandidateTarget, antigravityForcesSameSessionRecovery, antigravityReleasePending, antigravityUsesRunScopedState, assertAntigravityExecutionAdmissible } from "./antigravity-release.js";
|
||||
import { ANTIGRAVITY_SWARM_UNAVAILABLE } from "../antigravity-swarm-refusal.js";
|
||||
import { bindAntigravityCredentialTurn, bindAntigravityTransportRetirement, prepareAntigravityRunnerCredentials } from "./antigravity-runner-credentials.js";
|
||||
import { copyBackGrokAuth } from "@paperclipai/adapter-grok-local/server";
|
||||
|
||||
@@ -9090,7 +9091,8 @@ export function nativeSessionFailureDisposition(
|
||||
sourceFailureCode === NATIVE_PROVIDER_STARTUP_REJECTED ||
|
||||
sourceFailureCode === NATIVE_CONTROLLER_JOURNAL_BEHIND_RUNNER ||
|
||||
sourceFailureCode === NATIVE_SANDBOX_DISK_FULL ||
|
||||
sourceFailureCode === NATIVE_RUN_PAYLOAD_TOO_LARGE;
|
||||
sourceFailureCode === NATIVE_RUN_PAYLOAD_TOO_LARGE ||
|
||||
sourceFailureCode === ANTIGRAVITY_SWARM_UNAVAILABLE;
|
||||
const permissionDeclined = sourceFailureCode === "native_permission_declined";
|
||||
const exhausted = permanentFailure || permissionDeclined || attempt >= 3;
|
||||
return {
|
||||
@@ -9324,6 +9326,7 @@ function classifyNativeSessionFailure(
|
||||
| typeof NATIVE_CURRENT_WAKE_COMMENTS_UNREAD
|
||||
| typeof NATIVE_CURRENT_WAKE_COMMENTS_CHANGED_AFTER_READ
|
||||
| "provider_session_open_rejected"
|
||||
| typeof ANTIGRAVITY_SWARM_UNAVAILABLE
|
||||
| "provider_session_open_timeout"
|
||||
| "runner_task_admission_rejected"
|
||||
| "runner_ingress_access_rejected"
|
||||
@@ -9453,6 +9456,14 @@ function classifyNativeSessionFailure(
|
||||
if (/classification=(?:requested_model_unsupported|grok_model_mismatch)\)/.test(message)) {
|
||||
return "native_provider_model_rejected";
|
||||
}
|
||||
// The swarm route refused this /swarm (typed, with its own plain message).
|
||||
// Every automatic attempt would refuse the same way, so it waits for the user.
|
||||
if (/classification=antigravity_swarm_[a-z_]+\)/.test(message)) return ANTIGRAVITY_SWARM_UNAVAILABLE;
|
||||
// The Runner and its provider process disagree on the request contract, or the
|
||||
// operator grant does not cover this execution: the same run cannot open again.
|
||||
if (/classification=(?:sidecar_request_invalid|candidate_admission_invalid)\)/.test(message)) {
|
||||
return NATIVE_PROVIDER_STARTUP_REJECTED;
|
||||
}
|
||||
if (deterministicProviderStartupFailure(error)) return NATIVE_PROVIDER_STARTUP_REJECTED;
|
||||
return "provider_session_open_rejected";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user