Repository navigation
refactor(harmonyos): ship HarmonyOS as the managed platform plugin - #4857
Conversation
Size Report
Startup median (7 runs, lower is better):
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on ef1b664. The verdict and the full list are in the summary comment.
|
The packed HarmonyOS plugin at ef1b664 spawns packages/platform-harmonyos/src/hdc.ts:31: The plugin bundles its own copy of Could the plugin own its toolchain PATH end to end? In The one lower-priority open inline thread (the Not blocking, and each can be taken or left: the two recorder tests were deleted rather than moved with Also required before merge, as live evidence for a device-facing move: index.ts:643 moves all HarmonyOS device dispatch, interaction, lifecycle and capture into a separately bundled plugin, and no live run is attached. Install the packed plugin with Not verified here: the packed plugin was not built or run against a stub |
ef1b664 to
8ba31dc
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 8ba31dc. The verdict and the full list are in the summary comment.
8ba31dc to
0c2188a
Compare
|
Rule: every process the plugin spawns and every diagnostic it emits goes through the The plugin now has one command route: Two host ports had to be minted rather than reached for: Enforcement: Validation: |
|
Simplification question (could the plugin own its toolchain PATH end to end?) — taken, at 0c2188a.
What is deliberately not here: merging web, Vega and HarmonyOS into one family-keyed selection, which waits on #4597 as you said. And the |
|
Validation with a packed-plugin test driving an interaction through a stub
Live evidence — blocker, not skipped. Non-blocking notes: taken — the two recorder behaviours are back as |
|
The web and Vega runtime import sites listed in the reply above are tracked in #4862 (same bundled host-kit fault in the two platform plugins already merged). Not changed in this PR. |
This comment has been minimized.
This comment has been minimized.
|
This follow-up on the earlier review covers 0c2188a: the code findings from ef1b664 are fixed, but the live HarmonyOS run that #4317 requires is still missing. The evidence file shows only a stub-hdc run, and it says no device or emulator was reachable. This PR moves all HarmonyOS dispatch, interaction, lifecycle and capture into a separately bundled plugin, so it is a device-facing change. The stub proves routing, PATH and request-scoped tracing. It cannot catch real-device differences such as layout shape, Not blocking, and fine to take or leave: the evidence file says the same sequence runs as a gate in package-smoke.mjs, but the smoke runs only devices, open, press and close, so either add Both open inline threads no longer apply at this head and can be resolved: the test no longer assigns into Smoke Tests (macos) and Build 0.22.0-nightly are still running, one more check is queued, and none has failed. The smoke job runs the Not verified here: the packed bundle contents, the unit, smoke and layering tests (judged from reading them), the stub run and |
|
Optional items from the
The live-run requirement is untouched and left for the maintainer as the waiver question it is. Verified at this head: |
This comment has been minimized.
This comment has been minimized.
|
At 327e188, the earlier findings from the first review are fixed. One high-priority defect remains in the release path. packages/platform-harmonyos/package.json still declares Could CI is green: 31 checks, none failing. No conflicts. Not verified here: package-smoke and the tests were not run locally, and no real HarmonyOS device or |
|
On Yes, it is the intended 0.22 staging, and it is the same for the other managed plugins. On The review's concern is right as a release risk: a 0.22 release cut before the flip removes the built-in family and publishes no plugin. That is now tracked as a release gate in #4866, for all of these packages together, with a check so the release cannot name an install package it does not publish. The flag is not changed in this PR. Waiting for the maintainer on this and on the live-run waiver. |
|
The staging answer settles the manifest point from the review at 327e188: The one remaining item before merge is the live HarmonyOS run of the packed plugin, or a maintainer waiver for it. |
The packed core no longer answers for the HarmonyOS family. `@agent-device/harmonyos` is a managed optional platform plugin like the web and Vega plugins: the composition resolves it through the same one-shot module selection, and a request that names `--platform harmonyos` without it answers `plugin-not-installed` with its install command, while unfiltered discovery and doctor skip the family. The family's mechanics move with it. HDC device discovery, the ArkUI interactor, interaction handlers, app lifecycle and logs, the toolchain probe, the plugin-owned HDC screen recorder and the RSS memory sampler all live in the package now; the plugin reads the documented toolchain roots from the host environment the composition hands it and never touches `process.env`. Core keeps only the canonical platform vocabulary.
The HarmonyOS plugin rebuilt the live recording snapshot field for field, so the shape now comes from capture-kit and the plugin names only its recorder.
Every process spawn and diagnostic in @agent-device/harmonyos now goes through the PlatformHost the core hands setup(): one command runner and one HDC route are built there and handed to inventory, runtime, interactor, recorder and doctor, so the packed bundle carries no separate host-kit command or diagnostics scope. The layering policy bans those two runtime scopes for every managed platform package, with the web and Vega files that still import them registered as their own migration slices. The HarmonyOS facade stays metadata-eager, the core's toolchain preparer is android-only, and the packed-plugin smoke test drives discovery, launch, snapshot, a press, capture and close against a stub HDC reachable only through HDC_SDK_PATH.
The facade said the toolbox binds on first use while `setup` built it immediately, so the resolution is now lazy and memoized per setup: a setup that never runs a command imports and builds nothing, and the operations of one setup still share the one toolbox that binds its host. One toolchain root probe per spawn instead of two: `resolveHdc` read a Promise of the resolved HDC through a doubled await. The packed-plugin smoke now also runs `snapshot -i` and `screenshot` against the stub `hdc`, asserting each CLI reply, the JPEG the stub wrote, and the layout-dump and frame-capture argv the stub recorded, so the evidence file names the six commands the gate covers.
327e188 to
de014dd
Compare
This comment has been minimized.
This comment has been minimized.
|
The earlier review at 327e188 asked for live device evidence. That is still missing, and this update at de014dd is a pure rebase that adds none. One code defect also remains. For an open HarmonyOS session, Could the HarmonyOS command runner in command-host.ts own the executable and PATH for both one-shot and streamed HDC commands, using the existing managed app-log process service through the setup host for streaming? Before merge, this PR needs a live run of the managed plugin on a real hdc target, installed from the packed tarball through The only failing check is Body rules. That job grades the PR title and body, not the code. Its script and workflow came from the 0.22 base, so this diff does not touch its route. The current body has Summary, Value and Validation and stays under the word limit, so the run probably graded an earlier body. Not verified here: the job log, since no failure excerpt was captured. A re-run, or a body edit that re-triggers the job, should clear it. No conflicts. The two earlier review threads were resolved before 327e188. After the logs fix and the device run, the Body rules re-run is the last open item. |
`logs start` ran both of its HDC commands outside the host the plugin was set up with: the PID lookup went through the runtime host's command port and the hilog stream through its local process transport, so neither got the family's documented toolchain roots on `PATH`. A toolchain that needs a sibling executable there served discovery and interaction and failed the stream. The plugin's command runner now owns both routes. The one-shot `pidof` takes `toolbox.hdc.runShell`, and the plan names its own process route: the setup host's new managed background command entry, backed by the same app-log process service the core's own transport uses, so the stream keeps its ownership marker, stop, and cleanup and spawns with the same prepared environment.
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
|
Fixed in Both HDC commands
Tests:
Local gates on this SHA: build, Still open and not touched here: the live |
|
The earlier findings from de014dd (#4857 (comment)) are addressed in the code at 2edb39e, except the missing live-device evidence, which still stands. The managed plugin has still not run on a real hdc target, and the new logs route (logs start through startBackgroundCommand) is now part of what is unproven. Before merge, install the packed tarball with agent-device plugins add and run it on a real hdc target. Show real output for devices --platform harmonyos listing the target, then open , snapshot -i, screenshot, press @ref, logs start (the log file receives hilog lines and the app-log.pid marker exists under the session dir), logs stop, and close. A maintainer waiver is the alternative. The only evidence today is unit tests and a packed-plugin smoke against a stub hdc, and the PR body says no hdc target is available. See https://github.com/callstack/agent-device/blob/2edb39e/docs/evidence/harmonyos-managed-platform-2026-11-20.md#L1. Not blocking, take or leave: the startBackgroundCommand doc in packages/plugins/src/platform.ts#L72 says it is absent when the composing process owns no session artifacts, but createPlatformPluginHost always defines it, so the UNSUPPORTED_OPERATION branch in command-host.ts cannot fire today. Either make it required on PlatformHost and delete that branch, or drop the "absent when" sentence. The Body rules check was cancelled, not failed. It grades the PR title and body, and this change does not touch what it exercises, so a re-run should clear it. No conflicts were reported. Not verified here: the tests, the package smoke and the Body rules log were not run or read, and no HarmonyOS device or hdc was reachable. After the live run or a waiver, re-run the cancelled check. |
|
Reply to #4857 (comment). Body rules passes at 2edb39e (re-run requested anyway). The optional |
|
Live run of the packed plugin on a real HarmonyOS device, head Setup: Huawei nova 14, All 93 lines in Observations, not blockers for this PR:
|
|
The live run at 2edb39e (#4857 (comment)) covers every step the review asked for: the packed plugin installed with |
Every process spawn, process-table read and diagnostic in @agent-device/web and @agent-device/vega now goes through the PlatformHost the core hands setup(): one command route per family is built there and handed to inventory, runtime, interactor, recorder and doctor, so neither packed bundle carries a separate host-kit command or diagnostics scope. Each family gets a `command-host.ts` that owns its argv and a `toolbox.ts` that binds the host, lazily and once per setup, matching the shape the HarmonyOS plugin set in #4857. Two host-kit reads the web and Vega plugins made directly became host ports rather than plugin code: `isExecutableOnPath`, which is how Vega prefers a CLI from the host `PATH` before its home install, and `listHostProcesses`, which is how the web provider derives the owned-process record for the fleet it starts. The latter answers through the host's own executable resolution and apart from any command override one request carries. The web plugin's `ManagedBrowserHost` and its optional-command and optional-diagnostic fallbacks are gone: a toolbox is required, so a plugin surface can no longer run a command nobody asked it to run. Vega's inventory now loads with no core host at all, as HarmonyOS's already does, and its tool provider takes the family's command runner instead of building ambient ones. The kernel gained `commandFailureDetails` and `requireCommandSuccess` for a caller that holds a command answer and no host, which is what a plugin on `PlatformHost.runCommand` holds; the exec-wrap guard accepts either pair so neither family spreads the stdout/stderr/exitCode trio by hand. With both families converted, the layering policy's per-file debt list is deleted rather than emptied: a managed platform package is bound to its host from its first commit, and a file that wants a host-kit command or diagnostic helper is a bug at that file.
Every process spawn, process-table read and diagnostic in @agent-device/web and @agent-device/vega now goes through the PlatformHost the core hands setup(): one command route per family is built there and handed to inventory, runtime, interactor, recorder and doctor, so neither packed bundle carries a separate host-kit command or diagnostics scope. Each family gets a `command-host.ts` that owns its argv and a `toolbox.ts` that binds the host, lazily and once per setup, matching the shape the HarmonyOS plugin set in #4857. Two host-kit reads the web and Vega plugins made directly became host ports rather than plugin code: `isExecutableOnPath`, which is how Vega prefers a CLI from the host `PATH` before its home install, and `listHostProcesses`, which is how the web provider derives the owned-process record for the fleet it starts. The latter answers through the host's own executable resolution and apart from any command override one request carries. The web plugin's `ManagedBrowserHost` and its optional-command and optional-diagnostic fallbacks are gone: a toolbox is required, so a plugin surface can no longer run a command nobody asked it to run. Vega's inventory now loads with no core host at all, as HarmonyOS's already does, and its tool provider takes the family's command runner instead of building ambient ones. The kernel gained `commandFailureDetails` and `requireCommandSuccess` for a caller that holds a command answer and no host, which is what a plugin on `PlatformHost.runCommand` holds; the exec-wrap guard accepts either pair so neither family spreads the stdout/stderr/exitCode trio by hand. With both families converted, the layering policy's per-file debt list is deleted rather than emptied: a managed platform package is bound to its host from its first commit, and a file that wants a host-kit command or diagnostic helper is a bug at that file.
* refactor(web,vega): run each plugin's commands on its setup host Every process spawn, process-table read and diagnostic in @agent-device/web and @agent-device/vega now goes through the PlatformHost the core hands setup(): one command route per family is built there and handed to inventory, runtime, interactor, recorder and doctor, so neither packed bundle carries a separate host-kit command or diagnostics scope. Each family gets a `command-host.ts` that owns its argv and a `toolbox.ts` that binds the host, lazily and once per setup, matching the shape the HarmonyOS plugin set in #4857. Two host-kit reads the web and Vega plugins made directly became host ports rather than plugin code: `isExecutableOnPath`, which is how Vega prefers a CLI from the host `PATH` before its home install, and `listHostProcesses`, which is how the web provider derives the owned-process record for the fleet it starts. The latter answers through the host's own executable resolution and apart from any command override one request carries. The web plugin's `ManagedBrowserHost` and its optional-command and optional-diagnostic fallbacks are gone: a toolbox is required, so a plugin surface can no longer run a command nobody asked it to run. Vega's inventory now loads with no core host at all, as HarmonyOS's already does, and its tool provider takes the family's command runner instead of building ambient ones. The kernel gained `commandFailureDetails` and `requireCommandSuccess` for a caller that holds a command answer and no host, which is what a plugin on `PlatformHost.runCommand` holds; the exec-wrap guard accepts either pair so neither family spreads the stdout/stderr/exitCode trio by hand. With both families converted, the layering policy's per-file debt list is deleted rather than emptied: a managed platform package is bound to its host from its first commit, and a file that wants a host-kit command or diagnostic helper is a bug at that file. * refactor(web): read the browser fleet's processes through its host The web fleet record still read processes through the plugin's own copy of the host kit: `readProcessIdentities`, `readProcessExecutablePaths`, `readHostProcessIdentityObservationsAsync`, and the startup reaper's `reapOwnedProcessRecordsAtStartup`. A managed plugin is bundled with its own copy of that kit, and a request's command-host and diagnostic scopes never enter it, so each of those reads answered with the daemon process environment and traced into the plugin's own store instead of the request's. `--debug` for a web `open` that refreshed the record showed the backend spawn and nothing of the reads that derived the record. `PlatformHost` now answers these through a `processes` facet: the host's process table, per-pid identity facts and observations, executable paths, and the reap of an owned-process record. It is served by the core's own copy of the kit in `src/platform-runtime/plugin-host.ts`, where the request's scopes live, so the read is in the environment and exec trace the request opened. `listHostProcesses` became `processes.list`, and the fleet scan, the record's liveness probe, the install lock's claim on this process's start time, and both orphan reapers now ask the host. The facet is reads plus that one reap: a plugin never signals a pid it merely saw, only the ones a record it owns names. The layering policy polices `host-kit/process` export by export now. Its 16 exports that reach the exec layer join the ban for every managed family; the ones that read this process's own globals or compute from what the caller holds (`hostPlatform`, `hostProcessId`, `isProcessAlive`, `expandProcessTree`, `processStartTimesDiffer`) stay reachable, because they cannot leave the request's scope. A runtime edge that names no export could reach any of them, so a namespace or bare import of the scope is refused. Proof, in both directions: the core's host answers a table read, an identity read and a real reap of a spawned child inside a `--debug` request's exec trace (`src/platform-runtime/plugin-host.test.ts`), and the web fleet scan and startup reap make no process tool of their own — `spawn` and `spawnSync` are refused for that module graph, and the reads it acts on are the ones its host answered (`agent-browser-process-record-host-routing.test.ts`). Also drops what the route made dead or wrong: `VegaToolbox` carried a host and a timer nothing read; the HarmonyOS test host answered "on PATH" for every name because `whichCmd` returns a boolean; and an orphaned JSDoc block sat above `managedStatusOptions` rather than the status reader it describes. The packed-plugin gate names the reads too. It refused an `open` request that traced no process-table read already; on macOS the scan also asks the host for each candidate's executable, which answers through `osascript` (through a CIM query on Windows). A live packed run on this head traced six `ps` reads and one `osascript` read under the one `open` request, so both kinds are asserted per request rather than kept only in the evidence file. * refactor(web): take the managed install lock through its host Claiming the install lock reads this process's identity with `ps`, and every poll of a held or stale lock re-proves the recorded owner and the guard holder with another read. The plugin took the lock from its bundled host-kit copy, so those reads ran with the daemon environment and traced into the bundle's own store: a request that waited out another process's install showed no wait. The host answers `processes.withLock`, and names its own identity there rather than being told it. The async identity read is the one the request sees: it runs `ps` through the command host, where the synchronous probe's `spawnSync` never appears in the exec trace. The packed web gate now asserts the plugin bundle carries no process tool, and that a `web setup --debug` on a clean state dir traces both the lock's `ps` read and the managed-backend install into the request that asked for it. * refactor(scripts): derive the host-kit exports a managed plugin may load The platform package policy refused a managed platform's runtime import of a host-kit export by looking the name up in a hand-kept per-scope list. A new export that reached the exec layer escaped until someone added it, which is the same failure the rule exists to catch. The rule now reads the host-kit module graph: an export is refused unless the graph proves its declaring module loads neither `internal/exec.ts` nor the diagnostic store, and the allowed set is the same derivation. Namespace and bare imports are refused, an unknown subpath is refused, and a missing exec root is reported as stale instead of quietly widening the permission. Per-specifier `type` markers are erased at runtime, so `ImportEdge` carries `typeSymbols` and the reach rule judges only the value names an import binds. `internal/host-process-facts.ts` and `internal/sleep.ts` split out of `internal/host-process.ts` and `internal/retry.ts`: the pid arithmetic and the timer import nothing, so those exports stay on the clean side of the line, and the process tool's reads stay where they were. * refactor(plugins): answer every machine and process fact on the host Splitting `internal/host-process-facts.ts` and `internal/sleep.ts` out of the host kit moved two eager modules into the closure of every entry that imports them, which is what the eager-closure budget refuses: a clean leaf is not free, it costs one evaluated module per closure that already evaluated the parent. Both modules are merged back, so the process scope has no pure export left and the derived rule refuses it wholesale — which is the sound verdict anyway: a re-export of `isProcessAlive` still evaluates the module that loads the exec layer, so no per-name permission for that scope could be honest. The three managed plugins now ask their host instead of their bundled copy: - `PlatformHost` carries the machine its commands run on — `hostOs`, `nodeExecutablePath`, `nodeVersion`, `temporaryDirectory`, `processId` — read once when the core builds the host. The web family builds its managed install layout, its npm argv, its launch executable, its Node capability read and the pid its fleet scan must skip from these. - `PlatformHost.processes` answers two more questions the plugin cannot derive from rows it was given: `expandTree`, because only the host knows which parent-child relation its own table records, and `judgeRecordedLiveness`, because the fail-closed reading of a written record depends on the host's own start-time format and its own liveness probe. The host answers both from the core's copy, inside the request's exec trace. - Pacing uses `node:timers/promises`, the timer the core's host waits on too. The retry scope of the bundled copy carries that scope's diagnostic store, and a wait between two backend sends belongs to no scope. `readIdentityObservations` leaves the contract with no caller left: the record probe asks the host to judge the records rather than reading observations it would have to compare itself. The policy tests now assert the merged truth: the file scope is still judged name by name (the pure path helper imports, the lock helper does not), and the process and retry scopes are refused for every managed family. * refactor(web): name the host's machine facts at its own type `WebStatusHost` restated the five machine facts the host answers instead of naming the type the family already gives them to, so the list had two owners. * test(linux): answer the host's machine and process facts in the plugin test host * test(layering): fit the policy test within its line cap * refactor(linux): read the host OS and pace input without the bundled host kit * style(layering): format the policy test within its line cap * fix(vega): print the doctor install hint with POSIX separators on every host
…4857) * refactor(harmonyos): move HarmonyOS into the managed platform plugin The packed core no longer answers for the HarmonyOS family. `@agent-device/harmonyos` is a managed optional platform plugin like the web and Vega plugins: the composition resolves it through the same one-shot module selection, and a request that names `--platform harmonyos` without it answers `plugin-not-installed` with its install command, while unfiltered discovery and doctor skip the family. The family's mechanics move with it. HDC device discovery, the ArkUI interactor, interaction handlers, app lifecycle and logs, the toolchain probe, the plugin-owned HDC screen recorder and the RSS memory sampler all live in the package now; the plugin reads the documented toolchain roots from the host environment the composition hands it and never touches `process.env`. Core keeps only the canonical platform vocabulary. * refactor(recording): share the transport recording snapshot builder The HarmonyOS plugin rebuilt the live recording snapshot field for field, so the shape now comes from capture-kit and the plugin names only its recorder. * refactor(harmonyos): run the plugin's commands on its setup host Every process spawn and diagnostic in @agent-device/harmonyos now goes through the PlatformHost the core hands setup(): one command runner and one HDC route are built there and handed to inventory, runtime, interactor, recorder and doctor, so the packed bundle carries no separate host-kit command or diagnostics scope. The layering policy bans those two runtime scopes for every managed platform package, with the web and Vega files that still import them registered as their own migration slices. The HarmonyOS facade stays metadata-eager, the core's toolchain preparer is android-only, and the packed-plugin smoke test drives discovery, launch, snapshot, a press, capture and close against a stub HDC reachable only through HDC_SDK_PATH. * refactor(harmonyos): bind the plugin's toolbox on first command The facade said the toolbox binds on first use while `setup` built it immediately, so the resolution is now lazy and memoized per setup: a setup that never runs a command imports and builds nothing, and the operations of one setup still share the one toolbox that binds its host. One toolchain root probe per spawn instead of two: `resolveHdc` read a Promise of the resolved HDC through a doubled await. The packed-plugin smoke now also runs `snapshot -i` and `screenshot` against the stub `hdc`, asserting each CLI reply, the JPEG the stub wrote, and the layout-dump and frame-capture argv the stub recorded, so the evidence file names the six commands the gate covers. * fix(harmonyos): stream hilog through the plugin's setup host `logs start` ran both of its HDC commands outside the host the plugin was set up with: the PID lookup went through the runtime host's command port and the hilog stream through its local process transport, so neither got the family's documented toolchain roots on `PATH`. A toolchain that needs a sibling executable there served discovery and interaction and failed the stream. The plugin's command runner now owns both routes. The one-shot `pidof` takes `toolbox.hdc.runShell`, and the plan names its own process route: the setup host's new managed background command entry, backed by the same app-log process service the core's own transport uses, so the stream keeps its ownership marker, stop, and cleanup and spawns with the same prepared environment.
* refactor(web,vega): run each plugin's commands on its setup host Every process spawn, process-table read and diagnostic in @agent-device/web and @agent-device/vega now goes through the PlatformHost the core hands setup(): one command route per family is built there and handed to inventory, runtime, interactor, recorder and doctor, so neither packed bundle carries a separate host-kit command or diagnostics scope. Each family gets a `command-host.ts` that owns its argv and a `toolbox.ts` that binds the host, lazily and once per setup, matching the shape the HarmonyOS plugin set in #4857. Two host-kit reads the web and Vega plugins made directly became host ports rather than plugin code: `isExecutableOnPath`, which is how Vega prefers a CLI from the host `PATH` before its home install, and `listHostProcesses`, which is how the web provider derives the owned-process record for the fleet it starts. The latter answers through the host's own executable resolution and apart from any command override one request carries. The web plugin's `ManagedBrowserHost` and its optional-command and optional-diagnostic fallbacks are gone: a toolbox is required, so a plugin surface can no longer run a command nobody asked it to run. Vega's inventory now loads with no core host at all, as HarmonyOS's already does, and its tool provider takes the family's command runner instead of building ambient ones. The kernel gained `commandFailureDetails` and `requireCommandSuccess` for a caller that holds a command answer and no host, which is what a plugin on `PlatformHost.runCommand` holds; the exec-wrap guard accepts either pair so neither family spreads the stdout/stderr/exitCode trio by hand. With both families converted, the layering policy's per-file debt list is deleted rather than emptied: a managed platform package is bound to its host from its first commit, and a file that wants a host-kit command or diagnostic helper is a bug at that file. * refactor(web): read the browser fleet's processes through its host The web fleet record still read processes through the plugin's own copy of the host kit: `readProcessIdentities`, `readProcessExecutablePaths`, `readHostProcessIdentityObservationsAsync`, and the startup reaper's `reapOwnedProcessRecordsAtStartup`. A managed plugin is bundled with its own copy of that kit, and a request's command-host and diagnostic scopes never enter it, so each of those reads answered with the daemon process environment and traced into the plugin's own store instead of the request's. `--debug` for a web `open` that refreshed the record showed the backend spawn and nothing of the reads that derived the record. `PlatformHost` now answers these through a `processes` facet: the host's process table, per-pid identity facts and observations, executable paths, and the reap of an owned-process record. It is served by the core's own copy of the kit in `src/platform-runtime/plugin-host.ts`, where the request's scopes live, so the read is in the environment and exec trace the request opened. `listHostProcesses` became `processes.list`, and the fleet scan, the record's liveness probe, the install lock's claim on this process's start time, and both orphan reapers now ask the host. The facet is reads plus that one reap: a plugin never signals a pid it merely saw, only the ones a record it owns names. The layering policy polices `host-kit/process` export by export now. Its 16 exports that reach the exec layer join the ban for every managed family; the ones that read this process's own globals or compute from what the caller holds (`hostPlatform`, `hostProcessId`, `isProcessAlive`, `expandProcessTree`, `processStartTimesDiffer`) stay reachable, because they cannot leave the request's scope. A runtime edge that names no export could reach any of them, so a namespace or bare import of the scope is refused. Proof, in both directions: the core's host answers a table read, an identity read and a real reap of a spawned child inside a `--debug` request's exec trace (`src/platform-runtime/plugin-host.test.ts`), and the web fleet scan and startup reap make no process tool of their own — `spawn` and `spawnSync` are refused for that module graph, and the reads it acts on are the ones its host answered (`agent-browser-process-record-host-routing.test.ts`). Also drops what the route made dead or wrong: `VegaToolbox` carried a host and a timer nothing read; the HarmonyOS test host answered "on PATH" for every name because `whichCmd` returns a boolean; and an orphaned JSDoc block sat above `managedStatusOptions` rather than the status reader it describes. The packed-plugin gate names the reads too. It refused an `open` request that traced no process-table read already; on macOS the scan also asks the host for each candidate's executable, which answers through `osascript` (through a CIM query on Windows). A live packed run on this head traced six `ps` reads and one `osascript` read under the one `open` request, so both kinds are asserted per request rather than kept only in the evidence file. * refactor(web): take the managed install lock through its host Claiming the install lock reads this process's identity with `ps`, and every poll of a held or stale lock re-proves the recorded owner and the guard holder with another read. The plugin took the lock from its bundled host-kit copy, so those reads ran with the daemon environment and traced into the bundle's own store: a request that waited out another process's install showed no wait. The host answers `processes.withLock`, and names its own identity there rather than being told it. The async identity read is the one the request sees: it runs `ps` through the command host, where the synchronous probe's `spawnSync` never appears in the exec trace. The packed web gate now asserts the plugin bundle carries no process tool, and that a `web setup --debug` on a clean state dir traces both the lock's `ps` read and the managed-backend install into the request that asked for it. * refactor(scripts): derive the host-kit exports a managed plugin may load The platform package policy refused a managed platform's runtime import of a host-kit export by looking the name up in a hand-kept per-scope list. A new export that reached the exec layer escaped until someone added it, which is the same failure the rule exists to catch. The rule now reads the host-kit module graph: an export is refused unless the graph proves its declaring module loads neither `internal/exec.ts` nor the diagnostic store, and the allowed set is the same derivation. Namespace and bare imports are refused, an unknown subpath is refused, and a missing exec root is reported as stale instead of quietly widening the permission. Per-specifier `type` markers are erased at runtime, so `ImportEdge` carries `typeSymbols` and the reach rule judges only the value names an import binds. `internal/host-process-facts.ts` and `internal/sleep.ts` split out of `internal/host-process.ts` and `internal/retry.ts`: the pid arithmetic and the timer import nothing, so those exports stay on the clean side of the line, and the process tool's reads stay where they were. * refactor(plugins): answer every machine and process fact on the host Splitting `internal/host-process-facts.ts` and `internal/sleep.ts` out of the host kit moved two eager modules into the closure of every entry that imports them, which is what the eager-closure budget refuses: a clean leaf is not free, it costs one evaluated module per closure that already evaluated the parent. Both modules are merged back, so the process scope has no pure export left and the derived rule refuses it wholesale — which is the sound verdict anyway: a re-export of `isProcessAlive` still evaluates the module that loads the exec layer, so no per-name permission for that scope could be honest. The three managed plugins now ask their host instead of their bundled copy: - `PlatformHost` carries the machine its commands run on — `hostOs`, `nodeExecutablePath`, `nodeVersion`, `temporaryDirectory`, `processId` — read once when the core builds the host. The web family builds its managed install layout, its npm argv, its launch executable, its Node capability read and the pid its fleet scan must skip from these. - `PlatformHost.processes` answers two more questions the plugin cannot derive from rows it was given: `expandTree`, because only the host knows which parent-child relation its own table records, and `judgeRecordedLiveness`, because the fail-closed reading of a written record depends on the host's own start-time format and its own liveness probe. The host answers both from the core's copy, inside the request's exec trace. - Pacing uses `node:timers/promises`, the timer the core's host waits on too. The retry scope of the bundled copy carries that scope's diagnostic store, and a wait between two backend sends belongs to no scope. `readIdentityObservations` leaves the contract with no caller left: the record probe asks the host to judge the records rather than reading observations it would have to compare itself. The policy tests now assert the merged truth: the file scope is still judged name by name (the pure path helper imports, the lock helper does not), and the process and retry scopes are refused for every managed family. * refactor(web): name the host's machine facts at its own type `WebStatusHost` restated the five machine facts the host answers instead of naming the type the family already gives them to, so the list had two owners. * test(linux): answer the host's machine and process facts in the plugin test host * test(layering): fit the policy test within its line cap * refactor(linux): read the host OS and pace input without the bundled host kit * style(layering): format the policy test within its line cap * fix(vega): print the doctor install hint with POSIX separators on every host
Summary
Moves HarmonyOS from the packed core into the managed platform plugin
@agent-device/harmonyos(packages/platform-harmonyos). Without the plugin,--platform harmonyosanswersplugin-not-installedwith its install command, and unscopeddevices/doctorskip the family. Every spawn and diagnostic goes through thePlatformHostfromsetup; the plugin reads toolchain roots from the setup environment, notprocess.env. A layering rule bans runtime@agent-device/host-kit/command|diagnosticsimports in managed platform packages. Part of #4317. The package staysprivate(#4866).Value
Validation
Head rebased onto
0.22at62f24be4fd. Local: build, typecheck, lint, layering, command-docs, daemon-wire-compat, fullvitest --project unit-core(20911 passed),check:packagewith the packed-plugin smoke (stubhdcviaHDC_SDK_PATH). No live HarmonyOS target on this Mac:hdc list targetsis empty and no emulator image exists; evidence indocs/evidence/harmonyos-managed-platform-2026-11-20.md. A live run or a maintainer waiver is required before merge.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.