Compare commits

...

1 Commits

Author SHA1 Message Date
fullstack-engineer f1370ea86b test(workspace): add push-mode queue coverage for a2a_response.py (closes #308)
Secret scan / Scan diff for credential-shaped strings (pull_request) Failing after 1s
sop-tier-check / tier-check (pull_request) Successful in 41s
audit-force-merge / audit (pull_request) Has been skipped
Add 4 fixtures + 12 tests covering the push-mode at-capacity envelope
path in a2a_response.parse() (lines 189-197).

Push-mode envelopes ({"queued": true, ...}) are returned by the
platform when a push-mode workspace (has public URL) is at capacity.
The proxy queues the request and returns {"queued": true, "message":
"...", "queue_id": "..."}. This path was added in PR #278 but never
tested — lines 182-197 had zero fixture coverage.

Fixtures added:
- push_queued_full     {"queued": true, method: "message/send", queue_id: "q-1"}
- push_queued_notify   {"queued": true, method: "notify", queue_id: "q-2"}
- push_queued_no_method  {"queued": true, queue_id: "q-3"}  (falls back to "message/send")
- push_queued_no_queue_id {"queued": true, method: "message/send"}

Tests cover: full envelope, notify method, method fallback, queue_id
absence, push vs poll distinction, INFO logging, and adversarial inputs
where non-True truthy values (queued: 1, queued: "yes") route to
Malformed rather than Queued.

Also updates test_every_fixture_classifies_to_expected_variant to
enumerate the new fixtures.
2026-05-10 16:17:29 +00:00
+83
View File
@@ -115,12 +115,91 @@ _FIXTURES = {
"malformed_delivery_mode_no_status": {
"delivery_mode": "poll",
},
# --- Push-mode queue envelopes ---
# Returned when a push-mode workspace (has public URL) is at capacity.
# The platform queues the request and returns {"queued": true, ...}.
# Distinguishable from poll-mode by data.get("queued") is True alone.
"push_queued_full": {
"queued": True,
"method": "message/send",
"queue_id": "q-1",
},
"push_queued_notify": {
"queued": True,
"method": "notify",
"queue_id": "q-2",
},
"push_queued_no_method": {
# method absent — parser must not raise; falls back to "message/send".
"queued": True,
"queue_id": "q-3",
},
"push_queued_no_queue_id": {
# queue_id absent — parser must not raise; logs queue_id="?".
"queued": True,
"method": "message/send",
},
}
# ============== Variant-by-variant coverage ==============
class TestPushQueuedVariant:
"""``parse()`` returns ``Queued`` for push-mode at-capacity envelope
(lines 189-197 of a2a_response.py): ``{"queued": true, ...}``.
The push-mode path was added in PR #278 alongside the a2a_proxy.go
push-at-capacity branch. Lines 182-197 were not covered until this test.
"""
def test_full_envelope_message_send(self):
v = a2a_response.parse(_FIXTURES["push_queued_full"])
assert isinstance(v, a2a_response.Queued)
assert v.method == "message/send"
assert v.delivery_mode == "poll"
def test_envelope_with_notify(self):
v = a2a_response.parse(_FIXTURES["push_queued_notify"])
assert isinstance(v, a2a_response.Queued)
assert v.method == "notify"
def test_envelope_missing_method_falls_back_to_message_send(self):
# a2a_response.py:191 — method_raw is None, defaults to "message/send".
v = a2a_response.parse(_FIXTURES["push_queued_no_method"])
assert isinstance(v, a2a_response.Queued)
assert v.method == "message/send"
def test_envelope_missing_queue_id_still_queued(self):
# queue_id is purely informational; its absence must not break parsing.
v = a2a_response.parse(_FIXTURES["push_queued_no_queue_id"])
assert isinstance(v, a2a_response.Queued)
assert v.method == "message/send"
def test_push_queued_is_distinct_from_poll_queued(self):
# Same Queued variant, but from different wire shapes. Confirm both paths.
push_v = a2a_response.parse(_FIXTURES["push_queued_full"])
poll_v = a2a_response.parse(_FIXTURES["poll_queued_full"])
assert isinstance(push_v, a2a_response.Queued)
assert isinstance(poll_v, a2a_response.Queued)
assert push_v.method == poll_v.method == "message/send"
def test_logs_info_on_push_queued(self, caplog):
with caplog.at_level(logging.INFO, logger="a2a_response"):
a2a_response.parse(_FIXTURES["push_queued_full"])
assert any("queued for busy push-mode peer" in r.message for r in caplog.records)
assert any("queue_id=q-1" in r.message for r in caplog.records)
def test_queued_true_is_distinct_from_queued_truthy(self):
# "queued": 1 / "queued": "yes" — these are truthy but not True,
# and must NOT trigger the push-mode path. Route to Malformed instead.
v = a2a_response.parse({"queued": 1})
assert isinstance(v, a2a_response.Malformed)
v = a2a_response.parse({"queued": "yes"})
assert isinstance(v, a2a_response.Malformed)
class TestQueuedVariant:
"""``parse()`` recognizes the workspace-server poll-mode short-circuit
envelope (a2a_proxy.go:402-406) and returns ``Queued``."""
@@ -436,6 +515,10 @@ class TestRegressionGate:
"poll_queued_full": a2a_response.Queued,
"poll_queued_notify": a2a_response.Queued,
"poll_queued_no_method": a2a_response.Queued,
"push_queued_full": a2a_response.Queued,
"push_queued_notify": a2a_response.Queued,
"push_queued_no_method": a2a_response.Queued,
"push_queued_no_queue_id": a2a_response.Queued,
"malformed_empty_dict": a2a_response.Malformed,
"malformed_unexpected_keys": a2a_response.Malformed,
"malformed_status_queued_no_delivery_mode": a2a_response.Malformed,