diff --git a/CONTEXT.md b/CONTEXT.md
index 59acab2ff..f0d19df34 100644
--- a/CONTEXT.md
+++ b/CONTEXT.md
@@ -194,6 +194,14 @@ _Avoid_: 进度通知、快照轮询、第二套历史
把项目对话历史条目与运行态事件转换成消息气泡和工具卡片的读取期转换;不持久化,也不构成事实源。
_Avoid_: 投影缓存文件、已脱敏卡片库、第二套 reducer
+**项目对话输入**:
+AGC 项目对话的输入只有自然语言回合(含 `@` 素材引用与附件);需要动作时由 Runtime 工具与确认卡承接,不从输入文本解析控制词。
+_Avoid_: 斜杠命令、聊天命令草稿、命令发现列表
+
+**项目命令 id**:
+AGC 运行期工具与项目权限策略使用的稳定标识(`GAME_CREATION_APP_COMMANDS` 与 `GameCreationAppPermission`),由 Rust 运行期策略校验与 App 权限审计 / 项目前置条件判定消费,不是用户输入语法。
+_Avoid_: 把命令 id 当作可输入的聊天命令、为权限位补聊天入口
+
**引用候选**:
输入区可以命中的对象集合(`@` 素材、`$` Skill),由宿主按种类注入;输入区不判断候选属于哪一类。
_Avoid_: 输入区自己读项目清单或应用目录、把候选取值写死在组件里
diff --git a/apps/ai-game-creator-shell/package.json b/apps/ai-game-creator-shell/package.json
index 385f52277..c9c7a2d3a 100644
--- a/apps/ai-game-creator-shell/package.json
+++ b/apps/ai-game-creator-shell/package.json
@@ -15,20 +15,10 @@
"skill-pack:test": "node --test scripts/check-skill-pack.test.mjs",
"llm-status": "node scripts/run-cli-with-config.mjs --llm-status",
"agent-task": "node scripts/run-cli-with-config.mjs --agent-task",
- "chat": "node scripts/run-cli-with-config.mjs --swarm-chat",
- "swarm": "node scripts/run-cli-with-config.mjs --swarm-chat",
"config": "node scripts/game-creator-config-wizard.mjs",
- "test:chat": "node scripts/agent-swarm-test-chat.mjs --task \"制作一个可直接试玩的原创植物塔防小游戏:玩家选择并放置原创守卫阻挡敌人,完成波次后可以进入下一关并重新开始。主题、单位名称与视觉语言必须原创,不使用任何现有游戏角色、单位名、Logo 或受保护视觉语言。请自主完成正式产物、静态检查和双视口试玩验证。\" --no-open",
- "test:chat:manual": "node scripts/agent-swarm-test-chat.mjs",
"agent-run": "node scripts/run-cli-with-config.mjs --agent-run",
"agent-run:smoke": "node scripts/smoke-agent-run-local-provider.mjs",
"agent-runtime:real-e2e": "node scripts/agent-runtime-real-e2e.mjs",
- "agent-runtime:collaboration-policy-real-e2e": "node scripts/agent-runtime-real-e2e.mjs --suite supervisor-swarm-collaboration-policy-mixed-recovery",
- "agent-runtime:mixed-swarm-real-e2e": "node scripts/agent-runtime-real-e2e.mjs --suite supervisor-swarm-static-isolated-autonomous-chat",
- "agent-runtime:supervisor-swarm-autonomous-chat-real-e2e": "node scripts/agent-runtime-real-e2e.mjs --suite supervisor-swarm-autonomous-chat",
- "agent-runtime:supervisor-autonomous-playable-lane-defense-real-e2e": "node scripts/agent-runtime-real-e2e.mjs --suite supervisor-autonomous-playable-lane-defense",
- "agent-runtime:supervisor-autonomous-playable-lane-defense-deterministic-e2e": "node scripts/agent-runtime-deterministic-playable-e2e.mjs",
- "agent-runtime:supervisor-autonomous-playable-lane-defense-deterministic-self-test": "node scripts/agent-runtime-deterministic-playable-e2e.mjs --self-test",
"agent-runtime:supervisor-swarm-transient-retry-real-e2e": "node scripts/agent-runtime-real-e2e.mjs --suite supervisor-swarm-transient-retry",
"agent-runtime:supervisor-swarm-final-reply-transient-retry-real-e2e": "node scripts/agent-runtime-real-e2e.mjs --suite supervisor-swarm-final-reply-transient-retry",
"agent-runtime:supervisor-swarm-tool-plan-handoff-runner-kill-real-e2e": "node scripts/agent-runtime-real-e2e.mjs --suite supervisor-swarm-tool-plan-handoff-runner-kill",
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-deterministic-playable-e2e.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-deterministic-playable-e2e.mjs
deleted file mode 100644
index ef18c3780..000000000
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-deterministic-playable-e2e.mjs
+++ /dev/null
@@ -1,2030 +0,0 @@
-import { spawn } from 'node:child_process';
-import { createHash, randomUUID } from 'node:crypto';
-import fs from 'node:fs/promises';
-import os from 'node:os';
-import path from 'node:path';
-import { fileURLToPath } from 'node:url';
-
-import {
- createDeterministicLaneDefenseRouter,
- deterministicLaneDefenseCanonicalHtml,
- deterministicLaneDefenseInitialHtml,
- deterministicLaneDefenseModel,
- deterministicManifestReadyAgentIds,
- hiddenCanvasCss,
- startDeterministicLaneDefenseProvider,
- visibleCanvasCss,
-} from './deterministic-lane-defense-provider.mjs';
-import { withLoopbackNoProxy } from './llm-transient-fault-proxy.mjs';
-
-const appRoot = path.resolve(fileURLToPath(new URL('..', import.meta.url)));
-const repoRoot = path.resolve(appRoot, '../..');
-const realE2eScript = path.join(appRoot, 'scripts/agent-runtime-real-e2e.mjs');
-const suite = 'supervisor-autonomous-playable-lane-defense';
-const wrapperSuite =
- 'supervisor-autonomous-playable-lane-defense-deterministic';
-const configFileName = 'game-creator.config.json';
-const configSentinelName = '.deterministic-provider-e2e.json';
-const configSentinelSchema = 'genarrative-deterministic-provider-e2e-config.v1';
-const platformSessionFixtureEnv = 'GENARRATIVE_AGC_PLATFORM_SESSION_FIXTURE';
-const platformSessionFixtureName = '.deterministic-platform-session.json';
-const platformSessionFixtureSchema =
- 'genarrative-agc-platform-session-fixture.v1';
-const outputLimit = 32 * 1024 * 1024;
-
-function hashValue(value) {
- return createHash('sha256').update(value).digest('hex');
-}
-
-function assert(condition, code) {
- if (condition) return;
- const error = new Error(code);
- error.code = code;
- throw error;
-}
-
-function parseArguments(args) {
- let keepProject = false;
- let selfTest = false;
- for (const arg of args) {
- if (arg === '--keep-project') keepProject = true;
- else if (arg === '--self-test') selfTest = true;
- else throw new Error('unknown-argument');
- }
- assert(!(keepProject && selfTest), 'self-test-keep-project-conflict');
- return { keepProject, selfTest };
-}
-
-function deterministicRuntimeConfig(apiKey, provider) {
- return {
- agentMode: 'provider',
- editorApi: {
- apiKey,
- baseUrl: provider.editorBaseUrl,
- },
- llm: {
- apiKey,
- baseUrl: provider.baseUrl,
- model: deterministicLaneDefenseModel,
- apiKind: 'openai_chat',
- reasoningEffort: 'max',
- stream: false,
- requestTimeoutMs: 30_000,
- maxRetries: 0,
- retryBackoffMs: 100,
- },
- agentLlm: {
- 'project-supervisor': {
- reasoningEffort: 'max',
- },
- },
- };
-}
-
-function deterministicPlatformSessionFixture(apiKey, provider) {
- return {
- schemaVersion: platformSessionFixtureSchema,
- userId: 'deterministic-e2e-user',
- accessToken: apiKey,
- apiBaseUrl: provider.editorBaseUrl,
- generation: 1,
- };
-}
-
-function appendBounded(current, chunk) {
- const combined = Buffer.concat([current, chunk]);
- if (combined.length > outputLimit) throw new Error('child-output-too-large');
- return combined;
-}
-
-function runChild(args, environment) {
- return new Promise((resolve) => {
- const child = spawn(process.execPath, args, {
- cwd: appRoot,
- env: environment,
- stdio: ['ignore', 'pipe', 'pipe'],
- });
- let stdout = Buffer.alloc(0);
- let stderr = Buffer.alloc(0);
- let outputError = null;
- child.stdout.on('data', (chunk) => {
- try {
- stdout = appendBounded(stdout, chunk);
- } catch (error) {
- outputError = error;
- child.kill('SIGTERM');
- }
- });
- child.stderr.on('data', (chunk) => {
- try {
- stderr = appendBounded(stderr, chunk);
- } catch (error) {
- outputError = error;
- child.kill('SIGTERM');
- }
- });
- child.once('error', (error) =>
- resolve({ code: null, signal: null, error, stdout, stderr }),
- );
- child.once('close', (code, signal) =>
- resolve({ code, signal, error: outputError, stdout, stderr }),
- );
- });
-}
-
-function safeChildDiagnostic(result) {
- return {
- exitCode: Number.isInteger(result.code) ? result.code : null,
- signal: typeof result.signal === 'string' ? result.signal : null,
- errorCode:
- typeof result.error?.code === 'string' ? result.error.code : null,
- stdoutBytes: result.stdout.length,
- stdoutSha256: hashValue(result.stdout),
- stderrBytes: result.stderr.length,
- stderrSha256: hashValue(result.stderr),
- };
-}
-
-function parseChildReport(result) {
- try {
- const report = JSON.parse(result.stdout.toString('utf8'));
- assert(report && typeof report === 'object', 'child-report-root-invalid');
- return report;
- } catch (error) {
- if (error?.code) throw error;
- const wrapped = new Error('child-report-json-invalid');
- wrapped.code = 'child-report-json-invalid';
- throw wrapped;
- }
-}
-
-function expectedProviderStats(stats) {
- const manifestReadyTasks = manifestReadyTaskEvidence(stats);
- const projectSupervisorRuntimePlanningCount =
- Number.isInteger(stats.byAgent?.['project-supervisor']?.planning) &&
- Number.isInteger(stats.interactionExecuteCount)
- ? stats.byAgent['project-supervisor'].planning -
- stats.interactionExecuteCount
- : null;
- return (
- Number.isInteger(stats.requestCount) &&
- stats.requestCount >= 40 &&
- stats.planningRequestCount +
- stats.finalReplyRequestCount +
- (stats.contextCompactionRequestCount ?? 0) +
- (stats.imageInspectionRequestCount ?? 0) ===
- stats.requestCount &&
- stats.finalReplyRequestCount === 0 &&
- stats.interactionExecuteCount === 1 &&
- stats.goalContractCount === 1 &&
- stats.actionHistoryCount === 1 &&
- stats.acceptanceUpdateCount === 1 &&
- stats.delegateActionCount === 0 &&
- stats.runStatusCount >= 1 &&
- stats.sourceWriteCount >= 7 &&
- stats.staticSmokeCount >= 4 &&
- stats.previewValidationCount >= 2 &&
- manifestReadyTasks.exactlyOnce &&
- stats.manifestReadyTaskFileWriteCount >= 7 &&
- stats.manifestReadyTaskPreviewValidationCount >= 1 &&
- stats.manifestReadyTaskCanvasGenerationCount >=
- stats.canvasGenerationRequestCount &&
- stats.manifestReadyTaskCanvasGenerationCount <=
- stats.canvasGenerationRequestCount + 16 &&
- stats.imageInspectionRequestCount === 1 &&
- stats.canvasGenerationRequestCount === 3 &&
- stats.canvasDownloadRequestCount === 3 &&
- stats.canvasSliceDownloadRequestCount === 4 &&
- stats.canvasGeneratedAspectRatios?.['16:9'] === 1 &&
- stats.canvasGeneratedAspectRatios?.['1:1'] === 2 &&
- stats.canonicalCodeRunCount === 1 &&
- stats.canonicalCodeAssetListCount === 1 &&
- stats.unexpectedRequestCount === 0 &&
- Object.keys(stats.rejectionCodes ?? {}).length === 0 &&
- projectSupervisorRuntimePlanningCount >= 5 &&
- stats.byAgent?.['project-supervisor']?.finalReply === 0 &&
- stats.byAgent?.['project-supervisor']?.projectMutation === 0 &&
- stats.byAgent?.['code-prototype']?.planning >= 5 &&
- stats.byAgent?.['code-prototype']?.finalReply === 0 &&
- stats.byAgent?.['code-prototype']?.projectMutation === 1 &&
- stats.byAgent?.['quality-review']?.finalReply === 0 &&
- stats.byAgent?.['quality-review']?.projectMutation === 0
- );
-}
-
-function manifestReadyTaskEvidence(stats) {
- const rawCounts = stats?.readyTaskCountsByAgent;
- const byAgent =
- rawCounts && typeof rawCounts === 'object' && !Array.isArray(rawCounts)
- ? Object.fromEntries(
- Object.entries(rawCounts)
- .sort(([left], [right]) => left.localeCompare(right))
- .map(([agentId, counts]) => [
- agentId,
- {
- run: counts?.run ?? null,
- completion: counts?.completion ?? null,
- },
- ]),
- )
- : {};
- const actualAgentIds = Object.keys(byAgent);
- const expectedAgentIds = [...deterministicManifestReadyAgentIds].sort();
- const exactAgentSet =
- actualAgentIds.length === expectedAgentIds.length &&
- actualAgentIds.every(
- (agentId, index) => agentId === expectedAgentIds[index],
- );
- const runTotal = Object.values(byAgent).reduce(
- (total, counts) => total + (Number.isInteger(counts.run) ? counts.run : 0),
- 0,
- );
- const completionTotal = Object.values(byAgent).reduce(
- (total, counts) =>
- total + (Number.isInteger(counts.completion) ? counts.completion : 0),
- 0,
- );
- const perAgentExactlyOnce =
- exactAgentSet &&
- expectedAgentIds.every(
- (agentId) =>
- byAgent[agentId]?.run === 1 && byAgent[agentId]?.completion === 1,
- );
- return {
- expectedAgentIds,
- byAgent,
- runTotal,
- completionTotal,
- exactAgentSet,
- perAgentExactlyOnce,
- exactlyOnce:
- perAgentExactlyOnce &&
- runTotal === deterministicManifestReadyAgentIds.length &&
- completionTotal === deterministicManifestReadyAgentIds.length &&
- stats?.manifestReadyTaskRunCount ===
- deterministicManifestReadyAgentIds.length &&
- stats?.manifestReadyTaskCompletionCount ===
- deterministicManifestReadyAgentIds.length,
- };
-}
-
-const requiredZeroChildEvidenceFields = Object.freeze([
- 'activeRunnerKillCount',
- 'approveInputCount',
- 'answerInputCount',
- 'steerInputCount',
- 'turnReportWaitingForConfirmationCount',
- 'turnReportWaitingForUserInputCount',
- 'turnReportReconciliationAgentCount',
- 'providerLifecycleFailedCount',
- 'openProviderLifecycleCount',
- 'pendingActionCount',
- 'confirmationSidecarCount',
- 'userInputSidecarCount',
- 'providerActionBatchSidecarCount',
- 'providerRetrySidecarCount',
- 'providerHandoffSidecarCount',
- 'toolPlanHandoffSidecarCount',
- 'finalizationJournalCount',
- 'reconciliationResidueCount',
-]);
-
-function expectedChildReport(report, options, providerStats) {
- const evidence = report?.evidence;
- const providerRequestCount = providerStats?.requestCount;
- const runtimeProviderRequestCount =
- Number.isInteger(providerRequestCount) &&
- Number.isInteger(providerStats?.interactionExecuteCount) &&
- Number.isInteger(providerStats?.imageInspectionRequestCount)
- ? providerRequestCount -
- providerStats.interactionExecuteCount -
- providerStats.imageInspectionRequestCount
- : null;
- return (
- report?.status === 'PASS' &&
- report?.suite === suite &&
- report?.errorCount === 0 &&
- Array.isArray(report?.blocked) &&
- report.blocked.length === 0 &&
- report?.cleanup?.performed === !options.keepProject &&
- report?.cleanup?.kept === options.keepProject &&
- evidence?.evidenceCompleteness === 'complete' &&
- evidence?.dedicatedZeroInterventionPath === true &&
- evidence?.stdinTaskCount === 1 &&
- evidence?.stdinEndedAfterTask === true &&
- evidence?.turnReportOutcome === 'settled' &&
- evidence?.parentTaskStatus === 'completed' &&
- evidence?.parentRuntimeStatus === 'idle' &&
- evidence?.parentRuntimePhase === 'completed' &&
- evidence?.laneDefensePlaytestPassed === true &&
- evidence?.laneDefenseAssertionCount === 37 &&
- evidence?.laneDefensePassedAssertionCount === 37 &&
- evidence?.browserValidationPassed === true &&
- evidence?.staticSmokePassed === true &&
- evidence?.gameIndexChanged === true &&
- Number.isInteger(evidence?.projectRevisionDelta) &&
- evidence.projectRevisionDelta > 0 &&
- evidence?.finalSupervisorAssistantCount === 1 &&
- evidence?.professionalAssistantCount >= 3 &&
- evidence?.providerRequestIdentityCount === runtimeProviderRequestCount &&
- evidence?.providerLifecycleStartedCount === runtimeProviderRequestCount &&
- evidence?.providerLifecycleTerminalCount === runtimeProviderRequestCount &&
- evidence?.providerLifecycleCompletedCount === runtimeProviderRequestCount &&
- requiredZeroChildEvidenceFields.every((field) => evidence?.[field] === 0)
- );
-}
-
-function syntheticPayload(agentId, runId, tools, extraContext = '') {
- return {
- model: deterministicLaneDefenseModel,
- stream: false,
- messages: [
- {
- role: 'user',
- content: `- templateAgentId: ${agentId}\n- runId: ${runId}\n${extraContext}`,
- },
- ],
- tools: tools.map((name) => ({ type: 'function', function: { name } })),
- };
-}
-
-function syntheticInteractionExecutePayload() {
- return {
- model: deterministicLaneDefenseModel,
- stream: false,
- reasoning_effort: 'max',
- messages: [
- {
- role: 'system',
- content: '你现在位于统一的 Agent interaction loop。',
- },
- {
- role: 'user',
- content: '用户这轮输入:\n制作一个三消经营游戏',
- },
- ],
- tools: ['runtime_execute', 'runtime_resume', 'project_location'].map(
- (name) => ({ type: 'function', function: { name } }),
- ),
- };
-}
-
-function syntheticUiPrototypeInspectionPayload() {
- return {
- model: deterministicLaneDefenseModel,
- stream: false,
- messages: [
- {
- role: 'system',
- content: '你是游戏界面视觉检查 Agent。只分析画面。',
- },
- {
- role: 'user',
- content: [
- {
- type: 'text',
- text: '请逐项检查 informationHud、gameplaySurface、objectiveEntities、primaryControls、failureRestartFlow、responsiveLayout、implementationClarity、originalTheme,并只返回严格 JSON。',
- },
- {
- type: 'image_url',
- image_url: { url: 'data:image/png;base64,AA==' },
- },
- ],
- },
- ],
- };
-}
-
-function responseFunctionNames(response) {
- return response.choices[0].message.tool_calls.map(
- (call) => call.function.name,
- );
-}
-
-function responseFunctionCalls(response) {
- return response.choices[0].message.tool_calls.map((call) => ({
- name: call.function.name,
- arguments: JSON.parse(call.function.arguments),
- }));
-}
-
-async function runSelfTest() {
- const html = deterministicLaneDefenseInitialHtml();
- assert([...html].length <= 8_000, 'self-test-html-source-budget-invalid');
- assert(
- html.includes(hiddenCanvasCss) &&
- !html.includes(visibleCanvasCss) &&
- html.includes('playable-web-game-state.v1') &&
- html.includes('data-playtest-id="next-level"') &&
- html.includes('Goal: defend the garden and win every wave.') &&
- html.includes('requestAnimationFrame'),
- 'self-test-html-contract-invalid',
- );
- const canonicalHtml = deterministicLaneDefenseCanonicalHtml();
- assert(
- canonicalHtml.includes(visibleCanvasCss) &&
- canonicalHtml.includes("atlasArt.src='../assets/art-spritesheet.png'") &&
- [
- 'player.png',
- 'blocks-and-targets.png',
- 'obstacles-and-scene.png',
- 'feedback-effects.png',
- ].every((fileName) =>
- canonicalHtml.includes(`../assets/art-spritesheet-slices/${fileName}`),
- ) &&
- (canonicalHtml.match(/ctx\.drawImage\(/g) ?? []).length >= 5,
- 'self-test-canonical-visible-art-contract-invalid',
- );
- const apiKey = `deterministic-self-test-${randomUUID()}`;
- const runtimeConfig = deterministicRuntimeConfig(apiKey, {
- baseUrl: 'http://127.0.0.1:41001/v1',
- editorBaseUrl: 'http://127.0.0.1:41002',
- });
- assert(
- runtimeConfig.agentMode === 'provider' &&
- runtimeConfig.llm.apiKind === 'openai_chat' &&
- runtimeConfig.llm.reasoningEffort === 'max' &&
- runtimeConfig.agentLlm?.['project-supervisor']?.reasoningEffort ===
- 'max' &&
- runtimeConfig.llm.apiKey === apiKey &&
- runtimeConfig.editorApi.apiKey === apiKey,
- 'self-test-provider-runtime-config-invalid',
- );
- const captureProviderErrorCode = (operation) => {
- try {
- operation();
- return null;
- } catch (error) {
- return error?.code ?? null;
- }
- };
- const allTools = [
- 'update_agent_plan',
- 'respond_to_user',
- 'runtime_tool_agent_action_history',
- 'runtime_tool_agent_acceptance_update',
- 'runtime_tool_agent_run_status',
- 'runtime_tool_command_run_limited',
- 'runtime_tool_file_patch',
- 'runtime_tool_file_write',
- 'runtime_tool_preview_validate',
- 'runtime_tool_task_list',
- ];
- const manifestReadyTools = [
- ...allTools,
- 'runtime_tool_asset_list',
- 'runtime_tool_file_read',
- ];
- const rootRunId = 'parent-run';
- const contractFingerprint = 'a'.repeat(64);
- const contractContext = `[Root Goal Contract]\n${JSON.stringify({ contractFingerprint })}`;
- const observationContext = (observations) =>
- `${contractContext}\n已有工具观察:\n${JSON.stringify(observations)}`;
- const goalContractTools = ['runtime_tool_agent_goal_contract'];
- const goalContractRouter = createDeterministicLaneDefenseRouter({ apiKey });
- goalContractRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- 'project-supervisor',
- 'goal-contract-order-run',
- goalContractTools,
- ),
- });
- assert(
- captureProviderErrorCode(() =>
- goalContractRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- 'project-supervisor',
- 'goal-contract-order-run',
- goalContractTools,
- ),
- }),
- ) === 'provider-goal-contract-out-of-order',
- 'self-test-goal-contract-duplicate-not-rejected',
- );
-
- const router = createDeterministicLaneDefenseRouter({ apiKey });
- const route = (agentId, runId, tools = allTools, extraContext = '') =>
- router.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(agentId, runId, tools, extraContext),
- });
- const interactionExecuteResponse = router.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticInteractionExecutePayload(),
- });
- const interactionExecuteCalls = responseFunctionCalls(
- interactionExecuteResponse,
- );
- const interactionExecuteStats = router.getStats();
- assert(
- interactionExecuteCalls.length === 1 &&
- interactionExecuteCalls[0]?.name === 'runtime_execute' &&
- Object.keys(interactionExecuteCalls[0]?.arguments ?? {}).length === 0 &&
- interactionExecuteStats.requestCount === 1 &&
- interactionExecuteStats.planningRequestCount === 1 &&
- interactionExecuteStats.interactionExecuteCount === 1 &&
- interactionExecuteStats.manifestReadyTaskRunCount === 0 &&
- interactionExecuteStats.manifestReadyTaskCompletionCount === 0 &&
- Object.keys(interactionExecuteStats.readyTaskCountsByAgent).length === 0,
- 'self-test-interaction-max-execute-sequence-invalid',
- );
- const visualInspectionResponse = router.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticUiPrototypeInspectionPayload(),
- });
- const visualInspection = JSON.parse(
- visualInspectionResponse.choices[0].message.content,
- );
- assert(
- Object.keys(visualInspection?.checks ?? {}).join(',') ===
- 'informationHud,gameplaySurface,objectiveEntities,primaryControls,failureRestartFlow,responsiveLayout,implementationClarity,originalTheme' &&
- Object.values(visualInspection.checks).every((value) => value === true) &&
- Array.isArray(visualInspection.issues) &&
- visualInspection.issues.length === 0 &&
- router.getStats().imageInspectionRequestCount === 1 &&
- router.getStats().unexpectedRequestCount === 0,
- 'self-test-ui-prototype-inspection-request-not-routed',
- );
- const goalContractResponse = route(
- 'project-supervisor',
- rootRunId,
- goalContractTools,
- );
- const goalContractCalls = responseFunctionCalls(goalContractResponse);
- const acceptanceNodes =
- goalContractCalls[0]?.arguments?.input?.acceptanceNodes ?? [];
- assert(
- goalContractCalls.length === 1 &&
- goalContractCalls[0]?.name === 'runtime_tool_agent_goal_contract' &&
- goalContractCalls[0]?.arguments?.input?.outcome?.includes(
- '可完整游玩的原创植物塔防网页游戏',
- ) &&
- acceptanceNodes.length === 2 &&
- acceptanceNodes[0]?.criterionId === 'static-current-revision' &&
- JSON.stringify(acceptanceNodes[0]?.requiredEvidence) ===
- JSON.stringify(['tool:command.run_limited']) &&
- acceptanceNodes[1]?.criterionId === 'playable-current-revision' &&
- JSON.stringify(acceptanceNodes[1]?.requiredEvidence) ===
- JSON.stringify(['tool:preview.validate']) &&
- JSON.stringify(acceptanceNodes[1]?.dependsOn) ===
- JSON.stringify(['static-current-revision']),
- 'self-test-goal-contract-invalid',
- );
- assert(
- responseFunctionNames(
- route(
- 'project-supervisor',
- rootRunId,
- ['runtime_tool_task_list', 'runtime_tool_agent_run_status'],
- `${contractContext}\n当前正式 manifest DAG 仍有专业 task 在运行`,
- ),
- ).join(',') === 'runtime_tool_task_list,runtime_tool_agent_run_status',
- 'self-test-manifest-wait-invalid',
- );
-
- const visualReadyAgentIds = new Set([
- 'art-director',
- 'design-foundation',
- 'art-asset-plan',
- ]);
- const canvasCallsByAgent = new Map();
- const callBatchesByAgent = new Map();
- for (const agentId of deterministicManifestReadyAgentIds) {
- const runId = `manifest-ready-${agentId}`;
- const extraContext =
- `处理 manifest ready 任务:${agentId}\n` + `任务 ID:${agentId}`;
- const readyTools = visualReadyAgentIds.has(agentId)
- ? [
- ...manifestReadyTools,
- 'runtime_tool_canvas_asset_generate',
- 'runtime_tool_image_inspect',
- ]
- : manifestReadyTools;
- let terminalCompletionCount = 0;
- for (let attempt = 0; attempt < 8; attempt += 1) {
- const attemptTools =
- agentId === 'art-director' && attempt >= 2
- ? ['respond_to_user']
- : readyTools;
- const response = route(agentId, runId, attemptTools, extraContext);
- const calls = responseFunctionCalls(response);
- const batches = callBatchesByAgent.get(agentId) ?? [];
- batches.push(calls.map((call) => call.name));
- callBatchesByAgent.set(agentId, batches);
- const canvasCall = calls.find(
- (call) => call.name === 'runtime_tool_canvas_asset_generate',
- );
- if (canvasCall) {
- assert(
- !canvasCallsByAgent.has(agentId),
- `self-test-canvas-generation-duplicate:${agentId}`,
- );
- canvasCallsByAgent.set(agentId, canvasCall);
- }
- if (calls.some((call) => call.name === 'respond_to_user')) {
- terminalCompletionCount += 1;
- break;
- }
- }
- assert(
- terminalCompletionCount === 1,
- `self-test-manifest-ready-terminal-invalid:${agentId}`,
- );
- }
- const artDirectorAssetCall = canvasCallsByAgent.get('art-director');
- const designFoundationAssetCall = canvasCallsByAgent.get('design-foundation');
- const artAssetPlanAssetCall = canvasCallsByAgent.get('art-asset-plan');
- assert(
- JSON.stringify(callBatchesByAgent.get('art-asset-plan')) ===
- JSON.stringify([
- ['runtime_tool_asset_list'],
- ['runtime_tool_file_write'],
- ['runtime_tool_canvas_asset_generate'],
- ['runtime_tool_file_read', 'runtime_tool_asset_list'],
- ['update_agent_plan', 'respond_to_user'],
- ]),
- 'self-test-art-asset-plan-revision-stages-invalid',
- );
- assert(
- JSON.stringify(callBatchesByAgent.get('code-prototype')) ===
- JSON.stringify([
- [
- 'runtime_tool_file_read',
- 'runtime_tool_file_read',
- 'runtime_tool_file_read',
- ],
- [
- 'runtime_tool_file_read',
- 'runtime_tool_file_read',
- 'runtime_tool_file_read',
- 'runtime_tool_asset_list',
- ],
- ['runtime_tool_file_write'],
- ['runtime_tool_command_run_limited'],
- ['update_agent_plan', 'respond_to_user'],
- ]),
- 'self-test-code-prototype-asset-audit-sequence-invalid',
- );
- assert(
- canvasCallsByAgent.size === 3 &&
- artDirectorAssetCall?.arguments?.input?.outputPath ===
- 'assets/art-spec.png' &&
- artDirectorAssetCall.arguments.input.aspectRatio === '1:1' &&
- artDirectorAssetCall.arguments.input.assetKind === 'icon-spec' &&
- designFoundationAssetCall?.arguments?.input?.outputPath ===
- 'assets/ui-prototype.png' &&
- designFoundationAssetCall.arguments.input.aspectRatio === '16:9' &&
- designFoundationAssetCall.arguments.input.assetKind === 'ui-design' &&
- artAssetPlanAssetCall?.arguments?.input?.outputPath ===
- 'assets/art-spritesheet.png' &&
- artAssetPlanAssetCall.arguments.input.aspectRatio === '1:1' &&
- artAssetPlanAssetCall.arguments.input.assetKind === 'icon-spritesheet',
- 'self-test-visual-assets-invalid',
- );
-
- const visualRecoveryRouter = createDeterministicLaneDefenseRouter({ apiKey });
- const visualRecoveryRunId = 'visual-recovery-design-foundation';
- const visualRecoveryTools = [
- ...manifestReadyTools,
- 'runtime_tool_canvas_asset_generate',
- 'runtime_tool_image_inspect',
- ];
- const visualRecoveryRoute = (
- tools = visualRecoveryTools,
- extraContext = '',
- ) =>
- visualRecoveryRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- 'design-foundation',
- visualRecoveryRunId,
- tools,
- `处理 manifest ready 任务:design-foundation\n任务 ID:design-foundation${extraContext}`,
- ),
- });
- visualRecoveryRoute();
- visualRecoveryRoute();
- const visualRecoveryCanvasResponse = visualRecoveryRoute();
- const visualRecoveryInitialInspectResponse = visualRecoveryRoute();
- assert(
- responseFunctionNames(visualRecoveryCanvasResponse).join(',') ===
- 'runtime_tool_canvas_asset_generate' &&
- responseFunctionNames(visualRecoveryInitialInspectResponse).includes(
- 'runtime_tool_image_inspect',
- ),
- 'self-test-ui-prototype-initial-inspection-sequence-invalid',
- );
- const failedInspectObservation = {
- tool: 'image.inspect',
- status: 'failed',
- summary: '视觉模型调用失败',
- detail: 'upstream-422',
- };
- const prematureCompletionResponse = visualRecoveryRoute(
- ['update_agent_plan', 'respond_to_user'],
- `\n已有工具观察:\n${JSON.stringify([failedInspectObservation])}`,
- );
- assert(
- responseFunctionNames(prematureCompletionResponse).includes(
- 'respond_to_user',
- ),
- 'self-test-ui-prototype-premature-completion-fixture-invalid',
- );
- const visualBlockedObservation = {
- tool: 'runtime.visual_asset',
- status: 'blocked',
- summary: 'UI 原型视觉检查尚未通过',
- detail:
- 'expectedPath=assets/ui-prototype.png · requiredInspection=image.inspect',
- };
- const blockedRetryResponse = visualRecoveryRoute(
- visualRecoveryTools,
- `\n已有工具观察:\n${JSON.stringify([visualBlockedObservation])}`,
- );
- assert(
- responseFunctionNames(blockedRetryResponse).join(',') ===
- 'runtime_tool_image_inspect',
- 'self-test-ui-prototype-visual-block-did-not-retry-inspection',
- );
- const failedRetryResponse = visualRecoveryRoute(
- visualRecoveryTools,
- `\n已有工具观察:\n${JSON.stringify([failedInspectObservation])}`,
- );
- assert(
- responseFunctionNames(failedRetryResponse).join(',') ===
- 'runtime_tool_image_inspect',
- 'self-test-ui-prototype-failed-inspection-did-not-retry',
- );
- const successfulInspectObservation = {
- tool: 'image.inspect',
- status: 'ok',
- summary: '视觉检查已完成,共分析 1 张图片',
- detail: null,
- };
- const visualRecoveryFinalResponse = visualRecoveryRoute(
- ['update_agent_plan', 'respond_to_user'],
- `\n已有工具观察:\n${JSON.stringify([successfulInspectObservation])}`,
- );
- const visualRecoveryStats = visualRecoveryRouter.getStats();
- assert(
- responseFunctionNames(visualRecoveryFinalResponse).includes(
- 'respond_to_user',
- ) &&
- visualRecoveryStats.manifestReadyTaskRunCount === 1 &&
- visualRecoveryStats.manifestReadyTaskCompletionCount === 1 &&
- visualRecoveryStats.manifestReadyTaskCanvasGenerationCount === 1 &&
- visualRecoveryStats.byAgent?.['design-foundation']?.projectMutation ===
- 3 &&
- visualRecoveryStats.unexpectedRequestCount === 0,
- 'self-test-ui-prototype-visual-recovery-not-exactly-once',
- );
-
- const finalStaticResponse = route(
- 'project-supervisor',
- rootRunId,
- ['runtime_tool_command_run_limited'],
- `${contractContext}\n已有工具观察:\nseedTaskCounts: completed=16 running=0 pending=0 waiting=0 failed=0 total=16`,
- );
- assert(
- responseFunctionNames(finalStaticResponse).join(',') ===
- 'runtime_tool_command_run_limited',
- 'self-test-final-static-not-exclusive',
- );
- const successfulFinalStaticObservation = {
- tool: 'command.run_limited',
- status: 'ok',
- summary: 'game.static_smoke 已完成',
- detail: null,
- };
- const finalPreviewResponse = route(
- 'project-supervisor',
- rootRunId,
- ['runtime_tool_preview_validate'],
- observationContext([successfulFinalStaticObservation]),
- );
- assert(
- responseFunctionNames(finalPreviewResponse).join(',') ===
- 'runtime_tool_preview_validate',
- 'self-test-final-preview-not-exclusive',
- );
- const successfulFinalPreviewObservation = {
- tool: 'preview.validate',
- status: 'ok',
- summary: '桌面与移动视口真实试玩已通过',
- detail: null,
- };
- const finalHistoryResponse = route(
- 'project-supervisor',
- rootRunId,
- ['runtime_tool_agent_action_history'],
- observationContext([successfulFinalPreviewObservation]),
- );
- const finalHistoryCalls = responseFunctionCalls(finalHistoryResponse);
- assert(
- finalHistoryCalls.length === 1 &&
- finalHistoryCalls[0]?.name === 'runtime_tool_agent_action_history' &&
- JSON.stringify(finalHistoryCalls[0]?.arguments?.input) ===
- JSON.stringify({
- runId: null,
- actionId: null,
- tool: null,
- status: 'ok',
- limit: 10,
- }),
- 'self-test-final-action-history-invalid',
- );
- const staticActionId = `action-${'1'.repeat(24)}`;
- const previewActionId = `action-${'2'.repeat(24)}`;
- const actionHistoryDetail = JSON.stringify({
- runId: rootRunId,
- count: 2,
- truncated: false,
- outputTruncated: false,
- actions: [
- {
- agentId: 'project-supervisor',
- runId: rootRunId,
- actionId: staticActionId,
- tool: 'command.run_limited',
- status: 'ok',
- },
- {
- agentId: 'project-supervisor',
- runId: rootRunId,
- actionId: previewActionId,
- tool: 'preview.validate',
- status: 'ok',
- },
- ],
- });
- const finalAcceptanceResponse = route(
- 'project-supervisor',
- rootRunId,
- ['runtime_tool_agent_acceptance_update'],
- observationContext([
- {
- tool: 'agent.action_history',
- status: 'ok',
- summary: '已读取当前 Agent 的 2 条终态动作',
- detail: actionHistoryDetail,
- },
- ]),
- );
- const finalAcceptanceCalls = responseFunctionCalls(finalAcceptanceResponse);
- const acceptanceInput = finalAcceptanceCalls[0]?.arguments?.input;
- assert(
- finalAcceptanceCalls.length === 1 &&
- finalAcceptanceCalls[0]?.name ===
- 'runtime_tool_agent_acceptance_update' &&
- acceptanceInput?.contractFingerprint === contractFingerprint &&
- acceptanceInput?.evaluations?.length === 2 &&
- acceptanceInput.evaluations[0]?.criterionId ===
- 'static-current-revision' &&
- acceptanceInput.evaluations[0]?.evidence?.[0]?.actionId ===
- staticActionId &&
- acceptanceInput.evaluations[1]?.criterionId ===
- 'playable-current-revision' &&
- acceptanceInput.evaluations[1]?.evidence?.[0]?.actionId ===
- previewActionId,
- 'self-test-final-acceptance-update-invalid',
- );
- const finalRespondResponse = route(
- 'project-supervisor',
- rootRunId,
- ['respond_to_user'],
- observationContext([
- {
- tool: 'agent.acceptance_update',
- status: 'ok',
- summary: 'Acceptance Graph 已更新',
- detail: null,
- },
- ]),
- );
- assert(
- responseFunctionNames(finalRespondResponse).join(',') === 'respond_to_user',
- 'self-test-final-respond-not-exclusive',
- );
-
- const planRejectionRouter = createDeterministicLaneDefenseRouter({ apiKey });
- planRejectionRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- 'project-supervisor',
- 'plan-rejection-run',
- goalContractTools,
- ),
- });
- const planRejectionResponse = planRejectionRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- 'project-supervisor',
- 'plan-rejection-run',
- ['respond_to_user', 'runtime_tool_file_patch', 'runtime_tool_file_write'],
- '当前父 run 已进入只编排模式;本轮只允许收束或安全编排。',
- ),
- });
- const planRejectionWaitResponse = planRejectionRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- 'project-supervisor',
- 'plan-rejection-run',
- ['runtime_tool_task_list', 'runtime_tool_agent_run_status'],
- '当前正式 manifest DAG 仍有专业 task 在运行',
- ),
- });
- const planRejectionStats = planRejectionRouter.getStats();
- assert(
- responseFunctionNames(planRejectionResponse).join(',') ===
- 'respond_to_user' &&
- responseFunctionNames(planRejectionWaitResponse).join(',') ===
- 'runtime_tool_task_list,runtime_tool_agent_run_status' &&
- planRejectionStats.byAgent?.['project-supervisor']?.projectMutation ===
- 0 &&
- planRejectionStats.delegateActionCount === 0 &&
- planRejectionStats.runStatusCount === 1 &&
- planRejectionStats.unexpectedRequestCount === 0,
- 'self-test-supervisor-plan-rejection-did-not-converge-read-only',
- );
-
- const earlyFinalReplyRouter = createDeterministicLaneDefenseRouter({
- apiKey,
- });
- assert(
- captureProviderErrorCode(() =>
- earlyFinalReplyRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- 'project-supervisor',
- 'early-final-reply-run',
- [],
- '给用户一个正常中文回复',
- ),
- }),
- ) === 'provider-parent-final-reply-before-acceptance',
- 'self-test-parent-final-reply-bypassed-acceptance',
- );
-
- const acceptanceGuardRunId = 'acceptance-guard-run';
- const acceptanceGuardRouter = createDeterministicLaneDefenseRouter({
- apiKey,
- });
- const acceptanceGuardRoute = (tools, extraContext = '') =>
- acceptanceGuardRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- 'project-supervisor',
- acceptanceGuardRunId,
- tools,
- extraContext,
- ),
- });
- acceptanceGuardRoute(goalContractTools);
- acceptanceGuardRoute(
- ['runtime_tool_command_run_limited'],
- `${contractContext}\n已有工具观察:\nseedTaskCounts: completed=16 running=0 pending=0 waiting=0 failed=0 total=16`,
- );
- acceptanceGuardRoute(
- ['runtime_tool_preview_validate'],
- observationContext([successfulFinalStaticObservation]),
- );
- acceptanceGuardRoute(
- ['runtime_tool_agent_action_history'],
- observationContext([successfulFinalPreviewObservation]),
- );
- const acceptanceGuardDetail = JSON.parse(actionHistoryDetail);
- acceptanceGuardDetail.runId = acceptanceGuardRunId;
- for (const action of acceptanceGuardDetail.actions) {
- action.runId = acceptanceGuardRunId;
- }
- const actionHistoryObservationFor = (detail) => ({
- tool: 'agent.action_history',
- status: 'ok',
- summary: '已读取当前 Agent 的 2 条终态动作',
- detail: JSON.stringify(detail),
- });
- const ambiguousContractContext = `[Root Goal Contract]\n{"contractFingerprint":"${contractFingerprint}","nested":{"contractFingerprint":"${'b'.repeat(64)}"}}`;
- assert(
- captureProviderErrorCode(() =>
- acceptanceGuardRoute(
- ['runtime_tool_agent_acceptance_update'],
- `${ambiguousContractContext}\n已有工具观察:\n${JSON.stringify([
- actionHistoryObservationFor(acceptanceGuardDetail),
- ])}`,
- ),
- ) === 'provider-goal-contract-fingerprint-missing',
- 'self-test-ambiguous-goal-contract-fingerprint-accepted',
- );
- const invalidActionHistoryDetail = structuredClone(acceptanceGuardDetail);
- invalidActionHistoryDetail.actions[0].actionId = 'action-invalid';
- assert(
- captureProviderErrorCode(() =>
- acceptanceGuardRoute(
- ['runtime_tool_agent_acceptance_update'],
- `${contractContext}\n已有工具观察:\n${JSON.stringify([
- actionHistoryObservationFor(invalidActionHistoryDetail),
- ])}`,
- ),
- ) === 'provider-final-acceptance-evidence-missing',
- 'self-test-invalid-action-history-id-accepted',
- );
- assert(
- responseFunctionNames(
- acceptanceGuardRoute(
- ['runtime_tool_agent_acceptance_update'],
- `${contractContext}\n已有工具观察:\n${JSON.stringify([
- actionHistoryObservationFor(acceptanceGuardDetail),
- ])}`,
- ),
- ).join(',') === 'runtime_tool_agent_acceptance_update',
- 'self-test-acceptance-stage-advanced-after-rejected-history',
- );
-
- const stats = router.getStats();
- const manifestReadyTasks = manifestReadyTaskEvidence(stats);
- assert(
- manifestReadyTasks.exactlyOnce &&
- stats.goalContractCount === 1 &&
- stats.actionHistoryCount === 1 &&
- stats.acceptanceUpdateCount === 1 &&
- stats.interactionExecuteCount === 1 &&
- stats.delegateActionCount === 0 &&
- stats.imageInspectionRequestCount === 1 &&
- stats.manifestReadyTaskCanvasGenerationCount === 3 &&
- stats.byAgent?.['project-supervisor']?.projectMutation === 0 &&
- stats.byAgent?.['code-prototype']?.projectMutation === 1 &&
- stats.byAgent?.['quality-review']?.projectMutation === 0,
- 'self-test-manifest-ready-exactly-once-invalid',
- );
-
- const missingReadyTaskStats = structuredClone(stats);
- const missingAgentId = deterministicManifestReadyAgentIds.at(-1);
- delete missingReadyTaskStats.readyTaskCountsByAgent[missingAgentId];
- missingReadyTaskStats.manifestReadyTaskRunCount -= 1;
- missingReadyTaskStats.manifestReadyTaskCompletionCount -= 1;
- assert(
- !manifestReadyTaskEvidence(missingReadyTaskStats).exactlyOnce,
- 'self-test-manifest-ready-missing-accepted',
- );
-
- const duplicateReadyTaskStats = structuredClone(stats);
- const duplicateAgentId = deterministicManifestReadyAgentIds[0];
- duplicateReadyTaskStats.readyTaskCountsByAgent[duplicateAgentId].completion +=
- 1;
- duplicateReadyTaskStats.manifestReadyTaskCompletionCount += 1;
- assert(
- !manifestReadyTaskEvidence(duplicateReadyTaskStats).exactlyOnce,
- 'self-test-manifest-ready-duplicate-accepted',
- );
-
- const retryObservationContext = (observations) =>
- `\n已有工具观察:\n${JSON.stringify(observations)}`;
- const staleObservation = {
- tool: 'runtime.verification',
- status: 'blocked',
- summary: '最终回复生成期间项目 revision 已变化',
- detail: 'responseRevision=1, currentRevision=2',
- };
- const successfulSmokeObservation = {
- tool: 'command.run_limited',
- status: 'ok',
- summary: 'game.static_smoke 已完成',
- detail: null,
- };
- const blockedSmokeObservation = {
- tool: 'command.run_limited',
- status: 'blocked',
- summary: '仓库规范或启动上下文已漂移,旧动作未执行',
- detail:
- 'repositoryContextDrift=true · 请在同一 run 下一轮 planning 重新确认适用规范',
- };
- const projectLockSmokeObservations = [
- {
- tool: 'command.run_limited',
- status: 'failed',
- summary: 'game.static_smoke 无法取得项目验证锁',
- detail: '项目正在被其他写操作占用:$PROJECT_ROOT/.agent/project.lock',
- },
- {
- tool: 'command.run_limited',
- status: 'failed',
- summary: 'game.static_smoke 无法取得项目验证锁',
- detail: '项目正在被其他写操作占用:$PROJECT_ROOT\\.agent\\project.lock',
- },
- ];
- const projectRevisionDriftSmokeObservation = {
- tool: 'command.run_limited',
- status: 'blocked',
- summary: '并行项目变更使旧动作过期,旧动作未执行',
- detail:
- 'projectRevisionDrift=true · expectedRevision=4 · currentRevision=5 · replanRequired=true',
- };
- const projectRevisionDriftCanvasObservation = {
- tool: 'canvas.asset_generate',
- status: 'blocked',
- summary: '并行项目变更使旧动作过期,旧动作未执行',
- detail:
- 'projectRevisionDrift=true · expectedRevision=5 · currentRevision=6 · replanRequired=true',
- };
- const successfulProjectMutationObservation = {
- tool: 'project.patchset',
- status: 'ok',
- summary: 'project.patchset 已原子应用 2 项变更',
- detail: 'checkpointId=checkpoint-concurrent-ready-batch',
- };
- const missingArtAssetObservation = {
- tool: 'runtime.visual_asset',
- status: 'blocked',
- summary: '首版美术素材图尚未按正式视觉流程生成并登记,不能完成任务',
- detail: '[redacted sensitive context]',
- };
- const successfulCanvasMutationObservation = {
- tool: 'canvas.asset_generate',
- status: 'ok',
- summary: '素材画布图片已生成并登记',
- detail: null,
- };
-
- const artAssetRecoveryAgentId = 'art-asset-plan';
- const artAssetRecoveryRunId = 'art-asset-visual-recovery-ready-run';
- const artAssetRecoveryTools = [
- ...manifestReadyTools,
- 'runtime_tool_canvas_asset_generate',
- ];
- const artAssetRecoveryRouter = createDeterministicLaneDefenseRouter({
- apiKey,
- });
- const artAssetRecoveryRoute = (extraContext = '') =>
- artAssetRecoveryRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- artAssetRecoveryAgentId,
- artAssetRecoveryRunId,
- artAssetRecoveryTools,
- `处理 manifest ready 任务:${artAssetRecoveryAgentId}\n任务 ID:${artAssetRecoveryAgentId}${extraContext}`,
- ),
- });
- for (let attempt = 0; attempt < 8; attempt += 1) {
- if (
- responseFunctionNames(artAssetRecoveryRoute()).includes('respond_to_user')
- ) {
- break;
- }
- }
- const artAssetRegenerationResponse = artAssetRecoveryRoute(
- retryObservationContext([missingArtAssetObservation]),
- );
- const artAssetReverificationResponse = artAssetRecoveryRoute(
- retryObservationContext([successfulCanvasMutationObservation]),
- );
- const artAssetRefinalizationResponse = artAssetRecoveryRoute(
- retryObservationContext([successfulSmokeObservation]),
- );
- const artAssetRecoveryStats = artAssetRecoveryRouter.getStats();
- assert(
- responseFunctionNames(artAssetRegenerationResponse).join(',') ===
- 'runtime_tool_canvas_asset_generate' &&
- responseFunctionNames(artAssetReverificationResponse).join(',') ===
- 'runtime_tool_command_run_limited' &&
- responseFunctionNames(artAssetRefinalizationResponse).includes(
- 'respond_to_user',
- ) &&
- artAssetRecoveryStats.readyTaskCountsByAgent[artAssetRecoveryAgentId]
- ?.completion === 1 &&
- artAssetRecoveryStats.manifestReadyTaskCanvasGenerationCount === 2 &&
- artAssetRecoveryStats.unexpectedRequestCount === 0,
- 'self-test-art-asset-visual-recovery-not-exactly-once',
- );
-
- const artAssetRevisionDriftRunId = 'art-asset-revision-drift-ready-run';
- const artAssetRevisionDriftRouter = createDeterministicLaneDefenseRouter({
- apiKey,
- });
- const artAssetRevisionDriftRoute = (extraContext = '') =>
- artAssetRevisionDriftRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- artAssetRecoveryAgentId,
- artAssetRevisionDriftRunId,
- artAssetRecoveryTools,
- `处理 manifest ready 任务:${artAssetRecoveryAgentId}\n任务 ID:${artAssetRecoveryAgentId}${extraContext}`,
- ),
- });
- const artAssetInitialListResponse = artAssetRevisionDriftRoute();
- const artAssetManifestWriteResponse = artAssetRevisionDriftRoute();
- const artAssetInitialCanvasResponse = artAssetRevisionDriftRoute();
- const artAssetRetryCanvasResponse = artAssetRevisionDriftRoute(
- retryObservationContext([projectRevisionDriftCanvasObservation]),
- );
- const artAssetPostRetryReadResponse = artAssetRevisionDriftRoute(
- retryObservationContext([successfulCanvasMutationObservation]),
- );
- const artAssetRevisionDriftFinalizationResponse =
- artAssetRevisionDriftRoute();
- const artAssetRevisionDriftStats = artAssetRevisionDriftRouter.getStats();
- assert(
- responseFunctionNames(artAssetInitialListResponse).join(',') ===
- 'runtime_tool_asset_list' &&
- responseFunctionNames(artAssetManifestWriteResponse).join(',') ===
- 'runtime_tool_file_write' &&
- responseFunctionNames(artAssetInitialCanvasResponse).join(',') ===
- 'runtime_tool_canvas_asset_generate' &&
- responseFunctionNames(artAssetRetryCanvasResponse).join(',') ===
- 'runtime_tool_canvas_asset_generate' &&
- responseFunctionNames(artAssetPostRetryReadResponse).join(',') ===
- 'runtime_tool_file_read,runtime_tool_asset_list' &&
- responseFunctionNames(artAssetRevisionDriftFinalizationResponse).includes(
- 'respond_to_user',
- ) &&
- artAssetRevisionDriftStats.readyTaskCountsByAgent[artAssetRecoveryAgentId]
- ?.run === 1 &&
- artAssetRevisionDriftStats.readyTaskCountsByAgent[artAssetRecoveryAgentId]
- ?.completion === 1 &&
- artAssetRevisionDriftStats.manifestReadyTaskCanvasGenerationCount === 2 &&
- artAssetRevisionDriftStats.unexpectedRequestCount === 0,
- 'self-test-art-asset-revision-drift-recovery-not-exactly-once',
- );
-
- const artAssetRevisionDriftLimitRunId =
- 'art-asset-revision-drift-limit-ready-run';
- const artAssetRevisionDriftLimitRouter = createDeterministicLaneDefenseRouter(
- { apiKey },
- );
- const artAssetRevisionDriftLimitRoute = (extraContext = '') =>
- artAssetRevisionDriftLimitRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- artAssetRecoveryAgentId,
- artAssetRevisionDriftLimitRunId,
- artAssetRecoveryTools,
- `处理 manifest ready 任务:${artAssetRecoveryAgentId}\n任务 ID:${artAssetRecoveryAgentId}${extraContext}`,
- ),
- });
- artAssetRevisionDriftLimitRoute();
- artAssetRevisionDriftLimitRoute();
- artAssetRevisionDriftLimitRoute();
- for (let retry = 0; retry < 16; retry += 1) {
- assert(
- responseFunctionNames(
- artAssetRevisionDriftLimitRoute(
- retryObservationContext([projectRevisionDriftCanvasObservation]),
- ),
- ).join(',') === 'runtime_tool_canvas_asset_generate',
- `self-test-art-asset-revision-drift-retry-invalid:${retry}`,
- );
- }
- const artAssetRevisionDriftLimitCode = captureProviderErrorCode(() =>
- artAssetRevisionDriftLimitRoute(
- retryObservationContext([projectRevisionDriftCanvasObservation]),
- ),
- );
- const artAssetRevisionDriftLimitStats =
- artAssetRevisionDriftLimitRouter.getStats();
- assert(
- artAssetRevisionDriftLimitCode ===
- 'provider-ready-art-canvas-retry-exhausted' &&
- artAssetRevisionDriftLimitStats.readyTaskCountsByAgent[
- artAssetRecoveryAgentId
- ]?.run === 1 &&
- artAssetRevisionDriftLimitStats.readyTaskCountsByAgent[
- artAssetRecoveryAgentId
- ]?.completion === 0 &&
- artAssetRevisionDriftLimitStats.manifestReadyTaskCanvasGenerationCount ===
- 17,
- 'self-test-art-asset-revision-drift-limit-invalid',
- );
-
- const readOnlyCommandRouter = createDeterministicLaneDefenseRouter({
- apiKey,
- });
- const readOnlyCommandRunId = 'read-only-command-only-ready-run';
- const readOnlyCommandRoute = (tools) =>
- readOnlyCommandRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- 'quality-review',
- readOnlyCommandRunId,
- tools,
- '处理 manifest ready 任务:quality-review\n任务 ID:quality-review',
- ),
- });
- readOnlyCommandRoute(manifestReadyTools);
- readOnlyCommandRoute(manifestReadyTools);
- const readOnlyCommandCode = captureProviderErrorCode(() =>
- readOnlyCommandRoute(['runtime_tool_command_run_limited']),
- );
- const readOnlyCommandStats = readOnlyCommandRouter.getStats();
- assert(
- readOnlyCommandCode ===
- 'provider-ready-finalization-tools-invalid:quality-review:runtime_tool_command_run_limited' &&
- readOnlyCommandStats.readyTaskCountsByAgent['quality-review']
- ?.completion === 0 &&
- readOnlyCommandStats.manifestReadyTaskStaticSmokeCount === 0,
- 'self-test-read-only-command-only-not-rejected',
- );
-
- const preCompletionRouter = createDeterministicLaneDefenseRouter({ apiKey });
- const preCompletionAgentId = 'preview-readiness';
- const preCompletionRunId = 'pre-completion-transient-ready-run';
- const preCompletionRoute = (tools, extraContext = '') =>
- preCompletionRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- preCompletionAgentId,
- preCompletionRunId,
- tools,
- `处理 manifest ready 任务:${preCompletionAgentId}\n任务 ID:${preCompletionAgentId}${extraContext}`,
- ),
- });
- preCompletionRoute(manifestReadyTools);
- for (let retry = 0; retry < 16; retry += 1) {
- assert(
- responseFunctionNames(
- preCompletionRoute(
- ['runtime_tool_command_run_limited'],
- retryObservationContext([blockedSmokeObservation]),
- ),
- ).join(',') === 'runtime_tool_command_run_limited',
- `self-test-ready-precompletion-transient-invalid:${retry}`,
- );
- }
- const preCompletionLimitCode = captureProviderErrorCode(() =>
- preCompletionRoute(
- ['runtime_tool_command_run_limited'],
- retryObservationContext([blockedSmokeObservation]),
- ),
- );
- const preCompletionStats = preCompletionRouter.getStats();
- assert(
- preCompletionLimitCode ===
- `provider-ready-precompletion-verification-exhausted:${preCompletionAgentId}` &&
- preCompletionStats.readyTaskCountsByAgent[preCompletionAgentId]
- ?.completion === 0 &&
- preCompletionStats.manifestReadyTaskStaticSmokeCount === 17,
- 'self-test-ready-precompletion-limit-invalid',
- );
-
- const projectLockRouter = createDeterministicLaneDefenseRouter({ apiKey });
- const projectLockRunId = 'project-lock-transient-ready-run';
- const projectLockRoute = (tools, extraContext = '') =>
- projectLockRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- preCompletionAgentId,
- projectLockRunId,
- tools,
- `处理 manifest ready 任务:${preCompletionAgentId}\n任务 ID:${preCompletionAgentId}${extraContext}`,
- ),
- });
- projectLockRoute(manifestReadyTools);
- for (const observation of projectLockSmokeObservations) {
- assert(
- responseFunctionNames(
- projectLockRoute(
- ['runtime_tool_command_run_limited'],
- retryObservationContext([observation]),
- ),
- ).join(',') === 'runtime_tool_command_run_limited',
- 'self-test-ready-project-lock-path-separator-not-retried',
- );
- }
-
- const duplicateRouter = createDeterministicLaneDefenseRouter({ apiKey });
- const duplicateRoute = (runId, extraContext = '') =>
- duplicateRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- duplicateAgentId,
- runId,
- manifestReadyTools,
- `处理 manifest ready 任务:${duplicateAgentId}\n任务 ID:${duplicateAgentId}${extraContext}`,
- ),
- });
- duplicateRoute('duplicate-ready-run');
- duplicateRoute('duplicate-ready-run');
- let duplicateTerminalCode = null;
- try {
- duplicateRoute('duplicate-ready-run');
- } catch (error) {
- duplicateTerminalCode = error?.code ?? null;
- }
- let duplicateRunCode = null;
- try {
- duplicateRoute('second-ready-run');
- } catch (error) {
- duplicateRunCode = error?.code ?? null;
- }
- assert(
- duplicateTerminalCode ===
- `provider-ready-run-terminal-duplicate:${duplicateAgentId}` &&
- duplicateRunCode ===
- `provider-ready-agent-run-duplicate:${duplicateAgentId}`,
- 'self-test-manifest-ready-provider-duplicate-not-rejected',
- );
-
- const retryAgentId = 'preview-readiness';
- const retryRunId = 'retry-ready-run';
- const retryRouter = createDeterministicLaneDefenseRouter({ apiKey });
- const retryRoute = (extraContext = '') =>
- retryRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- retryAgentId,
- retryRunId,
- manifestReadyTools,
- `处理 manifest ready 任务:${retryAgentId}\n任务 ID:${retryAgentId}${extraContext}`,
- ),
- });
- for (let attempt = 0; attempt < 8; attempt += 1) {
- if (responseFunctionNames(retryRoute()).includes('respond_to_user')) break;
- }
- for (let retry = 0; retry < 16; retry += 1) {
- assert(
- responseFunctionNames(
- retryRoute(retryObservationContext([staleObservation])),
- ).join(',') === 'runtime_tool_command_run_limited',
- `self-test-ready-retry-verification-call-invalid:${retry}`,
- );
- if (retry === 0) {
- let missingObservationCode = null;
- try {
- retryRoute();
- } catch (error) {
- missingObservationCode = error?.code ?? null;
- }
- assert(
- missingObservationCode ===
- `provider-ready-retry-verification-invalid:${retryAgentId}`,
- 'self-test-ready-retry-missing-observation-accepted',
- );
- }
- assert(
- responseFunctionNames(
- retryRoute(retryObservationContext([successfulSmokeObservation])),
- ).includes('respond_to_user'),
- `self-test-ready-retry-finalization-invalid:${retry}`,
- );
- }
- let retryLimitCode = null;
- try {
- retryRoute(retryObservationContext([staleObservation]));
- } catch (error) {
- retryLimitCode = error?.code ?? null;
- }
- const retryStats = retryRouter.getStats();
- assert(
- retryLimitCode ===
- `provider-ready-run-terminal-duplicate:${retryAgentId}` &&
- retryStats.readyTaskCountsByAgent[retryAgentId]?.run === 1 &&
- retryStats.readyTaskCountsByAgent[retryAgentId]?.completion === 1,
- 'self-test-ready-retry-limit-or-exactly-once-invalid',
- );
-
- const verifiedDeliveryRepairRouter = createDeterministicLaneDefenseRouter({
- apiKey,
- });
- const verifiedDeliveryRepairRunId = 'verified-delivery-repair-ready-run';
- const verifiedDeliveryRepairRoute = (tools, extraContext = '') =>
- verifiedDeliveryRepairRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- retryAgentId,
- verifiedDeliveryRepairRunId,
- tools,
- `处理 manifest ready 任务:${retryAgentId}\n任务 ID:${retryAgentId}${extraContext}`,
- ),
- });
- for (let attempt = 0; attempt < 8; attempt += 1) {
- if (
- responseFunctionNames(
- verifiedDeliveryRepairRoute(manifestReadyTools),
- ).includes('respond_to_user')
- ) {
- break;
- }
- }
- const rejectedVerificationPlan = verifiedDeliveryRepairRoute(
- manifestReadyTools,
- retryObservationContext([staleObservation]),
- );
- const verifiedDeliveryRepairResponse = verifiedDeliveryRepairRoute(
- ['respond_to_user'],
- `${retryObservationContext([staleObservation])}\n上一条输出不符合工具计划协议:当前 revision 已通过验证。本次修复的原生工具目录只保留 respond_to_user;必须立即调用它交付专业合同结论。`,
- );
- const verifiedDeliveryRepairStats = verifiedDeliveryRepairRouter.getStats();
- assert(
- responseFunctionNames(rejectedVerificationPlan).join(',') ===
- 'runtime_tool_command_run_limited' &&
- responseFunctionNames(verifiedDeliveryRepairResponse).join(',') ===
- 'respond_to_user' &&
- verifiedDeliveryRepairStats.readyTaskCountsByAgent[retryAgentId]
- ?.completion === 1 &&
- verifiedDeliveryRepairStats.unexpectedRequestCount === 0,
- 'self-test-ready-verified-delivery-repair-invalid',
- );
-
- const transientRetryRouter = createDeterministicLaneDefenseRouter({ apiKey });
- const transientRetryRunId = 'transient-retry-ready-run';
- const transientRetryRoute = (extraContext = '') =>
- transientRetryRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- retryAgentId,
- transientRetryRunId,
- manifestReadyTools,
- `处理 manifest ready 任务:${retryAgentId}\n任务 ID:${retryAgentId}${extraContext}`,
- ),
- });
- for (let attempt = 0; attempt < 8; attempt += 1) {
- if (
- responseFunctionNames(transientRetryRoute()).includes('respond_to_user')
- ) {
- break;
- }
- }
- transientRetryRoute(retryObservationContext([staleObservation]));
- assert(
- responseFunctionNames(
- transientRetryRoute(retryObservationContext([blockedSmokeObservation])),
- ).join(',') === 'runtime_tool_command_run_limited' &&
- responseFunctionNames(
- transientRetryRoute(
- retryObservationContext([successfulSmokeObservation]),
- ),
- ).includes('respond_to_user') &&
- transientRetryRouter.getStats().readyTaskCountsByAgent[retryAgentId]
- ?.completion === 1,
- 'self-test-ready-transient-verification-retry-invalid',
- );
-
- const standaloneRetryAgentId = 'design-foundation';
- const standaloneRetryRunId = 'standalone-retry-ready-run';
- const standaloneRetryRouter = createDeterministicLaneDefenseRouter({
- apiKey,
- });
- const standaloneRetryRoute = (extraContext = '') =>
- standaloneRetryRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- standaloneRetryAgentId,
- standaloneRetryRunId,
- manifestReadyTools,
- `处理 manifest ready 任务:${standaloneRetryAgentId}\n任务 ID:${standaloneRetryAgentId}${extraContext}`,
- ),
- });
- for (let attempt = 0; attempt < 8; attempt += 1) {
- if (
- responseFunctionNames(standaloneRetryRoute()).includes('respond_to_user')
- ) {
- break;
- }
- }
- const standaloneReplayResponse = standaloneRetryRoute(
- retryObservationContext([successfulSmokeObservation]),
- );
- const standaloneReplayDuplicateCode = captureProviderErrorCode(() =>
- standaloneRetryRoute(retryObservationContext([successfulSmokeObservation])),
- );
- assert(
- responseFunctionNames(standaloneReplayResponse).includes(
- 'respond_to_user',
- ) &&
- standaloneReplayDuplicateCode ===
- `provider-ready-run-terminal-duplicate:${standaloneRetryAgentId}` &&
- standaloneRetryRouter.getStats().readyTaskCountsByAgent[
- standaloneRetryAgentId
- ]?.completion === 1,
- 'self-test-ready-standalone-verification-replay-invalid',
- );
-
- const concurrentMutationAgentId = 'design-foundation';
- const concurrentMutationRunId = 'concurrent-mutation-ready-run';
- const concurrentMutationRouter = createDeterministicLaneDefenseRouter({
- apiKey,
- });
- const concurrentMutationRoute = (extraContext = '') =>
- concurrentMutationRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- concurrentMutationAgentId,
- concurrentMutationRunId,
- manifestReadyTools,
- `处理 manifest ready 任务:${concurrentMutationAgentId}\n任务 ID:${concurrentMutationAgentId}${extraContext}`,
- ),
- });
- for (let attempt = 0; attempt < 8; attempt += 1) {
- if (
- responseFunctionNames(concurrentMutationRoute()).includes(
- 'respond_to_user',
- )
- ) {
- break;
- }
- }
- assert(
- responseFunctionNames(
- concurrentMutationRoute(
- retryObservationContext([successfulProjectMutationObservation]),
- ),
- ).join(',') === 'runtime_tool_command_run_limited' &&
- responseFunctionNames(
- concurrentMutationRoute(
- retryObservationContext([successfulSmokeObservation]),
- ),
- ).includes('respond_to_user') &&
- concurrentMutationRouter.getStats().readyTaskCountsByAgent[
- concurrentMutationAgentId
- ]?.completion === 1,
- 'self-test-ready-concurrent-mutation-reverification-invalid',
- );
-
- const repairedWriterAgentId = 'balance-seed';
- const repairedWriterRunId = 'repaired-writer-ready-run';
- const repairedWriterRouter = createDeterministicLaneDefenseRouter({ apiKey });
- const repairedWriterRoute = (tools = manifestReadyTools, extraContext = '') =>
- repairedWriterRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- repairedWriterAgentId,
- repairedWriterRunId,
- tools,
- `处理 manifest ready 任务:${repairedWriterAgentId}\n任务 ID:${repairedWriterAgentId}${extraContext}`,
- ),
- });
- for (let attempt = 0; attempt < 8; attempt += 1) {
- if (
- responseFunctionNames(repairedWriterRoute()).includes('respond_to_user')
- ) {
- break;
- }
- }
- const repairedWriterMutation = repairedWriterRoute(
- ['runtime_tool_file_write'],
- retryObservationContext([successfulSmokeObservation]),
- );
- const repairedWriterVerification = repairedWriterRoute(
- manifestReadyTools,
- retryObservationContext([successfulProjectMutationObservation]),
- );
- const repairedWriterFinalization = repairedWriterRoute(
- manifestReadyTools,
- retryObservationContext([successfulSmokeObservation]),
- );
- const repairedWriterDuplicateCode = captureProviderErrorCode(() =>
- repairedWriterRoute(
- manifestReadyTools,
- retryObservationContext([successfulSmokeObservation]),
- ),
- );
- assert(
- responseFunctionNames(repairedWriterMutation).join(',') ===
- 'runtime_tool_file_write' &&
- responseFunctionNames(repairedWriterVerification).join(',') ===
- 'runtime_tool_command_run_limited' &&
- responseFunctionNames(repairedWriterFinalization).includes(
- 'respond_to_user',
- ) &&
- repairedWriterDuplicateCode ===
- `provider-ready-run-terminal-duplicate:${repairedWriterAgentId}` &&
- repairedWriterRouter.getStats().readyTaskCountsByAgent[
- repairedWriterAgentId
- ]?.completion === 1,
- 'self-test-ready-repaired-writer-reverification-invalid',
- );
-
- const projectRevisionDriftAgentId = 'preview-readiness';
- const projectRevisionDriftRunId = 'project-revision-drift-ready-run';
- const projectRevisionDriftRouter = createDeterministicLaneDefenseRouter({
- apiKey,
- });
- const projectRevisionDriftRoute = (extraContext = '') =>
- projectRevisionDriftRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- projectRevisionDriftAgentId,
- projectRevisionDriftRunId,
- manifestReadyTools,
- `处理 manifest ready 任务:${projectRevisionDriftAgentId}\n任务 ID:${projectRevisionDriftAgentId}${extraContext}`,
- ),
- });
- for (let attempt = 0; attempt < 8; attempt += 1) {
- if (
- responseFunctionNames(projectRevisionDriftRoute()).includes(
- 'respond_to_user',
- )
- ) {
- break;
- }
- }
- assert(
- responseFunctionNames(
- projectRevisionDriftRoute(
- retryObservationContext([projectRevisionDriftSmokeObservation]),
- ),
- ).join(',') === 'runtime_tool_command_run_limited' &&
- responseFunctionNames(
- projectRevisionDriftRoute(
- retryObservationContext([successfulSmokeObservation]),
- ),
- ).includes('respond_to_user') &&
- projectRevisionDriftRouter.getStats().readyTaskCountsByAgent[
- projectRevisionDriftAgentId
- ]?.completion === 1,
- 'self-test-ready-project-revision-drift-retry-invalid',
- );
-
- const readOnlyRetryAgentId = 'quality-review';
- const readOnlyRetryRunId = 'read-only-retry-ready-run';
- const readOnlyRetryRouter = createDeterministicLaneDefenseRouter({ apiKey });
- const readOnlyRetryRoute = (extraContext = '') =>
- readOnlyRetryRouter.route({
- authorization: `Bearer ${apiKey}`,
- payload: syntheticPayload(
- readOnlyRetryAgentId,
- readOnlyRetryRunId,
- manifestReadyTools,
- `处理 manifest ready 任务:${readOnlyRetryAgentId}\n任务 ID:${readOnlyRetryAgentId}${extraContext}`,
- ),
- });
- for (let attempt = 0; attempt < 8; attempt += 1) {
- if (
- responseFunctionNames(readOnlyRetryRoute()).includes('respond_to_user')
- ) {
- break;
- }
- }
- assert(
- responseFunctionNames(
- readOnlyRetryRoute(retryObservationContext([staleObservation])),
- ).includes('respond_to_user') &&
- readOnlyRetryRouter.getStats().manifestReadyTaskStaticSmokeCount === 0,
- 'self-test-read-only-retry-used-forbidden-verification',
- );
- assert(
- stats.goalContractCount === 1 &&
- stats.actionHistoryCount === 1 &&
- stats.acceptanceUpdateCount === 1 &&
- stats.delegateActionCount === 0 &&
- stats.manifestReadyTaskCanvasGenerationCount === 3 &&
- stats.byAgent?.['project-supervisor']?.projectMutation === 0 &&
- stats.byAgent?.['code-prototype']?.projectMutation === 1 &&
- stats.byAgent?.['quality-review']?.projectMutation === 0 &&
- stats.unexpectedRequestCount === 0,
- 'self-test-provider-core-stats-invalid',
- );
-
- const syntheticRuntimeProviderRequestCount =
- stats.requestCount -
- stats.interactionExecuteCount -
- stats.imageInspectionRequestCount;
-
- const syntheticChildReport = {
- status: 'PASS',
- suite,
- errorCount: 0,
- blocked: [],
- cleanup: { performed: true, kept: false },
- evidence: {
- ...Object.fromEntries(
- requiredZeroChildEvidenceFields.map((field) => [field, 0]),
- ),
- evidenceCompleteness: 'complete',
- dedicatedZeroInterventionPath: true,
- stdinTaskCount: 1,
- stdinEndedAfterTask: true,
- turnReportOutcome: 'settled',
- parentTaskStatus: 'completed',
- parentRuntimeStatus: 'idle',
- parentRuntimePhase: 'completed',
- laneDefensePlaytestPassed: true,
- laneDefenseAssertionCount: 37,
- laneDefensePassedAssertionCount: 37,
- browserValidationPassed: true,
- staticSmokePassed: true,
- gameIndexChanged: true,
- projectRevisionDelta: 2,
- finalSupervisorAssistantCount: 1,
- professionalAssistantCount: 3,
- providerRequestIdentityCount: syntheticRuntimeProviderRequestCount,
- providerLifecycleStartedCount: syntheticRuntimeProviderRequestCount,
- providerLifecycleTerminalCount: syntheticRuntimeProviderRequestCount,
- providerLifecycleCompletedCount: syntheticRuntimeProviderRequestCount,
- },
- };
- const incompletePlaytestReport = structuredClone(syntheticChildReport);
- incompletePlaytestReport.evidence.laneDefensePassedAssertionCount = 36;
- const manualInputReport = structuredClone(syntheticChildReport);
- manualInputReport.evidence.approveInputCount = 1;
- const residualSidecarReport = structuredClone(syntheticChildReport);
- residualSidecarReport.evidence.providerHandoffSidecarCount = 1;
- assert(
- expectedChildReport(syntheticChildReport, { keepProject: false }, stats) &&
- !expectedChildReport(
- incompletePlaytestReport,
- { keepProject: false },
- stats,
- ) &&
- !expectedChildReport(manualInputReport, { keepProject: false }, stats) &&
- !expectedChildReport(
- residualSidecarReport,
- { keepProject: false },
- stats,
- ),
- 'self-test-child-hard-gates-invalid',
- );
-
- const rootPackage = JSON.parse(
- await fs.readFile(path.join(repoRoot, 'package.json'), 'utf8'),
- );
- const shellPackage = JSON.parse(
- await fs.readFile(path.join(appRoot, 'package.json'), 'utf8'),
- );
- assert(
- shellPackage.scripts?.[
- 'agent-runtime:supervisor-autonomous-playable-lane-defense-deterministic-e2e'
- ] === 'node scripts/agent-runtime-deterministic-playable-e2e.mjs' &&
- rootPackage.scripts?.[
- 'ai-game-creator-shell:agent-runtime:supervisor-autonomous-playable-lane-defense-deterministic-e2e'
- ] ===
- 'npm --prefix apps/ai-game-creator-shell run agent-runtime:supervisor-autonomous-playable-lane-defense-deterministic-e2e --',
- 'self-test-package-command-invalid',
- );
- return {
- status: 'PASS',
- suite: `${wrapperSuite}-self-test`,
- providerUsed: false,
- htmlChars: [...html].length,
- providerStats: stats,
- manifestReadyTasks,
- manifestReadyFailureSamplesValidated: ['missing', 'duplicate'],
- manifestReadyProviderDuplicateRejections: {
- terminal: duplicateTerminalCode,
- run: duplicateRunCode,
- },
- terminalRetryContractsValidated: {
- readOnlyCommandOnlyRejected: true,
- preCompletionTransientRetryLimit: 16,
- projectLockPathSeparatorsRetried: ['/', '\\'],
- },
- providerRuntimeModeValidated: true,
- interactionExecutionValidated: {
- reasoningEffort: 'max',
- requestCount: stats.interactionExecuteCount,
- responseTools: interactionExecuteCalls.map((call) => call.name),
- readyTaskRunCountBeforeRuntime:
- interactionExecuteStats.manifestReadyTaskRunCount,
- readyTaskCompletionCountBeforeRuntime:
- interactionExecuteStats.manifestReadyTaskCompletionCount,
- },
- goalContractValidated: true,
- finalizationSequenceValidated: [
- 'command.run_limited',
- 'preview.validate',
- 'agent.action_history',
- 'agent.acceptance_update',
- 'respond_to_user',
- ],
- canvasArtifactsValidated: [
- 'assets/art-spec.png',
- 'assets/ui-prototype.png',
- 'assets/art-spritesheet.png',
- ],
- uiPrototypeInspectionValidated: true,
- uiPrototypeVisualRecoveryExactlyOnceValidated: true,
- artAssetVisualRecoveryExactlyOnceValidated: true,
- artAssetRevisionDriftRecoveryExactlyOnceValidated: true,
- artAssetRevisionDriftRetryLimitValidated: 16,
- supervisorPlanRejectionMode: 'respond-only-then-read-only-wait',
- childHardGatesValidated: true,
- packageCommandsRegistered: true,
- };
-}
-
-async function runE2e(options) {
- const token = randomUUID();
- const apiKey = `deterministic-runtime-${randomUUID()}`;
- const configDir = await fs.mkdtemp(
- path.join(os.tmpdir(), 'genarrative-deterministic-provider-config-'),
- );
- let provider = null;
- let childResult = null;
- let childReport = null;
- let configRemoved = false;
- let providerStats = null;
- let failureCode = null;
- try {
- if (process.platform !== 'win32') await fs.chmod(configDir, 0o700);
- await fs.writeFile(
- path.join(configDir, configSentinelName),
- `${JSON.stringify({ schemaVersion: configSentinelSchema, token })}\n`,
- { flag: 'wx', mode: 0o600 },
- );
- provider = await startDeterministicLaneDefenseProvider({ apiKey });
- const config = deterministicRuntimeConfig(apiKey, provider);
- const fixturePath = path.join(configDir, platformSessionFixtureName);
- await fs.writeFile(
- fixturePath,
- `${JSON.stringify(deterministicPlatformSessionFixture(apiKey, provider))}\n`,
- { flag: 'wx', mode: 0o600 },
- );
- await fs.writeFile(
- path.join(configDir, configFileName),
- `${JSON.stringify(config)}\n`,
- { flag: 'wx', mode: 0o600 },
- );
- const childArgs = [
- realE2eScript,
- '--suite',
- suite,
- '--config-dir',
- configDir,
- ];
- if (options.keepProject) childArgs.push('--keep-project');
- childResult = await runChild(
- childArgs,
- withLoopbackNoProxy({
- ...process.env,
- NO_COLOR: '1',
- [platformSessionFixtureEnv]: fixturePath,
- GENARRATIVE_AGC_DEBUG_PROVIDER_E2E: '1',
- }),
- );
- childReport = parseChildReport(childResult);
- } catch (error) {
- failureCode = error?.code ?? 'deterministic-e2e-unexpected-error';
- } finally {
- if (provider) {
- try {
- await provider.stop();
- providerStats = provider.getStats();
- } catch {
- failureCode ??= 'deterministic-provider-stop-failed';
- }
- }
- try {
- const sentinel = JSON.parse(
- await fs.readFile(path.join(configDir, configSentinelName), 'utf8'),
- );
- assert(
- sentinel.schemaVersion === configSentinelSchema &&
- sentinel.token === token,
- 'deterministic-config-sentinel-invalid',
- );
- await fs.rm(configDir, { recursive: true, force: false });
- configRemoved = true;
- } catch (error) {
- failureCode ??= error?.code ?? 'deterministic-config-cleanup-failed';
- }
- }
-
- const childPassed =
- childResult?.code === 0 &&
- childResult?.signal === null &&
- !childResult?.error &&
- expectedChildReport(childReport, options, providerStats);
- const providerPassed =
- providerStats?.stopped === true && expectedProviderStats(providerStats);
- const manifestReadyTasks = manifestReadyTaskEvidence(providerStats);
- const status =
- !failureCode && childPassed && providerPassed && configRemoved
- ? 'PASS'
- : 'FAIL';
- if (status !== 'PASS' && !failureCode) {
- failureCode = !childPassed
- ? 'deterministic-child-e2e-failed'
- : !providerPassed
- ? 'deterministic-provider-contract-failed'
- : 'deterministic-config-not-cleaned';
- }
- return {
- status,
- suite: wrapperSuite,
- providerMode: 'deterministic-loopback-openai-chat',
- delegatedSuite: suite,
- child: childReport,
- provider: providerStats,
- manifestReadyTasks,
- finalizationContract: {
- goalContractCount: providerStats?.goalContractCount ?? null,
- actionHistoryCount: providerStats?.actionHistoryCount ?? null,
- acceptanceUpdateCount: providerStats?.acceptanceUpdateCount ?? null,
- delegateActionCount: providerStats?.delegateActionCount ?? null,
- supervisorProjectMutationCount:
- providerStats?.byAgent?.['project-supervisor']?.projectMutation ?? null,
- },
- cleanup: {
- providerStopped: providerStats?.stopped === true,
- configRemoved,
- projectKept: options.keepProject,
- },
- childDiagnostic: childResult ? safeChildDiagnostic(childResult) : null,
- failureCode,
- };
-}
-
-const options = parseArguments(process.argv.slice(2));
-const report = options.selfTest ? await runSelfTest() : await runE2e(options);
-process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
-process.exitCode = report.status === 'PASS' ? 0 : 1;
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/assertions/core.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/assertions/core.mjs
index f91c928e8..e2e02ff7f 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/assertions/core.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/assertions/core.mjs
@@ -1,69 +1,8 @@
import { createHash } from '../dependencies.mjs';
import { isPlainObject } from '../harness/config.mjs';
-import {
- interactiveCliOutput,
- writeInteractiveCliLine,
-} from '../harness/process.mjs';
-import {
- shutdownWaiters,
- state,
- userInputAnswerText,
-} from '../runtime-state.mjs';
+import { shutdownWaiters, state } from '../runtime-state.mjs';
import { disposableProjectPathVariants } from './runtime.mjs';
-export async function answerRemainingInteractiveQuestions(session) {
- let answeredPromptCount = 1;
- const deadline = Date.now() + 60_000;
- while (Date.now() < deadline) {
- const output = interactiveCliOutput(session);
- if (output.includes(`[\u5df2\u56de\u7b54] ${state.userInput.requestId}`))
- return;
- const promptCount = output.split('或直接输入其他答案:').length - 1;
- while (answeredPromptCount < promptCount && answeredPromptCount < 3) {
- writeInteractiveCliLine(session, userInputAnswerText);
- answeredPromptCount += 1;
- }
- if (output.includes('[待确认]')) {
- throw codedError('user-input-unexpected-tool-confirmation');
- }
- if (session.closed) throw codedError('user-input-cli-closed-before-answer');
- await sleep(100);
- }
- throw codedError('user-input-answer-timeout');
-}
-
-export function parseSingleSwarmTurnReport(output, codePrefix) {
- const reportLines = output
- .split(/\r?\n/u)
- .filter((line) => line.startsWith('[turn.report] '));
- assert(reportLines.length === 1, `${codePrefix}-turn-report-count-invalid`);
- const report = JSON.parse(reportLines[0].slice('[turn.report] '.length));
- assert(
- isPlainObject(report) &&
- JSON.stringify(Object.keys(report).sort()) ===
- JSON.stringify(
- [
- 'schemaVersion',
- 'outcome',
- 'parentAgentId',
- 'sessionId',
- 'parentRunId',
- 'runtimeCount',
- 'busyRuntimeCount',
- 'pendingTaskCount',
- 'runningTaskCount',
- 'waitingForConfirmationCount',
- 'waitingForUserInputCount',
- 'newAssistantMessageCount',
- 'finalReplyChars',
- 'reconciliationAgentCount',
- ].sort(),
- ),
- `${codePrefix}-turn-report-shape-invalid`,
- );
- return report;
-}
-
export function isFailedTask(task) {
return (
['failed', 'cancelled', 'budget-exhausted'].includes(task.status) ||
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/assertions/runtime.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/assertions/runtime.mjs
index 4b49e89d9..ee48a17c4 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/assertions/runtime.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/assertions/runtime.mjs
@@ -2419,24 +2419,6 @@ export function finalMessageId(agentId, sessionId, runId) {
).slice(0, 32)}`;
}
-export function runtimePublicStatusMessageId(
- agentId,
- sessionId,
- runId,
- status,
-) {
- const correlationId = runtimeMessageCorrelationId(
- agentId,
- sessionId,
- runId,
- ).slice(0, 32);
- const statusFingerprint = createHash('sha256')
- .update(status)
- .digest('hex')
- .slice(0, 16);
- return `runtime-public-status-${correlationId}-${statusFingerprint}`;
-}
-
export function backgroundTaskMessageId(agentId, sessionId, runId, source) {
const fingerprint = createHash('sha256')
.update(`${agentId}\n${sessionId}\n${runId}\n${source}`)
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/entry.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/entry.mjs
index 8b20293b9..56c6f0231 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/entry.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/entry.mjs
@@ -20,15 +20,6 @@ import {
stopOwnedIsolatedRunner,
} from './harness/app-data.mjs';
import { loadConfig, parseArguments } from './harness/config.mjs';
-import {
- activeInteractiveCliSessions,
- captureOwnedProcessCleanupSnapshot,
- closeInteractiveCli,
- destroyInteractiveCliOutputStreams,
- interactiveCliOutput,
- verifyOwnedProcessCleanupSnapshot,
- waitForInteractiveCliStdioClose,
-} from './harness/process.mjs';
import { checkPrerequisites } from './harness/project.mjs';
import {
buildSummary,
@@ -48,8 +39,6 @@ import {
state,
steerInstruction,
StreamingSecretScanner,
- userInputAnswerCanary,
- userInputAnswerText,
} from './runtime-state.mjs';
import {
collectPartialContextCompactionEvidence,
@@ -101,29 +90,14 @@ import {
isSteerRunnerKillSuite,
runSteerRunnerKillE2e,
} from './suites/steer-runner-kill.mjs';
-import {
- collectPartialSupervisorAutonomousPlayableEvidence,
- emptySupervisorAutonomousPlayableEvidence,
- isSupervisorAutonomousPlayableLaneDefenseSuite,
- runSupervisorAutonomousPlayableLaneDefenseE2e,
-} from './suites/supervisor-autonomous-playable.mjs';
import {
collectPartialSupervisorSwarmEvidence,
emptySupervisorSwarmEvidence,
- isSupervisorSwarmInteractiveChatSuite,
isSupervisorSwarmSuite,
isSupervisorSwarmTransientRetrySuite,
- recordSupervisorSwarmChatSessionFailureDiagnostic,
runSupervisorSwarmE2e,
- supervisorSwarmChatSessionFailureEvidence,
supervisorSwarmToolPlanHandoffProxyNeedsCleanup,
} from './suites/supervisor-swarm.mjs';
-import {
- collectPartialUserInputEvidence,
- emptyUserInputEvidence,
- isUserInputRuntimeSuite,
- runUserInputRuntimeE2e,
-} from './suites/user-input.mjs';
import {
collectPartialWebSearchEvidence,
emptyWebSearchEvidence,
@@ -175,13 +149,9 @@ if (selfTestRequested) {
if (isContextCompactionSuite()) {
state.evidence = emptyContextCompactionEvidence();
}
- if (isUserInputRuntimeSuite()) state.evidence = emptyUserInputEvidence();
if (isScopedAgentsSuite()) state.evidence = emptyScopedAgentsEvidence();
if (isProjectSkillSuite()) state.evidence = emptyProjectSkillEvidence();
if (isParallelReadSuite()) state.evidence = emptyParallelReadEvidence();
- if (isSupervisorAutonomousPlayableLaneDefenseSuite()) {
- state.evidence = emptySupervisorAutonomousPlayableEvidence();
- }
if (isSupervisorSwarmSuite()) {
state.evidence = emptySupervisorSwarmEvidence();
}
@@ -192,11 +162,9 @@ if (selfTestRequested) {
if (
isWebSearchSuite() ||
isContextCompactionSuite() ||
- isUserInputRuntimeSuite() ||
isScopedAgentsSuite() ||
isProjectSkillSuite() ||
isParallelReadSuite() ||
- isSupervisorAutonomousPlayableLaneDefenseSuite() ||
isSupervisorSwarmSuite() ||
isSteerRunnerKillSuite()
) {
@@ -208,9 +176,8 @@ if (selfTestRequested) {
state.transcriptScanner = new StreamingSecretScanner(state.secrets);
state.config = await checkPrerequisites(loaded.config);
- const required = isSupervisorAutonomousPlayableLaneDefenseSuite()
- ? ['llmConfigured', 'chromeAvailable']
- : isProcessSessionSuite() || isIsolatedRunnerSuite()
+ const required =
+ isProcessSessionSuite() || isIsolatedRunnerSuite()
? ['llmConfigured']
: ['llmConfigured', 'chromeAvailable'];
if (state.suite === 'full') {
@@ -232,16 +199,12 @@ if (selfTestRequested) {
await runWebSearchE2e();
} else if (isContextCompactionSuite()) {
await runContextCompactionE2e();
- } else if (isUserInputRuntimeSuite()) {
- await runUserInputRuntimeE2e();
} else if (isScopedAgentsSuite()) {
await runScopedAgentsE2e();
} else if (isProjectSkillSuite()) {
await runProjectSkillE2e();
} else if (isParallelReadSuite()) {
await runParallelReadE2e();
- } else if (isSupervisorAutonomousPlayableLaneDefenseSuite()) {
- await runSupervisorAutonomousPlayableLaneDefenseE2e();
} else if (isSupervisorSwarmSuite()) {
await runSupervisorSwarmE2e();
} else if (isProcessSessionSuite()) {
@@ -262,107 +225,6 @@ if (selfTestRequested) {
recordError(error?.code ?? 'unexpected-error', error);
} finally {
state.cleanupInProgress = true;
- const stateTrackedInteractiveCliSessions = new Set(
- [
- state.userInputCliSession,
- state.supervisorAutonomousPlayableCliSession,
- state.supervisorSwarmCliSession,
- ].filter(Boolean),
- );
- const interactiveCliSessions = [
- ...new Set([
- ...stateTrackedInteractiveCliSessions,
- ...activeInteractiveCliSessions,
- ]),
- ];
- const supervisorAutonomousPlayableCliSession =
- state.supervisorAutonomousPlayableCliSession;
- if (isUserInputRuntimeSuite() && state.userInputCliSession) {
- try {
- await closeInteractiveCli(state.userInputCliSession);
- } catch (error) {
- state.status = 'FAIL';
- recordError('user-input-cli-cleanup-failed', error);
- }
- state.userInputCliSession = null;
- }
- if (
- isSupervisorAutonomousPlayableLaneDefenseSuite() &&
- state.supervisorAutonomousPlayableCliSession
- ) {
- try {
- await closeInteractiveCli(state.supervisorAutonomousPlayableCliSession);
- } catch (error) {
- state.status = 'FAIL';
- recordError('supervisor-autonomous-playable-cli-cleanup-failed', error);
- }
- state.supervisorAutonomousPlayableCliSession = null;
- }
- if (
- isSupervisorSwarmInteractiveChatSuite() &&
- state.supervisorSwarmCliSession
- ) {
- try {
- if (
- state.status !== 'PASS' &&
- state.supervisorSwarmCliSession.closed &&
- !state.supervisorSwarm.chatSessionFailureDiagnostic
- ) {
- recordSupervisorSwarmChatSessionFailureDiagnostic(
- state.supervisorSwarmCliSession,
- );
- }
- await closeInteractiveCli(state.supervisorSwarmCliSession);
- } catch (error) {
- state.status = 'FAIL';
- recordError(
- 'supervisor-swarm-autonomous-chat-cli-cleanup-failed',
- error,
- );
- }
- state.supervisorSwarmCliSession = null;
- }
- for (const session of interactiveCliSessions) {
- if (stateTrackedInteractiveCliSessions.has(session)) continue;
- try {
- await closeInteractiveCli(session);
- } catch (error) {
- state.status = 'FAIL';
- recordError('interactive-cli-cleanup-failed', error);
- }
- }
- if (
- isSupervisorAutonomousPlayableLaneDefenseSuite() &&
- state.isolatedRunner.appDataDir
- ) {
- try {
- const runnerPid = state.isolatedRunner.current?.pid ?? null;
- const helperPid =
- state.isolatedRunner.current?.killHandle?.child?.pid ?? null;
- state.supervisorAutonomousPlayable.ownedProcessCleanupSnapshot =
- await captureOwnedProcessCleanupSnapshot({
- runnerPid,
- helperPids: Number.isSafeInteger(helperPid) ? [helperPid] : [],
- rootPids: [
- ...interactiveCliSessions.map((session) => session.child?.pid),
- ...[...activeCommandChildren].map((child) => child.pid),
- ].filter((pid) => Number.isSafeInteger(pid) && pid > 0),
- });
- const observed =
- state.supervisorAutonomousPlayable.ownedProcessCleanupSnapshot
- .observedCounts;
- assert(
- observed.runner === 1 && observed.helper === 1,
- 'supervisor-autonomous-playable-owned-process-snapshot-incomplete',
- );
- } catch (error) {
- state.status = 'FAIL';
- recordError(
- 'supervisor-autonomous-playable-owned-process-snapshot-failed',
- error,
- );
- }
- }
if (isIsolatedRunnerSuite() && state.isolatedRunner.appDataDir) {
try {
await stopOwnedIsolatedRunner();
@@ -380,25 +242,6 @@ if (selfTestRequested) {
).catch(() => {});
}
}
- for (const session of interactiveCliSessions) {
- try {
- await waitForInteractiveCliStdioClose(session, 10_000);
- } catch (error) {
- destroyInteractiveCliOutputStreams(session);
- state.status = 'FAIL';
- recordError(
- error?.code === 'interactive-cli-stdio-close-timeout'
- ? error.code
- : 'interactive-cli-stdio-cleanup-failed',
- error,
- );
- }
- }
- if (supervisorAutonomousPlayableCliSession) {
- state.supervisorAutonomousPlayable.cliOutput = interactiveCliOutput(
- supervisorAutonomousPlayableCliSession,
- );
- }
if (isIsolatedRunnerSuite() && state.isolatedRunner.appDataDir) {
if (state.isolatedRunner.stopped) {
try {
@@ -500,28 +343,6 @@ if (selfTestRequested) {
state.status = 'FAIL';
recordError('web-search-formal-config-cli-call-detected');
}
- } else if (isUserInputRuntimeSuite()) {
- state.evidence.userInputRunnerStopped = state.isolatedRunner.stopped;
- state.evidence.userInputAppDataCleanupPerformed =
- state.isolatedRunner.cleanupPerformed;
- state.evidence.userInputRunnerKillMethod = killMethod;
- state.evidence.userInputRunnerPidfdClaimCount =
- state.isolatedRunner.pidfdClaimCount;
- state.evidence.userInputRunnerPidfdSignalCount =
- state.isolatedRunner.pidfdSignalCount;
- state.evidence.formalConfigCliCallCount =
- state.isolatedRunner.sourceConfigCliCallCount;
- state.evidence.sourceRunnerEndpointUnchanged =
- state.isolatedRunner.sourceRunnerEndpointUnchanged;
- state.evidence.sourceConfigHardlinkCount =
- state.isolatedRunner.configLinks.length;
- state.evidence.sourceConfigLinksVerified =
- state.isolatedRunner.sourceConfigLinksVerified;
- state.evidence.isolatedAppDataUsed = true;
- if (state.isolatedRunner.sourceConfigCliCallCount > 0) {
- state.status = 'FAIL';
- recordError('user-input-formal-config-cli-call-detected');
- }
} else if (isScopedAgentsSuite()) {
state.evidence.scopedAgentsRunnerStopped = state.isolatedRunner.stopped;
state.evidence.scopedAgentsAppDataCleanupPerformed =
@@ -588,28 +409,6 @@ if (selfTestRequested) {
state.status = 'FAIL';
recordError('parallel-read-formal-config-cli-call-detected');
}
- } else if (isSupervisorAutonomousPlayableLaneDefenseSuite()) {
- state.evidence.supervisorAutonomousPlayableRunnerStopped =
- state.isolatedRunner.stopped;
- state.evidence.supervisorAutonomousPlayableAppDataCleanupPerformed =
- state.isolatedRunner.cleanupPerformed;
- state.evidence.formalConfigCliCallCount =
- state.isolatedRunner.sourceConfigCliCallCount;
- state.evidence.sourceRunnerEndpointUnchanged =
- state.isolatedRunner.sourceRunnerEndpointUnchanged;
- state.evidence.sourceAppDataDirectoryUntouched =
- state.isolatedRunner.sourceAppDataDirectoryUntouched;
- state.evidence.sourceConfigReplicaCount =
- state.isolatedRunner.configLinks.length;
- state.evidence.sourceConfigReplicasVerified =
- state.isolatedRunner.sourceConfigLinksVerified;
- state.evidence.isolatedAppDataUsed = true;
- if (state.isolatedRunner.sourceConfigCliCallCount > 0) {
- state.status = 'FAIL';
- recordError(
- 'supervisor-autonomous-playable-formal-config-cli-call-detected',
- );
- }
} else if (isSupervisorSwarmSuite()) {
state.evidence.supervisorSwarmRunnerStopped =
state.isolatedRunner.stopped;
@@ -719,61 +518,6 @@ if (selfTestRequested) {
);
}
}
- if (
- isSupervisorAutonomousPlayableLaneDefenseSuite() &&
- state.isolatedRunner.appDataDir
- ) {
- const snapshot =
- state.supervisorAutonomousPlayable.ownedProcessCleanupSnapshot;
- if (snapshot) {
- try {
- const cleanup = await verifyOwnedProcessCleanupSnapshot(snapshot);
- state.evidence.ownedProcessIdentityCaptured = true;
- state.evidence.ownedRunnerObservedCount =
- snapshot.observedCounts.runner;
- state.evidence.ownedHelperObservedCount =
- snapshot.observedCounts.helper;
- state.evidence.ownedNodeDescendantObservedCount =
- snapshot.observedCounts.node;
- state.evidence.ownedBrowserDescendantObservedCount =
- snapshot.observedCounts.browser;
- state.evidence.ownedCommandDescendantObservedCount =
- snapshot.observedCounts.command;
- state.evidence.ownedRunnerResidualCount =
- cleanup.residualCounts.runner;
- state.evidence.ownedHelperResidualCount =
- cleanup.residualCounts.helper;
- state.evidence.ownedNodeDescendantResidualCount =
- cleanup.residualCounts.node;
- state.evidence.ownedBrowserDescendantResidualCount =
- cleanup.residualCounts.browser;
- state.evidence.ownedCommandDescendantResidualCount =
- cleanup.residualCounts.command;
- state.evidence.activeCommandChildrenAfterCleanup =
- cleanup.activeCommandChildCount;
- state.evidence.activeInteractiveCliSessionsAfterCleanup =
- cleanup.activeInteractiveCliSessionCount;
- state.evidence.ownedProcessCleanupPassed = cleanup.clean;
- if (!cleanup.clean) {
- state.status = 'FAIL';
- recordError(
- 'supervisor-autonomous-playable-owned-process-residual-detected',
- );
- }
- } catch (error) {
- state.status = 'FAIL';
- recordError(
- 'supervisor-autonomous-playable-owned-process-verification-failed',
- error,
- );
- }
- } else {
- state.status = 'FAIL';
- recordError(
- 'supervisor-autonomous-playable-owned-process-snapshot-missing',
- );
- }
- }
if (
isSteerRunnerKillSuite() &&
state.projectRoot &&
@@ -836,20 +580,6 @@ if (selfTestRequested) {
recordError('context-compaction-partial-evidence-read-failed', error);
}
}
- if (
- isUserInputRuntimeSuite() &&
- state.projectRoot &&
- state.status !== 'PASS'
- ) {
- try {
- state.evidence = {
- ...state.evidence,
- ...(await collectPartialUserInputEvidence()),
- };
- } catch (error) {
- recordError('user-input-partial-evidence-read-failed', error);
- }
- }
if (isScopedAgentsSuite() && state.projectRoot && state.status !== 'PASS') {
try {
state.evidence = {
@@ -880,24 +610,6 @@ if (selfTestRequested) {
recordError('parallel-read-partial-evidence-read-failed', error);
}
}
- if (
- isSupervisorAutonomousPlayableLaneDefenseSuite() &&
- state.projectRoot &&
- state.status !== 'PASS' &&
- state.evidence.evidenceCompleteness !== 'complete'
- ) {
- try {
- state.evidence = {
- ...state.evidence,
- ...(await collectPartialSupervisorAutonomousPlayableEvidence()),
- };
- } catch (error) {
- recordError(
- 'supervisor-autonomous-playable-partial-evidence-read-failed',
- error,
- );
- }
- }
if (
isSupervisorSwarmSuite() &&
state.projectRoot &&
@@ -1062,23 +774,6 @@ if (selfTestRequested) {
report = JSON.stringify(summary, null, 2);
}
}
- if (isUserInputRuntimeSuite()) {
- state.userInput.reportLeakCount = countExactSecrets(
- Buffer.from(report),
- [
- userInputAnswerCanary,
- userInputAnswerText,
- ...state.userInput.privateValues,
- ].filter(isNonEmptyString),
- );
- state.evidence.userInputReportLeakCount = state.userInput.reportLeakCount;
- if (state.userInput.reportLeakCount > 0) {
- state.status = 'FAIL';
- recordError('user-input-private-body-report-leak-detected');
- summary = buildSummary();
- report = JSON.stringify(summary, null, 2);
- }
- }
if (isScopedAgentsSuite()) {
state.scopedAgents.reportLeakCount = countExactSecrets(
Buffer.from(report),
@@ -1121,20 +816,6 @@ if (selfTestRequested) {
report = JSON.stringify(summary, null, 2);
}
}
- if (isSupervisorAutonomousPlayableLaneDefenseSuite()) {
- state.supervisorAutonomousPlayable.reportLeakCount = countExactSecrets(
- Buffer.from(report),
- state.supervisorAutonomousPlayable.privateValues,
- );
- state.evidence.supervisorAutonomousPlayableReportLeakCount =
- state.supervisorAutonomousPlayable.reportLeakCount;
- if (state.supervisorAutonomousPlayable.reportLeakCount > 0) {
- state.status = 'FAIL';
- recordError('supervisor-autonomous-playable-report-body-leak-detected');
- summary = buildSummary();
- report = JSON.stringify(summary, null, 2);
- }
- }
if (isSupervisorSwarmSuite()) {
state.supervisorSwarm.reportLeakCount = countExactSecrets(
Buffer.from(report),
@@ -1164,11 +845,9 @@ if (selfTestRequested) {
if (
isWebSearchSuite() ||
isContextCompactionSuite() ||
- isUserInputRuntimeSuite() ||
isScopedAgentsSuite() ||
isProjectSkillSuite() ||
isParallelReadSuite() ||
- isSupervisorAutonomousPlayableLaneDefenseSuite() ||
isSupervisorSwarmSuite() ||
isSteerRunnerKillSuite()
) {
@@ -1211,16 +890,6 @@ if (selfTestRequested) {
const remainingWebSearchReportLeakCount = isWebSearchSuite()
? countExactSecrets(Buffer.from(report), webSearchPrivateLeakValues())
: 0;
- const remainingUserInputReportLeakCount = isUserInputRuntimeSuite()
- ? countExactSecrets(
- Buffer.from(report),
- [
- userInputAnswerCanary,
- userInputAnswerText,
- ...state.userInput.privateValues,
- ].filter(isNonEmptyString),
- )
- : 0;
const remainingScopedAgentsReportLeakCount = isScopedAgentsSuite()
? countExactSecrets(Buffer.from(report), state.scopedAgents.privateValues)
: 0;
@@ -1230,13 +899,6 @@ if (selfTestRequested) {
const remainingParallelReadReportLeakCount = isParallelReadSuite()
? countExactSecrets(Buffer.from(report), state.parallelRead.privateValues)
: 0;
- const remainingSupervisorAutonomousPlayableReportLeakCount =
- isSupervisorAutonomousPlayableLaneDefenseSuite()
- ? countExactSecrets(
- Buffer.from(report),
- state.supervisorAutonomousPlayable.privateValues,
- )
- : 0;
const remainingSupervisorSwarmReportLeakCount = isSupervisorSwarmSuite()
? countExactSecrets(
Buffer.from(report),
@@ -1246,11 +908,9 @@ if (selfTestRequested) {
const remainingFormalConfigPathReportLeakCount =
isWebSearchSuite() ||
isContextCompactionSuite() ||
- isUserInputRuntimeSuite() ||
isScopedAgentsSuite() ||
isProjectSkillSuite() ||
isParallelReadSuite() ||
- isSupervisorAutonomousPlayableLaneDefenseSuite() ||
isSupervisorSwarmSuite() ||
isSteerRunnerKillSuite()
? countExactSecrets(Buffer.from(report), formalConfigPathVariants())
@@ -1259,11 +919,9 @@ if (selfTestRequested) {
remainingProjectPathReportLeakCount > 0 ||
remainingResponseStreamReportLeakCount > 0 ||
remainingWebSearchReportLeakCount > 0 ||
- remainingUserInputReportLeakCount > 0 ||
remainingScopedAgentsReportLeakCount > 0 ||
remainingProjectSkillReportLeakCount > 0 ||
remainingParallelReadReportLeakCount > 0 ||
- remainingSupervisorAutonomousPlayableReportLeakCount > 0 ||
remainingSupervisorSwarmReportLeakCount > 0 ||
remainingFormalConfigPathReportLeakCount > 0
) {
@@ -1273,21 +931,17 @@ if (selfTestRequested) {
? 'disposable-project-path-report-redaction-required'
: remainingResponseStreamReportLeakCount > 0
? 'response-stream-report-redaction-required'
- : remainingUserInputReportLeakCount > 0
- ? 'user-input-report-redaction-required'
- : remainingScopedAgentsReportLeakCount > 0
- ? 'scoped-agents-report-redaction-required'
- : remainingProjectSkillReportLeakCount > 0
- ? 'project-skill-report-redaction-required'
- : remainingParallelReadReportLeakCount > 0
- ? 'parallel-read-report-redaction-required'
- : remainingSupervisorAutonomousPlayableReportLeakCount > 0
- ? 'supervisor-autonomous-playable-report-redaction-required'
- : remainingSupervisorSwarmReportLeakCount > 0
- ? 'supervisor-swarm-report-redaction-required'
- : remainingFormalConfigPathReportLeakCount > 0
- ? 'formal-config-path-report-redaction-required'
- : 'web-search-report-redaction-required',
+ : remainingScopedAgentsReportLeakCount > 0
+ ? 'scoped-agents-report-redaction-required'
+ : remainingProjectSkillReportLeakCount > 0
+ ? 'project-skill-report-redaction-required'
+ : remainingParallelReadReportLeakCount > 0
+ ? 'parallel-read-report-redaction-required'
+ : remainingSupervisorSwarmReportLeakCount > 0
+ ? 'supervisor-swarm-report-redaction-required'
+ : remainingFormalConfigPathReportLeakCount > 0
+ ? 'formal-config-path-report-redaction-required'
+ : 'web-search-report-redaction-required',
);
const safeSummary = {
status: state.status,
@@ -1302,19 +956,13 @@ if (selfTestRequested) {
projectPathReportLeakCount: remainingProjectPathReportLeakCount,
responseStreamReportLeakCount: remainingResponseStreamReportLeakCount,
webSearchReportLeakCount: remainingWebSearchReportLeakCount,
- userInputReportLeakCount: remainingUserInputReportLeakCount,
scopedAgentsReportLeakCount: remainingScopedAgentsReportLeakCount,
projectSkillReportLeakCount: remainingProjectSkillReportLeakCount,
parallelReadReportLeakCount: remainingParallelReadReportLeakCount,
- supervisorAutonomousPlayableReportLeakCount:
- remainingSupervisorAutonomousPlayableReportLeakCount,
supervisorSwarmReportLeakCount:
remainingSupervisorSwarmReportLeakCount,
formalConfigPathReportLeakCount:
remainingFormalConfigPathReportLeakCount,
- ...(isSupervisorSwarmSuite()
- ? supervisorSwarmChatSessionFailureEvidence()
- : {}),
},
errorCount: state.errors.length,
errorHashes: state.errors.map(summarizeRecordedError),
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/app-data.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/app-data.mjs
index 3d8e052c6..c5ed62fa2 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/app-data.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/app-data.mjs
@@ -37,26 +37,16 @@ import {
state,
steerRunnerKillAppDataSentinelFileName,
steerRunnerKillAppDataSentinelSchema,
- supervisorAutonomousPlayableAppDataSentinelFileName,
- supervisorAutonomousPlayableAppDataSentinelSchema,
supervisorSwarmAppDataSentinelFileName,
supervisorSwarmAppDataSentinelSchema,
- supervisorSwarmAutonomousChatAppDataSentinelFileName,
- supervisorSwarmAutonomousChatAppDataSentinelSchema,
- supervisorSwarmCollaborationPolicyAppDataSentinelFileName,
- supervisorSwarmCollaborationPolicyAppDataSentinelSchema,
supervisorSwarmFinalReplyTransientRetryAppDataSentinelFileName,
supervisorSwarmFinalReplyTransientRetryAppDataSentinelSchema,
supervisorSwarmRequiredAgentIds,
- supervisorSwarmStaticIsolatedAutonomousChatAppDataSentinelFileName,
- supervisorSwarmStaticIsolatedAutonomousChatAppDataSentinelSchema,
supervisorSwarmToolPlanHandoffRunnerKillAppDataSentinelFileName,
supervisorSwarmToolPlanHandoffRunnerKillAppDataSentinelSchema,
supervisorSwarmTransientRetryAppDataSentinelFileName,
supervisorSwarmTransientRetryAppDataSentinelSchema,
supervisorSwarmTransientRetryTargetAgentId,
- userInputAppDataSentinelFileName,
- userInputAppDataSentinelSchema,
webSearchAppDataSentinelFileName,
webSearchAppDataSentinelSchema,
windowsProcessHandleHelperSource,
@@ -68,21 +58,14 @@ import { isProjectSkillSuite } from '../suites/project-skill.mjs';
import { isResponseStreamSuite } from '../suites/response-stream.mjs';
import { isScopedAgentsSuite } from '../suites/scoped-agents.mjs';
import { isSteerRunnerKillSuite } from '../suites/steer-runner-kill.mjs';
-import { isSupervisorAutonomousPlayableLaneDefenseSuite } from '../suites/supervisor-autonomous-playable.mjs';
import {
- isSupervisorSwarmAutonomousChatSuite,
- isSupervisorSwarmCollaborationPolicyMixedRecoverySuite,
isSupervisorSwarmFinalReplyTransientRetrySuite,
isSupervisorSwarmInitialTransientRetrySuite,
- isSupervisorSwarmInteractiveChatSuite,
- isSupervisorSwarmMixedHarnessSuite,
- isSupervisorSwarmStaticIsolatedAutonomousChatSuite,
isSupervisorSwarmSuite,
isSupervisorSwarmToolPlanHandoffRunnerKillSuite,
isSupervisorSwarmTransientRetrySuite,
rebuildSupervisorSwarmTranscriptScanner,
} from '../suites/supervisor-swarm.mjs';
-import { isUserInputRuntimeSuite } from '../suites/user-input.mjs';
import {
isWebSearchSuite,
sameEffectiveAgentLlmWithoutWebSearch,
@@ -100,19 +83,10 @@ import { appendBounded, runProcess } from './process.mjs';
import { decodeUtf8Fatal, isIsolatedRunnerSuite } from './reporting.mjs';
import { killRunnerOnce, readRunnerStatus, runnerBootId } from './runtime.mjs';
-const platformSessionFixtureEnv = 'GENARRATIVE_AGC_PLATFORM_SESSION_FIXTURE';
-const platformSessionFixtureMaxBytes = 16 * 1024;
-const isolatedPlatformSessionFixtureName =
- '.deterministic-platform-session.json';
-const platformSessionFixtureSchema =
- 'genarrative-agc-platform-session-fixture.v1';
-
export function isolatedSuiteProtectsSourceAppData() {
return (
isSupervisorSwarmTransientRetrySuite() ||
- isSupervisorSwarmToolPlanHandoffRunnerKillSuite() ||
- isSupervisorAutonomousPlayableLaneDefenseSuite() ||
- isSupervisorSwarmInteractiveChatSuite()
+ isSupervisorSwarmToolPlanHandoffRunnerKillSuite()
);
}
@@ -120,27 +94,6 @@ export function isolatedSuiteUsesSiblingAppData() {
return isWebSearchSuite() || isolatedSuiteProtectsSourceAppData();
}
-export function sameSupervisorPlayableProviderBinding(left, right) {
- const scalarFields = [
- 'providerAgentMode',
- 'providerModel',
- 'providerApiKind',
- 'providerReasoningEffort',
- 'providerBaseUrlSha256',
- ];
- return (
- left != null &&
- right != null &&
- scalarFields.every((field) => left[field] === right[field]) &&
- Array.isArray(left.boundAgentIds) &&
- Array.isArray(right.boundAgentIds) &&
- left.boundAgentIds.length === right.boundAgentIds.length &&
- left.boundAgentIds.every(
- (agentId, index) => agentId === right.boundAgentIds[index],
- )
- );
-}
-
export function isolatedSuiteAppDataProfile() {
if (isSteerRunnerKillSuite()) {
return {
@@ -174,14 +127,6 @@ export function isolatedSuiteAppDataProfile() {
codePrefix: 'context-compaction-appdata',
};
}
- if (isUserInputRuntimeSuite()) {
- return {
- prefix: '.agent-runtime-real-e2e-user-input-',
- sentinelName: userInputAppDataSentinelFileName,
- sentinelSchema: userInputAppDataSentinelSchema,
- codePrefix: 'user-input-appdata',
- };
- }
if (isScopedAgentsSuite()) {
return {
prefix: '.agent-runtime-real-e2e-scoped-agents-',
@@ -236,41 +181,6 @@ export function isolatedSuiteAppDataProfile() {
codePrefix: 'supervisor-swarm-transient-retry-appdata',
};
}
- if (isSupervisorAutonomousPlayableLaneDefenseSuite()) {
- return {
- prefix: '.agent-runtime-real-e2e-supervisor-autonomous-playable-',
- sentinelName: supervisorAutonomousPlayableAppDataSentinelFileName,
- sentinelSchema: supervisorAutonomousPlayableAppDataSentinelSchema,
- codePrefix: 'supervisor-autonomous-playable-appdata',
- };
- }
- if (isSupervisorSwarmAutonomousChatSuite()) {
- return {
- prefix: '.agent-runtime-real-e2e-supervisor-swarm-autonomous-chat-',
- sentinelName: supervisorSwarmAutonomousChatAppDataSentinelFileName,
- sentinelSchema: supervisorSwarmAutonomousChatAppDataSentinelSchema,
- codePrefix: 'supervisor-swarm-autonomous-chat-appdata',
- };
- }
- if (isSupervisorSwarmStaticIsolatedAutonomousChatSuite()) {
- return {
- prefix:
- '.agent-runtime-real-e2e-supervisor-swarm-static-isolated-autonomous-chat-',
- sentinelName:
- supervisorSwarmStaticIsolatedAutonomousChatAppDataSentinelFileName,
- sentinelSchema:
- supervisorSwarmStaticIsolatedAutonomousChatAppDataSentinelSchema,
- codePrefix: 'supervisor-swarm-static-isolated-autonomous-chat-appdata',
- };
- }
- if (isSupervisorSwarmCollaborationPolicyMixedRecoverySuite()) {
- return {
- prefix: '.agent-runtime-real-e2e-supervisor-swarm-collaboration-policy-',
- sentinelName: supervisorSwarmCollaborationPolicyAppDataSentinelFileName,
- sentinelSchema: supervisorSwarmCollaborationPolicyAppDataSentinelSchema,
- codePrefix: 'supervisor-swarm-collaboration-policy-appdata',
- };
- }
if (isSupervisorSwarmSuite()) {
return {
prefix: '.agent-runtime-real-e2e-supervisor-swarm-',
@@ -505,120 +415,6 @@ export async function verifySourceAppDataDirectoryUntouched() {
state.isolatedRunner.sourceAppDataDirectoryUntouched = true;
}
-async function readPlatformSessionFixtureForIsolatedSuite(sourceConfigDir) {
- const rawPath = process.env[platformSessionFixtureEnv];
- assert(
- isNonEmptyString(rawPath) && path.isAbsolute(rawPath),
- 'supervisor-autonomous-playable-platform-session-fixture-missing',
- );
- const sourceRealPath = await fs.realpath(sourceConfigDir);
- const requestedPath = path.resolve(rawPath);
- const requestedMetadata = await fs.lstat(requestedPath).catch((error) => {
- if (error?.code === 'ENOENT') return null;
- throw error;
- });
- assert(
- requestedMetadata?.isFile() && !requestedMetadata.isSymbolicLink(),
- 'supervisor-autonomous-playable-platform-session-fixture-not-regular',
- );
- assert(
- requestedMetadata.size <= platformSessionFixtureMaxBytes,
- 'supervisor-autonomous-playable-platform-session-fixture-too-large',
- );
- const realPath = await fs.realpath(requestedPath);
- assert(
- isPathInside(sourceRealPath, realPath),
- 'supervisor-autonomous-playable-platform-session-fixture-outside-config',
- );
- const bytes = await fs.readFile(realPath);
- assert(
- bytes.length <= platformSessionFixtureMaxBytes,
- 'supervisor-autonomous-playable-platform-session-fixture-too-large',
- );
- let fixture;
- try {
- fixture = JSON.parse(
- decodeUtf8Fatal(bytes, 'platform-session-fixture-invalid-utf8'),
- );
- } catch (error) {
- throw codedError(
- 'supervisor-autonomous-playable-platform-session-fixture-invalid',
- error,
- );
- }
- const expectedKeys = [
- 'schemaVersion',
- 'userId',
- 'accessToken',
- 'apiBaseUrl',
- 'generation',
- ];
- assert(
- isPlainObject(fixture) &&
- JSON.stringify(Object.keys(fixture).sort()) ===
- JSON.stringify([...expectedKeys].sort()) &&
- fixture.schemaVersion === platformSessionFixtureSchema &&
- isNonEmptyString(fixture.userId) &&
- isNonEmptyString(fixture.accessToken) &&
- isNonEmptyString(fixture.apiBaseUrl) &&
- Number.isSafeInteger(fixture.generation) &&
- fixture.generation > 0,
- 'supervisor-autonomous-playable-platform-session-fixture-invalid',
- );
- return {
- sourcePath: realPath,
- bytes,
- fixture,
- sha256: createHash('sha256').update(bytes).digest('hex'),
- };
-}
-
-async function installPlatformSessionFixtureIntoIsolatedAppData(
- sourceConfigDir,
- appDataDir,
-) {
- if (!isSupervisorAutonomousPlayableLaneDefenseSuite()) return;
- const source =
- await readPlatformSessionFixtureForIsolatedSuite(sourceConfigDir);
- const isolatedPath = path.join(
- appDataDir,
- isolatedPlatformSessionFixtureName,
- );
- await fs.copyFile(
- source.sourcePath,
- isolatedPath,
- fsConstants.COPYFILE_EXCL | fsConstants.COPYFILE_FICLONE,
- );
- await fs.chmod(isolatedPath, 0o600).catch(() => {});
- const isolatedMetadata = await fs.lstat(isolatedPath);
- assert(
- isolatedMetadata.isFile() &&
- !isolatedMetadata.isSymbolicLink() &&
- isolatedMetadata.size === source.bytes.length,
- 'supervisor-autonomous-playable-platform-session-fixture-copy-invalid',
- );
- const isolatedBytes = await fs.readFile(isolatedPath);
- assert(
- createHash('sha256').update(isolatedBytes).digest('hex') === source.sha256,
- 'supervisor-autonomous-playable-platform-session-fixture-copy-mismatch',
- );
- state.isolatedRunner.platformSessionFixtureSourcePath = source.sourcePath;
- state.isolatedRunner.platformSessionFixturePath = isolatedPath;
- state.isolatedRunner.platformSessionFixtureSha256 = source.sha256;
- state.isolatedRunner.platformSessionFixturePreviousEnv =
- Object.prototype.hasOwnProperty.call(process.env, platformSessionFixtureEnv)
- ? process.env[platformSessionFixtureEnv]
- : undefined;
- process.env[platformSessionFixtureEnv] = isolatedPath;
- state.formalConfigPathTranscriptScanner?.addSecrets(
- absolutePathVariants(source.sourcePath, isolatedPath),
- );
- const previousLeakCount = state.transcriptScanner?.count ?? 0;
- state.secrets = [...new Set([...state.secrets, source.fixture.accessToken])];
- rebuildSupervisorSwarmTranscriptScanner();
- state.transcriptScanner.count = previousLeakCount;
-}
-
export async function prepareIsolatedSuiteAppData({
streamAgentId = null,
webSearchAgentId = null,
@@ -773,8 +569,7 @@ export async function prepareIsolatedSuiteAppData({
isScopedAgentsSuite() ||
isProjectSkillSuite() ||
isParallelReadSuite() ||
- isSupervisorSwarmSuite() ||
- isSupervisorAutonomousPlayableLaneDefenseSuite()
+ isSupervisorSwarmSuite()
? 'private-copy'
: 'hardlink';
try {
@@ -891,10 +686,6 @@ export async function prepareIsolatedSuiteAppData({
state.secrets = [...suiteSecrets];
rebuildSupervisorSwarmTranscriptScanner();
state.transcriptScanner.count = previousLeakCount;
- await installPlatformSessionFixtureIntoIsolatedAppData(
- sourceConfigDir,
- appDataDir,
- );
const unexpectedEndpoint = await fs
.lstat(path.join(appDataDir, runnerEndpointFileName))
.catch((error) => {
@@ -903,46 +694,6 @@ export async function prepareIsolatedSuiteAppData({
});
assert(!unexpectedEndpoint, `${profile.codePrefix}-endpoint-preexisted`);
state.runtimeConfigDir = appDataDir;
- if (isSupervisorAutonomousPlayableLaneDefenseSuite()) {
- const isolatedConfig = await loadConfig(appDataDir);
- const expectedBinding = state.config.providerBinding;
- const agentIds = [projectSupervisorAgentId];
- const bindings = agentIds.map((agentId) => {
- const effective = effectiveAgentLlmConfig(isolatedConfig.config, agentId);
- assert(
- ['apiKey', 'baseUrl', 'model', 'apiKind', 'reasoningEffort'].every(
- (key) => isNonEmptyString(effective[key]),
- ),
- 'supervisor-autonomous-playable-effective-provider-incomplete',
- );
- return {
- providerModel: effective.model.trim(),
- providerApiKind: effective.apiKind.trim(),
- providerReasoningEffort: effective.reasoningEffort.trim(),
- providerBaseUrlSha256: hashValue(effective.baseUrl.trim()),
- };
- });
- const effectiveBinding = {
- ...bindings[0],
- boundAgentIds: [...agentIds].sort(),
- };
- assert(
- expectedBinding &&
- bindings.every(
- (binding) => JSON.stringify(binding) === JSON.stringify(bindings[0]),
- ) &&
- sameSupervisorPlayableProviderBinding(
- effectiveBinding,
- expectedBinding,
- ),
- 'supervisor-autonomous-playable-effective-provider-binding-mismatch',
- );
- state.supervisorAutonomousPlayable.expectedProviderBinding = {
- ...expectedBinding,
- };
- state.supervisorAutonomousPlayable.effectiveProviderBinding =
- effectiveBinding;
- }
if (streamAgentId) {
const isolatedConfig = await loadConfig(appDataDir);
const isolatedEffective = effectiveAgentLlmConfig(
@@ -981,22 +732,6 @@ export async function prepareIsolatedSuiteAppData({
);
state.webSearch.effectiveEnabled = true;
}
- if (isUserInputRuntimeSuite()) {
- const isolatedConfig = await loadConfig(appDataDir);
- const isolatedEffective = effectiveAgentLlmConfig(
- isolatedConfig.config,
- projectSupervisorAgentId,
- );
- assert(
- isolatedEffective.model === 'gpt-5.5' &&
- ['apiKey', 'baseUrl', 'model'].every(
- (key) =>
- typeof isolatedEffective[key] === 'string' &&
- isolatedEffective[key].trim().length > 0,
- ),
- 'user-input-effective-gpt-5-5-config-invalid',
- );
- }
if (isScopedAgentsSuite()) {
const isolatedConfig = await loadConfig(appDataDir);
const isolatedEffective = effectiveAgentLlmConfig(
@@ -1073,9 +808,8 @@ export async function prepareIsolatedSuiteAppData({
effective.requestTimeoutMs > 0 &&
Number.isSafeInteger(effective.maxRetries) &&
effective.maxRetries >=
- (isSupervisorSwarmInteractiveChatSuite() ||
(isSupervisorSwarmTransientRetrySuite() &&
- agentId !== supervisorSwarmTransientRetryTargetAgentId)
+ agentId !== supervisorSwarmTransientRetryTargetAgentId
? 0
: 1) &&
effective.maxRetries <= 3 &&
@@ -1095,24 +829,6 @@ export async function prepareIsolatedSuiteAppData({
{ llm: isolatedConfig.config.llm },
'',
);
- if (isSupervisorSwarmMixedHarnessSuite()) {
- assert(
- globalEffective.model === 'gpt-5.5' &&
- globalEffective.apiKind === 'openai_chat' &&
- isNonEmptyString(globalEffective.reasoningEffort) &&
- Number.isSafeInteger(globalEffective.requestTimeoutMs) &&
- globalEffective.requestTimeoutMs > 0 &&
- Number.isSafeInteger(globalEffective.maxRetries) &&
- globalEffective.maxRetries >= 0 &&
- globalEffective.maxRetries <= 3 &&
- Number.isSafeInteger(globalEffective.retryBackoffMs) &&
- globalEffective.retryBackoffMs > 0 &&
- ['apiKey', 'baseUrl', 'model'].every((key) =>
- isNonEmptyString(globalEffective[key]),
- ),
- 'supervisor-swarm-mixed-default-provider-policy-invalid',
- );
- }
const configuredAgentIds = Object.keys(
isPlainObject(isolatedConfig.config.agentLlm)
? isolatedConfig.config.agentLlm
@@ -2000,31 +1716,6 @@ export async function verifyIsolatedSuiteConfigLinksUnchanged() {
'isolated-source-config-changed-during-suite',
);
}
- const fixture = state.isolatedRunner;
- if (
- fixture.platformSessionFixtureSourcePath &&
- fixture.platformSessionFixturePath &&
- fixture.platformSessionFixtureSha256
- ) {
- const [sourceMetadata, isolatedMetadata, sourceBytes, isolatedBytes] =
- await Promise.all([
- fs.lstat(fixture.platformSessionFixtureSourcePath),
- fs.lstat(fixture.platformSessionFixturePath),
- fs.readFile(fixture.platformSessionFixtureSourcePath),
- fs.readFile(fixture.platformSessionFixturePath),
- ]);
- assert(
- sourceMetadata.isFile() &&
- !sourceMetadata.isSymbolicLink() &&
- isolatedMetadata.isFile() &&
- !isolatedMetadata.isSymbolicLink() &&
- createHash('sha256').update(sourceBytes).digest('hex') ===
- fixture.platformSessionFixtureSha256 &&
- createHash('sha256').update(isolatedBytes).digest('hex') ===
- fixture.platformSessionFixtureSha256,
- 'supervisor-autonomous-playable-platform-session-fixture-changed',
- );
- }
}
export async function verifySourceConfigLinkCountsRestored() {
@@ -2064,22 +1755,7 @@ export async function removeIsolatedSuiteAppData() {
} catch (error) {
ownershipError = error;
}
- try {
- await fs.rm(appDataDir, { recursive: true, force: false });
- } finally {
- if (state.isolatedRunner.platformSessionFixtureSourcePath) {
- const previous = state.isolatedRunner.platformSessionFixturePreviousEnv;
- if (previous === undefined) {
- delete process.env[platformSessionFixtureEnv];
- } else {
- process.env[platformSessionFixtureEnv] = previous;
- }
- }
- state.isolatedRunner.platformSessionFixturePath = null;
- state.isolatedRunner.platformSessionFixtureSourcePath = null;
- state.isolatedRunner.platformSessionFixtureSha256 = null;
- state.isolatedRunner.platformSessionFixturePreviousEnv = undefined;
- }
+ await fs.rm(appDataDir, { recursive: true, force: false });
state.runtimeConfigDir = state.options.configDir;
try {
await verifySourceConfigLinkCountsRestored();
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/config.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/config.mjs
index 54efb5c75..43768d3b3 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/config.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/config.mjs
@@ -13,15 +13,10 @@ import {
responseStreamSuite,
scopedAgentsSuite,
steerRunnerKillSuite,
- supervisorAutonomousPlayableLaneDefenseSuite,
- supervisorSwarmAutonomousChatSuite,
- supervisorSwarmCollaborationPolicyMixedRecoverySuite,
supervisorSwarmFinalReplyTransientRetrySuite,
- supervisorSwarmStaticIsolatedAutonomousChatSuite,
supervisorSwarmSuite,
supervisorSwarmToolPlanHandoffRunnerKillSuite,
supervisorSwarmTransientRetrySuite,
- userInputRuntimeSuite,
webSearchSuite,
} from '../runtime-state.mjs';
import { collectApiKeys, isPathInside } from './io.mjs';
@@ -58,7 +53,6 @@ export function parseArguments(args) {
suite === responseStreamSuite ||
suite === webSearchSuite ||
suite === contextCompactionSuite ||
- suite === userInputRuntimeSuite ||
suite === scopedAgentsSuite ||
suite === projectSkillSuite ||
suite === parallelReadSuite ||
@@ -66,10 +60,6 @@ export function parseArguments(args) {
suite === supervisorSwarmTransientRetrySuite ||
suite === supervisorSwarmFinalReplyTransientRetrySuite ||
suite === supervisorSwarmToolPlanHandoffRunnerKillSuite ||
- suite === supervisorSwarmAutonomousChatSuite ||
- suite === supervisorAutonomousPlayableLaneDefenseSuite ||
- suite === supervisorSwarmStaticIsolatedAutonomousChatSuite ||
- suite === supervisorSwarmCollaborationPolicyMixedRecoverySuite ||
suite === steerRunnerKillSuite ||
processSessionSuites.has(suite),
'unsupported-suite',
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/process.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/process.mjs
index 950b9646a..1594f2ed0 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/process.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/process.mjs
@@ -2,7 +2,6 @@ import {
assert,
codedError,
hashValue,
- sleep,
throwIfShutdownRequested,
} from '../assertions/core.mjs';
import { fs, path, spawn, withLoopbackNoProxy } from '../dependencies.mjs';
@@ -13,14 +12,9 @@ import {
manifestPath,
state,
} from '../runtime-state.mjs';
-import {
- isSupervisorSwarmTransientRetrySuite,
- recordSupervisorSwarmChatSessionFailureDiagnostic,
-} from '../suites/supervisor-swarm.mjs';
+import { isSupervisorSwarmTransientRetrySuite } from '../suites/supervisor-swarm.mjs';
import { isIsolatedRunnerSuite } from './reporting.mjs';
-export const activeInteractiveCliSessions = new Set();
-
export async function prepareCliBinary() {
const cargo = process.platform === 'win32' ? 'cargo.exe' : 'cargo';
await runProcess(
@@ -84,8 +78,8 @@ export function buildCliChildEnvironment() {
NO_COLOR: '1',
RUST_BACKTRACE: '0',
};
- // The deterministic playable suite copies its account fixture into the
- // sibling isolated AppData directory. Set the path explicitly here so
+ // The isolated runner copies its account fixture into the sibling isolated
+ // AppData directory. Set the path explicitly here so
// every CLI and the Runner it launches use the isolated copy, even if the
// parent harness environment was restored or changed after setup.
if (state.isolatedRunner.platformSessionFixturePath) {
@@ -144,197 +138,6 @@ export function codedProcessError(code, details) {
return error;
}
-export function startInteractiveCli(args) {
- assert(Boolean(state.cliBinary), 'interactive-cli-binary-not-ready');
- assert(Boolean(state.runtimeConfigDir), 'interactive-config-dir-not-ready');
- if (
- isIsolatedRunnerSuite() &&
- state.options?.configDir &&
- path.resolve(state.runtimeConfigDir) ===
- path.resolve(state.options.configDir)
- ) {
- state.isolatedRunner.sourceConfigCliCallCount += 1;
- }
- const child = spawn(
- state.cliBinary,
- [...args, '--config-dir', state.runtimeConfigDir],
- {
- cwd: appRoot,
- env: buildCliChildEnvironment(),
- stdio: ['pipe', 'pipe', 'pipe'],
- },
- );
- return createInteractiveCliSession(child);
-}
-
-export function createInteractiveCliSession(child) {
- activeCommandChildren.add(child);
- const session = {
- child,
- stdout: Buffer.alloc(0),
- stderr: Buffer.alloc(0),
- exited: false,
- exitInfo: null,
- exitPromise: null,
- closed: false,
- closeInfo: null,
- closePromise: null,
- stdioClosed: false,
- stdioCloseInfo: null,
- spawnError: null,
- stdinError: null,
- };
- activeInteractiveCliSessions.add(session);
- session.exitPromise = new Promise((resolve) => {
- const settle = (result) => {
- if (session.exited) return;
- activeCommandChildren.delete(child);
- session.exited = true;
- session.closed = true;
- session.exitInfo = result;
- session.closeInfo = result;
- resolve(result);
- };
- child.once('error', (error) => {
- session.spawnError = error;
- settle({ code: null, signal: null, error });
- });
- child.once('exit', (code, signal) => {
- settle({ code, signal, error: null });
- });
- });
- session.closePromise = new Promise((resolve) => {
- child.once('close', (code, signal) => {
- activeCommandChildren.delete(child);
- activeInteractiveCliSessions.delete(session);
- session.stdioClosed = true;
- session.stdioCloseInfo = {
- code,
- signal,
- error: session.spawnError,
- };
- resolve(session.stdioCloseInfo);
- });
- });
- child.stdin?.on('error', (error) => {
- session.stdinError ??= error;
- });
- child.stdout.on('data', (chunk) => {
- state.transcriptScanner?.scan('interactive-stdout', chunk);
- state.projectPathTranscriptScanner?.scan('interactive-stdout', chunk);
- state.formalConfigPathTranscriptScanner?.scan('interactive-stdout', chunk);
- session.stdout = appendBounded(session.stdout, chunk, commandOutputLimit);
- });
- child.stderr.on('data', (chunk) => {
- state.transcriptScanner?.scan('interactive-stderr', chunk);
- state.projectPathTranscriptScanner?.scan('interactive-stderr', chunk);
- state.formalConfigPathTranscriptScanner?.scan('interactive-stderr', chunk);
- session.stderr = appendBounded(session.stderr, chunk, commandOutputLimit);
- });
- return session;
-}
-
-export function interactiveCliOutput(session) {
- return `${session.stdout.toString('utf8')}\n${session.stderr.toString('utf8')}`;
-}
-
-export function writeInteractiveCliLine(session, line) {
- assert(!session.closed, 'interactive-cli-already-closed');
- assert(session.child.stdin.writable, 'interactive-cli-stdin-not-writable');
- session.child.stdin.write(`${line}\n`);
-}
-
-export async function waitForInteractiveCliOutput(
- session,
- predicate,
- code,
- timeoutMs,
- { allowAfterProcessExit = false } = {},
-) {
- const deadline = Date.now() + timeoutMs;
- while (Date.now() < deadline) {
- const output = interactiveCliOutput(session);
- if (predicate(output)) return output;
- if (session.exited && !allowAfterProcessExit) {
- if (session === state.supervisorSwarmCliSession) {
- recordSupervisorSwarmChatSessionFailureDiagnostic(session);
- }
- throw codedError(`${code}-cli-exited`);
- }
- if (session.stdioClosed) {
- if (session === state.supervisorSwarmCliSession) {
- recordSupervisorSwarmChatSessionFailureDiagnostic(session);
- }
- throw codedError(`${code}-cli-stdio-closed`);
- }
- await sleep(50);
- }
- throw codedError(code);
-}
-
-export async function waitForInteractiveCliExit(session, timeoutMs) {
- const result = await Promise.race([
- session.exitPromise,
- sleep(timeoutMs).then(() => null),
- ]);
- if (!result) throw codedError('interactive-cli-exit-timeout');
- if (result.error) throw codedError('interactive-cli-process-error');
- assert(
- result.code === 0 && result.signal === null,
- 'interactive-cli-exit-invalid',
- );
- return result;
-}
-
-export async function closeInteractiveCli(session) {
- if (!session) return null;
- if (session.exited) return session.exitInfo;
- if (
- session.child.stdin.writable &&
- !session.child.stdin.writableEnded &&
- !session.child.stdin.destroyed
- ) {
- session.child.stdin.write('/quit\n');
- }
- let result = await Promise.race([
- session.exitPromise,
- sleep(3_000).then(() => null),
- ]);
- if (!result && !session.exited) {
- session.child.kill('SIGTERM');
- result = await Promise.race([
- session.exitPromise,
- sleep(2_000).then(() => null),
- ]);
- }
- if (!result && !session.exited) {
- session.child.kill('SIGKILL');
- result = await Promise.race([
- session.exitPromise,
- sleep(5_000).then(() => null),
- ]);
- }
- assert(Boolean(result), 'interactive-cli-cleanup-timeout');
- return result;
-}
-
-export async function waitForInteractiveCliStdioClose(session, timeoutMs) {
- if (!session || session.stdioClosed) return session?.stdioCloseInfo ?? null;
- const result = await Promise.race([
- session.closePromise,
- sleep(timeoutMs).then(() => null),
- ]);
- if (!result) throw codedError('interactive-cli-stdio-close-timeout');
- return result;
-}
-
-export function destroyInteractiveCliOutputStreams(session) {
- if (!session) return;
- for (const stream of [session.child.stdout, session.child.stderr]) {
- if (stream && !stream.destroyed) stream.destroy();
- }
-}
-
export async function runProcess(
program,
args,
@@ -406,214 +209,6 @@ export async function runProcess(
});
}
-export async function listSystemProcessIdentities() {
- if (process.platform === 'win32') {
- const systemRoot = process.env.SystemRoot ?? process.env.SYSTEMROOT;
- assert(
- typeof systemRoot === 'string' && path.isAbsolute(systemRoot),
- 'owned-process-snapshot-system-root-invalid',
- );
- const powershell = path.join(
- systemRoot,
- 'System32/WindowsPowerShell/v1.0/powershell.exe',
- );
- const metadata = await fs.lstat(powershell);
- assert(
- metadata.isFile() && !metadata.isSymbolicLink(),
- 'owned-process-snapshot-powershell-invalid',
- );
- const result = await runProcess(
- powershell,
- [
- '-NoProfile',
- '-NonInteractive',
- '-Command',
- '$processes = @(Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,CreationDate,Name); $processes | ConvertTo-Json -Compress',
- ],
- {
- cwd: appRoot,
- timeoutMs: 30_000,
- env: { ...process.env, NO_COLOR: '1', RUST_BACKTRACE: '0' },
- },
- );
- const parsed = JSON.parse(result.stdout);
- return (Array.isArray(parsed) ? parsed : [parsed])
- .map((record) => ({
- pid: Number(record?.ProcessId),
- parentPid: Number(record?.ParentProcessId),
- startedAt: String(record?.CreationDate ?? ''),
- name: String(record?.Name ?? ''),
- }))
- .filter(validSystemProcessIdentity);
- }
- assert(
- process.platform === 'linux' || process.platform === 'darwin',
- 'owned-process-snapshot-platform-unsupported',
- );
- const result = await runProcess(
- 'ps',
- ['-A', '-o', 'pid=', '-o', 'ppid=', '-o', 'lstart=', '-o', 'comm='],
- { cwd: appRoot, timeoutMs: 30_000 },
- );
- return result.stdout
- .split(/\r?\n/u)
- .map((line) => line.trim())
- .filter(Boolean)
- .map((line) => {
- const fields = line.split(/\s+/u);
- return {
- pid: Number(fields[0]),
- parentPid: Number(fields[1]),
- startedAt: fields.slice(2, 7).join(' '),
- name: fields.slice(7).join(' '),
- };
- })
- .filter(validSystemProcessIdentity);
-}
-
-function validSystemProcessIdentity(record) {
- return (
- Number.isSafeInteger(record?.pid) &&
- record.pid > 0 &&
- Number.isSafeInteger(record.parentPid) &&
- record.parentPid >= 0 &&
- typeof record.startedAt === 'string' &&
- record.startedAt.length > 0 &&
- typeof record.name === 'string' &&
- record.name.length > 0
- );
-}
-
-export function buildOwnedProcessCleanupSnapshot(
- processRecords,
- { rootPids = [], runnerPid = null, helperPids = [] } = {},
-) {
- assert(
- Array.isArray(processRecords) &&
- Array.isArray(rootPids) &&
- Array.isArray(helperPids),
- 'owned-process-snapshot-input-invalid',
- );
- const records = processRecords.filter(validSystemProcessIdentity);
- const byPid = new Map(records.map((record) => [record.pid, record]));
- const childrenByParent = new Map();
- for (const record of records) {
- const children = childrenByParent.get(record.parentPid) ?? [];
- children.push(record.pid);
- childrenByParent.set(record.parentPid, children);
- }
- const normalizedRunnerPid = Number.isSafeInteger(runnerPid)
- ? runnerPid
- : null;
- const helperPidSet = new Set(
- helperPids.filter((pid) => Number.isSafeInteger(pid) && pid > 0),
- );
- const roots = [
- ...new Set(
- [...rootPids, normalizedRunnerPid, ...helperPidSet].filter(
- (pid) => Number.isSafeInteger(pid) && pid > 0,
- ),
- ),
- ];
- assert(roots.length > 0, 'owned-process-snapshot-root-missing');
- const ownedPids = new Set();
- const queue = [...roots];
- while (queue.length > 0) {
- const pid = queue.shift();
- if (ownedPids.has(pid)) continue;
- ownedPids.add(pid);
- queue.push(...(childrenByParent.get(pid) ?? []));
- }
- const identities = [...ownedPids]
- .map((pid) => byPid.get(pid))
- .filter(Boolean)
- .map((record) => ({
- pid: record.pid,
- startedAt: record.startedAt,
- name: record.name,
- kind: ownedProcessKind(record, normalizedRunnerPid, helperPidSet),
- }))
- .sort((left, right) => left.pid - right.pid);
- return {
- identities,
- observedCounts: countOwnedProcessKinds(identities),
- };
-}
-
-function ownedProcessKind(record, runnerPid, helperPids) {
- if (record.pid === runnerPid) return 'runner';
- if (helperPids.has(record.pid)) return 'helper';
- const name = path.basename(record.name).toLowerCase();
- if (/^node(?:\.exe)?$/u.test(name)) return 'node';
- if (/^(?:chrome|chromium|msedge|google-chrome)(?:\.exe)?$/u.test(name)) {
- return 'browser';
- }
- return 'command';
-}
-
-function countOwnedProcessKinds(identities) {
- const counts = {
- runner: 0,
- helper: 0,
- node: 0,
- browser: 0,
- command: 0,
- total: identities.length,
- };
- for (const identity of identities) counts[identity.kind] += 1;
- return counts;
-}
-
-export function inspectOwnedProcessCleanupResiduals(
- snapshot,
- processRecords,
- { activeCommandChildCount = 0, activeInteractiveCliSessionCount = 0 } = {},
-) {
- assert(
- Array.isArray(snapshot?.identities) && Array.isArray(processRecords),
- 'owned-process-residual-input-invalid',
- );
- const currentByPid = new Map(
- processRecords
- .filter(validSystemProcessIdentity)
- .map((record) => [record.pid, record]),
- );
- const residualIdentities = snapshot.identities.filter((identity) => {
- const current = currentByPid.get(identity.pid);
- return (
- current?.startedAt === identity.startedAt &&
- current?.name === identity.name
- );
- });
- return {
- residualCounts: countOwnedProcessKinds(residualIdentities),
- activeCommandChildCount,
- activeInteractiveCliSessionCount,
- clean:
- residualIdentities.length === 0 &&
- activeCommandChildCount === 0 &&
- activeInteractiveCliSessionCount === 0,
- };
-}
-
-export async function captureOwnedProcessCleanupSnapshot(options) {
- return buildOwnedProcessCleanupSnapshot(
- await listSystemProcessIdentities(),
- options,
- );
-}
-
-export async function verifyOwnedProcessCleanupSnapshot(snapshot) {
- return inspectOwnedProcessCleanupResiduals(
- snapshot,
- await listSystemProcessIdentities(),
- {
- activeCommandChildCount: activeCommandChildren.size,
- activeInteractiveCliSessionCount: activeInteractiveCliSessions.size,
- },
- );
-}
-
export function appendBounded(current, chunk, limit) {
const combined = Buffer.concat([current, chunk]);
return combined.length <= limit
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/project.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/project.mjs
index 9fa9ea193..883e5fbea 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/project.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/project.mjs
@@ -28,12 +28,10 @@ import {
isGoalRuntimeSuite,
} from '../suites/goal.mjs';
import { isResponseStreamSuite } from '../suites/response-stream.mjs';
-import { isSupervisorAutonomousPlayableLaneDefenseSuite } from '../suites/supervisor-autonomous-playable.mjs';
import {
isSupervisorSwarmSuite,
supervisorSwarmVerificationFixtureSource,
} from '../suites/supervisor-swarm.mjs';
-import { isUserInputRuntimeSuite } from '../suites/user-input.mjs';
import { isWebSearchSuite } from '../suites/web-search.mjs';
import { createSentinelOwnedTempDirectory } from './app-data.mjs';
import { effectiveAgentLlmConfig } from './config.mjs';
@@ -41,19 +39,15 @@ import { runProcess } from './process.mjs';
import { isIsolatedRunnerSuite } from './reporting.mjs';
export function requiredAgentIdsForSuite() {
- return isUserInputRuntimeSuite()
- ? [projectSupervisorAgentId]
- : isSupervisorAutonomousPlayableLaneDefenseSuite()
- ? [projectSupervisorAgentId]
- : isSupervisorSwarmSuite()
- ? [
- projectSupervisorAgentId,
- supervisorSwarmDesignAgentId,
- supervisorSwarmQualityAgentId,
- ]
- : isIsolatedRunnerSuite()
- ? [mainAgentId]
- : [mainAgentId, 'quality-review'];
+ return isSupervisorSwarmSuite()
+ ? [
+ projectSupervisorAgentId,
+ supervisorSwarmDesignAgentId,
+ supervisorSwarmQualityAgentId,
+ ]
+ : isIsolatedRunnerSuite()
+ ? [mainAgentId]
+ : [mainAgentId, 'quality-review'];
}
export function expectedProviderBindingForSuite(config) {
@@ -120,11 +114,9 @@ export async function checkPrerequisites(config) {
return {
llmConfigured,
providerBinding,
- chromeAvailable:
- !isIsolatedRunnerSuite() ||
- isSupervisorAutonomousPlayableLaneDefenseSuite()
- ? Boolean(await findSupportedBrowser())
- : false,
+ chromeAvailable: !isIsolatedRunnerSuite()
+ ? Boolean(await findSupportedBrowser())
+ : false,
editorApiConfigured,
};
}
@@ -267,8 +259,7 @@ export async function seedDisposableProject({
? supervisorSwarmVerificationFixtureSource()
: isGoalRuntimeSuite() ||
isResponseStreamSuite() ||
- isWebSearchSuite() ||
- isSupervisorAutonomousPlayableLaneDefenseSuite()
+ isWebSearchSuite()
? goalRevisionOneVerificationFixtureSource()
: goalRevisionTwoVerificationFixtureSource(),
),
@@ -405,23 +396,6 @@ export function seededGameHtml() {
`;
}
-export function productionDefaultGameIndexHtml() {
- return `
-
-
-
-
- Genarrative Game Draft
-
-
- 还没有生成游戏。回到聊天输入创意并确认生成后,这里会写入可试玩原型。
-
-`;
-}
-
export function buildTaskPrompt(suite) {
const editorAssetOutcome =
suite === 'full'
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/reporting.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/reporting.mjs
index a176cf335..c59503ec2 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/reporting.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/reporting.mjs
@@ -20,9 +20,7 @@ import { isProjectSkillSuite } from '../suites/project-skill.mjs';
import { isResponseStreamSuite } from '../suites/response-stream.mjs';
import { isScopedAgentsSuite } from '../suites/scoped-agents.mjs';
import { isSteerRunnerKillSuite } from '../suites/steer-runner-kill.mjs';
-import { isSupervisorAutonomousPlayableLaneDefenseSuite } from '../suites/supervisor-autonomous-playable.mjs';
import { isSupervisorSwarmSuite } from '../suites/supervisor-swarm.mjs';
-import { isUserInputRuntimeSuite } from '../suites/user-input.mjs';
import { isWebSearchSuite } from '../suites/web-search.mjs';
import { isPathInside, readJson } from './io.mjs';
@@ -88,17 +86,12 @@ export function buildSummary() {
config: state.config,
blocked: state.blocked,
run: {
- agentId:
- isUserInputRuntimeSuite() ||
- isSupervisorAutonomousPlayableLaneDefenseSuite() ||
- isSupervisorSwarmSuite()
- ? projectSupervisorAgentId
- : mainAgentId,
+ agentId: isSupervisorSwarmSuite()
+ ? projectSupervisorAgentId
+ : mainAgentId,
runIdHash: hashValue(state.initialRunId),
sessionIdHash: hashValue(state.initialSessionId),
- runnerKilled: isSupervisorAutonomousPlayableLaneDefenseSuite()
- ? false
- : state.runnerKilled,
+ runnerKilled: state.runnerKilled,
resumed: state.resumed,
identityStable: state.identityStable,
},
@@ -110,11 +103,9 @@ export function buildSummary() {
projectPathReportLeakCount: state.projectPathReportLeakCount,
...(isWebSearchSuite() ||
isContextCompactionSuite() ||
- isUserInputRuntimeSuite() ||
isScopedAgentsSuite() ||
isProjectSkillSuite() ||
isParallelReadSuite() ||
- isSupervisorAutonomousPlayableLaneDefenseSuite() ||
isSupervisorSwarmSuite() ||
isSteerRunnerKillSuite()
? {
@@ -408,11 +399,9 @@ export function isIsolatedRunnerSuite() {
isResponseStreamSuite() ||
isWebSearchSuite() ||
isContextCompactionSuite() ||
- isUserInputRuntimeSuite() ||
isScopedAgentsSuite() ||
isProjectSkillSuite() ||
isParallelReadSuite() ||
- isSupervisorAutonomousPlayableLaneDefenseSuite() ||
isSupervisorSwarmSuite()
);
}
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/runtime.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/runtime.mjs
index f6f6ae0a4..d2f2cd567 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/runtime.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/harness/runtime.mjs
@@ -87,11 +87,7 @@ import {
import { isProjectSkillSuite } from '../suites/project-skill.mjs';
import { isScopedAgentsSuite } from '../suites/scoped-agents.mjs';
import { isSteerRunnerKillSuite } from '../suites/steer-runner-kill.mjs';
-import {
- confirmSupervisorSwarmPendingActionsInChat,
- isSupervisorSwarmInteractiveChatSuite,
- isSupervisorSwarmSuite,
-} from '../suites/supervisor-swarm.mjs';
+import { isSupervisorSwarmSuite } from '../suites/supervisor-swarm.mjs';
import { killRunnerPidOnce, verifyOwnedRunnerForKill } from './app-data.mjs';
import { isPlainObject } from './config.mjs';
import {
@@ -1038,13 +1034,6 @@ export async function confirmPendingActions(
allowedTools = null,
shouldConfirm = () => true,
) {
- if (isSupervisorSwarmInteractiveChatSuite()) {
- await confirmSupervisorSwarmPendingActionsInChat(
- allowedTools,
- shouldConfirm,
- );
- return;
- }
for (const pending of await findPendingActions()) {
if (state.confirmedActionIds.has(pending.actionId)) continue;
if (!shouldConfirm(pending)) continue;
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/runtime-state.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/runtime-state.mjs
index c27fa5aea..88e662cfc 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/runtime-state.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/runtime-state.mjs
@@ -43,12 +43,6 @@ export const contextCompactionAppDataSentinelFileName =
export const contextCompactionAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-context-compaction-appdata.v1';
-export const userInputAppDataSentinelFileName =
- '.agent-runtime-real-e2e-user-input-appdata.json';
-
-export const userInputAppDataSentinelSchema =
- 'genarrative-agent-runtime-real-e2e-user-input-appdata.v1';
-
export const scopedAgentsAppDataSentinelFileName =
'.agent-runtime-real-e2e-scoped-agents-appdata.json';
@@ -109,30 +103,6 @@ export const supervisorSwarmToolPlanHandoffCheckpointReachedFileName =
export const supervisorSwarmToolPlanHandoffCheckpointReachedSchema =
'game-creator-tool-plan-handoff-runner-kill-checkpoint-reached.v1';
-export const supervisorSwarmAutonomousChatAppDataSentinelFileName =
- '.agent-runtime-real-e2e-supervisor-swarm-autonomous-chat-appdata.json';
-
-export const supervisorSwarmAutonomousChatAppDataSentinelSchema =
- 'genarrative-agent-runtime-real-e2e-supervisor-swarm-autonomous-chat-appdata.v1';
-
-export const supervisorAutonomousPlayableAppDataSentinelFileName =
- '.agent-runtime-real-e2e-supervisor-autonomous-playable-appdata.json';
-
-export const supervisorAutonomousPlayableAppDataSentinelSchema =
- 'genarrative-agent-runtime-real-e2e-supervisor-autonomous-playable-appdata.v1';
-
-export const supervisorSwarmStaticIsolatedAutonomousChatAppDataSentinelFileName =
- '.agent-runtime-real-e2e-supervisor-swarm-static-isolated-autonomous-chat-appdata.json';
-
-export const supervisorSwarmStaticIsolatedAutonomousChatAppDataSentinelSchema =
- 'genarrative-agent-runtime-real-e2e-supervisor-swarm-static-isolated-autonomous-chat-appdata.v1';
-
-export const supervisorSwarmCollaborationPolicyAppDataSentinelFileName =
- '.agent-runtime-real-e2e-supervisor-swarm-collaboration-policy-appdata.json';
-
-export const supervisorSwarmCollaborationPolicyAppDataSentinelSchema =
- 'genarrative-agent-runtime-real-e2e-supervisor-swarm-collaboration-policy-appdata.v1';
-
export const mainAgentId = 'code-prototype';
export const projectSupervisorAgentId = 'project-supervisor';
@@ -179,8 +149,6 @@ export const webSearchSuite = 'web-search';
export const contextCompactionSuite = 'context-compaction';
-export const userInputRuntimeSuite = 'user-input-runtime';
-
export const scopedAgentsSuite = 'scoped-agents';
export const projectSkillSuite = 'project-skill';
@@ -213,18 +181,6 @@ export const supervisorSwarmTransientRetryBackoffMs = 30_000;
export const supervisorSwarmTransientRetryPreDueGuardMs = 1_500;
-export const supervisorSwarmAutonomousChatSuite =
- 'supervisor-swarm-autonomous-chat';
-
-export const supervisorAutonomousPlayableLaneDefenseSuite =
- 'supervisor-autonomous-playable-lane-defense';
-
-export const supervisorSwarmStaticIsolatedAutonomousChatSuite =
- 'supervisor-swarm-static-isolated-autonomous-chat';
-
-export const supervisorSwarmCollaborationPolicyMixedRecoverySuite =
- 'supervisor-swarm-collaboration-policy-mixed-recovery';
-
export const runtimeContextBundleSchemaVersion =
'game-creator-runtime-context-bundle.v5';
@@ -234,17 +190,6 @@ export const providerRequestLifecycleSchemaVersion =
export const providerActionBatchSchemaVersion =
'game-creator-provider-action-batch.v2';
-export const runProfileBindingSchemaVersion =
- 'game-creator-run-profile-binding.v1';
-
-export const autonomousCompletionContractSchemaVersion =
- 'game-creator-autonomous-completion-contract.v2';
-
-export const autonomousPlaytestReceiptSchemaVersion =
- 'game-creator-autonomous-playtest-receipt.v2';
-
-export const autonomousGameBuildRunProfile = 'autonomous-game-build';
-
export const supervisorCollaborationPolicySchemaVersion =
'game-creator-supervisor-collaboration-policy.v1';
@@ -287,12 +232,6 @@ export const contextCompactionTriggerTurns = new Set([4, 8]);
export const contextCompactionConstraintCanary = `GENARRATIVE_CONTEXT_CONSTRAINT_${randomUUID().replaceAll('-', '').slice(0, 20)}`;
-export const userInputAnswerCanary = `GENARRATIVE_USER_CHOICE_${randomUUID()
- .replaceAll('-', '')
- .slice(0, 20)}`;
-
-export const userInputAnswerText = `选择轻量像素风,优先保证移动端轮廓和动作可读性;确认标记 ${userInputAnswerCanary}`;
-
export const scopedAgentsRootCanary = `GENARRATIVE_SCOPE_ROOT_${randomUUID()
.replaceAll('-', '')
.slice(0, 20)}`;
@@ -461,143 +400,6 @@ export const supervisorSwarmConfirmedTools = [
'project.verify',
];
-export const supervisorSwarmAutonomousTask =
- '请把这个试玩项目推进到可以交给首批玩家体验的状态。以仓库现有的正式交付要求、临时检查要求和实际验证结果为准;按阶段生效的临时检查必须在各自生效后全部完成,不能把后续检查并入前置检查或漏掉。完成后简短说明交付内容、验证结论和仍需关注的问题。';
-
-export const supervisorAutonomousPlayableLaneDefenseTask =
- '做一个植物大战僵尸式的塔防游戏,要能选择植物、阻挡敌人、正常闯关,并且生成后可以直接试玩。';
-
-export const supervisorAutonomousPlayableSourceFieldMaxChars = 8_000;
-
-export const supervisorAutonomousPlayableSourceTotalMaxChars = 10_000;
-
-export const supervisorAutonomousPlayableSafeStatuses = new Set([
- 'cancelling',
- 'budget-exhausted',
- 'cancelled',
- 'completed',
- 'failed',
- 'idle',
- 'needs-reconciliation',
- 'paused',
- 'pausing',
- 'pending',
- 'running',
- 'waiting-for-confirmation',
- 'waiting-for-user-input',
-]);
-
-export const supervisorAutonomousPlayableSafePhases = new Set([
- 'action',
- 'budget-exhausted',
- 'cancelled',
- 'cancelling',
- 'completion-contract-failed',
- 'completed',
- 'conversation-write-failed',
- 'executing',
- 'failed',
- 'finalizing',
- 'idle',
- 'needs-reconciliation',
- 'observation',
- 'parent-terminal',
- 'paused',
- 'pausing',
- 'planning',
- 'provider-action-batch',
- 'queued',
- 'response',
- 'running',
- 'waiting-for-agent',
- 'waiting-for-confirmation',
- 'waiting-for-delegate-receipts',
- 'waiting-for-isolated-join',
- 'waiting-for-process-session',
- 'waiting-for-provider-retry',
- 'waiting-for-user-input',
-]);
-
-export const supervisorAutonomousPlayableSafeDeliveryStatuses = new Set([
- 'claimed-by-parent',
- 'dispatched',
- 'ready',
- 'suppressed',
-]);
-
-export const supervisorAutonomousPlayableSafeTerminalStatuses = new Set([
- 'budget-exhausted',
- 'cancelled',
- 'completed',
- 'failed',
-]);
-
-export const supervisorAutonomousPlayableSafeTurnOutcomes = new Set([
- 'failed',
- 'incomplete',
- 'needs-reconciliation',
- 'settled',
-]);
-
-export const laneDefensePlaytestRequiredAssertions = [
- 'state-surface-valid',
- 'level-positive',
- 'start-control-clicked',
- 'start-sequence-advanced',
- 'start-phase-playing',
- 'defender-option-control-clicked',
- 'defender-selection-sequence-advanced',
- 'defender-selection-recorded',
- 'lane-cell-control-clicked',
- 'defender-placement-sequence-advanced',
- 'defender-count-increased',
- 'enemies-present-after-placement',
- 'speed-up-control-clicked',
- 'battle-sequence-advanced',
- 'battle-sequence-monotonic',
- 'enemy-position-changed',
- 'enemy-health-decreased',
- 'phase-won',
- 'next-level-control-clicked',
- 'next-level-sequence-advanced',
- 'level-increased',
- 'restart-control-clicked',
- 'restart-sequence-advanced',
- 'restart-phase-ready-or-playing',
-];
-
-export const supervisorSwarmAutonomousRoutingTerms = [
- supervisorSwarmDesignAgentId,
- supervisorSwarmQualityAgentId,
- 'agent.delegate',
- 'agent.run_status',
- '同一个 planning 轮次',
- '同轮',
- '并行',
- '返工',
- 'repair',
- '一次',
- '两个 Agent',
- '两个专业',
- 'Runner',
- 'pidfd',
- 'actionId',
- 'delegationId',
-];
-
-export const supervisorSwarmCollaborationPolicyControlTerms = [
- '.agent/collaboration-policy.json',
- supervisorCollaborationPolicySchemaVersion,
- 'requiredInitialWave',
- 'minStaticDelegates',
- 'requiredStaticAgentIds',
- 'minIsolatedChildren',
- 'minIsolatedGroupsBeforeClaim',
- 'orchestratorOnlyAfterDelegation',
- 'policyFingerprint',
- 'contractFingerprint',
-];
-
export const supervisorSwarmIsolatedReviews = [
{
path: 'e2e/isolated-a/evidence.txt',
@@ -625,17 +427,6 @@ export const supervisorSwarmIsolatedReviews = [
},
];
-export const supervisorSwarmIsolatedReviewGroups = [
- supervisorSwarmIsolatedReviews.slice(0, 2),
- supervisorSwarmIsolatedReviews.slice(2),
-];
-
-export const supervisorSwarmInitialIsolatedReviews =
- supervisorSwarmIsolatedReviewGroups[0];
-
-export const supervisorSwarmFollowupIsolatedReviews =
- supervisorSwarmIsolatedReviewGroups[1];
-
export const webSearchBaselineApiUrl =
'https://api.github.com/repos/nodejs/node/releases/latest';
@@ -703,8 +494,6 @@ export const pollIntervalMs = 750;
export const runTimeoutMs = 30 * 60 * 1000;
-export const supervisorAutonomousPlayableRunTimeoutMs = 60 * 60 * 1000;
-
export const supervisorSwarmTerminalSidecarCleanupTimeoutMs = 10_000;
export const processRunnerKillStartTimeoutMs = 5 * 60 * 1000;
@@ -938,10 +727,6 @@ export class BlockedError extends Error {
export const isolatedRunnerState = {
appDataDir: null,
- platformSessionFixturePath: null,
- platformSessionFixtureSourcePath: null,
- platformSessionFixtureSha256: null,
- platformSessionFixturePreviousEnv: undefined,
ownerToken: null,
createdAt: 0,
current: null,
@@ -968,9 +753,6 @@ export const state = {
linuxPidfdPythonPath: null,
windowsProcessHandlePowerShellPath: null,
cleanupInProgress: false,
- userInputCliSession: null,
- supervisorSwarmCliSession: null,
- supervisorAutonomousPlayableCliSession: null,
status: 'FAIL',
suite: null,
options: null,
@@ -1082,23 +864,6 @@ export const state = {
finalReplyFingerprint: null,
reportLeakCount: 0,
},
- userInput: {
- requestId: null,
- responseId: null,
- actionId: null,
- questionMessageId: null,
- answerMessageId: null,
- questionCount: 0,
- optionCount: 0,
- providerStartedBeforeKill: 0,
- providerStartedAfterRestart: 0,
- conversationCountBeforeKill: 0,
- conversationCountAfterRestart: 0,
- oldRunnerBootId: null,
- newRunnerBootId: null,
- privateValues: [],
- reportLeakCount: 0,
- },
scopedAgents: {
effectiveModel: null,
effectiveApiKind: null,
@@ -1120,20 +885,6 @@ export const state = {
privateValues: [],
reportLeakCount: 0,
},
- supervisorAutonomousPlayable: {
- freshInitBaselineUsed: false,
- initialGameIndexSha256: null,
- expectedProviderBinding: null,
- effectiveProviderBinding: null,
- stdinWriteCount: 0,
- stdinEnded: false,
- stdinBytes: 0,
- turnReport: null,
- cliOutput: '',
- privateValues: [],
- reportLeakCount: 0,
- ownedProcessCleanupSnapshot: null,
- },
supervisorSwarm: {
effectiveModel: null,
effectiveApiKind: null,
@@ -1215,47 +966,7 @@ export const state = {
toolPlanHandoffLifecycleClosedExactlyOnce: false,
toolPlanHandoffAuditIdempotent: false,
toolPlanHandoffRecoveredPlanFingerprintMatched: false,
- autonomousTaskRecipeFree: false,
- autonomousRepositoryRecipeFree: false,
- interactiveCliUsed: false,
- chatSessionUnexpectedlyClosed: false,
- chatSessionFailureKind: 'none',
- chatSessionExitCode: 'none',
- chatSessionCloseSignal: 'none',
- chatSessionProcessErrorCode: 'none',
- chatSessionStderrChars: 0,
- chatSessionStderrSha256: 'none',
- turnReport: null,
- mixedSpawnActionId: null,
- mixedSpawnRequestHash: null,
- mixedFollowupSpawnActionId: null,
- mixedFollowupSpawnRequestHash: null,
- staticIsolatedProviderRequestIds: [],
- staticIsolatedProviderOverlapObserved: false,
- preKillMixedIdentity: null,
collaborationPolicyWritten: false,
- collaborationPolicySnapshotInitialRecord: null,
- collaborationPolicySnapshotInitialBytes: null,
- collaborationPolicySnapshotInitialBytesSha256: null,
- collaborationPolicySnapshotInitialIdentityHash: null,
- collaborationPolicySnapshotBindingInitialRecord: null,
- collaborationPolicySnapshotBindingInitialBytes: null,
- collaborationPolicySnapshotBindingInitialBytesSha256: null,
- chatSessionFailureDiagnostic: null,
- collaborationPolicyDriftFixtureWritten: false,
- collaborationPolicyDriftFixturePolicyFingerprint: null,
- collaborationPolicyDriftedMinIsolatedGroupsBeforeClaim: null,
- initialBatchRecoveryBoundaryObserved: false,
- initialBatchRecoveryOldRunnerBootId: null,
- initialBatchRecoveryNewRunnerBootId: null,
- initialBatchRecoveryPreKillIdentity: null,
- initialBatchRecoveryPostRecoveryIdentity: null,
- initialBatchRecoveryPreKillSideEffects: null,
- initialBatchRecoveryPostRecoverySideEffects: null,
- initialBatchRecoveryIdentityStable: false,
- initialBatchRecoveryConfirmationRestoredCount: 0,
- initialBatchRecoveryPidfdClaimCount: 0,
- initialBatchRecoveryPidfdSignalCount: 0,
},
confirmedActionIds: new Set(),
cleanupPerformed: false,
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/self-test.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/self-test.mjs
index b3f83ea49..f427b7b71 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/self-test.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/self-test.mjs
@@ -8,10 +8,8 @@ import {
collectToolPlanRepairAuditEvidence,
countExactSecrets,
emptyToolPlanRepairCountsByProtocolErrorKind,
- finalMessageId,
hasSafeToolPlanAuditPayload,
isNonEmptyString,
- runtimePublicStatusMessageId,
sumObjectValues,
toolPlanRepairEvidenceHasNoFatalLocalRepair,
} from '../assertions/runtime.mjs';
@@ -22,68 +20,37 @@ import {
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 { seededGameHtml } from '../harness/project.mjs';
import {
buildSummary,
isIsolatedRunnerSuite,
providerUsedFromEvidence,
} from '../harness/reporting.mjs';
-import {
- agentConversationPath,
- isEmptyExecutionOwnerLock,
-} from '../harness/runtime.mjs';
+import { 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,
@@ -92,19 +59,7 @@ import {
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,
@@ -120,18 +75,11 @@ import {
supervisorSwarmCollaborationPolicyDriftObservationCount,
supervisorSwarmCollaborationPolicySnapshotBinding,
supervisorSwarmEvidenceFieldTemplate,
- supervisorSwarmExpectedIsolatedReviewGroups,
supervisorSwarmFinalReplyFaultInjectionAllowed,
supervisorSwarmFinalReplyFaultPrerequisites,
- supervisorSwarmFollowupBeforeClaimOrderValid,
supervisorSwarmHostVerificationPassed,
supervisorSwarmInitialBatchBindsPolicySnapshot,
- supervisorSwarmIsolatedReviewGroupIndex,
- supervisorSwarmIsolatedWriteScopeRoots,
- supervisorSwarmMixedIsolatedGroupEntries,
- supervisorSwarmObservedJoinClaimForGroups,
supervisorSwarmProfessionalSessions,
- supervisorSwarmReadyIsolatedGroupIds,
supervisorSwarmResidualSidecarsEmpty,
supervisorSwarmSeedPrivateValues,
supervisorSwarmToolPlanHandoffProxyNeedsCleanup,
@@ -141,33 +89,12 @@ import {
} 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',
@@ -302,345 +229,6 @@ export async function runAgentRuntimeRealE2eSelfTests() {
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 =
@@ -1210,94 +798,15 @@ export async function runAgentRuntimeRealE2eSelfTests() {
),
'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 collaborationPolicy = expectedSupervisorSwarmCollaborationPolicy();
const syntheticSnapshotExpected = {
projectId: 'synthetic-project-id',
parentAgentId: projectSupervisorAgentId,
parentRunId: 'synthetic-parent-run',
boundFrom: supervisorCollaborationPolicySnapshotInitialBatchBinding,
- policy: multiGroupPolicy,
- policyFingerprint: hashValue(JSON.stringify(multiGroupPolicy)),
+ policy: collaborationPolicy,
+ policyFingerprint: hashValue(JSON.stringify(collaborationPolicy)),
};
const syntheticSnapshotBindingBatch = {
schemaVersion: providerActionBatchSchemaVersion,
@@ -1311,7 +820,7 @@ export async function runAgentRuntimeRealE2eSelfTests() {
collaborationContract: {
schemaVersion: supervisorCollaborationContractSchemaVersion,
policySchemaVersion: supervisorCollaborationPolicySchemaVersion,
- policySnapshot: multiGroupPolicy,
+ policySnapshot: collaborationPolicy,
policyFingerprint: syntheticSnapshotExpected.policyFingerprint,
contractFingerprint: hashValue('synthetic-collaboration-contract'),
},
@@ -1359,7 +868,6 @@ export async function runAgentRuntimeRealE2eSelfTests() {
const syntheticSnapshotBindingBytes = JSON.stringify(
syntheticSnapshotBinding,
);
- const syntheticDriftedPolicy = driftedSupervisorSwarmCollaborationPolicy();
state.initialRunId = syntheticSnapshotExpected.parentRunId;
const syntheticDriftObservationCount =
supervisorSwarmCollaborationPolicyDriftObservationCount([
@@ -1412,38 +920,17 @@ export async function runAgentRuntimeRealE2eSelfTests() {
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 &&
@@ -1454,47 +941,9 @@ export async function runAgentRuntimeRealE2eSelfTests() {
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',
+ 'agent-runtime-real-e2e-self-test-collaboration-policy-snapshot-binding-invalid',
);
+
const syntheticIdentity = {
agentId: 'private-agent-id',
taskId: 'private-task-id',
@@ -1732,29 +1181,21 @@ export async function runAgentRuntimeRealE2eSelfTests() {
dynamicPrivateBodyCount: expectedPrivateValues.length,
evidenceMetadataExcluded: true,
genericBoundaryTermsExcluded: true,
- mixedIsolatedGroupTopologyValidated: true,
- mixedReadyJoinObservationValidated: true,
- mixedObservedJoinClaimValidated: true,
- mixedCrossGroupWriteScopesValidated: true,
- mixedFollowupBeforeClaimOrderValidated: true,
- legacySingleIsolatedGroupTopologyValidated: true,
- mixedSuitePolicyIsolationValidated: true,
+ isolatedReviewGroupTopologyValidated: true,
+ isolatedReadyJoinObservationValidated: true,
+ isolatedObservedJoinClaimValidated: true,
+ isolatedWriteScopesValidated: true,
+ isolatedFollowupBeforeClaimOrderValidated: 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,
@@ -1762,11 +1203,6 @@ export async function runAgentRuntimeRealE2eSelfTests() {
stableKillHandleSignalValidated,
stableKillHandleCommandFailureCleanupValidated,
windowsOwnedTempPathValidated,
- autonomousPlayableSuiteRegistered,
- autonomousPlayablePackageCommandsRegistered,
- autonomousPlayableDedicatedPathValidated: true,
- autonomousPlayableExactStdinValidated: true,
- autonomousPlayablePartialCollectorPrivacyValidated,
toolPlanHandoffSuiteRegistered,
toolPlanHandoffPackageCommandsRegistered,
toolPlanHandoffSourceGuardRegistered,
@@ -1776,7 +1212,6 @@ export async function runAgentRuntimeRealE2eSelfTests() {
toolPlanHandoffEvidenceFieldsRegistered,
toolPlanHandoffUnknownResultBoundaryPreserved: true,
finalReplyFaultPrerequisiteValidated: true,
- collaborationPolicyDriftFixtureValidated: true,
collaborationPolicyDriftStatusObserved: true,
duplicateCollaborationPolicySnapshotCount: syntheticSnapshotDuplicateCount,
duplicateCollaborationPolicySnapshotBindingCount:
@@ -1787,7 +1222,6 @@ export async function runAgentRuntimeRealE2eSelfTests() {
collaborationPolicyPartialMissingEvidenceSafe:
syntheticMissingSnapshotSafe && syntheticMissingBindingSafe,
enospcFailureDiagnosticClassified: true,
- chatSessionFailureEvidenceSchemaValidated: true,
toolPlanRepairCount: fullRepairEvidence.toolPlanRepairCount,
toolPlanRepairedLoopCount: fullRepairEvidence.toolPlanRepairedLoopCount,
toolPlanSecondRepairCount: fullRepairEvidence.toolPlanSecondRepairCount,
@@ -1927,139 +1361,6 @@ function validateExecutionOwnerLockScanSelfTest() {
};
}
-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',
@@ -2121,110 +1422,6 @@ function validateProviderUsedReportingSelfTest() {
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();
@@ -2365,133 +1562,3 @@ async function validateStableKillHandleCommandFailureCleanup() {
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;
- }
-}
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/supervisor-autonomous-playable.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/supervisor-autonomous-playable.mjs
deleted file mode 100644
index 6d988a64a..000000000
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/supervisor-autonomous-playable.mjs
+++ /dev/null
@@ -1,1890 +0,0 @@
-import {
- assert,
- codedError,
- hashJsonValue,
- hashValue,
- isFailedTask,
- parseSingleSwarmTurnReport,
- recordError,
- sleep,
-} from '../assertions/core.mjs';
-import {
- absolutePathVariants,
- actionAuditIdentity,
- countExactSecrets,
- duplicateCount,
- finalMessageId,
- isNonEmptyString,
- runtimePublicStatusMessageId,
-} from '../assertions/runtime.mjs';
-import { fs, path } from '../dependencies.mjs';
-import {
- claimOwnedRunner,
- ensureOwnedRunnerStableKillSupport,
- prepareIsolatedSuiteAppData,
-} from '../harness/app-data.mjs';
-import { isPlainObject } from '../harness/config.mjs';
-import { isLiveTask, isPathInside, listFiles } from '../harness/io.mjs';
-import {
- codedProcessError,
- interactiveCliOutput,
- prepareCliBinary,
- startInteractiveCli,
- waitForInteractiveCliOutput,
-} from '../harness/process.mjs';
-import {
- productionDefaultGameIndexHtml,
- seedDisposableProject,
-} from '../harness/project.mjs';
-import { decodeUtf8Fatal } from '../harness/reporting.mjs';
-import {
- countLureLeaks,
- findPendingActions,
- readRuntime,
-} from '../harness/runtime.mjs';
-import {
- autonomousCompletionContractSchemaVersion,
- autonomousGameBuildRunProfile,
- autonomousPlaytestReceiptSchemaVersion,
- laneDefensePlaytestRequiredAssertions,
- projectSupervisorAgentId,
- providerRequestLifecycleSchemaVersion,
- runProfileBindingSchemaVersion,
- state,
- supervisorAutonomousPlayableLaneDefenseSuite,
- supervisorAutonomousPlayableLaneDefenseTask,
- supervisorAutonomousPlayableRunTimeoutMs,
- supervisorAutonomousPlayableSafeDeliveryStatuses,
- supervisorAutonomousPlayableSafePhases,
- supervisorAutonomousPlayableSafeStatuses,
- supervisorAutonomousPlayableSafeTerminalStatuses,
- supervisorAutonomousPlayableSafeTurnOutcomes,
- supervisorAutonomousPlayableSourceFieldMaxChars,
- supervisorAutonomousPlayableSourceTotalMaxChars,
- supervisorSwarmSessionId,
- supervisorSwarmTerminalSidecarCleanupTimeoutMs,
-} from '../runtime-state.mjs';
-import {
- collectSupervisorSwarmPublicLeakEvidence,
- countSupervisorSwarmSteerRecords,
- readSupervisorSwarmJsonDirectory,
- readSupervisorSwarmPersistence,
- readSupervisorSwarmProjectRevision,
- supervisorSwarmParentDeliveries,
- validateSupervisorSwarmFinalization,
-} from './supervisor-swarm.mjs';
-
-const projectSupervisorCliSource = 'project-supervisor-cli';
-const projectSupervisorAcceptedPublicStatus = 'accepted';
-const projectSupervisorAcceptedPublicStatusContent =
- '任务已接收,项目总控 Agent 正在启动处理。';
-
-export function isSupervisorAutonomousPlayableAcceptedPublicStatus(
- message,
- runId,
-) {
- return (
- isPlainObject(message) &&
- message.role === 'assistant' &&
- message.agentId == null &&
- message.sessionId == null &&
- message.messageId ===
- runtimePublicStatusMessageId(
- projectSupervisorAgentId,
- supervisorSwarmSessionId,
- runId,
- projectSupervisorAcceptedPublicStatus,
- ) &&
- message.content === projectSupervisorAcceptedPublicStatusContent
- );
-}
-
-export function inspectSupervisorAutonomousPlayableConversationBoundary(
- legacyConversation,
- userFacing,
- runId,
-) {
- const legacyUserFacingMessages = legacyConversation.filter((message) =>
- ['user', 'assistant'].includes(message.role),
- );
- const acceptedPublicStatuses = legacyUserFacingMessages.filter((message) =>
- isSupervisorAutonomousPlayableAcceptedPublicStatus(message, runId),
- );
- const wrongAgentFinalAssistants = userFacing.filter(
- (message) =>
- message.role === 'assistant' &&
- message.agentId !== projectSupervisorAgentId &&
- !isSupervisorAutonomousPlayableAcceptedPublicStatus(message, runId),
- );
- return {
- legacyUserFacingMessageCount: legacyUserFacingMessages.length,
- acceptedPublicStatusCount: acceptedPublicStatuses.length,
- wrongAgentFinalAssistantCount: wrongAgentFinalAssistants.length,
- };
-}
-
-export function supervisorAutonomousPlayableMode() {
- return {
- rootSource: projectSupervisorCliSource,
- evidenceAgentId: projectSupervisorAgentId,
- scenario: 'project-supervisor-autonomous-playable-lane-defense',
- cliFlags: [],
- };
-}
-
-export function buildSupervisorAutonomousPlayableStdin() {
- const task = supervisorAutonomousPlayableLaneDefenseTask;
- assert(
- task ===
- '做一个植物大战僵尸式的塔防游戏,要能选择植物、阻挡敌人、正常闯关,并且生成后可以直接试玩。' &&
- !/[\r\n]/u.test(task),
- 'supervisor-autonomous-playable-task-not-exact',
- );
- for (const forbidden of [
- projectSupervisorAgentId,
- autonomousGameBuildRunProfile,
- 'Agent',
- 'Runtime',
- 'approve',
- 'answer',
- 'steer',
- 'runner',
- 'tool',
- 'actionId',
- 'runId',
- ]) {
- assert(
- !task.includes(forbidden),
- 'supervisor-autonomous-playable-task-recipe-leak',
- );
- }
- return Buffer.from(`${task}\n`, 'utf8');
-}
-
-export async function waitForSupervisorAutonomousPlayableParentRuntime(task) {
- const deadline = Date.now() + 120_000;
- while (Date.now() < deadline) {
- const runtime = await readRuntime(projectSupervisorAgentId).catch(
- () => null,
- );
- if (
- runtime?.agentId === projectSupervisorAgentId &&
- runtime.sessionId === supervisorSwarmSessionId &&
- isNonEmptyString(runtime.runId) &&
- runtime.currentTask === task &&
- runtime.runProfile === autonomousGameBuildRunProfile &&
- /^[0-9a-f]{64}$/u.test(runtime.runProfileBindingFingerprint ?? '')
- ) {
- return runtime;
- }
- const session = state.supervisorAutonomousPlayableCliSession;
- if (session?.closed && session.closeInfo?.code !== 0) {
- throw codedProcessError('supervisor-autonomous-playable-cli-failed', {
- ...session.closeInfo,
- stdout: session.stdout,
- stderr: session.stderr,
- });
- }
- await sleep(50);
- }
- throw codedError('supervisor-autonomous-playable-parent-runtime-timeout');
-}
-
-export async function waitForSupervisorAutonomousPlayableCliExit(session) {
- let timeoutHandle;
- const timeout = new Promise((resolve) => {
- timeoutHandle = setTimeout(
- () => resolve(null),
- supervisorAutonomousPlayableRunTimeoutMs,
- );
- });
- let result;
- try {
- result = await Promise.race([session.exitPromise, timeout]);
- } finally {
- clearTimeout(timeoutHandle);
- }
- if (!result) {
- throw codedError('supervisor-autonomous-playable-cli-timeout');
- }
- if (result.error || result.code !== 0 || result.signal !== null) {
- state.supervisorAutonomousPlayable.cliOutput =
- interactiveCliOutput(session);
- throw codedProcessError('supervisor-autonomous-playable-cli-failed', {
- ...result,
- stdout: session.stdout,
- stderr: session.stderr,
- });
- }
- const output = await waitForInteractiveCliOutput(
- session,
- () =>
- /(?:^|\r?\n)\[turn\.report\] [^\r\n]+\r?\n/u.test(
- session.stdout.toString('utf8'),
- ),
- 'supervisor-autonomous-playable-turn-report-timeout',
- 10_000,
- { allowAfterProcessExit: true },
- );
- state.supervisorAutonomousPlayable.cliOutput = output;
- const report = parseSingleSwarmTurnReport(
- output,
- 'supervisor-autonomous-playable',
- );
- state.supervisorAutonomousPlayable.turnReport = report;
- return report;
-}
-
-export async function readSupervisorAutonomousPlayableResidualSidecarCounts() {
- const roots = {
- confirmations: '.agent/runtime/confirmations',
- finalizations: '.agent/runtime/finalizations',
- parallelReadBatches: '.agent/runtime/parallel-read-batches',
- pendingActions: '.agent/runtime/pending-actions',
- providerActionBatches: '.agent/runtime/provider-action-batches',
- providerHandoffs: '.agent/runtime/provider-handoffs',
- providerRetries: '.agent/runtime/provider-retries',
- toolPlanHandoffs: '.agent/runtime/tool-plan-handoffs',
- userInput: '.agent/runtime/user-input',
- };
- const counts = {};
- for (const [name, relativePath] of Object.entries(roots)) {
- counts[name] = (
- await listFiles(path.join(state.projectRoot, relativePath))
- ).length;
- }
- return counts;
-}
-
-export function supervisorAutonomousPlayableSafeLifecycleLabel(value, allowed) {
- if (value == null || value === '') return 'absent';
- return typeof value === 'string' && allowed.has(value) ? value : 'unknown';
-}
-
-export function countSupervisorAutonomousPlayableLifecycleLabels(
- records,
- field,
- allowed,
-) {
- const counts = {};
- for (const record of records) {
- const label = supervisorAutonomousPlayableSafeLifecycleLabel(
- record?.[field],
- allowed,
- );
- counts[label] = (counts[label] ?? 0) + 1;
- }
- return counts;
-}
-
-export function supervisorAutonomousPlayableSafeTurnCount(report, field) {
- const value = report?.[field];
- return Number.isSafeInteger(value) && value >= 0 ? value : null;
-}
-
-export function summarizeSupervisorAutonomousPlayableSourcePayloadAudits(
- records,
-) {
- const protocols = records.filter(
- (record) => record.recordType === 'agent.runtime.tool_plan.protocol',
- );
- let sourceMutationActionMax = 0;
- let sourcePayloadMaxFieldChars = 0;
- let sourcePayloadMaxTotalChars = 0;
- let sourcePayloadPolicyViolationCount = 0;
- for (const record of protocols) {
- const mutationCount = record.autonomousSourceMutationActionCount;
- const maxFieldChars = record.autonomousSourceMaxFieldChars;
- const totalChars = record.autonomousSourceTotalChars;
- const valid =
- record.autonomousSourcePayloadValidated === true &&
- Number.isSafeInteger(mutationCount) &&
- mutationCount >= 0 &&
- mutationCount <= 1 &&
- Number.isSafeInteger(maxFieldChars) &&
- maxFieldChars >= 0 &&
- maxFieldChars <= supervisorAutonomousPlayableSourceFieldMaxChars &&
- Number.isSafeInteger(totalChars) &&
- totalChars >= maxFieldChars &&
- totalChars <= supervisorAutonomousPlayableSourceTotalMaxChars;
- if (!valid) sourcePayloadPolicyViolationCount += 1;
- if (Number.isSafeInteger(mutationCount)) {
- sourceMutationActionMax = Math.max(
- sourceMutationActionMax,
- mutationCount,
- );
- }
- if (Number.isSafeInteger(maxFieldChars)) {
- sourcePayloadMaxFieldChars = Math.max(
- sourcePayloadMaxFieldChars,
- maxFieldChars,
- );
- }
- if (Number.isSafeInteger(totalChars)) {
- sourcePayloadMaxTotalChars = Math.max(
- sourcePayloadMaxTotalChars,
- totalChars,
- );
- }
- }
- return {
- acceptedAutonomousToolPlanCount: protocols.length,
- sourceMutationActionMax,
- sourcePayloadMaxFieldChars,
- sourcePayloadMaxTotalChars,
- sourcePayloadPolicyViolationCount,
- };
-}
-
-export function buildSupervisorAutonomousPlayablePartialEvidence(
- persistence,
- {
- residualSidecars = {},
- pendingActionCount = 0,
- turnReport = null,
- partialEvidenceReadErrorCount = 0,
- } = {},
-) {
- const productionDefaultGameIndexSha256 = hashValue(
- Buffer.from(productionDefaultGameIndexHtml(), 'utf8'),
- );
- const parentTask = persistence.taskSnapshot.latest.find(
- (task) =>
- task.agentId === projectSupervisorAgentId &&
- task.runId === state.initialRunId,
- );
- const parentRuntime = persistence.runtimeStates.find(
- (runtime) =>
- runtime.agentId === projectSupervisorAgentId &&
- runtime.runId === state.initialRunId,
- );
- const childTasks = persistence.taskSnapshot.latest.filter(
- (task) =>
- task.parentAgentId === projectSupervisorAgentId &&
- task.parentRunId === state.initialRunId,
- );
- const childRuntimes = persistence.runtimeStates.filter(
- (runtime) =>
- runtime.parentAgentId === projectSupervisorAgentId &&
- runtime.parentRunId === state.initialRunId,
- );
- const deliveries = (persistence.deliveries ?? []).filter(
- (delivery) =>
- delivery.parentAgentId === projectSupervisorAgentId &&
- delivery.parentRunId === state.initialRunId,
- );
- const initialDeliveries = deliveries.filter(
- (delivery) => delivery.repairOfDelegationId == null,
- );
- const repairDeliveries = deliveries.filter(
- (delivery) => delivery.repairOfDelegationId != null,
- );
- const repairDeliveryIds = new Set(
- repairDeliveries.map((delivery) => delivery.delegationId),
- );
- const failedRepairChildCount = childTasks.filter(
- (task) => isFailedTask(task) && repairDeliveryIds.has(task.delegationId),
- ).length;
- const failedOriginalTasks = childTasks.filter(
- (task) => isFailedTask(task) && !repairDeliveryIds.has(task.delegationId),
- );
- let recoveredOriginalFailureCount = 0;
- for (const task of failedOriginalTasks) {
- const original = initialDeliveries.find(
- (delivery) =>
- delivery.delegationId === task.delegationId &&
- delivery.targetAgentId === task.agentId &&
- delivery.targetSessionId === task.sessionId &&
- delivery.targetRunId === task.runId,
- );
- if (
- original &&
- repairDeliveries.some(
- (repair) =>
- repair.repairOfDelegationId === original.delegationId &&
- repair.terminalStatus === 'completed' &&
- repair.structuredResult?.contractStatus === 'evidence-ready',
- )
- ) {
- recoveredOriginalFailureCount += 1;
- }
- }
-
- const relevantRunKeys = new Set();
- for (const record of [
- parentTask,
- parentRuntime,
- ...childTasks,
- ...childRuntimes,
- ]) {
- if (isNonEmptyString(record?.agentId) && isNonEmptyString(record?.runId)) {
- relevantRunKeys.add(`${record.agentId}\0${record.runId}`);
- }
- }
- const lifecycle = persistence.agentDb.filter(
- (record) =>
- record.recordType === 'agent.runtime.provider_request.lifecycle' &&
- relevantRunKeys.has(`${record.agentId}\0${record.runId}`),
- );
- const retryAudits = persistence.agentDb.filter(
- (record) =>
- record.recordType === 'agent.runtime.provider_request.retry' &&
- relevantRunKeys.has(`${record.agentId}\0${record.runId}`),
- );
- const lifecycleByRequest = new Map();
- let duplicateProviderLifecycleCount = 0;
- for (const record of lifecycle) {
- if (!isNonEmptyString(record.requestId)) continue;
- const statuses = lifecycleByRequest.get(record.requestId) ?? new Set();
- if (statuses.has(record.status)) duplicateProviderLifecycleCount += 1;
- statuses.add(record.status);
- lifecycleByRequest.set(record.requestId, statuses);
- }
- const terminalTaskCount = persistence.taskSnapshot.latest.filter((task) =>
- ['budget-exhausted', 'cancelled', 'completed', 'failed'].includes(
- task.status,
- ),
- ).length;
- const supervisorMessages = persistence.supervisorConversation ?? [];
- const turnReportCaptured = isPlainObject(turnReport);
- const turnReportOutcome = turnReportCaptured
- ? supervisorAutonomousPlayableSafeTurnOutcomes.has(turnReport.outcome)
- ? turnReport.outcome
- : 'unknown'
- : null;
- const turnReportParentIdentityStable = turnReportCaptured
- ? turnReport.parentAgentId === projectSupervisorAgentId &&
- turnReport.sessionId === supervisorSwarmSessionId &&
- turnReport.parentRunId === state.initialRunId
- : false;
- const turnReportPrivateLeakCount = turnReportCaptured
- ? countExactSecrets(
- Buffer.from(JSON.stringify(turnReport)),
- state.supervisorAutonomousPlayable.privateValues,
- )
- : null;
- const sourcePayload =
- summarizeSupervisorAutonomousPlayableSourcePayloadAudits(
- persistence.agentDb,
- );
- const providerBinding =
- state.supervisorAutonomousPlayable.effectiveProviderBinding ??
- state.supervisorAutonomousPlayable.expectedProviderBinding;
-
- return {
- evidenceCompleteness: 'partial',
- partialEvidenceCollected: true,
- partialEvidenceReadErrorCount,
- partialPrivacyScanComplete: false,
- rootRunObserved: Boolean(parentTask || parentRuntime),
- parentTaskStatus: supervisorAutonomousPlayableSafeLifecycleLabel(
- parentTask?.status,
- supervisorAutonomousPlayableSafeStatuses,
- ),
- parentTaskPhase: supervisorAutonomousPlayableSafeLifecycleLabel(
- parentTask?.phase,
- supervisorAutonomousPlayableSafePhases,
- ),
- parentRuntimeStatus: supervisorAutonomousPlayableSafeLifecycleLabel(
- parentRuntime?.status,
- supervisorAutonomousPlayableSafeStatuses,
- ),
- parentRuntimePhase: supervisorAutonomousPlayableSafeLifecycleLabel(
- parentRuntime?.phase,
- supervisorAutonomousPlayableSafePhases,
- ),
- childTaskStatusCounts: countSupervisorAutonomousPlayableLifecycleLabels(
- childTasks,
- 'status',
- supervisorAutonomousPlayableSafeStatuses,
- ),
- childTaskPhaseCounts: countSupervisorAutonomousPlayableLifecycleLabels(
- childTasks,
- 'phase',
- supervisorAutonomousPlayableSafePhases,
- ),
- childRuntimeStatusCounts: countSupervisorAutonomousPlayableLifecycleLabels(
- childRuntimes,
- 'status',
- supervisorAutonomousPlayableSafeStatuses,
- ),
- childRuntimePhaseCounts: countSupervisorAutonomousPlayableLifecycleLabels(
- childRuntimes,
- 'phase',
- supervisorAutonomousPlayableSafePhases,
- ),
- initialDeliveryStatusCounts:
- countSupervisorAutonomousPlayableLifecycleLabels(
- initialDeliveries,
- 'status',
- supervisorAutonomousPlayableSafeDeliveryStatuses,
- ),
- repairDeliveryStatusCounts:
- countSupervisorAutonomousPlayableLifecycleLabels(
- repairDeliveries,
- 'status',
- supervisorAutonomousPlayableSafeDeliveryStatuses,
- ),
- repairTerminalStatusCounts:
- countSupervisorAutonomousPlayableLifecycleLabels(
- repairDeliveries,
- 'terminalStatus',
- supervisorAutonomousPlayableSafeTerminalStatuses,
- ),
- failedOriginalChildCount: failedOriginalTasks.length,
- failedRepairChildCount,
- recoveredSpecialistFailureCount: recoveredOriginalFailureCount,
- recoveredOriginalFailureCount,
- awaitingRepairCount:
- failedOriginalTasks.length - recoveredOriginalFailureCount,
- stdinTaskCount: state.supervisorAutonomousPlayable.stdinWriteCount,
- stdinEndedAfterTask: state.supervisorAutonomousPlayable.stdinEnded,
- stdinBytes: state.supervisorAutonomousPlayable.stdinBytes,
- taskSha256: state.initialTask?.sha256 ?? null,
- providerAgentMode: providerBinding?.providerAgentMode ?? null,
- providerModel: providerBinding?.providerModel ?? null,
- providerApiKind: providerBinding?.providerApiKind ?? null,
- providerReasoningEffort: providerBinding?.providerReasoningEffort ?? null,
- providerBaseUrlSha256: providerBinding?.providerBaseUrlSha256 ?? null,
- providerBoundAgentCount: providerBinding?.boundAgentIds?.length ?? 0,
- providerBindingMatched:
- state.supervisorAutonomousPlayable.effectiveProviderBinding != null &&
- JSON.stringify(
- state.supervisorAutonomousPlayable.effectiveProviderBinding,
- ) ===
- JSON.stringify(
- state.supervisorAutonomousPlayable.expectedProviderBinding,
- ),
- turnReportCaptured,
- turnReportParentIdentityStable,
- turnReportNewAssistantMessageCount:
- supervisorAutonomousPlayableSafeTurnCount(
- turnReport,
- 'newAssistantMessageCount',
- ),
- turnReportFinalReplyChars: supervisorAutonomousPlayableSafeTurnCount(
- turnReport,
- 'finalReplyChars',
- ),
- turnReportPrivateLeakCount,
- turnReportOutcome,
- turnReportRuntimeCount: supervisorAutonomousPlayableSafeTurnCount(
- turnReport,
- 'runtimeCount',
- ),
- turnReportBusyRuntimeCount: supervisorAutonomousPlayableSafeTurnCount(
- turnReport,
- 'busyRuntimeCount',
- ),
- turnReportPendingTaskCount: supervisorAutonomousPlayableSafeTurnCount(
- turnReport,
- 'pendingTaskCount',
- ),
- turnReportRunningTaskCount: supervisorAutonomousPlayableSafeTurnCount(
- turnReport,
- 'runningTaskCount',
- ),
- turnReportWaitingForConfirmationCount:
- supervisorAutonomousPlayableSafeTurnCount(
- turnReport,
- 'waitingForConfirmationCount',
- ),
- turnReportWaitingForUserInputCount:
- supervisorAutonomousPlayableSafeTurnCount(
- turnReport,
- 'waitingForUserInputCount',
- ),
- turnReportReconciliationAgentCount:
- supervisorAutonomousPlayableSafeTurnCount(
- turnReport,
- 'reconciliationAgentCount',
- ),
- taskCount: persistence.taskSnapshot.latest.length,
- terminalTaskCount,
- childTaskCount: childTasks.length,
- runtimeCount: persistence.runtimeStates.length,
- childRuntimeCount: childRuntimes.length,
- finalSupervisorAssistantCount: supervisorMessages.filter(
- (message) => message.role === 'assistant',
- ).length,
- supervisorUserMessageCount: supervisorMessages.filter(
- (message) => message.role === 'user',
- ).length,
- professionalAssistantCount: (
- persistence.professionalConversations ?? []
- ).reduce(
- (count, conversation) =>
- count +
- conversation.messages.filter((message) => message.role === 'assistant')
- .length,
- 0,
- ),
- providerRequestIdentityCount: lifecycleByRequest.size,
- providerLifecycleStartedCount: lifecycle.filter(
- (record) => record.status === 'started',
- ).length,
- providerLifecycleTerminalCount: lifecycle.filter((record) =>
- ['completed', 'failed'].includes(record.status),
- ).length,
- providerLifecycleCompletedCount: lifecycle.filter(
- (record) => record.status === 'completed',
- ).length,
- providerLifecycleFailedCount: lifecycle.filter(
- (record) => record.status === 'failed',
- ).length,
- providerRetryAuditCount: retryAudits.length,
- providerConnectivityRetryAuditCount: retryAudits.filter(
- (record) => record.errorKind === 'connectivity',
- ).length,
- providerTransportRetryAuditCount: retryAudits.filter(
- (record) => record.errorKind === 'transport',
- ).length,
- providerTimeoutRetryAuditCount: retryAudits.filter(
- (record) => record.errorKind === 'timeout',
- ).length,
- ...sourcePayload,
- openProviderLifecycleCount: [...lifecycleByRequest.values()].filter(
- (statuses) =>
- statuses.has('started') &&
- !statuses.has('completed') &&
- !statuses.has('failed'),
- ).length,
- duplicateProviderLifecycleCount,
- pendingActionCount,
- confirmationSidecarCount: residualSidecars.confirmations ?? 0,
- userInputSidecarCount: residualSidecars.userInput ?? 0,
- providerActionBatchSidecarCount:
- residualSidecars.providerActionBatches ?? 0,
- providerRetrySidecarCount: residualSidecars.providerRetries ?? 0,
- providerHandoffSidecarCount: residualSidecars.providerHandoffs ?? 0,
- toolPlanHandoffSidecarCount: residualSidecars.toolPlanHandoffs ?? 0,
- finalizationJournalCount: residualSidecars.finalizations ?? 0,
- reconciliationResidueCount:
- supervisorAutonomousPlayableReconciliationResidueCount(persistence),
- freshInitBaselineUsed:
- state.supervisorAutonomousPlayable.freshInitBaselineUsed,
- initialGameIndexMatchesProductionDefault:
- state.supervisorAutonomousPlayable.initialGameIndexSha256 ===
- productionDefaultGameIndexSha256,
- initialGameIndexSha256:
- state.supervisorAutonomousPlayable.initialGameIndexSha256,
- };
-}
-
-export async function collectPartialSupervisorAutonomousPlayableEvidence() {
- const persistence = await readSupervisorSwarmPersistence({
- tolerateErrors: true,
- });
- let partialEvidenceReadErrorCount = Object.keys(
- persistence.failureEvidenceErrors,
- ).length;
- let residualSidecars = {};
- try {
- residualSidecars =
- await readSupervisorAutonomousPlayableResidualSidecarCounts();
- } catch {
- partialEvidenceReadErrorCount += 1;
- recordError('supervisor-autonomous-playable-partial-sidecar-read-failed');
- }
- let pendingActionCount = 0;
- try {
- pendingActionCount = (await findPendingActions()).length;
- } catch {
- partialEvidenceReadErrorCount += 1;
- recordError('supervisor-autonomous-playable-partial-pending-read-failed');
- }
- state.supervisorAutonomousPlayable.privateValues = [
- ...new Set([
- ...state.supervisorAutonomousPlayable.privateValues,
- ...state.supervisorSwarm.privateValues,
- ]),
- ];
- return buildSupervisorAutonomousPlayablePartialEvidence(persistence, {
- residualSidecars,
- pendingActionCount,
- turnReport: state.supervisorAutonomousPlayable.turnReport,
- partialEvidenceReadErrorCount,
- });
-}
-
-export function supervisorAutonomousPlayableReconciliationResidueCount(
- persistence,
-) {
- const taskCount = persistence.taskSnapshot.latest.filter(
- (task) => task.phase === 'needs-reconciliation',
- ).length;
- const runtimeCount = persistence.runtimeStates.filter(
- (runtime) => runtime.phase === 'needs-reconciliation',
- ).length;
- const auditCount = persistence.agentDb.filter(
- (record) =>
- record.status === 'needs-reconciliation' ||
- record.phase === 'needs-reconciliation' ||
- String(record.recordType ?? '').includes('needs_reconciliation'),
- ).length;
- return taskCount + runtimeCount + auditCount;
-}
-
-export function supervisorAutonomousPlayableFailureDisposition(
- persistence,
- { requireRecovered = false } = {},
-) {
- const deliveries = supervisorSwarmParentDeliveries(
- persistence.deliveries ?? [],
- );
- const parentTask = persistence.taskSnapshot.latest.find(
- (task) =>
- task.agentId === projectSupervisorAgentId &&
- task.runId === state.initialRunId,
- );
- const parentRuntime = persistence.runtimeStates.find(
- (runtime) =>
- runtime.agentId === projectSupervisorAgentId &&
- runtime.runId === state.initialRunId,
- );
- assert(
- !isFailedTask(parentTask ?? {}) && !isFailedTask(parentRuntime ?? {}),
- 'supervisor-autonomous-playable-root-failed',
- );
- const parentActive =
- (parentTask && isLiveTask(parentTask)) ||
- [
- 'pending',
- 'running',
- 'waiting-for-confirmation',
- 'waiting-for-user-input',
- ].includes(parentRuntime?.status) ||
- ['queued', 'running', 'executing', 'finalizing'].includes(
- parentRuntime?.phase,
- );
- let recoveredOriginalFailureCount = 0;
- let awaitingRepairCount = 0;
- for (const task of persistence.taskSnapshot.latest.filter(
- (candidate) =>
- candidate.parentAgentId === projectSupervisorAgentId &&
- candidate.parentRunId === state.initialRunId &&
- isFailedTask(candidate),
- )) {
- const delivery = deliveries.find(
- (candidate) =>
- candidate.delegationId === task.delegationId &&
- candidate.targetAgentId === task.agentId &&
- candidate.targetSessionId === task.sessionId &&
- candidate.targetRunId === task.runId,
- );
- assert(
- delivery && delivery.repairOfDelegationId == null,
- delivery?.repairOfDelegationId != null
- ? 'supervisor-autonomous-playable-repair-child-failed'
- : 'supervisor-autonomous-playable-unrecoverable-child-failed',
- );
- const repairs = deliveries.filter(
- (candidate) => candidate.repairOfDelegationId === delivery.delegationId,
- );
- assert(
- repairs.length <= 1,
- 'supervisor-autonomous-playable-duplicate-repair',
- );
- const repairable =
- delivery.status !== 'suppressed' &&
- ((delivery.acceptanceCriteria?.length ?? 0) > 0 ||
- (delivery.expectedArtifacts?.length ?? 0) > 0) &&
- (delivery.structuredResult == null ||
- delivery.structuredResult.contractStatus === 'needs-repair');
- const recovered = repairs.some(
- (repair) =>
- repair.terminalStatus === 'completed' &&
- repair.structuredResult?.contractStatus === 'evidence-ready',
- );
- assert(
- repairable && (recovered || parentActive || !requireRecovered),
- 'supervisor-autonomous-playable-specialist-failure-unrecovered',
- );
- if (recovered) recoveredOriginalFailureCount += 1;
- else awaitingRepairCount += 1;
- }
- if (requireRecovered) {
- assert(
- awaitingRepairCount === 0,
- 'supervisor-autonomous-playable-terminal-repair-incomplete',
- );
- }
- return { recoveredOriginalFailureCount, awaitingRepairCount };
-}
-
-export function assertSupervisorAutonomousPlayableRuntimeHealthy(persistence) {
- for (const task of persistence.taskSnapshot.latest) {
- if (task.phase === 'needs-reconciliation') {
- throw codedError(
- 'supervisor-autonomous-playable-runtime-needs-reconciliation',
- );
- }
- }
- for (const runtime of persistence.runtimeStates) {
- if (runtime.phase === 'needs-reconciliation') {
- throw codedError(
- 'supervisor-autonomous-playable-runtime-needs-reconciliation',
- );
- }
- }
- return supervisorAutonomousPlayableFailureDisposition(persistence);
-}
-
-export async function waitForSupervisorAutonomousPlayableDurableQuiescence() {
- const deadline = Date.now() + supervisorSwarmTerminalSidecarCleanupTimeoutMs;
- let quietPolls = 0;
- while (Date.now() < deadline) {
- const persistence = await readSupervisorSwarmPersistence();
- assertSupervisorAutonomousPlayableRuntimeHealthy(persistence);
- const pending = await findPendingActions();
- const residualSidecars =
- await readSupervisorAutonomousPlayableResidualSidecarCounts();
- const noLiveTasks = persistence.taskSnapshot.latest.every(
- (task) =>
- !isLiveTask(task) &&
- !['waiting-for-user-input', 'waiting-for-confirmation'].includes(
- task.status,
- ),
- );
- const noLiveRuntimes = persistence.runtimeStates.every(
- (runtime) =>
- !isNonEmptyString(runtime.runId) ||
- ['completed', 'cancelled'].includes(runtime.phase),
- );
- const settled =
- noLiveTasks &&
- noLiveRuntimes &&
- pending.length === 0 &&
- Object.values(residualSidecars).every((count) => count === 0) &&
- supervisorAutonomousPlayableReconciliationResidueCount(persistence) === 0;
- if (settled) {
- quietPolls += 1;
- if (quietPolls >= 3) {
- const failureDisposition =
- supervisorAutonomousPlayableFailureDisposition(persistence, {
- requireRecovered: true,
- });
- return { persistence, residualSidecars, failureDisposition };
- }
- } else {
- quietPolls = 0;
- }
- await sleep(50);
- }
- throw codedError('supervisor-autonomous-playable-residue-timeout');
-}
-
-export function supervisorAutonomousPlayableStaticSmokeMatchesFinalIndex(
- gate,
- revision,
- finalGameIndexSha256,
-) {
- return (
- gate?.lastVerificationStatus === 'passed' &&
- gate.verifiedRevision === revision &&
- gate.staticSmokeVerifiedRevision === revision &&
- gate.staticSmokeVerifiedGameIndexSha256 === finalGameIndexSha256
- );
-}
-
-export async function validateSupervisorAutonomousPlayableEvidence(
- persistence,
- residualSidecars,
-) {
- const task = supervisorAutonomousPlayableLaneDefenseTask;
- const mode = supervisorAutonomousPlayableMode();
- const report = state.supervisorAutonomousPlayable.turnReport;
- assert(
- report?.schemaVersion === 'game-creator-swarm-turn-report.v1' &&
- report.outcome === 'settled' &&
- report.parentAgentId === projectSupervisorAgentId &&
- report.sessionId === supervisorSwarmSessionId &&
- report.parentRunId === state.initialRunId &&
- report.runtimeCount >= 1 &&
- report.busyRuntimeCount === 0 &&
- report.pendingTaskCount === 0 &&
- report.runningTaskCount === 0 &&
- report.waitingForConfirmationCount === 0 &&
- report.waitingForUserInputCount === 0 &&
- report.newAssistantMessageCount === 1 &&
- report.finalReplyChars > 0 &&
- report.reconciliationAgentCount === 0,
- 'supervisor-autonomous-playable-turn-report-invalid',
- );
-
- const failureDisposition = supervisorAutonomousPlayableFailureDisposition(
- persistence,
- {
- requireRecovered: true,
- },
- );
- const parentTask = persistence.taskSnapshot.latest.find(
- (candidate) =>
- candidate.agentId === projectSupervisorAgentId &&
- candidate.sessionId === supervisorSwarmSessionId &&
- candidate.runId === state.initialRunId,
- );
- const parentRuntime = persistence.runtimeStates.find(
- (candidate) =>
- candidate.agentId === projectSupervisorAgentId &&
- candidate.runId === state.initialRunId,
- );
- assert(
- parentTask?.task === task &&
- parentTask.source === mode.rootSource &&
- parentTask.status === 'completed' &&
- parentTask.phase === 'completed' &&
- parentTask.runProfile === autonomousGameBuildRunProfile &&
- parentRuntime?.sessionId === supervisorSwarmSessionId &&
- parentRuntime.phase === 'completed' &&
- parentRuntime.pendingToolAction == null &&
- parentRuntime.pendingAction == null &&
- parentRuntime.queuedSteerCount === 0 &&
- parentRuntime.runProfile === autonomousGameBuildRunProfile &&
- persistence.taskSnapshot.latest.every(
- (candidate) =>
- !isLiveTask(candidate) &&
- !['waiting-for-user-input', 'waiting-for-confirmation'].includes(
- candidate.status,
- ),
- ) &&
- persistence.runtimeStates.every(
- (candidate) =>
- candidate.phase !== 'needs-reconciliation' &&
- ![
- 'pending',
- 'running',
- 'waiting-for-user-input',
- 'waiting-for-confirmation',
- ].includes(candidate.status),
- ),
- 'supervisor-autonomous-playable-runtime-not-terminal',
- );
-
- const supervisorUsers = persistence.supervisorConversation.filter(
- (message) => message.role === 'user',
- );
- const supervisorAssistants = persistence.supervisorConversation.filter(
- (message) => message.role === 'assistant',
- );
- const assistant = supervisorAssistants[0];
- const professionalMessages = persistence.professionalConversations.flatMap(
- (entry) => entry.messages,
- );
- const isolatedMessages = persistence.isolatedConversations.flatMap(
- (entry) => entry.messages,
- );
- const userFacing = [
- ...persistence.supervisorConversation,
- ...persistence.legacyConversation,
- ];
- const conversationBoundary =
- inspectSupervisorAutonomousPlayableConversationBoundary(
- persistence.legacyConversation,
- userFacing,
- state.initialRunId,
- );
- const allMessages = [
- ...userFacing,
- ...professionalMessages,
- ...isolatedMessages,
- ];
- const duplicateMessageCount = duplicateCount(
- allMessages.map((message) => message.messageId).filter(Boolean),
- );
- const parentAssistantAudits = persistence.agentDb.filter(
- (record) =>
- record.recordType === 'conversation.message' &&
- record.role === 'assistant' &&
- record.agentId === projectSupervisorAgentId &&
- record.sessionId === supervisorSwarmSessionId &&
- record.messageId === assistant?.messageId,
- );
- const parentCompletedAudits = persistence.agentDb.filter(
- (record) =>
- record.recordType === 'agent.runtime.completed' &&
- record.agentId === projectSupervisorAgentId &&
- record.runId === state.initialRunId,
- );
- assert(
- supervisorUsers.length === 1 &&
- supervisorUsers[0].content === task &&
- supervisorAssistants.length === 1 &&
- assistant.agentId === projectSupervisorAgentId &&
- assistant.messageId ===
- finalMessageId(
- projectSupervisorAgentId,
- supervisorSwarmSessionId,
- state.initialRunId,
- ) &&
- conversationBoundary.legacyUserFacingMessageCount === 1 &&
- conversationBoundary.acceptedPublicStatusCount === 1 &&
- conversationBoundary.wrongAgentFinalAssistantCount === 0 &&
- parentAssistantAudits.length === 1 &&
- parentCompletedAudits.length === 1 &&
- duplicateMessageCount === 0,
- 'supervisor-autonomous-playable-final-assistant-invalid',
- );
- const finalization = validateSupervisorSwarmFinalization(
- persistence.agentDb,
- {
- agentId: projectSupervisorAgentId,
- taskId: parentTask.taskId,
- sessionId: supervisorSwarmSessionId,
- runId: state.initialRunId,
- },
- assistant,
- );
-
- const actionRecords = persistence.agentDb.filter(
- (record) =>
- isNonEmptyString(record.actionId) &&
- [
- 'agent.runtime.tool_action.executing',
- 'agent.runtime.tool_action.observed',
- 'agent.runtime.tool_observation',
- 'agent.runtime.action_receipt',
- ].includes(record.recordType),
- );
- const actionReceipts = actionRecords.filter(
- (record) => record.recordType === 'agent.runtime.action_receipt',
- );
- const duplicateActionLifecycleCount = duplicateCount(
- actionRecords.map(actionAuditIdentity),
- );
- const duplicateReceiptCount = duplicateCount(
- actionReceipts.map(
- (record) => `${record.agentId}\0${record.runId}\0${record.actionId}`,
- ),
- );
- assert(
- duplicateActionLifecycleCount === 0 && duplicateReceiptCount === 0,
- 'supervisor-autonomous-playable-duplicate-action-or-receipt',
- );
-
- const runProfileBindings = await readSupervisorSwarmJsonDirectory(
- '.agent/runtime/run-profile-bindings',
- );
- const autonomousRunKeys = new Set(
- runProfileBindings
- .filter(
- (candidate) =>
- candidate.profile === autonomousGameBuildRunProfile &&
- candidate.rootAgentId === projectSupervisorAgentId &&
- candidate.rootRunId === state.initialRunId,
- )
- .map((candidate) => `${candidate.agentId}\0${candidate.runId}`),
- );
- const sourcePayload =
- summarizeSupervisorAutonomousPlayableSourcePayloadAudits(
- persistence.agentDb.filter((record) =>
- autonomousRunKeys.has(`${record.agentId}\0${record.runId}`),
- ),
- );
- assert(
- sourcePayload.acceptedAutonomousToolPlanCount > 0 &&
- sourcePayload.sourcePayloadPolicyViolationCount === 0,
- 'supervisor-autonomous-playable-source-payload-policy-invalid',
- );
- const matchingBindings = runProfileBindings.filter(
- (binding) =>
- binding.agentId === projectSupervisorAgentId &&
- binding.runId === state.initialRunId,
- );
- const binding = matchingBindings[0];
- const bindingIdentity = binding && {
- schemaVersion: binding.schemaVersion,
- projectId: binding.projectId,
- agentId: binding.agentId,
- runId: binding.runId,
- rootAgentId: binding.rootAgentId,
- rootRunId: binding.rootRunId,
- parentAgentId: binding.parentAgentId,
- parentRunId: binding.parentRunId,
- source: binding.source,
- profile: binding.profile,
- profileFingerprint: binding.profileFingerprint,
- parentBindingFingerprint: binding.parentBindingFingerprint,
- boundAt: binding.boundAt,
- };
- assert(
- matchingBindings.length === 1 &&
- binding.schemaVersion === runProfileBindingSchemaVersion &&
- binding.rootAgentId === projectSupervisorAgentId &&
- binding.rootRunId === state.initialRunId &&
- binding.parentAgentId == null &&
- binding.parentRunId == null &&
- binding.source === mode.rootSource &&
- binding.profile === autonomousGameBuildRunProfile &&
- binding.profileFingerprint ===
- hashJsonValue({
- schemaVersion: runProfileBindingSchemaVersion,
- profile: autonomousGameBuildRunProfile,
- }) &&
- binding.bindingFingerprint === hashJsonValue(bindingIdentity),
- 'supervisor-autonomous-playable-run-profile-binding-invalid',
- );
-
- const contracts = await readSupervisorSwarmJsonDirectory(
- '.agent/runtime/autonomous-completion-contracts',
- );
- const receipts = await readSupervisorSwarmJsonDirectory(
- '.agent/runtime/autonomous-playtest-receipts',
- );
- assert(
- contracts.length === 1 && receipts.length === 1,
- 'supervisor-autonomous-playable-autonomous-artifact-count-invalid',
- );
- const contract = contracts[0];
- const receipt = receipts[0];
- const evidenceBinding = binding;
- const evidenceRunId = state.initialRunId;
- const contractIdentity = {
- schemaVersion: contract.schemaVersion,
- projectId: contract.projectId,
- agentId: contract.agentId,
- runId: contract.runId,
- runProfileBindingFingerprint: contract.runProfileBindingFingerprint,
- taskSha256: contract.taskSha256,
- baselineRevision: contract.baselineRevision,
- baselineIndexSha256: contract.baselineIndexSha256,
- baselineArtifacts: contract.baselineArtifacts,
- playtestScenario: contract.playtestScenario,
- createdAt: contract.createdAt,
- };
- assert(
- contract.schemaVersion === autonomousCompletionContractSchemaVersion &&
- contract.projectId === binding.projectId &&
- contract.agentId === projectSupervisorAgentId &&
- contract.runId === state.initialRunId &&
- contract.runProfileBindingFingerprint === binding.bindingFingerprint &&
- contract.taskSha256 === hashValue(task) &&
- contract.baselineIndexSha256 ===
- state.supervisorAutonomousPlayable.initialGameIndexSha256 &&
- Array.isArray(contract.baselineArtifacts) &&
- contract.baselineArtifacts.length === 1 &&
- contract.baselineArtifacts[0]?.path === 'game/index.html' &&
- contract.baselineArtifacts[0]?.sha256 ===
- state.supervisorAutonomousPlayable.initialGameIndexSha256 &&
- Number.isInteger(contract.baselineArtifacts[0]?.sizeBytes) &&
- contract.baselineArtifacts[0].sizeBytes > 0 &&
- contract.playtestScenario === 'lane-defense-v1' &&
- contract.contractFingerprint === hashJsonValue(contractIdentity),
- 'supervisor-autonomous-playable-completion-contract-invalid',
- );
-
- const revision = await readSupervisorSwarmProjectRevision();
- const finalGameIndex = await fs.readFile(
- path.join(state.projectRoot, 'game/index.html'),
- );
- const finalGameIndexSha256 = hashValue(finalGameIndex);
- assert(
- revision.schemaVersion === 'game-creator-project-revision.v1' &&
- revision.projectId === contract.projectId &&
- revision.revision > contract.baselineRevision &&
- finalGameIndexSha256 !==
- state.supervisorAutonomousPlayable.initialGameIndexSha256 &&
- finalGameIndexSha256 !== contract.baselineIndexSha256,
- 'supervisor-autonomous-playable-project-output-invalid',
- );
-
- const gates = (
- await readSupervisorSwarmJsonDirectory('.agent/runtime/verification')
- ).filter(
- (gate) =>
- gate.agentId === mode.evidenceAgentId && gate.runId === evidenceRunId,
- );
- const gate = gates[0];
- const staticSmokeAudits = persistence.agentDb.filter(
- (record) =>
- record.recordType === 'agent.runtime.command.run_limited' &&
- record.agentId === mode.evidenceAgentId &&
- record.runId === evidenceRunId &&
- record.commandId === 'game.static_smoke' &&
- record.status === 'completed',
- );
- assert(
- gates.length === 1 &&
- supervisorAutonomousPlayableStaticSmokeMatchesFinalIndex(
- gate,
- revision.revision,
- finalGameIndexSha256,
- ) &&
- staticSmokeAudits.length >= 1,
- 'supervisor-autonomous-playable-static-smoke-invalid',
- );
-
- const receiptIdentity = {
- schemaVersion: receipt.schemaVersion,
- projectId: receipt.projectId,
- agentId: receipt.agentId,
- runId: receipt.runId,
- runProfileBindingFingerprint: receipt.runProfileBindingFingerprint,
- executorAgentId: receipt.executorAgentId,
- executorRunId: receipt.executorRunId,
- executorSource: receipt.executorSource,
- executorRunProfileBindingFingerprint:
- receipt.executorRunProfileBindingFingerprint,
- actionId: receipt.actionId,
- actionFingerprint: receipt.actionFingerprint,
- revision: receipt.revision,
- gameIndex: receipt.gameIndex,
- playtestScenario: receipt.playtestScenario,
- scenarioFingerprint: receipt.scenarioFingerprint,
- report: receipt.report,
- screenshots: receipt.screenshots,
- createdAt: receipt.createdAt,
- };
- assert(
- receipt.schemaVersion === autonomousPlaytestReceiptSchemaVersion &&
- receipt.projectId === contract.projectId &&
- receipt.agentId === mode.evidenceAgentId &&
- receipt.runId === evidenceRunId &&
- receipt.runProfileBindingFingerprint ===
- evidenceBinding.bindingFingerprint &&
- receipt.revision === revision.revision &&
- receipt.gameIndex.path === 'game/index.html' &&
- receipt.gameIndex.sha256 === finalGameIndexSha256 &&
- receipt.gameIndex.sizeBytes === finalGameIndex.length &&
- receipt.playtestScenario === 'lane-defense-v1' &&
- receipt.receiptFingerprint === hashJsonValue(receiptIdentity) &&
- actionReceipts.filter(
- (record) =>
- record.agentId === mode.evidenceAgentId &&
- record.runId === evidenceRunId &&
- record.actionId === receipt.actionId &&
- record.actionFingerprint === receipt.actionFingerprint &&
- record.tool === 'preview.validate' &&
- record.status === 'ok',
- ).length === 1,
- 'supervisor-autonomous-playable-playtest-receipt-invalid',
- );
-
- const readDigest = async (digest, expectedSuffix) => {
- assert(
- isNonEmptyString(digest?.path) &&
- !path.isAbsolute(digest.path) &&
- digest.path.endsWith(expectedSuffix),
- 'supervisor-autonomous-playable-evidence-path-invalid',
- );
- const file = path.resolve(state.projectRoot, digest.path);
- assert(
- isPathInside(state.projectRoot, file),
- 'supervisor-autonomous-playable-evidence-path-escape',
- );
- const metadata = await fs.lstat(file);
- assert(
- metadata.isFile() && !metadata.isSymbolicLink(),
- 'supervisor-autonomous-playable-evidence-file-invalid',
- );
- const bytes = await fs.readFile(file);
- assert(
- hashValue(bytes) === digest.sha256 && bytes.length === digest.sizeBytes,
- 'supervisor-autonomous-playable-evidence-digest-invalid',
- );
- return bytes;
- };
- const reportBytes = await readDigest(receipt.report, '/validation.json');
- const browserReport = JSON.parse(
- decodeUtf8Fatal(
- reportBytes,
- 'supervisor-autonomous-playable-browser-report-invalid-utf8',
- ),
- );
- const screenshotEntries = await Promise.all(
- receipt.screenshots.map(async (digest) => ({
- digest,
- bytes: await readDigest(digest, '.png'),
- })),
- );
- assert(
- screenshotEntries.length === 2 &&
- screenshotEntries.every(({ bytes }) =>
- bytes.subarray(0, 8).equals(Buffer.from('\x89PNG\r\n\x1a\n', 'binary')),
- ),
- 'supervisor-autonomous-playable-screenshot-invalid',
- );
- const desktop = screenshotEntries.find(({ digest }) =>
- digest.path.endsWith('/desktop.png'),
- );
- const mobile = screenshotEntries.find(({ digest }) =>
- digest.path.endsWith('/mobile.png'),
- );
- const desktopViewport = browserReport.viewportResults?.find(
- (entry) => entry.viewport === 'desktop',
- );
- const mobileViewport = browserReport.viewportResults?.find(
- (entry) => entry.viewport === 'mobile',
- );
- const playtest = browserReport.playtest;
- const assertionNames = new Set(
- (playtest?.assertions ?? []).map((entry) => entry.name),
- );
- assert(
- desktop &&
- mobile &&
- browserReport.schemaVersion === 'browser-validation.v1' &&
- browserReport.passed === true &&
- Array.isArray(browserReport.viewportResults) &&
- browserReport.viewportResults.length === 2 &&
- JSON.stringify(
- browserReport.viewportResults.map((entry) => entry.viewport).sort(),
- ) === JSON.stringify(['desktop', 'mobile']) &&
- desktopViewport?.passed === true &&
- mobileViewport?.passed === true &&
- playtest?.scenario === 'lane-defense-v1' &&
- playtest.passed === true &&
- playtest.scenarioFingerprint === receipt.scenarioFingerprint &&
- playtest.assertions.every((entry) => entry.passed === true) &&
- laneDefensePlaytestRequiredAssertions.every((name) =>
- assertionNames.has(name),
- ),
- 'supervisor-autonomous-playable-lane-defense-playtest-invalid',
- );
- const lifecycle = persistence.agentDb.filter(
- (record) =>
- record.recordType === 'agent.runtime.provider_request.lifecycle',
- );
- const retryAudits = persistence.agentDb.filter(
- (record) => record.recordType === 'agent.runtime.provider_request.retry',
- );
- const lifecycleByRequest = new Map();
- for (const record of lifecycle) {
- assert(
- record.auditSchemaVersion === providerRequestLifecycleSchemaVersion &&
- isNonEmptyString(record.requestId),
- 'supervisor-autonomous-playable-provider-lifecycle-invalid',
- );
- const records = lifecycleByRequest.get(record.requestId) ?? [];
- records.push(record);
- lifecycleByRequest.set(record.requestId, records);
- }
- for (const records of lifecycleByRequest.values()) {
- assert(
- records.length === 2 &&
- records[0].status === 'started' &&
- ['completed', 'failed'].includes(records[1].status) &&
- [
- 'agentId',
- 'taskId',
- 'sessionId',
- 'runId',
- 'source',
- 'requestKind',
- 'requestSlot',
- ].every((field) => records[0][field] === records[1][field]),
- 'supervisor-autonomous-playable-provider-lifecycle-open-or-duplicate',
- );
- }
- assert(
- lifecycleByRequest.size > 0 &&
- retryAudits.every(
- (retry) =>
- lifecycleByRequest.get(retry.requestId)?.[1]?.status === 'failed' &&
- lifecycle.some(
- (record) =>
- record.status === 'started' &&
- record.agentId === retry.agentId &&
- record.runId === retry.runId &&
- record.requestSlot === retry.nextRequestSlot,
- ),
- ),
- 'supervisor-autonomous-playable-provider-retry-invalid',
- );
-
- const pendingActions = await findPendingActions();
- const reconciliationResidueCount =
- supervisorAutonomousPlayableReconciliationResidueCount(persistence);
- const steerRecordCount =
- (await countSupervisorSwarmSteerRecords()) +
- persistence.agentDb.filter((record) =>
- String(record.recordType ?? '').startsWith('agent.runtime.steer'),
- ).length;
- const approvalAuditCount = persistence.agentDb.filter(
- (record) =>
- record.recordType === 'agent.runtime.tool_confirmation.approved',
- ).length;
- const rejectionAuditCount = persistence.agentDb.filter(
- (record) =>
- record.recordType === 'agent.runtime.tool_confirmation.rejected',
- ).length;
- const confirmationAuditCount = persistence.agentDb.filter((record) =>
- String(record.recordType ?? '').includes('confirmation'),
- ).length;
- const userInputAuditCount = persistence.agentDb.filter((record) =>
- String(record.recordType ?? '').startsWith('agent.runtime.user_input.'),
- ).length;
- assert(
- pendingActions.length === 0 &&
- Object.values(residualSidecars).every((count) => count === 0) &&
- reconciliationResidueCount === 0 &&
- approvalAuditCount === 0 &&
- rejectionAuditCount === 0 &&
- confirmationAuditCount === 0 &&
- userInputAuditCount === 0 &&
- steerRecordCount === 0 &&
- !/\[待确认\]|\[Needs input\]|输入 approve 或 reject|请选择 1-/u.test(
- state.supervisorAutonomousPlayable.cliOutput,
- ),
- 'supervisor-autonomous-playable-intervention-or-residue-detected',
- );
-
- const publicLeaks = collectSupervisorSwarmPublicLeakEvidence(persistence, {
- requireZero: true,
- });
- const projectLureLeakCount = await countLureLeaks();
- const cliLureLeakCount = countExactSecrets(
- Buffer.from(state.supervisorAutonomousPlayable.cliOutput),
- state.lures,
- );
- state.lureLeakCount = projectLureLeakCount + cliLureLeakCount;
- assert(state.lureLeakCount === 0, 'sensitive-lure-leak-detected');
- state.supervisorAutonomousPlayable.privateValues = [
- ...new Set(state.supervisorSwarm.privateValues),
- ];
- const absolutePaths = absolutePathVariants(
- state.projectRoot,
- state.options?.configDir,
- state.isolatedRunner.appDataDir,
- );
- let logApiKeyLeakCount = 0;
- let logPrivateBodyLeakCount = 0;
- let logAbsolutePathLeakCount = 0;
- for (const file of await listFiles(
- path.join(state.projectRoot, '.agent/logs'),
- )) {
- const metadata = await fs.lstat(file);
- if (!metadata.isFile() || metadata.isSymbolicLink()) continue;
- const bytes = await fs.readFile(file);
- logApiKeyLeakCount += countExactSecrets(bytes, state.secrets);
- logPrivateBodyLeakCount += countExactSecrets(
- bytes,
- state.supervisorAutonomousPlayable.privateValues,
- );
- logAbsolutePathLeakCount += countExactSecrets(bytes, absolutePaths);
- }
- const browserReportApiKeyLeakCount = countExactSecrets(
- reportBytes,
- state.secrets,
- );
- const browserReportPrivateBodyLeakCount = countExactSecrets(
- reportBytes,
- state.supervisorAutonomousPlayable.privateValues,
- );
- const browserReportAbsolutePathLeakCount = countExactSecrets(
- reportBytes,
- absolutePaths,
- );
- assert(
- logApiKeyLeakCount === 0 &&
- logPrivateBodyLeakCount === 0 &&
- logAbsolutePathLeakCount === 0 &&
- browserReportApiKeyLeakCount === 0 &&
- browserReportPrivateBodyLeakCount === 0 &&
- browserReportAbsolutePathLeakCount === 0,
- 'supervisor-autonomous-playable-log-or-report-leak-detected',
- );
- const lifecycleProjection = buildSupervisorAutonomousPlayablePartialEvidence(
- persistence,
- {
- residualSidecars,
- pendingActionCount: pendingActions.length,
- turnReport: report,
- },
- );
- const providerBinding =
- state.supervisorAutonomousPlayable.effectiveProviderBinding;
- assert(
- providerBinding &&
- JSON.stringify(providerBinding) ===
- JSON.stringify(
- state.supervisorAutonomousPlayable.expectedProviderBinding,
- ) &&
- isNonEmptyString(providerBinding.providerModel) &&
- isNonEmptyString(providerBinding.providerApiKind) &&
- isNonEmptyString(providerBinding.providerReasoningEffort) &&
- /^[0-9a-f]{64}$/u.test(providerBinding.providerBaseUrlSha256),
- 'supervisor-autonomous-playable-provider-binding-invalid',
- );
-
- return {
- ...emptySupervisorAutonomousPlayableEvidence(),
- ...lifecycleProjection,
- evidenceCompleteness: 'complete',
- partialEvidenceCollected: false,
- partialEvidenceReadErrorCount: 0,
- partialPrivacyScanComplete: true,
- stdinTaskCount: state.supervisorAutonomousPlayable.stdinWriteCount,
- stdinEndedAfterTask: state.supervisorAutonomousPlayable.stdinEnded,
- stdinBytes: state.supervisorAutonomousPlayable.stdinBytes,
- taskSha256: hashValue(task),
- providerAgentMode: providerBinding.providerAgentMode,
- providerModel: providerBinding.providerModel,
- providerApiKind: providerBinding.providerApiKind,
- providerReasoningEffort: providerBinding.providerReasoningEffort,
- providerBaseUrlSha256: providerBinding.providerBaseUrlSha256,
- providerBoundAgentCount: providerBinding.boundAgentIds.length,
- providerBindingMatched: true,
- turnReportCaptured: true,
- turnReportParentIdentityStable: true,
- turnReportNewAssistantMessageCount: report.newAssistantMessageCount,
- turnReportFinalReplyChars: report.finalReplyChars,
- turnReportPrivateLeakCount: 0,
- turnReportOutcome: report.outcome,
- turnReportRuntimeCount: report.runtimeCount,
- turnReportBusyRuntimeCount: report.busyRuntimeCount,
- turnReportPendingTaskCount: report.pendingTaskCount,
- turnReportRunningTaskCount: report.runningTaskCount,
- turnReportWaitingForConfirmationCount: report.waitingForConfirmationCount,
- turnReportWaitingForUserInputCount: report.waitingForUserInputCount,
- turnReportReconciliationAgentCount: report.reconciliationAgentCount,
- taskCount: persistence.taskSnapshot.latest.length,
- terminalTaskCount: persistence.taskSnapshot.latest.length,
- childTaskCount: persistence.taskSnapshot.latest.filter(
- (candidate) => candidate.parentRunId === state.initialRunId,
- ).length,
- runtimeCount: persistence.runtimeStates.length,
- childRuntimeCount: persistence.runtimeStates.filter(
- (candidate) => candidate.parentRunId === state.initialRunId,
- ).length,
- recoveredSpecialistFailureCount:
- failureDisposition.recoveredOriginalFailureCount,
- recoveredOriginalFailureCount:
- failureDisposition.recoveredOriginalFailureCount,
- finalSupervisorAssistantCount: supervisorAssistants.length,
- supervisorUserMessageCount: supervisorUsers.length,
- professionalAssistantCount: professionalMessages.filter(
- (message) => message.role === 'assistant',
- ).length,
- isolatedAssistantCount: isolatedMessages.filter(
- (message) => message.role === 'assistant',
- ).length,
- professionalUserFacingAssistantCount: 0,
- completedAuditCount: parentCompletedAudits.length,
- finalizationStageCount: finalization.stageCount,
- providerRequestIdentityCount: lifecycleByRequest.size,
- providerLifecycleStartedCount: lifecycle.filter(
- (record) => record.status === 'started',
- ).length,
- providerLifecycleTerminalCount: lifecycle.filter((record) =>
- ['completed', 'failed'].includes(record.status),
- ).length,
- providerLifecycleCompletedCount: lifecycle.filter(
- (record) => record.status === 'completed',
- ).length,
- providerLifecycleFailedCount: lifecycle.filter(
- (record) => record.status === 'failed',
- ).length,
- providerRetryAuditCount: retryAudits.length,
- providerConnectivityRetryAuditCount: retryAudits.filter(
- (record) => record.errorKind === 'connectivity',
- ).length,
- providerTransportRetryAuditCount: retryAudits.filter(
- (record) => record.errorKind === 'transport',
- ).length,
- providerTimeoutRetryAuditCount: retryAudits.filter(
- (record) => record.errorKind === 'timeout',
- ).length,
- ...sourcePayload,
- openProviderLifecycleCount: 0,
- duplicateProviderLifecycleCount: 0,
- duplicateMessageCount,
- duplicateActionLifecycleCount,
- duplicateReceiptCount,
- runProfileBindingCount: matchingBindings.length,
- baselineRevision: contract.baselineRevision,
- projectRevision: revision.revision,
- projectRevisionDelta: revision.revision - contract.baselineRevision,
- initialGameIndexSha256:
- state.supervisorAutonomousPlayable.initialGameIndexSha256,
- finalGameIndexSha256,
- gameIndexChanged: true,
- gameIndexBytes: finalGameIndex.length,
- staticSmokePassed: true,
- staticSmokeAuditCount: staticSmokeAudits.length,
- autonomousCompletionContractCount: contracts.length,
- autonomousPlaytestReceiptCount: receipts.length,
- playtestScenario: playtest.scenario,
- laneDefensePlaytestPassed: true,
- laneDefenseAssertionCount: playtest.assertions.length,
- laneDefensePassedAssertionCount: playtest.assertions.filter(
- (entry) => entry.passed,
- ).length,
- browserValidationPassed: true,
- desktopScreenshotSha256: desktop.digest.sha256,
- desktopScreenshotBytes: desktop.bytes.length,
- mobileScreenshotSha256: mobile.digest.sha256,
- mobileScreenshotBytes: mobile.bytes.length,
- browserReportSha256: receipt.report.sha256,
- browserReportBytes: reportBytes.length,
- pendingActionCount: pendingActions.length,
- confirmationSidecarCount: residualSidecars.confirmations,
- userInputSidecarCount: residualSidecars.userInput,
- providerActionBatchSidecarCount: residualSidecars.providerActionBatches,
- providerRetrySidecarCount: residualSidecars.providerRetries,
- providerHandoffSidecarCount: residualSidecars.providerHandoffs,
- toolPlanHandoffSidecarCount: residualSidecars.toolPlanHandoffs,
- finalizationJournalCount: residualSidecars.finalizations,
- reconciliationResidueCount,
- approvalAuditCount,
- rejectionAuditCount,
- userInputAuditCount,
- steerRecordCount,
- providerPayloadPublicLeakCount: publicLeaks.providerPayloadPublicLeakCount,
- privateBodyPublicLeakCount: publicLeaks.privateBodyPublicLeakCount,
- apiKeyPublicLeakCount: publicLeaks.apiKeyPublicLeakCount,
- projectPathPublicLeakCount: publicLeaks.projectPathPublicLeakCount,
- formalConfigPathPublicLeakCount:
- publicLeaks.formalConfigPathPublicLeakCount,
- logApiKeyLeakCount,
- logPrivateBodyLeakCount,
- logAbsolutePathLeakCount,
- browserReportApiKeyLeakCount,
- browserReportPrivateBodyLeakCount,
- browserReportAbsolutePathLeakCount,
- paths: [
- receipt.gameIndex.path,
- receipt.report.path,
- desktop.digest.path,
- mobile.digest.path,
- ],
- };
-}
-
-export async function runSupervisorAutonomousPlayableLaneDefenseE2e() {
- await ensureOwnedRunnerStableKillSupport();
- const mode = supervisorAutonomousPlayableMode();
- state.supervisorAutonomousPlayable.freshInitBaselineUsed = false;
- await seedDisposableProject({ preserveProductionInitBaseline: false });
- const initialGameIndex = await fs.readFile(
- path.join(state.projectRoot, 'game/index.html'),
- );
- state.supervisorAutonomousPlayable.initialGameIndexSha256 =
- hashValue(initialGameIndex);
- state.cliBinary = await prepareCliBinary();
- await prepareIsolatedSuiteAppData();
- state.isolatedRunner.launchAttempted = true;
-
- const stdin = buildSupervisorAutonomousPlayableStdin();
- const task = supervisorAutonomousPlayableLaneDefenseTask;
- state.initialTask = {
- chars: [...task].length,
- sha256: hashValue(task),
- };
- state.supervisorAutonomousPlayable.privateValues = [task];
- state.supervisorSwarm.userTask = task;
- state.supervisorSwarm.privateValues = [task];
- state.supervisorAutonomousPlayableCliSession = startInteractiveCli([
- '--swarm-chat',
- '--init',
- '--autonomous-game-build',
- ...mode.cliFlags,
- state.projectRoot,
- ]);
- state.supervisorAutonomousPlayable.stdinWriteCount = 1;
- state.supervisorAutonomousPlayable.stdinBytes = stdin.length;
- state.supervisorAutonomousPlayable.stdinEnded = true;
- state.supervisorAutonomousPlayableCliSession.child.stdin.end(stdin);
-
- const started = await waitForSupervisorAutonomousPlayableParentRuntime(task);
- state.initialRunId = started.runId;
- state.initialSessionId = started.sessionId;
- await claimOwnedRunner();
- const report = await waitForSupervisorAutonomousPlayableCliExit(
- state.supervisorAutonomousPlayableCliSession,
- );
- assert(
- report.outcome === 'settled',
- 'supervisor-autonomous-playable-turn-not-settled',
- );
-
- const { persistence, residualSidecars } =
- await waitForSupervisorAutonomousPlayableDurableQuiescence();
- state.identityStable = true;
- state.evidence = await validateSupervisorAutonomousPlayableEvidence(
- persistence,
- residualSidecars,
- );
- assert(state.evidence.secretLeakCount === 0, 'loaded-key-leak-detected');
-}
-
-export function emptySupervisorAutonomousPlayableEvidence() {
- const mode = supervisorAutonomousPlayableMode();
- return {
- scenario: mode.scenario,
- targetAgentId: projectSupervisorAgentId,
- runProfile: autonomousGameBuildRunProfile,
- dedicatedZeroInterventionPath: true,
- faultInjectionUsed: false,
- activeRunnerKillCount: 0,
- approveInputCount: 0,
- answerInputCount: 0,
- steerInputCount: 0,
- stdinTaskCount: 0,
- stdinEndedAfterTask: false,
- stdinBytes: 0,
- taskSha256: null,
- providerAgentMode: null,
- providerModel: null,
- providerApiKind: null,
- providerReasoningEffort: null,
- providerBaseUrlSha256: null,
- providerBoundAgentCount: 0,
- providerBindingMatched: false,
- evidenceCompleteness: 'none',
- partialEvidenceCollected: false,
- partialEvidenceReadErrorCount: 0,
- partialPrivacyScanComplete: false,
- rootRunObserved: false,
- parentTaskStatus: null,
- parentTaskPhase: null,
- parentRuntimeStatus: null,
- parentRuntimePhase: null,
- childTaskStatusCounts: {},
- childTaskPhaseCounts: {},
- childRuntimeStatusCounts: {},
- childRuntimePhaseCounts: {},
- initialDeliveryStatusCounts: {},
- repairDeliveryStatusCounts: {},
- repairTerminalStatusCounts: {},
- failedOriginalChildCount: 0,
- failedRepairChildCount: 0,
- recoveredSpecialistFailureCount: 0,
- recoveredOriginalFailureCount: 0,
- awaitingRepairCount: 0,
- isolatedAppDataUsed: false,
- formalConfigCliCallCount: 0,
- sourceRunnerEndpointUnchanged: false,
- sourceAppDataDirectoryUntouched: false,
- sourceConfigReplicaCount: 0,
- sourceConfigReplicasVerified: false,
- turnReportOutcome: null,
- turnReportCaptured: false,
- turnReportParentIdentityStable: false,
- turnReportNewAssistantMessageCount: null,
- turnReportFinalReplyChars: null,
- turnReportPrivateLeakCount: null,
- turnReportRuntimeCount: 0,
- turnReportBusyRuntimeCount: 0,
- turnReportPendingTaskCount: 0,
- turnReportRunningTaskCount: 0,
- turnReportWaitingForConfirmationCount: 0,
- turnReportWaitingForUserInputCount: 0,
- turnReportReconciliationAgentCount: 0,
- taskCount: 0,
- terminalTaskCount: 0,
- childTaskCount: 0,
- runtimeCount: 0,
- childRuntimeCount: 0,
- uniqueRootRunCount: 0,
- recursiveDescendantCount: 0,
- completedDescendantCount: 0,
- artChildCount: 0,
- artDeliveryClaimCount: 0,
- assetListBeforeArtDelegation: false,
- finalSupervisorAssistantCount: 0,
- supervisorUserMessageCount: 0,
- professionalAssistantCount: 0,
- isolatedAssistantCount: 0,
- professionalUserFacingAssistantCount: 0,
- completedAuditCount: 0,
- finalizationStageCount: 0,
- providerRequestIdentityCount: 0,
- providerLifecycleStartedCount: 0,
- providerLifecycleTerminalCount: 0,
- providerLifecycleCompletedCount: 0,
- providerLifecycleFailedCount: 0,
- providerRetryAuditCount: 0,
- providerConnectivityRetryAuditCount: 0,
- providerTransportRetryAuditCount: 0,
- providerTimeoutRetryAuditCount: 0,
- acceptedAutonomousToolPlanCount: 0,
- sourceMutationActionMax: 0,
- sourcePayloadMaxFieldChars: 0,
- sourcePayloadMaxTotalChars: 0,
- sourcePayloadPolicyViolationCount: 0,
- openProviderLifecycleCount: 0,
- duplicateProviderLifecycleCount: 0,
- duplicateMessageCount: 0,
- duplicateActionLifecycleCount: 0,
- duplicateReceiptCount: 0,
- runProfileBindingCount: 0,
- baselineRevision: 0,
- projectRevision: 0,
- projectRevisionDelta: 0,
- freshInitBaselineUsed: false,
- initialGameIndexMatchesProductionDefault: false,
- initialGameIndexSha256: null,
- finalGameIndexSha256: null,
- gameIndexChanged: false,
- finalGameIndexDiffersFromBaseline: false,
- uniqueFixedChildCodePrototype: false,
- gameIndexBytes: 0,
- staticSmokePassed: false,
- staticSmokeGameIndexSha256Matched: false,
- staticSmokeAuditCount: 0,
- autonomousCompletionContractCount: 0,
- autonomousPlaytestReceiptCount: 0,
- playtestScenario: null,
- laneDefensePlaytestPassed: false,
- laneDefenseAssertionCount: 0,
- laneDefensePassedAssertionCount: 0,
- browserValidationPassed: false,
- desktopPlaytestPassed: false,
- mobilePlaytestPassed: false,
- desktopScreenshotSha256: null,
- desktopScreenshotBytes: 0,
- mobileScreenshotSha256: null,
- mobileScreenshotBytes: 0,
- browserReportSha256: null,
- browserReportBytes: 0,
- pendingActionCount: 0,
- confirmationSidecarCount: 0,
- userInputSidecarCount: 0,
- providerActionBatchSidecarCount: 0,
- providerRetrySidecarCount: 0,
- providerHandoffSidecarCount: 0,
- toolPlanHandoffSidecarCount: 0,
- finalizationJournalCount: 0,
- reconciliationResidueCount: 0,
- approvalAuditCount: 0,
- rejectionAuditCount: 0,
- userInputAuditCount: 0,
- steerRecordCount: 0,
- providerPayloadPublicLeakCount: 0,
- privateBodyPublicLeakCount: 0,
- apiKeyPublicLeakCount: 0,
- projectPathPublicLeakCount: 0,
- formalConfigPathPublicLeakCount: 0,
- logApiKeyLeakCount: 0,
- logPrivateBodyLeakCount: 0,
- logAbsolutePathLeakCount: 0,
- browserReportApiKeyLeakCount: 0,
- browserReportPrivateBodyLeakCount: 0,
- browserReportAbsolutePathLeakCount: 0,
- supervisorAutonomousPlayableReportLeakCount: 0,
- supervisorAutonomousPlayableRunnerStopped: false,
- supervisorAutonomousPlayableAppDataCleanupPerformed: false,
- ownedProcessIdentityCaptured: false,
- ownedRunnerObservedCount: 0,
- ownedHelperObservedCount: 0,
- ownedNodeDescendantObservedCount: 0,
- ownedBrowserDescendantObservedCount: 0,
- ownedCommandDescendantObservedCount: 0,
- ownedRunnerResidualCount: 0,
- ownedHelperResidualCount: 0,
- ownedNodeDescendantResidualCount: 0,
- ownedBrowserDescendantResidualCount: 0,
- ownedCommandDescendantResidualCount: 0,
- activeCommandChildrenAfterCleanup: 0,
- activeInteractiveCliSessionsAfterCleanup: 0,
- ownedProcessCleanupPassed: false,
- secretLeakCount: 0,
- lureLeakCount: 0,
- paths: [],
- };
-}
-
-export function isSupervisorAutonomousPlayableLaneDefenseSuite() {
- return state.suite === supervisorAutonomousPlayableLaneDefenseSuite;
-}
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/supervisor-swarm.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/supervisor-swarm.mjs
index 65f2668b1..80f725314 100644
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/supervisor-swarm.mjs
+++ b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/supervisor-swarm.mjs
@@ -1,4 +1,3 @@
-export * from './supervisor-swarm/chat-session.mjs';
export * from './supervisor-swarm/collaboration-assertions.mjs';
export * from './supervisor-swarm/collaboration-policy.mjs';
export * from './supervisor-swarm/evidence-schema.mjs';
diff --git a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/supervisor-swarm/chat-session.mjs b/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/supervisor-swarm/chat-session.mjs
deleted file mode 100644
index b968340a5..000000000
--- a/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/suites/supervisor-swarm/chat-session.mjs
+++ /dev/null
@@ -1,108 +0,0 @@
-import {
- assert,
- codedError,
- commandPassedMarker,
- findPendingActions,
- readRuntime,
- safeProcessFailureDiagnostic,
- state,
- supervisorSwarmConfirmedTools,
- supervisorSwarmDesignContent,
- supervisorSwarmDesignPath,
- supervisorSwarmQualityContent,
- supervisorSwarmQualityPath,
- supervisorSwarmWeakQualityContent,
- visibleText,
- waitForInteractiveCliOutput,
- writeInteractiveCliLine,
-} from './shared.mjs';
-
-export function supervisorSwarmVerificationFixtureSource() {
- return `import fs from 'node:fs';\nconst html = fs.readFileSync('game/index.html', 'utf8');\nconst agents = fs.readFileSync('AGENTS.md', 'utf8');\nconst optionalExact = (file, expected) => !fs.existsSync(file) || fs.readFileSync(file, 'utf8') === expected;\nconst passed = html.includes(${JSON.stringify(visibleText)}) && html.includes('