feat(pgpm-core): rebundleModule — per-chunk packageModule merge with byte-identical gate#1412
Merged
Conversation
…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, second slice: turns the chunk plan from
rebundlePlan(#1411) into actual merged migrations on disk.rebundleModule(sourceDir, { outputDir, ...strategy })writes a rebundled module whose per-change files collapse to one migration per chunk, gated byte-identical against the original when packaged.The merge reuses
packageModule's exact engine rather than a second implementation.packageModuleis refactored to extract that engine asmergeSqlStatements:Per chunk and per direction,
rebundleModulemerges the member scripts (transactions stripped) and re-wraps in one transaction — deploy/revertCOMMIT, verifyROLLBACK— so each chunk deploys as exactly one transaction:It then writes a chunk-quotient
pgpm.plan(one change per chunk, deps = earlier chunk names, viageneratePlanContent) and remaps tags onto their sealing chunk. The module stays the same extension — control/Makefile/package.json are copied verbatim, only the internal change set collapses.Gate.
rebundleModulereturnsinvariant, and packaging both directories must match:This holds because merging strips the inner transactions and preserves statement order, so re-packaging strips the re-added wrappers and yields the same AST. Any deparse instability is caught by the existing round-trip diff.
Additive only; nothing calls
rebundleModuleyet. Follow-ups: classifier-driven boundaries (Atom 2 facts choosing seams) and thecontrol-onlycross-chunk dep mode for published module forks.Test plan
rebundleModuletests (real DDL, no DB): per-chunk files + chunk-quotient plan, metadata copy, single-transaction merge (one BEGIN/COMMIT; verify ROLLBACK), byte-identical gate at folder and single-chunk dial positions, overwrite guard.packageModuleextraction is behavior-preserving).rebundlePlantests still green;tsc --noEmitandpnpm buildclean.Link to Devin session: https://app.devin.ai/sessions/ad40d16f38a349b48eb7ce9375e27e6e
Requested by: @pyramation