Implement automatic environment pinning when analysis capsules are created. Capture pip/conda/nix dependencies, container image digests, and compute a deterministic environment_digest so capsules can be reproduced months or years later.
forge/runtime_capture.py module with environment discovery functionscapture_python_environment() -> Dict captures pip packages, Python version, conda envcapture_container_environment() -> Dict captures Docker image digest, runtime infocompute_environment_digest(env: Dict) -> str generates deterministic SHA256forge/runtime_capture.py with:
def capture_python_environment() -> Dict:
"""Capture Python packages, version, and virtual environment."""
# Use importlib.metadata to get installed packages
# Include Python version, pip version, conda environment if active
# Return dict sorted for deterministic hashing
def capture_container_environment() -> Dict:
"""Capture container image digest if running in Docker."""
# Check /proc/self/cgroup for container ID
# Query Docker daemon for image digest
# Return container metadata or None if not in container
def compute_environment_digest(env: Dict) -> str:
"""Generate deterministic SHA256 hash of environment."""
# Sort keys recursively, canonicalize JSON
# Return hex digest
def verify_environment_match(capsule_env: Dict) -> Dict:
"""Check if current environment matches capsule's captured environment."""
# Re-capture current environment
# Compare with capsule's environment_digest
# Return match status with diffagent.py:environment_digest in capsule manifestpost_process.py:--capture-capsule flag to generate capsule after analysisartifact_registry.py capsule functions:register_capsule() accepts environment_capture: Dict parameterverify_capsule() calls verify_environment_match()api.py:GET /api/capsules/{capsule_id}/environment-verify - check environment matchdocs/planning/specs/quest_reproducible_analysis_capsules_spec.md — parent questartifact_registry.py — capsule registration functions (already exists)agent.py — analysis execution (already exists)