From 016e069cb22ddd568f85e552c8dc9d3348acadc7 Mon Sep 17 00:00:00 2001 From: Dotta Date: Wed, 4 Nov 2026 18:35:05 -0600 Subject: [PATCH] fix(runtime): narrow missing pre-copy stamps before publication checks Co-Authored-By: Paperclip --- .../services/native-runtime/native-harness-backup-storage.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/services/native-runtime/native-harness-backup-storage.ts b/server/src/services/native-runtime/native-harness-backup-storage.ts index cc1b8f96a04..eff1a75f618 100644 --- a/server/src/services/native-runtime/native-harness-backup-storage.ts +++ b/server/src/services/native-runtime/native-harness-backup-storage.ts @@ -30,7 +30,7 @@ type OfflineOwner = { kind: "offline_migration"; companyId: string; issueId: str writersStopped: true; terminalFailureOnly?: true }; type InactiveSource = { root: string; manifestSha256: string; scopeDigest: string; normalizedSessionId: string; runnerInstanceId: string; providerLeaseId: string }; -const fail = (reason: string): never => { throw new Error(`native_harness_storage_${reason}`); }; +function fail(reason: string): never { throw new Error(`native_harness_storage_${reason}`); } const aad = (binding: Binding) => Buffer.from(JSON.stringify([SCHEMA, binding.companyId, binding.scopeDigest, binding.id])); const scope = (binding: Pick) => and( eq(nativeHarnessBackups.companyId, binding.companyId), eq(nativeHarnessBackups.scopeDigest, binding.scopeDigest)); @@ -159,7 +159,7 @@ async function fence(tx: Parameters[0]>[0], owner: eq(environmentLeases.issueId, owner.issueId), eq(environmentLeases.providerLeaseId, inactiveSource.providerLeaseId), sql`${environmentLeases.metadata}->'nativeHarnessBackup'->>'manifestSha256' = ${inactiveSource.manifestSha256}`)).limit(1); const stamp = readNativeHarnessBackupStamp(lease?.stamp, inactiveSource.providerLeaseId); - if (!binding || stamp?.sessionScopeSha256 !== inactiveSource.scopeDigest + if (!binding || !stamp || stamp.sessionScopeSha256 !== inactiveSource.scopeDigest || stamp.normalizedSessionId !== inactiveSource.normalizedSessionId || stamp.runnerInstanceId !== inactiveSource.runnerInstanceId) { fail("prestage_source_changed"); }