Skip to content

workspace: join commits to work by patch-id when a trailer is gone #3036

Closed

Description

@lex00

Problem

A commit joins to its work through trailers (commitJoins in packages/core/src/workspace/intent-joins.ts). A rebase or cherry-pick keeps the trailers when the tool keeps the message, but people also rewrite messages, drop trailers by hand, or carry a change across branches with tooling that rewrites it. The commit then has a new SHA and no trailer, and the intent walk reports it as unexplained, even though the change is the same one a unit or an agent run made.

git already has an identity that survives this: git patch-id --stable gives the same id to the same diff whatever its parent.

Proposal

  • When a join records the commits a unit or an agent run made (the run record of workspace: record what each agent run cost and which changes it made #3033, and a unit's result), it also records each commit's stable patch-id.
  • graph --intent and graph --intent --record fall back to patch-id matching when a commit in the window carries no trailer. A commit whose patch-id matches a recorded one joins to that unit or run, marked as "joined by content", so a reader can tell it from a trailer join.
  • A patch-id join never overrides a trailer join, and conflicting joins become a finding.

Acceptance

  • Recorded commits carry patchId (the git patch-id --stable value) beside their sha.
  • After a rebase or cherry-pick that drops the trailer, graph --intent still joins the commit to its unit or run, marked joinedBy: "patch-id".
  • A squash of several commits (a different patch-id) doesn't join by content. The squash case is workspace: follow a squash merge to the pull request's original commits #3035.
  • Schema and docs cover the field and the join order (trailer first, then patch-id).

Activity

  1. added
    provenance
    area:workspace
    on Sep 29, 2026
  2. lex00 commented on Oct 3, 2026

    @lex00
    ContributorAuthor

    Status: run records (#3033) already store each commit's patch-id, so the remaining work here is the fallback join on it in graph --intent and runs.

  3. lex00 commented on Oct 4, 2026

    @lex00
    ContributorAuthor

    Design as built in #3425.

    The fallback lives in the run join that graph --intent, graph --intent --record and runs all share. A commit with no Chant-Run trailer that no run's end lists joins every run whose end recorded a commit with the same git patch-id --stable. The join order is trailer, then record, then patch-id, and the patch-id join is tried only when the first two give nothing.

    Readers see it as joinedBy: ["patch-id"] on the made-by edge, on the intent-record runs entry and on the runs --json commit, each with recordedAs, the recorded commit it rewrites. The why block's spans and runs gain a joinedBy field, so hud can mark content joins without a new narrowedBy value; hud's reader rejects unknown narrowedBy values. A run's recorded hunks don't narrow a content join, because the rewritten commit's line numbers may have moved, and runs --json gives such a commit hunks: null.

    A commit claimed by one run's trailer or record whose content matches a commit another run recorded keeps its join, and graph --intent reports the new finding intent-commit-join-conflict. runs --json reads patch-ids only for commits made since the earliest run with a recorded patch-id started, less a day for clock skew, in one git log -p | git patch-id pass. The unit's result side of the proposal isn't built, per the status comment above: run records already store the patch-ids.

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

    area:workspaceprovenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions