Skip to content

Attribution always reports 0% even when the agent wrote all the code #421

@wasabeef

Description

@wasabeef

What happened?

initial_attribution in checkpoint metadata (entire/checkpoints/v1) always shows agent_lines: 0 and agent_percentage: 0, regardless of actual agent contribution.

Three independent bugs in the PostCommit condensation pipeline cause this. They often trigger together.

Bug 1 — Wrong baseline for detecting non-agent files

CalculateAttributionWithAccumulated() finds user-only files by diffing baseTree (session start) against headTree (after commit). When unrelated commits exist between session start and the current commit, all files from those intermediate commits are misclassified as "user edits," inflating totalUserAdded.

The comparison should use parentTree (the commit's immediate parent) instead of baseTree.

Where: manual_commit_attribution.go:226getAllChangedFilesBetweenTrees(baseTree, headTree)

Bug 2 — Stale sessions claim unrelated commits

findSessionsForWorktree() returns all sessions including ENDED ones. HandleCondenseIfFilesTouched triggers condensation whenever FilesTouched is non-empty, without verifying that the committed files actually overlap with the session's shadow branch.

HandleCondense already has this check (filesOverlapWithContent() for non-ACTIVE sessions), but HandleCondenseIfFilesTouched was missing it. ENDED sessions with carry-forward files produce zero-attribution checkpoints that overwrite valid ones.

Where: manual_commit_hooks.goHandleCondenseIfFilesTouched

Bug 3 — Double condensation overwrites correct results

When multiple sessions exist in the same worktree, both react to the same commit. The first condensation calculates correct attribution and advances AttributionBaseCommit to HEAD. A second condensation of the same session then sees baseTree == headTree, produces an empty diff, and overwrites the correct result.

Where: manual_commit_hooks.gocondenseAndUpdateState

Steps to reproduce

  1. entire enable (manual-commit strategy).
  2. Start an agent session, let it create files.
  3. From another terminal, make an unrelated commit (triggers Bug 1).
  4. Stop the first session, start a new one in the same directory.
  5. Let the new session write code, then commit.
  6. Check metadata.json on entire/checkpoints/v1agent_percentage is 0.

To trigger all three bugs:

  1. The first (now ENDED) session still has FilesTouched entries.
  2. PostCommit processes the ENDED session first → zero-attribution checkpoint (Bug 2). The active session condenses correctly, but gets condensed again via the stale session path (Bug 3), overwriting the correct result.

Entire CLI version

v0.4.5

OS and architecture

Darwin 24.5.0 arm64

Agent

Claude Code

Strategy

manual-commit (default)

Terminal

WezTerm

Logs / debug output

# Pattern in .entire/logs/entire.log:

# First condensation — correct:
post-commit: session 743d4b39 agent_lines:396 human_added:539 agent_pct:42.36

# ENDED session fires (Bug 2) — zero:
post-commit: session a62ddd7e agent_lines:0 human_added:0 agent_pct:0.00

# Same session condensed again (Bug 3) — overwrites correct result:
post-commit: session 743d4b39 agent_lines:0 human_added:0 agent_pct:0.00

Additional context

  • All three bugs occur without sub-agents or task agents.
  • Bug 1 is the most common — any mid-session commit, git pull --rebase, or git merge triggers it.
  • Bug 2 triggers whenever an ENDED session has leftover FilesTouched entries (normal after carry-forward).
  • Bug 3 requires multiple sessions in the same worktree, or rapid sequential commits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions