Skip to content

refactor(vt): make leaf reporting and summary outcomes exhaustive - #1019

Merged
wan9chi merged 2 commits into
mainfrom
t3/vt-leaf-outcome-refactor
Nov 26, 2026
Merged

wan9chi merged 2 commits into
mainfrom
t3/vt-leaf-outcome-refactor

Conversation

@wan9chi

@wan9chi wan9chi commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Motivation

The leaf execution reporting pipeline and persisted run summary flattened mutually exclusive states into loosely coupled tuples and flags, allowing invalid combinations to be constructed and forcing downstream code to reconstruct intent:

  • execute_spawn built a typed private Report enum and immediately flattened it into (Option<ExitStatus>, CacheUpdateStatus, Option<ExecutionError>) at LeafExecutionReporter::finish.
  • LeafExecutionReporter split a single leaf lifecycle across uncorrelated start(CacheStatus) and finish(...) calls, requiring SummaryLeafReporter to stash Option<CacheStatus> and pair it back up with the finish outcome.
  • cache_update::update_cache returned (CacheUpdateStatus, Option<ExecutionError>) and fabricated CacheNotUpdatedReason::CacheDisabled on all four error paths (as did Report::failed), even when caching was enabled.
  • summary::SpawnOutcome::Success carried six independent bool/Option<SavedError> fields (infra_error, fspy_unsupported, ipc_server_error, tracking_incomplete, tool_disabled_cache, upload_error), allowing mutually exclusive skip/error states to coexist and allowing upload_error to be attached even when no local cache update happened.
  • TaskResult::from_execution unpacked four flags from CacheUpdateStatus into spawn_outcome_from_execution, which relied on a (None, None) fallback for dry-run WouldSpawn leaves, while summary rendering depended on implicit if let precedence.

Changes

  • Typed cache update and self-contained leaf outcomes (event.rs, execute/cache_update.rs, execute/mod.rs, execute/scheduler.rs, session/mod.rs):
    • Replace (CacheUpdateStatus, Option<ExecutionError>) with CacheUpdateOutcome (Updated { upload_error }, NotUpdated(CacheNotUpdatedReason), Failed(ExecutionError)) so error paths never fabricate CacheDisabled.
    • Trim CacheNotUpdatedReason to post-exit-0 reasons only (CacheDisabled, Cancelled, FspyUnsupported, IpcServerError, ToolRequested, TrackingIncomplete).
    • Borrow &CacheStatus in LeafExecutionReporter::start and replace the 3-argument finish signature with a self-contained LeafOutcome (CacheHit, RestoreFailed, InProcess, Spawned { cache_status, outcome }, FailedBeforeStart, Cancelled) plus LeafOutcome::into_error, eliminating SummaryLeafReporter.cache_status and any cross-product unreachable! branches.
    • Keep a private SpawnReport in execute/mod.rs (excluding InProcess) and rename execute::SpawnOutcome::Failed to InfraError to avoid ambiguity with summary::SpawnOutcome::Failed.
    • Update all six LeafExecutionReporter implementations (PlainReporter, InterleavedLeafReporter, LabeledLeafReporter, GroupedLeafReporter, JsonLeafReporter, SummaryLeafReporter) to consume LeafOutcome cleanly while preserving existing output, JSON, and exit-status behavior.
  • Exhaustive persisted summary cache outcomes (summary.rs, summary_reporter.rs):
    • Replace the six fields on summary::SpawnOutcome::Success with SavedCacheOutcome (Updated { upload_error }, NotUpdated(SavedCacheNotUpdatedReason), Failed(SavedError)) and add SpawnOutcome::WouldSpawn for dry runs.
    • Map LeafOutcome directly to LeafSummaryOutcome with zero unreachable! arms, removing flag unpacking and the (None, None) fallback.
    • Restrict TaskResult::set_upload_error to SavedCacheOutcome::Updated, preserve IPC-error summary formatting parity, and keep existing ReadSummaryError::IncompatibleVersion handling for older last-summary.json files.
    • Add unit tests covering legacy deserialization, JSON round-tripping of the new variants, LeafSummaryOutcome::from_leaf_outcome, set_upload_error, and summary formatting.

Note

Medium Risk
Touches the core task execution, caching, and reporting path, but changes are mostly structural typing with explicit parity for exit status, fast-fail, and summary output.

Overview
Replaces the loosely coupled leaf reporting pipeline (start(CacheStatus) plus finish(exit_status, cache_update, error)) with a single LeafOutcome that bundles cache context and result so invalid pairings are unrepresentable. Post-run caching now returns CacheUpdateOutcome (Updated / NotUpdated / Failed) instead of (CacheUpdateStatus, Option<ExecutionError>), so infrastructure failures no longer masquerade as CacheDisabled.

The spawn path maps through SpawnReport into narrower SpawnOutcome variants (SpawnedSuccess, SpawnedFailed, InfraError), and update_cache is only invoked for exit-0 runs. All LeafExecutionReporter implementations and the summary layer consume LeafOutcome directly; persisted summaries use SavedCacheOutcome / SavedCacheNotUpdatedReason and LeafSummaryOutcome::from_leaf_outcome, with legacy last-summary.json shapes rejected as incompatible.

Reviewed by Cursor Bugbot for commit c0c73b1. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  -0.14%  [ -2.91% ..  +3.51%]  overhead   +57.58%
dynamic/access             change  +0.00%  [ -4.62% ..  +4.30%]  overhead   +18.67%
dynamic/access-relative    change  +0.30%  [ -2.67% ..  +2.70%]  overhead   +67.27%
dynamic/access-contended   change  +2.21%  [ -7.26% ..  +6.77%]  overhead   +35.25%
static/launch              change  +0.07%  [ -2.60% ..  +3.22%]  overhead  +205.01%
static/access              change  -0.22%  [ -1.18% ..  +0.50%]  overhead +1422.05%
static/access-relative     change  +0.10%  [ -1.05% ..  +0.91%]  overhead +1971.19%
static/access-contended    change  -0.15%  [ -1.21% ..  +0.93%]  overhead +1855.82%

macos

dynamic/launch             change  +0.12%  [ -2.19% ..  +2.50%]  overhead  +226.87%
dynamic/access             change  +0.00%  [ -1.06% ..  +1.08%]  overhead    +1.80%
dynamic/access-relative    change  -0.21%  [ -1.55% ..  +1.46%]  overhead  +244.30%
dynamic/access-contended   change  -1.64%  [ -3.88% ..  +1.73%]  overhead    +3.69%

windows

dynamic/launch             change  +0.20%  [ -2.29% ..  +2.12%]  overhead   +26.57%
dynamic/access             change  +0.00%  [ -1.30% ..  +1.13%]  overhead    +0.93%
dynamic/access-relative    change  -0.18%  [ -1.28% ..  +1.09%]  overhead    +0.91%
dynamic/access-contended   change  +0.17%  [ -0.70% ..  +1.61%]  overhead    +1.77%

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f552e47. Configure here.

wan9chi and others added 2 commits November 26, 2026 09:25
Replace the flattened 3-argument LeafExecutionReporter::finish signature,
CacheUpdateStatus/Option<ExecutionError> tuple, and 6 coupled fields on
summary::SpawnOutcome::Success with exhaustive enums (LeafOutcome,
CacheUpdateOutcome, and SavedCacheOutcome) so invalid pairings are
unrepresentable.

Co-authored-by: Gemini 4 Neon <noreply@google.com>
…utcome

- Borrow `&CacheStatus` in `LeafExecutionReporter::start` and make
  `LeafOutcome` self-contained (`CacheHit`, `RestoreFailed`, `InProcess`,
  `Spawned { cache_status, outcome }`, `FailedBeforeStart`, `Cancelled`),
  removing `SummaryLeafReporter.cache_status` and the `CacheStatus` x
  `LeafOutcome` cross-product `unreachable!`s in `summary.rs`.
- Keep a private `SpawnReport` in `execute/mod.rs` (excluding `InProcess`)
  so `execute_spawn` has no `unreachable!` arm.
- Add `LeafOutcome::into_error` to deduplicate error extraction across
  five reporters.
- Align naming (`SavedCacheOutcome::NotUpdated(SavedCacheNotUpdatedReason)`,
  `execute::SpawnOutcome::InfraError`), preserve IPC-error rendering parity
  in `format_full_summary`, update doc comments, and add round-trip and
  non-spawn outcome tests.

Co-authored-by: gemini-4-neon <noreply@google.com>
@wan9chi
wan9chi force-pushed the t3/vt-leaf-outcome-refactor branch from f552e47 to c0c73b1 Compare November 26, 2026 01:25
@wan9chi
wan9chi merged commit ce5aa15 into main Nov 26, 2026
23 checks passed
@wan9chi
wan9chi deleted the t3/vt-leaf-outcome-refactor branch November 26, 2026 01:29
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