Skip to content

refactor(web): ship web as the first platform plugin - #4792

Merged
thymikee merged 7 commits into
0.22from
refactor/0.22-web-platform-plugin
Nov 20, 2026
Merged

thymikee merged 7 commits into
0.22from
refactor/0.22-web-platform-plugin

Conversation

@thymikee

@thymikee thymikee commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Validation

  • AGENT_DEVICE_VITEST_MAX_WORKERS=2 pnpm check:affected --run --base origin/0.22 --head 5418f5f56b685ee5165e54f06ec51730dae5e5f8 passed with exactCommit=true in .tmp/validation/run-df36B3/receipt.json. The local plan passed 42 checks and skipped 28.
  • 21,379 unit tests passed with 10 skipped. All 441 related tests, 309 provider integration tests, and 9 packed tests passed. Node integration passed 155 tests with 13 skipped.
  • Core tarball against 6f60c1e2aa went from 1,648,824 to 1,637,132 compressed bytes (−11,692) and from 5,314,615 to 5,274,325 unpacked bytes (−40,290).
  • The two earlier provider test timeouts passed in isolation and on the final two-worker run. Hosted coverage and live device lanes follow CI.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.19 MB 6.14 MB -49.2 kB
Package (unpacked) 6.19 MB 6.14 MB -49.2 kB
Package (download) 1.88 MB 1.87 MB -14.5 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 35.4 ms 19.8 ms -15.6 ms
CLI --help 56.3 ms 40.6 ms -15.7 ms

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on cc5fdba. The verdict and the full list are in the summary comment.

Comment thread packages/plugins/src/discovery.ts Resolved
@thymikee

Copy link
Copy Markdown
Member Author

This PR's own slice at cc5fdba has one problem to fix before merge. CI is green (16 checks, none failing), and there are no conflicts.

The store accepts a package that declares platform: <optional family>, and the public agent-device/plugins types advertise PlatformContribution (sdk/plugins.ts:18-20). But the only production composition, provider-device-runtimes.ts:30-70, never passes platformHost. So setUpClaim throws Platform setup requires a platform host for every platform claim at daemon start (registry.ts:480). A user who installs a platform plugin sees daemon status report failed with reason invalid_plugin, which blames the plugin for missing host wiring. Even a successful setup would not help, because nothing reads registry.platforms or resolvePlatform, and PlatformModuleRegistry and the platform plugin registry keep answering from the builtin set. The claim space also ignores builtin owners: web is accepted for a plugin while core still registers the builtin web platform, so wiring the host later would give one family two owners. The rule to satisfy: every claim kind the store accepts has a production composition that can set it up, and a single owner of its family. Either wire the daemon composition in this PR, with builtin families in the claim space the way builtinProviderCandidates does for providers, or keep the kind out of the published Contribution union and store acceptance until the web cutover lands.

Not blocking, and fine to take or leave: resolvePlatform adds a third absence authority beside PlatformModuleRegistry.get and getPlugin, and the caller passes the reporter per call, so it could be dropped in favor of exposing set-up modules and failed claims through the inventory; claim validation became async (validate.ts:48, plus a dynamic import of NATIVE_REPLAY_BACKEND on every call at registry.ts:408) where a static import and a leaf module for the family partition would keep it synchronous; platform.test.ts:105 exercises resolvePlatform with a test-supplied reporter, so once the consumer exists it should assert absence through the daemon composition; validatePlatformSetup hardcodes web and six web operation names (validate.ts:298), which could come from one table keyed by OptionalPlatform; provider.ts:5 still re-exports the moved Web* types and its importers could use @agent-device/contracts/web-provider; registry.ts:483 casts the setup result instead of typing PlatformSetup with the real contracts; the Node-floor check moved to load time (store.ts:165), so a below-floor package now reserves its claims, and the comment above it is stale; and daemon-runtime.ts:669 emits provider_plugin_failed with a platform field, where a kind-neutral name may read better.

Could this land smaller? This slice's production net is about 274 lines, but it adds a seam with no consumer. Would it work to ship the platform kind together with its first consumer (the web cutover), with the plugin registry exposing only set-up platform modules and failed platform claims, and the composition root registering them into the existing registries behind one absence reporter? That needs #4784 merged into 0.22 first, so this diff is only its own slice, and a decision on whether a builtin family and a plugin can coexist during the extraction (for example, reserve builtin families until each extraction PR removes the builtin).

The open inline thread on discovery.ts (node-floor range parsing) still applies, but the code comes from the #4784 commits, so fix it there.

No eager-closure budget entry explains the async change, so treat that note as likely rather than confirmed. The next step is to wire the platform kind into the daemon composition in this PR, or keep it out of the published contract until the web cutover lands.

@thymikee

Copy link
Copy Markdown
Member Author

Decision on the design question: yes, the platform kind ships with its first consumer. This PR becomes the single web PR (contract plus cutover), and stays a draft until #4784 merges.

  • Blocker: the daemon composition will pass platformHost and register set-up platform modules behind the one absence reporter; resolvePlatform goes away as a separate absence authority.
  • Coexistence during extraction: each family still compiled into core reserves its claim through a builtin candidate, as builtinProviderCandidates does. A store package that claims a still-bundled family loses as a duplicate. A family leaves the builtin set in the PR that extracts it, so web has one owner here.
  • The optional items are taken. The discovery.ts node-floor thread stays with refactor(plugins): move the plugin contract to version 3 #4784.

The rework is in progress on this branch.

@thymikee

Copy link
Copy Markdown
Member Author

This now conflicts with 0.22. Please rebase. The earlier review at cc5fdba still stands for the code.

@thymikee
thymikee force-pushed the refactor/0.22-web-platform-plugin branch from cc5fdba to 5418f5f Compare November 20, 2026 13:05
@thymikee thymikee changed the title feat(plugins): add the platform contribution kind refactor(web): ship web as the first platform plugin Nov 20, 2026
@thymikee

Copy link
Copy Markdown
Member Author

Addressed the review at cc5fdba in 5418f5f5.

  1. Combined the platform contract and the first consumer in this draft. The packed core excludes the browser implementation and a clean install discovers web only after installing the plugin.
  2. Daemon and embedded composition require PlatformHost. The daemon binds replay from that same registry. The registry publishes set-up modules and failure inventory, and the composition root registers the modules with the built-ins. Inventory, runtime, and interactor lookups share the family registry and absence reporter.
  3. Bundled Apple, Android, HarmonyOS, Vega, and Linux reserve their claims before store packages. The daemon and the standalone web commands use those reservations. The regression tests cover duplicate required and optional claims, store-backed inventory and doctor, and the missing and stale web outcomes.
  4. Claim validation is synchronous. A family table checks web-specific operations. Web consumers import provider types from contracts, and a checked setup boundary supplies concrete runtime types without casting or pulling those declarations into the packed SDK. Below-floor installations keep their claims and platform startup failures emit platform_plugin_failed.
  5. Took the three refactor(plugins): move the plugin contract to version 3 #4784 carry-ins. The host replay test resolves engines through startProviderRegistry, so the raw claims view is gone. Reservations produce loaded contributions or separate failed entries, setup validation returns the typed per-kind result, and the table owns rejection messages and native/legacy replay claim spelling.
  6. Rebased onto the refactor(plugins): move the plugin contract to version 3 #4784 squash merge on 0.22. The Node-floor regression verifies that Node 18 is accepted by 18 - 20.

The exact-head gate passed with 42 checks passed and 28 skipped. See the PR body for the receipt, test counts, and packed size.

@thymikee
thymikee marked this pull request as ready for review November 20, 2026 13:06
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 5418f5f

Since the review of cc5fdba: 1 new · 0 still open · 1 no longer raised

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
src/platform-runtime/request-providers.ts:128 🆕 Default web provider is created before the guards that should skip it
Not in the reviewers' prompt (7 files)
  • package.json: left out as an asset or for its size; reviewers could still search it
  • packages/contracts/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/daemon/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/platform-web/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/platform-web/tsconfig.json: left out as an asset or for its size; reviewers could still search it
  • pnpm-lock.yaml: generated or a lockfile, so its lines were left out
  • scripts/layering/contracts-exports.snapshot.json: left out as an asset or for its size; reviewers could still search it

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (0a1c2cce7b9b).

💬 Talking to Sentinel

In a finding's thread, reply with:

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.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 5418f5f. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

The PR is ready at 5418f5f. The conflict from the earlier review (#4792 (comment)) is resolved, and no conflicts remain.

The code matches what the PR describes. CI is green: 50 checks, 0 failing. The Integration Tests job ran the live web smoke (smoke-web-platform.test.ts). It packs packages/platform-web, runs plugins add <tarball>, then web setup, open, fill and daemon-shutdown cleanup. All 4 tests passed with 0 skipped. No CI job covers stale-claim recovery for a web device.

Not blocking, and you can take or leave it: in platform-runtime.ts:155, createPlatformRuntimeGateway takes both platforms? and reportAbsent?. The second exists only for the claim-recovery caller. If both are omitted, the install hint is silently dropped. Could platforms be required and reportAbsent removed? The claim-recovery gateway (daemon and daemonless device release --stale) would then use the same platform selection as the rest of the daemon. A daemon-composition test showing that a stale web claim with a durable screen recording reconciles while @agent-device/web is installed would cover it.

Of the open inline threads, the one on packages/plugins/src/discovery.ts (hyphen range) is fixed at this head; discovery.test.ts:191 asserts that 18 - 20 accepts Node 18, so it can be resolved: #4792 (comment). The one on request-providers.ts:135 does not apply. Without a web registration the request fails with plugin-not-installed anyway, and with web installed get() is a cheap lookup that runs before the guards while createProvider still runs after them, so it can be resolved: #4792 (comment).

The install hints and docs name @agent-device/web, which is still private and not published by the release script. #4597 asks for this until the trusted-publisher transition. Publication must happen before a 0.22 release whose core lacks web.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
…time gateway

Claim recovery now binds through the process's platform selection: the daemon
passes its composed platforms, and daemonless device release --stale starts one
platforms-scoped plugin registry on first gateway use and closes it when the run
ends. The registry start is shared with the managed web backend.
@thymikee

Copy link
Copy Markdown
Member Author

Update at ea6d77438c: claim recovery uses the process's platform selection

Follow-up to #4792 (comment).

  • platforms is required on createPlatformRuntimeGateway; the reportAbsent option is removed.
  • Daemon: createClaimRecoveryGatewayFor(host, platforms) receives the selection the daemon already composed.
  • Daemonless device release --stale: one 'platforms'-scoped plugin registry per run, started from the caller's state dir on the first gateway use and closed in a finally. Session paths and process records still follow each stale owner. A run that needs no gateway loads no plugin.
  • src/platform-runtime/installed-platforms.ts is the one owner of the out-of-daemon registry start; platform-runtime-managed-web-backend.ts now uses it too.
  • New src/daemon-composition-claim-recovery.test.ts (4 cases, daemon and daemonless): with a web platform plugin installed, a stale web claim with an open recording is released; with web absent it is retained with screen-recording-cleanup-pending. Both "released" cases fail when recovery is put back to the 5418f5f behaviour.

Limit, stated plainly: the test installs a store web plugin whose runtime can settle a dead recorder. The stock @agent-device/web runtime still returns cleanup-pending for a recording after a daemon restart (packages/platform-web/src/recording/runtime.ts), so with the stock plugin such a claim stays retained, as before this PR. This change makes recovery bind the installed registration; it does not change web recording cleanup. I can file that as a separate issue if wanted.

Both inline threads are answered and resolved. The local Sentinel fix for request-providers.ts was dropped, per the review.

Validation

pnpm check:affected --run --base origin/0.22 --head ea6d77438c: all runnable checks passed, exactCommit=true.

@thymikee
thymikee merged commit f62ecb3 into 0.22 Nov 20, 2026
32 of 33 checks passed
@thymikee
thymikee deleted the refactor/0.22-web-platform-plugin branch November 20, 2026 14:39
thymikee added a commit that referenced this pull request Nov 20, 2026
* feat(plugins): add the platform contribution kind

* refactor(web): ship web as the first platform plugin

* fix(web): compose platform plugins through the family registry

* refactor(plugins): separate claim reservations from setup

* fix(plugins): use the left bound for Node hyphen ranges

* chore(gates): verify the web plugin stays outside packed core

* refactor(platform-runtime): require the platform selection on the runtime gateway

Claim recovery now binds through the process's platform selection: the daemon
passes its composed platforms, and daemonless device release --stale starts one
platforms-scoped plugin registry on first gateway use and closes it when the run
ends. The registry start is shared with the managed web backend.
thymikee added a commit that referenced this pull request Nov 20, 2026
* feat(plugins): add the platform contribution kind

* refactor(web): ship web as the first platform plugin

* fix(web): compose platform plugins through the family registry

* refactor(plugins): separate claim reservations from setup

* fix(plugins): use the left bound for Node hyphen ranges

* chore(gates): verify the web plugin stays outside packed core

* refactor(platform-runtime): require the platform selection on the runtime gateway

Claim recovery now binds through the process's platform selection: the daemon
passes its composed platforms, and daemonless device release --stale starts one
platforms-scoped plugin registry on first gateway use and closes it when the run
ends. The registry start is shared with the managed web backend.
thymikee added a commit that referenced this pull request Nov 21, 2026
* feat(plugins): add the platform contribution kind

* refactor(web): ship web as the first platform plugin

* fix(web): compose platform plugins through the family registry

* refactor(plugins): separate claim reservations from setup

* fix(plugins): use the left bound for Node hyphen ranges

* chore(gates): verify the web plugin stays outside packed core

* refactor(platform-runtime): require the platform selection on the runtime gateway

Claim recovery now binds through the process's platform selection: the daemon
passes its composed platforms, and daemonless device release --stale starts one
platforms-scoped plugin registry on first gateway use and closes it when the run
ends. The registry start is shared with the managed web backend.
thymikee added a commit that referenced this pull request Nov 21, 2026
* feat(plugins): add the platform contribution kind

* refactor(web): ship web as the first platform plugin

* fix(web): compose platform plugins through the family registry

* refactor(plugins): separate claim reservations from setup

* fix(plugins): use the left bound for Node hyphen ranges

* chore(gates): verify the web plugin stays outside packed core

* refactor(platform-runtime): require the platform selection on the runtime gateway

Claim recovery now binds through the process's platform selection: the daemon
passes its composed platforms, and daemonless device release --stale starts one
platforms-scoped plugin registry on first gateway use and closes it when the run
ends. The registry start is shared with the managed web backend.
thymikee added a commit that referenced this pull request Nov 23, 2026
* feat(plugins): add the platform contribution kind

* refactor(web): ship web as the first platform plugin

* fix(web): compose platform plugins through the family registry

* refactor(plugins): separate claim reservations from setup

* fix(plugins): use the left bound for Node hyphen ranges

* chore(gates): verify the web plugin stays outside packed core

* refactor(platform-runtime): require the platform selection on the runtime gateway

Claim recovery now binds through the process's platform selection: the daemon
passes its composed platforms, and daemonless device release --stale starts one
platforms-scoped plugin registry on first gateway use and closes it when the run
ends. The registry start is shared with the managed web backend.
hannojg pushed a commit to hannojg/agent-device that referenced this pull request Nov 23, 2026
* feat(plugins): add the platform contribution kind

* refactor(web): ship web as the first platform plugin

* fix(web): compose platform plugins through the family registry

* refactor(plugins): separate claim reservations from setup

* fix(plugins): use the left bound for Node hyphen ranges

* chore(gates): verify the web plugin stays outside packed core

* refactor(platform-runtime): require the platform selection on the runtime gateway

Claim recovery now binds through the process's platform selection: the daemon
passes its composed platforms, and daemonless device release --stale starts one
platforms-scoped plugin registry on first gateway use and closes it when the run
ends. The registry start is shared with the managed web backend.
thymikee added a commit that referenced this pull request Nov 24, 2026
* feat(plugins): add the platform contribution kind

* refactor(web): ship web as the first platform plugin

* fix(web): compose platform plugins through the family registry

* refactor(plugins): separate claim reservations from setup

* fix(plugins): use the left bound for Node hyphen ranges

* chore(gates): verify the web plugin stays outside packed core

* refactor(platform-runtime): require the platform selection on the runtime gateway

Claim recovery now binds through the process's platform selection: the daemon
passes its composed platforms, and daemonless device release --stale starts one
platforms-scoped plugin registry on first gateway use and closes it when the run
ends. The registry start is shared with the managed web backend.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant