Merge origin/master into feat/antigravity-swarm-command

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* origin/master:
  refactor(plugin-sdk): remove archivedState from the resume result (#22443)
  refactor(runner): let the provider decide whether a released Runner relaunches (#22442)
  fix(connections): drop MCP wording and the MCP guide link from Google Workspace setup (#22793)
  fix(ui): defer the Connectors announcement until a return visit (#22790)
  fix(connections): show only the privacy policy link in the Google Workspace picker (#22795)
  Add count, newest-first and lean run reads to customer-success inspection (#22781)
  fix(connections): keep a finished setup checklist on screen when the app refreshes queries (#22715)
  perf(ci): Phase 2 PR CI under 4 minutes (dynamic workers, fast E2E boot, typecheck overlap, test-budget gate) (#22729)
  fix(plan-mode): open the plan review card when a Plan-mode run settles without one (#22732)
This commit is contained in:
DottaandClaude Opus 5.5 committed 2026-11-24 13:21:12 -06:00
commit 3cbfa500f4
142 files changed
+5552 -11636

No files matched your search

+28 -4
View File
@@ -203,11 +203,30 @@ async function stopEmbeddedPostgresBounded(
// a fresh port and a fresh data directory, so a transient collision clears.
const EMBEDDED_POSTGRES_START_MAX_ATTEMPTS = 5;
export type EmbeddedPostgresTestDatabaseOptions = {
maxConnections?: number;
};
function applyPostgresConfigOverrides(dataDir: string, options?: EmbeddedPostgresTestDatabaseOptions): void {
const maxConnections = options?.maxConnections;
if (!maxConnections || !Number.isInteger(maxConnections) || maxConnections < 1) {
return;
}
const configPath = path.join(dataDir, "postgresql.conf");
if (!fs.existsSync(configPath)) {
return;
}
fs.appendFileSync(configPath, `\nmax_connections = ${maxConnections}\n`, "utf8");
}
// Start one embedded Postgres cluster with a bounded retry. Each attempt gets a
// fresh port and a fresh data directory. On a failed attempt we stop the cluster
// and remove its data directory before the next attempt. After the last attempt
// we throw with the real Postgres output so the failure is loud and diagnosable.
async function startEmbeddedPostgresWithRetry(tempDirPrefix: string): Promise<{
async function startEmbeddedPostgresWithRetry(
tempDirPrefix: string,
options?: EmbeddedPostgresTestDatabaseOptions,
): Promise<{
port: number;
dataDir: string;
instance: EmbeddedPostgresInstance;
@@ -218,6 +237,7 @@ async function startEmbeddedPostgresWithRetry(tempDirPrefix: string): Promise<{
const created = await createEmbeddedPostgresTestInstance(tempDirPrefix);
try {
await created.instance.initialise();
applyPostgresConfigOverrides(created.dataDir, options);
await created.instance.start();
return { port: created.port, dataDir: created.dataDir, instance: created.instance };
} catch (error) {
@@ -542,6 +562,7 @@ function resetTemplateDirCache(): void {
async function startEmbeddedPostgresFromTemplateWithRetry(
templateDir: string,
tempDirPrefix: string,
options?: EmbeddedPostgresTestDatabaseOptions,
): Promise<{ port: number; dataDir: string; instance: EmbeddedPostgresInstance }> {
let lastError = new Error("embedded Postgres startup from template failed");
@@ -556,6 +577,7 @@ async function startEmbeddedPostgresFromTemplateWithRetry(
fs.cpSync(templateDir, dataDir, { recursive: true });
// Postgres refuses a data directory that is group or world accessible.
fs.chmodSync(dataDir, 0o700);
applyPostgresConfigOverrides(dataDir, options);
created = await createEmbeddedPostgresTestInstanceAt(dataDir);
await created.instance.start();
return { port: created.port, dataDir: rootDir, instance: created.instance };
@@ -640,12 +662,13 @@ export async function getEmbeddedPostgresTestSupport(): Promise<EmbeddedPostgres
// fresh path so the cache can only make a suite faster, never fail it.
async function startEmbeddedPostgresClusterForSuite(
tempDirPrefix: string,
options?: EmbeddedPostgresTestDatabaseOptions,
): Promise<{ port: number; dataDir: string; instance: EmbeddedPostgresInstance; mode: EmbeddedPostgresStartMode }> {
const templateDir = await getEmbeddedPostgresTemplateDir();
if (templateDir !== null) {
try {
const started = await startEmbeddedPostgresFromTemplateWithRetry(templateDir, tempDirPrefix);
const started = await startEmbeddedPostgresFromTemplateWithRetry(templateDir, tempDirPrefix, options);
return { ...started, mode: "template" };
} catch (error) {
if (error instanceof TestPostgresShutdownError) throw error;
@@ -663,16 +686,17 @@ async function startEmbeddedPostgresClusterForSuite(
// The bounded retry hardens the cluster start against the port race. It throws
// with the real Postgres output if every attempt fails.
const started = await startEmbeddedPostgresWithRetry(tempDirPrefix);
const started = await startEmbeddedPostgresWithRetry(tempDirPrefix, options);
return { ...started, mode: "fresh" };
}
export async function startEmbeddedPostgresTestDatabase(
tempDirPrefix: string,
options?: EmbeddedPostgresTestDatabaseOptions,
): Promise<EmbeddedPostgresTestDatabase> {
const adminUrl = testPostgresAdminUrl();
if (adminUrl) return startTestPostgresDatabase(adminUrl);
const { port, dataDir, instance, mode } = await startEmbeddedPostgresClusterForSuite(tempDirPrefix);
const { port, dataDir, instance, mode } = await startEmbeddedPostgresClusterForSuite(tempDirPrefix, options);
lastStartMode = mode;
try {
+4 -1
View File
@@ -16,7 +16,10 @@ try {
let adminUrl = testPostgresAdminUrl();
if (adminUrl) await checkTestPostgresAdmin(adminUrl);
else {
server = await startEmbeddedPostgresTestDatabase("paperclip-test-command-");
// Shared multi-worker test server: raise max_connections above Postgres's
// default 100 so 7-8 parallel Vitest fork workers (each with main + private
// pools) never exhaust backend slots on 8-core runners or dev workstations.
server = await startEmbeddedPostgresTestDatabase("paperclip-test-command-", { maxConnections: 300 });
const url = new URL(server.connectionString);
url.pathname = "/postgres";
adminUrl = url.toString();
@@ -11,7 +11,7 @@ import type { DurableRecoveryIdentity } from "../contracts/durable-recovery.js";
export type RunnerReleaseResumeOutcome =
| "resumed"
| "unavailable"
| { outcome: "resumed"; runner: { version: string; digest: string }; settled?: () => Promise<void> };
| { outcome: "resumed"; runner: { version: string; digest: string } };
export interface RunnerExecutionDriver {
/** The driver verifies a stopped, idle Codex App Server source before launch. */
-1
View File
@@ -101,7 +101,6 @@ export { resolveGrokEffort } from "./drivers/acpx/grok-effort.js";
export * from "./drivers/runner-tool-bridge.js";
export {
createRunnerdCodexTransport,
isSettledReleasedRunnerCut,
revertUnattachedRelaunchRotation,
probeNativeRunnerEnvironment,
NativeEnvironmentProbeCleanupError,
@@ -122,7 +122,6 @@ it.skipIf(process.platform === "win32").each(["cached", "lost claim reply", "cac
const measuredTurn = new Promise<void>(resolve => { enterMeasuredTurn = resolve; });
const heldMeasuredTurn = new Promise<void>(resolve => { finishMeasuredTurn = resolve; });
const sockets = new Set<PrpWireConnection>();
const relaunchSettled = vi.fn(async () => { expect(authority!.store.state.identity.runId).toBe(identity.runId); });
const registration = async (core: DurablePrpControlPlane, source = core.store.state.identity) => {
if ((mode === "late claim reply" || mode === "held past deadline" || mode === "early claim expired") && claimAccepted) throw new Error("Fixture source authentication started after expiry");
authority = core;
@@ -184,7 +183,7 @@ it.skipIf(process.platform === "win32").each(["cached", "lost claim reply", "cac
if (mode === "relaunched flush retry" && pair.resume.mock.calls.length === 1) {
vi.spyOn(authority!, "flushCheckpoint").mockRejectedValueOnce(new Error("Fixture checkpoint write failed"));
}
return { outcome: "resumed", runner: { version, digest: runnerDigest }, settled: relaunchSettled };
return { outcome: "resumed", runner: { version, digest: runnerDigest } };
}
return "resumed";
}),
@@ -438,9 +437,7 @@ it.skipIf(process.platform === "win32").each(["cached", "lost claim reply", "cac
await bundle.transport.close();
} else await attaching;
expect(new Set(claimTicketDigests).size).toBe(1);
if (mode === "relaunched same build" || mode === "relaunched flush retry") expect(relaunchSettled).toHaveBeenCalledOnce();
if (mode === "relaunched incompatible build") {
expect(relaunchSettled).not.toHaveBeenCalled();
expect(pair.resume).toHaveBeenCalledOnce();
expect(authority!.store.state.identity.runId).toBe(identity.runId);
return;
@@ -4,7 +4,7 @@ import {
runnerLaunchRequirementsDigest,
type RunnerProviderLaunchRequirements,
} from "./runner-provider-launch.js";
import { coldAdmissionTimeoutMs, describeRunnerCommandStall, isSettledReleasedRunnerCut, revertUnattachedRelaunchRotation, RUNNER_MAX_STOPPED_CREDIT_MS, RUNNER_POST_STOP_GRACE_MS, RunnerStallLedger, waitForRunnerCommand } from "./runnerd-codex-transport.js";
import { coldAdmissionTimeoutMs, describeRunnerCommandStall, revertUnattachedRelaunchRotation, RUNNER_MAX_STOPPED_CREDIT_MS, RUNNER_POST_STOP_GRACE_MS, RunnerStallLedger, waitForRunnerCommand } from "./runnerd-codex-transport.js";
import { configuredEnvironmentProjection } from "../configured-environment.js";
import { chmod, cp, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, stat, truncate, writeFile } from "node:fs/promises";
import { createHash } from "node:crypto";
@@ -2211,26 +2211,6 @@ describe("a rotation for a released Runner that the host starts again", () => {
}
}
});
it("accepts a stopped Runner's ready cut only when nothing is left in flight", () => {
expect(isSettledReleasedRunnerCut(settled, priorIdentity)).toBe(true);
expect(isSettledReleasedRunnerCut({ schema: settled.schema, ...priorIdentity, lifecycle: "suspended" }, priorIdentity)).toBe(true);
for (const changed of [
{ outbox: [{ sourceSeq: 8 }] },
{ ackedSourceSeq: 6 },
{ nextSourceSeq: undefined },
{ processedCommands: { "command-a": { status: "pending" } } },
{ processedCommands: { "command-a": { status: "indeterminate" } } },
{ warmTransition: { transitionId: "transition" } },
{ pendingTerminalDelivery: { turnId: "turn" } },
{ pendingProviderCleanup: { turnId: "turn" } },
{ lifecycle: "connecting" },
{ schema: "paperclip.runner.durable.state.v0" },
{ runId: desiredIdentity.runId },
]) {
expect(isSettledReleasedRunnerCut({ ...settled, ...changed }, priorIdentity)).toBe(false);
}
});
});
describe("authority rotation after the prior controller state is restored", () => {
@@ -237,22 +237,6 @@ function assertSuspendedRunnerState(
}
}
export function isSettledReleasedRunnerCut(
state: Record<string, unknown>,
expected: DurableRecoveryIdentity,
): boolean {
if (state.schema !== "paperclip.runner.durable.state.v1" || !recoveryIdentityMatches(state, expected)) return false;
if (state.lifecycle === "suspended") return true;
return state.lifecycle === "ready"
&& Array.isArray(state.outbox) && state.outbox.length === 0
&& Number.isSafeInteger(state.nextSourceSeq) && state.ackedSourceSeq === Math.max(0, Number(state.nextSourceSeq) - 1)
&& state.warmTransition === undefined
&& (state.pendingTerminalDelivery ?? null) === null
&& (state.pendingProviderCleanup ?? null) === null
&& Object.values(record(state.processedCommands)).every(command =>
!["pending", "indeterminate"].includes(String(record(command).status)));
}
function assertRealDirectory(path: string): void {
const metadata = lstatSync(path);
if (metadata.isSymbolicLink() || !metadata.isDirectory()) {
@@ -5067,7 +5051,6 @@ class DurablePrpCodexTransport implements CodexAppServerTransport {
assertPending();
let outcome: "resumed" | "unavailable" | undefined;
let relaunched: { version: string; digest: string } | undefined;
let settled: (() => Promise<void>) | undefined;
try {
if (!episode.ticket) {
episode.ticket = core.issueBootstrapTicket(RUNNER_BOOTSTRAP_TICKET_TTL_MS);
@@ -5081,7 +5064,6 @@ class DurablePrpCodexTransport implements CodexAppServerTransport {
const result = await Promise.race([pair.resume(episode.source, episode.ticket), deadline, closed]);
outcome = typeof result === "string" ? result : result.outcome;
relaunched = typeof result === "string" ? undefined : result.runner;
settled = typeof result === "string" ? undefined : result.settled;
} catch (error) {
// A generic RPC error cannot prove refusal. Keep this exact pending claim quiet.
assertPending();
@@ -5096,7 +5078,6 @@ class DurablePrpCodexTransport implements CodexAppServerTransport {
core.acceptRelaunchedRunner(episode.ticket!, relaunched, episode.parked);
this.#relaunchedRunnerArtifact = structuredClone(relaunched);
await Promise.race([core.flushCheckpoint(), deadline, closed]);
await Promise.race([settled?.(), deadline, closed]);
} catch (error) {
if (error instanceof Error && error.message === "native_runner_relaunched_build_unaccepted") {
throw new Error("native_runner_reuse_unavailable");
@@ -194,8 +194,7 @@ export const environmentTaskResultSchema = z.discriminatedUnion("kind", [
z.object({ kind: z.literal("admission_rejected"), taskId: providerId,
reason: z.enum(["session_state_unavailable", "account_binding_mismatch"]) }).strict(),
z.object({ kind: z.literal("released"), taskId: providerId }).strict(),
z.object({ kind: z.literal("resume"), taskId: providerId, outcome: z.enum(["resumed", "unavailable"]), runner: runnerArtifact.optional(),
archivedState: z.record(z.string(), z.unknown()).optional() }).strict(),
z.object({ kind: z.literal("resume"), taskId: providerId, outcome: z.enum(["resumed", "unavailable"]), runner: runnerArtifact.optional() }).strict(),
z.object({
kind: z.literal("ownership"),
taskId: providerId,
@@ -307,8 +306,7 @@ export function parseEnvironmentTaskResult(operation: PluginEnvironmentTaskOpera
const expected = operation.kind === "release" ? "released" : operation.kind === "resume" ? "resume" : operation.kind === "read_file" ? "file" : operation.kind === "describe" ? "description" : operation.kind === "prepare" ? "prepared" : operation.kind === "check_project_auth" ? "project_auth" : ["read_state", "archive_state"].includes(operation.kind) ? "state" : ["status", "connection", "credentials", "copilot_metadata"].includes(operation.kind) ? operation.kind : "accepted";
const rejectedSubmit = operation.kind === "submit" && result.kind === "admission_rejected";
if (result.taskId !== taskId || (result.kind !== expected && !rejectedSubmit)) throw new Error("Invalid plugin-provided Runner execution response");
if (operation.kind === "resume" && result.kind === "resume" && (operation.runner
? result.outcome === "resumed" && (!result.runner || !result.archivedState) : result.archivedState !== undefined)) {
if (operation.kind === "resume" && result.kind === "resume" && operation.runner && result.outcome === "resumed" && !result.runner) {
throw new Error("Invalid plugin-provided Runner execution response");
}
return result;
@@ -94,7 +94,7 @@ describe("release and resume task contract", () => {
expect(environmentTaskResultSchema.safeParse({ ...result, runner: { ...runner, extra: true } }).success).toBe(false);
});
it("relaunches as the claimant's identity only when asked, and reports the archived state", () => {
it("relaunches as the claimant's identity only when asked, and reports the build", () => {
expect(environmentTaskResultSchema.parse({ ...description, resumeIdentityVersion: 1 })).toEqual({ ...description, resumeIdentityVersion: 1 });
expect(environmentTaskResultSchema.safeParse({ ...description, resumeIdentityVersion: 2 }).success).toBe(false);
const runner = { runId: "claimant-run", turnId: "turn-claimant-run", itemId: "item-claimant-run" };
@@ -104,12 +104,11 @@ describe("release and resume task contract", () => {
expect(environmentTaskOperationSchema.safeParse({ ...resume, runner: changed }).success).toBe(false);
}
const build = { version: "0.4.1", digest: `sha256:${"b".repeat(64)}` };
const archivedState = { schema: "paperclip.runner.durable.state.v1", ...identity, lifecycle: "ready" };
const resumed = { kind: "resume", taskId: "task", outcome: "resumed", runner: build, archivedState };
const resumed = { kind: "resume", taskId: "task", outcome: "resumed", runner: build };
expect(parseEnvironmentTaskResult(relaunch, "task", resumed)).toEqual(resumed);
expect(() => parseEnvironmentTaskResult(relaunch, "task", { ...resumed, archivedState: undefined })).toThrow();
const archivedState = { schema: "paperclip.runner.durable.state.v1", ...identity, lifecycle: "ready" };
expect(() => parseEnvironmentTaskResult(relaunch, "task", { ...resumed, archivedState })).toThrow();
expect(() => parseEnvironmentTaskResult(relaunch, "task", { ...resumed, runner: undefined })).toThrow();
expect(() => parseEnvironmentTaskResult(resume, "task", resumed)).toThrow();
expect(parseEnvironmentTaskResult(relaunch, "task", { kind: "resume", taskId: "task", outcome: "unavailable" }))
.toEqual({ kind: "resume", taskId: "task", outcome: "unavailable" });
});
@@ -16,7 +16,6 @@
"urlPatterns": [
"https://workspace.google.com/*"
],
"docsUrl": "https://developers.google.com/workspace/guides/configure-mcp-servers",
"setupPrerequisite": {
"title": "Google Developer Preview access required",
"description": "Google must register the Workspace email and the Cloud project that owns the OAuth client before these services can be used.",
@@ -111,10 +110,10 @@
"prompt": "consent"
}
},
"guidanceMd": "Enable the Google Workspace MCP APIs and register Paperclip's callback URI. Choose which permissions to grant on Google's consent screen; declined permissions disable only the corresponding actions.",
"guidanceMd": "Enable the Gmail, Drive, Docs, Sheets, Slides, and Calendar APIs in your Google Cloud project and register Paperclip's callback URI. Choose which permissions to grant on Google's consent screen; declined permissions disable only the corresponding actions.",
"consoleLinks": {
"register": "https://console.cloud.google.com/auth/clients",
"docs": "https://developers.google.com/workspace/guides/configure-mcp-servers"
"docs": "https://developers.google.com/workspace/guides/create-credentials#oauth-client-id"
},
"riskTier": "S4"
}
+42 -2
View File
@@ -65,10 +65,28 @@ export const INSPECTION_RESOURCES = [
"threads",
] as const;
export type InspectionResource = (typeof INSPECTION_RESOURCES)[number];
export const INSPECTION_ORDERS = ["newest", "oldest"] as const;
export type InspectionOrder = (typeof INSPECTION_ORDERS)[number];
export const INSPECTION_VIEWS = ["summary"] as const;
export type InspectionView = (typeof INSPECTION_VIEWS)[number];
/** The tenant path for queries that use only the original (version 1) features. */
export const INSPECTION_READ_PATH = "/read";
/**
* The tenant path for queries that use `count`, `order` or `view`. A tenant
* that predates them answers 404 here, so Cloud fails closed with
* `tenant_inspection_version_unsupported` instead of misreading the query.
*/
export const INSPECTION_EXTENDED_READ_PATH = "/read-v2";
export interface InspectionCount {
total: number;
/** Counts grouped by the resource's `status` column, or null when it has none. */
byStatus: Record<string, number> | null;
}
export interface InspectionQuery {
operation:
| "list"
| "get"
| "count"
| "instructions.file"
| "skills.file"
| "runs.log"
@@ -85,6 +103,10 @@ export interface InspectionQuery {
limit?: number;
offset?: number;
range?: { start: number; end: number };
/** `list` only: order by creation time instead of by id. */
order?: InspectionOrder;
/** `list`/`get` on `runs` only: leave out the large JSON columns. */
view?: InspectionView;
context?: {
projectId?: string;
workspaceId?: string;
@@ -129,6 +151,11 @@ export function canonicalJson(value: unknown): string {
}
throw new Error("Invalid JSON value");
}
export function inspectionReadPath(query: InspectionQuery): string {
return query.operation === "count" || query.order !== undefined || query.view !== undefined
? INSPECTION_EXTENDED_READ_PATH
: INSPECTION_READ_PATH;
}
export function parseInspectionQuery(value: unknown): InspectionQuery {
if (!value || typeof value !== "object" || Array.isArray(value))
throw new Error("Invalid inspection query");
@@ -144,6 +171,8 @@ export function parseInspectionQuery(value: unknown): InspectionQuery {
"limit",
"offset",
"range",
"order",
"view",
"context",
]);
if (Object.keys(q).some((k) => !allowed.has(k)))
@@ -152,6 +181,7 @@ export function parseInspectionQuery(value: unknown): InspectionQuery {
![
"list",
"get",
"count",
"instructions.file",
"skills.file",
"runs.log",
@@ -169,11 +199,21 @@ export function parseInspectionQuery(value: unknown): InspectionQuery {
if (q.resource !== undefined && !INSPECTION_RESOURCES.includes(q.resource))
throw new Error("Unsupported inspection resource");
if (q.operation === "get" && !q.resourceId) throw new Error("resourceId required");
if (["get", "list"].includes(q.operation) && !q.resource) throw new Error("resource required");
if (["get", "list", "count"].includes(q.operation) && !q.resource)
throw new Error("resource required");
if (!(q.operation === "list" && q.resource === "companies") && !q.companyId)
throw new Error("companyId required");
if (!["get", "list"].includes(q.operation) && !q.resourceId)
if (!["get", "list", "count"].includes(q.operation) && !q.resourceId)
throw new Error("resourceId required");
if (q.operation === "count" && q.resourceId !== undefined)
throw new Error("count does not take resourceId");
if (q.order !== undefined && (q.operation !== "list" || !INSPECTION_ORDERS.includes(q.order)))
throw new Error("Invalid order");
if (
q.view !== undefined &&
(!["list", "get"].includes(q.operation) || q.resource !== "runs" || !INSPECTION_VIEWS.includes(q.view))
)
throw new Error("Invalid view");
if (
q.path !== undefined &&
(typeof q.path !== "string" || q.path.length > 1024 || q.path.includes("\0"))
@@ -0,0 +1,31 @@
import { describe, expect, it } from "vitest";
import { getConnectableAppDefinition } from "./app-definitions.js";
const MCP_SERVERS_GUIDE = "configure-mcp-servers";
const OAUTH_CLIENT_GUIDE = "https://developers.google.com/workspace/guides/create-credentials#oauth-client-id";
describe("Google Workspace setup links and copy", () => {
const app = getConnectableAppDefinition("google-workspace")!;
const method = (key: string) => app.methods.find((candidate) => candidate.key === key)!;
it("never sends a user to Google's MCP servers guide", () => {
expect(JSON.stringify(app)).not.toContain(MCP_SERVERS_GUIDE);
});
it("gives the Paperclip-managed sign-in no requirements link", () => {
expect(app.docsUrl).toBeUndefined();
expect(method("paperclip-workspace").consoleLinks?.docs).toBeUndefined();
});
it("links the customer-owned client method to Google's OAuth client guide", () => {
expect(method("customer-workspace-oauth").consoleLinks?.docs).toBe(OAUTH_CLIENT_GUIDE);
});
it("does not mention MCP in user-facing method text", () => {
for (const entry of app.methods) {
for (const text of [entry.label, entry.whenToUse, entry.guidanceMd, ...(entry.warnings ?? [])]) {
expect(text ?? "").not.toMatch(/\bMCP\b/);
}
}
});
});