CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m22s
Development Plan M0.1. Every section reference in code, tests, specs/, the example config, the tuning guide, and the CLAUDE.md and README files now cites docs/Architecture.md (P, L, D, O, X, Q) instead of the old spec's A-H, and docs/Architecture-Build-Spec.md is deleted (git keeps it). The plan's old-to-new table goes with it. Mostly mechanical, with a per-site choice where one old section split: A4 became L2 where it meant stop/abandon/the loop and L3 where it meant approvals; A10 became L6 in the context-budget code and L7 elsewhere; B2 became D4 for outbound Gitea and publishing and D5 for review intake; 'A3 step N' became the matching step of L8's boot sequence. Comments describing behaviour the architecture drops (planning always escalating, thresholds tuned at an old build step) now describe the current code and point at the Development Plan. docs/Architecture.md gains one line the rewrite missed: intake outages delay but never fail work (old B2), now in L5, where the poller and Matrix code cite it. Comments and docs only; no behaviour change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
"""Integration: state written before an abrupt process death must be intact
|
|
and the in-flight intent visible on the next boot (architecture L8)."""
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from nisse_dev.reconcile import reconcile_on_boot
|
|
from nisse_dev.state import StateStore
|
|
|
|
pytestmark = pytest.mark.integration
|
|
|
|
CRASH_SCRIPT = """
|
|
import os
|
|
import sys
|
|
from nisse_dev.canonical import UserMessage
|
|
from nisse_dev.state import StateStore
|
|
|
|
store = StateStore(sys.argv[1])
|
|
store.transition("EXECUTING", cause="test", project="demo", data={"milestone": 2})
|
|
store.begin_intent("push_branch", {"branch": "milestone-2"}, cause="test")
|
|
store.append_event(UserMessage(text="start milestone 2", source="m:1"))
|
|
os._exit(1) # die without closing anything, as a power cut would
|
|
"""
|
|
|
|
|
|
def test_state_survives_process_death(tmp_path: Path) -> None:
|
|
db = tmp_path / "state.db"
|
|
result = subprocess.run(
|
|
[sys.executable, "-c", CRASH_SCRIPT, str(db)],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=30,
|
|
check=False,
|
|
)
|
|
assert result.returncode == 1, result.stderr
|
|
|
|
with StateStore(db) as store:
|
|
state = store.get_state()
|
|
assert state is not None
|
|
assert state.state == "EXECUTING"
|
|
assert state.data == {"milestone": 2}
|
|
|
|
report = reconcile_on_boot(store, {"push_branch": lambda intent: None})
|
|
assert report.action == "await_input"
|
|
[pending] = store.pending_intents()
|
|
assert pending.payload == {"branch": "milestone-2"}
|
|
|
|
[stored] = store.read_events()
|
|
assert stored.event.text == "start milestone 2"
|