Files
claude-code-haha/scripts/quality-gate/persistence-upgrade.ts
T
程序员阿江(Relakkes) ea8d7be6ca fix(agent-teams): enforce task dependencies in approved teams
An approved team handed every member its instructions at the same moment,
so members whose tasks depended on unfinished work started anyway: the
second and third layers of a plan ran before the first, a member could mark
a blocked task in progress, and results only ever went to the lead. The
official CLI states dependencies in tool prompts and nothing more, so the
plan the user approved was not what ran.

- A member whose tasks all wait on other tasks gets its instructions only
  once one of them is ready. What the lead or a teammate sends it before
  that waits in its inbox and arrives with the instructions; only the user
  writing to it, or a shutdown request, reaches it earlier. This survives a
  Stop and a server restart.
- TaskUpdate refuses a teammate that starts or completes a task while a
  task it is blocked by is unfinished. The lead is not held to it.
- Each member is told who waits on its tasks and to send them its result
  before completing, so a dependent member starts with that result in
  hand. A member that starts without one is told whose is missing.
- A member that exits after approving a shutdown request is no longer
  recorded as failed, and the lead gets no failure notice for it. The
  shutdown-approval schema keeps leaving out the desktop backend on
  purpose, now documented and tested.
- TeamPlan tells the lead that a dependent member's prompt is delivered
  when its dependencies are done.
2026-10-06 01:43:38 +08:00

111 lines
3.7 KiB
TypeScript

#!/usr/bin/env bun
type Check = {
title: string
command: string[]
cwd?: string
}
const rootDir = process.cwd()
const checks: Check[] = [
{
title: 'Data directory relocation metadata and legacy attachment aliases',
command: ['bun', 'test', './src/utils/storageMigrationMetadata.test.ts', './src/utils/storageRelocations.test.ts'],
},
{
title: 'Desktop data migration journal recovery and credential namespace copy',
command: ['bun', 'run', 'test', '--', '--run', 'electron/services/dataMigration.test.ts', 'electron/services/migrationCredentials.test.ts'],
cwd: 'desktop',
},
{
title: 'Agent Teams plan sidecar compatibility and approval recovery',
command: ['bun', 'test', './src/utils/swarm/teamPlanStore.test.ts', './src/server/services/teamPlanService.test.ts'],
},
{
title: 'Agent Teams legacy mailbox migration to unread inbox plus history',
command: ['bun', 'test', './src/utils/teammateMailbox.test.ts', '--test-name-pattern', 'legacy inbox files'],
},
{
title: 'Agent Teams members recorded before deferred instructions rehydrate as already instructed',
command: ['bun', 'test', './src/server/services/teamPlanRuntime.supervisor.test.ts', '--test-name-pattern', 'written before deferred instructions'],
},
{
title: 'Agent Teams teammate resume from agent metadata written before the teammate fields',
command: ['bun', 'test', './src/utils/swarm/inProcessRunner.resume.test.ts', '--test-name-pattern', 'metadata written before'],
},
{
title: 'Session collaboration state migration and recovery',
command: ['bun', 'test', './src/server/services/sessionCollaborationService.test.ts', '--test-name-pattern', 'migrat|recover'],
},
{
title: 'Connector installation state migrations',
command: ['bun', 'test', './src/server/services/connectorsPersistence.test.ts'],
},
{
title: 'Public browser device store migration',
command: ['bun', 'test', './src/server/publicAccess.test.ts', '--test-name-pattern', 'old store migration'],
},
{
title: 'Private ngrok credential store migration',
command: ['bun', 'run', 'test', '--', '--run', 'electron/services/publicAccess.test.ts', '-t', 'migrat'],
cwd: 'desktop',
},
{
title: 'Local index schema compatibility after protocol rollback',
command: [
'bun', 'test', './src/server/services/localIndex/database.test.ts',
'--test-name-pattern', 'frozen v[45]',
],
},
{
title: 'Trace projection resource-window schema migrations',
command: ['bun', 'test', './src/server/services/localIndex/traceIndex.test.ts'],
},
{
title: 'Server persistent JSON migrations',
command: ['bun', 'test', './src/server/__tests__/persistence-upgrade.test.ts'],
},
{
title: 'Desktop UI preference migrations',
command: [
'bun',
'test',
'./src/server/__tests__/desktop-ui-preferences.test.ts',
'--test-name-pattern',
'normalizes old schema files',
],
},
{
title: 'Desktop localStorage migrations',
command: ['bun', 'run', 'test', '--', '--run', 'src/lib/persistenceMigrations.test.ts'],
cwd: 'desktop',
},
]
async function runCheck(check: Check): Promise<number> {
const cwd = check.cwd ? `${rootDir}/${check.cwd}` : rootDir
console.log(`\n[persistence-upgrade] ${check.title}`)
console.log(`$ ${check.command.join(' ')}`)
const proc = Bun.spawn(check.command, {
cwd,
stdout: 'inherit',
stderr: 'inherit',
})
return proc.exited
}
let failures = 0
for (const check of checks) {
const code = await runCheck(check)
if (code !== 0) {
failures += 1
}
}
if (failures > 0) {
console.error(`\n[persistence-upgrade] failed checks: ${failures}`)
process.exit(1)
}
console.log('\n[persistence-upgrade] all checks passed')