Skip to content

task: a landing merges into a branch whose tip moved since the cut — the moved check compares names only #620

Closed

Description

@santoshkumarradha

What happened

PR #589 ("repository work is always on a branch, and a landing never writes a protected checkout", head c378d2c4, over dev@4c08cd3b) promises a landing is refused when the person's checkout "moved since the cut". It compares branch names only. Nothing records the branch's sha at the cut, so a person who committed, amended, rebased or pulled on the same branch while the task ran is merged into without a word. The manual states the wider promise today:

A checkout moved after the task started, or detached before it landed, is kept by
the same rule so aforge never guesses where you meant the work to go.

(internal/manual/chat/how-tasks-run.md, section "Why my task's branch was kept", :412)

#589's own texts are being corrected to say "name". This issue is the product decision behind them: should a landing onto a branch whose TIP moved since the cut be kept on its branch with a sentence, or merged?

Replication

Deterministic (no model). In any repo: check out feat/x, cut a task with a stub worker, then in the root checkout git commit --allow-empty -m "mine" on feat/x, then land. Today the card says merged and the task branch goes into a feat/x that is not the one it was cut from. TestC8AMovedOrDetachedCheckoutKeepsTheTaskBranch (internal/session/task_landing_protected_test.go) only ever moves the name; a same-name variant of it lands green with nothing kept.

Field (real models). aforge do on a feature branch, --model deepseek/deepseek-v4-flash, OPENROUTER_API_KEY, ~5 min / ~$0.30: commit on that branch by hand while the task runs, watch the landing merge.

Where

  • Cut: cutWorktreeFrom (internal/session/task_run.go:5836) — home := currentBranch(root) (:5838), returned on the tree as home: with no sha (:5863). Same on the fork road: universeBranch (internal/session/groundladder.go:445, :462).
  • Record: Home string \json:"home,omitempty"` (internal/session/task_store.go:184) and TaskNode.Home (internal/session/task_run.go:305) — the record already carries Ground, Mode, Rung, Seal, Base`.
  • Check: keptLandingSentence (internal/session/task_branch_protection.go:109), the moved arm case t.home != "" && current != t.home (:114).
  • Landing: comeHome (internal/session/task_run.go:6121), the guard at :6171.

The fix

Refuse, for the reason the name check already gives: a branch whose tip moved is not the world the work was cut from, and a silent merge into it is exactly the guess #589 says aforge never makes. Shape: record the base sha at the cut on the record that already carries branch/ground (homeSha, additive — absent means an older record keeps today's name-only behaviour), compare it beside the name at landing, and say one sentence on the task card and on the /land road (internal/tui3/landcmd.go):

its branch task/x was kept: feat/x has moved on since the work was cut — merge it where you want it

If the call goes the other way — merge — then the manual section above must say so, because it promises the opposite today.

Acceptance

  • e2e: go test -tags e2e ./internal/e2e/ — a task cut on feat/x, a hand commit on feat/x in the root checkout, landing returns branch kept and the report contains has moved on since the work was cut; the checkout's tip is unchanged; exit 0.
  • e2e: control — the same run with no hand commit merges as it always did (merged, task branch in feat/x).
  • Unit: every landing that reads home reads the recorded sha through the one keptLandingSentence check; a record with no homeSha still gets the protected/detached/renamed arms.
  • The manual page quotes the new sentence (internal/manual/chat/how-tasks-run.md, "Why my task's branch was kept"), and the change entry's invalidates names that "moved since the cut" used to mean the name only.

Drafted with CodeAF · reviewed and owned by the author

Activity

  1. added
    bug
    area:session
    on Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:sessionbug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions