From 5782667a40c4f00058a4feb9840f1185cfbcb642 Mon Sep 17 00:00:00 2001 From: mesalogo Date: Wed, 9 Sep 2026 11:29:37 +0800 Subject: [PATCH] fix: accept equivalent remote runtime lock formatting --- .../remote-runtime-resource-loader.test.ts | 15 +++++++++++++++ .../remote-runtime-resource-loader.ts | 12 ++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/remote-agent/remote-runtime-resource-loader.test.ts b/src/main/remote-agent/remote-runtime-resource-loader.test.ts index 85013e12..b4c90cca 100644 --- a/src/main/remote-agent/remote-runtime-resource-loader.test.ts +++ b/src/main/remote-agent/remote-runtime-resource-loader.test.ts @@ -102,6 +102,21 @@ describe('remote Runtime verification metadata loader', () => { }) }) + it('canonicalizes equivalent Runtime lock formatting', async () => { + const fixture = await createFixture() + await writeFile( + fixture.paths.runtimeLockPath, + JSON.stringify(runtimeLock) + ) + + await expect( + loadRemoteRuntimeVerificationMetadata(fixture.paths) + ).resolves.toMatchObject({ + runtimeLock, + canonicalRemoteRuntimeLockBytes: canonical(runtimeLock) + }) + }) + it.each([ { bytes: Buffer.from('not json\n'), error: 'invalid JSON' }, { diff --git a/src/main/remote-agent/remote-runtime-resource-loader.ts b/src/main/remote-agent/remote-runtime-resource-loader.ts index 06b8bde8..130e3e9b 100644 --- a/src/main/remote-agent/remote-runtime-resource-loader.ts +++ b/src/main/remote-agent/remote-runtime-resource-loader.ts @@ -100,8 +100,7 @@ export async function loadRemoteRuntimeVerificationMetadata( readCanonicalMetadata( paths.keyRegistryPath, { parse: parseAgentReleaseKeyRegistry }, - 'Runtime release-key registry', - true + 'Runtime release-key registry' ), readCanonicalMetadata( paths.runtimeLockPath, @@ -133,8 +132,7 @@ function assertSafeVerificationInjection( async function readCanonicalMetadata( filePathInput: string, schema: { parse(value: unknown): T }, - label: string, - acceptEquivalentJsonFormatting = false + label: string ): Promise> { const filePath = resolve(filePathInput) const pathStat = await lstat(filePath) @@ -207,12 +205,6 @@ async function readCanonicalMetadata( `${JSON.stringify(value, null, 2)}\n`, 'utf8' ) - if ( - !acceptEquivalentJsonFormatting && - !canonicalBytes.equals(bytes) - ) { - throw new Error(`${label} is not canonical`) - } return { bytes: canonicalBytes, value } }