Repository navigation
refactor(web,vega): run each plugin's commands on its setup host - #4874
Conversation
Live packed-plugin run — Vega Virtual Device (2026-11-21)Packed core + packed
The packed web family is covered the same way over the fixture managed-backend install in |
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 536d508. The verdict and the full list are in the summary comment.
|
At 536d508 the web plugin still spawns process-table reads outside the host, so the PR body claim that every spawn goes through the PlatformHost does not hold yet. Only The rule to satisfy: no exec-backed host-kit helper is reachable at runtime from a managed plugin, and Code reading plus the evidence in the PR; the reviewed commit is 536d508. The failing Smoke Tests check on this head is only the 'Require both Apple jobs to succeed' gate reporting cancelled. The Apple, Android and Linux runs created at 01:44:37 were all cancelled within about 2 s of starting, before any test step, by a concurrency cancel from duplicate pull_request events. The later Apple, Android and Linux runs on the same head all passed, and the diff touches no route those smokes exercise, so this failure looks unrelated to the change. The next step before merge is the host-kit/process decision above. One lower-priority inline thread still applies, and no high-priority thread is open. Not blocking, and fine to take or leave: Of the 823 net production lines, about 247 are docs and evidence, about 340 are the two package-smoke gates and about 256 are the two fixture files, while plugin source nets only +188. Could web take Not verified here: the package-smoke gates on base or head (the red-on-base claim is taken from the PR body), the Vega live run (read from the evidence doc), whether host-kit |
80f9c66 to
afffaee
Compare
|
Reply to the blocking finding on What moved to the host. Gate. Tests. Live route, packed, on this head. One Cleanups from the same list. Done: the always-true |
This comment has been minimized.
This comment has been minimized.
|
The earlier finding on the per-plugin process reads is mostly fixed at afffaee: the fleet record and reaper now run through the host, and the harmonyos test now returns the boolean from
This breaks the issue invariant that every spawn, process-table read and diagnostic goes through the PlatformHost. On a managed web install, or any setup that meets a held or stale install lock, these The rule the code must satisfy: no host-kit module that a managed plugin imports at runtime may reach Could the hand-kept Before merge, one packed CI is green: 15 checks, 0 not passing at afffaee. No conflicts. Not verified here: tests and packed runs were not executed, and the live-trace counts, the 1596-test vitest run and the reverse test are taken from the author comment. The reachability above comes from reading the code and was not observed live. Not verified here: whether the packed bundle tree-shakes The earlier harmonyos thread is fixed at this head and can be resolved: #4874 (comment). The earlier review is at #4874 (comment). The remaining step before merge is routing the web install lock through the host. |
327e188 to
de014dd
Compare
|
This head (afffaee) now conflicts with the base branch. Please rebase onto it and push; the open finding from #4874 (comment) (route the web install lock through the host) still applies to the rebased head. |
This comment has been minimized.
This comment has been minimized.
|
Install lock now goes through the host, and the per-export list is gone. Head: What moved
The host answers with No bundled-copy How the gate derives reachability
Per-specifier Derived today, from the tracked tree:
To keep that honest without widening any ban, two leaves came out of host-kit: Tests
Packed traceRead this first: the requested So the same packed scratch, same clean state dir, is run through the request that does take the lock — The two On your two questionsReplacing the hand-kept list with the graph rule: done, as above — one derivation decides both the refusal and the allowlist, so nothing needs a second list.
The earlier harmonyos thread stays resolved at this head; the shape-only asks stay closed as deferred. |
5644fa6 to
39361c9
Compare
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.
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.
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.
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.
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.
`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.
This comment has been minimized.
This comment has been minimized.
39361c9 to
bde3144
Compare
|
Rebased onto |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 1b94a43. The verdict and the full list are in the summary comment.
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.
|
This PR is ready at b283468. The install lock now goes through the host, the layering rule derives from the import graph, and the exec-backed reach policy reads correctly. All 15 checks pass, and the earlier replay-suite failure was on a previous head and touched no route in this delta. The conflict from the earlier review is resolved. Nothing else must happen before merge. Not blocking, and fine to take or leave: plugin-host.ts:94 repeats the same five-key machine-fact list that WebMachine declares in packages/platform-web/src/toolbox.ts, so one exported PlatformHostMachine type in packages/plugins/src/platform.ts could serve all three. The PR body lists the processes facet without expandTree, judgeRecordedLiveness and the new machine facts, and it still says it is stacked on #4857, which has merged. Both earlier inline threads no longer apply and can be resolved: the Vega doctor hint is now a fixed string with no host-separator join (thread), and the HarmonyOS test host still answers from whichCmd (thread). Not verified here: tests and the packed web and vega gates were not run. The packed |
* 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
The managed web and Vega plugins run every spawn, process-table read, install lock and diagnostic through the
PlatformHosthanded tosetup(), as HarmonyOS does, so neither packed bundle carries its own host-kit exec or diagnostics scope.PlatformHostgainsisExecutableOnPathand aprocessesfacet (table, identities, executable paths, owned-record reap,withLock), answered only by the core. The layering rule now derives from the host-kit module graph which exports reach exec or diagnostics, so a new exec-backed export is refused without editing a list. Fixes #4862. Stacked on #4857.Value
host-kit/command|diagnosticsimports in managed pluginsValidation
Head
bde31446a0, rebased onto0.22at9a12ab0ebb(HarmonyOS and Linux merged); the Linux plugin now also reads the host OS fromPlatformHostand paces input without host-kit. Local: build, typecheck, lint, layering, command-docs, daemon-wire-compat, fullvitest --project unit-core,check:packagewith packed web and Vega gates (argv, child env, one exec record per call; web asserts thepslock and table reads). Packedweb setup --debugtraces the install-lockpsreads under the request with no bundled spawn. Live Vega Virtual Device run indocs/evidence/vega-managed-platform-2026-11-21.md; web used a fixture backend. CI: hosted checks at this head.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.