Skip to content

yield: single-owner attribution double-credits commits across monorepo subdirs and worktrees (groups keyed by path string, not repo root) #713

Description

@ozymandiashh

Problem

The single-owner commit attribution shipped in #692 enforces "each commit is credited to at most one session" per launch-directory string, not per repository. Two facts combine:

  • attributeCommits groups sessions into repo groups keyed by the raw project.projectPath string, and isGitRepo uses git rev-parse --is-inside-work-tree, which is true for ANY subdirectory of a repo (src/yield.ts, grouping block).
  • getCommitsInRange runs git log --all --since --until with no pathspec, so from any subdirectory it returns the identical repo-wide commit list.

So in a monorepo (sessions launched from repo/packages/a and repo/packages/b) or with git worktrees, the same underlying repository forms two independent groups, each pulls the full commit history, and the same commit is independently awarded once per group.

Repro (verified on the merged code)

Two sessions in one temp repo, launched from two subdirectories, one commit inside both windows: the commit is credited to a session in EACH group — one commit, two productive sessions, commitCount totals 2. The second "owner" is not even ambiguous, since it is the sole candidate within its own group. Three scenario variants reproduced; every existing test stays green because each test uses a single repo path per group.

Suggested fix

Key the repo groups by the canonical repository root — git rev-parse --show-toplevel (and --git-common-dir if worktrees should unify) — instead of the raw projectPath string. A regression test with two sessions launched from two subdirectories of one repo pins it.

Found during an independent review pass with adversarial verification; happy to provide the full repro scripts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions