diff --git a/.aoci/baseline.json b/.aoci/baseline.json index 79c1c4c6f..63bf913cd 100644 --- a/.aoci/baseline.json +++ b/.aoci/baseline.json @@ -1,7 +1,7 @@ { "version": 1, "created_at": "2026-11-19T05:53:26Z", - "updated_at": "2026-11-20T04:00:47Z", + "updated_at": "2026-11-20T04:53:50Z", "files": { ".agents/skills/changelog-card-publish/SKILL.md": { "role": "index", @@ -773,9 +773,9 @@ }, "aoci.code.txt": { "role": "index", - "sha256": "fd65ad13daae90f670004eecf0ba71d4bb7edcc08b175db82d45aaa9b3182342", - "size": 637047, - "normalized_sha256": "fd65ad13daae90f670004eecf0ba71d4bb7edcc08b175db82d45aaa9b3182342" + "sha256": "5daeae6a37fff9d9cc1a8319c689162082f938929a3d8741274f1b4e9f8268df", + "size": 637644, + "normalized_sha256": "5daeae6a37fff9d9cc1a8319c689162082f938929a3d8741274f1b4e9f8268df" }, "aoci.meta.txt": { "role": "index", @@ -4923,9 +4923,9 @@ }, "packages/local-runtime-v2/src/application/session/runtime-services-lifecycle.ts": { "role": "index", - "sha256": "8cb4c6a12a5af5af8e9017b394958e074a5611e5967d49a357035a40e1f27b10", - "size": 14998, - "normalized_sha256": "8cb4c6a12a5af5af8e9017b394958e074a5611e5967d49a357035a40e1f27b10" + "sha256": "8d75fb6874f0543b46ebac2bf7dd1f510ef2513f3bed230c84ccde254ce65493", + "size": 15157, + "normalized_sha256": "8d75fb6874f0543b46ebac2bf7dd1f510ef2513f3bed230c84ccde254ce65493" }, "packages/local-runtime-v2/src/application/session/runtime-session-composition.ts": { "role": "index", @@ -5007,9 +5007,9 @@ }, "packages/local-runtime-v2/src/background-runtime.ts": { "role": "index", - "sha256": "4232e2064f02521185bfa6d12cc9004fd5c3b10c63ba6adc41deaca39f9d5753", - "size": 6690, - "normalized_sha256": "4232e2064f02521185bfa6d12cc9004fd5c3b10c63ba6adc41deaca39f9d5753" + "sha256": "77840f4939dfb288c02a866b9beead46f7886f5154221dc2f23ac4cbe17d1b5a", + "size": 6890, + "normalized_sha256": "77840f4939dfb288c02a866b9beead46f7886f5154221dc2f23ac4cbe17d1b5a" }, "packages/local-runtime-v2/src/compat/v1/agent-host.test.ts": { "role": "observe", @@ -5647,6 +5647,12 @@ "size": 31436, "normalized_sha256": "9f29d2319003fa4d022f50cd852b359e482c346a604aa5f890a306089bd93edb" }, + "packages/local-runtime-v2/src/infra/shutdown-diagnostics.ts": { + "role": "index", + "sha256": "e1b5da492e3ac36fcc418436da15957af153f8795fbf0be8661fc6d875f39c84", + "size": 277, + "normalized_sha256": "e1b5da492e3ac36fcc418436da15957af153f8795fbf0be8661fc6d875f39c84" + }, "packages/local-runtime-v2/src/infra/sse/bounded-ring.ts": { "role": "index", "sha256": "7b5e1b749aeacdc73939b560d8771580cdf713e5f99a2ae9fa8aa6fd1e4c18c9", @@ -5715,9 +5721,9 @@ }, "packages/local-runtime-v2/src/runtime.ts": { "role": "index", - "sha256": "e29b437be6aa6473017031184571631432bf8dab82454c875deb0e93c43f8c4d", - "size": 35404, - "normalized_sha256": "e29b437be6aa6473017031184571631432bf8dab82454c875deb0e93c43f8c4d" + "sha256": "b802e88e552dd869780546d60803e5a268f8c87a73fbf91437cf78bb00ae6bf1", + "size": 35740, + "normalized_sha256": "b802e88e552dd869780546d60803e5a268f8c87a73fbf91437cf78bb00ae6bf1" }, "packages/local-runtime-v2/src/service/agent-turn/contracts.ts": { "role": "index", @@ -29036,9 +29042,9 @@ }, "packages/webui/test/browser/support/native-browser-host.ts": { "role": "index", - "sha256": "5b5dce9cb2ab1762eabc3035faf06c215d5b870259d7f91dafdac064720ea15b", - "size": 7883, - "normalized_sha256": "5b5dce9cb2ab1762eabc3035faf06c215d5b870259d7f91dafdac064720ea15b" + "sha256": "0bdfaa062b39de9e45eabad4fce1a9795c65ed5f921de27fd377a549e1feb7df", + "size": 7937, + "normalized_sha256": "0bdfaa062b39de9e45eabad4fce1a9795c65ed5f921de27fd377a549e1feb7df" }, "packages/webui/test/browser/support/native-design-browser-host.ts": { "role": "index", @@ -31298,9 +31304,9 @@ }, "release/public-source.json": { "role": "index", - "sha256": "889a7423fe6d64dbe26a6e07d6df22b4bef6bc8194a06fc04c0e3fb2c287785d", - "size": 457094, - "normalized_sha256": "889a7423fe6d64dbe26a6e07d6df22b4bef6bc8194a06fc04c0e3fb2c287785d" + "sha256": "508672275a7ccee0e795d51d42a7379311c8d4956642c050076cdc22aff8eba1", + "size": 457161, + "normalized_sha256": "508672275a7ccee0e795d51d42a7379311c8d4956642c050076cdc22aff8eba1" }, "release/webui-npm/README.md": { "role": "index", diff --git a/aoci.code.txt b/aoci.code.txt index cb9b7e559..b94b4db2c 100644 --- a/aoci.code.txt +++ b/aoci.code.txt @@ -1023,7 +1023,7 @@ runtime-plugin-hook-composition.ts[AE4T]: F:Configures runtime plugin hook handl runtime-prompt-support.ts[AW4T]: F:Initializes prompt support for the local runtime's services. | R:- | A:initializeRuntimeServicePromptSupport | S:- runtime-queue-selection.ts[AW4T]: F:Builds the queue selection used by session runtime services. | R:- | A:createRuntimeQueueSelection | S:- runtime-services-composition.ts[AG4T]: F:Resolves service compatibility and builds agent reference and workspace projections. | R:- | A:resolveServicesCompatibility,createRuntimeAgentReferenceProjection,createServiceWorkspace | S:- -runtime-services-lifecycle.ts[AR4L]: F:Coordinates plugin session lifecycle, auth notifications, and owner cleanup after initialization failure. | R:- | A:closeRuntimeServiceOwnersAfterFailure,createRuntimePluginSessionLifecycle,createRuntimePluginAuthContextNotifier | S:- +runtime-services-lifecycle.ts[AR4L]: F:Coordinates plugin session lifecycle, auth notifications and runtime owner shutdown. | R:- | A:closeRuntimeServiceOwnersAfterFailure,createRuntimePluginSessionLifecycle,createRuntimePluginAuthContextNotifier | S:Reports a shutdown phase just before the sandbox close call. runtime-session-composition.ts[AG4L]: F:Composes the production runtime session services from their host inputs. | R:- | A:createProductionSessionComposition,ProductionSessionComposition,RuntimeSessionCompositionInput | S:- runtime-skill-application.ts[AE4S]: F:Exposes runtime skill actions and plugin skill summary through the application boundary. | R:- | A:RuntimeSkillApplication,RuntimePluginSkillSummary,createRuntimeSkillApplication | S:- runtime-user-applications.ts[AG4T]: F:Composes the user-facing application services for the local runtime. | R:- | A:createRuntimeUserApplications | S:- @@ -1037,9 +1037,9 @@ view-contract.ts[LD4S]: F:Defines session views and preserves the status values wire.ts[MD4M]: F:Projects session and project records into their public view and tree representations. | R:- | A:toSessionInfoView,toProjectDetail,projectDisplayName,toSessionTreeNodeView | S:- ===//packages/local-runtime-v2/src/=== -background-runtime.ts[ER4M]: F:Creates a background runtime from supplied options and exposes its lifecycle contract. | R:- | A:createBackgroundRuntime,CreateBackgroundRuntimeOptions,BackgroundRuntime | S:- +background-runtime.ts[ER4M]: F:Creates and owns background runtime infrastructure. | R:- | A:createBackgroundRuntime,CreateBackgroundRuntimeOptions,BackgroundRuntime | S:Shutdown drains deferred maintenance before releasing the runtime owner lease and can report both phases. index.ts[LG4T]: F:Exports local runtime host creation and rootless runtime generation switching. | R:- | A:createLocalRuntimeHost,createLocalRuntimeHostV2,switchRootlessV2Generation | S:- -runtime.ts[AG4L]: F:Constructs the V2 local runtime host and provides a factory with test overrides. | R:- | A:createLocalRuntimeHostV2,createLocalRuntimeHostV2ForTest,LocalRuntimeV2TestOverrides | S:- +runtime.ts[AG4L]: F:Constructs and closes the V2 local runtime host and provides a factory with test overrides. | R:code:packages/local-runtime-v2/src/background-runtime.ts | A:createLocalRuntimeHostV2,createLocalRuntimeHostV2ForTest,LocalRuntimeV2TestOverrides | S:Opt-in shutdown phase markers precede owner, legacy host and database teardown. services.ts[AG4L]: F:Defines the local runtime service assembly, creation options, and test overrides. | R:- | A:RuntimeServices,RuntimeServicesTestOverrides,CreateRuntimeServicesOptions | S:- ===//packages/local-runtime-v2/src/compat/v1/=== @@ -5738,7 +5738,7 @@ accessibility-review.json[SE4T]: F:Records browser accessibility review evidence accessibility.d.mts[SE4T]: F:Declares types for browser accessibility test helpers. | R:- | A:- | S:- accessibility.mjs[SE4M]: F:Implements browser accessibility checks and loads their exceptions. | R:- | A:- | S:- composer-mascot-opaque.webm.asset.json[SE4T]: F:Describes the opaque composer mascot video test asset. | R:- | A:- | S:- -native-browser-host.ts[SE4S]: F:Provides a native browser host for testing Browser Use. | R:- | A:- | S:- +native-browser-host.ts[SE4S]: F:Runs the real WebUI service and native PTYs for browser acceptance. | R:- | A:- | S:Enables runtime shutdown phase markers and reports the current service owner if teardown times out. native-design-browser-host.ts[SE4M]: F:Provides a native WebUI host for testing Design, including the synthetic provider that receives the media upload. | R:- | A:- | S:The synthetic provider reads the multipart upload body itself: the platform multipart parser differs across platforms and leaves the provider waiting. rendering-integrity.json[SE4L]: F:Stores the recorded browser rendering integrity expectations for each surface, state and theme. | R:- | A:- | S:It is re-recorded with RECORD_RENDERING_INTEGRITY=1 when the surfaces move, and every value is compared against what the run measures. rendering-integrity.mjs[SE4M]: F:Loads and checks browser rendering integrity requirements. | R:- | A:- | S:- @@ -5760,7 +5760,7 @@ source-text.ts[SE4T]: F:Reads source text for WebUI unit checks. | R:- | A:- | S ===//release/=== dependency-licenses.json[SE4L]: F:Records third-party dependency licenses for release. | R:- | A:- | S:- extraction.json[SE4T]: F:Pins the extracted source baseline and public package scope. | R:- | A:- | S:- -public-source.json[FV6L]: F:Inventories the files in the reviewed public source projection and the published path of every one of them. | R:- | A:- | S:The inventory is generated by `node scripts/source-inventory.mjs --write`; recording a file does not make it fit for publication. +public-source.json[FV6L]: F:Inventories reviewed public source paths, including runtime shutdown diagnostics. | R:- | A:- | S:Regenerate with node scripts/source-inventory.mjs --write after reviewing which files are suitable for publication. ===//release/webui-npm/=== README.md[SE4T]: F:Documents installation and use of the WebUI npm package. | R:- | A:- | S:- @@ -5866,3 +5866,6 @@ windows-contract.test.mjs[SE4S]: F:Tests Windows-specific distribution and runti ===//tools/plugins/=== validate-plugin.mjs[SE4L]: F:Validates plugin packages against their manifest and schema contracts. | R:- | A:- | S:- + +===//packages/local-runtime-v2/src/infra/=== +shutdown-diagnostics.ts[SE4T]: F:Writes opt-in runtime shutdown phase markers to stderr. | R:- | A:traceRuntimeShutdownPhase | S:Enabled only by MCODE_RUNTIME_SHUTDOWN_DIAGNOSTICS=1. Callers supply static phase names. diff --git a/packages/local-runtime-v2/src/application/session/runtime-services-lifecycle.ts b/packages/local-runtime-v2/src/application/session/runtime-services-lifecycle.ts index 337f1c54e..0ccd20912 100644 --- a/packages/local-runtime-v2/src/application/session/runtime-services-lifecycle.ts +++ b/packages/local-runtime-v2/src/application/session/runtime-services-lifecycle.ts @@ -1,3 +1,4 @@ +import { traceRuntimeShutdownPhase } from "../../infra/shutdown-diagnostics.js"; import type { InitializedCronService } from "../../service/cron/index.js"; import type { InitializedMcpService } from "../../service/mcp/index.js"; import type { RuntimeMiniAppServices } from "../../service/miniapp/index.js"; @@ -212,7 +213,10 @@ export function createRuntimeServicesLifecycle( () => Promise.resolve(input.agentApplication.close()), () => Promise.resolve(input.workspaceGit.close()), () => Promise.resolve(input.sessionSystem.close()), - () => Promise.resolve(input.sandbox.close()), + () => { + traceRuntimeShutdownPhase("close_sandbox"); + return Promise.resolve(input.sandbox.close()); + }, ]; for (const close of closeSteps) { try { diff --git a/packages/local-runtime-v2/src/background-runtime.ts b/packages/local-runtime-v2/src/background-runtime.ts index 78f011707..6398593da 100644 --- a/packages/local-runtime-v2/src/background-runtime.ts +++ b/packages/local-runtime-v2/src/background-runtime.ts @@ -10,6 +10,7 @@ import { } from './infra/runtime-owner/index.js'; import { Scheduler, type SchedulerClient, type SchedulerOptions } from './infra/scheduler/index.js'; import { pruneTransientStorage } from './infra/storage-retention/index.js'; +import { traceRuntimeShutdownPhase } from './infra/shutdown-diagnostics.js'; interface BackgroundRuntimeClients { /** Scheduler is an Electron-owned capability; embedded CLI keeps only the event bus. */ @@ -142,11 +143,13 @@ export async function createBackgroundRuntime( firstError = error; } try { + traceRuntimeShutdownPhase('await_background_maintenance'); await maintenancePromise; } catch (error) { firstError ??= error; } try { + traceRuntimeShutdownPhase('release_runtime_owner'); await runtimeOwnerIdentity.close(); } catch (error) { firstError ??= error; diff --git a/packages/local-runtime-v2/src/infra/shutdown-diagnostics.ts b/packages/local-runtime-v2/src/infra/shutdown-diagnostics.ts new file mode 100644 index 000000000..2ddad4cf0 --- /dev/null +++ b/packages/local-runtime-v2/src/infra/shutdown-diagnostics.ts @@ -0,0 +1,5 @@ +/** Phase markers for a host whose shutdown deadline expires before it returns. */ +export function traceRuntimeShutdownPhase(phase: string): void { + if (process.env.MCODE_RUNTIME_SHUTDOWN_DIAGNOSTICS !== "1") return; + process.stderr.write(`[runtime-shutdown] ${phase}\n`); +} diff --git a/packages/local-runtime-v2/src/runtime.ts b/packages/local-runtime-v2/src/runtime.ts index b43acd4bd..e1d99160e 100644 --- a/packages/local-runtime-v2/src/runtime.ts +++ b/packages/local-runtime-v2/src/runtime.ts @@ -16,6 +16,7 @@ import { createBackgroundRuntime, type BackgroundRuntime, } from "./background-runtime.js"; +import { traceRuntimeShutdownPhase } from "./infra/shutdown-diagnostics.js"; import { cleanupFailedV1Startup, createDeferredAgentRuntimeTelemetry, @@ -958,6 +959,7 @@ async function closeRuntime({ database, }: RuntimeResourceState): Promise { let firstError: unknown; + traceRuntimeShutdownPhase("stop_v1_producers"); await stopV1Producers(v1, (error) => { firstError ??= error; }); @@ -980,16 +982,19 @@ async function closeRuntime({ firstError ??= error; } try { + traceRuntimeShutdownPhase("close_v1_host"); await closeV1?.(); } catch (error) { firstError ??= error; } try { + traceRuntimeShutdownPhase("close_database"); database?.close(); } catch (error) { firstError ??= error; } if (firstError !== undefined) throw firstError; + traceRuntimeShutdownPhase("closed"); } async function closeOwnerResources( @@ -1005,6 +1010,7 @@ async function closeOwnerResources( ]; for (const [cleanupStep, step] of steps) { try { + if (operation === "close") traceRuntimeShutdownPhase(cleanupStep); await step(); } catch (err) { recordError?.(err); diff --git a/packages/webui/test/browser/support/native-browser-host.ts b/packages/webui/test/browser/support/native-browser-host.ts index ec5394006..5d8624fba 100644 --- a/packages/webui/test/browser/support/native-browser-host.ts +++ b/packages/webui/test/browser/support/native-browser-host.ts @@ -17,6 +17,7 @@ await mkdir(workspaceDir); await mkdir(clientDir); await writeFile(path.join(directory, "config.yaml"), "# isolated WebUI native acceptance; no credentials\n"); process.env.MINIMAX_DATA_DIR = directory; +process.env.MCODE_RUNTIME_SHUTDOWN_DIAGNOSTICS = "1"; (await import("@mavis/config")).resetConfig(); // Serve this exact build with the browser harness identity. Config and WebSocket // are still injected by the production service; no synthetic transport is installed. diff --git a/release/public-source.json b/release/public-source.json index 3d33a097d..340e9b5c6 100644 --- a/release/public-source.json +++ b/release/public-source.json @@ -949,6 +949,7 @@ "packages/local-runtime-v2/src/infra/runtime-owner/rootless-v2-generation.ts", "packages/local-runtime-v2/src/infra/runtime-owner/runtime-owner-lease.ts", "packages/local-runtime-v2/src/infra/scheduler/index.ts", + "packages/local-runtime-v2/src/infra/shutdown-diagnostics.ts", "packages/local-runtime-v2/src/infra/sse/bounded-ring.ts", "packages/local-runtime-v2/src/infra/sse/index.ts", "packages/local-runtime-v2/src/infra/sse/subscriber-registry.ts",