Skip to content

feat(foreman): integrate library for disjoint slice union#1036

Merged
Defilan merged 1 commit into
defilantech:mainfrom
Defilan:feat/slicer-integrate
Jul 10, 2026
Merged

feat(foreman): integrate library for disjoint slice union#1036
Defilan merged 1 commit into
defilantech:mainfrom
Defilan:feat/slicer-integrate

Conversation

@Defilan

@Defilan Defilan commented Jul 10, 2026

Copy link
Copy Markdown
Member

What

Task 2 of the Sliced Workloads epic (#1033): the Integrate function in pkg/foreman/slicer, a Go port of the experiment's integrate.sh.

Integrate unions the disjoint slice branches onto the current base on a fresh integration branch and returns the union diff for the downstream reconcile step. It:

  1. Proves disjointness (no file changed by two slices) -> *OverlapError naming the file and both slices.
  2. Applies each slice's diff onto the base (disjoint files -> clean apply, not a semantic merge) -> *ApplyError if a slice's diff conflicts (e.g. cut from a stale base).
  3. Commits the union; *EmptyUnionError when no slice changed anything.

Owners maps 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-fix tasks and the reconcile gate. 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 existing commandRunner convention, 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

  • Tests added
  • go test / go vet / gofmt / golangci-lint clean on the package
  • Pure library, no behavior change to existing code
  • DCO sign-off

Part 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.

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

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 56.92308% with 28 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/foreman/slicer/integrate.go 56.92% 17 Missing and 11 partials ⚠️

📢 Thoughts on this report? Let us know!

@Defilan Defilan merged commit 39131f6 into defilantech:main Jul 10, 2026
24 checks passed
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