What isn't the dev agent's moves to nisse-core, unchanged in behaviour, with its tests: canonical, render, render_anthropic, llm, catalog, probe, context, views, state, reconcile, worker, cancel, dump, transport, matrix, execution, testing, vault, memory, oplog, envfile and gitea (whole). - nisse_core.state.StateStore holds the tables every agent has; an agent's subclass adds its tables (version, migrations), roles and views. nisse_dev.state.StateStore adds the build VM blocks (v5). - views.project takes what each role is shown, rather than a fixed table. - Vault takes the agent's name (agent=), for provenance. - A test that nisse_core never imports an agent. - The loop, config, git, delegation, expert, tools and evals stay in nisse-dev until nisse-ops has a loop to share. Docs: the Development Plan marks M7.1 done and notes that Phase 6 waits on the agent host and Terraform; Architecture Part L names the package. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
69 lines
2.4 KiB
Python
69 lines
2.4 KiB
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from nisse_core.reconcile import reconcile_on_boot
|
|
from nisse_core.state import Intent, StateStore
|
|
|
|
|
|
@pytest.fixture
|
|
def store(tmp_path: Path) -> StateStore:
|
|
return StateStore(tmp_path / "state.db")
|
|
|
|
|
|
def test_no_pending_intents_resumes(store: StateStore) -> None:
|
|
report = reconcile_on_boot(store, {})
|
|
assert report.action == "resume"
|
|
assert report.notes == []
|
|
|
|
|
|
def test_verified_effect_commits_intent_and_resumes(store: StateStore) -> None:
|
|
store.begin_intent("push_branch", {"branch": "m2"}, cause="test")
|
|
report = reconcile_on_boot(store, {"push_branch": lambda intent: True})
|
|
assert report.action == "resume"
|
|
assert store.pending_intents() == []
|
|
|
|
|
|
def test_verified_no_effect_aborts_intent_and_resumes(store: StateStore) -> None:
|
|
store.begin_intent("push_branch", {"branch": "m2"}, cause="test")
|
|
report = reconcile_on_boot(store, {"push_branch": lambda intent: False})
|
|
assert report.action == "resume"
|
|
assert store.pending_intents() == []
|
|
|
|
|
|
def test_unverifiable_intent_gates_to_await_input(store: StateStore) -> None:
|
|
store.begin_intent("push_branch", {"branch": "m2"}, cause="test")
|
|
report = reconcile_on_boot(store, {"push_branch": lambda intent: None})
|
|
assert report.action == "await_input"
|
|
assert [i.kind for i in store.pending_intents()] == ["push_branch"]
|
|
|
|
|
|
def test_unknown_intent_kind_gates_to_await_input(store: StateStore) -> None:
|
|
store.begin_intent("mystery", {}, cause="test")
|
|
report = reconcile_on_boot(store, {})
|
|
assert report.action == "await_input"
|
|
assert "no reconciler registered" in report.notes[0]
|
|
|
|
|
|
def test_reconciler_receives_the_intent(store: StateStore) -> None:
|
|
store.begin_intent("push_branch", {"branch": "m2"}, cause="test")
|
|
seen: list[Intent] = []
|
|
|
|
def check(intent: Intent) -> bool:
|
|
seen.append(intent)
|
|
return True
|
|
|
|
reconcile_on_boot(store, {"push_branch": check})
|
|
assert seen[0].payload == {"branch": "m2"}
|
|
|
|
|
|
def test_mixed_verdicts_still_gate(store: StateStore) -> None:
|
|
store.begin_intent("push_branch", {}, cause="test")
|
|
store.begin_intent("open_pr", {}, cause="test")
|
|
report = reconcile_on_boot(
|
|
store,
|
|
{"push_branch": lambda intent: True, "open_pr": lambda intent: None},
|
|
)
|
|
assert report.action == "await_input"
|
|
assert [i.kind for i in store.pending_intents()] == ["open_pr"]
|