diff --git a/CHANGELOG.md b/CHANGELOG.md index 73cfa130a..f021d1e5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +- **Changed** When automatic file-access tracking cannot record everything a task did, the "Not cached" summary line now includes the reason (for example, that the tracking channel ran out of capacity) ([#1054](https://github.com/voidzero-dev/vite-task/pull/1054)). - **Changed** Invalid remote cache endpoint URLs in `cache.remote.url` or `VP_REMOTE_CACHE_URL` (such as missing schemes, non-`http`/`https` schemes, or missing hosts) now fail upfront during configuration and planning instead of warning per task during execution, and `vp run --help` now documents `VP_REMOTE_CACHE`, `VP_REMOTE_CACHE_URL`, and `VP_REMOTE_CACHE_HEADER_` ([#1048](https://github.com/voidzero-dev/vite-task/pull/1048)). - **Changed** Removed `NEXT_*`, `VERCEL`, `VERCEL_*`, `USE_OUTPUT_FOR_EDGE_FUNCTIONS`, `NOW_BUILDER`, `VC_MICROFRONTENDS_CONFIG_FILE_NAME`, `GITHUB_*`, `ACTIONS_ID_TOKEN_REQUEST_URL`, `DOCKER_*`, `BUILDKIT_*`, `COMPOSE_*`, and `*_TOKEN` from the default untracked environment variables passed to cached tasks. Tasks that need any of these variables should declare them explicitly in `cache.env` or `cache.untrackedEnv` ([#1044](https://github.com/voidzero-dev/vite-task/pull/1044)). - **Changed** `VP_*` environment variables (including `VP_REMOTE_CACHE*` and `VP_RUN_*`) are no longer passed through to cached tasks by default; embedders can opt specific variables into default untracked passthrough via `SessionConfig::extra_untracked_env` ([#1043](https://github.com/voidzero-dev/vite-task/pull/1043)). diff --git a/crates/fspy/src/error.rs b/crates/fspy/src/error.rs index e47f84d42..90a7b3cd7 100644 --- a/crates/fspy/src/error.rs +++ b/crates/fspy/src/error.rs @@ -35,13 +35,19 @@ pub enum SpawnError { /// so the accesses collected for the run are a subset of what it really /// touched. /// -/// The tracking channel can be full, or a process can continue untracked -/// because the seccomp filter could not be installed. -/// /// The run itself is unaffected: recording must never stop the program /// doing the work. What cannot be done is anything that needs every /// access, caching above all, which has to treat the run as untracked /// rather than as having touched only the paths that fit. -#[derive(thiserror::Error, Clone, Copy, PartialEq, Eq, Debug)] -#[error("automatic file tracking could not record every file access")] -pub struct TrackingIncomplete; +#[derive(thiserror::Error, Clone, PartialEq, Eq, Debug)] +pub enum TrackingIncomplete { + /// The shared-memory tracking channel ran out of capacity (buffer space, + /// descriptor slots, or the single-record length limit). + #[error("the tracking channel ran out of capacity")] + ChannelCapacityExceeded, + + /// A tracked process reported that it could not record an operation it + /// went on to perform. + #[error("a tracked process could not record an operation")] + Reported, +} diff --git a/crates/fspy/src/ipc.rs b/crates/fspy/src/ipc.rs index 691157d9d..a6ff6c678 100644 --- a/crates/fspy/src/ipc.rs +++ b/crates/fspy/src/ipc.rs @@ -1,5 +1,5 @@ use allocator_api2::alloc::Global; -use fspy_shared::ipc::{AccessReader, AccessReceiver, PathAccess}; +use fspy_shared::ipc::{AccessCloseError, AccessReader, AccessReceiver, PathAccess}; use crate::error::TrackingIncomplete; @@ -51,7 +51,11 @@ impl TryFrom> for ChannelAccesses { /// something it went on to do. What did arrive is then a subset of /// what the run really touched, so none of it is handed back. fn try_from(receiver: AccessReceiver) -> Result { - Ok(Self { reader: receiver.close().map_err(|_| TrackingIncomplete)? }) + match receiver.close() { + Ok(reader) => Ok(Self { reader }), + Err(AccessCloseError::Capacity) => Err(TrackingIncomplete::ChannelCapacityExceeded), + Err(AccessCloseError::Reported) => Err(TrackingIncomplete::Reported), + } } } diff --git a/crates/vt/src/session/event.rs b/crates/vt/src/session/event.rs index 01d206f04..1990dc989 100644 --- a/crates/vt/src/session/event.rs +++ b/crates/vt/src/session/event.rs @@ -114,9 +114,10 @@ pub enum CacheNotUpdatedReason { /// the seccomp filter could not be installed and an exec continued /// untracked. The accesses that did arrive are a subset of what the /// task touched, so caching from them would bake in inputs and outputs - /// that are not all of them. - #[cfg_attr(not(fspy), expect(dead_code, reason = "only fspy tracking can be incomplete"))] - TrackingIncomplete, + /// that are not all of them. Carries the underlying reason for + /// user-facing reporting. + #[cfg(fspy)] + TrackingIncomplete(fspy::TrackingIncomplete), } /// Outcome of the post-run cache update after a spawned process exited with diff --git a/crates/vt/src/session/execute/cache_update.rs b/crates/vt/src/session/execute/cache_update.rs index 5f084ce67..3eea2d3ef 100644 --- a/crates/vt/src/session/execute/cache_update.rs +++ b/crates/vt/src/session/execute/cache_update.rs @@ -106,8 +106,14 @@ pub(super) async fn update_cache( // arrived is a subset of what it touched, and an entry // built from a subset would replay with inputs and outputs missing. #[cfg(fspy)] - let Ok(path_accesses) = path_accesses.map(Result::as_ref).transpose() else { - return CacheUpdateOutcome::NotUpdated(CacheNotUpdatedReason::TrackingIncomplete); + let path_accesses = match path_accesses { + Some(Ok(accesses)) => Some(accesses), + Some(Err(reason)) => { + return CacheUpdateOutcome::NotUpdated(CacheNotUpdatedReason::TrackingIncomplete( + reason.clone(), + )); + } + None => None, }; // Every schema version's folder is in the task cache, not only this one. diff --git a/crates/vt/src/session/reporter/summary.rs b/crates/vt/src/session/reporter/summary.rs index bef80fb4f..892759429 100644 --- a/crates/vt/src/session/reporter/summary.rs +++ b/crates/vt/src/session/reporter/summary.rs @@ -164,7 +164,7 @@ pub enum SavedCacheNotUpdatedReason { IpcServerError(SavedError), /// Automatic file tracking could not record everything the task did, so /// the inferred inputs and outputs were a subset of what it touched. - TrackingIncomplete, + TrackingIncomplete(SavedError), /// A runner-aware tool called `disableCache()`, skipping cache update. ToolRequested, } @@ -334,7 +334,10 @@ impl SavedCacheNotUpdatedReason { Self::IpcServerError(SavedError::new(err)) } CacheNotUpdatedReason::ToolRequested => Self::ToolRequested, - CacheNotUpdatedReason::TrackingIncomplete => Self::TrackingIncomplete, + #[cfg(fspy)] + CacheNotUpdatedReason::TrackingIncomplete(reason) => { + Self::TrackingIncomplete(SavedError::new(reason)) + } } } } @@ -579,12 +582,13 @@ impl TaskResult { SavedCacheNotUpdatedReason::ToolRequested => { (Str::from("→ Not cached: the task opted out of caching"), Vec::new(), &[]) } - SavedCacheNotUpdatedReason::TrackingIncomplete => ( - Str::from( - "→ Not cached: automatic file tracking couldn't record everything this task did. Configure `input` and `output` manually to enable caching.", + SavedCacheNotUpdatedReason::TrackingIncomplete(error) => ( + vt_str::format!( + "→ Not cached: automatic file tracking couldn't record everything this task did: {}. Configure `input` and `output` manually to enable caching.", + error.message, ), Vec::new(), - &[], + &error.causes, ), SavedCacheNotUpdatedReason::FspyUnsupported => ( Str::from( @@ -1892,7 +1896,13 @@ mod tests { let summary = full_summary(vec![ not_updated("opt-out", SavedCacheNotUpdatedReason::ToolRequested), - not_updated("incomplete", SavedCacheNotUpdatedReason::TrackingIncomplete), + not_updated( + "incomplete", + SavedCacheNotUpdatedReason::TrackingIncomplete(saved_error( + "the tracking channel ran out of capacity", + &[], + )), + ), not_updated("no-fspy", SavedCacheNotUpdatedReason::FspyUnsupported), not_updated( "ipc", @@ -1917,11 +1927,9 @@ mod tests { ]); assert!(summary.as_str().contains("→ Not cached: the task opted out of caching")); - assert!( - summary - .as_str() - .contains("→ Not cached: automatic file tracking couldn't record everything") - ); + assert!(summary.as_str().contains( + "→ Not cached: automatic file tracking couldn't record everything this task did: the tracking channel ran out of capacity. Configure `input` and `output` manually to enable caching." + )); assert!( summary .as_str() diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/fspy_shm_capacity/snapshots/shm_capacity_env_sizes_the_tracking_channel.md b/crates/vt_bin/tests/e2e_snapshots/fixtures/fspy_shm_capacity/snapshots/shm_capacity_env_sizes_the_tracking_channel.md index eeedd0a19..79f406a11 100644 --- a/crates/vt_bin/tests/e2e_snapshots/fixtures/fspy_shm_capacity/snapshots/shm_capacity_env_sizes_the_tracking_channel.md +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/fspy_shm_capacity/snapshots/shm_capacity_env_sizes_the_tracking_channel.md @@ -23,7 +23,7 @@ Performance: 0% cache hit rate Task Details: ──────────────────────────────────────────────── [1] fspy-shm-capacity#stat: $ vtt stat-many 20000 ✓ - → Not cached: automatic file tracking couldn't record everything this task did. Configure `input` and `output` manually to enable caching. + → Not cached: automatic file tracking couldn't record everything this task did: the tracking channel ran out of capacity. Configure `input` and `output` manually to enable caching. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ``` @@ -46,6 +46,6 @@ Performance: 0% cache hit rate Task Details: ──────────────────────────────────────────────── [1] fspy-shm-capacity#stat: $ vtt stat-many 20000 ✓ - → Not cached: automatic file tracking couldn't record everything this task did. Configure `input` and `output` manually to enable caching. + → Not cached: automatic file tracking couldn't record everything this task did: the tracking channel ran out of capacity. Configure `input` and `output` manually to enable caching. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```