Skip to content

The agent that grows with you

fix(bot): receipt read forwards the immutable author so retries recover instead of conflicting

teknium1c4248663f796
diff --git a/tests/tools/test_bot_live_owner_delivery.py b/tests/tools/test_bot_live_owner_delivery.py
index 4ab4ce85e67..c87126856f3 100644
--- a/tests/tools/test_bot_live_owner_delivery.py
+++ b/tests/tools/test_bot_live_owner_delivery.py
@@ -68,6 +68,17 @@ def test_owner_from_another_home_or_malformed_id_is_refused_before_admission(tmp
assert authority.calls == []
+def test_receipt_read_forwards_the_immutable_author(tmp_path, monkeypatch):
+ """F10: an authored admission is re-read with its stored author, so the authority sees the same payload."""
+ authority = _FakeAuthority()
+ monkeypatch.setattr(mailbox, "authority_delivery", authority)
+ delivery_id = "d" * 32
+ author = {"kind": "user", "id": "u-1", "display": "Ann"}
+ queued = mailbox.deliver_to_live_owner(tmp_path, _owner(tmp_path), "hello", delivery_id=delivery_id, author=author)
+ assert mailbox.read_delivery_result(tmp_path, delivery_id) == queued
+ assert [params.get("author") for _home, params in authority.calls] == [author, author]
+
+
@pytest.mark.parametrize("terminal_status", ["settled", "failed", "cancelled"])
def test_terminal_receipt_is_immutable(tmp_path, terminal_status):
delivery_id = "c" * 32
diff --git a/tools/bot_live_delivery.py b/tools/bot_live_delivery.py
index 83e0a177739..1bbcba0c2ed 100644
--- a/tools/bot_live_delivery.py
+++ b/tools/bot_live_delivery.py
@@ -195,6 +195,8 @@ def read_delivery_result(profile_home: Path | str, delivery_id: str) -> dict[str
record = _read(_root(profile_home) / f"{_delivery_id(delivery_id)}.json")
if record is not None and record.get('admission_id'):
home = Path(profile_home).resolve()
+ # The authority compares the stored author to the retry payload; omitting it is a conflict.
return authority_delivery(home, dict(id=delivery_id,
- profile=home.name if home.parent.name == 'profiles' else 'default', message=record['message']))
+ profile=home.name if home.parent.name == 'profiles' else 'default', message=record['message'],
+ **({'author': dict(record['author'])} if record.get('author') else {})))
return record