Hmbown/CodeWhale · warning
telemetry permission changed before arming
Error message
telemetry permission changed before arming
What it means
arm() enables telemetry buffering using an optimistic-concurrency check: the caller passes the tombstone generation it observed earlier, and arm re-reads it under the privacy lock. If the generation changed — meaning the tombstone was created or removed between the observation and arming, i.e. the user toggled (likely disabled) telemetry — arming is refused with this error instead of overwriting the user's decision.
Solutions
- Re-read the current tombstone generation and retry arm with the fresh value.
- If telemetry was disabled meanwhile, respect it — do not force arm; surface the state to the user.
- Serialize arming through a single owner (same process/lock discipline) to avoid racing with wipe.
- For long sessions, re-observe the generation immediately before arming rather than caching it at startup.
- Check for other codewhale processes running concurrently (pgrep) when the error repeats.
Example fix
// before: generation observed long ago let observed = tombstone_generation(root)?; // ... much later ... arm(root, observed, || enabled)?; // may bail // after: re-observe just before arming let observed = tombstone_generation(root)?; arm(root, observed, || enabled)?;
Defensive patterns
Strategy: retry
Validate before calling
// Re-observe the generation immediately before arming let fresh = telemetry::buffer::tombstone_generation(root)?; anyhow::ensure!(fresh.as_ref() == Some(&observed), "tombstone generation drifted");
Type guard
fn generation_unchanged(root: &Path, observed: &Option<TombstoneGeneration>) -> bool {
telemetry::buffer::tombstone_generation(root).ok().as_ref().flatten() == Some(observed)
} Try / catch
match arm(root, observed, || enabled) {
Err(e) if e.to_string().contains("changed before arming") => {
let fresh = tombstone_generation(root)?;
if !disabled_by_user(&fresh) { arm(root, fresh, || enabled)?; }
}
r => r?,
} Prevention
- Re-read the tombstone generation just before arming, not at startup
- Serialize wipe/arm through a single process or lock
- Treat a generation change as a user decision, not a retryable glitch
- Avoid running multiple codewhale instances that toggle telemetry
When it happens
Trigger: Calling arm(root, observed_generation, permission_still_enabled) after another process (or the user) modified/deleted the tombstone file, so tombstone_generation(root) no longer equals observed_generation.
Common situations: Two codewhale processes racing to enable telemetry; user ran wipe/disable in another terminal just as a session tried to arm; stale observed_generation held across a long-lived session; tests manipulating the telemetry dir concurrently.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- ; additionally the Codewhale-owned legacy secret slot…
- The live pet recording was changed or replaced externally…
- The live pet recording was replaced externally after…
- The previous pet recording changed while reading; it was…
- Too many active Engine pet spans.
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/640d2f032574bfb5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/telemetry/src/buffer.rs:466
}
/// Clear the tombstone and drop anything buffered before this process was
/// permitted.
///
/// Called by `init` on every arming. Both the exact tombstone generation and a
/// fresh durable permission check must still match while the wipe lock is held.
/// A stale buffer left by an earlier run or by a bug cannot enter the new
/// process's batch.
pub(crate) fn arm(
root: &Path,
observed_generation: Option<&TombstoneGeneration>,
permission_still_enabled: impl FnOnce() -> bool,
) -> Result<()> {
ensure_dir(root)?;
with_lock(root, || {
let current_generation = tombstone_generation(root)?;
if current_generation.as_ref() != observed_generation {
anyhow::bail!("telemetry permission changed before arming");
}
if !permission_still_enabled() {
anyhow::bail!("telemetry permission is no longer enabled");
}
let tombstone = tombstone_path(root);
if tombstone.exists() {
fs::remove_file(&tombstone)
.with_context(|| format!("failed to remove {}", tombstone.display()))?;
}
truncate(&buffer_path(root))
})
}
View on GitHub (pinned to 73e0f67d83)