fix(team): reject failed opencode session handles
This commit is contained in:
parent
95652c8990
commit
f6b2bc4cec
2 changed files with 8 additions and 5 deletions
|
|
@ -185,7 +185,7 @@ export function isMaterializedOpenCodeSessionId(sessionId: unknown): boolean {
|
|||
return false;
|
||||
}
|
||||
const trimmed = sessionId.trim();
|
||||
return trimmed.length > 0 && !trimmed.startsWith('failed:');
|
||||
return trimmed.length > 0 && !trimmed.toLowerCase().startsWith('failed:');
|
||||
}
|
||||
|
||||
export function hasMaterializedOpenCodeRuntimeForBootstrap(
|
||||
|
|
@ -372,8 +372,8 @@ export function hasOpenCodeRuntimeHandle(
|
|||
const runtimeSessionId = (value as { runtimeSessionId?: unknown }).runtimeSessionId;
|
||||
const runtimeEvidenceSessionId = (value as { sessionId?: unknown }).sessionId;
|
||||
const sessionId =
|
||||
(typeof runtimeSessionId === 'string' && runtimeSessionId.trim().length > 0) ||
|
||||
(typeof runtimeEvidenceSessionId === 'string' && runtimeEvidenceSessionId.trim().length > 0);
|
||||
isMaterializedOpenCodeSessionId(runtimeSessionId) ||
|
||||
isMaterializedOpenCodeSessionId(runtimeEvidenceSessionId);
|
||||
return runtimePid || sessionId;
|
||||
}
|
||||
|
||||
|
|
@ -401,8 +401,7 @@ export function hasOpenCodeRuntimeEntryHandle(
|
|||
typeof value.runtimePid === 'number' &&
|
||||
Number.isFinite(value.runtimePid) &&
|
||||
value.runtimePid > 0;
|
||||
const runtimeSessionId =
|
||||
typeof value.runtimeSessionId === 'string' && value.runtimeSessionId.trim().length > 0;
|
||||
const runtimeSessionId = isMaterializedOpenCodeSessionId(value.runtimeSessionId);
|
||||
return pid || runtimePid || runtimeSessionId || hasOpenCodeRuntimeLivenessMarker(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,9 @@ describe('TeamProvisioningOpenCodeRuntimeEvidencePolicy', () => {
|
|||
expect(hasOpenCodeRuntimeHandle({ runtimeSessionId: ' session-1 ' })).toBe(true);
|
||||
expect(hasOpenCodeRuntimeHandle({ sessionId: 'session-2' })).toBe(true);
|
||||
expect(hasOpenCodeRuntimeHandle({ runtimePid: 0, sessionId: ' ' })).toBe(false);
|
||||
expect(hasOpenCodeRuntimeHandle({ sessionId: 'failed:session-2' })).toBe(false);
|
||||
expect(hasOpenCodeRuntimeHandle({ runtimeSessionId: 'FAILED:session-3' })).toBe(false);
|
||||
expect(hasOpenCodeRuntimeEntryHandle({ runtimeSessionId: 'failed:entry-session' })).toBe(false);
|
||||
expect(hasOpenCodeRuntimeLivenessMarker({ livenessKind: 'runtime_process_candidate' })).toBe(
|
||||
true
|
||||
);
|
||||
|
|
@ -195,6 +198,7 @@ describe('TeamProvisioningOpenCodeRuntimeEvidencePolicy', () => {
|
|||
);
|
||||
expect(isMaterializedOpenCodeSessionId('runtime-session')).toBe(true);
|
||||
expect(isMaterializedOpenCodeSessionId('failed:runtime-session')).toBe(false);
|
||||
expect(isMaterializedOpenCodeSessionId('FAILED:runtime-session')).toBe(false);
|
||||
expect(hasMaterializedOpenCodeRuntimeForBootstrap(result.members.Builder)).toBe(true);
|
||||
expect(isRecoverableOpenCodeBootstrapPendingLaunchResult(result, 'Builder')).toBe(true);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue