Implement A9 state-change logging in the state store
Retrofit for the conventions merged in #4 (issue #3): - OpLog: JSON-lines emitter with the fixed envelope (ts, agent, event, task_id, cause); task_id set by the orchestrator at unit-of-work start - StateStore owns emission: transition, intent begin/commit/abort, and schema migrations each emit their event right after the durable write commits; callers pass the cause - reconcile_on_boot emits boot.reconcile with action and verdicts, and resolves intents with reconciliation-verdict causes - Failed resolutions emit nothing (a line exists iff the write committed) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ba848281ec
commit
18d4fcd701
7 files changed
+216
-32
No files matched your search
@@ -18,35 +18,35 @@ def test_no_pending_intents_resumes(store: StateStore) -> None:
|
||||
|
||||
|
||||
def test_verified_effect_commits_intent_and_resumes(store: StateStore) -> None:
|
||||
store.begin_intent("push_branch", {"branch": "m2"})
|
||||
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"})
|
||||
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"})
|
||||
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", {})
|
||||
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"})
|
||||
store.begin_intent("push_branch", {"branch": "m2"}, cause="test")
|
||||
seen: list[Intent] = []
|
||||
|
||||
def check(intent: Intent) -> bool:
|
||||
@@ -58,8 +58,8 @@ def test_reconciler_receives_the_intent(store: StateStore) -> None:
|
||||
|
||||
|
||||
def test_mixed_verdicts_still_gate(store: StateStore) -> None:
|
||||
store.begin_intent("push_branch", {})
|
||||
store.begin_intent("open_pr", {})
|
||||
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},
|
||||
|
||||
Reference in new issue
Block a user