Skip to content

fix(daemon): skip side-effect errors when the repo was deleted mid-operation - #67

Draft
posthog[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixdaemon-treat-temp-repo-teardown-as-e41121
Draft

posthog[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixdaemon-treat-temp-repo-teardown-as-e41121

Conversation

@posthog

@posthog posthog Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • The team gets error-tracking noise. Each temp-repo teardown race opens a new single-event issue that somebody must triage. No user attribution or data is affected.
  • After a commit, the daemon runs git diff between the commit and its parent. When the repo is deleted first, git exits 1 with Could not access <oid>.
  • is_missing_working_dir_error matches only exit-128 stderr text and NotFound IO errors. So this shape gets to both log sites (command side effect failed, async side-effect error).
  • Known sources: the autter doctor attribution self-check deletes its repo without waiting for daemon side effects, and developer tests delete temp repos right after they commit.

Changes

  • Classify by repo state, not by error text. The new is_vanished_repo_error treats any GitCliError or IoError as benign when the command's worktree, its git dir HEAD, or its objects dir no longer exists. The existing is_missing_working_dir_error text match is unchanged and stays as a fallback.
  • repository_is_gone resolves the git dir with the existing git_dir_for_worktree, so a subdirectory of a live repo resolves to that repo and still reports real errors.
  • Doctor self-check waits for side effects. FamilyStatus gets inflight_effects (with #[serde(default)], so older daemons read as 0). The self-check polls it until the value is 0, within its current deadline, before remove_dir_all.
Error shape Before After
exit 128 No such file or directory / not a git repository skipped skipped
IoError NotFound skipped skipped
exit 1 Could not access <oid>, repo deleted reported skipped
exit 128 not a tree object / bad object, objects deleted reported skipped
any git error, repo still on disk reported reported

Note

Draft #64 adds more exit-128 strings to is_missing_working_dir_error. When the objects dir is gone, this PR also covers those shapes. This PR does not edit that function, so both can merge. Draft #66 changes the two log sites, which this PR does not touch.

Testing

  • cargo test --lib -- missing_working_dir repository_is_gone: 6 passed (2 new tests: exit-1 Could not access with a live, objects-deleted, and fully deleted repo; and a subdirectory of a live repo).
  • cargo test --lib daemon: 139 passed. cargo test --lib diagnostics: 9 passed.
  • cargo clippy --all-targets -- -D warnings and cargo fmt --check: clean.
  • doctor_validates_checkpoint_round_trip_end_to_end fails in the sandbox with git commit ... (status=1). It fails the same way on unchanged main, so the cause is the sandbox environment. CI must confirm it.

Agent context

  • I did not match only paths under the self-check root, because developer temp repos would still make noise.
  • I did not add a list of stderr strings, because each new git error shape would need one more string.
  • Not in scope: the checkpoint side effect failed log site has no vanished-repo guard, and inflight_effects does not count commands still queued in the family sequencer. Both are possible follow-ups.

Created with PostHog Desktop from this inbox report.

🤖 Generated with Claude Code


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

posthog Bot added 2 commits October 7, 2026 19:49
…eration

The vanished-repo guard matched only exit-128 stderr text and NotFound IO
errors. git also reports the race in other shapes, for example `git diff`
exits 1 with "Could not access <oid>" after the objects are gone, so those
errors still reached error tracking.

The guard now also treats any git or IO error as benign when the command's
worktree, its git dir HEAD, or its objects dir no longer exists.

The daemon now reports in-flight side effects per family in the family
status, and the `autter doctor` attribution self-check waits for them before
it deletes its repo.

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

Generated-By: PostHog Desktop
Task-Id: 509cd030-ac58-4e8e-84a3-7f359e5a5d9c
…_for_worktree

Move the repo-state check into a separate is_vanished_repo_error wrapper, so
is_missing_working_dir_error and its tests stay as they were. Resolve the git
dir with git_dir_for_worktree instead of a hand-written ladder.

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

Generated-By: PostHog Desktop
Task-Id: 509cd030-ac58-4e8e-84a3-7f359e5a5d9c
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.

0 participants