Skip to content

fix(daemon): stop logging vanished clone/init target as an error - #60

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixdaemon-stop-logging-vanished-a1ce5d
Draft

posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixdaemon-stop-logging-vanished-a1ce5d

Conversation

@posthog

@posthog posthog Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Problem

  • The team gets a new error-tracking issue every time someone clones or inits a repo into a directory that disappears right after — nothing is actually broken.
  • After a successful git clone/git init, finalize_root_exit resolves the new repo's family key. When the target directory is already gone, common_dir_for_repo_path finds no repo and the branch called observability::log_error, which the telemetry bridge turns into a user-facing $exception.
  • The failure is an expected race, not a bug: the target vanished before the daemon finalized the trace (agent plugin staging clones, temp dirs a test run deletes the moment git exits). A "missing gitdir for worktree while reading HEAD reflog" exception fires for the same directory in the same second, confirming the directory vanished rather than any parse problem.
  • The code already keeps the best worktree hint and carries on, so attribution is unaffected — this is pure telemetry noise aimed at the team.
  • The absolute path was baked into the message, so every distinct directory opened its own single-occurrence issue (one test run produced two issues a minute apart).

Changes

  • Log the vanished target at warn level (a Message envelope, which the telemetry worker never turns into an $exception) instead of log_error. This mirrors the two existing benign-race guards in the same function (vanished working dir, missing reflog end cut).
  • Move the absolute path out of the message and into structured context, so future occurrences group into one issue instead of fragmenting per directory.
  • Simplify the failure carrier from Option<(PathBuf, AutterError)> to Option<PathBuf> now that no error object is built.

Testing

  • New unit test clone_target_vanished_before_finalize_keeps_worktree_hint_and_does_not_error: the target never materializes on disk; finalize still succeeds, keeps the worktree hint, and falls back to Global scope.
  • cargo test --lib daemon::trace_normalizer — 21 passed.
  • cargo check --locked --all-targets and rustfmt --check clean.

Agent context

  • Confirmed via telemetry_worker.rs that only TelemetryEnvelope::Error reaches the error buffer (→ $exception); Message envelopes go to a separate buffer, so warn-level logging removes the exception without losing the signal.

Created with PostHog Desktop from this inbox report.


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

After a successful clone or init, finalize_root_exit resolves the new repo's
family key. When the target directory is already gone (an expected race for
agent staging clones and throwaway test repos), common_dir_for_repo_path finds
no repo and the branch logged via observability::log_error, which the telemetry
bridge turns into a user-facing $exception. The code already keeps the best
worktree hint and continues, so attribution is never affected.

Treat the vanished target as a benign outcome: log it at warn level (a Message
envelope, not an Error), mirroring the vanished-working-dir and missing-reflog
guards in the same function. Move the absolute path out of the message and into
structured context so occurrences group into one issue instead of fragmenting
one per directory.

paths: src/daemon/trace_normalizer.rs

Generated-By: PostHog Desktop
Task-Id: 8656b2be-b314-4b57-ae05-63890fc0b543
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