fix(conductor): Apply review suggestions for track 'history_segregation'
This commit is contained in:
@@ -122,11 +122,16 @@ def default_project(name: str = "unnamed") -> dict:
|
||||
# ── load / save ──────────────────────────────────────────────────────────────
|
||||
|
||||
def get_history_path(project_path: str | Path) -> Path:
|
||||
"""Return the Path to the sibling history TOML file for a given project."""
|
||||
p = Path(project_path)
|
||||
return p.parent / f"{p.stem}_history.toml"
|
||||
|
||||
|
||||
def load_project(path) -> dict:
|
||||
def load_project(path: str | Path) -> dict:
|
||||
"""
|
||||
Load a project TOML file.
|
||||
Automatically migrates legacy 'discussion' keys to a sibling history file.
|
||||
"""
|
||||
with open(path, "rb") as f:
|
||||
proj = tomllib.load(f)
|
||||
|
||||
@@ -150,6 +155,7 @@ def load_project(path) -> dict:
|
||||
|
||||
|
||||
def load_history(project_path: str | Path) -> dict:
|
||||
"""Load the segregated discussion history from its dedicated TOML file."""
|
||||
hist_path = get_history_path(project_path)
|
||||
if hist_path.exists():
|
||||
with open(hist_path, "rb") as f:
|
||||
@@ -157,7 +163,11 @@ def load_history(project_path: str | Path) -> dict:
|
||||
return {}
|
||||
|
||||
|
||||
def save_project(proj: dict, path, disc_data: dict | None = None):
|
||||
def save_project(proj: dict, path: str | Path, disc_data: dict | None = None):
|
||||
"""
|
||||
Save the project TOML.
|
||||
If 'discussion' is present in proj, it is moved to the sibling history file.
|
||||
"""
|
||||
# Ensure 'discussion' is NOT in the main project dict
|
||||
if "discussion" in proj:
|
||||
# If disc_data wasn't provided, use the one from proj
|
||||
|
||||
Reference in New Issue
Block a user