diff --git a/server/src/__tests__/agent-directory-working-copies.test.ts b/server/src/__tests__/agent-directory-working-copies.test.ts index 29cc125c76..e7d2b32ee0 100644 --- a/server/src/__tests__/agent-directory-working-copies.test.ts +++ b/server/src/__tests__/agent-directory-working-copies.test.ts @@ -12,7 +12,6 @@ import { eq } from "drizzle-orm"; import { agentFileStore, fileHash, inspectAgentFile, snapshotAgentFiles, MAX_AGENT_FILE_BYTES, MAX_AGENT_DIRECTORY_BYTES, MAX_AGENT_DIRECTORY_ENTRIES } from "../services/agent-file-store.js"; import { agents, companies, authUsers, companyMemberships, principalPermissionGrants, heartbeatRuns, environmentLeases, environments, agentInstructionWorkingCopies, agentInstructionRevisions, agentInstructionHeads, createDb } from "@paperclipai/db"; import { startEmbeddedPostgresTestDatabase } from "./helpers/embedded-postgres.js"; -import { agentDirectoryWorkingCopyService } from "../services/agent-directory-working-copies.js"; import { agentInstructionRevisionService } from "../services/agent-instruction-revisions.js"; import { agentInstructionWorkingCopyService, instructionWorkingCopyGuidance } from "../services/agent-instruction-working-copies.js"; import { resolveManagedInstructionsRoot } from "../services/agent-instructions.js"; @@ -898,10 +897,14 @@ describe("persistent agent directories", () => { } }, }; - const executionTarget = { kind: "remote" as const, transport: "sandbox" as const, environmentId: randomUUID(), remoteCwd, runner }; + const executionTarget = { kind: "remote" as const, transport: "sandbox" as const, environmentId: randomUUID(), leaseId: "", remoteCwd, runner }; + await db.insert(environments).values({ id: executionTarget.environmentId, name: "Warm fixture sandbox", driver: "sandbox" }); const prepare = async (reuseRunId?: string) => { const runId = randomUUID(); await db.insert(heartbeatRuns).values({ id: runId, companyId, agentId, invocationSource: "on_demand", responsibleUserId: userId }); + executionTarget.leaseId = randomUUID(); + await db.insert(environmentLeases).values({ id: executionTarget.leaseId, companyId, environmentId: executionTarget.environmentId, + heartbeatRunId: runId, provider: "daytona", providerLeaseId: "warm-fixture-allocation" }); return (await copies.prepare({ ...target(), runId, cwd: home, target: executionTarget, warm: true, reuseRunId }))!; }; let copy = await prepare(); @@ -919,7 +922,7 @@ describe("persistent agent directories", () => { } await copies.collectStopped({ companyId, runId: original.runId, target: executionTarget }); expect(await fs.stat(copy.executionRoot)).toBeTruthy(); - await copies.collectStopped({ companyId, runId: copy.runId, target: executionTarget }); + expect((await copies.collectStopped({ companyId, runId: copy.runId, target: executionTarget }))?.receipt).toMatchObject({ cleanupPending: false }); await expect(fs.stat(copy.executionRoot)).rejects.toMatchObject({ code: "ENOENT" }); }); diff --git a/server/src/services/native-runtime/status-arbiter.test.ts b/server/src/services/native-runtime/status-arbiter.test.ts index 2eaff32cd3..9fd0454422 100644 --- a/server/src/services/native-runtime/status-arbiter.test.ts +++ b/server/src/services/native-runtime/status-arbiter.test.ts @@ -51,7 +51,15 @@ describe("native status authority", () => { expect(arbitrate({ assessment: passive, cursorPlanWaitAuthorized: true })).toMatchObject({ toStatus: "in_progress", reasonCode: "native_plan_accepted_waiting_for_continuation", effects: [], }); - expect(arbitrate({ assessment: passive })).toMatchObject({ reasonCode: "live_continuation_registered" }); + expect(arbitrate({ assessment: passive })).toMatchObject({ + toStatus: "in_progress", + reasonCode: "completion_evidence_incomplete", + effects: [expect.objectContaining({ + kind: "enqueue_continuation", + continuationKind: "same_agent", + idempotencyKey: "native-completion-incomplete", + })], + }); expect(arbitrate({ assessment: passive, cursorPlanWaitAuthorized: true, terminalState: "failed" }).reasonCode).not.toBe("native_plan_accepted_waiting_for_continuation"); expect(arbitrate({ assessment: passive, cursorPlanWaitAuthorized: true, priorIssueStatus: "cancelled" }).toStatus).toBe("cancelled"); expect(arbitrate({ assessment: passive, cursorPlanWaitAuthorized: true, governanceGate: { kind: "interaction", id: "pending" } }).toStatus).toBe("in_review");