Skip to content

fix(daemon): stop reporting rewrite synthesis failures for a deleted worktree - #117

Merged
sagnik11 merged 1 commit into
mainfrom
posthog-self-driving/fixdaemon-stop-reporting-rewrite-43f192
Nov 20, 2026
Merged

sagnik11 merged 1 commit into
mainfrom
posthog-self-driving/fixdaemon-stop-reporting-rewrite-43f192

Conversation

@posthog

@posthog posthog Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • An agent can delete its temporary git worktree before the daemon handles the git command. This race is benign: the worktree is gone, so there is nothing to attribute.
  • rewrite_events_from_semantic_events then fails in find_repository with not a git repository. The inner tracing::error!("strict rewrite synthesis failed") runs before the outer is_vanished_repo_error guard, and sentry_layer.rs sends every ERROR-level log to error tracking.
  • The temporary path is in the message, so each new temporary worktree opens a new error tracking issue.

Origin

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

Changes

  • The rewrite synthesis Err arm checks is_vanished_repo_error(&error, cmd.worktree.as_deref()) first. When it is true, the daemon logs at debug level and returns the error as before, so the outer guard in maybe_apply_side_effects_for_applied_command still skips the side effect.
  • All other rewrite synthesis failures (for example cherry-pick reflog or stash oid) still log at error level.
  • New unit test vanished_repo_error_detects_find_repository_on_deleted_worktree runs find_repository on a deleted worktree and also checks the Windows not a git repository shape.
Case Before After
Worktree deleted before rewrite synthesis ERROR log, new error tracking issue debug log, side effect skipped
Other rewrite synthesis failure ERROR log ERROR log (no change)

Why

  • Stop noise in error tracking from a benign race. This continues earlier fixes for the same kind of race (#52, #60, #67).

Checks

  • cargo test --locked --lib vanished_repo: 2 passed.
  • cargo clippy --locked --lib --tests -- -D warnings: clean (Rust 1.93.0).
  • rustfmt --check --edition 2024 src/daemon.rs: clean.
  • Skipped: the full task test integration suite and task lint/task fmt (task is not installed in the sandbox). The change is one log-level branch and one unit test, and CI runs the full suite.

Success measure

  • Error tracking events whose message starts with strict rewrite synthesis failed and contains not a git repository go to 0. The volume is too low for a quiet period to prove the fix, so the unit test is the main check.

Agent context

  • No integration test: a daemon-mode test cannot reliably delete the worktree between the git command and the daemon's side effect. The unit test pins the real find_repository error on a deleted worktree instead.

Created with PostHog Desktop from this inbox report.


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

…worktree

An agent can delete a temporary worktree before the daemon handles the git command. Rewrite synthesis then fails in find_repository, and the error-level log sent the benign race to error tracking with the temporary path in the message. The outer vanished-repo guard already skipped the side effect, but the inner log ran first.

Now the rewrite synthesis error arm checks is_vanished_repo_error first. When it is true, the daemon logs at debug level and returns the error as before, so the outer guard still runs. Other rewrite synthesis failures still log at error level. Add a unit test that runs find_repository on a deleted worktree.

Generated-By: PostHog Desktop
Task-Id: 272e438d-f425-4b6f-bda6-6a9b8eb02ab8
@posthog
posthog Bot requested a review from sagnik11 November 20, 2026 03:18
@blacksmith-sh

blacksmith-sh Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Found 6 test failures on Blacksmith runners:

Failures

Test View Logs
[elevated] elevated service is running/[elevated] elevated service is running View Logs
[elevated] elevated service is running/[elevated] elevated service is running View Logs
[elevated] the elevated service is untouched by the standard-user attempts/
[elevated] the elevated service is untouched by the standard-user attempts
View Logs
[elevated] the elevated service is untouched by the standard-user attempts/
[elevated] the elevated service is untouched by the standard-user attempts
View Logs
[upgrade] install.ps1 started the service again as a new process/
[upgrade] install.ps1 started the service again as a new process
View Logs
[upgrade] install.ps1 started the service again as a new process/
[upgrade] install.ps1 started the service again as a new process
View Logs

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

@sagnik11
sagnik11 marked this pull request as ready for review November 20, 2026 03:46
@sagnik11
sagnik11 merged commit bc6d4af into main Nov 20, 2026
7 of 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