Skip to content

Fix stale attribution base when unrelated commits occur during an active agent session #151

@jcleira

Description

@jcleira

Description

In long agent sessions where the user also makes unrelated commits between agent turns, the AttributionBaseCommit stored in session state is not updated when those unrelated commits land. When the agent eventually commits, the attribution diff (AttributionBaseCommit → HEAD) spans multiple unrelated human commits, inflating the human line count and deflating the agent percentage.

This was fixed in entireio/cli#792.

What to fix

In the post-commit hook:

  1. When a commit lands without a Partio-Checkpoint: trailer (i.e. an unrelated human commit during an active session), update the session's AttributionBaseCommit to the new HEAD.
  2. This ensures subsequent agent-attributed commits diff only against the most recent baseline — not a stale session-start commit.
  3. Add an integration test that makes unrelated commits mid-session and verifies the final agent attribution reflects only the agent's own changes.

Acceptance Criteria

  • When unrelated commits occur during an active agent session, attribution for subsequent agent commits is scoped to changes since the last unrelated commit
  • AttributionBaseCommit in session state is updated when the post-commit hook runs without a checkpoint trailer
  • Attribution percentages are not deflated by including prior unrelated changes in the human-side diff
  • Existing attribution tests still pass
  • make test passes
  • make lint passes

Source

Inspired by entireio/cli#792

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions