fix: make Host updates simple and fast
GoodBuddy Agents / Validate Agent source (push) Canceled after 0s
GoodBuddy Agents / Build Linux arm64 Agent (push) Canceled after 0s
GoodBuddy Agents / Build Linux x64 Agent (push) Canceled after 0s
GoodBuddy Agent Release / Authorize Agent release (push) Canceled after 0s
Cross-platform packages / Validate source (push) Canceled after 0s
GoodBuddy Agent Release / Build Linux arm64 compound package (push) Canceled after 0s
GoodBuddy Agent Release / Build Linux x64 compound package (push) Canceled after 0s
GoodBuddy Agent Release / Sign cumulative Agent catalog (push) Canceled after 0s
GoodBuddy Agent Release / Publish Agent to GitHub and OSS (push) Canceled after 0s
Cross-platform packages / Authorize desktop packaging (push) Canceled after 0s
Cross-platform packages / linux arm64 (push) Canceled after 0s
Cross-platform packages / macos arm64 (push) Canceled after 0s
Cross-platform packages / windows arm64 (push) Canceled after 0s
Cross-platform packages / linux x64 (push) Canceled after 0s
Cross-platform packages / macos x64 (push) Canceled after 0s
Cross-platform packages / windows x64 (push) Canceled after 0s
Cross-platform packages / Publish GitHub and OSS release (push) Canceled after 0s

Host repair could fail while adopting the published OpenCode Runtime, then
repeat package and payload verification and carry durable metadata snapshots
for recovery. Host preparation now verifies each acquired compound archive
once, adopts signed Agent and Runtime metadata without rereading payload trees,
and retries failed work by cleaning staging and preparing fresh.

The desktop and Agent versions are advanced to 0.11.9 with the approved
bilingual release notes. Remote Projects remain a disabled-by-default technical
preview, Agent packages remain separate Linux x64/arm64 releases, and this
release has no LoongArch preview.

Release note: 修复 Host 更新采用失败,移除重复远端包体校验,并将中断恢复简化为清理暂存后重新准备。
This commit is contained in:
mesalogo
2026-08-29 22:31:39 +08:00
parent a99b90cc02
commit 85e14ca626
35 changed files with 1062 additions and 1951 deletions
+13 -8
View File
@@ -31,7 +31,7 @@ import {
loadRegisteredAgentBundle,
readManagedAgentReleaseKeyRegistry,
RegisteredAgentBundleError,
verifyInstalledAgentBundle,
verifyPublishedAgentBundle,
type VerifiedInstalledAgentBundle
} from './installed-bundle-verifier'
import { InstallationRegistry } from './installation-registry'
@@ -41,7 +41,7 @@ import {
import {
loadRegisteredRuntimeBundle,
readRemoteRuntimeLock,
verifyRuntimeBundle,
verifyPublishedRuntimeBundle,
type VerifiedRuntimeBundle
} from './runtime-bundle-verifier'
import { createProductionRuntimeProtocol } from './runtime-composition'
@@ -91,7 +91,7 @@ export type AgentCliDependencies = {
runtimeReleaseKeyRegistry?: AgentReleaseKeyRegistry
runtimeLock?: RemoteRuntimeLock
runtimeRegistry?: RuntimeBundleRegistry
verifyRuntime?: typeof verifyRuntimeBundle
verifyRuntime?: typeof verifyPublishedRuntimeBundle
runtimeVerificationEnvironment?: 'production' | 'test'
currentArchitecture?: () => AgentArchitecture
runModelBridgeHelper?: typeof runOpenCodeModelBridgeHelper
@@ -299,7 +299,7 @@ async function runRuntime(
const verified =
registered === undefined || forceVerification
? await (
dependencies.verifyRuntime ?? verifyRuntimeBundle
dependencies.verifyRuntime ?? verifyPublishedRuntimeBundle
)(paths.bundleDirectory, verificationOptions)
: await loadRegisteredRuntimeBundle(
registered.bundleDirectory,
@@ -524,10 +524,11 @@ async function runLifecycle(
paths,
dependencies
)
const alreadyCurrent =
const currentInstallationMatches =
registry.snapshot().current?.installationId ===
installationId
if (!alreadyCurrent) {
const alreadyCurrent = registry.isCurrent(verified)
if (!alreadyCurrent && !currentInstallationMatches) {
registry.stageCandidate(verified)
}
prepareManagedSocketDirectory(paths)
@@ -539,7 +540,11 @@ async function runLifecycle(
verified
).bootstrap()
if (!alreadyCurrent) {
registry.promoteCandidate(installationId)
if (currentInstallationMatches) {
registry.refreshCurrent(verified)
} else {
registry.promoteCandidate(installationId)
}
}
io.output.write(`${JSON.stringify(status)}\n`)
break
@@ -757,7 +762,7 @@ async function verifyManagedInstallation(
storagePath: resolve(agentRoot, 'registry.json')
})
const verified = await (
dependencies.verifyInstallation ?? verifyInstalledAgentBundle
dependencies.verifyInstallation ?? verifyPublishedAgentBundle
)(dirname(paths.executablePath), {
installationId,
architecture,
@@ -76,6 +76,33 @@ describe('Agent installation registry', () => {
).toThrow('authorized registry role')
})
it('replaces same-installation legacy metadata after verification', () => {
const root = privateTemporaryDirectory()
const storagePath = resolve(root, 'registry.json')
writeFileSync(
storagePath,
`${JSON.stringify({
formatVersion: 1,
current: {
installationId: 'install-a',
agentVersion: '0.11.1',
manifestSha256: 'a'.repeat(64),
arch: 'x64'
}
}, null, 2)}\n`,
{ mode: 0o600 }
)
const registry = new InstallationRegistry({ storagePath })
const current = verified('install-a', '0.11.1', 'a')
expect(registry.isCurrent(current)).toBe(false)
registry.refreshCurrent(current)
expect(registry.snapshot().current).toMatchObject({
installationId: 'install-a',
protocol: { major: 1, minor: 0 }
})
})
it('replaces a stale candidate with the requested signed identity', () => {
const { registry } = createRegistry()
registry.stageCandidate(verified('install-a', '0.11.0', 'a'))
+30 -1
View File
@@ -40,6 +40,14 @@ export class InstallationRegistry {
return structuredClone(this.#state)
}
isCurrent(verified: VerifiedInstalledAgentBundle): boolean {
const current = this.#state.current
return (
current !== undefined &&
entryEquals(current, entryFromVerified(verified))
)
}
stageCandidate(
verified: VerifiedInstalledAgentBundle
): InstallationRegistryEntry {
@@ -100,6 +108,25 @@ export class InstallationRegistry {
return this.snapshot()
}
refreshCurrent(
verified: VerifiedInstalledAgentBundle
): InstallationRegistryState {
const entry = entryFromVerified(verified)
if (
this.#state.current?.installationId !==
entry.installationId
) {
throw new Error(
'Verified Agent installation is not the current identity'
)
}
this.#commit({
formatVersion: 1,
current: entry
})
return this.snapshot()
}
assertVerifiedRole(
verified: VerifiedInstalledAgentBundle,
roles: readonly ('current' | 'candidate')[]
@@ -234,7 +261,9 @@ function entryEquals(
left.installationId === right.installationId &&
left.agentVersion === right.agentVersion &&
left.manifestSha256 === right.manifestSha256 &&
left.arch === right.arch
left.arch === right.arch &&
JSON.stringify(left.protocol) ===
JSON.stringify(right.protocol)
)
}
@@ -24,6 +24,7 @@ import {
canonicalInstalledAgentManifestBytes,
installedAgentManifestSignaturePayload,
loadRegisteredAgentBundle,
verifyPublishedAgentBundle,
verifyInstalledAgentBundle
} from './installed-bundle-verifier'
@@ -88,7 +89,7 @@ describe('installed Agent bundle verifier', () => {
'tampered'
)
await expect(verifyBundle()).rejects.toThrow(
/size mismatch|hash mismatch/u
/entrypoint metadata changed|size mismatch|hash mismatch/u
)
resetInstallation()
@@ -134,6 +135,26 @@ describe('installed Agent bundle verifier', () => {
})
it('adopts signed published metadata without rehashing unrelated payload', async () => {
writeBundle()
writeFileSync(
join(installationDirectory, 'licenses', 'GoodBuddy-0BSD.txt'),
'changed after extraction'
)
await expect(verifyPublishedBundle()).resolves.toMatchObject({
installationId: 'install-10',
manifest: { agentVersion: '0.11.0' }
})
writeFileSync(
join(installationDirectory, 'lib', 'agent.cjs'),
'changed entrypoint'
)
await expect(verifyPublishedBundle()).rejects.toThrow(
'entrypoint metadata changed'
)
})
it('loads Host-managed registry evidence without repeating signature or payload verification', async () => {
writeBundle()
const manifestBytes = readFileSync(
@@ -269,6 +290,16 @@ function verifyBundle() {
})
}
function verifyPublishedBundle() {
return verifyPublishedAgentBundle(installationDirectory, {
installationId: 'install-10',
architecture: 'x64',
releaseKeyRegistry,
verificationEnvironment: 'test',
enforceFilesystemMode: process.platform !== 'win32'
})
}
function elf(architecture: 'x64' | 'arm64'): Buffer {
const header = Buffer.alloc(64)
header.set([0x7f, 0x45, 0x4c, 0x46])
+101 -69
View File
@@ -110,6 +110,66 @@ export async function readManagedAgentReleaseKeyRegistry(
export async function verifyInstalledAgentBundle(
installationDirectoryInput: string,
options: VerifyInstalledAgentBundleOptions
): Promise<VerifiedInstalledAgentBundle> {
const verified = await verifyPublishedAgentBundle(
installationDirectoryInput,
options
)
const {
installationDirectory,
manifest
} = verified
const declaredPaths = new Set(
manifest.files.map((file) => file.path)
)
for (const file of manifest.files) {
const filePath = join(
installationDirectory,
...file.path.split('/')
)
const stat = await lstat(filePath)
assertOwnedRegularFile(stat, file.path, options.uid)
if (stat.size !== file.size) {
throw new Error(`Agent payload size mismatch: ${file.path}`)
}
if ((await sha256File(filePath)) !== file.sha256) {
throw new Error(`Agent payload hash mismatch: ${file.path}`)
}
if (
shouldEnforceMode(options) &&
modeString(stat.mode) !== file.mode
) {
throw new Error(`Agent payload mode mismatch: ${file.path}`)
}
}
const actualPaths = new Set(
await listInstallationFiles(installationDirectory, options)
)
const expectedPaths = new Set([
...declaredPaths,
MANIFEST_FILE_NAME,
SIGNATURE_FILE_NAME
])
if (
actualPaths.size !== expectedPaths.size ||
[...actualPaths].some((path) => !expectedPaths.has(path))
) {
throw new Error(
'Agent installation contains undeclared or missing files'
)
}
return verified
}
/**
* Authenticates a package-installer-published Agent from signed metadata and
* bounded entrypoint metadata. The installer already hashed every payload
* file while extracting it.
*/
export async function verifyPublishedAgentBundle(
installationDirectoryInput: string,
options: VerifyInstalledAgentBundleOptions
): Promise<VerifiedInstalledAgentBundle> {
const installationId = validateInstallationId(options.installationId)
const installationDirectory = resolve(installationDirectoryInput)
@@ -162,47 +222,11 @@ export async function verifyInstalledAgentBundle(
)
}
const declaredPaths = new Set(
manifest.files.map((file) => file.path)
const executablePath = await assertAgentEntrypoints(
installationDirectory,
manifest,
options
)
for (const file of manifest.files) {
const filePath = join(
installationDirectory,
...file.path.split('/')
)
const stat = await lstat(filePath)
assertOwnedRegularFile(stat, file.path, options.uid)
if (stat.size !== file.size) {
throw new Error(`Agent payload size mismatch: ${file.path}`)
}
if ((await sha256File(filePath)) !== file.sha256) {
throw new Error(`Agent payload hash mismatch: ${file.path}`)
}
if (
shouldEnforceMode(options) &&
modeString(stat.mode) !== file.mode
) {
throw new Error(`Agent payload mode mismatch: ${file.path}`)
}
}
const actualPaths = new Set(
await listInstallationFiles(installationDirectory, options)
)
const expectedPaths = new Set([
...declaredPaths,
MANIFEST_FILE_NAME,
SIGNATURE_FILE_NAME
])
if (
actualPaths.size !== expectedPaths.size ||
[...actualPaths].some((path) => !expectedPaths.has(path))
) {
throw new Error(
'Agent installation contains undeclared or missing files'
)
}
await assertElfArchitecture(
join(installationDirectory, manifest.entrypoint.runtimePath),
manifest.arch,
@@ -212,10 +236,7 @@ export async function verifyInstalledAgentBundle(
return {
installationId,
installationDirectory,
executablePath: join(
installationDirectory,
manifest.entrypoint.path
),
executablePath,
manifest,
manifestSha256,
binaryDigest: `sha256:${manifestSha256}`
@@ -326,19 +347,9 @@ async function loadRegisteredAgentBundleUnchecked(
)
}
const executablePath = join(
const executablePath = await assertAgentEntrypoints(
installationDirectory,
manifest.entrypoint.path
)
await assertRegisteredEntrypoint(executablePath, '0755', options)
await assertRegisteredEntrypoint(
join(installationDirectory, manifest.entrypoint.runtimePath),
'0755',
options
)
await assertRegisteredEntrypoint(
join(installationDirectory, manifest.entrypoint.scriptPath),
'0644',
manifest,
options
)
return {
@@ -500,24 +511,45 @@ function importPublicKey(key: AgentReleaseKey) {
return publicKey
}
async function assertRegisteredEntrypoint(
filePath: string,
expectedMode: string,
async function assertAgentEntrypoints(
installationDirectory: string,
manifest: AgentBundleManifest,
options: Pick<
LoadRegisteredAgentBundleOptions,
VerifyInstalledAgentBundleOptions,
'uid' | 'filesystemPlatform' | 'enforceFilesystemMode'
>
): Promise<void> {
const stat = await lstat(filePath)
assertOwnedRegularFile(stat, filePath, options.uid)
if (
shouldEnforceMode(options) &&
modeString(stat.mode) !== expectedMode
) {
throw new Error(
`Agent payload mode mismatch: ${basename(filePath)}`
): Promise<string> {
for (const path of [
manifest.entrypoint.path,
manifest.entrypoint.runtimePath,
manifest.entrypoint.scriptPath
]) {
const record = manifest.files.find((file) => file.path === path)
if (record === undefined) {
throw new Error(`Agent entrypoint is not declared: ${path}`)
}
const filePath = join(
installationDirectory,
...path.split('/')
)
const stat = await lstat(filePath)
assertOwnedRegularFile(stat, filePath, options.uid)
if (
stat.size !== record.size ||
(
shouldEnforceMode(options) &&
modeString(stat.mode) !== record.mode
)
) {
throw new Error(
`Agent entrypoint metadata changed: ${basename(filePath)}`
)
}
}
return join(
installationDirectory,
manifest.entrypoint.path
)
}
async function readMetadataFile(
+4 -15
View File
@@ -283,8 +283,8 @@ async function loadVerifiedRuntimeCapabilities(
entry.runtimeId,
entry.bundleDigest
)
const verified = options.loadRegistered === undefined
? await loadRegisteredRuntimeBundle(
await (options.loadRegistered === undefined
? loadRegisteredRuntimeBundle(
bundleDirectory,
{
registered: entry,
@@ -315,21 +315,10 @@ async function loadVerifiedRuntimeCapabilities(
: { uid: options.uid })
}
)
: await options.loadRegistered(
: options.loadRegistered(
entry,
bundleDirectory
)
if (
verified.manifest.runtimeVersion !== entry.runtimeVersion ||
verified.manifestDigest !== entry.manifestDigest ||
verified.manifest.bundleDigest !== entry.bundleDigest ||
verified.manifest.acpCapabilitiesDigest !==
entry.acpCapabilitiesDigest
) {
throw new Error(
'Runtime bundle no longer matches its registry identity'
)
}
))
capabilities.push({
runtimeId: entry.runtimeId,
version: entry.runtimeVersion,
@@ -8,7 +8,10 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import {
type RemoteRuntimeBundleManifest
} from '../shared/remote-runtime-launch-contracts'
import { verifyRuntimeBundle } from './runtime-bundle-verifier'
import {
verifyPublishedRuntimeBundle,
verifyRuntimeBundle
} from './runtime-bundle-verifier'
import {
RuntimeBundleRegistry,
createVerifiedRuntimeCapabilitySource
@@ -216,6 +219,45 @@ describe('Remote Runtime bundle verifier', () => {
expect.any(Error)
)
})
it('adopts signed published metadata without rehashing unrelated payload', async () => {
const fixture = await createBundle()
const options = {
architecture: 'x64' as const,
releaseKeyRegistry: fixture.registry,
runtimeLock: lock,
verificationEnvironment: 'test' as const,
filesystemPlatform: 'win32' as const
}
writeFileSync(
join(fixture.bundleDirectory, 'licenses', 'opencode.txt'),
'changed after extraction'
)
await expect(
verifyPublishedRuntimeBundle(
fixture.bundleDirectory,
options
)
).resolves.toMatchObject({
manifest: { runtimeVersion: '1.18.9' }
})
writeFileSync(
join(fixture.bundleDirectory, 'bin', 'opencode'),
Buffer.concat([
readFileSync(
join(fixture.bundleDirectory, 'bin', 'opencode')
),
Buffer.from('changed')
])
)
await expect(
verifyPublishedRuntimeBundle(
fixture.bundleDirectory,
options
)
).rejects.toThrow('entrypoint metadata changed')
})
})
async function createBundle(
@@ -3,6 +3,7 @@ export {
loadRegisteredRuntimeBundle,
readRemoteRuntimeLock,
runtimeManifestSignaturePayload,
verifyPublishedRuntimeBundle,
verifyRuntimeBundle,
verifyRuntimeManifestSignature
} from '../shared/node/runtime-bundle-verifier'
+1 -11
View File
@@ -240,20 +240,10 @@ export async function createProductionRuntimeProtocol(
options.architecture
),
loadRegisteredRuntimeBundle: async (resolved) => {
const verified = await loadRegistered(
return await loadRegistered(
resolved.entry,
resolved.bundleDirectory
)
if (
verified.manifestDigest !== resolved.entry.manifestDigest ||
verified.manifest.bundleDigest !==
resolved.entry.bundleDigest
) {
throw new Error(
'Runtime bundle no longer matches its registered identity'
)
}
return verified
},
resolveWorkspace: async (preparation, context) =>
resolveCurrentWorkspace(