feat: complete reliable coordination adapter
Some checks failed
tamq-ci / test (push) Failing after 5s
Some checks failed
tamq-ci / test (push) Failing after 5s
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
This commit is contained in:
parent
25113f463e
commit
6d2ccc7760
30 changed files with 2553 additions and 144 deletions
|
|
@ -41,10 +41,58 @@ def test_store_migrates_legacy_endpoint_rows_to_manual_delivery(tmp_path):
|
|||
assert store.endpoints()[0]["delivery_mode"] == "manual"
|
||||
assert store.db.execute(
|
||||
"SELECT value FROM metadata WHERE key='schema_version'"
|
||||
).fetchone()[0] == "4"
|
||||
).fetchone()[0] == "6"
|
||||
assert "displayed_at" in {
|
||||
row["name"] for row in store.db.execute("PRAGMA table_info(messages)")
|
||||
}
|
||||
assert store.db.execute(
|
||||
"SELECT COUNT(*) FROM protocol_events"
|
||||
).fetchone()[0] == 0
|
||||
|
||||
|
||||
def test_protocol_ledger_is_atomic_and_not_duplicated_on_reopen(tmp_path):
|
||||
path = tmp_path / "queue.sqlite3"
|
||||
store = Store(path)
|
||||
message_id = store.add(
|
||||
"source", "target", "first\nsecond", provenance="worker_output"
|
||||
)
|
||||
event = store.protocol_events(message_id=message_id)[0]
|
||||
assert event["event_type"] == "message.accepted"
|
||||
assert event["repo"] == "source"
|
||||
assert event["peer_repo"] == "target"
|
||||
assert json.loads(event["detail"]) == {"line_count": 2}
|
||||
store.close()
|
||||
|
||||
reopened = Store(path)
|
||||
assert len(reopened.protocol_events(message_id=message_id)) == 1
|
||||
reopened.close()
|
||||
|
||||
|
||||
def test_schema_v5_backfills_existing_message_lifecycle(tmp_path):
|
||||
path = tmp_path / "legacy-messages.sqlite3"
|
||||
store = Store(path)
|
||||
message_id = store.add("a", "b", "old")
|
||||
store.db.execute("DELETE FROM protocol_events")
|
||||
store.db.execute(
|
||||
"UPDATE messages SET displayed_at=2,injected_at=3,acknowledged_at=4 "
|
||||
"WHERE message_id=?",
|
||||
(message_id,),
|
||||
)
|
||||
store.db.commit()
|
||||
store.close()
|
||||
|
||||
migrated = Store(path)
|
||||
assert [row["event_type"] for row in migrated.protocol_events()] == [
|
||||
"delivery.displayed",
|
||||
"delivery.injected",
|
||||
"message.acknowledged",
|
||||
"message.accepted",
|
||||
]
|
||||
assert all(
|
||||
json.loads(row["detail"])["backfilled"] is True
|
||||
for row in migrated.protocol_events()
|
||||
)
|
||||
migrated.close()
|
||||
|
||||
|
||||
def test_mark_displayed_releases_lease_without_acknowledging(tmp_path):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue