Skip to content

refactor(plugins): move the plugin contract to version 3 - #4784

Merged
thymikee merged 14 commits into
0.22from
refactor/0.22-plugin-contract-v3
Nov 20, 2026
Merged

thymikee merged 14 commits into
0.22from
refactor/0.22-plugin-contract-v3

Conversation

@thymikee

@thymikee thymikee commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

The 0.22 plugin contract changes once to version 3 (ADR 0034, #3311, #4591). A plugin factory now returns apiVersion: 3 plus a contributes list of independently activated claims — provider, replay-backend, replay-execution. Each claim key is declared statically in the package's agent-device metadata, validated before import, and matched against the factory result after it runs; the registry keeps one record, setup outcome and cleanup entry per claim. Nine plugin packages migrated. Version 2 packages, including the external @nomac/agent-device, get a typed incompatible-plugin-api outcome with no compatibility shim. A platform kind lands with #4597, not here.

92 files, +2489/−1202 gross. No scope expansion beyond the contract, the nine plugins, their tests and docs, plus two packaging fixes the widened contract exposed: the contract declarations now share one published chunk with the replay contracts, and @agent-device/replay types its published declarations against agent-device/plugins as Maestro already does.

export default () => ({
  apiVersion: 3,
  contributes: [{ kind: 'provider', provider: 'example', credentials: { variables: [] }, setup }],
});

Validation

Head 38fe33365a, base 6534ef3869.

  • pnpm check:affected --run --base origin/0.22 --head 38fe33365a — passed, exactCommit: true; 42 checks passed, 28 skipped as GitHub-authoritative; 22,123 tests passed, 0 failed. Selection stayed full.
  • pnpm exec fallow audit --base origin/0.22 — no issues in the changed files, no suppressions or baseline edits.
  • pnpm run check:package — Maestro and replay package-smoke pass, including the embedded-runtime failure-isolation cases and the managed plugins add route.
  • pnpm exec vitest run scripts/__tests__/eager-closure-budgets.test.ts — no plugin entry gains an eager module.

CI owns full coverage, native builds, device lanes and provider integration. No device run beyond what CI does.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

thymikee and others added 9 commits November 19, 2026 22:49
…ions

AgentDevicePlugin is now { apiVersion: 3, contributes: [Contribution, ...] } with
provider, replay-backend and replay-execution kinds. The registry validates the whole
declaration, expands it into per-claim records, and reserves claim spaces in candidate
order. All nine maintained plugins wrap their factories in contributes. No shim: a
version 2 result gets the typed incompatible-plugin-api outcome.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
…port

The store reads package.json agent-device { apiVersion, provider?, replayBackend?,
replayExecution? }: a version other than 3 fails pre-import with the typed
incompatible-plugin-api reason, engines.node establishes the Node floor
(node-below-floor), and reserved or malformed claim ids fail before any code runs.
After the factory runs with its options, the returned claim keys must equal the
declared ones unordered, or the package is invalid. All nine maintained packages
declare their claims and the Node floor.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
… suites

Update the existing suites to the contributes shape and add: a version 2 factory
and a version 2 metadata package both get incompatible-plugin-api; a metadata /
factory claim mismatch invalidates the package; cross-package duplicates keep the
first claim and fail the loser; a multi-kind package activates its replay claim
when its provider setup fails; the replay-only scope sets up no provider claim;
close runs activated claims in reverse activation order with per-step outcomes.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
The plugins guide now documents contributes with per-kind contributions, the
agent-device package.json field with static claim keys, the engines Node floor,
the replay-execution ad kind, and the incompatible-plugin-api outcome for
version 2 packages.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
AgentDevicePlugin gains a defaulted contribution generic so provider
packages can declare ProviderOnlyPlugin/ProviderAgentDevicePlugin; their
packed .d.mts then inline only the provider branch and stay assignable to
the host's AgentDevicePlugin despite the replay branches' unique-symbol
brands. Update the aws smoke fixture to the v3 contributes shape.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Repair the dead-code, complexity, and duplication findings the 0.22
plugin contract v3 change introduced, without suppressions or baselines.

- make module-private helpers non-exported (`incompatiblePluginApi`,
  `nodeRangeFloor`), and drop unused exported helpers (`claimKeysOf`, the
  `Contribution` type re-export)
- extract `providerClaim`, `replayBackendClaim`, and `replayExecutionClaim`
  from `readAgentDeviceClaims`, and `setUpClaims`, `setUpClaim`,
  `resolveRegisteredReplayExecution`, `failedLoadClaimFor`, and
  `assertStoreSelectionCurrent` from the registration and replay paths
- share the hosted App Automate connection resolution and validation in
  `@agent-device/provider-webdriver/plugin` as lazy loaders, so the
  BrowserStack and TestMu entries call one owner without importing the
  WebDriver runtime at plugin load time
Contract v3 made `Contribution` name the host, format-backend and
native-execution declarations, so those declarations started splitting
across two published chunks. TypeScript then saw two unrelated types with
the same name, and a consumer could not pass a plugin from one public
entry into another entry's function.

- pin the plugin contract and the contract declarations it names into the
  shared `sdk-replay-backend.d` declaration chunk
- type `startAgentDevice` `plugins` through the contract package with the
  WebDriver options the host composes, so the SDK index no longer pulls
  the `./plugins` entry into a shared chunk whose exports get mangled
- declare the Replay plugin's published types against
  `agent-device/plugins`, as the Maestro entry already does
- write the integration fixtures' plugin objects in contract v3, including
  the typed `incompatible-plugin-api` reason the host now reports
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.17 MB 6.18 MB +8.2 kB
Package (unpacked) 6.17 MB 6.18 MB +8.2 kB
Package (download) 1.88 MB 1.88 MB +2.4 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 43.1 ms 42.6 ms -0.5 ms
CLI --help 61.8 ms 85.7 ms +23.9 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: 2 new findings on 73f893c. The verdict and the full list are in the summary comment.

Comment thread packages/plugins/src/registry.ts Resolved
Comment thread src/builtin-provider-plugins.ts Resolved
@thymikee

thymikee commented Nov 20, 2026 •

Copy link
Copy Markdown
Member Author

Thanks for the contract move. At 73f893c there are two problems that need fixing before merge, and the failing device Smoke Tests are most likely caused by the first one. The link to the first problem comes from the diff and the workflow routes.

The non-source install writes a package.json with only name, version, type and exports (scripts/install-workspace-replay-plugins.ts:57). CI runs this mode (node scripts/install-workspace-replay-plugins.ts, used by android.yml, apple.yml and the run-gate action). It drops the new agent-device and engines fields, so readAgentDeviceClaims at store.ts:167 throws incompatible-plugin-api for @agent-device/maestro and @agent-device/replay before import. Native .ad replay/test and Maestro are then unavailable on every device lane that uses this install. Unit lanes pass because vitest globalSetup installs in source (symlink) mode, which keeps the full manifest. Every writer that materializes a plugin package.json for the store must keep the manifest fields the store validates before import. Here that means copying manifest['agent-device'] and manifest.engines into the written file, since this is the only writer of publishConfig.exports. Please add a non-source-mode case to scripts/__tests__/install-workspace-replay-plugins.test.ts that reads the written manifest through readAgentDeviceClaims.

packages/replay/README.md:11 still says the plugin uses API version 2 and that the managed API version 2 check applies. packages/replay/src/plugin.ts now returns apiVersion 3 with a replay-execution contribution, and the host rejects version 2. Anyone following the npm README gets a package the host refuses. Please state API version 3 and the replay-execution contribution, declared as agent-device {apiVersion: 3, replayExecution: true}.

The change reroutes how native .ad replay/test and provider runtimes reach devices, so the device Smoke Tests are its live evidence. After the install fix, it needs green Android, iOS, macOS and Linux Smoke Tests at the new head. The .ad replay step (for example agent-device test test/integration/replays/android/emulator/01-settings.ad) must pass against the store-installed @agent-device/replay and @agent-device/maestro. agent-device plugins list or the daemon status inventory should show both as active v3 claims (replay-execution ad, replay-backend maestro). No test covers the non-source workspace install that CI uses.

Not blocking, and you can take or leave these: (1) a slot that fails to load reserves claims from readProviderId/readBackendId (registry.ts:287, 750-772) instead of its declaredClaims, so a store package that throws after valid metadata reserves nothing, which contradicts ADR 0034 "the first registration keeps its claim even when that registration fails", and a failed replay-execution load lands in claimed.backend instead of claimed.execution; a failed slot should reserve exactly the claim keys it declares, in their own spaces; (2) discovery.ts:140-164 adds its own version compare while @agent-device/host-kit/version already exports compareVersions, which packages/plugins already imports; (3) the incompatible-API error, the reserved-provider check and the reserved ad backend check are each built twice across discovery.ts, validate.ts and registry.ts; (4) the Fallow duplication fix in packages/provider-webdriver/src/plugin.ts:39 adds 53 lines of hosted-connection helpers and an extra dynamic import per connect, replacing a 3-line loader per provider, and a config accept would be smaller; (5) plugins.md:177 says a version 2 package is listed as failed, but plugins add/update now refuse it, and the hint "Install a plugin release supporting apiVersion 3" misleads an author of a v3 package who forgot the agent-device field; (6) metadata accepts two spellings for one claim (replayExecution true or 'ad'), and ADR 0034:39, ADR 0012:23 and the storePluginCandidates comment in store.ts still describe version 2 or pre-import behavior; (7) the gross diff is 3350 lines, above the 2,500-line bound in docs/agents/pull-requests.md, though net production is 641 and no split is needed.

Could one CLAIM_KINDS record in validate.ts, keyed by kind (provider, replay-backend, replay-execution), replace most of that? Each entry would hold the metadata field, the id reader, the reserved ids, the duplicate reason and the setup check. readAgentDeviceClaims and claimKeyOfContribution would both return typed { kind, id } claims through it, with one incompatible-API builder, and the registry would keep one Map<kind, Set<id>>. A failed slot would reserve its declaredClaims, which removes readProviderId, readBackendId and the Slot.provider/backend pre-read fields. Reusing compareVersions, dropping the webdriver helpers, and having Limrun export its connection would also remove the ! and the ./validate export in src/builtin-provider-plugins.ts, and the platform kind in #4597 would then be one table entry plus its setup.

The open inline thread on registry cleanup now awaiting serially and the one on connection! in the Limrun plugin still apply as lower-priority threads. Neither blocks merge, and the Limrun one goes away if Limrun exports its connection directly.

Addresses the review on #4784.

- install: copy the `agent-device` claim block and `engines` into non-source
  package.json, with a non-source install test
- claims: one CLAIM_KINDS record returns typed { kind, id } claims; the registry
  keeps one Map<kind, Set<id>>; a failed slot reserves exactly declaredClaims,
  and one metadata spelling exists per claim
- reuse compareVersions from @agent-device/host-kit/version
- Limrun exports its connection; webdriver no longer carries the shared
  HostedConnection loader shim
- docs: plugins guide, replay README, ADR 0012, ADR 0034 and the
  incompatible-plugin-api hint match the contract
An embedder plugin carries no package metadata, so nothing names its claims
before the factory runs. When its validation failed, resolution found no claim
and reported the engine as absent. A selected package keeps its own load,
compatibility or setup reason: a store package answers for the name the caller
selected, and a candidate the embedding host supplied answers because no name
can exclude it.
A candidate that fails before its contributions are readable still has to say
what it was meant to provide: the inventory names it, and the selection that
asked for that claim resolves to its reason. The id is read through the same
CLAIM_KINDS table the validated readers use, so no second reader exists, and a
slot whose package metadata already declared its claims is left as it was.
@thymikee

Copy link
Copy Markdown
Member Author

All findings addressed at 38fe33365a. Point by point:

1. Non-source install dropped the claim block (blocker) — scripts/install-workspace-replay-plugins.ts now copies manifest['agent-device'] and manifest.engines into the written package.json, alongside the published exports. You're right that unit lanes could never see this: vitest globalSetup installs in symlink mode, which keeps the whole manifest. Covered by a new non-source case in scripts/__tests__/install-workspace-replay-plugins.test.ts — it installs both workspace plugins into a temp AGENT_DEVICE_HOME in the mode CI uses and reads the staged manifests back through readPluginPackageClaims, so a dropped field fails there instead of only on a device lane. The device lanes remain the live evidence for this shape: Apple and Android run this exact install step before the native .ad and Maestro replays, so their Smoke Tests at this head are what shows both packages registering as active v3 claims (replay-execution ad, replay-backend maestro). They are running with this push; nothing here claims they're green yet.

2. packages/replay/README.md:11 — now says version 3, names the replay-execution contribution, and shows "agent-device": { "apiVersion": 3, "replayExecution": true }.

3. One claim record, no parallel arrays — packages/plugins/src/validate.ts now owns one CLAIM_KINDS table keyed by ClaimKind. Each entry carries the metadata field, the contribution id field, the reserved ids, the duplicate reason, identityFor, readMetadata, readContribution and validateSetup. Both readers return readonly PluggedClaim[] — { kind, id }, never a bare id:

export type PluggedClaim = Readonly<{ kind: ClaimKind; id: string }>;

The registry keeps one Map<ClaimKind, Set<string>> instead of the three Sets; claimObstacle() is the one reserved-then-duplicate check; claimKeyOf() is the one spelling of kind:id used by the store, the registry and the errors; reservedClaimError/duplicateClaimError/validateClaimSetup each exist once. Your non-blocking (1) and (3) are in here: a slot reserves its declaredClaims before the factory runs, readProviderId/readBackendId and the Slot.provider/backend pre-read fields are gone, and a failed replay-execution load lands in its own space.

Your (6), the two spellings: replayExecution now accepts only true, because the id ad belongs to the kind and not to the package.

4. compareVersions — packages/plugins/src/discovery.ts imports it from @agent-device/host-kit/version; the hand-written comparison is gone.

5. Limrun's connection — packages/provider-limrun/src/plugin.ts exports LIMRUN_CONNECTION through internal.ts, builtinLimrunConnection() takes no argument, and the caller in src/cli/connection/connect-provider-adapters.ts passes the host per call. Both the connection! assertion and the ./validate deep import in src/builtin-provider-plugins.ts are gone, which also retires inline thread r4637510790.

6. Serial reverse-order close — kept on purpose, now with the reason where you looked. close() walks activated claims in reverse activation order: each runtime shuts down before its own disposer, and one disposer's work is the next one's precondition, so it cannot be a Promise.all. That sequence is the ownership order ADR 0034 records. A hanging disposer is bounded by the daemon shutdown timeout, and the outcome record still names the claim that never settled. Reply in r4637510743.

7. Docs — website/docs/docs/plugins.md documents apiVersion 3, the three claim kinds, static agent-device metadata, contributes, setup(host), and states that plugins add/update refuse a version 2 package rather than listing it as failed. Your (5): the incompatible-plugin-api hint now separates "has no agent-device package.json field with an apiVersion" from "declares apiVersion N", so the v3 author who lost the field isn't sent looking for another release. ADR 0034 and ADR 0012 describe contributes + setup, the storePluginCandidates comment describes declared claims, and the @agent-device/replay contract is described as the one the host resolves.

8. webdriver Fallow helpers — not accepted as new duplication; your instinct was right and the config accept wasn't needed either. The 53-line HostedConnection loader shim is dropped from packages/provider-webdriver/src/plugin.ts, and BrowserStack and TestMu call their own lazy loader inline, matching the shape those packages had on 0.22. fallow audit --base origin/0.22 reports no issues in the changed files with no ignore entry.

Two behaviour regressions the first attempt at (3) introduced, both caught by gates and fixed in the two follow-up commits, since they're in the same code you're reading:

  • An embedder plugin has no package metadata, so nothing names its claims before the factory runs. When its validation failed, resolution found no claim and answered plugin-not-installed — a chosen plugin reporting itself absent, against ADR 0034. It now keeps its typed reason (a6426ad2be).
  • The same removal also took the failed plugin's name out of the inventory, which test/integration/installed-package-metro.test.ts checks. A slot that fails before its contributions are readable now names its claims through the same CLAIM_KINDS table (readableClaimsOfValue), so there is still no second reader (38fe33365a).

Gate receipt at this head: pnpm check:affected --run --base origin/0.22 --head 38fe33365a — passed, exactCommit: true, 42 checks passed, 28 skipped as GitHub-authoritative, 22,123 tests, 0 failed. pnpm run check:package, pnpm exec fallow audit --base origin/0.22, pnpm run check:production-exports, format, lint and typecheck all pass locally. No device run beyond what CI does.

@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: 2 new findings on 38fe333. The verdict and the full list are in the summary comment.

Comment thread packages/plugins/src/host.ts Resolved
Comment thread packages/plugins/src/registry.ts Resolved
Close starts teardowns in reverse activation order and runs them concurrently, so one hanging disposer no longer stalls the rest; each runtime still shuts down before its disposer. A claim that failed its reservation keeps that reason when its factory also fails. The migration guide says replay setup now receives only clientVersion and createError.
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. At c0c5820, the concurrent teardown and the lazy Limrun connection are fixed, and the replay setup claim in plugins.md is only half fixed. Three items remain; the earlier review is at #4784 (comment).

The restored test in replay-backend.test.ts:61 does not pin the concurrency guarantee. close() now tears down in reverse activation order, so second closes first. With the old serial loop, second.dispose still runs before the hanging first.dispose, and the test passes with or without the Promise.all at registry.ts:397. A revert to the serial loop would stay green, and one hanging disposer would again stall daemon shutdown. The rule is that no claim's teardown waits on another claim's teardown. Please make the claim that closes first (the later-activated one) hang, assert the other was disposed before release, and check that the test fails against the serial loop.

In validate.ts:182, readableClaimsOfValue replaced readBackendId, and it no longer reads the shipped v2 replay shapes: { apiVersion: 2, kind: 'replay-backend', backend: 'ad' } from @agent-device/replay and { ..., backend: 'maestro' } from @agent-device/maestro. An embedder that passes one of these to startAgentDevice({ plugins }) gets a slot with no claims. Then requireReplayClaim (registry.ts:525) throws plugin-not-installed instead of incompatible-plugin-api, and the inventory entry has no backend id. ADR 0034 requires these outcomes to stay distinct. The rule is that a present candidate that fails validation names every claim its returned value spells, in every shape the host refuses. readableClaimsOfValue is the one owner, so please read a top-level kind plus backend record as one contribution, mapping the reserved id ad to replay-execution as before. The apiVersion 99 test fixture is v3-shaped, so it does not cover this. Please replace it with the real v2 return shape for both replay and Maestro, and assert that resolveReplayExecution and resolveReplayBackend reject with incompatible-plugin-api.

The migration step at plugins.md:183 says to move host-command and environment work into the lazy create(host). A replay-execution create() receives no argument (registry.ts:482). A replay-backend host offers runCommand, but no environment read at create time. An author who follows the step will read host fields that do not exist. Please say that a replay-backend's host-command work moves into replayBackend.create(host), that execution.create() receives no host, and drop "reads the environment" or name the per-request host that carries env.

Not blocking, and you can take or leave these: ResolvedProviderPlugins.claims, ResolvedClaim and claimsOf() are read only by src/host-replay.test.ts, so the test could resolve through startProviderRegistry instead; Claim.contribution became optional, which needs an unreachable branch at registry.ts:434, optional chaining and a cast at registry.ts:443, so keeping reservations separate and returning the typed setup from validateClaimSetup would keep it required; and validate.ts:156 has per-kind branches outside CLAIM_KINDS (the reserved reason and message, and claimIdSpelledBy repeating true -> ad) that could move into the table entry.

On the open threads: #4784 (comment) (concurrent teardown) still applies until the test above pins it, and #4784 (comment) (create(host) docs) still applies until the docs fix. These two can be resolved now: #4784 (comment) (the connection! is gone) and #4784 (comment) (claim.failure ??= slot.failure is fixed with a regression test, and the loser keeping its own reason is intended).

All 17 checks at c0c5820 are green except Mutants, which is skipped, and that includes the Android, iOS, macOS and Linux smoke tests that run the store-installed v3 replay and Maestro claims. The active v3 claims are inferred from those smoke runs and the unit test's compatible=true assertion, since no plugins list output is in the logs. There are no conflicts. Before merge, the concurrency test needs to fail on the serial loop, v2-shaped embedder plugins need to answer incompatible-plugin-api with a real v2 test, and the plugins.md sentence needs fixing.

A refused version 2 replay or Maestro value ({ kind: 'replay-backend', backend }) names its claim again, so its selection answers incompatible-plugin-api instead of plugin-not-installed. The teardown test hangs the claim that closes first, so it fails against a serial loop. The migration guide says where replay host-command work moves.
@thymikee

Copy link
Copy Markdown
Member Author

Pushed 770eb01889. It answers the review at c0c5820 (#4784 (comment)).

  1. Concurrency test: the claim that closes first (the one activated last) now hangs, and the test asserts the other claim was disposed before the release. I checked it against the serial loop: it fails there.
  2. Version 2 replay shapes: readableClaimsOfValue reads a top-level { kind: 'replay-backend', backend } again, with ad mapped to replay-execution. New test with the real version 2 return values of @agent-device/replay and @agent-device/maestro: resolveReplayExecution and resolveReplayBackend both reject with incompatible-plugin-api and declaredApiVersion: 2, the Maestro inventory entry keeps its backend id, and no setup runs.
  3. plugins.md: a replay backend moves host-command work into replayBackend.create(host); execution.create() receives no host. The environment wording is gone.

Exact affected validation passed (42 passed, 28 skipped). The three non-blocking items (claimsOf used only by a test, optional Claim.contribution, per-kind branches outside CLAIM_KINDS) are not in this push; they fit the platform-kind work in #4792, which touches the same table.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 770eb01

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

No open findings.

Not in the reviewers' prompt (10 files)
  • packages/maestro/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/plugins/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/provider-aws-device-farm/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/provider-browserstack/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/provider-limrun/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/provider-revyl/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/provider-testmu/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/provider-tizen/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/provider-webos/package.json: left out as an asset or for its size; reviewers could still search it
  • tsdown.config.ts: left out as an asset or for its size; reviewers could still search it

1 new finding away from what changed since c0c5820 not shown. Comment @apex-sentinel-staging review for a full review.

Reviewed with this repository's own Sentinel configuration (5b906b7d40f1).

💬 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.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 770eb01. The three items from the earlier review are fixed:

  • The teardown test now hangs the claim that closes first, so a serial loop would fail it.
  • A refused candidate in the real version 2 replay or Maestro shape names its claim, so selection answers incompatible-plugin-api instead of plugin-not-installed. A test pins both shapes and checks that setup never runs.
  • The plugins.md migration step no longer promises host fields that create() does not receive.

All checks pass, including the four device smoke lanes.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@thymikee
thymikee merged commit 6f60c1e into 0.22 Nov 20, 2026
17 checks passed
@thymikee
thymikee deleted the refactor/0.22-plugin-contract-v3 branch November 20, 2026 11:16
thymikee added a commit that referenced this pull request Nov 20, 2026
* refactor(plugins): declare contract version 3 with per-kind contributions

AgentDevicePlugin is now { apiVersion: 3, contributes: [Contribution, ...] } with
provider, replay-backend and replay-execution kinds. The registry validates the whole
declaration, expands it into per-claim records, and reserves claim spaces in candidate
order. All nine maintained plugins wrap their factories in contributes. No shim: a
version 2 result gets the typed incompatible-plugin-api outcome.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* refactor(plugins): read static claims from package metadata before import

The store reads package.json agent-device { apiVersion, provider?, replayBackend?,
replayExecution? }: a version other than 3 fails pre-import with the typed
incompatible-plugin-api reason, engines.node establishes the Node floor
(node-below-floor), and reserved or malformed claim ids fail before any code runs.
After the factory runs with its options, the returned claim keys must equal the
declared ones unordered, or the package is invalid. All nine maintained packages
declare their claims and the Node floor.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* test(plugins): cover the version 3 contract in the registry and store suites

Update the existing suites to the contributes shape and add: a version 2 factory
and a version 2 metadata package both get incompatible-plugin-api; a metadata /
factory claim mismatch invalidates the package; cross-package duplicates keep the
first claim and fail the loser; a multi-kind package activates its replay claim
when its provider setup fails; the replay-only scope sets up no provider claim;
close runs activated claims in reverse activation order with per-step outcomes.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* docs(plugins): show the version 3 authoring shape

The plugins guide now documents contributes with per-kind contributions, the
agent-device package.json field with static claim keys, the engines Node floor,
the replay-execution ad kind, and the incompatible-plugin-api outcome for
version 2 packages.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): apply oxfmt to the version 3 contract files

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* fix(plugins): keep provider plugin declarations in the provider branch

AgentDevicePlugin gains a defaulted contribution generic so provider
packages can declare ProviderOnlyPlugin/ProviderAgentDevicePlugin; their
packed .d.mts then inline only the provider branch and stay assignable to
the host's AgentDevicePlugin despite the replay branches' unique-symbol
brands. Update the aws smoke fixture to the v3 contributes shape.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): merge duplicate plugin type imports in provider tests

* chore(gates): resolve Fallow findings for plugin contract v3

Repair the dead-code, complexity, and duplication findings the 0.22
plugin contract v3 change introduced, without suppressions or baselines.

- make module-private helpers non-exported (`incompatiblePluginApi`,
  `nodeRangeFloor`), and drop unused exported helpers (`claimKeysOf`, the
  `Contribution` type re-export)
- extract `providerClaim`, `replayBackendClaim`, and `replayExecutionClaim`
  from `readAgentDeviceClaims`, and `setUpClaims`, `setUpClaim`,
  `resolveRegisteredReplayExecution`, `failedLoadClaimFor`, and
  `assertStoreSelectionCurrent` from the registration and replay paths
- share the hosted App Automate connection resolution and validation in
  `@agent-device/provider-webdriver/plugin` as lazy loaders, so the
  BrowserStack and TestMu entries call one owner without importing the
  WebDriver runtime at plugin load time

* fix(plugins): keep the published contract types single-sourced

Contract v3 made `Contribution` name the host, format-backend and
native-execution declarations, so those declarations started splitting
across two published chunks. TypeScript then saw two unrelated types with
the same name, and a consumer could not pass a plugin from one public
entry into another entry's function.

- pin the plugin contract and the contract declarations it names into the
  shared `sdk-replay-backend.d` declaration chunk
- type `startAgentDevice` `plugins` through the contract package with the
  WebDriver options the host composes, so the SDK index no longer pulls
  the `./plugins` entry into a shared chunk whose exports get mangled
- declare the Replay plugin's published types against
  `agent-device/plugins`, as the Maestro entry already does
- write the integration fixtures' plugin objects in contract v3, including
  the typed `incompatible-plugin-api` reason the host now reports

* refactor(plugins): one typed claim record and honest declared claims

Addresses the review on #4784.

- install: copy the `agent-device` claim block and `engines` into non-source
  package.json, with a non-source install test
- claims: one CLAIM_KINDS record returns typed { kind, id } claims; the registry
  keeps one Map<kind, Set<id>>; a failed slot reserves exactly declaredClaims,
  and one metadata spelling exists per claim
- reuse compareVersions from @agent-device/host-kit/version
- Limrun exports its connection; webdriver no longer carries the shared
  HostedConnection loader shim
- docs: plugins guide, replay README, ADR 0012, ADR 0034 and the
  incompatible-plugin-api hint match the contract

* fix(plugins): a failed candidate keeps answering the replay selection

An embedder plugin carries no package metadata, so nothing names its claims
before the factory runs. When its validation failed, resolution found no claim
and reported the engine as absent. A selected package keeps its own load,
compatibility or setup reason: a store package answers for the name the caller
selected, and a candidate the embedding host supplied answers because no name
can exclude it.

* fix(plugins): name a failed load's claims through the claim table

A candidate that fails before its contributions are readable still has to say
what it was meant to provide: the inventory names it, and the selection that
asked for that claim resolves to its reason. The id is read through the same
CLAIM_KINDS table the validated readers use, so no second reader exists, and a
slot whose package metadata already declared its claims is left as it was.

* fix(plugins): tear down claims concurrently and keep duplicate reasons

Close starts teardowns in reverse activation order and runs them concurrently, so one hanging disposer no longer stalls the rest; each runtime still shuts down before its disposer. A claim that failed its reservation keeps that reason when its factory also fails. The migration guide says replay setup now receives only clientVersion and createError.

* fix(plugins): name version 2 replay claims and pin concurrent teardown

A refused version 2 replay or Maestro value ({ kind: 'replay-backend', backend }) names its claim again, so its selection answers incompatible-plugin-api instead of plugin-not-installed. The teardown test hangs the claim that closes first, so it fails against a serial loop. The migration guide says where replay host-command work moves.

---------

Co-authored-by: Mistral Vibe <vibe@mistral.ai>
thymikee added a commit that referenced this pull request Nov 20, 2026
* refactor(plugins): declare contract version 3 with per-kind contributions

AgentDevicePlugin is now { apiVersion: 3, contributes: [Contribution, ...] } with
provider, replay-backend and replay-execution kinds. The registry validates the whole
declaration, expands it into per-claim records, and reserves claim spaces in candidate
order. All nine maintained plugins wrap their factories in contributes. No shim: a
version 2 result gets the typed incompatible-plugin-api outcome.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* refactor(plugins): read static claims from package metadata before import

The store reads package.json agent-device { apiVersion, provider?, replayBackend?,
replayExecution? }: a version other than 3 fails pre-import with the typed
incompatible-plugin-api reason, engines.node establishes the Node floor
(node-below-floor), and reserved or malformed claim ids fail before any code runs.
After the factory runs with its options, the returned claim keys must equal the
declared ones unordered, or the package is invalid. All nine maintained packages
declare their claims and the Node floor.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* test(plugins): cover the version 3 contract in the registry and store suites

Update the existing suites to the contributes shape and add: a version 2 factory
and a version 2 metadata package both get incompatible-plugin-api; a metadata /
factory claim mismatch invalidates the package; cross-package duplicates keep the
first claim and fail the loser; a multi-kind package activates its replay claim
when its provider setup fails; the replay-only scope sets up no provider claim;
close runs activated claims in reverse activation order with per-step outcomes.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* docs(plugins): show the version 3 authoring shape

The plugins guide now documents contributes with per-kind contributions, the
agent-device package.json field with static claim keys, the engines Node floor,
the replay-execution ad kind, and the incompatible-plugin-api outcome for
version 2 packages.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): apply oxfmt to the version 3 contract files

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* fix(plugins): keep provider plugin declarations in the provider branch

AgentDevicePlugin gains a defaulted contribution generic so provider
packages can declare ProviderOnlyPlugin/ProviderAgentDevicePlugin; their
packed .d.mts then inline only the provider branch and stay assignable to
the host's AgentDevicePlugin despite the replay branches' unique-symbol
brands. Update the aws smoke fixture to the v3 contributes shape.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): merge duplicate plugin type imports in provider tests

* chore(gates): resolve Fallow findings for plugin contract v3

Repair the dead-code, complexity, and duplication findings the 0.22
plugin contract v3 change introduced, without suppressions or baselines.

- make module-private helpers non-exported (`incompatiblePluginApi`,
  `nodeRangeFloor`), and drop unused exported helpers (`claimKeysOf`, the
  `Contribution` type re-export)
- extract `providerClaim`, `replayBackendClaim`, and `replayExecutionClaim`
  from `readAgentDeviceClaims`, and `setUpClaims`, `setUpClaim`,
  `resolveRegisteredReplayExecution`, `failedLoadClaimFor`, and
  `assertStoreSelectionCurrent` from the registration and replay paths
- share the hosted App Automate connection resolution and validation in
  `@agent-device/provider-webdriver/plugin` as lazy loaders, so the
  BrowserStack and TestMu entries call one owner without importing the
  WebDriver runtime at plugin load time

* fix(plugins): keep the published contract types single-sourced

Contract v3 made `Contribution` name the host, format-backend and
native-execution declarations, so those declarations started splitting
across two published chunks. TypeScript then saw two unrelated types with
the same name, and a consumer could not pass a plugin from one public
entry into another entry's function.

- pin the plugin contract and the contract declarations it names into the
  shared `sdk-replay-backend.d` declaration chunk
- type `startAgentDevice` `plugins` through the contract package with the
  WebDriver options the host composes, so the SDK index no longer pulls
  the `./plugins` entry into a shared chunk whose exports get mangled
- declare the Replay plugin's published types against
  `agent-device/plugins`, as the Maestro entry already does
- write the integration fixtures' plugin objects in contract v3, including
  the typed `incompatible-plugin-api` reason the host now reports

* refactor(plugins): one typed claim record and honest declared claims

Addresses the review on #4784.

- install: copy the `agent-device` claim block and `engines` into non-source
  package.json, with a non-source install test
- claims: one CLAIM_KINDS record returns typed { kind, id } claims; the registry
  keeps one Map<kind, Set<id>>; a failed slot reserves exactly declaredClaims,
  and one metadata spelling exists per claim
- reuse compareVersions from @agent-device/host-kit/version
- Limrun exports its connection; webdriver no longer carries the shared
  HostedConnection loader shim
- docs: plugins guide, replay README, ADR 0012, ADR 0034 and the
  incompatible-plugin-api hint match the contract

* fix(plugins): a failed candidate keeps answering the replay selection

An embedder plugin carries no package metadata, so nothing names its claims
before the factory runs. When its validation failed, resolution found no claim
and reported the engine as absent. A selected package keeps its own load,
compatibility or setup reason: a store package answers for the name the caller
selected, and a candidate the embedding host supplied answers because no name
can exclude it.

* fix(plugins): name a failed load's claims through the claim table

A candidate that fails before its contributions are readable still has to say
what it was meant to provide: the inventory names it, and the selection that
asked for that claim resolves to its reason. The id is read through the same
CLAIM_KINDS table the validated readers use, so no second reader exists, and a
slot whose package metadata already declared its claims is left as it was.

* fix(plugins): tear down claims concurrently and keep duplicate reasons

Close starts teardowns in reverse activation order and runs them concurrently, so one hanging disposer no longer stalls the rest; each runtime still shuts down before its disposer. A claim that failed its reservation keeps that reason when its factory also fails. The migration guide says replay setup now receives only clientVersion and createError.

* fix(plugins): name version 2 replay claims and pin concurrent teardown

A refused version 2 replay or Maestro value ({ kind: 'replay-backend', backend }) names its claim again, so its selection answers incompatible-plugin-api instead of plugin-not-installed. The teardown test hangs the claim that closes first, so it fails against a serial loop. The migration guide says where replay host-command work moves.

---------

Co-authored-by: Mistral Vibe <vibe@mistral.ai>
thymikee added a commit that referenced this pull request Nov 21, 2026
* refactor(plugins): declare contract version 3 with per-kind contributions

AgentDevicePlugin is now { apiVersion: 3, contributes: [Contribution, ...] } with
provider, replay-backend and replay-execution kinds. The registry validates the whole
declaration, expands it into per-claim records, and reserves claim spaces in candidate
order. All nine maintained plugins wrap their factories in contributes. No shim: a
version 2 result gets the typed incompatible-plugin-api outcome.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* refactor(plugins): read static claims from package metadata before import

The store reads package.json agent-device { apiVersion, provider?, replayBackend?,
replayExecution? }: a version other than 3 fails pre-import with the typed
incompatible-plugin-api reason, engines.node establishes the Node floor
(node-below-floor), and reserved or malformed claim ids fail before any code runs.
After the factory runs with its options, the returned claim keys must equal the
declared ones unordered, or the package is invalid. All nine maintained packages
declare their claims and the Node floor.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* test(plugins): cover the version 3 contract in the registry and store suites

Update the existing suites to the contributes shape and add: a version 2 factory
and a version 2 metadata package both get incompatible-plugin-api; a metadata /
factory claim mismatch invalidates the package; cross-package duplicates keep the
first claim and fail the loser; a multi-kind package activates its replay claim
when its provider setup fails; the replay-only scope sets up no provider claim;
close runs activated claims in reverse activation order with per-step outcomes.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* docs(plugins): show the version 3 authoring shape

The plugins guide now documents contributes with per-kind contributions, the
agent-device package.json field with static claim keys, the engines Node floor,
the replay-execution ad kind, and the incompatible-plugin-api outcome for
version 2 packages.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): apply oxfmt to the version 3 contract files

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* fix(plugins): keep provider plugin declarations in the provider branch

AgentDevicePlugin gains a defaulted contribution generic so provider
packages can declare ProviderOnlyPlugin/ProviderAgentDevicePlugin; their
packed .d.mts then inline only the provider branch and stay assignable to
the host's AgentDevicePlugin despite the replay branches' unique-symbol
brands. Update the aws smoke fixture to the v3 contributes shape.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): merge duplicate plugin type imports in provider tests

* chore(gates): resolve Fallow findings for plugin contract v3

Repair the dead-code, complexity, and duplication findings the 0.22
plugin contract v3 change introduced, without suppressions or baselines.

- make module-private helpers non-exported (`incompatiblePluginApi`,
  `nodeRangeFloor`), and drop unused exported helpers (`claimKeysOf`, the
  `Contribution` type re-export)
- extract `providerClaim`, `replayBackendClaim`, and `replayExecutionClaim`
  from `readAgentDeviceClaims`, and `setUpClaims`, `setUpClaim`,
  `resolveRegisteredReplayExecution`, `failedLoadClaimFor`, and
  `assertStoreSelectionCurrent` from the registration and replay paths
- share the hosted App Automate connection resolution and validation in
  `@agent-device/provider-webdriver/plugin` as lazy loaders, so the
  BrowserStack and TestMu entries call one owner without importing the
  WebDriver runtime at plugin load time

* fix(plugins): keep the published contract types single-sourced

Contract v3 made `Contribution` name the host, format-backend and
native-execution declarations, so those declarations started splitting
across two published chunks. TypeScript then saw two unrelated types with
the same name, and a consumer could not pass a plugin from one public
entry into another entry's function.

- pin the plugin contract and the contract declarations it names into the
  shared `sdk-replay-backend.d` declaration chunk
- type `startAgentDevice` `plugins` through the contract package with the
  WebDriver options the host composes, so the SDK index no longer pulls
  the `./plugins` entry into a shared chunk whose exports get mangled
- declare the Replay plugin's published types against
  `agent-device/plugins`, as the Maestro entry already does
- write the integration fixtures' plugin objects in contract v3, including
  the typed `incompatible-plugin-api` reason the host now reports

* refactor(plugins): one typed claim record and honest declared claims

Addresses the review on #4784.

- install: copy the `agent-device` claim block and `engines` into non-source
  package.json, with a non-source install test
- claims: one CLAIM_KINDS record returns typed { kind, id } claims; the registry
  keeps one Map<kind, Set<id>>; a failed slot reserves exactly declaredClaims,
  and one metadata spelling exists per claim
- reuse compareVersions from @agent-device/host-kit/version
- Limrun exports its connection; webdriver no longer carries the shared
  HostedConnection loader shim
- docs: plugins guide, replay README, ADR 0012, ADR 0034 and the
  incompatible-plugin-api hint match the contract

* fix(plugins): a failed candidate keeps answering the replay selection

An embedder plugin carries no package metadata, so nothing names its claims
before the factory runs. When its validation failed, resolution found no claim
and reported the engine as absent. A selected package keeps its own load,
compatibility or setup reason: a store package answers for the name the caller
selected, and a candidate the embedding host supplied answers because no name
can exclude it.

* fix(plugins): name a failed load's claims through the claim table

A candidate that fails before its contributions are readable still has to say
what it was meant to provide: the inventory names it, and the selection that
asked for that claim resolves to its reason. The id is read through the same
CLAIM_KINDS table the validated readers use, so no second reader exists, and a
slot whose package metadata already declared its claims is left as it was.

* fix(plugins): tear down claims concurrently and keep duplicate reasons

Close starts teardowns in reverse activation order and runs them concurrently, so one hanging disposer no longer stalls the rest; each runtime still shuts down before its disposer. A claim that failed its reservation keeps that reason when its factory also fails. The migration guide says replay setup now receives only clientVersion and createError.

* fix(plugins): name version 2 replay claims and pin concurrent teardown

A refused version 2 replay or Maestro value ({ kind: 'replay-backend', backend }) names its claim again, so its selection answers incompatible-plugin-api instead of plugin-not-installed. The teardown test hangs the claim that closes first, so it fails against a serial loop. The migration guide says where replay host-command work moves.

---------

Co-authored-by: Mistral Vibe <vibe@mistral.ai>
thymikee added a commit that referenced this pull request Nov 21, 2026
* refactor(plugins): declare contract version 3 with per-kind contributions

AgentDevicePlugin is now { apiVersion: 3, contributes: [Contribution, ...] } with
provider, replay-backend and replay-execution kinds. The registry validates the whole
declaration, expands it into per-claim records, and reserves claim spaces in candidate
order. All nine maintained plugins wrap their factories in contributes. No shim: a
version 2 result gets the typed incompatible-plugin-api outcome.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* refactor(plugins): read static claims from package metadata before import

The store reads package.json agent-device { apiVersion, provider?, replayBackend?,
replayExecution? }: a version other than 3 fails pre-import with the typed
incompatible-plugin-api reason, engines.node establishes the Node floor
(node-below-floor), and reserved or malformed claim ids fail before any code runs.
After the factory runs with its options, the returned claim keys must equal the
declared ones unordered, or the package is invalid. All nine maintained packages
declare their claims and the Node floor.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* test(plugins): cover the version 3 contract in the registry and store suites

Update the existing suites to the contributes shape and add: a version 2 factory
and a version 2 metadata package both get incompatible-plugin-api; a metadata /
factory claim mismatch invalidates the package; cross-package duplicates keep the
first claim and fail the loser; a multi-kind package activates its replay claim
when its provider setup fails; the replay-only scope sets up no provider claim;
close runs activated claims in reverse activation order with per-step outcomes.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* docs(plugins): show the version 3 authoring shape

The plugins guide now documents contributes with per-kind contributions, the
agent-device package.json field with static claim keys, the engines Node floor,
the replay-execution ad kind, and the incompatible-plugin-api outcome for
version 2 packages.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): apply oxfmt to the version 3 contract files

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* fix(plugins): keep provider plugin declarations in the provider branch

AgentDevicePlugin gains a defaulted contribution generic so provider
packages can declare ProviderOnlyPlugin/ProviderAgentDevicePlugin; their
packed .d.mts then inline only the provider branch and stay assignable to
the host's AgentDevicePlugin despite the replay branches' unique-symbol
brands. Update the aws smoke fixture to the v3 contributes shape.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): merge duplicate plugin type imports in provider tests

* chore(gates): resolve Fallow findings for plugin contract v3

Repair the dead-code, complexity, and duplication findings the 0.22
plugin contract v3 change introduced, without suppressions or baselines.

- make module-private helpers non-exported (`incompatiblePluginApi`,
  `nodeRangeFloor`), and drop unused exported helpers (`claimKeysOf`, the
  `Contribution` type re-export)
- extract `providerClaim`, `replayBackendClaim`, and `replayExecutionClaim`
  from `readAgentDeviceClaims`, and `setUpClaims`, `setUpClaim`,
  `resolveRegisteredReplayExecution`, `failedLoadClaimFor`, and
  `assertStoreSelectionCurrent` from the registration and replay paths
- share the hosted App Automate connection resolution and validation in
  `@agent-device/provider-webdriver/plugin` as lazy loaders, so the
  BrowserStack and TestMu entries call one owner without importing the
  WebDriver runtime at plugin load time

* fix(plugins): keep the published contract types single-sourced

Contract v3 made `Contribution` name the host, format-backend and
native-execution declarations, so those declarations started splitting
across two published chunks. TypeScript then saw two unrelated types with
the same name, and a consumer could not pass a plugin from one public
entry into another entry's function.

- pin the plugin contract and the contract declarations it names into the
  shared `sdk-replay-backend.d` declaration chunk
- type `startAgentDevice` `plugins` through the contract package with the
  WebDriver options the host composes, so the SDK index no longer pulls
  the `./plugins` entry into a shared chunk whose exports get mangled
- declare the Replay plugin's published types against
  `agent-device/plugins`, as the Maestro entry already does
- write the integration fixtures' plugin objects in contract v3, including
  the typed `incompatible-plugin-api` reason the host now reports

* refactor(plugins): one typed claim record and honest declared claims

Addresses the review on #4784.

- install: copy the `agent-device` claim block and `engines` into non-source
  package.json, with a non-source install test
- claims: one CLAIM_KINDS record returns typed { kind, id } claims; the registry
  keeps one Map<kind, Set<id>>; a failed slot reserves exactly declaredClaims,
  and one metadata spelling exists per claim
- reuse compareVersions from @agent-device/host-kit/version
- Limrun exports its connection; webdriver no longer carries the shared
  HostedConnection loader shim
- docs: plugins guide, replay README, ADR 0012, ADR 0034 and the
  incompatible-plugin-api hint match the contract

* fix(plugins): a failed candidate keeps answering the replay selection

An embedder plugin carries no package metadata, so nothing names its claims
before the factory runs. When its validation failed, resolution found no claim
and reported the engine as absent. A selected package keeps its own load,
compatibility or setup reason: a store package answers for the name the caller
selected, and a candidate the embedding host supplied answers because no name
can exclude it.

* fix(plugins): name a failed load's claims through the claim table

A candidate that fails before its contributions are readable still has to say
what it was meant to provide: the inventory names it, and the selection that
asked for that claim resolves to its reason. The id is read through the same
CLAIM_KINDS table the validated readers use, so no second reader exists, and a
slot whose package metadata already declared its claims is left as it was.

* fix(plugins): tear down claims concurrently and keep duplicate reasons

Close starts teardowns in reverse activation order and runs them concurrently, so one hanging disposer no longer stalls the rest; each runtime still shuts down before its disposer. A claim that failed its reservation keeps that reason when its factory also fails. The migration guide says replay setup now receives only clientVersion and createError.

* fix(plugins): name version 2 replay claims and pin concurrent teardown

A refused version 2 replay or Maestro value ({ kind: 'replay-backend', backend }) names its claim again, so its selection answers incompatible-plugin-api instead of plugin-not-installed. The teardown test hangs the claim that closes first, so it fails against a serial loop. The migration guide says where replay host-command work moves.

---------

Co-authored-by: Mistral Vibe <vibe@mistral.ai>
thymikee added a commit that referenced this pull request Nov 23, 2026
* refactor(plugins): declare contract version 3 with per-kind contributions

AgentDevicePlugin is now { apiVersion: 3, contributes: [Contribution, ...] } with
provider, replay-backend and replay-execution kinds. The registry validates the whole
declaration, expands it into per-claim records, and reserves claim spaces in candidate
order. All nine maintained plugins wrap their factories in contributes. No shim: a
version 2 result gets the typed incompatible-plugin-api outcome.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* refactor(plugins): read static claims from package metadata before import

The store reads package.json agent-device { apiVersion, provider?, replayBackend?,
replayExecution? }: a version other than 3 fails pre-import with the typed
incompatible-plugin-api reason, engines.node establishes the Node floor
(node-below-floor), and reserved or malformed claim ids fail before any code runs.
After the factory runs with its options, the returned claim keys must equal the
declared ones unordered, or the package is invalid. All nine maintained packages
declare their claims and the Node floor.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* test(plugins): cover the version 3 contract in the registry and store suites

Update the existing suites to the contributes shape and add: a version 2 factory
and a version 2 metadata package both get incompatible-plugin-api; a metadata /
factory claim mismatch invalidates the package; cross-package duplicates keep the
first claim and fail the loser; a multi-kind package activates its replay claim
when its provider setup fails; the replay-only scope sets up no provider claim;
close runs activated claims in reverse activation order with per-step outcomes.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* docs(plugins): show the version 3 authoring shape

The plugins guide now documents contributes with per-kind contributions, the
agent-device package.json field with static claim keys, the engines Node floor,
the replay-execution ad kind, and the incompatible-plugin-api outcome for
version 2 packages.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): apply oxfmt to the version 3 contract files

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* fix(plugins): keep provider plugin declarations in the provider branch

AgentDevicePlugin gains a defaulted contribution generic so provider
packages can declare ProviderOnlyPlugin/ProviderAgentDevicePlugin; their
packed .d.mts then inline only the provider branch and stay assignable to
the host's AgentDevicePlugin despite the replay branches' unique-symbol
brands. Update the aws smoke fixture to the v3 contributes shape.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): merge duplicate plugin type imports in provider tests

* chore(gates): resolve Fallow findings for plugin contract v3

Repair the dead-code, complexity, and duplication findings the 0.22
plugin contract v3 change introduced, without suppressions or baselines.

- make module-private helpers non-exported (`incompatiblePluginApi`,
  `nodeRangeFloor`), and drop unused exported helpers (`claimKeysOf`, the
  `Contribution` type re-export)
- extract `providerClaim`, `replayBackendClaim`, and `replayExecutionClaim`
  from `readAgentDeviceClaims`, and `setUpClaims`, `setUpClaim`,
  `resolveRegisteredReplayExecution`, `failedLoadClaimFor`, and
  `assertStoreSelectionCurrent` from the registration and replay paths
- share the hosted App Automate connection resolution and validation in
  `@agent-device/provider-webdriver/plugin` as lazy loaders, so the
  BrowserStack and TestMu entries call one owner without importing the
  WebDriver runtime at plugin load time

* fix(plugins): keep the published contract types single-sourced

Contract v3 made `Contribution` name the host, format-backend and
native-execution declarations, so those declarations started splitting
across two published chunks. TypeScript then saw two unrelated types with
the same name, and a consumer could not pass a plugin from one public
entry into another entry's function.

- pin the plugin contract and the contract declarations it names into the
  shared `sdk-replay-backend.d` declaration chunk
- type `startAgentDevice` `plugins` through the contract package with the
  WebDriver options the host composes, so the SDK index no longer pulls
  the `./plugins` entry into a shared chunk whose exports get mangled
- declare the Replay plugin's published types against
  `agent-device/plugins`, as the Maestro entry already does
- write the integration fixtures' plugin objects in contract v3, including
  the typed `incompatible-plugin-api` reason the host now reports

* refactor(plugins): one typed claim record and honest declared claims

Addresses the review on #4784.

- install: copy the `agent-device` claim block and `engines` into non-source
  package.json, with a non-source install test
- claims: one CLAIM_KINDS record returns typed { kind, id } claims; the registry
  keeps one Map<kind, Set<id>>; a failed slot reserves exactly declaredClaims,
  and one metadata spelling exists per claim
- reuse compareVersions from @agent-device/host-kit/version
- Limrun exports its connection; webdriver no longer carries the shared
  HostedConnection loader shim
- docs: plugins guide, replay README, ADR 0012, ADR 0034 and the
  incompatible-plugin-api hint match the contract

* fix(plugins): a failed candidate keeps answering the replay selection

An embedder plugin carries no package metadata, so nothing names its claims
before the factory runs. When its validation failed, resolution found no claim
and reported the engine as absent. A selected package keeps its own load,
compatibility or setup reason: a store package answers for the name the caller
selected, and a candidate the embedding host supplied answers because no name
can exclude it.

* fix(plugins): name a failed load's claims through the claim table

A candidate that fails before its contributions are readable still has to say
what it was meant to provide: the inventory names it, and the selection that
asked for that claim resolves to its reason. The id is read through the same
CLAIM_KINDS table the validated readers use, so no second reader exists, and a
slot whose package metadata already declared its claims is left as it was.

* fix(plugins): tear down claims concurrently and keep duplicate reasons

Close starts teardowns in reverse activation order and runs them concurrently, so one hanging disposer no longer stalls the rest; each runtime still shuts down before its disposer. A claim that failed its reservation keeps that reason when its factory also fails. The migration guide says replay setup now receives only clientVersion and createError.

* fix(plugins): name version 2 replay claims and pin concurrent teardown

A refused version 2 replay or Maestro value ({ kind: 'replay-backend', backend }) names its claim again, so its selection answers incompatible-plugin-api instead of plugin-not-installed. The teardown test hangs the claim that closes first, so it fails against a serial loop. The migration guide says where replay host-command work moves.

---------

Co-authored-by: Mistral Vibe <vibe@mistral.ai>
hannojg pushed a commit to hannojg/agent-device that referenced this pull request Nov 23, 2026
)

* refactor(plugins): declare contract version 3 with per-kind contributions

AgentDevicePlugin is now { apiVersion: 3, contributes: [Contribution, ...] } with
provider, replay-backend and replay-execution kinds. The registry validates the whole
declaration, expands it into per-claim records, and reserves claim spaces in candidate
order. All nine maintained plugins wrap their factories in contributes. No shim: a
version 2 result gets the typed incompatible-plugin-api outcome.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* refactor(plugins): read static claims from package metadata before import

The store reads package.json agent-device { apiVersion, provider?, replayBackend?,
replayExecution? }: a version other than 3 fails pre-import with the typed
incompatible-plugin-api reason, engines.node establishes the Node floor
(node-below-floor), and reserved or malformed claim ids fail before any code runs.
After the factory runs with its options, the returned claim keys must equal the
declared ones unordered, or the package is invalid. All nine maintained packages
declare their claims and the Node floor.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* test(plugins): cover the version 3 contract in the registry and store suites

Update the existing suites to the contributes shape and add: a version 2 factory
and a version 2 metadata package both get incompatible-plugin-api; a metadata /
factory claim mismatch invalidates the package; cross-package duplicates keep the
first claim and fail the loser; a multi-kind package activates its replay claim
when its provider setup fails; the replay-only scope sets up no provider claim;
close runs activated claims in reverse activation order with per-step outcomes.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* docs(plugins): show the version 3 authoring shape

The plugins guide now documents contributes with per-kind contributions, the
agent-device package.json field with static claim keys, the engines Node floor,
the replay-execution ad kind, and the incompatible-plugin-api outcome for
version 2 packages.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): apply oxfmt to the version 3 contract files

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* fix(plugins): keep provider plugin declarations in the provider branch

AgentDevicePlugin gains a defaulted contribution generic so provider
packages can declare ProviderOnlyPlugin/ProviderAgentDevicePlugin; their
packed .d.mts then inline only the provider branch and stay assignable to
the host's AgentDevicePlugin despite the replay branches' unique-symbol
brands. Update the aws smoke fixture to the v3 contributes shape.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): merge duplicate plugin type imports in provider tests

* chore(gates): resolve Fallow findings for plugin contract v3

Repair the dead-code, complexity, and duplication findings the 0.22
plugin contract v3 change introduced, without suppressions or baselines.

- make module-private helpers non-exported (`incompatiblePluginApi`,
  `nodeRangeFloor`), and drop unused exported helpers (`claimKeysOf`, the
  `Contribution` type re-export)
- extract `providerClaim`, `replayBackendClaim`, and `replayExecutionClaim`
  from `readAgentDeviceClaims`, and `setUpClaims`, `setUpClaim`,
  `resolveRegisteredReplayExecution`, `failedLoadClaimFor`, and
  `assertStoreSelectionCurrent` from the registration and replay paths
- share the hosted App Automate connection resolution and validation in
  `@agent-device/provider-webdriver/plugin` as lazy loaders, so the
  BrowserStack and TestMu entries call one owner without importing the
  WebDriver runtime at plugin load time

* fix(plugins): keep the published contract types single-sourced

Contract v3 made `Contribution` name the host, format-backend and
native-execution declarations, so those declarations started splitting
across two published chunks. TypeScript then saw two unrelated types with
the same name, and a consumer could not pass a plugin from one public
entry into another entry's function.

- pin the plugin contract and the contract declarations it names into the
  shared `sdk-replay-backend.d` declaration chunk
- type `startAgentDevice` `plugins` through the contract package with the
  WebDriver options the host composes, so the SDK index no longer pulls
  the `./plugins` entry into a shared chunk whose exports get mangled
- declare the Replay plugin's published types against
  `agent-device/plugins`, as the Maestro entry already does
- write the integration fixtures' plugin objects in contract v3, including
  the typed `incompatible-plugin-api` reason the host now reports

* refactor(plugins): one typed claim record and honest declared claims

Addresses the review on callstack#4784.

- install: copy the `agent-device` claim block and `engines` into non-source
  package.json, with a non-source install test
- claims: one CLAIM_KINDS record returns typed { kind, id } claims; the registry
  keeps one Map<kind, Set<id>>; a failed slot reserves exactly declaredClaims,
  and one metadata spelling exists per claim
- reuse compareVersions from @agent-device/host-kit/version
- Limrun exports its connection; webdriver no longer carries the shared
  HostedConnection loader shim
- docs: plugins guide, replay README, ADR 0012, ADR 0034 and the
  incompatible-plugin-api hint match the contract

* fix(plugins): a failed candidate keeps answering the replay selection

An embedder plugin carries no package metadata, so nothing names its claims
before the factory runs. When its validation failed, resolution found no claim
and reported the engine as absent. A selected package keeps its own load,
compatibility or setup reason: a store package answers for the name the caller
selected, and a candidate the embedding host supplied answers because no name
can exclude it.

* fix(plugins): name a failed load's claims through the claim table

A candidate that fails before its contributions are readable still has to say
what it was meant to provide: the inventory names it, and the selection that
asked for that claim resolves to its reason. The id is read through the same
CLAIM_KINDS table the validated readers use, so no second reader exists, and a
slot whose package metadata already declared its claims is left as it was.

* fix(plugins): tear down claims concurrently and keep duplicate reasons

Close starts teardowns in reverse activation order and runs them concurrently, so one hanging disposer no longer stalls the rest; each runtime still shuts down before its disposer. A claim that failed its reservation keeps that reason when its factory also fails. The migration guide says replay setup now receives only clientVersion and createError.

* fix(plugins): name version 2 replay claims and pin concurrent teardown

A refused version 2 replay or Maestro value ({ kind: 'replay-backend', backend }) names its claim again, so its selection answers incompatible-plugin-api instead of plugin-not-installed. The teardown test hangs the claim that closes first, so it fails against a serial loop. The migration guide says where replay host-command work moves.

---------

Co-authored-by: Mistral Vibe <vibe@mistral.ai>
thymikee added a commit that referenced this pull request Nov 24, 2026
* refactor(plugins): declare contract version 3 with per-kind contributions

AgentDevicePlugin is now { apiVersion: 3, contributes: [Contribution, ...] } with
provider, replay-backend and replay-execution kinds. The registry validates the whole
declaration, expands it into per-claim records, and reserves claim spaces in candidate
order. All nine maintained plugins wrap their factories in contributes. No shim: a
version 2 result gets the typed incompatible-plugin-api outcome.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* refactor(plugins): read static claims from package metadata before import

The store reads package.json agent-device { apiVersion, provider?, replayBackend?,
replayExecution? }: a version other than 3 fails pre-import with the typed
incompatible-plugin-api reason, engines.node establishes the Node floor
(node-below-floor), and reserved or malformed claim ids fail before any code runs.
After the factory runs with its options, the returned claim keys must equal the
declared ones unordered, or the package is invalid. All nine maintained packages
declare their claims and the Node floor.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* test(plugins): cover the version 3 contract in the registry and store suites

Update the existing suites to the contributes shape and add: a version 2 factory
and a version 2 metadata package both get incompatible-plugin-api; a metadata /
factory claim mismatch invalidates the package; cross-package duplicates keep the
first claim and fail the loser; a multi-kind package activates its replay claim
when its provider setup fails; the replay-only scope sets up no provider claim;
close runs activated claims in reverse activation order with per-step outcomes.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* docs(plugins): show the version 3 authoring shape

The plugins guide now documents contributes with per-kind contributions, the
agent-device package.json field with static claim keys, the engines Node floor,
the replay-execution ad kind, and the incompatible-plugin-api outcome for
version 2 packages.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): apply oxfmt to the version 3 contract files

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* fix(plugins): keep provider plugin declarations in the provider branch

AgentDevicePlugin gains a defaulted contribution generic so provider
packages can declare ProviderOnlyPlugin/ProviderAgentDevicePlugin; their
packed .d.mts then inline only the provider branch and stay assignable to
the host's AgentDevicePlugin despite the replay branches' unique-symbol
brands. Update the aws smoke fixture to the v3 contributes shape.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* style(plugins): merge duplicate plugin type imports in provider tests

* chore(gates): resolve Fallow findings for plugin contract v3

Repair the dead-code, complexity, and duplication findings the 0.22
plugin contract v3 change introduced, without suppressions or baselines.

- make module-private helpers non-exported (`incompatiblePluginApi`,
  `nodeRangeFloor`), and drop unused exported helpers (`claimKeysOf`, the
  `Contribution` type re-export)
- extract `providerClaim`, `replayBackendClaim`, and `replayExecutionClaim`
  from `readAgentDeviceClaims`, and `setUpClaims`, `setUpClaim`,
  `resolveRegisteredReplayExecution`, `failedLoadClaimFor`, and
  `assertStoreSelectionCurrent` from the registration and replay paths
- share the hosted App Automate connection resolution and validation in
  `@agent-device/provider-webdriver/plugin` as lazy loaders, so the
  BrowserStack and TestMu entries call one owner without importing the
  WebDriver runtime at plugin load time

* fix(plugins): keep the published contract types single-sourced

Contract v3 made `Contribution` name the host, format-backend and
native-execution declarations, so those declarations started splitting
across two published chunks. TypeScript then saw two unrelated types with
the same name, and a consumer could not pass a plugin from one public
entry into another entry's function.

- pin the plugin contract and the contract declarations it names into the
  shared `sdk-replay-backend.d` declaration chunk
- type `startAgentDevice` `plugins` through the contract package with the
  WebDriver options the host composes, so the SDK index no longer pulls
  the `./plugins` entry into a shared chunk whose exports get mangled
- declare the Replay plugin's published types against
  `agent-device/plugins`, as the Maestro entry already does
- write the integration fixtures' plugin objects in contract v3, including
  the typed `incompatible-plugin-api` reason the host now reports

* refactor(plugins): one typed claim record and honest declared claims

Addresses the review on #4784.

- install: copy the `agent-device` claim block and `engines` into non-source
  package.json, with a non-source install test
- claims: one CLAIM_KINDS record returns typed { kind, id } claims; the registry
  keeps one Map<kind, Set<id>>; a failed slot reserves exactly declaredClaims,
  and one metadata spelling exists per claim
- reuse compareVersions from @agent-device/host-kit/version
- Limrun exports its connection; webdriver no longer carries the shared
  HostedConnection loader shim
- docs: plugins guide, replay README, ADR 0012, ADR 0034 and the
  incompatible-plugin-api hint match the contract

* fix(plugins): a failed candidate keeps answering the replay selection

An embedder plugin carries no package metadata, so nothing names its claims
before the factory runs. When its validation failed, resolution found no claim
and reported the engine as absent. A selected package keeps its own load,
compatibility or setup reason: a store package answers for the name the caller
selected, and a candidate the embedding host supplied answers because no name
can exclude it.

* fix(plugins): name a failed load's claims through the claim table

A candidate that fails before its contributions are readable still has to say
what it was meant to provide: the inventory names it, and the selection that
asked for that claim resolves to its reason. The id is read through the same
CLAIM_KINDS table the validated readers use, so no second reader exists, and a
slot whose package metadata already declared its claims is left as it was.

* fix(plugins): tear down claims concurrently and keep duplicate reasons

Close starts teardowns in reverse activation order and runs them concurrently, so one hanging disposer no longer stalls the rest; each runtime still shuts down before its disposer. A claim that failed its reservation keeps that reason when its factory also fails. The migration guide says replay setup now receives only clientVersion and createError.

* fix(plugins): name version 2 replay claims and pin concurrent teardown

A refused version 2 replay or Maestro value ({ kind: 'replay-backend', backend }) names its claim again, so its selection answers incompatible-plugin-api instead of plugin-not-installed. The teardown test hangs the claim that closes first, so it fails against a serial loop. The migration guide says where replay host-command work moves.

---------

Co-authored-by: Mistral Vibe <vibe@mistral.ai>
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