fix(pty): preserve owner close without incarnation

This commit is contained in:
Merge Sim
2026-08-31 16:03:59 -07:00
parent d6dbc3b486
commit 387cf89afd
2 changed files with 22 additions and 1 deletions
@@ -69,6 +69,24 @@ describe('killPtySessions input bounds', () => {
])
})
it('allows explicit owner-close when a capable host omits incarnation evidence', async () => {
const provider = {
listProcesses: vi.fn(async () => []),
supportsIncarnationFence: vi.fn(() => true)
}
const shutdown = vi.fn(async () => undefined)
const results = await killPtySessions([{ id: 'session-1' }], 'owner-close', {
listProviders: () => [{ provider: provider as never }],
providerForSession: () => provider as never,
shutdown,
supportsIncarnationFence: (target, id) =>
target.supportsIncarnationFence?.({ sessionId: id }) ?? false
})
expect(shutdown).toHaveBeenCalledTimes(1)
expect(results).toEqual([{ id: 'session-1', verdict: 'exited' }])
})
it('resolves incarnation-fence capability per session route', async () => {
const provider = {
listProcesses: vi.fn(async () => []),
+4 -1
View File
@@ -81,7 +81,10 @@ export async function killPtySessions(
}
}
fenceCapabilities.set(ref.id, fenceCapable)
if (fenceCapable && !ref.incarnationId) {
// Orphan cleanup must prove the exact incarnation before acting. Explicit
// owner-close is already user-authorized and retains legacy id-only behavior
// when the listing omits an incarnation.
if (intent === 'orphan-cleanup' && fenceCapable && !ref.incarnationId) {
return { ...ref, verdict: 'refused', reason: 'missing incarnation fence' }
}
try {