diff --git a/.changeset/shared-desktop-service-recovery.md b/.changeset/shared-desktop-service-recovery.md new file mode 100644 index 0000000000..10865742be --- /dev/null +++ b/.changeset/shared-desktop-service-recovery.md @@ -0,0 +1,10 @@ +--- +'@fluentui-react-native/desktop-test': patch +'@fluentui-react-native/desktop-driver': patch +'@fluentui-react-native/storybook-desktop': patch +--- + +Share native service construction between the generic supervisor and Storybook +channel child, wiring private durable settlement recovery, exact application-exit +probes, protected descriptor lifetime and settled shutdown. Keep corrupt sibling +journal records fenced rather than allowing a valid record to mask uncertainty. diff --git a/packages/agentic/desktop-driver/references/current-status.md b/packages/agentic/desktop-driver/references/current-status.md index 871dcc3912..b4d7451557 100644 --- a/packages/agentic/desktop-driver/references/current-status.md +++ b/packages/agentic/desktop-driver/references/current-status.md @@ -19,25 +19,25 @@ and its sub-issues, which record dependencies and parallel waves. ## Capabilities -| Capability | State | Boundary or remaining work | -| ---------------------------------------------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| W3C service and typed/WDIO clients | Done | Registered targets only; native browser-inapplicable commands explicitly unsupported. | -| Application-neutral driver | Done | No Storybook, React, or React Native dependency. Optional story provider is injected. | -| Native sessions and command/input queues | Done | One reservation per registered target in one service. Cross-service exact-application claims remain work in progress. | -| Verified private discovery and grants | Done | Native identity verified before credential transmission; all protected driver routes authenticate. Does not protect the separate Storybook channel. | -| Mutation effects, settlement, quarantine | Done | Native mutations settle before advancing. Uncertain story changes now quarantine instead of assuming a later render is safe. | -| Durable settlement storage and trusted recovery API | Done in library; integration in progress | Requires explicit `recovery` options. Shipped generic/Storybook supervisors do not yet wire them; restart can erase uncertainty. Do not use restart as recovery evidence. | -| Bounded observation, references, paging, deltas | Done | Provider capability/budget checks, explicit completeness and truncation. Reference generation is session-local; reopen after application replacement. | -| Find, action, check, sequence | Done | Up to eight sequence steps; request-id outcomes prevent replay within their retained session history. No replay across service replacement. | -| Capture and artifact pages | Done | Session-bound bounded artifacts and hashes; pixels are opt-in. Screenshots are evidence, not visual comparison. | -| Named accessibility actions | Done in agent operations | WDIO can list actions but has no corresponding named-action invocation command. | -| Story catalog/select/reset | Done, experimental integration | Catalog-only IDs, correlated readiness and marker verification. Delayed/unknown failures fence mutations. | -| Story args on protected driver | Intentionally unsupported | `story-args-unsupported`; legacy unprotected args remain separate. | -| Exclusive Storybook control | Work in progress | Channel selection/prepare ingress can bypass driver authority; out-of-band args/context invalidation is incomplete. | -| Supervisor crash containment and automatic reclaim | Work in progress outside driver | Exact ownership ledger, surviving-resource reconciliation, and lifelines belong to desktop-test. | -| Application-exit/reconnect continuity | Work in progress | No transparent app/session or runtime bridge restoration. Events are advisory, not proof of recovery. | -| Recording/replay export, event-tail API, visual comparison | Work in progress/deferred | No agent-session-to-WDIO export; window-events still returns its full bounded ring. | -| Intel macOS and distributed/remote control | Unsupported | Current macOS helper is arm64; service is loopback-only. | +| Capability | State | Boundary or remaining work | +| ---------------------------------------------------------- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| W3C service and typed/WDIO clients | Done | Registered targets only; native browser-inapplicable commands explicitly unsupported. | +| Application-neutral driver | Done | No Storybook, React, or React Native dependency. Optional story provider is injected. | +| Native sessions and command/input queues | Done | One reservation per registered target in one service. Cross-service exact-application claims remain work in progress. | +| Verified private discovery and grants | Done | Native identity verified before credential transmission; all protected driver routes authenticate. Does not protect the separate Storybook channel. | +| Mutation effects, settlement, quarantine | Done | Native mutations settle before advancing. Uncertain story changes now quarantine instead of assuming a later render is safe. | +| Durable settlement storage and trusted recovery API | Done | Generic/Storybook native paths share the harness factory's private storage and exact-incarnation probes. Direct library embedders must pass `recovery`; restart is not proof. | +| Bounded observation, references, paging, deltas | Done | Provider capability/budget checks, explicit completeness and truncation. Reference generation is session-local; reopen after application replacement. | +| Find, action, check, sequence | Done | Up to eight sequence steps; request-id outcomes prevent replay within their retained session history. No replay across service replacement. | +| Capture and artifact pages | Done | Session-bound bounded artifacts and hashes; pixels are opt-in. Screenshots are evidence, not visual comparison. | +| Named accessibility actions | Done in agent operations | WDIO can list actions but has no corresponding named-action invocation command. | +| Story catalog/select/reset | Done, experimental integration | Catalog-only IDs, correlated readiness and marker verification. Delayed/unknown failures fence mutations. | +| Story args on protected driver | Intentionally unsupported | `story-args-unsupported`; legacy unprotected args remain separate. | +| Exclusive Storybook control | Work in progress | Channel selection/prepare ingress can bypass driver authority; out-of-band args/context invalidation is incomplete. | +| Supervisor crash containment and automatic reclaim | Work in progress outside driver | Exact ownership ledger, surviving-resource reconciliation, and lifelines belong to desktop-test. | +| Application-exit/reconnect continuity | Work in progress | No transparent app/session or runtime bridge restoration. Events are advisory, not proof of recovery. | +| Recording/replay export, event-tail API, visual comparison | Work in progress/deferred | No agent-session-to-WDIO export; window-events still returns its full bounded ring. | +| Intel macOS and distributed/remote control | Unsupported | Current macOS helper is arm64; service is loopback-only. | The approved direction is a stronger `desktop-test` workload host, with native authority here and MCP as a client. No coordinator package or daemon is being diff --git a/packages/agentic/desktop-driver/references/service.md b/packages/agentic/desktop-driver/references/service.md index 281744d35f..279fdf2ceb 100644 --- a/packages/agentic/desktop-driver/references/service.md +++ b/packages/agentic/desktop-driver/references/service.md @@ -336,6 +336,11 @@ does and does not cover. ## Persist quarantines +The generic desktop-test supervisor and Storybook's native channel child use +the shared `@fluentui-react-native/desktop-test/driver-service` factory, which +wires private storage and exact application-incarnation probes by default. +The following explicit options are required only for direct driver embedders. + Pass `recovery` so a target quarantined by an unsettled mutation stays quarantined across a service restart: @@ -362,6 +367,9 @@ await service.recoverTarget('contoso-macos', { evidence: 'operator', quarantineI `evidence: 'operator'` records the operator's own judgment. - Without a probe, an attached application's quarantine lifts only through `recoverTarget`. +- Unreadable storage prevents startup. Any corrupt record, including a corrupt + sibling of an otherwise valid record, quarantines without trusting application + identity; an exit probe cannot clear it. - On Windows, pass `createWindowsApplicationProbe({ artifact })` and `await createWindowsPrivateStorage({ artifact, root })` with the verified Windows native driver artifact. diff --git a/packages/agentic/desktop-driver/src/server/recovery.test.ts b/packages/agentic/desktop-driver/src/server/recovery.test.ts index 7e8ef3d95e..a1067af21d 100644 --- a/packages/agentic/desktop-driver/src/server/recovery.test.ts +++ b/packages/agentic/desktop-driver/src/server/recovery.test.ts @@ -195,6 +195,44 @@ describe('Desktop Driver settlement journal', () => { expect(storage.records.size).toBe(0); }); + test.each(['mutation', 'quarantine'])('a valid sibling cannot hide a corrupt %s record from recovery', async (kind) => { + const storage = new MemoryStorage(); + const service = await startService(storage); + await quarantineByLostClick(service); + await service.harness.close(); + // Lost-response quarantine normally retains only the quarantine record. Add its mutation sibling to exercise both. + const [quarantineName, contents] = [...storage.records.entries()].find(([name]) => name.startsWith('quarantine-'))!; + const record = JSON.parse(contents) as Record; + const mutationName = quarantineName.replace('quarantine-', 'mutation-'); + storage.records.set( + mutationName, + JSON.stringify({ + application: record.application, + command: record.command, + id: record.id, + kind: 'mutation', + sessionId: record.sessionId, + since: record.since, + targetId: record.targetId, + version: 1, + }), + ); + storage.records.set(kind === 'mutation' ? mutationName : quarantineName, '{"corrupt":true}'); + const probe = jest.fn(async (): Promise => 'exited'); + const restarted = await startService(storage, {}, probe); + await expect(restarted.open()).rejects.toMatchObject(quarantinedOnOpen); + const quarantine = restarted.harness.server.sessions.getQuarantine(restarted.harness.target.id)!; + expect(quarantine.application).toBeUndefined(); + await expect( + restarted.harness.server.recoverTarget(restarted.harness.target.id, { + evidence: 'application-exited', + quarantineId: quarantine.id, + }), + ).rejects.toThrow(/not proven/); + expect(probe).not.toHaveBeenCalled(); + expect(storage.records.size).toBe(2); + }); + test('quarantines the target when it cannot record that a mutation settled', async () => { const storage = new MemoryStorage(); const service = await startService(storage); diff --git a/packages/agentic/desktop-driver/src/server/settlementJournal.ts b/packages/agentic/desktop-driver/src/server/settlementJournal.ts index b6f514990b..6d36eb4d1a 100644 --- a/packages/agentic/desktop-driver/src/server/settlementJournal.ts +++ b/packages/agentic/desktop-driver/src/server/settlementJournal.ts @@ -116,25 +116,25 @@ export class SettlementJournal { return undefined; } this.held.set(targetId, { ...(mutation !== undefined ? { mutation } : {}), ...(quarantine !== undefined ? { quarantine } : {}) }); - if (quarantine !== undefined) { - const parsed = parseRecord(quarantineSchema, quarantine, targetId); - if (parsed) { - const { kind: _kind, version: _version, ...record } = parsed; + const parsedQuarantine = quarantine === undefined ? undefined : parseRecord(quarantineSchema, quarantine, targetId); + const parsedMutation = mutation === undefined ? undefined : parseRecord(mutationSchema, mutation, targetId); + // A readable sibling cannot establish which application's effects an unreadable record represents. + const corrupt = (quarantine !== undefined && !parsedQuarantine) || (mutation !== undefined && !parsedMutation); + if (!corrupt) { + if (parsedQuarantine) { + const { kind: _kind, version: _version, ...record } = parsedQuarantine; return record; } - } - if (mutation !== undefined) { - const parsed = parseRecord(mutationSchema, mutation, targetId); - if (parsed) { + if (parsedMutation) { return { - ...(parsed.application ? { application: parsed.application } : {}), - command: parsed.command, + ...(parsedMutation.application ? { application: parsedMutation.application } : {}), + command: parsedMutation.command, effect: 'unknown', - id: parsed.id, + id: parsedMutation.id, message: 'The service stopped before this mutation settled.', origin: 'interrupted', - sessionId: parsed.sessionId, - since: parsed.since, + sessionId: parsedMutation.sessionId, + since: parsedMutation.since, targetId, }; } diff --git a/packages/agentic/desktop-test/AGENTS.md b/packages/agentic/desktop-test/AGENTS.md index 0cd2da0d2f..38b90d9e12 100644 --- a/packages/agentic/desktop-test/AGENTS.md +++ b/packages/agentic/desktop-test/AGENTS.md @@ -25,6 +25,8 @@ and bounded structured output contract. coverage. - Keep published API changes explicit and update the owning reference with the implementation. +- Keep generic and Storybook service composition in `src/driverService.ts`; + never bypass its durable recovery, descriptor lifetime or settled close. ## Validation diff --git a/packages/agentic/desktop-test/README.md b/packages/agentic/desktop-test/README.md index 0a0810397d..d6bd4db16f 100644 --- a/packages/agentic/desktop-test/README.md +++ b/packages/agentic/desktop-test/README.md @@ -65,6 +65,9 @@ when working on the package. artifact directory. - Native helpers are explicitly built or provisioned; normal test runs use verified prebuilt helpers only. +- Generic and Storybook native services share one factory with durable + quarantine storage and exact application-exit probes. Restart does not clear + uncertain effects; see [lifecycle and recovery](references/lifecycle.md). macOS RN Test App users must bundle before `prep`, then build: CocoaPods embeds only resources that exist during `pod install`. Renderer changes require a new diff --git a/packages/agentic/desktop-test/package.json b/packages/agentic/desktop-test/package.json index 5932feb55b..910b5c8418 100644 --- a/packages/agentic/desktop-test/package.json +++ b/packages/agentic/desktop-test/package.json @@ -45,6 +45,11 @@ "import": "./lib/commands.js", "default": "./src/commands.ts" }, + "./driver-service": { + "types": "./lib/driverService.d.ts", + "import": "./lib/driverService.js", + "default": "./src/driverService.ts" + }, "./wdio": { "types": "./lib/wdio/index.d.ts", "import": "./lib/wdio/index.js", diff --git a/packages/agentic/desktop-test/references/contributing.md b/packages/agentic/desktop-test/references/contributing.md index c0e4493605..e663567618 100644 --- a/packages/agentic/desktop-test/references/contributing.md +++ b/packages/agentic/desktop-test/references/contributing.md @@ -9,7 +9,9 @@ owner_paths: Configuration and host adapters live in `src/config.ts` and `src/adapters.ts`; CLI stages are composed in `src/cli.ts`; process ownership is in -`src/supervisor.ts`; reports are implemented in `src/reporting/`; and WDIO +`src/supervisor.ts`; shared native service, recovery, authority, descriptor and +settled shutdown composition lives in the real `src/driverService.ts` module +(also used by the Storybook channel child); reports are implemented in `src/reporting/`; and WDIO session wiring is in `src/wdio/`. Add contract coverage for schema, lifecycle, reporting protocol, and failure diff --git a/packages/agentic/desktop-test/references/current-status.md b/packages/agentic/desktop-test/references/current-status.md index babdf92fea..02fb895fa5 100644 --- a/packages/agentic/desktop-test/references/current-status.md +++ b/packages/agentic/desktop-test/references/current-status.md @@ -17,23 +17,23 @@ and its sub-issues. ## Capability matrix -| Capability | State | Limit or next gate | -| -------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | -| App/suite configuration and standalone installed-app use | Done | Storybook is optional; executable config is trusted operator code, not a sandbox. | -| Native service and helper composition | Done | Generic and Storybook paths still differ; shared factory/policy extraction is pending. | -| Standalone WDIO/Jasmine execution | Done | WDIO owns its session. Storybook CSF callbacks use a runner-owned session borrowed by a Node worker. | -| Required services, reporting, structured results | Done | One collector; bounded JSON/NDJSON summaries. Service-ready is not app/context-ready. | -| `serve --agent` descriptor publication | Done | Protects driver routes; no automatic build/launch from MCP. Normal WDIO cannot use the agent-served path yet. | -| Cleanup failure fence | Done, conservative | Failed cleanup retains `interactive.lock`; manual exact-owner/resource inspection is required. No automatic reclaim. | -| Complete lifecycle settlement | Work in progress | Guarded abandoned work, late acquisitions, exact resource ledger, and report/workload delegation separation need the shared resource model. | -| Durable quarantine wiring | Work in progress | Driver library supports it, but shipped supervisors do not pass recovery storage/probes. Restart is not recovery proof. | -| Supervisor crash containment | Work in progress | Child lifelines, survivor reconciliation, stale-claim protocol, status/stop/recover tooling. | -| Storybook resource contributions | Work in progress | Current integration substitutes its CLI lifecycle; retain the channel/driver child until relocation is justified and qualified. | -| MCP/WDIO handoff | Work in progress | Must await drain/deletion; attached-app handoff is independent of future supervisor-owned launch. | -| Supervisor-owned app lifetime | Work in progress | Current session-owned launch/externally owned attach semantics remain; never silently retain or terminate another owner's app. | -| Cross-service/multi-target claims | Work in progress | Target aliases and input mutexes are not exact-application exclusion; resolve registered-ID collisions before expanding hosts. | -| Bounded persisted run-query/control API | Work in progress | Schemas belong here. Agents may eventually select only declared workload IDs, not commands/paths/environment. | -| Automatic service reuse and per-user daemon | Deferred | Requires exact identity/config matching and evidence of need. Never adopt an unknown port occupant. | +| Capability | State | Limit or next gate | +| -------------------------------------------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | +| App/suite configuration and standalone installed-app use | Done | Storybook is optional; executable config is trusted operator code, not a sandbox. | +| Native service and helper composition | Done | Generic supervisor and supervised Storybook child use the same real `driverService` factory, helper policy, authority and settled close. | +| Standalone WDIO/Jasmine execution | Done | WDIO owns its session. Storybook CSF callbacks use a runner-owned session borrowed by a Node worker. | +| Required services, reporting, structured results | Done | One collector; bounded JSON/NDJSON summaries. Service-ready is not app/context-ready. | +| `serve --agent` descriptor publication | Done | Protects driver routes; no automatic build/launch from MCP. Normal WDIO cannot use the agent-served path yet. | +| Cleanup failure fence | Done, conservative | Failed cleanup retains `interactive.lock`; manual exact-owner/resource inspection is required. No automatic reclaim. | +| Complete lifecycle settlement | Work in progress | Guarded abandoned work, late acquisitions, exact resource ledger, and report/workload delegation separation need the shared resource model. | +| Durable quarantine wiring | Done | Both native service paths use owner-only storage and exact-incarnation probes; restart is not recovery proof. Live endpoint qualification remains separate. | +| Supervisor crash containment | Work in progress | Child lifelines, survivor reconciliation, stale-claim protocol, status/stop/recover tooling. | +| Storybook resource contributions | Work in progress | Current integration substitutes its CLI lifecycle; retain the channel/driver child until relocation is justified and qualified. | +| MCP/WDIO handoff | Work in progress | Must await drain/deletion; attached-app handoff is independent of future supervisor-owned launch. | +| Supervisor-owned app lifetime | Work in progress | Current session-owned launch/externally owned attach semantics remain; never silently retain or terminate another owner's app. | +| Cross-service/multi-target claims | Work in progress | Target aliases and input mutexes are not exact-application exclusion; resolve registered-ID collisions before expanding hosts. | +| Bounded persisted run-query/control API | Work in progress | Schemas belong here. Agents may eventually select only declared workload IDs, not commands/paths/environment. | +| Automatic service reuse and per-user daemon | Deferred | Requires exact identity/config matching and evidence of need. Never adopt an unknown port occupant. | See [lifecycle](lifecycle.md), [commands](commands.md), and `@fluentui-react-native/desktop-driver/references/current-status.md` for the @@ -67,7 +67,7 @@ did not retain a portable raw-report locator; do not imply otherwise. | macOS | Live failed-cleanup and service-restart cases; Paper separately; supervisor death with Metro/channel/helper survivors; exact attached-app preservation. | | Windows / Win32 | Same-branch MCP restart/revocation/dispose/args tests; physical console Ctrl+C; interactive input/capture rerun; process-tree containment and ownership checks. | | Storybook | Authenticated mutation ingress, context fencing/reconnect, consistent helper build policy, manifest provenance and separate nonces. | -| Recovery | Both service paths wire durable uncertainty before claiming crash-safe restart; ledger and exact-resource reconciliation precede automatic reclaim. | +| Recovery | Durable uncertainty is wired in both paths; live restart qualification, ledger and exact-resource reconciliation still precede automatic reclaim. | | Concurrency | No physical-input suites in parallel on one interactive desktop. Separate machines may qualify independent endpoints. | | Reliability | Establish the required repeated-run window rather than interpreting aggregate past successes as a pass. | diff --git a/packages/agentic/desktop-test/references/lifecycle.md b/packages/agentic/desktop-test/references/lifecycle.md index 00277fc8d2..29789f3cf9 100644 --- a/packages/agentic/desktop-test/references/lifecycle.md +++ b/packages/agentic/desktop-test/references/lifecycle.md @@ -35,13 +35,35 @@ There is no automatic stale-lock recovery. Cleanup failure now retains the claim, including a failure to dispose a host after startup failed. A timeout is not proof of settlement and must not release ownership. This conservative fence is not a resource ledger: late work abandoned -by service guards, process-tree survivors, exact resource accounting, durable -quarantine wiring, and crash reconciliation remain work in progress. +by service guards, process-tree survivors, exact resource accounting, and crash +reconciliation remain work in progress. -The driver library can persist settlement uncertainty, but neither shipped -service path currently supplies recovery storage/probes. Restart is therefore -not a safe recovery procedure for uncertain native or Storybook mutations. -Inspect exact resources and follow trusted recovery evidence requirements. +Both native service paths use the real `driverService.ts` composition root +(`@fluentui-react-native/desktop-test/driver-service`). It resolves prebuilt +helpers with `buildPolicy: 'never'`, creates native hosts, loads durable +settlement state before serving, probes the host, then publishes any protected +agent descriptor. Shutdown withdraws the descriptor and revokes its grant +before awaiting the driver listener, session settlement, and host disposal. +The Storybook channel/driver remains a supervised child. + +Recovery uses the platform's validated owner-only private storage, with a +bounded hashed namespace derived from the endpoint and registered target ID. +Ports, run IDs, helper builds, service incarnations, descriptor roots and grants +do not change that namespace. Keep the registered target ID stable across +restarts. An explicit trusted `recovery.root` selects a separate private root; +it must be provisioned with the platform's ownership requirements, never deleted +as disposable run output. Tests and custom hosts can supply `recovery.storage` +and `recovery.probeApplication`; these are operator APIs, not client inputs. + +An unreadable store aborts startup without publishing a descriptor. Corrupt +records quarantine the target without application identity, even when a sibling +record is valid. Only an exact recorded process ID/start-time probe can prove +application exit; native exit events and service death are not proof. +`service.recoverTarget` retains the driver's trusted exact-quarantine-ID +operator API; no new listing, offline recovery command, or model-facing +recovery route is exposed. Automatic stale-claim removal remains unsupported. +Inspect exact resources before explicit operator recovery; restarting alone +never clears uncertain native or Storybook mutations. Keep reporting runs distinct from physical workload claims, resource ownership, application ownership, grants, native sessions, input locks, and context epochs. diff --git a/packages/agentic/desktop-test/src/contracts.contract.cjs b/packages/agentic/desktop-test/src/contracts.contract.cjs index dcc9933d1a..7fef3c4e35 100644 --- a/packages/agentic/desktop-test/src/contracts.contract.cjs +++ b/packages/agentic/desktop-test/src/contracts.contract.cjs @@ -27,6 +27,24 @@ const waitFor = async (condition) => { } }; +function memoryRecovery() { + const records = new Map(); + return { + storage: { + read: async (name) => records.get(name), + publish: async (name, contents) => { + assert(!records.has(name), 'never replace a private record'); + records.set(name, contents); + }, + remove: async (name, contents) => { + if (records.get(name) !== contents) return false; + return records.delete(name); + }, + }, + records, + }; +} + async function main() { const { DesktopRunReporter } = await import(lib('reporting/collector.js')); const { NodeDesktopCommandRunner } = await import(lib('commands.js')); @@ -782,6 +800,7 @@ async function main() { const run = reporter({ kind: 'lifecycle' }); const supervisor = new DesktopSupervisor({ target, + recovery: memoryRecovery(), reporter: run, lockDirectory: path.join(root, 'locks'), hostFactory: async () => new FakeDesktopHost({ endpoint: 'win32', features: { boundedObservation: true } }), @@ -828,6 +847,7 @@ async function main() { const failing = new DesktopSupervisor({ target, + recovery: memoryRecovery(), reporter: reporter({ kind: 'lifecycle' }), lockDirectory: path.join(root, 'locks'), hostFactory: async () => new FakeDesktopHost({ endpoint: 'win32' }), @@ -844,6 +864,7 @@ async function main() { const failedCleanupLocks = path.join(root, 'failed-cleanup-locks'); const failedCleanup = new DesktopSupervisor({ target, + recovery: memoryRecovery(), reporter: reporter({ kind: 'lifecycle' }), lockDirectory: failedCleanupLocks, hostFactory: async () => { @@ -863,7 +884,7 @@ async function main() { assert.throws(() => claimDesktopWorkload('replacement', failedCleanupLocks), /Another desktop workload/); // The Storybook channel child's composition: one service, protected and published from the process that listens. - const { startDesktopService } = await import(lib('supervisor.js')); + const { startDesktopService } = await import(lib('driverService.js')); const { publishDesktopAgent } = await import(lib('agentConnection.js')); const { DesktopAuthority } = await import('@fluentui-react-native/desktop-driver/authority'); const serviceTarget = { endpoint: 'win32', id: 'agent-service', platformName: 'windows', renderer: 'paper', launchModes: ['launch'] }; @@ -882,6 +903,7 @@ async function main() { const servicePublished = []; const service = await startDesktopService(trackedHost(steps), { target: serviceTarget, + recovery: memoryRecovery(), addSecret: (secret) => secrets.push(secret), agent: { descriptor: 'service.json', @@ -911,6 +933,7 @@ async function main() { await assert.rejects( startDesktopService(trackedHost(failedSteps), { target: serviceTarget, + recovery: memoryRecovery(), agent: { publish: async () => { throw new Error('original service publication failure'); @@ -946,6 +969,142 @@ async function main() { release(async () => void lateRemoved++); await new Promise((resolve) => setImmediate(resolve)); assert.equal(lateRemoved, 1, 'a late publication is withdrawn'); + } else if (mode === 'recovery') { + const { DesktopSupervisor } = await import(lib('supervisor.js')); + const { startDesktopService } = await import(lib('driverService.js')); + const { FakeDesktopHost } = await import('@fluentui-react-native/desktop-driver/testing'); + const { createDesktopDriverClient } = await import('@fluentui-react-native/desktop-driver/client'); + const target = { + endpoint: 'win32', + host: { kind: 'installed', ownership: 'external', application: { windowTitle: 'fake' } }, + id: 'durable-target', + instanceId: 'recovery', + projectRoot: packageRoot, + configPath: path.join(root, 'desktop.config.mjs'), + }; + const capabilities = { alwaysMatch: { platformName: 'windows', 'furn:target': target.id, 'furn:launchMode': 'attach' } }; + const quarantined = (error) => error.data?.reason === 'target-quarantined'; + const uncertain = (error) => error.data?.mutation?.quarantined === true; + for (const firstPath of ['supervisor', 'channel']) { + const recovery = memoryRecovery(); + let state = 'running'; + const probed = []; + recovery.probeApplication = async (application) => { + probed.push(application); + return state; + }; + const start = async (servicePath) => { + const host = new FakeDesktopHost({ endpoint: 'win32' }); + if (servicePath === 'channel') { + const server = await startDesktopService(host, { + target: { endpoint: target.endpoint, id: target.id, platformName: 'windows', launchModes: ['attach'] }, + recovery, + }); + return { server, host, close: () => server.close() }; + } + const supervisor = new DesktopSupervisor({ + target, + recovery, + reporter: reporter({ kind: 'lifecycle' }), + lockDirectory: path.join(root, `locks-${firstPath}`), + hostFactory: async () => host, + }); + await supervisor.start(); + return { server: supervisor.server, host, close: () => supervisor.close() }; + }; + let service = await start(firstPath); + const open = () => createDesktopDriverClient({ url: service.server.url }).newSession(capabilities); + try { + const session = await open(); + const button = await session.findElement('accessibility id', 'button-primary'); + service.host.injectFault('click', { mode: 'lost-response' }); + service.server.sessions.get(session.id).desktopTimeouts.nativeCommand = 10; + await assert.rejects(button.click(), uncertain); + assert(recovery.records.size > 0, 'quarantine must be durable before responding'); + await service.close(); + + service = await start(firstPath === 'supervisor' ? 'channel' : 'supervisor'); + await assert.rejects(open(), quarantined, 'replacement composition cannot forget uncertain attached-target effects'); + const record = service.server.sessions.getQuarantine(target.id); + assert.deepEqual(probed.at(-1), { processId: 1000, processStartedAt: new Date(0).toISOString() }); + state = 'unknown'; + await assert.rejects( + service.server.recoverTarget(target.id, { evidence: 'application-exited', quarantineId: record.id }), + /not proven/, + ); + await assert.rejects(open(), quarantined); + state = 'exited'; + await service.server.recoverTarget(target.id, { evidence: 'application-exited', quarantineId: record.id }); + assert.equal(recovery.records.size, 0); + const recovered = await open(); + await recovered.delete(); + await service.close(); + + // A malformed journal never becomes absence, even when the probe claims exit. + const seed = await start(firstPath); + service = seed; + const seeded = await open(); + const element = await seeded.findElement('accessibility id', 'button-primary'); + seed.host.injectFault('click', { mode: 'lost-response' }); + seed.server.sessions.get(seeded.id).desktopTimeouts.nativeCommand = 10; + await assert.rejects(element.click()); + await seed.close(); + for (const name of recovery.records.keys()) recovery.records.set(name, '{"invalid":true}'); + service = await start(firstPath === 'supervisor' ? 'channel' : 'supervisor'); + await assert.rejects(open(), quarantined); + const corrupt = service.server.sessions.getQuarantine(target.id); + assert.equal(corrupt.application, undefined); + await assert.rejects( + service.server.recoverTarget(target.id, { evidence: 'application-exited', quarantineId: corrupt.id }), + /not proven/, + ); + } finally { + await service.close(); + } + } + + let disposed = 0; + let published = 0; + const host = new FakeDesktopHost({ endpoint: 'win32' }); + host.dispose = async () => void disposed++; + await assert.rejects( + startDesktopService(host, { + target: { endpoint: 'win32', id: target.id, platformName: 'windows' }, + recovery: { + storage: { + ...memoryRecovery().storage, + read: async () => { + throw new Error('inaccessible recovery'); + }, + }, + }, + agent: { + publish: async () => { + published++; + return async () => undefined; + }, + }, + }), + /inaccessible recovery/, + ); + assert.equal(disposed, 1); + assert.equal(published, 0, 'unreadable recovery must fail before descriptor publication'); + + let settle; + const settling = new Promise((resolve) => (settle = resolve)); + const settlingHost = new FakeDesktopHost({ endpoint: 'win32' }); + settlingHost.dispose = () => settling; + const service = await startDesktopService(settlingHost, { + target: { endpoint: 'win32', id: target.id, platformName: 'windows' }, + recovery: memoryRecovery(), + }); + let closed = false; + const closing = service.close().then(() => (closed = true)); + assert.equal(service.close(), service.close(), 'shutdown is one settled operation'); + await new Promise((resolve) => setTimeout(resolve, 20)); + assert.equal(closed, false, 'shutdown must await disposal, not just listener closure'); + settle(); + await closing; } else if (mode === 'agent-cli') { const { createDesktopReportSession } = await import(lib('reporting/session.js')); // serve --agent passes the agent options to an integration that serves agents, and rejects one that does not. @@ -1086,6 +1245,7 @@ async function main() { }; const supervisor = new DesktopSupervisor({ target, + recovery: memoryRecovery(), reporter: run, lockDirectory: path.join(root, 'locks'), hostFactory: async () => host, @@ -1127,6 +1287,7 @@ async function main() { await supervisor.start(); const duplicate = new DesktopSupervisor({ target, + recovery: memoryRecovery(), reporter: run, lockDirectory: path.join(root, 'locks'), hostFactory: async () => host, diff --git a/packages/agentic/desktop-test/src/contracts.test.ts b/packages/agentic/desktop-test/src/contracts.test.ts index 078d8430c3..559708c809 100644 --- a/packages/agentic/desktop-test/src/contracts.test.ts +++ b/packages/agentic/desktop-test/src/contracts.test.ts @@ -15,6 +15,7 @@ describe('neutral desktop harness contracts', () => { 'services', 'owned-service', 'agent', + 'recovery', 'agent-cli', 'wdio', 'typescript', diff --git a/packages/agentic/desktop-test/src/driverService.ts b/packages/agentic/desktop-test/src/driverService.ts new file mode 100644 index 0000000000..6dd4d71c6a --- /dev/null +++ b/packages/agentic/desktop-test/src/driverService.ts @@ -0,0 +1,157 @@ +import { createHash } from 'node:crypto'; + +import { NativeDesktopHost, resolveNativeDesktopDriver } from '@fluentui-react-native/desktop-driver'; +import type { DesktopHost, DesktopTarget, NativeDesktopHostOptions, NativeDriverArtifact } from '@fluentui-react-native/desktop-driver'; +import { + createMacOSApplicationProbe, + createMacOSPrivateStorage, + createWindowsApplicationProbe, + createWindowsPrivateStorage, + DesktopAuthority, +} from '@fluentui-react-native/desktop-driver/authority'; +import type { PrivateStorage } from '@fluentui-react-native/desktop-driver/authority'; +import { createDesktopDriverServer } from '@fluentui-react-native/desktop-driver/server'; +import type { DesktopDriverServer, ProbeApplication } from '@fluentui-react-native/desktop-driver/server'; +import { publishDesktopAgent } from './agentConnection.js'; +import type { DesktopAgentConnectionOptions, DesktopAgentPublication, DesktopAgentTarget } from './agentConnection.js'; + +export type DesktopServiceOptions = { + target: Omit; + port?: number; + host?: string; + /** Protects every route and publishes a descriptor only after the host and listener are ready. */ + agent?: DesktopAgentConnectionOptions; + /** Trusted storage/probe overrides. Omitted, use platform owner-only storage and the verified native helper. */ + recovery?: { + root?: string; + storage?: PrivateStorage; + probeApplication?: ProbeApplication; + }; + addSecret?: (secret: string) => void; + signal?: AbortSignal; + guard?: (work: Promise) => Promise; + /** Optional application-specific target context; native authority remains in the driver. */ + createTarget?: (host: DesktopHost) => Promise | undefined>; +}; + +export type DesktopService = DesktopDriverServer & { readonly agentDescriptor?: string }; + +export type NativeDesktopServiceOptions = Omit & + DesktopServiceOptions & { + artifact?: NativeDriverArtifact; + nativeDriver?: DesktopAgentTarget['nativeDriver']; + }; + +/** Normal service startup never builds a helper. Storybook may supply its already resolved artifact. */ +export async function startNativeDesktopService(options: NativeDesktopServiceOptions): Promise { + const artifact = + options.artifact ?? + (await resolveNativeDesktopDriver({ + ...options.nativeDriver, + platform: options.endpoint, + buildPolicy: 'never', + signal: options.signal, + })); + return startDesktopService(new NativeDesktopHost({ ...options, artifact }), options, artifact); +} + +/** One composition root for the generic supervisor and the supervised Storybook channel child. */ +export async function startDesktopService( + desktopHost: DesktopHost, + options: DesktopServiceOptions, + artifact?: NativeDriverArtifact, +): Promise { + const authority = options.agent ? new DesktopAuthority() : undefined; + let server: DesktopDriverServer | undefined; + let publication: DesktopAgentPublication | undefined; + try { + const target = { ...options.target, ...(await options.createTarget?.(desktopHost)), host: desktopHost }; + const recovery = await resolveRecovery(options, artifact); + options.signal?.throwIfAborted(); + server = await createDesktopDriverServer({ + ...(authority ? { authority } : {}), + host: options.host, + port: options.port, + recovery, + targets: [target], + }); + await desktopHost.probe(options.signal); + options.signal?.throwIfAborted(); + if (options.agent) { + publication = await publishDesktopAgent({ + authority: authority!, + connection: options.agent, + target: { endpoint: options.target.endpoint, id: options.target.id }, + url: server.url, + ...(artifact ? { artifact } : {}), + addSecret: options.addSecret, + signal: options.signal, + guard: options.guard, + }); + } + } catch (error) { + try { + if (server) await server.close(); + else await desktopHost.dispose(); + } catch (cleanup) { + throw new AggregateError([error, cleanup], 'Desktop service startup and disposal failed.'); + } + throw error; + } + const listening = server; + let closing: Promise | undefined; + return { + ...listening, + get agentDescriptor() { + return closing ? undefined : publication?.descriptor; + }, + close: () => + (closing ??= (async () => { + const failures: unknown[] = []; + for (const step of [async () => publication?.withdraw(), () => listening.close()]) { + try { + await step(); + } catch (error) { + failures.push(error); + } + } + if (failures.length === 1) throw failures[0]; + if (failures.length) throw new AggregateError(failures, 'Agent withdrawal and settled service close failed.'); + })()), + }; +} + +async function resolveRecovery( + options: DesktopServiceOptions, + artifact?: NativeDriverArtifact, +): Promise<{ storage: PrivateStorage; probeApplication?: ProbeApplication }> { + if (options.recovery?.storage && options.recovery.root !== undefined) + throw new TypeError('Desktop recovery accepts a storage adapter or a root, not both.'); + const endpoint = options.target.endpoint; + let storage = options.recovery?.storage; + let probeApplication = options.recovery?.probeApplication; + if (!storage) { + if (endpoint === 'macos') storage = await createMacOSPrivateStorage(options.recovery?.root); + else { + if (!artifact) throw new Error('Windows recovery storage requires a verified native helper or a trusted storage adapter.'); + storage = await createWindowsPrivateStorage({ artifact, root: options.recovery?.root }); + } + } + if (!probeApplication && artifact) + probeApplication = endpoint === 'macos' ? createMacOSApplicationProbe({ artifact }) : createWindowsApplicationProbe({ artifact }); + + // Neither service incarnations, grants, listener ports, nor report runs may change the recovery identity. + const prefix = `settlement-${createHash('sha256') + .update(JSON.stringify([endpoint, options.target.id])) + .digest('hex') + .slice(0, 24)}-`; + const privateStorage = storage; + return { + storage: { + read: (name) => privateStorage.read(prefix + name), + publish: (name, contents) => privateStorage.publish(prefix + name, contents), + remove: (name, contents) => privateStorage.remove(prefix + name, contents), + }, + ...(probeApplication ? { probeApplication } : {}), + }; +} diff --git a/packages/agentic/desktop-test/src/index.ts b/packages/agentic/desktop-test/src/index.ts index 152814f41c..946718dc9b 100644 --- a/packages/agentic/desktop-test/src/index.ts +++ b/packages/agentic/desktop-test/src/index.ts @@ -1,5 +1,7 @@ -export { claimDesktopWorkload, DesktopSupervisor, startNativeDesktopService } from './supervisor.js'; -export type { DesktopServiceOptions, DesktopSupervisorOptions } from './supervisor.js'; +export { claimDesktopWorkload, DesktopSupervisor } from './supervisor.js'; +export type { DesktopSupervisorOptions } from './supervisor.js'; +export { startNativeDesktopService } from './driverService.js'; +export type { DesktopServiceOptions } from './driverService.js'; export { createNativeAgentPublisher, defaultAgentDescriptor } from './agentConnection.js'; export type { DesktopAgentConnection, diff --git a/packages/agentic/desktop-test/src/supervisor.ts b/packages/agentic/desktop-test/src/supervisor.ts index fd207976da..4249c82ea6 100644 --- a/packages/agentic/desktop-test/src/supervisor.ts +++ b/packages/agentic/desktop-test/src/supervisor.ts @@ -3,17 +3,10 @@ import os from 'node:os'; import path from 'node:path'; import { createHash } from 'node:crypto'; -import { createDesktopDriverServer, NativeDesktopHost, resolveNativeDesktopDriver } from '@fluentui-react-native/desktop-driver'; -import type { - DesktopDriverServer, - DesktopHost, - DesktopTarget, - NativeDesktopHostOptions, - NativeDriverArtifact, -} from '@fluentui-react-native/desktop-driver'; -import { DesktopAuthority } from '@fluentui-react-native/desktop-driver/authority'; -import { publishDesktopAgent } from './agentConnection.js'; -import type { DesktopAgentConnectionOptions, DesktopAgentPublication } from './agentConnection.js'; +import type { DesktopDriverServer, DesktopHost } from '@fluentui-react-native/desktop-driver'; +import type { DesktopAgentConnectionOptions } from './agentConnection.js'; +import { startDesktopService, startNativeDesktopService } from './driverService.js'; +import type { DesktopService, DesktopServiceOptions } from './driverService.js'; import type { DesktopCommand, ResolvedDesktopTarget } from './config.js'; import type { DesktopIntegration } from './integration.js'; import { NodeDesktopCommandRunner, deadline } from './commands.js'; @@ -38,6 +31,7 @@ export type DesktopSupervisorOptions = { * ready. Every route then requires a grant, so only clients given one, such as the Desktop Driver MCP adapter, connect. */ agent?: DesktopAgentConnectionOptions; + recovery?: DesktopServiceOptions['recovery']; }; export class DesktopSupervisor { @@ -45,14 +39,11 @@ export class DesktopSupervisor { readonly target: ResolvedDesktopTarget; readonly runner: NodeDesktopCommandRunner; readonly services: DesktopServiceScope; - private serverValue?: DesktopDriverServer; + private serverValue?: DesktopService; private transport?: ReportTransport; private opened = false; private releaseClaim?: () => void; private closePromise?: Promise; - private artifact?: NativeDriverArtifact; - private authority?: DesktopAuthority; - private agentPublication?: DesktopAgentPublication; private ownershipUncertain = false; private readonly environment: Record = {}; private readonly workers = new Set(); @@ -74,7 +65,7 @@ export class DesktopSupervisor { /** The record name of the published agent connection descriptor, once it is published. */ get agentDescriptor(): string | undefined { - return this.agentPublication?.descriptor; + return this.serverValue?.agentDescriptor; } async open(interactive = true): Promise { @@ -101,44 +92,36 @@ export class DesktopSupervisor { await this.open(); try { await this.startConfiguredServices(); - const host = this.options.hostFactory ? await this.options.hostFactory(this.target) : await this.createHost(); - try { - const extension = await this.options.integration?.createTarget?.({ host, target: this.target, reporter: this.reporter }); - if (this.options.agent) this.authority = new DesktopAuthority(); - this.serverValue = await createDesktopDriverServer({ - ...(this.authority ? { authority: this.authority } : {}), - targets: [ - { - endpoint: this.target.endpoint, - id: this.target.id, - platformName: this.target.endpoint === 'macos' ? 'macos' : 'windows', - renderer: this.target.host.renderer, - launchTimeoutMs: this.target.launchTimeoutMs, - launchModes: this.target.host.ownership === 'external' ? ['attach'] : ['launch'], - host, - ...extension, - }, - ], - }); - await host.probe(this.services.controller.signal); - } catch (error) { - if (!this.serverValue) { - try { - await host.dispose(); - } catch (cleanup) { - this.ownershipUncertain = true; - throw new AggregateError([error, cleanup], 'Desktop target startup and disposal failed.'); - } - } - throw error; + const options: DesktopServiceOptions = { + target: { + endpoint: this.target.endpoint, + id: this.target.id, + platformName: this.target.endpoint === 'macos' ? 'macos' : 'windows', + renderer: this.target.host.renderer, + launchTimeoutMs: this.target.launchTimeoutMs, + launchModes: this.target.host.ownership === 'external' ? ['attach'] : ['launch'], + }, + agent: this.options.agent, + recovery: this.options.recovery, + signal: this.services.controller.signal, + guard: (work) => this.services.guard(work), + addSecret: (secret) => this.reporter.addSecret(secret), + createTarget: (host) => + this.options.integration?.createTarget?.({ host, target: this.target, reporter: this.reporter }) ?? Promise.resolve(undefined), + }; + if (this.options.hostFactory) { + const host = await this.options.hostFactory(this.target); + this.serverValue = await startDesktopService(host, options); + } else { + this.serverValue = await this.createService(options); } this.reporter.emit( { kind: 'service-ready', payload: { message: `WebDriver ${this.server.url}; target ${this.target.id}` } }, 'webdriver', { endpoint: this.target.endpoint, renderer: this.target.host.renderer }, ); - if (this.options.agent) await this.publishAgentConnection(this.options.agent); } catch (error) { + if (error instanceof AggregateError) this.ownershipUncertain = true; this.reporter.fail(error); try { await this.close(); @@ -149,23 +132,6 @@ export class DesktopSupervisor { } } - private async publishAgentConnection(options: DesktopAgentConnectionOptions): Promise { - this.agentPublication = await publishDesktopAgent({ - authority: this.authority!, - connection: options, - target: this.target, - url: this.server.url, - ...(this.artifact ? { artifact: this.artifact } : {}), - addSecret: (secret) => this.reporter.addSecret(secret), - signal: this.services.controller.signal, - guard: (work) => this.services.guard(work), - }); - this.reporter.emit({ - kind: 'diagnostic', - payload: { level: 'info', message: `Published agent connection ${this.agentPublication.descriptor} for target ${this.target.id}` }, - }); - } - async startConfiguredServices(): Promise { for (const service of this.target.services ?? []) { this.services.start(service.id, this.prepare(service.command, service.id)); @@ -173,22 +139,16 @@ export class DesktopSupervisor { } } - private async createHost(): Promise { + private async createService(options: DesktopServiceOptions): Promise { const requiredOS = this.target.endpoint === 'macos' ? 'darwin' : 'win32'; if (process.platform !== requiredOS) throw new Error(`Endpoint ${this.target.endpoint} requires ${requiredOS}; native helpers cannot run on ${process.platform}.`); const application = await resolveDesktopApplication(this.target, this.services.controller.signal); if (application.leaseNonce) this.reporter.addSecret(application.leaseNonce); - const artifact = await resolveNativeDesktopDriver({ - ...this.target.nativeDriver, - platform: this.target.endpoint, - buildPolicy: 'never', - signal: this.services.controller.signal, - }); - this.artifact = artifact; - return new NativeDesktopHost({ + return startNativeDesktopService({ + ...options, application, - artifact, + nativeDriver: this.target.nativeDriver, endpoint: this.target.endpoint, onStderr: (text) => this.reporter.emit({ kind: 'output', payload: { stream: 'stderr', text } }, 'native-helper', { @@ -250,9 +210,6 @@ export class DesktopSupervisor { }; for (const worker of this.workers) await close('worker', () => worker.stop({ failed: true })); this.workers.clear(); - const publication = this.agentPublication; - this.agentPublication = undefined; - if (publication) await close('agent-descriptor', () => publication.withdraw()); if (this.serverValue) await close('webdriver', () => deadline(this.serverValue!.close(), 30_000, 'Closing desktop sessions')); await close('services', () => this.services.close()); await close('commands', () => this.runner.close()); @@ -270,87 +227,6 @@ export class DesktopSupervisor { } } -export type DesktopServiceOptions = { - target: Omit; - port?: number; - host?: string; - /** - * Protects the service with a grant authority and publishes one agent's connection descriptor once it listens. Every - * route then requires a grant. Closing the service withdraws the descriptor and revokes the grant before the listener. - */ - agent?: DesktopAgentConnectionOptions; - /** Receives secrets the service issues, such as the agent grant, so reporters redact them. */ - addSecret?: (secret: string) => void; - signal?: AbortSignal; -}; - -/** Transitional composition for Storybook's channel child; lifecycle policy remains owned by desktop-test. */ -export async function startNativeDesktopService(options: NativeDesktopHostOptions & DesktopServiceOptions): Promise { - return startDesktopService(new NativeDesktopHost(options), options, options.artifact); -} - -/** Serves one target on the given host, and disposes the host if the service cannot start. */ -export async function startDesktopService( - desktopHost: DesktopHost, - options: DesktopServiceOptions, - artifact?: NativeDriverArtifact, -): Promise { - const authority = options.agent ? new DesktopAuthority() : undefined; - let server: DesktopDriverServer; - try { - server = await createDesktopDriverServer({ - ...(authority ? { authority } : {}), - host: options.host, - port: options.port, - targets: [{ ...options.target, host: desktopHost }], - }); - } catch (error) { - try { - await desktopHost.dispose(); - } catch (cleanup) { - throw new AggregateError([error, cleanup], 'Native listener startup and disposal failed.'); - } - throw error; - } - if (!options.agent) return server; - let publication: DesktopAgentPublication; - try { - publication = await publishDesktopAgent({ - authority: authority!, - connection: options.agent, - target: { endpoint: options.target.endpoint, id: options.target.id }, - url: server.url, - ...(artifact ? { artifact } : {}), - ...(options.addSecret ? { addSecret: options.addSecret } : {}), - ...(options.signal ? { signal: options.signal } : {}), - }); - } catch (error) { - try { - await server.close(); - } catch (cleanup) { - throw new AggregateError([error, cleanup], 'Agent publication and service cleanup failed.'); - } - throw error; - } - let closing: Promise | undefined; - return { - ...server, - close: () => - (closing ??= (async () => { - const failures: unknown[] = []; - for (const step of [() => publication.withdraw(), () => server.close()]) { - try { - await step(); - } catch (error) { - failures.push(error); - } - } - if (failures.length === 1) throw failures[0]; - if (failures.length) throw new AggregateError(failures, 'Agent withdrawal and service close failed.'); - })()), - }; -} - export function claimDesktopWorkload(runId: string, directory?: string): () => void { const user = createHash('sha256').update(os.homedir()).digest('hex').slice(0, 16); const root = directory ?? path.join(os.tmpdir(), `furn-desktop-workload-${user}`); diff --git a/packages/agentic/storybook-desktop/config/server.cjs b/packages/agentic/storybook-desktop/config/server.cjs index c2a66bda7a..99421e224d 100644 --- a/packages/agentic/storybook-desktop/config/server.cjs +++ b/packages/agentic/storybook-desktop/config/server.cjs @@ -16,7 +16,7 @@ async function startDesktopStorybookServer({ const requireFromProject = createRequire(path.join(projectRoot, 'package.json')); const { createChannelServer } = requireFromProject('@storybook/react-native/node'); const [{ startNativeDesktopService }, { createDesktopReportSession }] = await Promise.all([ - import('@fluentui-react-native/desktop-test'), + import('@fluentui-react-native/desktop-test/driver-service'), import('@fluentui-react-native/desktop-test/reporting'), ]); const report = await createDesktopReportSession({ artifactsRoot: path.join(projectRoot, 'artifacts', 'desktop'), kind: 'lifecycle' }); diff --git a/packages/agentic/storybook-desktop/references/contributing.md b/packages/agentic/storybook-desktop/references/contributing.md index a87ef80506..207be56c30 100644 --- a/packages/agentic/storybook-desktop/references/contributing.md +++ b/packages/agentic/storybook-desktop/references/contributing.md @@ -12,6 +12,11 @@ extraction and target identity live under `src/driver/`; command lifecycle and service ownership live under `src/cli/`; CSF callback extraction and worker execution live under `src/testing/`. +The channel child in `config/server.cjs` constructs its native driver through +`@fluentui-react-native/desktop-test/driver-service`. Keep recovery storage, +helper policy, authority, descriptor publication and settled driver shutdown +in that shared harness implementation, not a parallel Storybook copy. + Keep story callbacks statically extractable and authentication checks fail-closed. Update references when commands, supported config, outputs, or readiness contracts change.