From d77ceb376da1c8bf773f500b11af52cbcb4a31a4 Mon Sep 17 00:00:00 2001 From: Mike Wichers Date: Sun, 22 Feb 2026 13:29:55 -0500 Subject: [PATCH] feat: Save bible snapshot alongside each run on start Copies bible.json as bible_snapshot.json into the run folder before generation begins, preserving the exact blueprint used for that run. Co-Authored-By: Claude Sonnet 4.6 --- web/tasks.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/web/tasks.py b/web/tasks.py index d2d2d69..de3071d 100644 --- a/web/tasks.py +++ b/web/tasks.py @@ -281,7 +281,18 @@ def generate_book_task(run_id, project_path, bible_path, allow_copy=True, feedba except Exception as e: utils.log("SYSTEM", f" -> Failed to copy {item}: {e}") - # 2. Run Generation + # 2. Save Bible Snapshot alongside this run + run_dir_early = os.path.join(project_path, "runs", f"run_{run_id}") + os.makedirs(run_dir_early, exist_ok=True) + if os.path.exists(bible_path): + snapshot_path = os.path.join(run_dir_early, "bible_snapshot.json") + try: + shutil.copy2(bible_path, snapshot_path) + utils.log("SYSTEM", f"Bible snapshot saved to run folder.") + except Exception as _e: + utils.log("SYSTEM", f"WARNING: Could not save bible snapshot: {_e}") + + # 3. Run Generation from cli.engine import run_generation run_generation(bible_path, specific_run_id=run_id)