From aa6910939b7c99a544884006eecda9870e7ddf39 Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Wed, 14 Oct 2026 23:41:48 -0500 Subject: [PATCH] test(runtime): share the projectless local lease acquisition (#16086) Co-Authored-By: Paperclip --- ...0-12-test-audit-r15-environment-runtime.md | 62 +++++++++++++++++++ .../src/__tests__/environment-runtime.test.ts | 19 +----- 2 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 doc/plans/2026-10-12-test-audit-r15-environment-runtime.md diff --git a/doc/plans/2026-10-12-test-audit-r15-environment-runtime.md b/doc/plans/2026-10-12-test-audit-r15-environment-runtime.md new file mode 100644 index 00000000000..baa0a125523 --- /dev/null +++ b/doc/plans/2026-10-12-test-audit-r15-environment-runtime.md @@ -0,0 +1,62 @@ +# Environment runtime test audit — 2026-10-12 + +Parent: #16083 (`codex/test-audit-r14-browser`), exact head +`1113d4c9eaa49311c9b269c96b79bbae06d42e25`. + +## Change and keeper + +`server/src/__tests__/environment-runtime.test.ts:1405–1420` repeats the local +projectless acquisition already executed by the lifecycle test at1371. Both +use the same `seedEnvironment()` call, runtime, suite hooks and acquisition +input. The seed/acquire statements are AST-identical. Both tests originated +in `70679a33216` (Add sandbox environment support, #4415). + +Move the unique `lease.executionWorkspaceId` null assertion into the keeper +at1383. Keep the exact `leaseContext` equality, which already checks its two +null fields. Every original keeper statement remains unchanged and ordered. +The keeper also releases the lease and checks the durable released row. + +One file: +2/-17 test lines, net15 fewer lines. One registered case and one +redundant seed/acquisition/setup/cleanup cycle disappear (162→161 cases). +No production behavior changes. Provider, SSH, company access, secret +resolution/redaction, timeout precedence, session and recovery cases remain. + +## Exact-parent proof + +| Phase | Passed | Failed | Filtered/pending | +|---|---|---|---| +| Full baseline | 162 | 0 | 0 | +| Full candidate | 161 | 0 | 0 | +| Unmutated keeper control | 1 | 0 | 160 | +| Production mutation, intended keeper | 0 | 1 | 160 | +| Owner restored, full candidate | 161 | 0 | 0 | +| All source reverted, full parent | 162 | 0 | 0 | + +Proof-only production mutation at `environment-runtime.ts:4047`: acquisition +returns `lease: { ...lease, executionWorkspaceId: lease.executionWorkspaceId +?? input.environment.id }`. This real return-mapping fault leaves context and +DB setup intact. The relocated assertion at1383:49 rejects the environment +UUID because a projectless lease must return null. Production bytes were +restored before the full candidate replay. The mutation is not in this PR. + +The first reverted run had a suite-level startup failure (3 pure tests passed, +159 DB cases pending, no assertion failure). JSON-only output omitted the +hook diagnostic. An unchanged-source rerun with the default reporter passed +162/162. The failed attempt remains in the temporary receipt. No CI speedup +is claimed from the single local samples. + +## Hashes and receipts + +- Parent test SHA-256: `a7370481526c91044a020cf0e56a5ab4f27a7289c6ee8bcf94e414d7b70ab35a`. +- Candidate test SHA-256: `39069f6d8261886b9c9521a7e3e5026051d90287b5e14c471d589fde384832e7`. +- Production owner SHA-256: `77da04770ef8e87dd868f90a65c10ae2322a95ad1d8d78e73facb1be3443c0f8`. +- Identical seed/acquisition AST SHA-256: `d25af395dc9775474276cefbedd2d736ddfca7c57263db5543c603e52b6f96d3`. + +Full read: 7,223 lines, 100 declarations, 162 cases, two suites and four hooks. +The full ledger, case mapping, patch, preservation proof and JSON/log receipts +are in `/private/tmp/test-audit-environment-runtime/`. + +Local verification uses the full owner with the unchanged server Vitest +configuration. Full repository test/build preflight is deferred to isolated +CI because this audit worktree shares dependency symlinks and preflight +rewrites workspace package links. CI must pass before a green handoff. diff --git a/server/src/__tests__/environment-runtime.test.ts b/server/src/__tests__/environment-runtime.test.ts index e2cd5201336..ca6944dc2f2 100644 --- a/server/src/__tests__/environment-runtime.test.ts +++ b/server/src/__tests__/environment-runtime.test.ts @@ -1368,7 +1368,7 @@ describeEmbeddedPostgres("environmentRuntimeService", () => { }); }); - it("acquires and releases a local run lease through the runtime seam", async () => { + it("acquires and releases a projectless local run lease through the runtime seam", async () => { const { companyId, environment, runId } = await seedEnvironment(); const acquired = await runtime.acquireRunLease({ @@ -1380,6 +1380,7 @@ describeEmbeddedPostgres("environmentRuntimeService", () => { }); expect(acquired.lease.status).toBe("active"); + expect(acquired.lease.executionWorkspaceId).toBeNull(); expect(acquired.lease.metadata).toMatchObject({ driver: "local", executionWorkspaceMode: null, @@ -1402,22 +1403,6 @@ describeEmbeddedPostgres("environmentRuntimeService", () => { expect(rows[0]?.status).toBe("released"); }); - it("allows projectless runs through the runtime seam", async () => { - const { companyId, environment, runId } = await seedEnvironment(); - - const acquired = await runtime.acquireRunLease({ - companyId, - environment, - issueId: null, - heartbeatRunId: runId, - persistedExecutionWorkspace: null, - }); - - expect(acquired.lease.executionWorkspaceId).toBeNull(); - expect(acquired.leaseContext.executionWorkspaceId).toBeNull(); - expect(acquired.leaseContext.executionWorkspaceMode).toBeNull(); - }); - it("rejects truly unsupported drivers before acquiring a lease", async () => { const { companyId, agentId, environment, runId } = await seedEnvironment({ driver: "ssh",