Skip to content

refactor: make request-platform-providers provider wrappers static#1214

Closed
thymikee wants to merge 1 commit into
mainfrom
fix/ineffective-dynamic-imports
Closed

refactor: make request-platform-providers provider wrappers static#1214
thymikee wants to merge 1 commit into
mainfrom
fix/ineffective-dynamic-imports

Conversation

@thymikee

@thymikee thymikee commented Jul 11, 2026

Copy link
Copy Markdown
Member

Problem

pnpm build warned:

[INEFFECTIVE_DYNAMIC_IMPORT] src/daemon/app-log.ts is dynamically imported by
src/daemon/request-platform-providers.ts but also statically imported by
session-observability.ts, session-teardown.ts — dynamic import will not move
module into another chunk.

Fix

request-platform-providers.ts builds the per-request provider scope from a
table of descriptors, each of which did await import('…provider') inside
appendWrapper. But the file is daemon-only (imported solely by
request-router), and the daemon serves every platform, so all seven of those
dynamic imports defer nothing — each provider module is already loaded eagerly
in the daemon entry chunk. The app-log one additionally collides with the
static imports in session-observability / session-teardown, which is what
rolldown flagged.

The R3 platforms-seam layering rule already permits src/daemon/** to import
platforms/** statically (the seam only constrains src/core/ outside
core/interactors/), so this is allowed. So:

  • Hoist every with*Provider import to the top as a static import.
  • Collapse appendWrapper to a uniform synchronous one-liner per descriptor.
  • Drop the redundant per-descriptor provider guards — appendRequestProviderWrapper
    already short-circuits when the provider is absent.

Net −13 lines, one file.

Why runner-client's warning is intentionally left

Fixing the app-log collision unmasks a separate INEFFECTIVE_DYNAMIC_IMPORT
for runner-client.ts (rolldown only reports a subset at a time). That one is
not vestigial: runner-client is dynamically imported by
src/core/dispatch.ts / dispatch-interactions.ts, which is the mandated R3
cold-start seam
(core → platforms must cross via import() / type-only to
keep it out of the CLI's eager closure). It is also statically imported by ~20
daemon modules, so rolldown can't hoist it into its own chunk. The dynamic
import is correct and required; the warning is inherent to the seam. Rather
than paper over it with a build-config suppression, it's left visible.

Verification

  • Layering Guard passes (was the failing check).
  • Typecheck, lint, and provider + dispatch tests pass; build succeeds.
  • The CLI eager closure is unchanged — this file isn't in the CLI graph, so
    there's no cold-start impact.

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.7 MB 1.7 MB -3.9 kB
JS gzip 536.7 kB 534.3 kB -2.4 kB
npm tarball 646.3 kB 645.1 kB -1.2 kB
npm unpacked 2.3 MB 2.3 MB -3.9 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.4 ms 27.6 ms +0.2 ms
CLI --help 57.0 ms 57.6 ms +0.6 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/internal/daemon.js +85.2 kB +25.1 kB
dist/src/interaction.js +15.6 kB +5.1 kB
dist/src/sdk-android-adb.js -464 B -152 B
dist/src/session.js -76 B -15 B
dist/src/apps.js -54 B -11 B

@thymikee thymikee force-pushed the fix/ineffective-dynamic-imports branch from 026005e to 859dcd5 Compare July 12, 2026 06:42
@thymikee thymikee changed the title refactor: make vestigial runner-client/app-log dynamic imports static refactor: make request-platform-providers provider wrappers static Jul 12, 2026
`pnpm build` emitted INEFFECTIVE_DYNAMIC_IMPORT for `src/daemon/app-log.ts`: it
was `await import()`ed in request-platform-providers' `appendWrapper`, but is
also statically imported by session-observability / session-teardown, so the
dynamic import splits nothing.

request-platform-providers is daemon-only (imported solely by request-router)
and the daemon serves every platform, so all seven provider-wrapper dynamic
imports defer nothing — each provider is loaded eagerly regardless. The R3
platforms-seam layering rule explicitly permits `src/daemon/` to import
`platforms/` statically (the seam only constrains `src/core/` outside
`interactors/`), so this is allowed. Hoist every `with*Provider` import to the
top and collapse `appendWrapper` to a uniform synchronous one-liner; the
redundant per-descriptor provider guards move to `appendRequestProviderWrapper`,
which already short-circuits on an absent provider. Net -13 lines.

Deliberately unchanged: runner-client's dynamic imports in
`src/core/dispatch{,-interactions}.ts` are the mandated R3 cold-start seam
(core -> platforms must cross dynamically), so its INEFFECTIVE_DYNAMIC_IMPORT
warning is inherent to that seam and left as-is rather than papered over.

Verified: layering guard passes, typecheck / lint / provider + dispatch tests
pass, build succeeds, and the CLI eager closure is unchanged (this file is not
in the CLI graph).
@thymikee thymikee force-pushed the fix/ineffective-dynamic-imports branch from 859dcd5 to e0e714e Compare July 12, 2026 06:44
@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Jul 12, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Closing as superseded by #1227, which preserves the request-scoped dynamic provider boundary and resolves the app-log warning without merging this alternative static-provider implementation.

@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-13 09:25 UTC

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