Skip to content

feat(cli): --revise-from-branch on foreman dispatch for in-place PR refresh#1043

Open
joryirving wants to merge 1 commit into
defilantech:mainfrom
joryirving:feat/issue-996-revise-from-branch
Open

feat(cli): --revise-from-branch on foreman dispatch for in-place PR refresh#1043
joryirving wants to merge 1 commit into
defilantech:mainfrom
joryirving:feat/issue-996-revise-from-branch

Conversation

@joryirving

Copy link
Copy Markdown
Collaborator

What

Add --revise-from-branch <ref> to llmkube foreman dispatch. When set, the dispatched AgenticTask has both payload.branch and payload.reviseFromBranch stamped to that ref, so the executor restores the prior attempt and force-with-lease pushes an update to the same branch (and open PR) instead of cutting a new one.

Why

Post-PR iteration (a failing E2E, a reviewer request-changes) shouldn't require regenerating the whole branch — that wastes compute, tokens, and power for a one-line fix. The CRD field (payload.reviseFromBranch) and executor path already exist (#951, #978); today the only way to trigger them ad-hoc is hand-writing an AgenticTask. This flag makes incremental revision first-class for CLI-driven dogfooding.

Closes #996

How

  • New dispatchOptions.reviseFromBranch field, bound to --revise-from-branch.
  • New validateReviseFromBranch helper: when the flag is set, requires exactly one issue (a revision targets a single branch — matches the issue's "Notes").
  • buildTask stamps Branch and ReviseFromBranch together from the flag on the revision path; both stay empty on the fresh-branch path.
  • Help text gains a third example showing the revision flow.
  • Tests added: TestBuildTask_ReviseFromBranch (table: unset+set), TestValidateReviseFromBranch (table: 5 cases), TestRunDispatch_ReviseFromBranchFiresBeforeFetch (asserts the rule fires before the GitHub fetch).

The executor (pkg/foreman/agent/executor_native.go) and the WorkloadReconciler (internal/foreman/controller/workload_iteration.go) already consume ReviseFromBranch; nothing under api/foreman/ or charts/ changes.

Checklist

  • Tests added/updated
  • make test passes locally
  • make lint-all passes locally (darwin + linux)
  • Commit messages follow conventional commits
  • All commits are signed off (git commit -s) per DCO
  • AI assistance (per CONTRIBUTING.md): code and PR description authored with assistance from an LLM-driven session in opencode (model: litellm-anthropic/MiniMax-M3). Design, commits, and verification all performed by the same session against the user's stated intent.
  • Documentation updated (user-facing) — llmkube foreman dispatch --help example block shows the new flag.

…efresh

issue-fix tasks can already restore a prior attempt and force-with-lease
push an update to the same branch via payload.reviseFromBranch, but the
flag was unreachable from the CLI. Add --revise-from-branch <ref>: when
set, both payload.branch and payload.reviseFromBranch are stamped with
that ref, so the executor restores the prior attempt and refreshes the
open PR instead of cutting a new branch. Requires exactly one issue.

Closes defilantech#996

Signed-off-by: Jory Irving <jory@jory.dev>
@joryirving joryirving requested a review from Defilan as a code owner July 10, 2026 03:48
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Defilan Defilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice flag, but there's a merge-order gotcha with #1042 that makes it a no-op as written. #1042 gated the reviseFromBranch restore behind BranchStrategy == rebase, and the default is now reset — so a dispatched task that sets ReviseFromBranch but not BranchStrategy falls through to the fresh-cut path and never restores the prior attempt.

buildTask needs to also stamp BranchStrategy: BranchStrategyRebase on the revision path. The unit test passes because it only checks payload stamping, not the executor behavior — worth asserting the strategy too so this can't regress. Fix that and it's good.

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.

feat(cli): --revise-from-branch on 'foreman dispatch' for in-place PR revision

2 participants