feat(runtime): consume governed Activity Core closes
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a06ba0-10aa-7ea0-b20a-4f3fac39efe9
This commit is contained in:
parent
0e6d795aa4
commit
d00ffcb402
22 changed files with 1218 additions and 148 deletions
|
|
@ -16,6 +16,7 @@ from rein_aharness.close_outbox import (
|
|||
InvalidCloseRequestError,
|
||||
OutboxConflictError,
|
||||
OutboxCorruptError,
|
||||
PermanentCloseDeliveryError,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ def _request(
|
|||
*,
|
||||
run_id: str = "run-1",
|
||||
transaction_id: str = "tx-1",
|
||||
worker_id: str = "worker-1",
|
||||
action: str = "complete",
|
||||
result: dict[str, object] | None = None,
|
||||
error: str = "",
|
||||
|
|
@ -31,6 +33,7 @@ def _request(
|
|||
return CloseRequest(
|
||||
run_id=run_id,
|
||||
transaction_id=transaction_id,
|
||||
worker_id=worker_id,
|
||||
action=action,
|
||||
result=result or {"ok": True, "accepted_commit": "a" * 40},
|
||||
error=error,
|
||||
|
|
@ -57,6 +60,7 @@ def test_enqueue_uses_private_external_atomic_record(tmp_path: Path) -> None:
|
|||
assert payload["state"] == "pending"
|
||||
assert payload["attempts"] == 0
|
||||
assert payload["entry_id"] == receipt.entry_id
|
||||
assert payload["worker_id"] == "worker-1"
|
||||
assert not tuple(outbox.pending_dir.glob("*.tmp"))
|
||||
|
||||
|
||||
|
|
@ -164,6 +168,21 @@ def test_process_interrupt_leaves_attempt_durable_and_pending(tmp_path: Path) ->
|
|||
assert payload["last_error"] is None
|
||||
|
||||
|
||||
def test_permanent_delivery_refusal_is_quarantined(tmp_path: Path) -> None:
|
||||
outbox = CloseOutbox(state_dir=tmp_path / "state")
|
||||
receipt = outbox.enqueue(_request())
|
||||
|
||||
def conflict(_: CloseRequest) -> None:
|
||||
raise PermanentCloseDeliveryError("terminal_conflict")
|
||||
|
||||
report = outbox.replay(conflict)
|
||||
|
||||
assert report.quarantined == 1
|
||||
assert report.remaining == 0
|
||||
assert outbox.entry_state(receipt.entry_id) == "quarantined"
|
||||
assert outbox.status() == {"pending": 0, "delivered": 0, "quarantined": 1}
|
||||
|
||||
|
||||
def test_corrupt_pending_record_is_preserved_in_quarantine(tmp_path: Path) -> None:
|
||||
outbox = CloseOutbox(state_dir=tmp_path / "state")
|
||||
request = _request()
|
||||
|
|
@ -232,6 +251,7 @@ outbox = CloseOutbox(state_dir=Path(sys.argv[1]))
|
|||
receipt = outbox.enqueue(CloseRequest(
|
||||
run_id="run-shared",
|
||||
transaction_id="tx-shared",
|
||||
worker_id="worker-1",
|
||||
action="complete",
|
||||
result={"ok": True},
|
||||
))
|
||||
|
|
@ -279,6 +299,7 @@ def test_replay_limit_is_bounded_and_leaves_remaining_entries(tmp_path: Path) ->
|
|||
[
|
||||
({"run_id": "bad/id"}, "run_id"),
|
||||
({"transaction_id": "with space"}, "transaction_id"),
|
||||
({"worker_id": "with space"}, "worker_id"),
|
||||
({"action": "cancel"}, "action"),
|
||||
({"action": "complete", "error": "not allowed"}, "cannot carry"),
|
||||
({"action": "complete", "reopen": True}, "cannot carry"),
|
||||
|
|
@ -292,6 +313,7 @@ def test_close_request_rejects_ambiguous_identity_or_action(
|
|||
values: dict[str, object] = {
|
||||
"run_id": "run-1",
|
||||
"transaction_id": "tx-1",
|
||||
"worker_id": "worker-1",
|
||||
"action": "complete",
|
||||
"result": {"ok": True},
|
||||
"error": "",
|
||||
|
|
@ -325,6 +347,7 @@ def test_close_request_rejects_unbounded_or_non_json_result(
|
|||
CloseRequest(
|
||||
run_id="run-1",
|
||||
transaction_id="tx-1",
|
||||
worker_id="worker-1",
|
||||
action="complete",
|
||||
result=result, # type: ignore[arg-type]
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue