Skip to content

feat(foreman): run_integrate tool for sliced-workload union#1045

Merged
Defilan merged 3 commits into
defilantech:mainfrom
Defilan:feat/slicer-run-integrate
Jul 10, 2026
Merged

feat(foreman): run_integrate tool for sliced-workload union#1045
Defilan merged 3 commits into
defilantech:mainfrom
Defilan:feat/slicer-run-integrate

Conversation

@Defilan

@Defilan Defilan commented Jul 10, 2026

Copy link
Copy Markdown
Member

What

Task 4a of the Sliced Workloads epic (#1033): the deterministic run_integrate tool that a sliced Workload's integrate step dispatches.

It fetches the base from upstream and each slice branch from origin into local refs, unions them via slicer.Integrate, and pushes the integration branch back to origin for the downstream reconcile step + PR.

  • Verdict mapping: clean union → GATE-PASS; overlap / stale-base apply-conflict / empty union → GATE-FAIL (a slice violated its file scope — real signal); a fetch/push fault → GATE-ERROR (retryable).
  • Git auth comes from repo.TokenFromEnvOrFile (same source as fetch_issue), so no new plumbing in makeRegistryFactory.
  • buildDeterministicArgs surfaces the slice plan (slices, upstreamURL, and the reconcile fields) only for the integrate/reconcile kinds, so the gate's args stay byte-identical.

Why

The slicer combines disjoint-file slices by union. This is the executor wiring that runs that union in-cluster as a deterministic task and drives the AgenticTask verdict, sitting between the slice issue-fix tasks and the reconcile gate.

How

Mirrors the run_gate_job deterministic-tool pattern (Name/Schema/ExecuteTerminal verdict). The two-remote fetch (base from upstream, slices from origin) into local refs is what lets slicer.Integrate's base...slice diffs resolve against the current base (#813).

Testing

go test ./pkg/foreman/agent/tools/ -run TestRunIntegrate — real-git tests: clean union (pushed, carries both slices), overlap → GATE-FAIL, bad-args → GATE-ERROR. Full tools + agent package tests, go vet, golangci-lint, go build ./... all clean.

Stacked PR

Depends on #1034 (reconcile lib), #1036 (integrate lib), #1037 (task kinds + payload). Until those merge, this PR's diff includes their commits; the only new commit here is 3577286 (the run_integrate tool + wiring). Review that commit; I'll rebase to a clean diff as the dependencies land. run_reconcile follows as Task 4b.

Checklist

  • Real-git tests for pass/fail/error verdicts
  • go test / vet / golangci-lint / build clean
  • Gate args unchanged (slicer fields added only for integrate/reconcile kinds)
  • DCO sign-off

Part of #1033


Assisted-by: Claude Code (Opus 4.8); reviewed and verified by the author.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Defilan added 3 commits July 9, 2026 22:10
Add the integrate and reconcile AgenticTaskKind values (enum widened on both
AgenticTask.spec.kind and Workload pipeline steps) and the payload fields the
sliced-workload pipeline needs: Slices ([]SliceRef of name/branch/files),
Contract, and SharedIdentifiers ([]SharedIdentifier of id/definedBy/
referencedBy). integrate reads slices[].branch + baseBranch; reconcile reads
sharedIdentifiers + slices[].files + contract. Base and integration branch
reuse the existing baseBranch/branch fields.

API surface only: no executor handling yet (a follow-up wires the two kinds
to the slicer libraries). Regenerated deepcopy + CRD manifests + chart CRDs;
the AgenticTask webhook validates only agentRef, so no webhook change.

Part of defilantech#1033

Signed-off-by: Christopher Maher <chris@mahercode.io>
Task 4a of the Sliced Workloads epic (defilantech#1033): the deterministic run_integrate
tool that a sliced Workload's integrate step dispatches. It fetches the base
from upstream and each slice branch from origin into local refs, unions them
via slicer.Integrate, and pushes the integration branch back to origin for the
downstream reconcile step + PR.

Verdict mapping: clean union -> GATE-PASS; overlap / stale-base apply-conflict /
empty union -> GATE-FAIL (a slice violated its file scope, real signal); a
fetch/push fault -> GATE-ERROR (retryable). Git auth comes from
repo.TokenFromEnvOrFile (same source as fetch_issue), so the tool needs no new
plumbing in makeRegistryFactory. buildDeterministicArgs surfaces the slice plan
(slices, upstreamURL, and the reconcile fields) only for the integrate/reconcile
kinds, so the gate's args stay byte-identical.

Real-git tests cover the clean union (pushed, carries both slices), overlap ->
GATE-FAIL, and bad-args -> GATE-ERROR.

Part of defilantech#1033

Signed-off-by: Christopher Maher <chris@mahercode.io>
…jection

The tool passed user-influenced values (integration branch, base, slice
branches, upstream URL) straight to git argv, so a value beginning with '-'
could be smuggled in as a git flag (e.g. fetch --upload-pack=<cmd> executes a
command). Validate every such value up front with refSafe/gitURLSafe (mirroring
repo.gitRefSafe: no leading '-', no '..', git-ref-safe charset; URL scheme
allowlist) and reject with GATE-ERROR, and pass --end-of-options on fetch/push
as defense in depth. Adds a test asserting option-looking refs/URLs are
rejected. Flagged by the commit security review.

Signed-off-by: Christopher Maher <chris@mahercode.io>
@Defilan Defilan force-pushed the feat/slicer-run-integrate branch from 7328c26 to 4981f51 Compare July 10, 2026 05:14
@Defilan Defilan merged commit 5098b4e 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