Skip to content

stdlib: remove dependency on polyfill module #13769

Closed

Description

@shykes

Problem

Our official modules import a "polyfill" module for features that want in the engine, but didn't have the patience to wait for :)

At 1.0 launch, the number of official modules that import polyfill should be ideally zero, or at most a very small number for niche use cases.

As it stands today, aspiring module developers that peek at our own modules, will undoubtebly have to learn about polyfill, which will make their learning and development journey more complicated.

Solution

Remove all dependencies on github.com/dagger/polyfill (and legacy github.com/dagger/sdk-sdk/polyfill) in all modules under github.com/dagger

Activity

  1. added this to the v1.0.0 milestone on Jul 29, 2026
  2. added theissue type on Jul 29, 2026
  3. self-assigned this
    on Jul 30, 2026
  4. grouville commented on Aug 7, 2026

    @grouville
    Member

    Some context first, for anyone landing here cold.

    What are we trying to do?

    github.com/dagger/polyfill was a temporary compatibility module created while the native Workspace API was still missing behavior needed by official SDKs and toolchains. The goal here is simple:

    native engine APIs
            ↓
    migrate every consumer
            ↓
    archive dagger/polyfill
    

    The catch is that we cannot remove it by blindly swapping API names. A few polyfill behaviors have become part of the UX people rely on, so the engine needs to absorb those behaviors first.

    Who uses the polyfill today?

    There are 16 current consumers:

    • 9 ordinary toolchains—go, docker, jest, vitest, pytest, ruff, bun, mochajs, and deno—use project discovery.
    • 6 SDK generators—go, python, typescript, php, java, and dang—also need isolated staging, module loading, and correctly rooted generated changes.
    • dagger/sdk-sdk exercises the SDK contract through ModuleSource.
    • dang-sdk additionally edits module configuration.

    After looking through every consumer, this is the native API split that seems simplest:

    ordinary toolchains                 installed SDK generators
    Workspace.findConfigDirs(...)       CurrentModule.asSDK(ws).modulesInScope
    filesystem discovery               registered-module selection; no scan
    
    manual generated edits              ModuleSource generation
    Workspace.fork().changes()           generatedContextChangeset
                     \                  /
                      cwd-relative Changeset
    

    Why do we need both discovery APIs?

    findConfigDirs is the ordinary toolchain UX: find projects below the cwd plus the nearest enclosing project. It is intentionally more opinionated than glob or findUp; neither existing primitive provides that combined contract by itself.

    SDK generators have different information available. The engine already knows which managed Dagger modules are registered, so modulesInScope selects from that list instead of scanning for dagger.toml, dagger-module.toml, or dagger.json.

    Why do we need fork() and automatic path correction?

    workspace changes before SDK runs: A
    SDK stages generated change:       B
    
    Workspace.changes()         → A + B
    Workspace.fork().changes()  → B only
    

    Returned changesets are applied by the CLI from the caller's cwd. The engine therefore corrects paths at the two boundaries that return generated edits:

    Workspace.fork().changes()
    ModuleSource.generatedContextChangeset
                    ↓
           paths measured from cwd
    

    Ordinary non-forked Workspace.changes() and internal generateLocalDependencies changes stay workspace-root-relative. Helpers such as withDirectory, changeset merging, and config edits do not each need their own remapping API: they compose edits, while remapping happens once when the final generated changeset crosses back to the caller.

    What needs to change in the engine?

    • #13854: Workspace.findConfigDirs, CurrentModule.asSDK(workspace).modulesInScope, preserve literal "latest", and pin local-dependency loading through Workspace.moduleSource.
    • #13855: Workspace.fork, fork isolation, and automatic cwd-relative rooting for forked and generated changesets.
    • Ship a release containing both PRs.

    The cross-repository E2E pass found one additional engine bug: a reduced generated context could report unrelated workspace files as removals, and independently generated changesets could then cancel each other during composition. #13855 now sparsifies generated diffs to their touched paths and includes a regression test.

    How do we migrate safely?

    Each consumer migration must remove the polyfill and bump engineVersion in the same commit:

    bump only     engine and polyfill both re-root paths   ✗ double translation
    remove only   neither layer re-roots paths             ✗ wrong paths
    do both       exactly one layer re-roots paths         ✓
    

    There is no flag day. The engine changes are additive or gated by the calling module's declared engineVersion, so migrated and unmigrated modules can coexist in one workspace.

    SDK migration PRs

    Official-module migration PRs

    What has been tested?

    All migrations are rebased, pushed as drafts, and tested locally against a dev engine containing both engine PRs:

    • SDKs: Go 46/46, Python 34/34, TypeScript 51/51, PHP 25/25, Java 31/31, Dang 16/16, SDK-SDK 25/25.
    • Official modules: Go 11/11, Docker 1/1, Jest 6/6, Vitest 6/6, Pytest 3/3, Ruff 5/5, Bun 12/12, MochaJS 9/9, Deno 16/16.
    • Engine schema tests and focused integration coverage for discovery, module scope, fork isolation/rooting, local dependencies, literal latest, and generated-context composition are green.

    Hosted consumer checks currently error because the drafts use the provisional v1.0.0-beta.10 cutover, which has not been released. Replace it with the actual release version before merging.

    What happens after the migrations?

    • Re-pin dagger/dagger's SDK locks.
    • Archive dagger/polyfill after the final consumer migration lands.

    Full API review and diagrams: https://gist.github.com/grouville/fbbe5836b8e46ecf25bf5c626cd206e7

  5. 8 remaining items

  6. keeltrace commented on Aug 21, 2026

    @keeltrace

    AI disclosure: I used an AI assistant to audit the current polyfill consumer set and prepare a candidate Elixir migration; I reviewed and edited this comment before posting.

    One consumer appears to have been added after the migration inventory above: dagger/elixir-sdk. On its current default head (a50635d43806c146765921c9e0ad84902f309e12), the root module still references dagger/polyfill, and the dev module also carries the dependency. I found no open Elixir polyfill-removal PR, issue, or branch.

    I have a six-file migration packet prepared against that exact head that removes both dependency declarations, moves discovery/generation onto the native Workspace/ModuleSource APIs, updates lock/docs state, and includes a fail-closed zero-polyfill check plus lint/SDK/codegen/sdk-sdk verification harness.

    Since #13769 is actively owned and the existing consumer migrations are being coordinated here, I don't want to treat the newly discovered Elixir slice as unowned just because it isn't in the original list. If you're not already covering dagger/elixir-sdk, would it be useful for me to take that migration as a separate PR and run it through the same release/version cutover as the other consumers? If you are already planning it, I'll leave the lineage with you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions