Shared Monaco deferred-creation lifetime
Scope is only shared MonacoEditor, its existing monaco-init.js adapter, a new MonacoCreationLifetimeTests class, a bounded JavaScript browser harness, and this evidence. No protocol, caller, default, marker payload, authoritative text, endpoint or package change is made.
The new presentation keys required by caller target isolation exposed an existing creation race: createEditor awaits the AMD loader while _initialized remains false. Disposal previously skipped JS cleanup in that state and retired the DotNetObjectReference. The late JS continuation then created an editor for a retired host, installed it in the editor map and scheduled diagnostics against the retired reference.
The component now tracks only in-progress initialization as well as completed initialization for disposal. It sends the existing JS dispose request for either state, remains uninitialized when the creation continuation finishes after disposal, and rejects later render work. Completed initialization failure keeps its original cleanup/exception behavior; no unconditional dispose call is added to failed/static initialization. Component disposal is idempotent.
The JS adapter stores pending creation identities, removes them during dispose even when no editor exists yet, and validates that the same attempt is still current before creating an editor. The host must be connected both before starting the loader and after it resolves. Creation after the loader is synchronous, so the attempt is removed before the existing editor setup proceeds. Existing live editor disposal, diagnostic timer/abort cleanup, sync/blur/oversize handling and marker checks remain unchanged. No permanent retired-ID set or growth per closed editor is introduced.
Red and green
red.trx: one meaningful managed failure, zero skips. A real rendered component, with createEditor held by strict bUnit interop, was disposed before creation completed; no cancellation had been sent.green.trx: 30 passed, zero failed/skipped across the new creation lifetime case and the six preceding read-only/accessibility/disposal/sync/source/equipment classes. The new case awaits the actual initial-render continuation through a test-only derived component; it proves pending cancellation uses the original ID, no later option update occurs and GetValue remains the pre-initialization bound-value path after retirement. No production seam is added.js-red.json: actual production monaco-init.js executed in Chromium with deferred synthetic AMD/Monaco APIs. Both disposed-during-loader and detached-during-loader scenes created an orphan, performed a diagnostic request and called the retired DotNet reference after 550ms. The live control passed.js-green.json: three scenes passed /17 checks. Both retired scenes now create zero editors, issue zero diagnostic requests/callbacks and have no mapped value; the live editor still exposes its value, forwards readOnly true/false through actual updateOptions and disposes exactly once. All page-error lists are empty.
The JS harness uses the unchanged production adapter with a synthetic Monaco API, not the actual Monaco implementation. It proves pending registration, option forwarding and timer cleanup, not native Monaco typing, focus, rendering or assistive technology. It intercepts the sole local AMD loader request and uses no application host or external network. The modal worker owns native actual-Monaco pending/recovery acceptance.
Two initial JavaScript harness attempts are retained honestly: the first accidentally awaited the pending creation promise before releasing its loader; the second lacked a loopback base URL for the synthetic document's relative loader. They were interrupted/corrected before the meaningful red scenes. They are not product failures. The final harness supplies a loopback base URL and defers/release-controls the AMD callback without awaiting creation prematurely.
All managed tests used the mandatory private owned-loopback SQL runner even for filtered discovery. No private state/credential content was read or copied. Isolated artifacts are repository-anchored under artifacts/ot13-monaco-lifetime; package/framework versions are unchanged.
Reproduce from the OtOpcUa repository root:
python3 infra/tools/ui-consistency/check_monaco_lifetime.py --output docs/ui-consistency/evidence/ot13-monaco-lifetime/js-green.json
python3 infra/tools/ui-consistency/with_private_sql.py --state "$OT_PRIVATE_SQL_STATE" -- dotnet test tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.csproj -c Debug --artifacts-path artifacts/ot13-monaco-lifetime --filter 'FullyQualifiedName~MonacoCreationLifetimeTests|FullyQualifiedName~MonacoReadOnlyTests|FullyQualifiedName~MonacoAccessibilityTests|FullyQualifiedName~MonacoEditorDisposeTests|FullyQualifiedName~MonacoSyncTests|FullyQualifiedName~MonacoInteropSourceTests|FullyQualifiedName~EquipTokenEditorTests' --logger 'trx;LogFileName=green.trx' --results-directory docs/ui-consistency/evidence/ot13-monaco-lifetime
No host/service/container lifecycle was changed by this slice. The browser context closes after each synthetic run. Whole-consumer integration and native modal acceptance remain separate OT13/OT14 gates.