Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
This commit is contained in:
parent
788eb8e2ed
commit
92881b6b56
35 changed files with 1206 additions and 806 deletions
|
|
@ -15,7 +15,7 @@ def test_manual_send_inbox_and_ack_use_window_repository_identity(tmp_path, monk
|
|||
monkeypatch.setattr("tamq.cli.ping", service_is_down)
|
||||
monkeypatch.setattr("tamq.cli.validate_targets", lambda repos: None)
|
||||
|
||||
assert main(["send", "@audit-core:", "review", "this"]) == 0
|
||||
assert main(["send", "To:audit-core:", "review", "this"]) == 0
|
||||
message_id = capsys.readouterr().out.strip()
|
||||
|
||||
assert main(["inbox", "--repo", "audit-core", "--json"]) == 0
|
||||
|
|
@ -24,7 +24,7 @@ def test_manual_send_inbox_and_ack_use_window_repository_identity(tmp_path, monk
|
|||
assert row["sender_repo"] == "flex-auth"
|
||||
assert row["target_repo"] == "audit-core"
|
||||
assert row["body"] == "review this"
|
||||
assert row["state"] == "pending"
|
||||
assert row["provenance"] == "operator_input"
|
||||
|
||||
assert main(["ack", message_id]) == 0
|
||||
capsys.readouterr()
|
||||
|
|
@ -32,103 +32,6 @@ def test_manual_send_inbox_and_ack_use_window_repository_identity(tmp_path, monk
|
|||
assert capsys.readouterr().out == ""
|
||||
|
||||
|
||||
def test_bare_reply_targets_latest_inbound_sender(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.setenv("TAMQ_STATE_DIR", str(tmp_path / "state"))
|
||||
monkeypatch.setenv("TAMQ_REPO", "audit-core")
|
||||
monkeypatch.setattr("tamq.cli.ping", service_is_down)
|
||||
monkeypatch.setattr("tamq.cli.validate_targets", lambda repos: None)
|
||||
store = Store(tmp_path / "state" / "tamq.sqlite3")
|
||||
store.add("flex-auth", "audit-core", "older")
|
||||
latest = store.add("railiance-platform", "audit-core", "latest")
|
||||
store.acknowledge(latest)
|
||||
store.add("audit-core", "audit-core", "self note")
|
||||
store.close()
|
||||
|
||||
assert main(["reply", "--", "--looks-like-an-option", "thanks"]) == 0
|
||||
message_id = capsys.readouterr().out.strip()
|
||||
|
||||
store = Store(tmp_path / "state" / "tamq.sqlite3")
|
||||
row = next(row for row in store.list() if row["message_id"] == message_id)
|
||||
assert row["sender_repo"] == "audit-core"
|
||||
assert row["target_repo"] == "railiance-platform"
|
||||
assert row["body"] == "--looks-like-an-option thanks"
|
||||
store.close()
|
||||
|
||||
|
||||
def test_interactive_reply_shows_latest_and_cycles_session_recipients(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.setenv("TAMQ_STATE_DIR", str(tmp_path / "state"))
|
||||
monkeypatch.setenv("TAMQ_REPO", "audit-core")
|
||||
monkeypatch.setenv(
|
||||
"TAMQ_RECIPIENTS", '["audit-core","railiance-platform","flex-auth"]'
|
||||
)
|
||||
monkeypatch.setattr("tamq.cli.ping", service_is_down)
|
||||
monkeypatch.setattr("tamq.cli.validate_targets", lambda repos: None)
|
||||
store = Store(tmp_path / "state" / "tamq.sqlite3")
|
||||
store.add("flex-auth", "audit-core", "latest inbound")
|
||||
store.close()
|
||||
seen = []
|
||||
|
||||
def compose(recipients):
|
||||
seen.append(recipients)
|
||||
return "railiance-platform", "What's up?"
|
||||
|
||||
monkeypatch.setattr("tamq.cli.compose_message", compose)
|
||||
assert main(["reply"]) == 0
|
||||
message_id = capsys.readouterr().out.strip()
|
||||
|
||||
assert seen == [("flex-auth", "railiance-platform")]
|
||||
store = Store(tmp_path / "state" / "tamq.sqlite3")
|
||||
row = next(row for row in store.list() if row["message_id"] == message_id)
|
||||
assert (row["sender_repo"], row["target_repo"], row["body"]) == (
|
||||
"audit-core", "railiance-platform", "What's up?"
|
||||
)
|
||||
store.close()
|
||||
|
||||
|
||||
def test_interactive_reply_uses_first_peer_without_history(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.setenv("TAMQ_STATE_DIR", str(tmp_path / "state"))
|
||||
monkeypatch.setenv("TAMQ_REPO", "audit-core")
|
||||
monkeypatch.setenv("TAMQ_RECIPIENTS", '["audit-core","flex-auth"]')
|
||||
monkeypatch.setattr("tamq.cli.ping", service_is_down)
|
||||
monkeypatch.setattr("tamq.cli.validate_targets", lambda repos: None)
|
||||
monkeypatch.setattr(
|
||||
"tamq.cli.compose_message", lambda recipients: (recipients[0], "hello")
|
||||
)
|
||||
|
||||
assert main(["reply"]) == 0
|
||||
message_id = capsys.readouterr().out.strip()
|
||||
store = Store(tmp_path / "state" / "tamq.sqlite3")
|
||||
row = next(row for row in store.list() if row["message_id"] == message_id)
|
||||
assert row["target_repo"] == "flex-auth"
|
||||
store.close()
|
||||
|
||||
|
||||
def test_interactive_reply_cancellation_queues_nothing(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("TAMQ_STATE_DIR", str(tmp_path / "state"))
|
||||
monkeypatch.setenv("TAMQ_REPO", "audit-core")
|
||||
monkeypatch.setenv("TAMQ_RECIPIENTS", '["audit-core","flex-auth"]')
|
||||
monkeypatch.setattr("tamq.cli.compose_message", lambda recipients: None)
|
||||
|
||||
assert main(["reply"]) == 130
|
||||
store = Store(tmp_path / "state" / "tamq.sqlite3")
|
||||
assert store.list() == []
|
||||
store.close()
|
||||
|
||||
|
||||
def test_bare_reply_requires_managed_identity_and_prior_sender(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.setenv("TAMQ_STATE_DIR", str(tmp_path / "state"))
|
||||
monkeypatch.setattr("tamq.cli.ping", service_is_down)
|
||||
monkeypatch.setattr("tamq.cli.validate_targets", lambda repos: None)
|
||||
monkeypatch.delenv("TAMQ_REPO", raising=False)
|
||||
|
||||
assert main(["reply", "hello"]) == 2
|
||||
assert "managed window" in capsys.readouterr().err
|
||||
|
||||
monkeypatch.setenv("TAMQ_REPO", "audit-core")
|
||||
assert main(["reply", "hello"]) == 2
|
||||
assert "no counterparty" in capsys.readouterr().err
|
||||
|
||||
|
||||
def test_inbox_requires_repository_outside_managed_window(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.setenv("TAMQ_STATE_DIR", str(tmp_path / "state"))
|
||||
monkeypatch.delenv("TAMQ_REPO", raising=False)
|
||||
|
|
@ -136,16 +39,19 @@ def test_inbox_requires_repository_outside_managed_window(tmp_path, monkeypatch,
|
|||
assert "requires --repo" in capsys.readouterr().err
|
||||
|
||||
|
||||
def test_human_inbox_is_comment_safe_on_every_line(tmp_path, monkeypatch, capsys):
|
||||
def test_human_inbox_uses_readable_origin_framing(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.setenv("TAMQ_STATE_DIR", str(tmp_path / "state"))
|
||||
monkeypatch.setattr("tamq.cli.validate_targets", lambda repos: None)
|
||||
store = Store(tmp_path / "state" / "tamq.sqlite3")
|
||||
message_id = store.add("flex-auth", "audit-core", "first\nsecond\x1b[31m")
|
||||
store.add(
|
||||
"flex-auth", "audit-core", "first\nsecond\x1b[31m",
|
||||
provenance="operator_input",
|
||||
)
|
||||
store.close()
|
||||
|
||||
assert main(["inbox", "--repo", "audit-core"]) == 0
|
||||
assert capsys.readouterr().out == (
|
||||
f"#flex-auth: first\n# second\\x1b[31m [{message_id}]\n"
|
||||
"From:flex-auth/o: first\\x0asecond\\x1b[31m\n"
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -153,8 +59,8 @@ def test_inbox_filter_logs_and_acknowledges_successful_messages(tmp_path, monkey
|
|||
monkeypatch.setenv("TAMQ_STATE_DIR", str(tmp_path / "state"))
|
||||
monkeypatch.setattr("tamq.cli.validate_targets", lambda repos: None)
|
||||
store = Store(tmp_path / "state" / "tamq.sqlite3")
|
||||
first_id = store.add("flex-auth", "audit-core", "review 'quoted' $value")
|
||||
second_id = store.add("railiance-platform", "audit-core", "second")
|
||||
store.add("flex-auth", "audit-core", "review 'quoted' $value", provenance="operator_input")
|
||||
store.add("railiance-platform", "audit-core", "second", provenance="worker_output")
|
||||
store.close()
|
||||
log = tmp_path / "messages.log"
|
||||
|
||||
|
|
@ -163,8 +69,8 @@ def test_inbox_filter_logs_and_acknowledges_successful_messages(tmp_path, monkey
|
|||
f"cat >> {shlex.quote(str(log))}",
|
||||
]) == 0
|
||||
assert log.read_text(encoding="utf-8") == (
|
||||
f"#flex-auth: review 'quoted' $value [{first_id}]\n"
|
||||
f"#railiance-platform: second [{second_id}]\n"
|
||||
"From:flex-auth/o: review 'quoted' $value\n"
|
||||
"From:railiance-platform: second\n"
|
||||
)
|
||||
assert main(["inbox", "--repo", "audit-core"]) == 0
|
||||
assert capsys.readouterr().out == ""
|
||||
|
|
@ -183,7 +89,6 @@ def test_failed_inbox_filter_leaves_current_and_later_messages_pending(tmp_path,
|
|||
assert main(["inbox", "--repo", "audit-core", "--json"]) == 0
|
||||
rows = [json.loads(line) for line in capsys.readouterr().out.splitlines()]
|
||||
assert [row["message_id"] for row in rows] == [first_id, second_id]
|
||||
assert all(row["state"] == "pending" for row in rows)
|
||||
|
||||
|
||||
def test_inbox_filter_rejects_non_pending_and_json_modes(tmp_path, monkeypatch, capsys):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue