Skip to content

task size/small-change gate measures against a stale slice-1 branch ref for multi-slice tasks #68

Open

Description

@urban233

Found while reordering and branching slice 5 (recovery-and-budget) of
claude-code-adapter-verification-first ahead of slice 4.

git_ops._measure(task_id, base, target) (src/codev_workflow/git_ops.py,
around line 858) diffs base against git_state["branch"] -- the task's
git-state.json top-level branch field, which is frozen at whichever branch
create_branch set for the task's first slice and never updated as later
slices get their own stacked branches via start_slice_branch. own_branch()
exists specifically to resolve the current slice's branch instead
(git_ops.py, own_branch), and is used correctly elsewhere (commit, push,
open-pr), but _measure -- and therefore both slice_size() and
task_size() -- never calls it.

Reproduced: on claude-code-adapter-verification-first, now on its 4th
slice (recovery-and-budget), with base_snapshot correctly advanced to
99a46f1 (where slice 3/evidence-hooks landed):

$ codev task size --id claude-code-adapter-verification-first --json
{"lines_changed": 4309, "files_changed": 32, "max_lines": 600, "max_files": 12, "over_budget": true}

$ git diff --stat 99a46f1...HEAD   # the actual current-slice diff
 3 files changed, 39 insertions(+), 5 deletions(-)

git_state["branch"] is still codev/claude-code-adapter-verification-first--work-style-and-plan-tiering
(slice 1's branch, merged weeks ago and never advanced), so the diff is
really base..slice-1-branch -- which, since slice 1's branch predates
slices 2 and 3 landing, surfaces as the (reverse) diff of everything those
two slices added: hence the inflated ~4300 lines / 32 files against an
actual current-slice diff of 39 lines / 3 files.

Impact: _slice_size in gate.py feeds the small-change gate directly,
so every multi-slice task past its first slice gets a spuriously inflated,
often-over-budget size report -- the gate still only asks (fails open), so
it is friction (an unnecessary confirmation prompt on every edit) rather
than a block, but it makes the size signal meaningless for exactly the tasks
ADR-0035 stacking was built for.

Fix: _measure (or its caller in slice_size) should resolve the
branch via own_branch(task_id, target=target) instead of reading
git_state["branch"] directly, the same way commit/push/open-pr already do.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions