feat(pgpm-core): rebundlePlan — dependency-aware chunk/merge primitive with byte-identical gate#1411
Merged
Merged
Conversation
…e with byte-identical gate
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Atom 4, first slice: the granularity dial between the two extremes we already have (one-file-per-change vs one giant
pgpm package).rebundlePlan(moduleDir, strategy)groups a module's changes into fewer, larger chunks — but does so safely, respecting the three orderings the engine cares about (deploy topological, verify in deploy order, revert reversed).Deliberately thin and additive — it reuses the existing plumbing rather than inventing a parallel model:
parsePlanFile/getChangesslice/(buildDependencyGraph,buildPackageDependencies,detectPackageCycle,computeDeployOrder,extractPackageFromPath)resolveWithPlanalready usesKey correctness idea — contiguity ⇒ byte-identical. Chunks are contiguous runs of the source plan order, not an independent topo sort:
Because chunks are contiguous, concatenating chunks in order — members in source order, reverse for revert — reproduces the original resolved output exactly, at any dial position. Cross-chunk edges only ever point backward, so the chunk quotient is a DAG by construction; if a boundary ever splits a back-edge, we surface a warning instead of silently reordering.
verifyRebundleInvariant(moduleDir, result)is the gate that makes any granularity choice safe:Strategy surface (all optional):
boundary: 'folder' | 'none'(defaultfolder, reusing slice's path extraction)depth/prefixToStripfor the folder keymaxChunkSizeto cap chunk size (splits a boundary group, still contiguous)No behavior change anywhere else — new
rebundle/module exported from@pgpmjs/core, nothing consumes it yet. Actually merging chunk files / re-deparsing (thepackageModule-per-chunk step) and the classifier-driven boundaries land in follow-ups; this PR establishes the chunk model + ordering + invariant.Test plan
__tests__/rebundle/(no DB needed): folder grouping, verify==deploy / revert==reverse, cross-chunk dep derivation, single-chunk and size-capped dials, deploy/revert assembly order, and byte-identical invariant at all three dial positions.tsc --noEmitandpnpm buildclean.Link to Devin session: https://app.devin.ai/sessions/ad40d16f38a349b48eb7ce9375e27e6e
Requested by: @pyramation