Skip to content

fix(daemon): map a single-commit cherry-pick by content when the reflog entry has no cherry-pick action - #91

Merged
sagnik11 merged 4 commits into
mainfrom
posthog-self-driving/fixdaemon-map-single-commit-cherry-7703c3
Nov 13, 2026
Merged

sagnik11 merged 4 commits into
mainfrom
posthog-self-driving/fixdaemon-map-single-commit-cherry-7703c3

Conversation

@posthog

@posthog posthog Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • When the daemon cannot rebuild a cherry-pick, the authorship note for the picked commit is not rewritten. The AI attribution for that commit is lost.
  • resolve_linear_head_commit_chain_for_worktree accepts only HEAD reflog entries whose message contains cherry-pick.
  • Some triggers change that message, for example an inherited GIT_REFLOG_ACTION (custom-tool: <subject>), or a hook that amends the pick in the same command (commit (amend): <subject>). In these cases the side effect fails with "failed to reconstruct HEAD reflog chain".

Origin

  • Error tracking: issue
  • First signal: 2026-11-12
  • Inbox report: open
  • Likely cause: c2b5f87
  • Task started by: auto-start, after the report was rated P3 and ready to fix

Changes

  • Content fallback for single-commit picks. If the strict match fails and the pick has exactly one source commit, the daemon now:
    1. takes the first parent of new_head as the original head,
    2. requires a HEAD reflog path from that parent to new_head, which can include more than one step, for example pick then amend (new head_reflog_path_messages_for_worktree),
    3. requires the same git patch-id --stable for new_head and the source commit. This reuses the existing helper in ci_context.rs.
  • Warning log. Each time the fallback runs, it sends a warn-level log_message with the reflog actions and content_matches. The next hit then shows the trigger. The log does not include commit subjects, and no new error-tracking issues open from it.
  • The strict path and multi-commit picks do not change.
Case Before After
Reflog entry contains cherry-pick mapped mapped (no change)
Single pick, other action, same patch side effect error, no note rewrite mapped, warn log
Single pick, other action, different patch side effect error side effect error, warn log
Multi-commit pick, other action side effect error side effect error (no change)

Note

The report says that the trigger is a hypothesis. The GIT_REFLOG_ACTION case is confirmed by a test. The amend case is covered only at the reflog-walk level. The warn log will tell us if other triggers exist.

Tests

  • New integration test test_single_commit_cherry_pick_with_custom_reflog_action. It fails without the fix and passes with it.
  • New unit test for the reflog path walk (pick, then amend).
  • cargo clippy --all-targets -- -D warnings: pass. cargo fmt --check on the changed files: pass.
  • cargo test --lib repo_state (13 tests): pass.
  • cargo test --test integration cherry_pick in daemon mode with 8 threads: 62 of 63 pass. Each run had one different failing subdir test (..._multiple_ai_sessions_from_subdir_in_worktree, then ..._multiple_commits_with_c_flag). Both pass when run alone. These are multi-commit picks that the strict path maps, so the new fallback does not run for them. I did not run the full task test suite in the sandbox.

Agent context

  • I did not remove the cherry-pick filter for all counts. For multi-commit chains it prevents wrong matches against unrelated reflog entries.
  • I did not use the semantic original_head from head_change. In the amend case it does not equal the old of the last reflog entry. The parent of new_head is correct for both triggers.

Created with PostHog Desktop from this inbox report.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…og entry has no cherry-pick action

The cherry-pick side effect rebuilt the pick from HEAD reflog entries that contain "cherry-pick". When the entry for the new head has a different action (an inherited GIT_REFLOG_ACTION, or a hook that amends the pick), the side effect failed and the authorship note was not rewritten.

For a single-commit pick, accept the reflog path from the parent of the new head to the new head when the new commit has the same stable patch id as the source commit. Log the reflog actions (not the commit subjects) as a warning, so the next hit shows the trigger.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: 530e5807-a8fc-4702-82b4-b02677f92a61
@posthog
posthog Bot requested a review from sagnik11 November 12, 2026 05:25
posthog Bot and others added 3 commits November 12, 2026 05:28
…pick content fallback

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: 530e5807-a8fc-4702-82b4-b02677f92a61
Resolve the repo_state import list in src/daemon.rs: take main's list
and add head_reflog_path_messages_for_worktree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rote the landing reflog entry

The content fallback accepted any commit whose parent-to-commit reflog path
existed and whose patch id matched the source. A stale ref state could then
name a commit that was already on the branch (a plain `commit:` entry with
the same patch) and rewrite its note with the source's attribution.

The fallback now requires the HEAD reflog entry that landed on the new head
to pass head_reflog_entry_written_by("cherry-pick", ...) (which also accepts
a renamed GIT_REFLOG_ACTION entry) or to be `commit (amend)`. The warn log
records whether the landing entry was accepted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sagnik11
sagnik11 marked this pull request as ready for review November 13, 2026 16:58
@sagnik11
sagnik11 merged commit 7cf20d9 into main Nov 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant