Files
Genarrative/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/self-test.mjs
T
kdletters c09a511aaa
Project CI / Repository checks (push) Successful in 2m24s
Project CI / Frontend tests (push) Successful in 2m54s
Project CI / Backend tests (push) Successful in 4m33s
Project CI / Native shell tests (push) Successful in 14m29s
Codex/fix pr188 191 ci (#194)
Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/194
Co-authored-by: kdletters <kdletters@qq.com>
Co-committed-by: kdletters <kdletters@qq.com>
2026-08-25 15:41:55 +08:00

2498 lines
93 KiB
JavaScript

import {
assert,
canonicalJsonValue,
hashJsonValue,
hashValue,
} from '../assertions/core.mjs';
import {
collectToolPlanRepairAuditEvidence,
countExactSecrets,
emptyToolPlanRepairCountsByProtocolErrorKind,
finalMessageId,
hasSafeToolPlanAuditPayload,
isNonEmptyString,
runtimePublicStatusMessageId,
sumObjectValues,
toolPlanRepairEvidenceHasNoFatalLocalRepair,
} from '../assertions/runtime.mjs';
import { fs, os, path, readFileSync, spawn } from '../dependencies.mjs';
import {
closeOwnedRunnerKillHandle,
createSentinelOwnedTempDirectory,
ensureOwnedRunnerStableKillSupport,
isolatedSuiteAppDataProfile,
isolatedSuiteProtectsSourceAppData,
isolatedSuiteUsesSiblingAppData,
isProcessAlive,
openOwnedRunnerKillHandle,
sameSupervisorPlayableProviderBinding,
signalOwnedRunnerKillHandle,
sourceAppDataDirectoryEventIsViolation,
waitForChildClose,
} from '../harness/app-data.mjs';
import { parseArguments } from '../harness/config.mjs';
import {
buildOwnedProcessCleanupSnapshot,
closeInteractiveCli,
createInteractiveCliSession,
destroyInteractiveCliOutputStreams,
inspectOwnedProcessCleanupResiduals,
listSystemProcessIdentities,
safeProcessFailureDiagnostic,
waitForInteractiveCliExit,
waitForInteractiveCliOutput,
waitForInteractiveCliStdioClose,
} from '../harness/process.mjs';
import {
expectedProviderBindingForSuite,
seededGameHtml,
} from '../harness/project.mjs';
import {
buildSummary,
isIsolatedRunnerSuite,
providerUsedFromEvidence,
} from '../harness/reporting.mjs';
import {
agentConversationPath,
isEmptyExecutionOwnerLock,
} from '../harness/runtime.mjs';
import {
activeCommandChildren,
appRoot,
commandFailureMarker,
commandPassedMarker,
isolatedAgentJoinClaimSchemaVersion,
projectSupervisorAgentId,
providerActionBatchSchemaVersion,
repoRoot,
runnerEndpointFileName,
state,
StreamingSecretScanner,
supervisorAutonomousPlayableAppDataSentinelFileName,
supervisorAutonomousPlayableAppDataSentinelSchema,
supervisorAutonomousPlayableLaneDefenseSuite,
supervisorAutonomousPlayableLaneDefenseTask,
supervisorCollaborationContractSchemaVersion,
supervisorCollaborationPolicySchemaVersion,
supervisorCollaborationPolicySnapshotInitialBatchBinding,
supervisorCollaborationPolicySnapshotSchemaVersion,
supervisorSwarmAutonomousChatSuite,
supervisorSwarmCollaborationPolicyMixedRecoverySuite,
supervisorSwarmFollowupIsolatedReviews,
supervisorSwarmInitialIsolatedReviews,
supervisorSwarmIsolatedReviewGroups,
supervisorSwarmIsolatedReviews,
supervisorSwarmSessionId,
supervisorSwarmStaticIsolatedAutonomousChatSuite,
supervisorSwarmToolPlanHandoffRunnerKillAppDataSentinelFileName,
supervisorSwarmToolPlanHandoffRunnerKillAppDataSentinelSchema,
supervisorSwarmToolPlanHandoffRunnerKillSuite,
toolPlanProtocolAuditSafeFields,
toolPlanProtocolErrorKinds,
toolPlanRepairAuditSafeFields,
} from '../runtime-state.mjs';
import {
buildSupervisorAutonomousPlayablePartialEvidence,
buildSupervisorAutonomousPlayableStdin,
collectPartialSupervisorAutonomousPlayableEvidence,
inspectSupervisorAutonomousPlayableConversationBoundary,
isSupervisorAutonomousPlayableAcceptedPublicStatus,
isSupervisorAutonomousPlayableLaneDefenseSuite,
supervisorAutonomousPlayableStaticSmokeMatchesFinalIndex,
waitForSupervisorAutonomousPlayableCliExit,
} from './supervisor-autonomous-playable.mjs';
import {
buildSupervisorSwarmEvidence,
collectSupervisorSwarmDynamicPrivateValues,
driftedSupervisorSwarmCollaborationPolicy,
duplicateSupervisorSwarmCollaborationPolicySnapshotBindingCount,
duplicateSupervisorSwarmCollaborationPolicySnapshotCount,
expectedSupervisorSwarmCollaborationPolicy,
inspectSupervisorSwarmCollaborationPolicySnapshot,
inspectSupervisorSwarmCollaborationPolicySnapshotBinding,
inspectSupervisorSwarmRecoveredRepairConfirmationLifecycle,
isSupervisorSwarmSuite,
isSupervisorSwarmToolPlanHandoffRunnerKillSuite,
normalizeSupervisorSwarmToolPlanUpdate,
parseSupervisorSwarmToolPlanHandoffPlan,
registerSupervisorSwarmPrivateOutputValues,
registerSupervisorSwarmPrivateTransportValues,
supervisorSwarmCollaborationPolicyDriftObservationCount,
supervisorSwarmCollaborationPolicySnapshotBinding,
supervisorSwarmEvidenceFieldTemplate,
supervisorSwarmExpectedIsolatedReviewGroups,
supervisorSwarmFinalReplyFaultInjectionAllowed,
supervisorSwarmFinalReplyFaultPrerequisites,
supervisorSwarmFollowupBeforeClaimOrderValid,
supervisorSwarmHostVerificationPassed,
supervisorSwarmInitialBatchBindsPolicySnapshot,
supervisorSwarmIsolatedReviewGroupIndex,
supervisorSwarmIsolatedWriteScopeRoots,
supervisorSwarmMixedIsolatedGroupEntries,
supervisorSwarmObservedJoinClaimForGroups,
supervisorSwarmProfessionalSessions,
supervisorSwarmReadyIsolatedGroupIds,
supervisorSwarmResidualSidecarsEmpty,
supervisorSwarmSeedPrivateValues,
supervisorSwarmToolPlanHandoffProxyNeedsCleanup,
supervisorSwarmToolPlanHandoffSnapshotEvidence,
validateSupervisorSwarmCollaborationPolicySnapshot,
validateSupervisorSwarmCollaborationPolicySnapshotBinding,
} from './supervisor-swarm.mjs';
export async function runAgentRuntimeRealE2eSelfTests() {
const supervisorAcceptedPublicStatusLifecycle =
validateSupervisorAcceptedPublicStatusSelfTest();
const interactiveCliLifecycle =
await validateInteractiveCliInheritedStdioLifecycle();
const providerBindingLifecycle =
validateSupervisorPlayableProviderBindingSelfTest();
const providerUsedReportingLifecycle =
validateProviderUsedReportingSelfTest();
const ownedProcessCleanupLifecycle =
validateOwnedProcessCleanupIdentitySelfTest();
const liveProcessIdentities = await listSystemProcessIdentities();
assert(
liveProcessIdentities.some(
(identity) =>
identity.pid === process.pid &&
Number.isSafeInteger(identity.parentPid) &&
isNonEmptyString(identity.startedAt) &&
isNonEmptyString(identity.name),
),
'agent-runtime-real-e2e-self-test-live-process-identity-missing',
);
const professionalSessionLifecycle =
validateSupervisorSwarmProfessionalSessionsSelfTest();
const executionOwnerLockScanLifecycle =
validateExecutionOwnerLockScanSelfTest();
const staticSmokeBindingLifecycle =
validateStaticSmokeFinalIndexBindingSelfTest();
const seededGameHtmlLifecycle = validateSeededGameHtmlContractSelfTest();
const lateRegisteredScanner = new StreamingSecretScanner([
'initial-scanner-value',
]);
lateRegisteredScanner.scan('initial', 'initial-scanner-value');
lateRegisteredScanner.addSecrets(['late-isolated-appdata-value']);
lateRegisteredScanner.scan('late-a', 'late-isolated-');
lateRegisteredScanner.scan('late-a', 'appdata-value');
assert(
lateRegisteredScanner.count === 2,
'agent-runtime-real-e2e-self-test-late-scanner-registration-invalid',
);
const childCloseTimeoutLifecycle = {
waitForChildCloseFalseKillHardTimeoutValidated:
await validateWaitForChildCloseHardTimeout('false'),
waitForChildCloseThrowKillHardTimeoutValidated:
await validateWaitForChildCloseHardTimeout('throw'),
};
let stableKillHandlePlatformValidated = false;
let stableKillHandleCloseValidated = false;
let stableKillHandleSignalValidated = false;
let stableKillHandleCommandFailureCleanupValidated = false;
let windowsOwnedTempPathValidated = false;
if (process.platform === 'win32') {
const ownedDirectory = await createSentinelOwnedTempDirectory({
prefix: path.join(os.tmpdir(), 'agc-owned-path-self-test-'),
sentinelName: 'sentinel.json',
sentinel: { schemaVersion: 'agc-owned-path-self-test.v1' },
codePrefix: 'agc-owned-path-self-test',
});
try {
const sentinel = JSON.parse(
await fs.readFile(path.join(ownedDirectory, 'sentinel.json'), 'utf8'),
);
assert(
sentinel.schemaVersion === 'agc-owned-path-self-test.v1',
'agent-runtime-real-e2e-self-test-windows-owned-path-sentinel-invalid',
);
windowsOwnedTempPathValidated = true;
} finally {
await fs.rm(ownedDirectory, { recursive: true, force: false });
}
}
if (process.platform === 'linux' || process.platform === 'win32') {
await ensureOwnedRunnerStableKillSupport();
const closeVictim = spawn(
process.execPath,
['-e', 'setInterval(() => {}, 1000)'],
{ stdio: 'ignore', windowsHide: true },
);
await waitForSelfTestChildSpawn(closeVictim);
const closeHandle = await openOwnedRunnerKillHandle(closeVictim.pid);
try {
await closeOwnedRunnerKillHandle(closeHandle);
assert(
isProcessAlive(closeVictim.pid),
'agent-runtime-real-e2e-self-test-stable-handle-close-killed-target',
);
stableKillHandleCloseValidated = true;
} finally {
await stopSelfTestChild(closeVictim);
await closeOwnedRunnerKillHandle(closeHandle).catch(() => {});
}
const killVictim = spawn(
process.execPath,
['-e', 'setInterval(() => {}, 1000)'],
{ stdio: 'ignore', windowsHide: true },
);
await waitForSelfTestChildSpawn(killVictim);
const killHandle = await openOwnedRunnerKillHandle(killVictim.pid);
try {
await signalOwnedRunnerKillHandle(killHandle);
await waitForChildClose(killVictim, 10_000);
assert(
!isProcessAlive(killVictim.pid),
'agent-runtime-real-e2e-self-test-stable-handle-signal-target-live',
);
stableKillHandleSignalValidated = true;
} finally {
await stopSelfTestChild(killVictim);
await closeOwnedRunnerKillHandle(killHandle).catch(() => {});
}
stableKillHandleCommandFailureCleanupValidated =
await validateStableKillHandleCommandFailureCleanup();
stableKillHandlePlatformValidated = true;
}
const syntheticSourceEndpointLifecycleEvents = [
{ phase: 'created', fileName: runnerEndpointFileName },
{ phase: 'deleted', fileName: Buffer.from(runnerEndpointFileName) },
];
const sourceEndpointAbsentLifecycleGuardValidated =
syntheticSourceEndpointLifecycleEvents.every(({ fileName }) =>
sourceAppDataDirectoryEventIsViolation(
fileName,
'.synthetic-isolated-suite-',
{ exists: false, fingerprint: null },
),
) &&
!sourceAppDataDirectoryEventIsViolation(
runnerEndpointFileName,
'.synthetic-isolated-suite-',
{ exists: true, fingerprint: 'synthetic-endpoint-fingerprint' },
) &&
sourceAppDataDirectoryEventIsViolation(
'.synthetic-isolated-suite-created',
'.synthetic-isolated-suite-',
{ exists: true, fingerprint: 'synthetic-endpoint-fingerprint' },
) &&
!sourceAppDataDirectoryEventIsViolation(
'unrelated-source-config-file.json',
'.synthetic-isolated-suite-',
{ exists: false, fingerprint: null },
);
assert(
sourceEndpointAbsentLifecycleGuardValidated,
'agent-runtime-real-e2e-self-test-source-endpoint-lifecycle-guard-invalid',
);
const previousSuiteForToolPlanHandoff = state.suite;
state.suite = supervisorSwarmToolPlanHandoffRunnerKillSuite;
const toolPlanHandoffProfile = isolatedSuiteAppDataProfile();
const toolPlanHandoffParsedArguments = parseArguments([
'--config-dir',
path.resolve('synthetic-tool-plan-handoff-config'),
'--suite',
supervisorSwarmToolPlanHandoffRunnerKillSuite,
]);
const rootPackage = JSON.parse(
readFileSync(path.join(repoRoot, 'package.json'), 'utf8'),
);
const shellPackage = JSON.parse(
readFileSync(path.join(appRoot, 'package.json'), 'utf8'),
);
const previousSuiteForAutonomousPlayable = state.suite;
state.suite = supervisorAutonomousPlayableLaneDefenseSuite;
const autonomousPlayableProfile = isolatedSuiteAppDataProfile();
const autonomousPlayableParsedArguments = parseArguments([
'--config-dir',
path.resolve('synthetic-autonomous-playable-config'),
'--suite',
supervisorAutonomousPlayableLaneDefenseSuite,
]);
const autonomousPlayableStdin = buildSupervisorAutonomousPlayableStdin();
const autonomousPlayablePackageCommandsRegistered =
shellPackage.scripts?.[
'agent-runtime:supervisor-autonomous-playable-lane-defense-real-e2e'
] ===
'node scripts/agent-runtime-real-e2e.mjs --suite supervisor-autonomous-playable-lane-defense' &&
rootPackage.scripts?.[
'ai-game-creator-shell:agent-runtime:supervisor-autonomous-playable-lane-defense-real-e2e'
] ===
'npm --prefix apps/ai-game-creator-shell run agent-runtime:supervisor-autonomous-playable-lane-defense-real-e2e --';
const autonomousPlayableSuiteRegistered =
autonomousPlayableParsedArguments.suite ===
supervisorAutonomousPlayableLaneDefenseSuite &&
isSupervisorAutonomousPlayableLaneDefenseSuite() &&
!isSupervisorSwarmSuite() &&
isIsolatedRunnerSuite() &&
isolatedSuiteProtectsSourceAppData() &&
isolatedSuiteUsesSiblingAppData() &&
autonomousPlayableProfile.sentinelName ===
supervisorAutonomousPlayableAppDataSentinelFileName &&
autonomousPlayableProfile.sentinelSchema ===
supervisorAutonomousPlayableAppDataSentinelSchema &&
autonomousPlayableStdin.equals(
Buffer.from(`${supervisorAutonomousPlayableLaneDefenseTask}\n`, 'utf8'),
) &&
autonomousPlayablePackageCommandsRegistered;
const previousInitialRunIdForAutonomousPlayable = state.initialRunId;
const previousProjectRootForAutonomousPlayable = state.projectRoot;
const previousInitialTaskForAutonomousPlayable = state.initialTask;
const previousAutonomousPlayableTurnReport =
state.supervisorAutonomousPlayable.turnReport;
const previousAutonomousPlayablePrivateValues = [
...state.supervisorAutonomousPlayable.privateValues,
];
const previousSupervisorSwarmPrivateValues = [
...state.supervisorSwarm.privateValues,
];
const previousSupervisorSwarmInitialProviderBatch =
state.supervisorSwarm.initialProviderBatch;
const autonomousPlayablePartialCanary = 'private-autonomous-partial-canary';
const syntheticAutonomousPlayableRunId =
'synthetic-autonomous-playable-partial-root';
state.initialRunId = syntheticAutonomousPlayableRunId;
state.supervisorAutonomousPlayable.privateValues = [
...new Set([
...state.supervisorAutonomousPlayable.privateValues,
autonomousPlayablePartialCanary,
]),
];
const syntheticAutonomousPlayablePartialEvidence =
buildSupervisorAutonomousPlayablePartialEvidence(
{
taskSnapshot: {
latest: [
{
agentId: projectSupervisorAgentId,
runId: syntheticAutonomousPlayableRunId,
status: 'running',
phase: 'waiting-for-agent',
task: autonomousPlayablePartialCanary,
},
{
agentId: 'code-prototype',
sessionId: 'synthetic-original-session',
runId: 'synthetic-original-run',
parentAgentId: projectSupervisorAgentId,
parentRunId: syntheticAutonomousPlayableRunId,
delegationId: 'synthetic-original-delivery',
status: 'failed',
phase: 'failed',
},
{
agentId: 'code-prototype',
sessionId: 'synthetic-repair-session',
runId: 'synthetic-repair-run',
parentAgentId: projectSupervisorAgentId,
parentRunId: syntheticAutonomousPlayableRunId,
delegationId: 'synthetic-repair-delivery',
status: 'running',
phase: 'planning',
},
],
},
runtimeStates: [
{
agentId: projectSupervisorAgentId,
runId: syntheticAutonomousPlayableRunId,
status: 'running',
phase: 'waiting-for-agent',
currentTask: autonomousPlayablePartialCanary,
},
{
agentId: 'code-prototype',
runId: 'synthetic-original-run',
parentAgentId: projectSupervisorAgentId,
parentRunId: syntheticAutonomousPlayableRunId,
status: 'failed',
phase: 'failed',
},
{
agentId: 'code-prototype',
runId: 'synthetic-repair-run',
parentAgentId: projectSupervisorAgentId,
parentRunId: syntheticAutonomousPlayableRunId,
status: 'running',
phase: 'waiting-for-provider-retry',
},
],
deliveries: [
{
parentAgentId: projectSupervisorAgentId,
parentRunId: syntheticAutonomousPlayableRunId,
delegationId: 'synthetic-original-delivery',
repairOfDelegationId: null,
targetAgentId: 'code-prototype',
targetSessionId: 'synthetic-original-session',
targetRunId: 'synthetic-original-run',
status: 'ready',
terminalStatus: 'failed',
structuredResult: { contractStatus: 'needs-repair' },
},
{
parentAgentId: projectSupervisorAgentId,
parentRunId: syntheticAutonomousPlayableRunId,
delegationId: 'synthetic-repair-delivery',
repairOfDelegationId: 'synthetic-original-delivery',
targetAgentId: 'code-prototype',
targetSessionId: 'synthetic-repair-session',
targetRunId: 'synthetic-repair-run',
status: 'dispatched',
terminalStatus: null,
},
],
agentDb: [
{
recordType: 'agent.runtime.provider_request.lifecycle',
agentId: 'code-prototype',
runId: 'synthetic-original-run',
requestId: 'synthetic-provider-request',
status: 'started',
},
{
recordType: 'agent.runtime.provider_request.lifecycle',
agentId: 'code-prototype',
runId: 'synthetic-original-run',
requestId: 'synthetic-provider-request',
status: 'failed',
},
{
recordType: 'agent.runtime.provider_request.retry',
agentId: 'code-prototype',
runId: 'synthetic-original-run',
errorKind: 'transport',
},
],
supervisorConversation: [
{
role: 'user',
content: autonomousPlayablePartialCanary,
},
],
professionalConversations: [],
failureEvidenceErrors: {},
},
{
residualSidecars: { providerRetries: 1 },
pendingActionCount: 0,
turnReport: {
outcome: 'incomplete',
parentAgentId: projectSupervisorAgentId,
sessionId: supervisorSwarmSessionId,
parentRunId: syntheticAutonomousPlayableRunId,
runtimeCount: 3,
busyRuntimeCount: 2,
pendingTaskCount: 0,
runningTaskCount: 2,
waitingForConfirmationCount: 0,
waitingForUserInputCount: 0,
reconciliationAgentCount: 0,
},
},
);
const autonomousPlayablePartialEvidenceValidated =
syntheticAutonomousPlayablePartialEvidence.evidenceCompleteness ===
'partial' &&
syntheticAutonomousPlayablePartialEvidence.partialEvidenceCollected ===
true &&
syntheticAutonomousPlayablePartialEvidence.partialPrivacyScanComplete ===
false &&
syntheticAutonomousPlayablePartialEvidence.rootRunObserved === true &&
syntheticAutonomousPlayablePartialEvidence.parentRuntimePhase ===
'waiting-for-agent' &&
syntheticAutonomousPlayablePartialEvidence.childTaskStatusCounts.failed ===
1 &&
syntheticAutonomousPlayablePartialEvidence.childTaskStatusCounts.running ===
1 &&
syntheticAutonomousPlayablePartialEvidence.failedOriginalChildCount === 1 &&
syntheticAutonomousPlayablePartialEvidence.failedRepairChildCount === 0 &&
syntheticAutonomousPlayablePartialEvidence.awaitingRepairCount === 1 &&
syntheticAutonomousPlayablePartialEvidence.repairDeliveryStatusCounts
.dispatched === 1 &&
syntheticAutonomousPlayablePartialEvidence.providerLifecycleFailedCount ===
1 &&
syntheticAutonomousPlayablePartialEvidence.providerRetryAuditCount === 1 &&
syntheticAutonomousPlayablePartialEvidence.providerTransportRetryAuditCount ===
1 &&
syntheticAutonomousPlayablePartialEvidence.providerRetrySidecarCount ===
1 &&
syntheticAutonomousPlayablePartialEvidence.turnReportOutcome ===
'incomplete' &&
syntheticAutonomousPlayablePartialEvidence.turnReportCaptured === true &&
syntheticAutonomousPlayablePartialEvidence.turnReportParentIdentityStable ===
true &&
syntheticAutonomousPlayablePartialEvidence.turnReportPrivateLeakCount ===
0 &&
!JSON.stringify(syntheticAutonomousPlayablePartialEvidence).includes(
autonomousPlayablePartialCanary,
);
const syntheticAutonomousPlayableCollectorRoot = await fs.mkdtemp(
path.join(os.tmpdir(), 'genarrative-autonomous-partial-self-test-'),
);
let syntheticAutonomousPlayableCollectorEvidence;
try {
state.projectRoot = syntheticAutonomousPlayableCollectorRoot;
state.initialTask = {
bytes: Buffer.byteLength(autonomousPlayablePartialCanary, 'utf8'),
sha256: hashValue(autonomousPlayablePartialCanary),
};
state.supervisorSwarm.privateValues = [autonomousPlayablePartialCanary];
state.supervisorSwarm.initialProviderBatch = null;
state.supervisorAutonomousPlayable.turnReport = {
outcome: 'needs-reconciliation',
parentAgentId: projectSupervisorAgentId,
sessionId: supervisorSwarmSessionId,
parentRunId: syntheticAutonomousPlayableRunId,
runtimeCount: 1,
busyRuntimeCount: 0,
pendingTaskCount: 0,
runningTaskCount: 0,
waitingForConfirmationCount: 0,
waitingForUserInputCount: 0,
reconciliationAgentCount: 1,
privateDiagnostic: autonomousPlayablePartialCanary,
};
const taskPath = path.join(
state.projectRoot,
'.agent/runtime/tasks/project-supervisor.jsonl',
);
const runtimePath = path.join(
state.projectRoot,
'.agent/runtime/agents/project-supervisor.json',
);
const conversationPath = agentConversationPath(
projectSupervisorAgentId,
supervisorSwarmSessionId,
);
await fs.mkdir(path.dirname(taskPath), { recursive: true });
await fs.mkdir(path.dirname(runtimePath), { recursive: true });
await fs.mkdir(path.dirname(conversationPath), { recursive: true });
await fs.writeFile(
taskPath,
`${JSON.stringify({
agentId: projectSupervisorAgentId,
runId: syntheticAutonomousPlayableRunId,
status: 'budget-exhausted',
phase: 'budget-exhausted',
task: autonomousPlayablePartialCanary,
})}\n`,
);
await fs.writeFile(
runtimePath,
JSON.stringify({
agentId: projectSupervisorAgentId,
runId: syntheticAutonomousPlayableRunId,
status: 'needs-reconciliation',
phase: 'needs-reconciliation',
currentTask: autonomousPlayablePartialCanary,
}),
);
await fs.writeFile(
conversationPath,
`${JSON.stringify({
role: 'user',
content: autonomousPlayablePartialCanary,
})}\n`,
);
syntheticAutonomousPlayableCollectorEvidence =
await collectPartialSupervisorAutonomousPlayableEvidence();
} finally {
state.projectRoot = previousProjectRootForAutonomousPlayable;
state.initialTask = previousInitialTaskForAutonomousPlayable;
state.supervisorAutonomousPlayable.turnReport =
previousAutonomousPlayableTurnReport;
state.supervisorAutonomousPlayable.privateValues =
previousAutonomousPlayablePrivateValues;
state.supervisorSwarm.privateValues = previousSupervisorSwarmPrivateValues;
state.supervisorSwarm.initialProviderBatch =
previousSupervisorSwarmInitialProviderBatch;
await fs.rm(syntheticAutonomousPlayableCollectorRoot, {
recursive: true,
force: true,
});
}
const autonomousPlayablePartialCollectorPrivacyValidated =
syntheticAutonomousPlayableCollectorEvidence.evidenceCompleteness ===
'partial' &&
syntheticAutonomousPlayableCollectorEvidence.rootRunObserved === true &&
syntheticAutonomousPlayableCollectorEvidence.parentTaskStatus ===
'budget-exhausted' &&
syntheticAutonomousPlayableCollectorEvidence.parentTaskPhase ===
'budget-exhausted' &&
syntheticAutonomousPlayableCollectorEvidence.parentRuntimeStatus ===
'needs-reconciliation' &&
syntheticAutonomousPlayableCollectorEvidence.parentRuntimePhase ===
'needs-reconciliation' &&
syntheticAutonomousPlayableCollectorEvidence.supervisorUserMessageCount ===
1 &&
syntheticAutonomousPlayableCollectorEvidence.turnReportPrivateLeakCount ===
1 &&
!JSON.stringify(syntheticAutonomousPlayableCollectorEvidence).includes(
autonomousPlayablePartialCanary,
);
state.initialRunId = previousInitialRunIdForAutonomousPlayable;
state.suite = previousSuiteForAutonomousPlayable;
assert(
autonomousPlayableSuiteRegistered &&
autonomousPlayablePartialEvidenceValidated &&
autonomousPlayablePartialCollectorPrivacyValidated,
'agent-runtime-real-e2e-self-test-autonomous-playable-suite-invalid',
);
const rootToolPlanHandoffCommand =
'npm --prefix apps/ai-game-creator-shell run agent-runtime:supervisor-swarm-tool-plan-handoff-runner-kill-real-e2e --';
const shellToolPlanHandoffCommand =
'node scripts/agent-runtime-real-e2e.mjs --suite supervisor-swarm-tool-plan-handoff-runner-kill';
const originalToolPlanHandoffProxy =
state.supervisorSwarm.toolPlanHandoffProxy;
state.supervisorSwarm.toolPlanHandoffProxy = {};
const toolPlanHandoffCleanupRegistered =
supervisorSwarmToolPlanHandoffProxyNeedsCleanup();
state.supervisorSwarm.toolPlanHandoffProxy = originalToolPlanHandoffProxy;
const toolPlanHandoffPartialEvidence =
supervisorSwarmToolPlanHandoffSnapshotEvidence();
const toolPlanHandoffPackageCommandsRegistered =
rootPackage.scripts?.[
'ai-game-creator-shell:agent-runtime:supervisor-swarm-tool-plan-handoff-runner-kill-real-e2e'
] === rootToolPlanHandoffCommand &&
shellPackage.scripts?.[
'agent-runtime:supervisor-swarm-tool-plan-handoff-runner-kill-real-e2e'
] === shellToolPlanHandoffCommand;
const toolPlanHandoffSourceGuardRegistered =
sourceAppDataDirectoryEventIsViolation(
`${toolPlanHandoffProfile.prefix}synthetic`,
toolPlanHandoffProfile.prefix,
{ exists: false, fingerprint: null },
);
const toolPlanHandoffSuiteRegistered =
toolPlanHandoffParsedArguments.suite ===
supervisorSwarmToolPlanHandoffRunnerKillSuite &&
isSupervisorSwarmToolPlanHandoffRunnerKillSuite() &&
isSupervisorSwarmSuite() &&
isIsolatedRunnerSuite() &&
isolatedSuiteProtectsSourceAppData() &&
toolPlanHandoffProfile.prefix ===
'.agent-runtime-real-e2e-supervisor-swarm-tool-plan-handoff-runner-kill-' &&
toolPlanHandoffProfile.codePrefix ===
'supervisor-swarm-tool-plan-handoff-runner-kill-appdata' &&
toolPlanHandoffProfile.sentinelName ===
supervisorSwarmToolPlanHandoffRunnerKillAppDataSentinelFileName &&
toolPlanHandoffProfile.sentinelSchema ===
supervisorSwarmToolPlanHandoffRunnerKillAppDataSentinelSchema &&
toolPlanHandoffSourceGuardRegistered &&
toolPlanHandoffPackageCommandsRegistered &&
toolPlanHandoffCleanupRegistered &&
toolPlanHandoffPartialEvidence.toolPlanHandoffModeEnabled === true &&
Object.hasOwn(
toolPlanHandoffPartialEvidence,
'toolPlanHandoffNetworkReplayCount',
);
state.suite = previousSuiteForToolPlanHandoff;
const syntheticToolPlanHandoffEntry = {
response: {
toolCalls: [
{
id: 'synthetic-plan-call',
name: 'update_agent_plan',
arguments: JSON.stringify({
explanation: 'synthetic plan',
steps: [{ step: 'delegate', status: 'in_progress' }],
}),
},
...['design', 'quality'].map((agentId) => ({
id: `synthetic-${agentId}-call`,
name: 'runtime_tool_agent_delegate',
arguments: JSON.stringify({
reason: `delegate ${agentId}`,
input: { agentId },
}),
})),
],
},
};
const syntheticToolPlanHandoffPlan = parseSupervisorSwarmToolPlanHandoffPlan(
syntheticToolPlanHandoffEntry,
);
const syntheticNormalizedPlanUpdate = normalizeSupervisorSwarmToolPlanUpdate({
explanation: ` ${'x'.repeat(241)} `,
steps: [{ step: ` ${'y'.repeat(181)} `, status: ' pending ' }],
});
const toolPlanHandoffPlanProjectionValidated =
syntheticToolPlanHandoffPlan.thinkingSummary === 'synthetic plan' &&
syntheticToolPlanHandoffPlan.planUpdate?.steps?.length === 1 &&
syntheticToolPlanHandoffPlan.actions.length === 2 &&
syntheticToolPlanHandoffPlan.actions.every(
(action) => action.tool === 'agent.delegate',
) &&
syntheticToolPlanHandoffPlan.response === '' &&
syntheticNormalizedPlanUpdate.explanation === `${'x'.repeat(240)}…` &&
syntheticNormalizedPlanUpdate.steps[0].step === `${'y'.repeat(180)}…` &&
syntheticNormalizedPlanUpdate.steps[0].status === 'pending' &&
hashJsonValue(syntheticToolPlanHandoffPlan) ===
hashJsonValue(canonicalJsonValue(syntheticToolPlanHandoffPlan));
const toolPlanHandoffEvidenceFieldsRegistered = [
'toolPlanHandoffModeEnabled',
'toolPlanHandoffCheckpointCaptured',
'toolPlanHandoffNetworkReplayCount',
'toolPlanHandoffLifecycleClosedExactlyOnce',
'toolPlanHandoffAuditIdempotent',
'toolPlanHandoffRecoveredPlanFingerprintMatched',
'toolPlanHandoffCapabilityLeakCount',
'toolPlanHandoffPrePersistUnknownResultWindowCovered',
].every((field) =>
Object.hasOwn(supervisorSwarmEvidenceFieldTemplate(), field),
);
assert(
toolPlanHandoffSuiteRegistered &&
toolPlanHandoffPlanProjectionValidated &&
toolPlanHandoffEvidenceFieldsRegistered &&
supervisorSwarmEvidenceFieldTemplate()
.toolPlanHandoffPrePersistUnknownResultWindowCovered === false,
'agent-runtime-real-e2e-self-test-tool-plan-handoff-suite-invalid',
);
const previousInitialRunId = state.initialRunId;
const syntheticFinalReplyRunId = 'synthetic-final-reply-run';
state.initialRunId = syntheticFinalReplyRunId;
const syntheticToolPlanStarted = {
recordType: 'agent.runtime.provider_request.lifecycle',
status: 'started',
agentId: projectSupervisorAgentId,
runId: syntheticFinalReplyRunId,
requestKind: 'tool-plan',
requestId: 'synthetic-tool-plan-request',
};
const syntheticVerificationAudit = {
recordType: 'agent.runtime.project.verify',
agentId: projectSupervisorAgentId,
runId: syntheticFinalReplyRunId,
actionId: 'synthetic-verification-action',
status: 'completed',
exitCode: 0,
timedOut: false,
};
const syntheticVerificationReceipt = {
recordType: 'agent.runtime.action_receipt',
agentId: projectSupervisorAgentId,
runId: syntheticFinalReplyRunId,
actionId: syntheticVerificationAudit.actionId,
tool: 'project.verify',
status: 'ok',
};
const syntheticVerificationObservation = {
recordType: 'agent.runtime.tool_observation',
agentId: projectSupervisorAgentId,
runId: syntheticFinalReplyRunId,
actionId: syntheticVerificationAudit.actionId,
tool: 'project.verify',
status: 'ok',
};
const syntheticFinalReplyStarted = {
recordType: 'agent.runtime.provider_request.lifecycle',
status: 'started',
agentId: projectSupervisorAgentId,
taskId: 'synthetic-final-reply-task',
sessionId: supervisorSwarmSessionId,
runId: syntheticFinalReplyRunId,
requestKind: 'final-reply',
requestId: 'synthetic-final-reply-request',
requestSlot: 'synthetic-final-reply-slot',
};
const syntheticDeliveries = [
['synthetic-design', null],
['synthetic-quality', null],
['synthetic-repair', 'synthetic-quality'],
].map(([delegationId, repairOfDelegationId]) => ({
parentAgentId: projectSupervisorAgentId,
parentSessionId: supervisorSwarmSessionId,
parentRunId: syntheticFinalReplyRunId,
delegationId,
repairOfDelegationId,
status: 'claimed-by-parent',
terminalStatus: 'completed',
}));
const syntheticFinalReplyPrerequisites =
supervisorSwarmFinalReplyFaultPrerequisites(
{
deliveries: syntheticDeliveries,
claims: [
{
status: 'observed',
receipts: [
{ delegationId: 'synthetic-design' },
{ delegationId: 'synthetic-quality' },
],
},
{
status: 'observed',
receipts: [{ delegationId: 'synthetic-repair' }],
},
],
agentDb: [
syntheticToolPlanStarted,
syntheticVerificationAudit,
syntheticVerificationReceipt,
syntheticVerificationObservation,
syntheticFinalReplyStarted,
],
supervisorConversation: [],
projectRevision: { revision: 2 },
},
syntheticFinalReplyStarted,
{ sequence: 7, acceptedAtMs: 1234 },
);
const syntheticInvalidFinalReplyPrerequisites =
supervisorSwarmFinalReplyFaultPrerequisites(
{
deliveries: syntheticDeliveries,
claims: [
{
status: 'observed',
receipts: [
{ delegationId: 'synthetic-design' },
{ delegationId: 'synthetic-quality' },
],
},
{
status: 'observed',
receipts: [{ delegationId: 'synthetic-repair' }],
},
],
agentDb: [
syntheticToolPlanStarted,
syntheticFinalReplyStarted,
syntheticVerificationAudit,
syntheticVerificationReceipt,
syntheticVerificationObservation,
],
supervisorConversation: [{ role: 'assistant' }],
projectRevision: { revision: 2 },
},
syntheticFinalReplyStarted,
{ sequence: 7, acceptedAtMs: 1234 },
);
state.initialRunId = previousInitialRunId;
assert(
syntheticFinalReplyPrerequisites.preconditionsValid &&
syntheticFinalReplyPrerequisites.requestKind === 'final-reply' &&
syntheticFinalReplyPrerequisites.deliveryCount === 3 &&
syntheticFinalReplyPrerequisites.repairDeliveryCount === 1 &&
syntheticFinalReplyPrerequisites.observedClaimReceiptCount === 3 &&
syntheticFinalReplyPrerequisites.runtimeVerificationCount === 1 &&
syntheticFinalReplyPrerequisites.parentToolPlanStartedCount === 1 &&
!syntheticInvalidFinalReplyPrerequisites.preconditionsValid &&
JSON.stringify(
syntheticInvalidFinalReplyPrerequisites.invalidPrerequisiteFields,
) === JSON.stringify(['assistantAbsent']) &&
supervisorSwarmHostVerificationPassed({
stdout: commandPassedMarker,
stderr: '',
}) &&
!supervisorSwarmHostVerificationPassed({
stdout: commandFailureMarker,
stderr: '',
}) &&
supervisorSwarmFinalReplyFaultInjectionAllowed({
preconditionsValid: true,
}) &&
!supervisorSwarmFinalReplyFaultInjectionAllowed({
preconditionsValid: false,
}) &&
supervisorSwarmResidualSidecarsEmpty({ finalizations: 0, retries: 0 }) &&
!supervisorSwarmResidualSidecarsEmpty({
finalizations: 1,
retries: 0,
}),
'agent-runtime-real-e2e-self-test-final-reply-fault-prerequisite-invalid',
);
const newlineValue = 'private first line\nprivate second line';
const quotedValue = 'private value says "quoted"';
const backslashValue = 'private\\nested\\value';
const combinedValue = `${newlineValue}\n${quotedValue}\n${backslashValue}`;
const exactSecretCounts = {
newline: countExactSecrets(
Buffer.from(JSON.stringify({ value: newlineValue })),
[newlineValue],
),
quote: countExactSecrets(
Buffer.from(JSON.stringify({ value: quotedValue })),
[quotedValue],
),
backslash: countExactSecrets(
Buffer.from(JSON.stringify({ value: backslashValue })),
[backslashValue],
),
combined: countExactSecrets(
Buffer.from(JSON.stringify({ value: combinedValue })),
[combinedValue],
),
escapedFallback: countExactSecrets(
Buffer.from(
`prefix:${JSON.stringify(combinedValue).slice(1, -1)}:suffix`,
),
[combinedValue],
),
duplicateSecretInput: countExactSecrets(
Buffer.from(JSON.stringify({ value: combinedValue })),
[combinedValue, combinedValue],
),
};
assert(
Object.values(exactSecretCounts).every((count) => count === 1),
'agent-runtime-real-e2e-self-test-exact-secret-count-invalid',
);
const previousPrivateValueScopeState = {
secrets: state.secrets,
transcriptOnlySecrets: state.transcriptOnlySecrets,
privateValues: state.supervisorSwarm.privateValues,
transcriptScanner: state.transcriptScanner,
};
const syntheticTransportSecret =
'synthetic-private-transport-secret-for-scope-self-test';
const syntheticPrivateOutput = 'synthetic-private-output-for-scope-self-test';
state.secrets = [];
state.transcriptOnlySecrets = [];
state.supervisorSwarm.privateValues = [];
state.transcriptScanner = new StreamingSecretScanner([]);
registerSupervisorSwarmPrivateTransportValues([syntheticTransportSecret]);
registerSupervisorSwarmPrivateOutputValues([syntheticPrivateOutput]);
const privateOutputSplitAt = Math.floor(syntheticPrivateOutput.length / 2);
state.transcriptScanner.scan(
'synthetic-private-output',
syntheticPrivateOutput.slice(0, privateOutputSplitAt),
);
state.transcriptScanner.scan(
'synthetic-private-output',
syntheticPrivateOutput.slice(privateOutputSplitAt),
);
const scopedPrivateOutputValidated =
state.secrets.includes(syntheticTransportSecret) &&
!state.secrets.includes(syntheticPrivateOutput) &&
state.transcriptOnlySecrets.includes(syntheticPrivateOutput) &&
state.supervisorSwarm.privateValues.includes(syntheticTransportSecret) &&
state.supervisorSwarm.privateValues.includes(syntheticPrivateOutput) &&
state.transcriptScanner.count === 1 &&
countExactSecrets(
JSON.stringify({ privateOutput: syntheticPrivateOutput }),
state.secrets,
) === 0 &&
countExactSecrets(
JSON.stringify({ privateOutput: syntheticPrivateOutput }),
[...state.secrets, ...state.transcriptOnlySecrets],
) === 1;
state.secrets = previousPrivateValueScopeState.secrets;
state.transcriptOnlySecrets =
previousPrivateValueScopeState.transcriptOnlySecrets;
state.supervisorSwarm.privateValues =
previousPrivateValueScopeState.privateValues;
state.transcriptScanner = previousPrivateValueScopeState.transcriptScanner;
assert(
scopedPrivateOutputValidated,
'agent-runtime-real-e2e-self-test-private-output-scope-invalid',
);
const syntheticRecoveredRepairSessionId = 'synthetic-repair-session';
const syntheticRecoveredRepairIdentity = {
agentId: 'synthetic-repair-agent',
runId: 'synthetic-repair-run',
actionId: 'synthetic-repair-action',
actionFingerprint: 'synthetic-repair-fingerprint',
tool: 'project.patchset',
};
const matchesSyntheticRecoveredRepair = (record) =>
Object.entries(syntheticRecoveredRepairIdentity).every(
([field, value]) => record[field] === value,
);
const syntheticRecoveredRepairRecords = (requirementRecordType) => [
{
...syntheticRecoveredRepairIdentity,
recordType: requirementRecordType,
...(requirementRecordType ===
'agent.runtime.provider_action_batch.confirmation_required'
? {
sessionId: syntheticRecoveredRepairSessionId,
batchId: 'synthetic-repair-batch',
actionCount: 1,
actionIndex: 0,
}
: { summary: 'synthetic legacy confirmation requirement' }),
},
{
...syntheticRecoveredRepairIdentity,
recordType: 'agent.runtime.tool_confirmation.approved',
sessionId: syntheticRecoveredRepairSessionId,
confirmedRunId: syntheticRecoveredRepairIdentity.runId,
commandId: syntheticRecoveredRepairIdentity.tool,
},
{
...syntheticRecoveredRepairIdentity,
recordType: 'agent.runtime.action_receipt',
sessionId: syntheticRecoveredRepairSessionId,
executionMode: 'confirmation',
status: 'ok',
},
];
const inspectSyntheticRecoveredRepair = (records) =>
inspectSupervisorSwarmRecoveredRepairConfirmationLifecycle(
records,
matchesSyntheticRecoveredRepair,
syntheticRecoveredRepairSessionId,
syntheticRecoveredRepairIdentity.runId,
);
const syntheticModernRecoveredRepairRecords = syntheticRecoveredRepairRecords(
'agent.runtime.provider_action_batch.confirmation_required',
);
const syntheticLegacyRecoveredRepairRecords = syntheticRecoveredRepairRecords(
'agent.runtime.tool_confirmation_required',
);
const syntheticModernRecoveredRepairLifecycle =
inspectSyntheticRecoveredRepair(syntheticModernRecoveredRepairRecords);
const syntheticLegacyRecoveredRepairLifecycle =
inspectSyntheticRecoveredRepair(syntheticLegacyRecoveredRepairRecords);
const syntheticRecoveredRepairLifecycles = [
syntheticModernRecoveredRepairLifecycle,
syntheticLegacyRecoveredRepairLifecycle,
];
const syntheticRecoveredRepairNegativeLifecycles = [
syntheticModernRecoveredRepairRecords,
syntheticLegacyRecoveredRepairRecords,
].flatMap((records) => [
...records.map((record) =>
inspectSyntheticRecoveredRepair([...records, { ...record }]),
),
...records.map((_, missingIndex) =>
inspectSyntheticRecoveredRepair(
records.filter((__, recordIndex) => recordIndex !== missingIndex),
),
),
]);
const syntheticRecoveredRepairConflictLifecycle =
inspectSyntheticRecoveredRepair([
syntheticModernRecoveredRepairRecords[0],
syntheticLegacyRecoveredRepairRecords[0],
...syntheticModernRecoveredRepairRecords.slice(1),
]);
const syntheticRecoveredRepairAutoReceiptLifecycle =
inspectSyntheticRecoveredRepair(
syntheticModernRecoveredRepairRecords.map((record) =>
record.recordType === 'agent.runtime.action_receipt'
? { ...record, executionMode: 'auto' }
: record,
),
);
const syntheticRecoveredRepairWrongRunLifecycle =
inspectSyntheticRecoveredRepair(
syntheticModernRecoveredRepairRecords.map((record) =>
record.recordType === 'agent.runtime.tool_confirmation.approved'
? { ...record, confirmedRunId: 'synthetic-other-run' }
: record,
),
);
const syntheticRecoveredRepairMissingSessionLifecycles =
syntheticModernRecoveredRepairRecords.map((_, missingSessionIndex) =>
inspectSyntheticRecoveredRepair(
syntheticModernRecoveredRepairRecords.map((record, recordIndex) => {
if (recordIndex !== missingSessionIndex) return record;
const recordWithoutSession = { ...record };
delete recordWithoutSession.sessionId;
return recordWithoutSession;
}),
),
);
const syntheticRecoveredRepairWrongSessionLifecycle =
inspectSyntheticRecoveredRepair(
syntheticModernRecoveredRepairRecords.map((record) =>
isNonEmptyString(record.sessionId)
? { ...record, sessionId: 'synthetic-other-session' }
: record,
),
);
const syntheticLegacyRecoveredRepairWrongSessionLifecycle =
inspectSyntheticRecoveredRepair([
{
...syntheticLegacyRecoveredRepairRecords[0],
sessionId: 'synthetic-other-session',
},
...syntheticLegacyRecoveredRepairRecords.slice(1),
]);
const syntheticRecoveredRepairOutOfOrderLifecycle =
inspectSyntheticRecoveredRepair([
syntheticModernRecoveredRepairRecords[1],
syntheticModernRecoveredRepairRecords[0],
syntheticModernRecoveredRepairRecords[2],
]);
assert(
syntheticRecoveredRepairLifecycles.every(
(lifecycle) =>
lifecycle.valid &&
lifecycle.confirmationRequirements.length === 1 &&
lifecycle.approvals.length === 1 &&
lifecycle.receipts.length === 1,
) &&
syntheticRecoveredRepairNegativeLifecycles.every(
(lifecycle) => !lifecycle.valid,
) &&
!Object.hasOwn(syntheticLegacyRecoveredRepairRecords[0], 'sessionId') &&
syntheticLegacyRecoveredRepairLifecycle.valid &&
syntheticRecoveredRepairMissingSessionLifecycles.every(
(lifecycle) => !lifecycle.valid,
) &&
!syntheticRecoveredRepairConflictLifecycle.valid &&
!syntheticRecoveredRepairAutoReceiptLifecycle.valid &&
!syntheticRecoveredRepairWrongRunLifecycle.valid &&
!syntheticRecoveredRepairWrongSessionLifecycle.valid &&
!syntheticLegacyRecoveredRepairWrongSessionLifecycle.valid &&
!syntheticRecoveredRepairOutOfOrderLifecycle.valid,
'agent-runtime-real-e2e-self-test-recovered-repair-confirmation-lifecycle-invalid',
);
const evidenceMetadata = {
kind: 'project.verify.metadata',
path: 'game/metadata-only.txt',
sha256: 'a'.repeat(64),
};
const expectedPrivateValues = [
'private static delivery task',
'private static acceptance criterion',
'private static result summary',
'private evidence summary body',
'private professional conversation body',
];
const dynamicPrivateValues = collectSupervisorSwarmDynamicPrivateValues({
deliveries: [
{
task: expectedPrivateValues[0],
acceptanceCriteria: [expectedPrivateValues[1]],
resultSummary: expectedPrivateValues[2],
structuredResult: {
evidence: [
{
...evidenceMetadata,
summary: expectedPrivateValues[3],
},
],
},
},
],
professionalConversations: [
{ messages: [{ content: expectedPrivateValues[4] }] },
],
isolatedGroups: [],
isolatedInstances: [],
isolatedResults: [],
isolatedConversations: [],
});
assert(
expectedPrivateValues.every((value) =>
dynamicPrivateValues.includes(value),
),
'agent-runtime-real-e2e-self-test-dynamic-private-body-missing',
);
assert(
Object.values(evidenceMetadata).every(
(value) => !dynamicPrivateValues.includes(value),
),
'agent-runtime-real-e2e-self-test-evidence-metadata-private',
);
const seedPrivateValues = supervisorSwarmSeedPrivateValues(
'private repository instructions body',
);
assert(
supervisorSwarmIsolatedReviews.every(
(review) =>
seedPrivateValues.includes(review.content) &&
seedPrivateValues.includes(review.requirement) &&
review.boundaryTerms.every((term) => !seedPrivateValues.includes(term)),
),
'agent-runtime-real-e2e-self-test-generic-boundary-term-private',
);
const syntheticMixedGroups = [
{
delegationGroupId: 'synthetic-followup-group',
request: {
children: supervisorSwarmFollowupIsolatedReviews.map((review) => ({
expectedArtifacts: [review.path],
})),
},
},
{
delegationGroupId: 'synthetic-initial-group',
request: {
children: supervisorSwarmInitialIsolatedReviews.map((review) => ({
expectedArtifacts: [review.path],
})),
},
},
];
const syntheticMixedEntries = supervisorSwarmMixedIsolatedGroupEntries(
syntheticMixedGroups,
supervisorSwarmIsolatedReviewGroups,
);
const syntheticSingleGroupEntries = supervisorSwarmMixedIsolatedGroupEntries(
[
{
delegationGroupId: 'synthetic-single-group',
request: {
children: supervisorSwarmIsolatedReviews.map((review) => ({
expectedArtifacts: [review.path],
})),
},
},
],
[supervisorSwarmIsolatedReviews],
);
const syntheticReadyGroupIds = supervisorSwarmReadyIsolatedGroupIds(
`readyIsolatedJoins: ${JSON.stringify({
ready: true,
joins: syntheticMixedEntries.map(({ group }) => ({
delegationGroupId: group.delegationGroupId,
})),
})}\n\nagentId: ${projectSupervisorAgentId}`,
);
const syntheticObservedJoinClaim = supervisorSwarmObservedJoinClaimForGroups(
[
{
schemaVersion: isolatedAgentJoinClaimSchemaVersion,
parentAgentId: projectSupervisorAgentId,
parentRunId: 'synthetic-parent-run',
actionId: 'synthetic-claim-action',
status: 'observed',
joins: syntheticMixedEntries.map(({ group }) => ({
delegationGroupId: group.delegationGroupId,
})),
},
],
syntheticReadyGroupIds,
);
const syntheticWriteScopeRoots = supervisorSwarmIsolatedWriteScopeRoots(
supervisorSwarmIsolatedReviewGroups.flatMap((reviews) =>
reviews.map((review) => ({ writeScopes: [review.scope] })),
),
);
let syntheticOverlappingWriteScopesRejected = false;
try {
supervisorSwarmIsolatedWriteScopeRoots([
{ writeScopes: ['e2e/**'] },
{ writeScopes: ['e2e/isolated-a/**'] },
]);
} catch (error) {
syntheticOverlappingWriteScopesRejected =
error?.code === 'supervisor-swarm-mixed-child-write-scopes-overlap';
}
const syntheticFollowupOrderValidated =
supervisorSwarmFollowupBeforeClaimOrderValid(3, 5, [8, 9]) &&
!supervisorSwarmFollowupBeforeClaimOrderValid(3, 8, [8, 9]);
const originalSuite = state.suite;
const originalInitialRunId = state.initialRunId;
state.suite = supervisorSwarmStaticIsolatedAutonomousChatSuite;
const multiGroupPolicy = expectedSupervisorSwarmCollaborationPolicy();
const multiGroupCount = supervisorSwarmExpectedIsolatedReviewGroups().length;
const syntheticSnapshotExpected = {
projectId: 'synthetic-project-id',
parentAgentId: projectSupervisorAgentId,
parentRunId: 'synthetic-parent-run',
boundFrom: supervisorCollaborationPolicySnapshotInitialBatchBinding,
policy: multiGroupPolicy,
policyFingerprint: hashValue(JSON.stringify(multiGroupPolicy)),
};
const syntheticSnapshotBindingBatch = {
schemaVersion: providerActionBatchSchemaVersion,
batchId: 'synthetic-provider-batch',
projectId: syntheticSnapshotExpected.projectId,
agentId: projectSupervisorAgentId,
taskId: 'synthetic-parent-task',
sessionId: supervisorSwarmSessionId,
runId: syntheticSnapshotExpected.parentRunId,
status: 'waiting-confirmation',
collaborationContract: {
schemaVersion: supervisorCollaborationContractSchemaVersion,
policySchemaVersion: supervisorCollaborationPolicySchemaVersion,
policySnapshot: multiGroupPolicy,
policyFingerprint: syntheticSnapshotExpected.policyFingerprint,
contractFingerprint: hashValue('synthetic-collaboration-contract'),
},
};
const syntheticSnapshotBindingBatchAccepted =
supervisorSwarmInitialBatchBindsPolicySnapshot(
syntheticSnapshotBindingBatch,
syntheticSnapshotExpected.parentRunId,
);
const syntheticSnapshotBindingBatchRejections = [
{ ...syntheticSnapshotBindingBatch, status: 'aborted' },
{ ...syntheticSnapshotBindingBatch, collaborationContract: null },
{ ...syntheticSnapshotBindingBatch, agentId: 'synthetic-other-agent' },
{ ...syntheticSnapshotBindingBatch, runId: 'synthetic-other-run' },
{ ...syntheticSnapshotBindingBatch, schemaVersion: 'legacy-v1' },
].every(
(batch) =>
!supervisorSwarmInitialBatchBindsPolicySnapshot(
batch,
syntheticSnapshotExpected.parentRunId,
),
);
const syntheticSnapshotIdentity = {
schemaVersion: supervisorCollaborationPolicySnapshotSchemaVersion,
...syntheticSnapshotExpected,
};
const syntheticSnapshot = {
...syntheticSnapshotIdentity,
snapshotFingerprint: hashJsonValue(syntheticSnapshotIdentity),
boundAt: 1_784_305_826,
};
const syntheticSnapshotInspection =
validateSupervisorSwarmCollaborationPolicySnapshot(
syntheticSnapshot,
syntheticSnapshotExpected,
);
const syntheticSnapshotBinding =
supervisorSwarmCollaborationPolicySnapshotBinding(syntheticSnapshot);
const syntheticSnapshotBindingInspection =
validateSupervisorSwarmCollaborationPolicySnapshotBinding(
syntheticSnapshotBinding,
syntheticSnapshot,
);
const syntheticSnapshotBytes = JSON.stringify(syntheticSnapshot);
const syntheticSnapshotBindingBytes = JSON.stringify(
syntheticSnapshotBinding,
);
const syntheticDriftedPolicy = driftedSupervisorSwarmCollaborationPolicy();
state.initialRunId = syntheticSnapshotExpected.parentRunId;
const syntheticDriftObservationCount =
supervisorSwarmCollaborationPolicyDriftObservationCount([
{
recordType: 'agent.runtime.tool_observation',
agentId: projectSupervisorAgentId,
runId: syntheticSnapshotExpected.parentRunId,
tool: 'agent.run_status',
status: 'ok',
summary: '项目协作策略已漂移,当前父 run 继续使用已绑定快照',
},
]);
state.initialRunId = originalInitialRunId;
let syntheticSnapshotTamperRejected = false;
try {
validateSupervisorSwarmCollaborationPolicySnapshot(
{ ...syntheticSnapshot, snapshotFingerprint: '0'.repeat(64) },
syntheticSnapshotExpected,
);
} catch (error) {
syntheticSnapshotTamperRejected =
error?.code === 'supervisor-swarm-collaboration-policy-snapshot-invalid';
}
let syntheticSnapshotBindingTamperRejected = false;
try {
validateSupervisorSwarmCollaborationPolicySnapshotBinding(
{ ...syntheticSnapshotBinding, boundAt: syntheticSnapshot.boundAt + 1 },
syntheticSnapshot,
);
} catch (error) {
syntheticSnapshotBindingTamperRejected =
error?.code ===
'supervisor-swarm-collaboration-policy-snapshot-binding-invalid';
}
const syntheticMissingSnapshotSafe =
inspectSupervisorSwarmCollaborationPolicySnapshot(
null,
syntheticSnapshotExpected,
).identityHashMatched === false;
const syntheticMissingBindingSafe =
inspectSupervisorSwarmCollaborationPolicySnapshotBinding(
null,
syntheticSnapshot,
).snapshotMatched === false;
const syntheticSnapshotDuplicateCount =
duplicateSupervisorSwarmCollaborationPolicySnapshotCount([
syntheticSnapshot,
]);
const syntheticSnapshotBindingDuplicateCount =
duplicateSupervisorSwarmCollaborationPolicySnapshotBindingCount([
syntheticSnapshotBinding,
]);
const syntheticEnospcDiagnostic = safeProcessFailureDiagnostic({
code: 1,
stderr: 'No space left on device (os error 28)',
});
const syntheticChatSessionFailureEvidence = buildSupervisorSwarmEvidence({
chatSessionUnexpectedlyClosed: true,
chatSessionFailureKind: syntheticEnospcDiagnostic.failureKind,
chatSessionExitCode: syntheticEnospcDiagnostic.exitCode,
chatSessionCloseSignal: syntheticEnospcDiagnostic.signal,
chatSessionProcessErrorCode: syntheticEnospcDiagnostic.processErrorCode,
chatSessionStderrChars: syntheticEnospcDiagnostic.stderrChars,
chatSessionStderrSha256: syntheticEnospcDiagnostic.stderrSha256,
});
state.suite = supervisorSwarmCollaborationPolicyMixedRecoverySuite;
const recoveryPolicy = expectedSupervisorSwarmCollaborationPolicy();
const recoveryGroupCount =
supervisorSwarmExpectedIsolatedReviewGroups().length;
state.suite = supervisorSwarmAutonomousChatSuite;
const syntheticSnapshotBindingBatchSuiteIndependent =
supervisorSwarmInitialBatchBindsPolicySnapshot(
syntheticSnapshotBindingBatch,
syntheticSnapshotExpected.parentRunId,
);
state.suite = originalSuite;
assert(
syntheticSnapshotInspection.identityHashMatched &&
syntheticSnapshotBindingInspection.snapshotMatched &&
syntheticSnapshotBytes === JSON.stringify(syntheticSnapshot) &&
syntheticSnapshotBindingBytes ===
JSON.stringify(syntheticSnapshotBinding) &&
multiGroupPolicy.minIsolatedGroupsBeforeClaim === 2 &&
syntheticDriftedPolicy.minIsolatedGroupsBeforeClaim === 1 &&
syntheticDriftObservationCount === 1 &&
syntheticSnapshotTamperRejected &&
syntheticSnapshotBindingTamperRejected &&
syntheticMissingSnapshotSafe &&
syntheticMissingBindingSafe &&
syntheticSnapshotDuplicateCount === 0 &&
syntheticSnapshotBindingDuplicateCount === 0 &&
syntheticSnapshotBindingBatchAccepted &&
syntheticSnapshotBindingBatchRejections &&
syntheticSnapshotBindingBatchSuiteIndependent &&
syntheticEnospcDiagnostic.failureKind === 'enospc' &&
syntheticEnospcDiagnostic.stderrChars > 0 &&
/^[0-9a-f]{64}$/u.test(syntheticEnospcDiagnostic.stderrSha256) &&
syntheticChatSessionFailureEvidence.chatSessionUnexpectedlyClosed ===
true &&
syntheticChatSessionFailureEvidence.chatSessionFailureKind === 'enospc',
'agent-runtime-real-e2e-self-test-collaboration-policy-snapshot-binding-invalid',
);
assert(
JSON.stringify(
syntheticMixedEntries.map(({ groupIndex }) => groupIndex),
) === JSON.stringify([0, 1]) &&
JSON.stringify(
syntheticSingleGroupEntries.map(({ groupIndex }) => groupIndex),
) === JSON.stringify([0]) &&
supervisorSwarmIsolatedReviewGroupIndex(
supervisorSwarmIsolatedReviews.map((review) => ({
expectedArtifacts: [review.path],
})),
) === -1 &&
JSON.stringify(syntheticReadyGroupIds) ===
JSON.stringify(
syntheticMixedGroups.map((group) => group.delegationGroupId).sort(),
) &&
syntheticObservedJoinClaim.actionId === 'synthetic-claim-action' &&
syntheticWriteScopeRoots.length ===
supervisorSwarmIsolatedReviews.length &&
new Set(syntheticWriteScopeRoots).size ===
supervisorSwarmIsolatedReviews.length &&
syntheticOverlappingWriteScopesRejected &&
syntheticFollowupOrderValidated &&
multiGroupPolicy.minIsolatedChildren === 2 &&
Object.hasOwn(multiGroupPolicy, 'minIsolatedGroupsBeforeClaim') &&
multiGroupPolicy.minIsolatedGroupsBeforeClaim === 2 &&
multiGroupCount === 2 &&
recoveryPolicy.minIsolatedChildren === 3 &&
!Object.hasOwn(recoveryPolicy, 'minIsolatedGroupsBeforeClaim') &&
(recoveryPolicy.minIsolatedGroupsBeforeClaim ?? 0) === 0 &&
recoveryGroupCount === 1,
'agent-runtime-real-e2e-self-test-mixed-isolated-groups-invalid',
);
const syntheticIdentity = {
agentId: 'private-agent-id',
taskId: 'private-task-id',
sessionId: 'private-session-id',
runId: 'private-run-id',
source: 'private-source',
};
const persistedAuditEnvelope = {
schemaVersion: 'game-creator-agent-db.v1',
updatedAt: 1_784_305_826,
};
const retryableProtocolErrorKinds = toolPlanProtocolErrorKinds.filter(
(kind) => kind !== 'catalog-binding',
);
const repairRecords = retryableProtocolErrorKinds.map((kind, index) => ({
...persistedAuditEnvelope,
recordType: 'agent.runtime.tool_plan.repair',
...syntheticIdentity,
loopIteration: index,
repairAttempt: 0,
requestSlot: `loop-${index}-repair-0`,
responseFingerprint: hashValue(`private-response-${kind}`),
providerRequestIdSha256: hashValue(`private-provider-request-${kind}`),
attempt: 1,
maxAttempts: 2,
protocolErrorKind: kind,
protocolErrorSha256: hashValue(`private-error-${kind}`),
protocolErrorChars: 24,
responsePreviewSha256: hashValue(`private-preview-${kind}`),
responsePreviewChars: 26,
protocol: 'native_runtime_tools',
callIdSha256: hashValue(`private-call-${kind}`),
functionNameSha256: hashValue(`runtime_tool_${kind}`),
}));
repairRecords.push({
...repairRecords[0],
repairAttempt: 1,
requestSlot: 'loop-0-repair-1',
responseFingerprint: hashValue('private-response-shape-second'),
providerRequestIdSha256: hashValue('private-provider-request-shape-second'),
attempt: 2,
});
const fatalCatalogBindingRepair = {
...repairRecords[0],
loopIteration: retryableProtocolErrorKinds.length,
requestSlot: `loop-${retryableProtocolErrorKinds.length}-repair-0`,
responseFingerprint: hashValue('private-response-catalog-binding'),
providerRequestIdSha256: hashValue(
'private-provider-request-catalog-binding',
),
protocolErrorKind: 'catalog-binding',
};
const syntheticProtocolCallId = 'private-call-id';
const syntheticProtocolResponseId = 'private-response-id';
const normalizedProtocolRecord = {
...persistedAuditEnvelope,
recordType: 'agent.runtime.tool_plan.protocol',
...syntheticIdentity,
loopIteration: 8,
repairAttempt: 0,
requestSlot: 'loop-8-repair-0',
responseFingerprint: hashValue('private-protocol-response'),
providerRequestIdSha256: hashValue('private-protocol-provider-request'),
protocol: 'native_runtime_tools',
functionCallCount: 1,
callIdSha256s: [hashValue(syntheticProtocolCallId)],
functionNames: ['runtime_tool_file_read'],
normalizationKinds: ['complete-think-block', 'planner-commentary'],
normalizationCount: 3,
normalizedTextChars: 80,
normalizedTextSha256: hashValue('private-normalized-text'),
responseIdSha256: hashValue(syntheticProtocolResponseId),
responseIdChars: syntheticProtocolResponseId.length,
};
const toolPlanAudits = [normalizedProtocolRecord, ...repairRecords];
const fullRepairEvidence = collectToolPlanRepairAuditEvidence(toolPlanAudits);
const fatalRepairEvidence = collectToolPlanRepairAuditEvidence([
normalizedProtocolRecord,
fatalCatalogBindingRepair,
]);
const expectedRepairCounts = emptyToolPlanRepairCountsByProtocolErrorKind();
for (const kind of retryableProtocolErrorKinds) {
expectedRepairCounts[kind] = kind === 'response-shape' ? 2 : 1;
}
assert(
fullRepairEvidence.toolPlanRepairCount === 8 &&
fullRepairEvidence.toolPlanRepairedLoopCount === 7 &&
fullRepairEvidence.toolPlanSecondRepairCount === 1 &&
JSON.stringify(
fullRepairEvidence.toolPlanRepairCountsByProtocolErrorKind,
) === JSON.stringify(expectedRepairCounts) &&
sumObjectValues(
fullRepairEvidence.toolPlanRepairCountsByProtocolErrorKind,
) === fullRepairEvidence.toolPlanRepairCount &&
fullRepairEvidence.toolPlanAuditPayloadLeakCount === 0 &&
toolPlanRepairEvidenceHasNoFatalLocalRepair(fullRepairEvidence) &&
!toolPlanRepairEvidenceHasNoFatalLocalRepair(fatalRepairEvidence),
'agent-runtime-real-e2e-self-test-tool-plan-repair-aggregate-invalid',
);
const rawPayloadFields = [
'errorBody',
'detail',
'preview',
'arguments',
'body',
'text',
'protocolError',
'responsePreview',
'toolArguments',
];
const rejectedRawPayloadFieldCount = rawPayloadFields.filter(
(field) =>
!hasSafeToolPlanAuditPayload({
...repairRecords[0],
[field]: `private-${field}`,
}),
).length;
const recordsMissingRequiredFields = [
...[...toolPlanProtocolAuditSafeFields].map((field) => {
const record = { ...normalizedProtocolRecord };
delete record[field];
return record;
}),
...[...toolPlanRepairAuditSafeFields].map((field) => {
const record = { ...repairRecords[0] };
delete record[field];
return record;
}),
];
const rejectedMissingAuditFieldCount = recordsMissingRequiredFields.filter(
(record) => !hasSafeToolPlanAuditPayload(record),
).length;
const wrongSlotAuditRecords = [
{ ...normalizedProtocolRecord, requestSlot: 'loop-8-repair-1' },
{ ...repairRecords[0], requestSlot: 'loop-0-repair-1' },
];
const rejectedWrongSlotCount = wrongSlotAuditRecords.filter(
(record) => !hasSafeToolPlanAuditPayload(record),
).length;
const rawIdentifierAuditFields = {
callId: syntheticProtocolCallId,
callIds: [syntheticProtocolCallId],
functionName: 'runtime_tool_file_read',
providerRequestId: 'private-provider-request-id',
responseId: syntheticProtocolResponseId,
};
const rejectedRawIdentifierFieldCount = Object.entries(
rawIdentifierAuditFields,
).filter(
([field, value]) =>
!hasSafeToolPlanAuditPayload({
...normalizedProtocolRecord,
[field]: value,
}),
).length;
const invalidHashOrCatalogAuditRecords = [
{
...normalizedProtocolRecord,
callIdSha256s: ['A'.repeat(64)],
},
{
...normalizedProtocolRecord,
responseIdSha256: null,
},
{
...normalizedProtocolRecord,
functionNames: ['private_uncatalogued_function'],
},
{
...repairRecords[0],
providerRequestIdSha256: '0'.repeat(63),
},
{
...repairRecords[0],
repairAttempt: 1,
requestSlot: 'loop-0-repair-1',
},
];
const rejectedInvalidHashOrCatalogCount =
invalidHashOrCatalogAuditRecords.filter(
(record) => !hasSafeToolPlanAuditPayload(record),
).length;
assert(
rejectedRawPayloadFieldCount === rawPayloadFields.length &&
rejectedMissingAuditFieldCount === recordsMissingRequiredFields.length &&
rejectedWrongSlotCount === wrongSlotAuditRecords.length &&
rejectedRawIdentifierFieldCount ===
Object.keys(rawIdentifierAuditFields).length &&
rejectedInvalidHashOrCatalogCount ===
invalidHashOrCatalogAuditRecords.length &&
hasSafeToolPlanAuditPayload(normalizedProtocolRecord) &&
!hasSafeToolPlanAuditPayload({
...normalizedProtocolRecord,
normalizationKinds: ['private-kind'],
}) &&
!hasSafeToolPlanAuditPayload({
...repairRecords[0],
protocolErrorKind: 'private-error',
}),
'agent-runtime-real-e2e-self-test-tool-plan-payload-boundary-invalid',
);
const repairReport = JSON.stringify(fullRepairEvidence);
const repairReportPrivateValueLeakCount = countExactSecrets(
Buffer.from(repairReport),
[
...Object.values(syntheticIdentity),
...repairRecords.flatMap((record) => [
record.responseFingerprint,
record.providerRequestIdSha256,
record.protocolErrorSha256,
record.responsePreviewSha256,
record.callIdSha256,
record.functionNameSha256,
]),
],
);
assert(
repairReportPrivateValueLeakCount === 0 &&
!/(agentId|taskId|sessionId|runId|source|requestSlot|loopIteration|Sha256)/u.test(
repairReport,
),
'agent-runtime-real-e2e-self-test-tool-plan-report-private-data-leak',
);
return {
status: 'PASS',
suite: 'agent-runtime-real-e2e-self-test',
providerUsed: false,
exactSecretCounts,
scopedPrivateOutputValidated,
recoveredRepairConfirmationLifecycleValidated: true,
modernRecoveredRepairConfirmationLifecycleValidated: true,
legacyRecoveredRepairConfirmationLifecycleValidated: true,
recoveredRepairConfirmationConflictRejected: true,
recoveredRepairConfirmationModeAndOrderValidated: true,
dynamicPrivateBodyCount: expectedPrivateValues.length,
evidenceMetadataExcluded: true,
genericBoundaryTermsExcluded: true,
mixedIsolatedGroupTopologyValidated: true,
mixedReadyJoinObservationValidated: true,
mixedObservedJoinClaimValidated: true,
mixedCrossGroupWriteScopesValidated: true,
mixedFollowupBeforeClaimOrderValidated: true,
legacySingleIsolatedGroupTopologyValidated: true,
mixedSuitePolicyIsolationValidated: true,
collaborationPolicySnapshotCaptured: true,
collaborationPolicySnapshotStable: true,
collaborationPolicySnapshotBindingCaptured: true,
collaborationPolicySnapshotBindingStable: true,
durableSnapshotEligibilityAndContractBindingValidated: true,
sourceEndpointAbsentLifecycleGuardValidated,
...interactiveCliLifecycle,
...providerBindingLifecycle,
...providerUsedReportingLifecycle,
...ownedProcessCleanupLifecycle,
liveProcessIdentityEnumerationValidated: true,
...professionalSessionLifecycle,
...executionOwnerLockScanLifecycle,
...staticSmokeBindingLifecycle,
...seededGameHtmlLifecycle,
...supervisorAcceptedPublicStatusLifecycle,
isolatedAppDataLatePathScannerValidated: true,
...childCloseTimeoutLifecycle,
stableKillHandlePlatformValidated,
stableKillHandleCloseValidated,
stableKillHandleSignalValidated,
stableKillHandleCommandFailureCleanupValidated,
windowsOwnedTempPathValidated,
autonomousPlayableSuiteRegistered,
autonomousPlayablePackageCommandsRegistered,
autonomousPlayableDedicatedPathValidated: true,
autonomousPlayableExactStdinValidated: true,
autonomousPlayablePartialCollectorPrivacyValidated,
toolPlanHandoffSuiteRegistered,
toolPlanHandoffPackageCommandsRegistered,
toolPlanHandoffSourceGuardRegistered,
toolPlanHandoffCleanupRegistered,
toolPlanHandoffPartialEvidenceRegistered: true,
toolPlanHandoffPlanProjectionValidated,
toolPlanHandoffEvidenceFieldsRegistered,
toolPlanHandoffUnknownResultBoundaryPreserved: true,
finalReplyFaultPrerequisiteValidated: true,
collaborationPolicyDriftFixtureValidated: true,
collaborationPolicyDriftStatusObserved: true,
duplicateCollaborationPolicySnapshotCount: syntheticSnapshotDuplicateCount,
duplicateCollaborationPolicySnapshotBindingCount:
syntheticSnapshotBindingDuplicateCount,
collaborationPolicySnapshotTamperRejected: syntheticSnapshotTamperRejected,
collaborationPolicySnapshotBindingTamperRejected:
syntheticSnapshotBindingTamperRejected,
collaborationPolicyPartialMissingEvidenceSafe:
syntheticMissingSnapshotSafe && syntheticMissingBindingSafe,
enospcFailureDiagnosticClassified: true,
chatSessionFailureEvidenceSchemaValidated: true,
toolPlanRepairCount: fullRepairEvidence.toolPlanRepairCount,
toolPlanRepairedLoopCount: fullRepairEvidence.toolPlanRepairedLoopCount,
toolPlanSecondRepairCount: fullRepairEvidence.toolPlanSecondRepairCount,
toolPlanRepairCountsByProtocolErrorKind:
fullRepairEvidence.toolPlanRepairCountsByProtocolErrorKind,
toolPlanRepairClassificationTotalMatched: true,
toolPlanFatalLocalRepairRejected: true,
toolPlanPersistedAuditEnvelopeAccepted: true,
toolPlanRawPayloadFieldRejectionCount: rejectedRawPayloadFieldCount,
toolPlanMissingAuditFieldRejectionCount: rejectedMissingAuditFieldCount,
toolPlanWrongSlotRejectionCount: rejectedWrongSlotCount,
toolPlanRawIdentifierFieldRejectionCount: rejectedRawIdentifierFieldCount,
toolPlanInvalidHashOrCatalogRejectionCount:
rejectedInvalidHashOrCatalogCount,
toolPlanRepairReportPrivateValueLeakCount:
repairReportPrivateValueLeakCount,
};
}
function validateSupervisorSwarmProfessionalSessionsSelfTest() {
const rootRunId = 'synthetic-professional-session-root-run';
const deliverySession = {
agentId: 'synthetic-delivery-agent',
sessionId: 'synthetic-delivery-session',
};
const schedulerSession = {
agentId: 'synthetic-scheduler-agent',
sessionId: 'synthetic-scheduler-session',
};
const schedulerTask = (agentId, sessionId, overrides = {}) => ({
agentId,
sessionId,
source: 'agent-ready-task-scheduler',
parentAgentId: projectSupervisorAgentId,
parentRunId: rootRunId,
...overrides,
});
const sessions = supervisorSwarmProfessionalSessions({
deliveries: [
{
targetAgentId: deliverySession.agentId,
targetSessionId: deliverySession.sessionId,
},
{ targetAgentId: '', targetSessionId: 'invalid-delivery-session' },
],
latestTasks: [
schedulerTask(schedulerSession.agentId, schedulerSession.sessionId),
schedulerTask(deliverySession.agentId, deliverySession.sessionId),
schedulerTask('synthetic-isolated-agent', 'synthetic-isolated-session', {
source: 'agent-isolated-child',
}),
schedulerTask(
'synthetic-wrong-parent-agent',
'synthetic-wrong-parent-agent-session',
{ parentAgentId: 'synthetic-other-parent' },
),
schedulerTask(
'synthetic-wrong-parent-run-agent',
'synthetic-wrong-parent-run-session',
{ parentRunId: 'synthetic-other-run' },
),
schedulerTask(projectSupervisorAgentId, 'synthetic-root-session'),
schedulerTask('', 'synthetic-invalid-agent-session'),
schedulerTask('synthetic-invalid-session-agent', ''),
],
rootAgentId: projectSupervisorAgentId,
rootRunId,
});
const sessionIdentities = sessions
.map(({ agentId, sessionId }) => `${agentId}\0${sessionId}`)
.sort();
const expectedIdentities = [deliverySession, schedulerSession]
.map(({ agentId, sessionId }) => `${agentId}\0${sessionId}`)
.sort();
const missingRootBindingSessions = supervisorSwarmProfessionalSessions({
deliveries: [],
latestTasks: [
schedulerTask(schedulerSession.agentId, schedulerSession.sessionId),
],
rootAgentId: projectSupervisorAgentId,
rootRunId: '',
});
assert(
JSON.stringify(sessionIdentities) === JSON.stringify(expectedIdentities) &&
missingRootBindingSessions.length === 0,
'agent-runtime-real-e2e-self-test-professional-session-enumeration-invalid',
);
return {
schedulerProfessionalSessionIncluded: true,
professionalSessionIdentityDeduplicated: true,
isolatedProfessionalSessionExcluded: true,
wrongParentProfessionalSessionExcluded: true,
missingRootBindingProfessionalSessionExcluded: true,
};
}
function validateExecutionOwnerLockScanSelfTest() {
const root = path.join(os.tmpdir(), 'synthetic-execution-owner-lock-root');
const emptyRegularFile = {
size: 0,
isFile: () => true,
isSymbolicLink: () => false,
};
assert(
isEmptyExecutionOwnerLock(
root,
path.join(root, '.agent/runtime/execution-owner.lock'),
emptyRegularFile,
) &&
!isEmptyExecutionOwnerLock(
root,
path.join(root, '.agent/runtime/execution-owner.json'),
emptyRegularFile,
) &&
!isEmptyExecutionOwnerLock(
root,
path.join(root, '.agent/runtime/execution-owner.lock.backup'),
emptyRegularFile,
) &&
!isEmptyExecutionOwnerLock(
root,
path.join(root, '.agent/runtime/execution-owner.lock'),
{ ...emptyRegularFile, size: 1 },
) &&
!isEmptyExecutionOwnerLock(
root,
path.join(root, '.agent/runtime/execution-owner.lock'),
{ ...emptyRegularFile, isSymbolicLink: () => true },
),
'agent-runtime-real-e2e-self-test-execution-owner-lock-scan-boundary-invalid',
);
return {
emptyExecutionOwnerLockSkipped: true,
adjacentRuntimeEvidenceStillScanned: true,
nonEmptyExecutionOwnerLockStillScanned: true,
symbolicExecutionOwnerLockStillScanned: true,
};
}
function validateSupervisorAcceptedPublicStatusSelfTest() {
const runId = 'synthetic-supervisor-accepted-status-run';
const correlationId = finalMessageId(
projectSupervisorAgentId,
supervisorSwarmSessionId,
runId,
).slice('agent-finalization-'.length);
const expectedMessageId = `runtime-public-status-${correlationId}-070c160a6299c543`;
const canonicalAcceptedStatus = {
role: 'assistant',
agentId: null,
sessionId: null,
messageId: expectedMessageId,
content: '任务已接收,项目总控 Agent 正在启动处理。',
};
const rejectedVariants = [
{ ...canonicalAcceptedStatus, role: 'user' },
{ ...canonicalAcceptedStatus, agentId: projectSupervisorAgentId },
{ ...canonicalAcceptedStatus, sessionId: supervisorSwarmSessionId },
{ ...canonicalAcceptedStatus, messageId: `${expectedMessageId}-legacy` },
{ ...canonicalAcceptedStatus, content: '任务已接收。' },
];
const canonicalBoundary =
inspectSupervisorAutonomousPlayableConversationBoundary(
[canonicalAcceptedStatus],
[canonicalAcceptedStatus],
runId,
);
const rejectedBoundaries = [
...rejectedVariants.map((message) => [canonicalAcceptedStatus, message]),
[canonicalAcceptedStatus, { role: 'user', content: 'legacy-user' }],
].map((legacyConversation) =>
inspectSupervisorAutonomousPlayableConversationBoundary(
legacyConversation,
legacyConversation,
runId,
),
);
assert(
runtimePublicStatusMessageId(
projectSupervisorAgentId,
supervisorSwarmSessionId,
runId,
'accepted',
) === expectedMessageId &&
isSupervisorAutonomousPlayableAcceptedPublicStatus(
canonicalAcceptedStatus,
runId,
) &&
rejectedVariants.every(
(message) =>
!isSupervisorAutonomousPlayableAcceptedPublicStatus(message, runId),
) &&
canonicalBoundary.legacyUserFacingMessageCount === 1 &&
canonicalBoundary.acceptedPublicStatusCount === 1 &&
canonicalBoundary.wrongAgentFinalAssistantCount === 0 &&
rejectedBoundaries.every(
(boundary) =>
boundary.legacyUserFacingMessageCount !== 1 ||
boundary.acceptedPublicStatusCount !== 1 ||
boundary.wrongAgentFinalAssistantCount !== 0,
),
'agent-runtime-real-e2e-self-test-supervisor-accepted-public-status-invalid',
);
return {
supervisorAcceptedPublicStatusIdValidated: true,
supervisorAcceptedPublicStatusShapeValidated: true,
supervisorAcceptedPublicStatusLegacyVariantsRejected: true,
};
}
function validateSupervisorPlayableProviderBindingSelfTest() {
const previousSuite = state.suite;
state.suite = supervisorAutonomousPlayableLaneDefenseSuite;
try {
const config = {
agentMode: 'provider',
llm: {
apiKey: 'synthetic-provider-key-not-for-network',
baseUrl: 'https://synthetic-provider.invalid/gpt/v1',
model: 'gpt-5.6-sol',
apiKind: 'openai_responses',
reasoningEffort: 'max',
},
};
const binding = expectedProviderBindingForSuite(config);
assert(
binding?.providerModel === 'gpt-5.6-sol' &&
binding.providerApiKind === 'openai_responses' &&
binding.providerReasoningEffort === 'max' &&
/^[0-9a-f]{64}$/u.test(binding.providerBaseUrlSha256) &&
binding.boundAgentIds.length === 1 &&
!JSON.stringify(binding).includes(config.llm.apiKey) &&
!JSON.stringify(binding).includes(config.llm.baseUrl),
'agent-runtime-real-e2e-self-test-provider-binding-invalid',
);
const reorderedBinding = {
boundAgentIds: [...binding.boundAgentIds],
providerBaseUrlSha256: binding.providerBaseUrlSha256,
providerReasoningEffort: binding.providerReasoningEffort,
providerApiKind: binding.providerApiKind,
providerModel: binding.providerModel,
};
assert(
sameSupervisorPlayableProviderBinding(binding, reorderedBinding) &&
!sameSupervisorPlayableProviderBinding(binding, {
...reorderedBinding,
providerReasoningEffort: 'high',
}),
'agent-runtime-real-e2e-self-test-provider-binding-comparison-invalid',
);
const drifted = expectedProviderBindingForSuite({
...config,
agentLlm: { 'art-director': { reasoningEffort: 'high' } },
});
assert(
drifted === null,
'agent-runtime-real-e2e-self-test-provider-binding-drift-accepted',
);
return {
providerAgentModeBindingValidated: true,
providerModelBindingValidated: true,
providerApiKindBindingValidated: true,
providerReasoningEffortBindingValidated: true,
providerBaseUrlHashBindingValidated: true,
providerBindingPropertyOrderInsensitiveValidated: true,
providerBindingDriftRejected: true,
};
} finally {
state.suite = previousSuite;
}
}
function validateProviderUsedReportingSelfTest() {
const completeProviderEvidence = {
evidenceCompleteness: 'complete',
providerAgentMode: 'provider',
providerModel: 'gpt-5.6-sol',
providerApiKind: 'openai_responses',
providerReasoningEffort: 'max',
providerBaseUrlSha256: 'a'.repeat(64),
providerBoundAgentCount: 4,
providerBindingMatched: true,
providerRequestIdentityCount: 2,
providerLifecycleStartedCount: 2,
providerLifecycleTerminalCount: 2,
providerLifecycleCompletedCount: 2,
providerLifecycleFailedCount: 0,
openProviderLifecycleCount: 0,
duplicateProviderLifecycleCount: 0,
};
const negativeEvidence = [
{},
{ ...completeProviderEvidence, evidenceCompleteness: 'partial' },
{ ...completeProviderEvidence, providerAgentMode: null },
{ ...completeProviderEvidence, providerBindingMatched: false },
{ ...completeProviderEvidence, providerRequestIdentityCount: 0 },
{ ...completeProviderEvidence, providerLifecycleStartedCount: 1 },
{ ...completeProviderEvidence, providerLifecycleTerminalCount: 1 },
{ ...completeProviderEvidence, providerLifecycleCompletedCount: 1 },
{ ...completeProviderEvidence, providerLifecycleFailedCount: 1 },
{ ...completeProviderEvidence, openProviderLifecycleCount: 1 },
{ ...completeProviderEvidence, duplicateProviderLifecycleCount: 1 },
];
const previousEvidence = state.evidence;
let positiveSummary;
let partialSummary;
try {
state.evidence = completeProviderEvidence;
positiveSummary = buildSummary();
state.evidence = negativeEvidence[1];
partialSummary = buildSummary();
} finally {
state.evidence = previousEvidence;
}
assert(
providerUsedFromEvidence(completeProviderEvidence) === true &&
positiveSummary.providerUsed === true &&
partialSummary.providerUsed === false &&
negativeEvidence.every(
(evidence) => providerUsedFromEvidence(evidence) === false,
),
'agent-runtime-real-e2e-self-test-provider-used-reporting-invalid',
);
return {
providerUsedCompleteLifecycleValidated: true,
providerUsedPartialEvidenceRejected: true,
providerUsedMissingLifecycleRejected: true,
providerUsedFailedLifecycleRejected: true,
providerUsedOpenLifecycleRejected: true,
providerUsedDuplicateLifecycleRejected: true,
providerUsedBindingMismatchRejected: true,
};
}
function validateOwnedProcessCleanupIdentitySelfTest() {
const processRecords = [
{
pid: 41001,
parentPid: 1,
startedAt: 'runner-start',
name: 'genarrative-ai-game-creator-shell.exe',
},
{
pid: 41002,
parentPid: 41001,
startedAt: 'helper-start',
name: 'powershell.exe',
},
{
pid: 41003,
parentPid: 41001,
startedAt: 'node-start',
name: 'node.exe',
},
{
pid: 41004,
parentPid: 41003,
startedAt: 'browser-start',
name: 'chrome.exe',
},
{
pid: 41005,
parentPid: 41001,
startedAt: 'command-start',
name: 'cmd.exe',
},
{
pid: 42000,
parentPid: 1,
startedAt: 'unrelated-start',
name: 'node.exe',
},
];
const snapshot = buildOwnedProcessCleanupSnapshot(processRecords, {
runnerPid: 41001,
helperPids: [41002],
rootPids: [41001, 41002],
});
const live = inspectOwnedProcessCleanupResiduals(snapshot, processRecords, {
activeCommandChildCount: 1,
activeInteractiveCliSessionCount: 1,
});
const reusedPids = processRecords.map((record) =>
record.pid >= 41001 && record.pid <= 41005
? { ...record, startedAt: `${record.startedAt}-reused` }
: record,
);
const cleaned = inspectOwnedProcessCleanupResiduals(snapshot, reusedPids, {
activeCommandChildCount: 0,
activeInteractiveCliSessionCount: 0,
});
assert(
snapshot.observedCounts.runner === 1 &&
snapshot.observedCounts.helper === 1 &&
snapshot.observedCounts.node === 1 &&
snapshot.observedCounts.browser === 1 &&
snapshot.observedCounts.command === 1 &&
live.clean === false &&
live.residualCounts.total === 5 &&
cleaned.clean === true &&
cleaned.residualCounts.total === 0,
'agent-runtime-real-e2e-self-test-owned-process-cleanup-invalid',
);
return {
ownedRunnerResidualIdentityValidated: true,
ownedHelperResidualIdentityValidated: true,
ownedNodeResidualIdentityValidated: true,
ownedBrowserResidualIdentityValidated: true,
ownedCommandResidualIdentityValidated: true,
ownedProcessPidReuseRejected: true,
activeChildRegistryCleanupValidated: true,
};
}
function validateStaticSmokeFinalIndexBindingSelfTest() {
const sha256 = 'a'.repeat(64);
const gate = {
lastVerificationStatus: 'passed',
verifiedRevision: 7,
staticSmokeVerifiedRevision: 7,
staticSmokeVerifiedGameIndexSha256: sha256,
};
assert(
supervisorAutonomousPlayableStaticSmokeMatchesFinalIndex(gate, 7, sha256) &&
!supervisorAutonomousPlayableStaticSmokeMatchesFinalIndex(
gate,
7,
'b'.repeat(64),
),
'agent-runtime-real-e2e-self-test-static-smoke-final-index-binding-invalid',
);
return {
staticSmokeFinalIndexSha256BindingValidated: true,
staticSmokeStaleIndexSha256Rejected: true,
};
}
function validateSeededGameHtmlContractSelfTest() {
const html = seededGameHtml();
const lowerHtml = html.toLowerCase();
const satisfiesStaticSmokeContract = (candidate) => {
const lowerCandidate = candidate.toLowerCase();
return (
lowerCandidate.includes('<canvas') &&
lowerCandidate.includes('getcontext(') &&
lowerCandidate.includes('fillrect(') &&
candidate.includes('requestAnimationFrame') &&
['keydown', 'keyup', 'pointer', 'mousedown', 'touch', 'click'].some(
(marker) => lowerCandidate.includes(marker),
) &&
['goal', 'objective', 'survive'].some((marker) =>
lowerCandidate.includes(marker),
) &&
['win', 'victory', 'defeat'].some((marker) =>
lowerCandidate.includes(marker),
) &&
['restart', 'reset', 'again'].some((marker) =>
lowerCandidate.includes(marker),
) &&
lowerCandidate.includes('</script>') &&
lowerCandidate.includes('</html>')
);
};
assert(
satisfiesStaticSmokeContract(html) &&
lowerHtml.includes('real_e2e_target:before'.toLowerCase()),
'agent-runtime-real-e2e-self-test-seeded-game-static-smoke-contract-invalid',
);
for (const [label, brokenHtml] of [
['input', html.replaceAll('pointer', 'input-event-removed')],
['objective', html.replace(/objective|survive/giu, 'purpose-removed')],
['terminal', html.replace(/victory|defeat/giu, 'terminal-state-removed')],
['restart', html.replace(/restart/giu, 'retry-path-removed')],
]) {
assert(
!satisfiesStaticSmokeContract(brokenHtml),
`agent-runtime-real-e2e-self-test-seeded-game-negative-${label}-invalid`,
);
}
return {
seededGameHtmlStaticSmokeContractValidated: true,
seededGameHtmlStaticSmokeNegativeCasesValidated: true,
};
}
async function waitForSelfTestChildSpawn(child) {
if (Number.isSafeInteger(child.pid) && child.pid > 1) return;
await new Promise((resolve, reject) => {
child.once('spawn', resolve);
child.once('error', reject);
});
}
async function stopSelfTestChild(child) {
if (!child || child.exitCode !== null || child.signalCode !== null) return;
child.kill('SIGKILL');
await waitForChildClose(child, 10_000);
}
async function validateWaitForChildCloseHardTimeout(killBehavior) {
const child = spawn(process.execPath, ['-e', 'setInterval(() => {}, 1000)'], {
stdio: 'ignore',
windowsHide: true,
});
await waitForSelfTestChildSpawn(child);
const originalKill = child.kill.bind(child);
child.kill = () => {
if (killBehavior === 'false') return false;
const error = new Error('synthetic-child-kill-failure');
error.code = 'EPERM';
throw error;
};
const startedAt = Date.now();
let failure = null;
try {
await waitForChildClose(child, 25, 75);
} catch (error) {
failure = error;
} finally {
child.kill = originalKill;
await stopSelfTestChild(child);
}
assert(
failure?.code ===
'isolated-runner-stable-kill-handle-helper-reap-timeout' &&
Date.now() - startedAt < 2_000,
`agent-runtime-real-e2e-self-test-child-close-${killBehavior}-kill-hard-timeout-invalid`,
);
return true;
}
async function validateStableKillHandleCommandFailureCleanup() {
const victim = spawn(
process.execPath,
['-e', 'setInterval(() => {}, 1000)'],
{ stdio: 'ignore', windowsHide: true },
);
await waitForSelfTestChildSpawn(victim);
const handle = await openOwnedRunnerKillHandle(victim.pid);
const originalEnd = handle.child.stdin.end.bind(handle.child.stdin);
const originalKill = handle.child.kill.bind(handle.child);
let helperClosedWhenCleanupKillStarted = null;
let failure = null;
handle.child.stdin.end = () => {
const error = new Error('synthetic-stable-handle-epipe');
error.code = 'EPIPE';
throw error;
};
handle.child.kill = (...args) => {
helperClosedWhenCleanupKillStarted ??= handle.closed;
return originalKill(...args);
};
try {
await closeOwnedRunnerKillHandle(handle);
} catch (error) {
failure = error;
} finally {
handle.child.stdin.end = originalEnd;
handle.child.kill = originalKill;
}
try {
assert(
failure?.code === 'isolated-runner-stable-kill-handle-stdin-failed' &&
handle.command === 'CLOSE' &&
helperClosedWhenCleanupKillStarted === false &&
handle.closed === true &&
(handle.child.exitCode !== null || handle.child.signalCode !== null) &&
!activeCommandChildren.has(handle.child) &&
isProcessAlive(victim.pid),
'agent-runtime-real-e2e-self-test-stable-handle-command-failure-cleanup-invalid',
);
return true;
} finally {
await closeOwnedRunnerKillHandle(handle).catch(() => {});
await stopSelfTestChild(victim);
}
}
async function validateInteractiveCliInheritedStdioLifecycle() {
const expectedReport = {
schemaVersion: 'game-creator-swarm-turn-report.v1',
outcome: 'settled',
parentAgentId: 'project-supervisor',
sessionId: 'interactive-cli-fd3-self-test-session',
parentRunId: 'interactive-cli-fd3-self-test-run',
runtimeCount: 1,
busyRuntimeCount: 0,
pendingTaskCount: 0,
runningTaskCount: 0,
waitingForConfirmationCount: 0,
waitingForUserInputCount: 0,
newAssistantMessageCount: 1,
finalReplyChars: 1,
reconciliationAgentCount: 0,
};
const stderrMarker = 'interactive-cli-fd3-holder-stderr-marker';
const previousProjectPathScanner = state.projectPathTranscriptScanner;
const projectPathScanner = new StreamingSecretScanner([stderrMarker]);
state.projectPathTranscriptScanner = projectPathScanner;
const reportLine = `[turn.report] ${JSON.stringify(expectedReport)}\n`;
const splitIndex = Math.max(1, Math.floor(reportLine.length / 2));
const holderSource = `
process.stdin.setEncoding('utf8');
let input = '';
const safetyTimer = setTimeout(() => process.exit(74), 15_000);
process.stdin.on('data', (chunk) => {
input += chunk;
if (!input.includes('CLOSE\\n')) return;
clearTimeout(safetyTimer);
process.exit(0);
});
process.stdin.on('end', () => process.exit(75));
process.stdin.resume();
`;
const wrapperSource = `
const { spawn } = require('node:child_process');
const holder = spawn(
process.execPath,
['--input-type=commonjs', '-e', ${JSON.stringify(holderSource)}],
{ stdio: [3, 'inherit', 'inherit'], windowsHide: true },
);
holder.once('error', () => {
process.exitCode = 73;
});
holder.unref();
const reportLine = ${JSON.stringify(reportLine)};
process.stdout.write(reportLine.slice(0, ${splitIndex}), () => {
setImmediate(() => {
process.stdout.write(reportLine.slice(${splitIndex}), () => {
process.stderr.write(${JSON.stringify(`${stderrMarker}\n`)}, () => {
process.exit(process.exitCode ?? 0);
});
});
});
});
`;
const wrapper = spawn(
process.execPath,
['--input-type=commonjs', '-e', wrapperSource],
{
stdio: ['ignore', 'pipe', 'pipe', 'pipe'],
windowsHide: true,
},
);
const session = createInteractiveCliSession(wrapper);
const originalKill = wrapper.kill.bind(wrapper);
let killCallCount = 0;
wrapper.kill = (...args) => {
killCallCount += 1;
return originalKill(...args);
};
let controlStreamError = null;
wrapper.stdio[3].on('error', (error) => {
controlStreamError ??= error;
});
try {
await waitForInteractiveCliExit(session, 10_000);
assert(
session.exited && !session.stdioClosed,
'agent-runtime-real-e2e-self-test-interactive-cli-two-phase-not-observed',
);
const parsedReport =
await waitForSupervisorAutonomousPlayableCliExit(session);
await waitForInteractiveCliOutput(
session,
() => session.stderr.toString('utf8').includes(`${stderrMarker}\n`),
'agent-runtime-real-e2e-self-test-interactive-cli-output-timeout',
10_000,
{ allowAfterProcessExit: true },
);
assert(
JSON.stringify(canonicalJsonValue(parsedReport)) ===
JSON.stringify(canonicalJsonValue(expectedReport)),
'agent-runtime-real-e2e-self-test-interactive-cli-report-mismatch',
);
await closeInteractiveCli(session);
assert(
killCallCount === 0 && !session.stdioClosed,
'agent-runtime-real-e2e-self-test-interactive-cli-exit-cleanup-killed',
);
wrapper.stdio[3].end('CLOSE\n');
await waitForInteractiveCliStdioClose(session, 10_000);
assert(
controlStreamError === null &&
session.stdioClosed &&
projectPathScanner.count === 1,
'agent-runtime-real-e2e-self-test-interactive-cli-stdio-close-invalid',
);
return {
interactiveCliExitBeforeStdioCloseValidated: true,
interactiveCliPostExitReportValidated: true,
interactiveCliExitCleanupDidNotKillValidated: true,
interactiveCliStdioCloseAfterHolderReleaseValidated: true,
interactiveCliProjectPathScannerValidated: true,
};
} finally {
if (!wrapper.stdio[3].destroyed && !wrapper.stdio[3].writableEnded) {
wrapper.stdio[3].end('CLOSE\n');
}
if (!session.stdioClosed) {
await waitForInteractiveCliStdioClose(session, 10_000).catch(() => {
destroyInteractiveCliOutputStreams(session);
});
}
state.projectPathTranscriptScanner = previousProjectPathScanner;
}
}