Skip to content

refactor(reasons): declare the R5 provider reasons in ReasonTable rows - #4932

Merged
thymikee merged 10 commits into
mainfrom
t3/refactor-r5-provider-errors
Nov 22, 2026
Merged

thymikee merged 10 commits into
mainfrom
t3/refactor-r5-provider-errors

Conversation

@thymikee

@thymikee thymikee commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Eighteen new reason tables plus one new LEASE_REASONS row now own this batch's wire vocabulary: per-module Revyl tables with the shared HTTP classification rows in revyl-client.ts (owner revyl provider), per-module Limrun tables (limrun provider), four module-private WebDriver tables (app upload, transport, session, text entry; owner webdriver provider), PROVIDER_RUNTIME_REASONS in contracts/platform-runtime.ts (provider runtime), plus a provider-instance-ended row in the existing LEASE_REASONS table. Every raise site in provider-revyl, provider-limrun and provider-webdriver reads TABLE.member.reason, and the helpers taking a reason (installStopped, revylFailure, unsupportedRouteRefusal) are typed to the table union. Two values are raised from two packages, so each sits with the shared owner both sites already load: provider-session-unavailable with the runtime contract both bind through, provider-instance-ended with the lease table its readers import. No new module, so no eager closure grows.

Value

Measure base head
Batch values declared in a table 0 / 48 48 / 48
Tables (rows) across these packages and the two shared owners 0 (0) 5 (47)
Untyped published-reason literals in the 21 changed files 71 14
Local reason consts in webdriver-transport.ts 4 0

The 14 left are other batches' values (request_canceled, unsupported-provider-mode, text_entry_focus_not_observed, owner-capability-missing).

Before / after

No observable change: every site publishes the same byte-for-byte details.reason.

Validation

Head f8530734c4 on origin/main d6767e0910: typecheck, lint, format clean; reason and eager-closure guards (934 tests) and the revyl, limrun, webdriver, contracts and daemon-client units (1,916) pass; check:layering, check:fallow, check:production-exports, check:bundle-owner-files pass; reasons page regenerated and committed. Integration, device lanes and coverage are CI's.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.50 MB 6.50 MB +1.5 kB
Package (unpacked) 6.50 MB 6.50 MB +1.5 kB
Package (download) 1.98 MB 1.98 MB +342 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 20.2 ms 19.8 ms -0.3 ms
CLI --help 43.7 ms 44.0 ms +0.3 ms

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

The code at f853073 looks correct, but the Body rules check has only cancelled runs, so the PR is not ready to merge yet. The three cancelled runs validate the PR description, not code, and they most likely come from superseded runs after body edits. Re-run Body rules or confirm that a later run passed before merge. Not verified here: the reason-table guard, the eager-closure guard, typecheck and unit suites were not run; the other checks passed in CI (22 of 25).

Not blocking, take or leave: PROVIDER_INSTANCE_ENDED is still exported as a second spelling of LEASE_REASONS.instanceEnded.reason, and only isProviderInstanceEndedError reads it now, so it can read the LEASE_REASONS row and drop the export. The PR summary says six reason tables, while the Value table says five; the sixth is a row added to LEASE_REASONS. The ReasonTable contract asks to declare a table beside the code that classifies those failures, but WEBDRIVER_TRANSPORT_REASONS moved away from its predicates in webdriver-transport.ts, the Limrun table sits in device.ts which classifies none of its reasons, and REVYL_PROVIDER_REASONS holds session, interactor, runtime and connection rows that add new import edges into revyl-client.ts. A follow-up issue is enough for this.

Would one table per classifying module, all with the same provider owner string, be simpler? The row count stays the same, no new import edges appear in revyl-client.ts, webdriver-utils.ts or device.ts, and the generated page is unchanged because the generator groups by owner.

…_REASONS

Drops the PROVIDER_INSTANCE_ENDED alias, so the value has one spelling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

At a0497dc2a1: PROVIDER_INSTANCE_ENDED is gone and isProviderInstanceEndedError reads LEASE_REASONS.instanceEnded.reason (the daemon's 'PROVIDER_INSTANCE_ENDED' strings are a separate internal lease-end label, not this published value). The body now says five new tables plus one LEASE_REASONS row, and editing it re-triggers Body rules on the new head. Per-module tables sharing one owner string (e.g. webdriver provider) are left as is: the collector groups them under one owner on the page, so I will raise it only if the page reads badly once all batches land.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

The earlier evidence gap is closed. One docs claim is still wrong at a0497dc, and Body rules has no passing run yet.

The new row at https://github.com/callstack/agent-device/blob/a0497dc/website/docs/docs/error-reasons.md#L217 says limrun_app_sync_failed leaves nothing installed. The Android path calls syncApp with install: true (https://github.com/callstack/agent-device/blob/a0497dc/packages/provider-limrun/src/android.ts#L130-L139). LimrunSyncCache.run awaits that call before it prunes the local cache (https://github.com/callstack/agent-device/blob/a0497dc/packages/provider-limrun/src/sync-cache.ts#L29-L36). If the cache read fails after the install succeeds, the catch at lines 38-52 emits this reason. An in-memory check against both Git versions confirmed that an EACCES during cache pruning does this. A caller who trusts the page may retry an install that already finished. Please change the appSyncFailed row comment in https://github.com/callstack/agent-device/blob/a0497dc/packages/provider-limrun/src/device.ts#L28 to say that the sync or local cache maintenance failed and that callers should check the device to see whether the app was installed. Then regenerate the page.

Could webdriver-transport.ts own its timeout, connection refusal, interruption and unsupported-route rows in a local ReasonTable with the same webdriver provider owner? Every reference to those four rows is in the transport module, and the generator already groups separate tables with the same owner.

No conflicts. The Body rules run is cancelled, which matches the cancel-in-progress setting on edited and synchronize events. No code in the diff is on its route, and the current body passes the check when graded locally. The other CI checks are green. Not verified here: a passing Body rules run on a0497dc, typecheck, the reason-table guard and the unit suites at that commit. A passing Body rules run on the current head is still required before merge.

…ng module; fix the app-sync summary

Each WebDriver module (app upload, transport, session, text entry) now owns the rows it raises,
all under the 'webdriver provider' owner. limrun_app_sync_failed now says sync or local cache
maintenance failed and to check the device for the app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

At 1749353988: the appSyncFailed summary now says app sync or local cache maintenance failed and to check the device for the app before retrying; the page is regenerated. On the simplicity question: yes — the 13 WebDriver rows split cleanly by the module that raises them, so WEBDRIVER_PROVIDER_REASONS became four module-private tables (app upload 3, transport 4, session 5, text entry 1), all owned by webdriver provider, so the page still lists them under one heading. Typecheck, lint, Fallow, and the WebDriver/Limrun suites pass. Editing this PR re-triggers Body rules on the new head.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

At 1749353, one wording problem remains in the WebDriver shutdown reason. The earlier findings from the first review (#4932 (comment)) are fixed.

The provider_session_shutdown_during_allocation row says the provider ended the session the allocation was waiting on. That is not true on the production lease route. The lease lifecycle forwards allocation to WebDriverSessionManager.allocate. After shutdown, a fresh lease reaches the no-entry guard at line 174 and emits the reason from allocationRefusedAfterShutdown at line 769 with cleanup: 'none'. No session is created or ended on that route, and it existed on the base. An operator reading error-reasons.md:300 can infer that a session existed for a lease that never had one. Please describe the shared outcome instead, for example: "The WebDriver runtime could not complete the allocation because shutdown was in progress or had already finished." Then regenerate the reason reference and keep the wire value unchanged.

Could Revyl keep the lease allocation reasons in session-allocation.ts and the HTTP classification reasons in revyl-client.ts, like the module-private WebDriver tables? The lease mismatch row is used only by the local comparison at session-allocation.ts:82, so importing it from revyl-client.ts adds a transport dependency to that comparison.

The Body rules check was cancelled, not failed. The diff touches no PR body, so the cancellation looks unrelated. Not verified here: the cause of the cancellation, the test suites, the typecheck and the docs generator. The docs change was read in the diff only. Please re-run Body rules on 1749353 so it reports success.

…he shutdown-during-allocation summary

Rows used by one Revyl module move into that module (connection, deployment, interactor, session,
runtime, allocation); the HTTP classification rows several modules share stay in revyl-client.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

At c84adb27d0: provider_session_shutdown_during_allocation now says the WebDriver runtime could not finish the allocation because shutdown was in progress or done (wire value unchanged, page regenerated). Applied the Revyl split the same way as WebDriver: rows used by one module now live in that module (session-allocation.ts keeps leaseRequestMismatch, plus connection, deployment, interactor, session and runtime tables), and the HTTP classification rows several modules share stay in revyl-client.ts. Typecheck, lint, Fallow and 528 provider tests pass; the body is updated, which re-runs Body rules.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Most of the earlier findings (#4932 (comment)) are fixed at c84adb2, but one docs problem remains.

The summary for the release-during-allocation reason says the provider ended the session. That does not hold on a reachable route. When leaseLifecycle.release takes a lease during creation, the allocation waits for disposal (runtime-session.ts:186-190, 469-478). If the hub creates the session and then rejects DELETE, cleanup returns uncertain with a WEBDRIVER_SESSION_DELETE_FAILED warning (406-425). The release branch still emits provider_session_released_during_allocation (703-711). A caller reading the reason reference can treat the session as closed while the failed DELETE may have left it running and billing. The runtime hint at line 789 already tells the caller to check the provider before allocating again. Please describe the release as interrupting allocation, and say that details.cleanup reports the outcome of session cleanup. Regenerate the matching row in error-reasons.md:299 with the same wire value.

Could the Limrun app-state and sync-cache modules own their reason rows locally? The only production references to instanceUnreachable, appSyncRetired and appSyncFailed are app-state-read.ts:45 and sync-cache.ts:21 and :47. Both modules now import the device identity module only to read those rows.

Tests, typecheck and Fallow were not run here; this relies on CI and the author's statement. The Body rules check was cancelled, not failed. It checks the PR body, and the author said the body update re-runs it. The latest changes touch none of its inputs. There are no conflicts. After the docs fix, Body rules must re-run green before merge.

…the released-during-allocation summary

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

At 1f28fe0bf3: provider_session_released_during_allocation now says releasing the lease interrupted the allocation and details.cleanup reports how cleanup ended (wire value unchanged, page regenerated). Applied the optional Limrun move fully: every Limrun row is used by one module, so LIMRUN_PROVIDER_REASONS became five module-private tables (lease release, runtime, app-state read, Android, app sync) and device.ts drops the table. Typecheck, lint, Fallow and 593 provider tests pass.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

The earlier findings from c84adb2 (#4932 (comment)) are fixed at 1f28fe0. One finding remains.

Shutdown can delete a WebDriver session successfully at runtime-session.ts:407 and then get a rejection from the separate prepared-session cleanup callback at lines 414-420. That warning alone sets cleanup to uncertain at line 424. Shutdown then emits provider_session_cleanup_incomplete for every uncertain outcome (lines 250-261 and 814). The new row, and its generated copy at error-reasons.md:302, say that sessions were left running. That is not true when the driver already deleted them. The summary must hold on every path that emits the reason. As written, an operator or agent can try to stop an already-deleted session and miss the failed provider cleanup step.

The smallest fix is to describe the outcome as unconfirmed cleanup, for example "Shutdown could not confirm that all WebDriver sessions and provider resources were cleaned up.", and regenerate the reasons page.

The Body rules job was cancelled, not failed. It checks the PR body and the diff touches nothing it exercises, so it needs a rerun rather than a code change. Not verified here: typecheck, lint, Fallow and provider tests were not run locally, and the Body rules job log was not read. There are no conflicts. After the summary fix, the cancelled Body rules job must be rerun before merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

At 32215b3bc2: the provider_session_cleanup_incomplete summary now reads "Shutdown could not confirm that all WebDriver sessions and provider resources were cleaned up." (wire value unchanged, page regenerated). The push starts a fresh Body rules run on this head.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

At 32215b3, the earlier findings from 1f28fe0 (#4932 (comment)) are fixed, and one docs problem remains. CI is green: 21 checks, none failing. There are no conflicts.

The new row in error-reasons.md says Revyl took the request. That is not always true. The install budget starts at deployment.ts:58, and expiry during local build preparation goes through the same provider-unconfirmed error at :63 and :74. The first provider call comes after packageBuild at :87-90. An in-memory run of deployRevylApp on this head with a slow local stat returned provider-unconfirmed with a TimeoutError and zero provider calls. A caller or agent can infer that Revyl received the install and look for an in-flight operation, when the timeout happened entirely on the local host. Please describe the common outcome in the row above unconfirmed at revyl-client.ts:68: agent-device could not confirm the operation's outcome. Keep the advice to check the session before retrying when the operation could have reached Revyl. Then regenerate the page and keep the wire spelling.

Could a small shared Revyl outcome table own the three rows used by deployment and snapshot parsing, with the HTTP-only rows kept in revyl-client.ts, so the shared outcomes carry no assumption about reaching the transport?

Not verified here: the docs generator was not re-run. The generated row text was compared with the source comment by reading.

…HTTP rows; fix the unconfirmed summary

REVYL_OUTCOME_REASONS holds the three outcomes deployment and snapshot code also publish;
the HTTP-only rows become private to revyl-client.ts. provider-unconfirmed now says
agent-device could not confirm the outcome, since a timeout can occur before any provider call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

At 4e08567e2e: provider-unconfirmed now says agent-device could not confirm the outcome of the request (a timeout can happen in local build prep before any provider call), and keeps the check-the-session-before-retrying advice; the page is regenerated. Took the table suggestion: REVYL_OUTCOME_REASONS (exported) holds the three outcomes deployment and snapshot code also publish (provider-refused, provider-response-invalid, provider-unconfirmed), and the HTTP-only rows become a private REVYL_HTTP_REASONS in revyl-client.ts; RevylProviderReason is the union of both. Typecheck, lint, Fallow and 183 Revyl tests pass.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

The earlier findings from 32215b3 (#4932 (comment)) are fixed at 4e08567, and this PR is ready. CI is green: 21 checks, 0 not passing. Not verified here: typecheck and the docs generator were not run locally, so those rely on the author's statement and CI. Not blocking, and fine to take or leave: the old JSDoc block above REVYL_OUTCOME_REASONS in https://github.com/callstack/agent-device/blob/4e08567/packages/provider-revyl/src/revyl-client.ts#L48 now sits directly above a second JSDoc and describes a table that is split in two. Merging the two into one block, or moving the first onto REVYL_HTTP_REASONS, would fix it. No merge blocker remains.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 22, 2026
thymikee and others added 2 commits November 22, 2026 08:12
…er-errors

* origin/main:
  docs(commands): generate blocks for every public command and halve hand-written prose (#4919)
  fix(depgraph): budget the blast-radius query, not the whole-tree scan (#4920)
  refactor: remove dead exports and stale fallow exemptions (#4931)
  refactor(reasons): declare the R6a reasons in ReasonTable rows (#4938)

# Conflicts:
#	website/docs/docs/error-reasons.md
… block

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

At 739bfbf (after merging main at d77bc9f): the two JSDoc blocks above REVYL_OUTCOME_REASONS are one block now. It describes the outcome table and says that, with REVYL_HTTP_REASONS, the two tables hold every reason this client publishes.

@apex-sentinel-staging

This comment has been minimized.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 22, 2026
@thymikee

Copy link
Copy Markdown
Member Author

The R5 provider reasons now read cleanly in the ReasonTable rows at 739bfbf, and the earlier review at 4e08567 still applies. CI is green: 21 checks, none failing. There are no conflicts, and no review threads are open. Not verified here: the reason-table generator and the wire-compat ledger were not rerun locally, so consistency was checked by diff only.

Not blocking: the new JSDoc at https://github.com/callstack/agent-device/blob/739bfbf/packages/provider-revyl/src/revyl-client.ts#L50 says the two tables hold every reason this client publishes, but an aborted hierarchy read emits request_canceled at line 410, outside both tables. Cancellation is outside R5 and base publishes the same reason, so this is only wording. Describing the tables as the provider-owned reasons, with request_canceled as shared cancellation vocabulary, would fix it. Take it or leave it.

Could revyl-client.ts keep RevylProviderReason private, and could deployment.ts type installStopped as typeof REVYL_OUTCOME_REASONS.unconfirmed.reason | "request_canceled"? Those are its only two inputs, and the exported union exposes HTTP classifications that deployment never produces.

Evidence is the only open item: a green run of the reason-table generator and the wire-compat ledger on this head would settle it. Nothing else must happen before merge.

…e install-stop reasons

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Evidence on this head, run locally:

  • At 739bfbf, pnpm generate:reasons wrote error-reasons.md with no diff (git status --porcelain showed only the source edits below).
  • At 90bab50, pnpm check:daemon-wire-compat exits 0: "Daemon RPC wire surface checked against v0.21.41 (protocol unchanged): 224 declarations, 20 changed, 0 removed, 7 added, 0 moved". The PR does not touch test/wire-compat.
  • vitest run packages/provider-revyl passes 178/178, and tsc --noEmit -p packages/provider-revyl is clean.

Both optional notes are done at 90bab50:

  • The JSDoc now calls the two tables the provider-owned reasons and names request_canceled as shared cancellation vocabulary.
  • RevylProviderReason is private. deployment.ts types the install-stop reason as typeof REVYL_OUTCOME_REASONS.unconfirmed.reason | "request_canceled".

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 90bab50

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

No open findings.

1 finding below minor hidden (user_settings.min_severity).

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

💬 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

The code in 90bab50 looks correct, and the earlier evidence request is now satisfied. All 21 checks pass, and the type-only change since the earlier review is covered by CI typecheck. Not verified here: the author-run local checks (generate:reasons, wire-compat, vitest) were not re-run. No conflicts. Nothing else must happen before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 22, 2026
@thymikee
thymikee merged commit d1ace81 into main Nov 22, 2026
21 checks passed
@thymikee
thymikee deleted the t3/refactor-r5-provider-errors branch November 22, 2026 09:23
thymikee added a commit that referenced this pull request Nov 22, 2026
…n-client-reasons

* origin/main:
  refactor(reasons): declare the R5 provider reasons in ReasonTable rows (#4932)

# Conflicts:
#	website/docs/docs/error-reasons.md
thymikee added a commit that referenced this pull request Nov 22, 2026
…-reasons

* origin/main:
  refactor(reasons): declare the R5 provider reasons in ReasonTable rows (#4932)
  refactor(reasons): declare the platform-android reasons in ReasonTable rows (#4928)

# Conflicts:
#	website/docs/docs/error-reasons.md
thymikee added a commit that referenced this pull request Nov 22, 2026
* origin/main:
  refactor(reasons): declare the R5 provider reasons in ReasonTable rows (#4932)
  refactor(reasons): declare the platform-android reasons in ReasonTable rows (#4928)

# Conflicts:
#	packages/contracts/src/lease-scope.ts
#	website/docs/docs/error-reasons.md
thymikee added a commit that referenced this pull request Nov 22, 2026
* origin/main:
  refactor(reasons): declare the R5 provider reasons in ReasonTable rows (#4932)

# Conflicts:
#	website/docs/docs/error-reasons.md
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