mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-29 04:25:52 +01:00
## Thinking Path > - Paperclip manages agents and the work they perform. > - Product E2E tests exercise real agents, tools, setup and cleanup. > - Repeated runs need retained costs and traces, including failed attempts. > - A passing retry must not hide earlier spending or feedback. > - Recurring work also needs admission limits, private reports and failure detection. > - This change supplies those controls while keeping paid activation behind existing gates. ## Linked Issues or Issue Description Refs #16996 and #17158. This is the consolidated landing of the reviewed eval operations stack: #17019, #17024, #17025, #17027, #17030, #17033, #17035, #17038, #17043, #17044, #17048, #17050, #17051, #17092, #17096, #17100, #17107, #17109, #17112, #17115, #17117, #17121, #17123, #17127, #17130, #17133, #17134, #17137, #17140, #17143, #17154. The repository permits squash merges only. A local rehearsal showed that squashing each slice into master causes repeated conflicts in dependent slices. This PR preserves their commits and lands their combined implementation in one reviewed integration. Superseded slices will close after this merge. ## What Changed - Retain every attempt's cost receipt, including setup, failures, interruptions and retries. Separate reported amounts, estimates, missing costs and reserved capacity in reports and dashboards. - Add bounded request admission, exact model pricecards, gateway error accounting, cache policy and reconciliation evidence. Refuse unsupported routes and requests that cannot fit the allowance. - Integrate Braintrust gateway traces and OTLP correlation, with secret filtering and experiment imports. Record phase timing, including setup, feedback capture and cleanup. - Collect complaint and suggestion evidence after each attempt, including recovery after failures. Retain explicit review dispositions independently from the product grade. - Add gated daily and weekly selections, measured forecasts, setup/readiness checks, wall-time limits and retained monitor notifications. Include declared non-model overhead in admission while reporting the existing subscription separately. - Keep recurring history private, bound uploads and retention, and use isolated archive environments. Keep public publication an explicit operation. Report and publication jobs install only the committed lockfile, with scripts disabled and isolated stores; stale pins fail closed. - Integrate current master, preserve its Product E2E journey billing and privacy checks, and test that shared setup receipts do not double-count estimated agent usage. Preserve upstream fixture repairs. ## Verification - Complete integration baseline `0649a5ce7544ab20825c2183d2f421157db49f24` includes master `a3e1d915a7110a4e115b46396a3f79e6dfb4d05e` and every original stack head as ancestors. - On that integration baseline, `pnpm test:e2e:runner:unit`: 4,012 Vitest tests passed, two skipped, across 193 files; all 137 Node source-contract tests passed. - Focused billing and Product E2E journey contract checks: 24 tests passed. They cover estimates, unknown receipts, single-owner setup costs, browser-only execution and private publication guards. - Monitor and workflow wiring: all 96 Node tests passed. `node scripts/check-token-gates.mjs`: all gates clean. - `pnpm test:e2e:runner:typecheck` passes after the standard Runner TypeScript build refreshed local declarations. The first attempt rejected the new master `runner_prepared_launch` union member because this checkout retained an older generated declaration; the source union already contained that member. - Current head `492b0708a1c531a023d9ac10f0f3dc6383cc1754` removes dependency re-resolution from archive-authorized reporting jobs after the security scan flagged it. All 15 workflow-security tests pass after updating the old two-install assertion. - Hosted [CI run 39965460180](https://github.com/paperclipai/paperclip/actions/runs/39965460180) passes on the current repaired head, including typecheck, build, general tests, Runner checks, browser shards and canary dry run. Greptile is 5/5 on this exact head with no unresolved threads. The security scan passes after the fixed lockfile-resolution thread was resolved. - Paperclip Review returned a terminal neutral check but an incomplete 0-file assessment on the repaired head: its platform blocked both diff responses as prompt-injection content. This is not a successful code review. No bypass or fabricated pass was attempted; current-head Greptile, security and hosted CI are independent gates. - No paid test, reservation release or recurring-run activation accompanies this landing. Live route qualification and invoice reconciliation remain separate evidence. <details> <summary>Retained earlier validation failures</summary> Earlier broad local runs had two 15-second test timeouts (CLI poll cadence and Retry validation), one embedded-database setup timeout, and later PostgreSQL semaphore exhaustion. The exact timed-out tests passed separately without larger timeouts; the broad-run causes were not established. Those local failures remain distinct from subsequent hosted CI results. The independent #17158 fix records its Muse fixture collision, its UUID correction and hosted verification. Local Muse execution was also blocked by macOS embedded-PostgreSQL startup. No historical failure is treated as a successful paid qualification. </details> ## Risks - Admission is a local control, not a provider invoice cap. Missing provider receipts or resource charges retain unknown amounts and holds; estimates do not become billed dollars. - The bounded path admits only documented local suites and provider routes. Ordinary legacy or separate Runner protocol campaigns have different controls. Merging this code does not qualify additional routes. - Recurrence still needs the existing enable gates and current qualification/allowance evidence. Archive permissions and resources must match the documented private-environment contract. - Legacy reports may lack complete attempt or phase evidence. Reports preserve that limitation and do not infer zero usage from missing data. ## Model Used OpenAI GPT-6 through Codex, with reasoning, repository tools and code execution. The exact deployment variant and context-window size are not exposed by this session. ## 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 (targeted checks; full-suite host limitation disclosed above) - [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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
462 lines
20 KiB
TypeScript
462 lines
20 KiB
TypeScript
import type { AiConnectionBinding } from "../../packages/shared/src/ai-connections.js";
|
|
import { verifyInstalledDaytonaPlugin } from "./installed-daytona-plugin.js";
|
|
import { NATIVE_COMPLETION_BUDGET_CENTS } from "./native-completion-defaults.js";
|
|
import path from "node:path";
|
|
import { installedReleaseDaytonaPlugin } from "./installed-release.js";
|
|
import { isManagedHiringCase } from "./chat-cases.js";
|
|
import { FixtureRegistry } from "./fixture-registry.js";
|
|
import { isImmutableDaytonaImage } from "./catalog.js";
|
|
import { TASK_TITLE_BUDGET_CENTS } from "./task-titles.js";
|
|
import { codexSubscriptionAgentConfig, stageCodexSubscriptionFixture } from "./codex-subscription-fixture.js";
|
|
import { caseReceiptTask, CASE_RECEIPT_BUDGET_CENTS, CASE_RECEIPT_RUN_TIMEOUT_MS } from "./case-receipt-cases.js";
|
|
import { stageGrokSubscriptionFixture } from "./grok-subscription-fixture.js";
|
|
import type { RunnerApi } from "./api.js";
|
|
import type {
|
|
CredentialName,
|
|
MatrixExecution,
|
|
SecretReference,
|
|
SecretReferenceMap,
|
|
RunnerE2ERuntimeUsage,
|
|
} from "./types.js";
|
|
|
|
interface CompanyRecord {
|
|
id: string;
|
|
issuePrefix?: string | null;
|
|
name: string;
|
|
}
|
|
|
|
interface SecretRecord {
|
|
id: string;
|
|
}
|
|
interface PluginRecord {
|
|
id: string;
|
|
pluginKey: string;
|
|
status: string;
|
|
}
|
|
interface EnvironmentRecord {
|
|
id: string;
|
|
driver: string;
|
|
config?: Record<string, unknown>;
|
|
}
|
|
interface AgentRecord {
|
|
id: string;
|
|
name: string;
|
|
companyId: string;
|
|
}
|
|
interface ManagedAccountFixture {
|
|
connectionId: string;
|
|
binding: AiConnectionBinding;
|
|
}
|
|
|
|
interface ProjectRecord {
|
|
id: string;
|
|
name: string;
|
|
primaryWorkspace?: {
|
|
id: string;
|
|
cwd?: string | null;
|
|
} | null;
|
|
}
|
|
|
|
export interface LiveFixtureValues {
|
|
company: CompanyRecord;
|
|
secretRefs: SecretReferenceMap;
|
|
environment: EnvironmentRecord;
|
|
agent: AgentRecord;
|
|
project?: ProjectRecord;
|
|
aiConnection?: ManagedAccountFixture;
|
|
setupProbe?: { leaseId: string; durationMs: number; defaultRunner?: string };
|
|
setupLeases?: Array<{ leaseId: string; phase: "platform" | "adapter"; durationMs: number }>;
|
|
setupLeaseAccountingIncomplete?: boolean;
|
|
setupQualification?: { recorded: boolean; adapterType: string | null; platformResponses: number; adapterResponses: number };
|
|
|
|
onboardingRuntime?: {
|
|
mode: "production-wizard" | "post-onboarding-runtime-switch";
|
|
originalAdapterType: string;
|
|
originalModel: string | null;
|
|
testedAdapterType: string;
|
|
};
|
|
teardown(): Promise<void>;
|
|
}
|
|
|
|
function value<T>(resolved: ReadonlyMap<string, unknown>, id: string): T {
|
|
const result = resolved.get(id);
|
|
if (!result) throw new Error(`Missing resolved fixture ${id}`);
|
|
return result as T;
|
|
}
|
|
|
|
export function selectFixtureRuntimeLeases<T extends {
|
|
id: string; provider?: string | null; heartbeatRunId?: string | null; issueId?: string | null;
|
|
}>(input: { leases: T[]; runIds: string[]; issueId?: string; setupProbeLeaseId?: string; setupLeaseIds?: readonly string[] }): T[] {
|
|
const selectedRunIds = new Set(input.runIds);
|
|
const setupIds = new Set([...(input.setupLeaseIds ?? []), ...(input.setupProbeLeaseId ? [input.setupProbeLeaseId] : [])]);
|
|
const relevant = input.leases.filter(lease => lease.provider === "daytona" && (
|
|
setupIds.has(lease.id) || (input.setupLeaseIds === undefined && selectedRunIds.size === 0)
|
|
|| (lease.heartbeatRunId && selectedRunIds.has(lease.heartbeatRunId))
|
|
|| (input.issueId && lease.issueId === input.issueId)
|
|
));
|
|
return input.setupLeaseIds !== undefined || relevant.length > 0 ? relevant : input.leases;
|
|
}
|
|
|
|
export function fixtureRuntimeCostCoverage(usage: RunnerE2ERuntimeUsage, fixtures: Pick<LiveFixtureValues, "setupLeaseAccountingIncomplete">): RunnerE2ERuntimeUsage {
|
|
if (!fixtures.setupLeaseAccountingIncomplete) return usage;
|
|
const { estimatedListCostUsd: _estimate, ...known } = usage;
|
|
return { ...known, costStatus: "unavailable", costSource: "provider_cost_unavailable" };
|
|
}
|
|
|
|
export async function deleteDaytonaEnvironment(api: Pick<RunnerApi, "delete">, environmentId: string) {
|
|
const deadlineAt = Date.now() + 120_000;
|
|
let lastError: unknown;
|
|
while (Date.now() < deadlineAt) {
|
|
try {
|
|
await api.delete(
|
|
`/api/environments/${environmentId}?destroyReusableSandboxLeases=true`,
|
|
{
|
|
allowNotFound: true,
|
|
},
|
|
);
|
|
return;
|
|
} catch (error) {
|
|
lastError = error;
|
|
await new Promise((resolve) => setTimeout(resolve, 3_000));
|
|
}
|
|
}
|
|
throw new Error(
|
|
`Daytona lease cleanup failed: ${lastError instanceof Error ? lastError.message : String(lastError)}`,
|
|
);
|
|
}
|
|
|
|
export async function installFixtureDaytonaProvider(api: Pick<RunnerApi, "post">, execution: MatrixExecution) {
|
|
const installed = await verifyInstalledDaytonaPlugin(process.env, [execution]);
|
|
return api.post<PluginRecord>("/api/plugins/install", {
|
|
packageName: installed?.packageRoot ?? path.resolve(import.meta.dirname, "../../packages/plugins/sandbox-providers/daytona"),
|
|
isLocalPath: true,
|
|
}, { timeout: 120_000 });
|
|
}
|
|
|
|
export async function setupLiveFixtures(input: {
|
|
api: RunnerApi;
|
|
execution: MatrixExecution;
|
|
executionNonce: string;
|
|
workspacePath: string;
|
|
credentials: Partial<Record<CredentialName, string>>;
|
|
daytonaImage?: string;
|
|
onCompanyCreated?: (companyId: string) => Promise<void>;
|
|
}): Promise<LiveFixtureValues> {
|
|
const { api, execution } = input;
|
|
const receiptSmoke = execution.suite.id === "case-handoffs" && execution.task.id === caseReceiptTask.id;
|
|
const registry = new FixtureRegistry();
|
|
let setupProbe: LiveFixtureValues["setupProbe"];
|
|
|
|
if (execution.environment.id === "daytona") {
|
|
registry.register<PluginRecord>({
|
|
id: "sandbox-provider",
|
|
async setup() {
|
|
return installFixtureDaytonaProvider(api, execution);
|
|
},
|
|
async teardown() {
|
|
// The plugin is installed only in the isolated instance/database. The
|
|
// launcher removes that complete instance after the environment lease
|
|
// has been destroyed, so no global uninstall mutation is necessary.
|
|
},
|
|
});
|
|
}
|
|
|
|
registry.register<CompanyRecord>({
|
|
id: "company",
|
|
async setup() {
|
|
const company = await api.post<CompanyRecord>("/api/companies", {
|
|
name: `Runner E2E ${execution.id} ${input.executionNonce}`,
|
|
description: "Ephemeral paid full-stack runner acceptance fixture",
|
|
budgetMonthlyCents: receiptSmoke ? CASE_RECEIPT_BUDGET_CENTS
|
|
: ["native-completion", "native-instruction-consolidation", "native-connection-guidance"].includes(execution.suite.id)
|
|
|| (execution.suite.id === "everyday-workflows" && ["hire-reuse", "delegate-feedback"].includes(execution.task.id)) ? NATIVE_COMPLETION_BUDGET_CENTS
|
|
: execution.suite.id === "task-titles" ? TASK_TITLE_BUDGET_CENTS
|
|
: ["stock-harness", "task-workspaces", "case-handoffs", "feedback-persistence"].includes(execution.suite.id) ? 1_000 : 0,
|
|
});
|
|
await input.onCompanyCreated?.(company.id);
|
|
return company;
|
|
},
|
|
async teardown() {
|
|
// The isolated instance/database is removed by the launcher. Do not call
|
|
// company deletion here: metered runs intentionally retain cost-event
|
|
// references until that instance-wide teardown.
|
|
},
|
|
});
|
|
|
|
registry.register<SecretReferenceMap>({
|
|
id: "secrets",
|
|
dependencies: ["company"],
|
|
async setup(resolved) {
|
|
const company = value<CompanyRecord>(resolved, "company");
|
|
const refs: SecretReferenceMap = {};
|
|
for (const credentialName of execution.requiredCredentials) {
|
|
if (["GROK_AUTH_JSON", "CODEX_AUTH_JSON"].includes(credentialName)) continue;
|
|
const rawValue = input.credentials[credentialName];
|
|
if (!rawValue) throw new Error(`Missing credential ${credentialName}`);
|
|
const secret = await api.postSensitive<SecretRecord>(
|
|
`/api/companies/${company.id}/secrets`,
|
|
{
|
|
name: `Runner E2E ${credentialName} ${input.executionNonce}`,
|
|
key: credentialName,
|
|
value: rawValue,
|
|
description: `Ephemeral credential for ${execution.id}`,
|
|
},
|
|
);
|
|
refs[credentialName] = {
|
|
type: "secret_ref",
|
|
secretId: secret.id,
|
|
version: "latest",
|
|
} satisfies SecretReference;
|
|
}
|
|
return refs;
|
|
},
|
|
});
|
|
|
|
const grokSubscription = execution.profile.credential === "GROK_AUTH_JSON";
|
|
const codexSubscription = execution.profile.credential === "CODEX_AUTH_JSON";
|
|
if (grokSubscription || codexSubscription) {
|
|
registry.register<() => Promise<void>>({
|
|
id: "subscription-login",
|
|
dependencies: ["company"],
|
|
async setup(resolved) {
|
|
const raw = input.credentials[execution.profile.credential];
|
|
if (!raw) throw new Error("Missing explicit subscription login credential");
|
|
return (codexSubscription ? stageCodexSubscriptionFixture : stageGrokSubscriptionFixture)({
|
|
raw, companyId: value<CompanyRecord>(resolved, "company").id,
|
|
environment: process.env,
|
|
});
|
|
},
|
|
async teardown(remove) { await remove(); },
|
|
});
|
|
}
|
|
|
|
registry.register<EnvironmentRecord>({
|
|
id: "environment",
|
|
dependencies: [
|
|
"company",
|
|
"secrets",
|
|
...((grokSubscription || codexSubscription) ? ["subscription-login"] : []),
|
|
...(execution.environment.id === "daytona" ? ["sandbox-provider"] : []),
|
|
],
|
|
async setup(resolved) {
|
|
const company = value<CompanyRecord>(resolved, "company");
|
|
const secretRefs = value<SecretReferenceMap>(resolved, "secrets");
|
|
if (execution.environment.id === "local") {
|
|
// Paperclip has one instance-managed local environment. The company
|
|
// creation API ensures it exists; creating a second local environment
|
|
// is intentionally rejected by the public API.
|
|
const environments = await api.get<EnvironmentRecord[]>(
|
|
`/api/companies/${company.id}/environments?driver=local`,
|
|
);
|
|
const local = environments.find(
|
|
(candidate) => candidate.driver === "local",
|
|
);
|
|
if (!local)
|
|
throw new Error(
|
|
"Isolated Paperclip instance did not create its managed local environment",
|
|
);
|
|
return local;
|
|
}
|
|
return api.post<EnvironmentRecord>(
|
|
`/api/companies/${company.id}/environments`,
|
|
execution.environment.buildEnvironment({
|
|
secretRefs,
|
|
daytonaImage: input.daytonaImage,
|
|
executionId: input.executionNonce,
|
|
}),
|
|
);
|
|
},
|
|
async teardown(environment) {
|
|
if (execution.environment.id === "daytona") {
|
|
await deleteDaytonaEnvironment(api, environment.id);
|
|
}
|
|
},
|
|
});
|
|
|
|
const managedHiring = isManagedHiringCase(execution.suite.id, execution.task.id);
|
|
const savedCopilot = execution.profile.qualificationCandidate === "copilot";
|
|
const gatewayUrl = process.env.PAPERCLIP_E2E_GATEWAY_BASE_URL;
|
|
const gatewayToken = process.env.PAPERCLIP_E2E_GATEWAY_TOKEN;
|
|
const budgetedGateway = Boolean(gatewayUrl || gatewayToken);
|
|
if (budgetedGateway && (!gatewayUrl || !gatewayToken || !/^http:\/\/127\.0\.0\.1:[0-9]+$/.test(gatewayUrl)
|
|
|| execution.environment.id !== "local" || !["core-compatibility", "feedback-persistence"].includes(execution.suite.id))) throw new Error("Unqualified fixture gateway route");
|
|
if (managedHiring || savedCopilot || budgetedGateway) {
|
|
registry.register<ManagedAccountFixture>({
|
|
id: "ai-connection",
|
|
dependencies: ["company", ...(savedCopilot ? ["environment"] : [])],
|
|
async setup(resolved) {
|
|
const company = value<CompanyRecord>(resolved, "company");
|
|
const key = savedCopilot ? "COPILOT_GITHUB_TOKEN" : execution.profile.credential;
|
|
const provider = savedCopilot ? "github" : key === "ANTHROPIC_API_KEY" ? "anthropic"
|
|
: key === "OPENROUTER_API_KEY" ? "openrouter"
|
|
: key === "OPENAI_API_KEY" ? "openai" : null;
|
|
if (!provider) throw new Error(`Unsupported managed hiring credential ${key}`);
|
|
const apiKey = input.credentials[key];
|
|
if (!apiKey) throw new Error(`Missing credential ${key}`);
|
|
const account = await api.postSensitive<{ connectionId: string; grantId: string }>(
|
|
`/api/companies/${company.id}/ai-connections`,
|
|
{
|
|
provider,
|
|
method: "api_key",
|
|
name: `Runner E2E account ${input.executionNonce}`,
|
|
ownership: budgetedGateway ? "shared" : "personal",
|
|
...(budgetedGateway ? { routing: { kind: "gateway", protocol: provider === "anthropic" ? "messages" : "responses",
|
|
baseUrl: provider === "anthropic" ? gatewayUrl : `${gatewayUrl}/v1`, auth: "bearer", models: [{ id: execution.profile.model }] } } : {}),
|
|
...(savedCopilot ? { environmentId: value<EnvironmentRecord>(resolved, "environment").id } : {}),
|
|
apiKey: budgetedGateway ? gatewayToken : apiKey,
|
|
agentIds: [],
|
|
allAgents: budgetedGateway,
|
|
},
|
|
);
|
|
return {
|
|
connectionId: account.connectionId,
|
|
binding: budgetedGateway
|
|
? { provider, method: "api_key", mode: "shared", connectionId: account.connectionId, grantId: account.grantId }
|
|
: { provider, method: "api_key", mode: "responsible_user" },
|
|
};
|
|
},
|
|
});
|
|
}
|
|
|
|
registry.register<AgentRecord>({
|
|
id: "agent",
|
|
dependencies: [
|
|
"company",
|
|
"secrets",
|
|
"environment",
|
|
...((grokSubscription || codexSubscription) ? ["subscription-login"] : []),
|
|
...(managedHiring || savedCopilot || budgetedGateway ? ["ai-connection"] : []),
|
|
],
|
|
async setup(resolved) {
|
|
const company = value<CompanyRecord>(resolved, "company");
|
|
const environment = value<EnvironmentRecord>(resolved, "environment");
|
|
const secretRefs = value<SecretReferenceMap>(resolved, "secrets");
|
|
const agent = execution.profile.buildAgent({
|
|
environmentId: environment.id,
|
|
environmentFixtureId: execution.environment.id,
|
|
workspacePath: input.workspacePath,
|
|
secretRefs,
|
|
executionId: input.executionNonce,
|
|
});
|
|
const autoCodex = agent.adapterType === "codex_local" && (agent.runner === undefined || agent.runner === "auto");
|
|
const nativeCodex = agent.adapterType === "paperclip_runner" && (agent.adapterConfig as Record<string, unknown>).provider === "codex";
|
|
if (environment.driver === "sandbox" && execution.profile.generation === "native"
|
|
&& execution.profile.provider === "codex" && agent.runner !== "legacy" && (autoCodex || nativeCodex)) {
|
|
if (!isImmutableDaytonaImage(String(environment.config?.image ?? "")) || environment.config?.snapshot) {
|
|
throw new Error("Native Codex qualification requires this fixture's immutable image-backed environment.");
|
|
}
|
|
const startedAt = Date.now();
|
|
const probe = await api.post<{ ok: boolean; details?: { platformQualificationRecorded?: boolean; leaseId?: string } }>(
|
|
`/api/environments/${environment.id}/probe?companyId=${encodeURIComponent(company.id)}`,
|
|
{}, { timeout: 330_000 },
|
|
);
|
|
if (probe.ok !== true || probe.details?.platformQualificationRecorded !== true || !probe.details.leaseId) {
|
|
throw new Error("Native Codex image qualification was not recorded; agent creation was not attempted.");
|
|
}
|
|
setupProbe = { leaseId: probe.details.leaseId, durationMs: Date.now() - startedAt };
|
|
if (autoCodex) {
|
|
const adapters = await api.get<Array<{ type: string; defaultRunner?: string; supportedRunners?: string[] }>>(
|
|
`/api/adapters?companyId=${encodeURIComponent(company.id)}&environmentId=${encodeURIComponent(environment.id)}`,
|
|
);
|
|
const selected = adapters.find(adapter => adapter.type === "codex_local");
|
|
if (selected?.defaultRunner !== "paperclip" || !selected.supportedRunners?.includes("paperclip")) {
|
|
throw new Error("The qualified image does not advertise native Codex as its server-owned default.");
|
|
}
|
|
setupProbe.defaultRunner = selected.defaultRunner;
|
|
}
|
|
}
|
|
if (["stock-harness", "native-connection-guidance", "feedback-persistence"].includes(execution.suite.id)
|
|
|| (execution.suite.id === "everyday-workflows" && ["hire-reuse", "delegate-feedback"].includes(execution.task.id))) {
|
|
agent.budgetMonthlyCents = 1_000;
|
|
}
|
|
if (receiptSmoke) {
|
|
agent.budgetMonthlyCents = CASE_RECEIPT_BUDGET_CENTS;
|
|
agent.adapterConfig = { ...(agent.adapterConfig as Record<string, unknown>),
|
|
timeoutSec: CASE_RECEIPT_RUN_TIMEOUT_MS / 1_000, modelReasoningEffort: "low" };
|
|
const runtimeConfig = (agent.runtimeConfig ?? {}) as Record<string, unknown>;
|
|
agent.runtimeConfig = { ...runtimeConfig,
|
|
heartbeat: { ...((runtimeConfig.heartbeat ?? {}) as Record<string, unknown>),
|
|
enabled: false, maxConcurrentRuns: 1, maxDailyRuns: 1, maxDailyCostCents: CASE_RECEIPT_BUDGET_CENTS } };
|
|
}
|
|
if (managedHiring || savedCopilot || budgetedGateway) {
|
|
const account = value<ManagedAccountFixture>(resolved, "ai-connection");
|
|
const config = agent.adapterConfig as Record<string, unknown>;
|
|
delete config.env;
|
|
agent.runtimeConfig = {
|
|
...(agent.runtimeConfig as Record<string, unknown>),
|
|
aiConnection: account.binding,
|
|
};
|
|
}
|
|
return api.post<AgentRecord>(
|
|
`/api/companies/${company.id}/agents`,
|
|
codexSubscription ? codexSubscriptionAgentConfig(agent, process.env, company.id) : agent,
|
|
);
|
|
},
|
|
async teardown() {
|
|
// Agent state is instance-local. Daytona environment teardown below is
|
|
// the only fixture cleanup that must reach an external provider.
|
|
},
|
|
});
|
|
|
|
if (execution.task.flow === "repository_verification"
|
|
|| execution.task.flow === "finalization_recovery"
|
|
|| execution.task.flow === "followup_stop_resume"
|
|
|| execution.task.flow === "warm_three_turn"
|
|
|| (execution.suite.id === "extended-harnesses" && execution.task.id === "file-edit-validate")) {
|
|
registry.register<ProjectRecord>({
|
|
id: "project",
|
|
dependencies: ["company", "environment"],
|
|
async setup(resolved) {
|
|
const company = value<CompanyRecord>(resolved, "company");
|
|
const environment = value<EnvironmentRecord>(resolved, "environment");
|
|
return api.post<ProjectRecord>(
|
|
`/api/companies/${company.id}/projects`,
|
|
{
|
|
name: `Runner E2E workspace project ${input.executionNonce}`,
|
|
description:
|
|
"Ephemeral project anchoring the fixture execution workspace and file copy-back",
|
|
executionWorkspacePolicy: {
|
|
enabled: true,
|
|
defaultMode: "shared_workspace",
|
|
sharedWorkspaceConcurrency: "serialize",
|
|
allowIssueOverride: false,
|
|
environmentId: environment.id,
|
|
workspaceStrategy: { type: "project_primary" },
|
|
},
|
|
workspace: {
|
|
name: "Primary",
|
|
sourceType: "local_path",
|
|
cwd: input.workspacePath,
|
|
isPrimary: true,
|
|
},
|
|
},
|
|
);
|
|
},
|
|
async teardown() {
|
|
// The isolated instance is deleted after provider resources are gone.
|
|
},
|
|
});
|
|
}
|
|
|
|
const setup = await registry.setupAll();
|
|
return {
|
|
company: value<CompanyRecord>(setup.values, "company"),
|
|
secretRefs: value<SecretReferenceMap>(setup.values, "secrets"),
|
|
environment: value<EnvironmentRecord>(setup.values, "environment"),
|
|
agent: value<AgentRecord>(setup.values, "agent"),
|
|
...(setupProbe ? { setupProbe } : {}),
|
|
...(setup.values.has("project")
|
|
? { project: value<ProjectRecord>(setup.values, "project") }
|
|
: {}),
|
|
...(managedHiring
|
|
? {
|
|
aiConnection: value<ManagedAccountFixture>(
|
|
setup.values,
|
|
"ai-connection",
|
|
),
|
|
}
|
|
: {}),
|
|
teardown: setup.teardown,
|
|
};
|
|
}
|