Hmbown/CodeWhale · error

reviewed plugin stage changed before stdio launch

Error message

reviewed plugin stage changed before stdio launch

What it means

Before launching a reviewed plugin over stdio, prepare_stdio_launch re-opens and validates the reviewed stage and compares its content and capability hashes against the hashes captured when the plugin was approved. If the staged files changed since review (drift), launch is refused to guarantee the reviewed code is the code that runs.

Solutions

  1. Re-stage and re-review the plugin so the authority hashes match the current stage, then relaunch
  2. Restart the session/workflow so the plugin is staged and approved fresh
  3. Investigate what modified the stage directory (updater, another agent run) before retrying
  4. Restore the stage to its originally approved content if it was changed accidentally
Defensive patterns

Strategy: try-catch

Validate before calling

// before launch: recompute stage hashes and compare against approved authority
const current = hashStage(stageDir);
if (current.content !== approved.contentHash || current.capability !== approved.capabilityHash) {
  throw new Error("stage drift detected; re-review plugin before launch");
}

Try / catch

try {
  launchStdioPlugin(plugin);
} catch (e) {
  if (String(e).includes("stage changed before stdio launch")) {
    // halt the plugin, trigger re-staging + re-review workflow, never retry blindly
  }
  throw e;
}

Prevention

When it happens

Trigger: The staged plugin directory was modified (or re-staged from changed sources) between the security review/approval and the stdio launch; concurrent re-staging by another process; a stale stage directory whose hashes no longer match the authority's recorded content_hash/capability_hash.

Common situations: Long-lived session where the plugin was updated on disk after approval; plugin auto-update overwriting the stage mid-session; interrupted staging leaving a partially rewritten stage; developer manually editing staged plugin files.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/18fd4457fd300723. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/mcp.rs:684

        server_name: &str,
        command: &str,
        args: &[String],
        cwd: Option<&Path>,
    ) -> Result<ReviewedStdioLaunch> {
        self.validate_before_stdio_spawn(server_name)?;
        let staged_root = self
            .authority
            .staged_manifest
            .parent()
            .context("reviewed plugin stage manifest has no parent")?;
        let validated = crate::plugins::manifest::PluginManifest::validate_from_path(
            &self.authority.staged_manifest,
        )
        .map_err(|_| anyhow::anyhow!("reviewed plugin stage could not be opened for launch"))?;
        if validated.content_hash != self.authority.content_hash
            || validated.capability_hash != self.authority.capability_hash
        {
            anyhow::bail!("reviewed plugin stage changed before stdio launch");
        }

        let mut launch = ReviewedStdioLaunch {
            command: std::ffi::OsString::from(command),
            args: args.iter().map(std::ffi::OsString::from).collect(),
            cwd: cwd.map(Path::to_path_buf),
            opened_files: Vec::new(),
            #[cfg(unix)]
            cwd_fd: None,
        };
        if Path::new(command).is_absolute() {
            launch.bind_command(staged_root, Path::new(command), &validated.file_hashes)?;
        }
        // Darwin descriptor paths lose Node's module filename, package.json
        // context and relative-import directory (#5916). Keep the staged path
        // for .js/.cjs and multi-file .mjs entries, after bind_file verifies
        // their bytes. Node reopens these paths; this is not atomic descriptor
        // execution. Sibling modules already use the reviewed staged paths.

View on GitHub (pinned to 73e0f67d83)