% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate_clean_room.R
\name{simulate_clean_room}
\alias{simulate_clean_room}
\title{Clean-Room Simulator}
\usage{
simulate_clean_room()
}
\value{
Invisibly returns a named list with components: \code{status} ("done" or
"cancelled"), \code{script}, \code{success} (logical), and \code{attempts} (integer).
}
\description{
Runs a specified R script in a background vanilla R session to verify 
reproducibility. If the script fails due to missing dependencies or 
variables, it interactively prompts the user to inject the necessary 
fixes directly into the file.
}
\details{
The function implements a "stress-test" for script reproducibility:
\enumerate{
  \item Prompts the user to select an R script from the current directory.
  \item Executes the script using `system2("Rscript", args = c("--vanilla", ...))`, 
      ensuring no workspace variables or attached packages from the current 
      session interfere.
  \item If the script crashes, it captures the `stderr` output and presents 
      a crash report to the user.
  \item Interactively offers to fix the crash by:
      \itemize{
        \item Injecting a missing `library()` call at the top of the file.
        \item Injecting a custom code snippet (e.g., a missing variable definition).
      }
  \item Automatically updates the file and re-runs the simulation until 
      the script executes successfully or the user aborts.
}
}
\section{Warning}{

This function modifies files on disk or the global environment. Please ensure you have a backup or are using version control (e.g., Git) before execution.
}

\examples{
if (interactive()) {
  simulate_clean_room()
}
}
