From 15815eca6aa89fef4d70c5dfba24fc030ea0021d Mon Sep 17 00:00:00 2001 From: haelyra <49814733+haelyra@users.noreply.github.com> Date: Mon, 24 Aug 2026 21:30:19 -0400 Subject: [PATCH] fix(install): advance guided state checkpoints safely --- scripts/lib/multi-harness-setup.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/lib/multi-harness-setup.js b/scripts/lib/multi-harness-setup.js index 76826eea5..30b9d469d 100644 --- a/scripts/lib/multi-harness-setup.js +++ b/scripts/lib/multi-harness-setup.js @@ -113,6 +113,14 @@ function fingerprintFile(filePath) { }; } +function fingerprintInstallStateValue(state) { + const content = Buffer.from(`${JSON.stringify(state, null, 2)}\n`); + return { + exists: true, + sha256: crypto.createHash('sha256').update(content).digest('hex'), + }; +} + function operationIdentityMatches(stateOperation, plannedOperation) { return [ 'kind', @@ -364,11 +372,15 @@ async function applyPreflightedManagedPlan(entry) { ? entry.preview : preflightManagedPlan(entry.preview.plan); const ownedDestinations = new Set(preview.ownershipSnapshot.destinations); - const expectedStateFingerprint = preview.ownershipSnapshot.stateFingerprint; + let expectedStateFingerprint = preview.ownershipSnapshot.stateFingerprint; let operationIndex = 0; const assertStateUnchanged = () => ( assertInstallStateUnchanged(preview.plan, expectedStateFingerprint) ); + const prepareInstallStateWrite = ({ state }) => { + assertStateUnchanged(); + expectedStateFingerprint = fingerprintInstallStateValue(state); + }; const result = require('./install-executor').applyInstallPlan(preview.plan, { beforeInstallStateRead: assertStateUnchanged, @@ -390,7 +402,7 @@ async function applyPreflightedManagedPlan(entry) { ownedDestinations.add(destination); operationIndex += 1; }, - beforeInstallStateWrite: assertStateUnchanged, + beforeInstallStateWrite: prepareInstallStateWrite, }); const { projectCanonicalInstallState } = require('./install-state-store-sync'); const installStateProjection = await projectCanonicalInstallState(result.statePreview);