P-NP / tests /test_state.py
adamm-hf's picture
adamm-hf HF Staff
Upload 37 files
a527a3d verified
Raw
History Blame Contribute Delete
1.01 kB
from pathlib import Path
from pnp_lab.config import Settings
from pnp_lab.schemas import Claim, Frontier
from pnp_lab.state import StateStore
def settings_for(tmp_path: Path) -> Settings:
s = Settings()
s.persistent_root = tmp_path
s.brain_dir = tmp_path / "brain"
s.runtime_dir = tmp_path / "runtime"
s.hf_token = ""
s.ensure_dirs()
return s
def test_state_round_trip_in_markdown(tmp_path):
s = settings_for(tmp_path)
store = StateStore(s)
f = Frontier(id="F1", title="Frontier", question="Q?", why_high_leverage="why", smallest_prerequisite="p", kill_condition="k", success_condition="s")
store.seed_frontier(f)
c = Claim(id="C1", title="claim", statement="stmt", author="test")
store.upsert_claim(c)
assert store.path.suffix == ".md"
assert "```json" in store.path.read_text(encoding="utf-8")
reloaded = StateStore(s).snapshot()
assert reloaded["current_frontier_id"] == "F1"
assert reloaded["claims"]["C1"]["status"] == "CANDIDATE"