fix(cli-demo): preserve disposal diagnostics

Report context-disposal failure as an independent outcome even when argument, boot, task, or output handling has already produced a primary diagnostic.

Keep the primary error first, append the cleanup error, and retain the nonzero exit status so operators can see both the initiating failure and the possibility that teardown or persistence did not complete.

Add a regression that combines an invalid app composition with a failing disposer and asserts both ordered stderr lines.
This commit is contained in:
Tianyi Cui
2026-07-19 14:31:33 +08:00
parent ba693f0355
commit 1698f0baa6
2 changed files with 15 additions and 2 deletions

View File

@@ -398,6 +398,18 @@ describe('runOneShot and executeCli', () => {
expect(disposalOutput.stderr).toContain('dispose exploded')
})
it('reports disposal failure alongside an earlier run failure', async () => {
const ctx = new Context()
liveContexts.push(ctx)
const output = await invoke(ctx, ['task'], { failDispose: true })
expect(output).toEqual({
code: 1,
stdout: '',
stderr: 'dsh-cli-demo: config must create exactly one top-level agent, found 0\n'
+ 'dsh-cli-demo: dispose failed: dispose exploded\n',
})
})
it('cancels startup work and queued work before the correlated turn begins', async () => {
const startup = await harness(['hang'])
let started!: () => void