Skip to content

generate: diff each module and merge changesets - #9

Open
vito wants to merge 1 commit into
mainfrom
fix-generate
Open

generate: diff each module and merge changesets#9
vito wants to merge 1 commit into
mainfrom
fix-generate

Conversation

@vito

@vito vito commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

generateAll used to fold every module's workspace fork into an accumulator and diff once at the end:

modules(ws)
  .filter { mod => mod.skipGenerate(ws) == false }
  .reduce(pws.fork) { fork, mod =>
    fork.merge(pws.moduleSource("/" + mod.rootPath).generate)
  }
  .changes

A fork holds a directory in both its before and its after, and merge is two withDirectory calls, so a workspace with N modules folded 2N directory merges through a single chain. The fold is also a sequential dependency chain: each merge waits on the previous one, so nothing overlaps.

Now each module is diffed on its own and the diffs are merged with Changeset.withChangesets, which the engine already exposes for exactly this (git octopus merge):

let changes = modules(ws)
  .filter { !_.skipGenerate(ws) }
  .map { mod => pws.moduleSource("/" + mod.rootPath).generate }

# evaluate the changesets in parallel
changes.{{isEmpty}}

changeset.withChangesets(changes.reject { _.isEmpty })

The map is independent per module, so generation across modules can overlap instead of chaining through an accumulator, and empty changesets are dropped before merging rather than merged as no-ops.

Behavior change

Two modules generating the same path is now a conflict and fails, rather than silently keeping whichever module happened to be generated last. Octopus merge only supports the FAIL and FAIL_EARLY strategies; this uses the default FAIL.

Blocked on

dagger.json currently pins polyfill@fix-generate. That has to go back to polyfill@main with a real pin once dagger/polyfill#6 merges — this should not land with the branch pin in place.

🤖 Generated with Claude Code

Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant