feat(foreman): integrate library for disjoint slice union#1036
Merged
Conversation
Go port of the slicer experiment's integrate.sh: union the disjoint slice branches onto the current base on a fresh integration branch and return the union diff for reconciliation. Proves disjointness first (no file changed by two slices -> *OverlapError), then applies each slice's diff onto the base (*ApplyError on conflict, e.g. a slice cut from a stale base) and commits; *EmptyUnionError when no slice changed anything. Owners maps each changed file to its single owning slice. Git is shelled via an injectable GitRunner (exec-backed default), matching Foreman's commandRunner convention. Real-git table tests cover clean disjoint union, overlap rejection (branch not left behind), empty union, and arg validation. Pure library, no controller wiring. Part of defilantech#1033 Signed-off-by: Christopher Maher <chris@mahercode.io>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
4 tasks
This was referenced Jul 10, 2026
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.
What
Task 2 of the Sliced Workloads epic (#1033): the
Integratefunction inpkg/foreman/slicer, a Go port of the experiment'sintegrate.sh.Integrateunions the disjoint slice branches onto the current base on a fresh integration branch and returns the union diff for the downstream reconcile step. It:*OverlapErrornaming the file and both slices.*ApplyErrorif a slice's diff conflicts (e.g. cut from a stale base).*EmptyUnionErrorwhen no slice changed anything.Ownersmaps each changed file to its single owning slice.Why
The slicer combines disjoint-file slices by union, not merge. This is the mechanical combine step that sits between the slice
issue-fixtasks and thereconcilegate. The disjointness guard is a real check: a slice that touched a file outside its scope is caught here rather than silently corrupting the union.How
Git is shelled via an injectable
GitRunner(exec-backed by default), matching Foreman's existingcommandRunnerconvention, so the library never hard-codes a transport. The build gate stays at the task layer; this library only produces the union and its diff. Independent of the reconcile library (#1034) — different file, no shared symbols, no merge conflict.Testing
go test ./pkg/foreman/slicer/ -run TestIntegrate— real-git table tests (temp repos) covering: clean disjoint union (both slices' changes land, union diff correct), overlap rejection (returns*OverlapError, integration branch not left behind), empty union, and arg validation. Build, vet, gofmt, golangci-lint (both arches) clean.Checklist
go test/go vet/gofmt/golangci-lintclean on the packagePart of #1033
Assisted-by: Claude Code (Opus 4.8), porting a script and test suite the author validated live; reviewed and verified by the author.