Skip to content

Commit 646a40e

Browse files
dwinter3claude
andauthored
fix(consults): log positive proof when a cross-Enterprise forward fires (8th-layer#36) (#261)
The L2-to-L2 consult forward path only logged on failure (non-2xx peer response or transport error). A successful forward was silent — so when a peer reply never arrived, there was no way to tell a dropped forward from a slow/absent peer-side auto-responder. Add an INFO log on the success branch of all three forward paths (_forward_request, _forward_message, _x_enterprise_forward_request), recording peer l2_id, thread_id, and peer status. Source-side proof the forward left this L2, separate from any peer-side delay. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 3a1295d commit 646a40e

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

server/backend/src/cq_server/consults.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ def _forward_request(target: dict[str, Any], payload: dict[str, Any]) -> None:
249249
r.text[:200],
250250
)
251251
raise HTTPException(status_code=502, detail="peer unreachable")
252+
# agent#36 — positive proof the cross-Enterprise forward fired.
253+
# Without this, a missing peer reply is indistinguishable from a
254+
# forward that never left this L2; the source-side log disambiguates.
255+
logger.info(
256+
"consults forward-request: peer=%s thread=%s status=%s — cross-Enterprise forward delivered",
257+
target["l2_id"],
258+
payload.get("thread_id", "?"),
259+
r.status_code,
260+
)
252261
except httpx.RequestError as e:
253262
logger.warning(
254263
"consults forward-request: peer=%s transport_error=%r",
@@ -285,6 +294,13 @@ def _forward_message(target: dict[str, Any], payload: dict[str, Any]) -> None:
285294
r.text[:200],
286295
)
287296
raise HTTPException(status_code=502, detail="peer unreachable")
297+
# agent#36 — positive proof the cross-Enterprise forward fired.
298+
logger.info(
299+
"consults forward-message: peer=%s thread=%s status=%s — cross-Enterprise forward delivered",
300+
target["l2_id"],
301+
payload.get("thread_id", "?"),
302+
r.status_code,
303+
)
288304
except httpx.RequestError as e:
289305
logger.warning(
290306
"consults forward-message: peer=%s transport_error=%r",
@@ -393,6 +409,17 @@ def _x_enterprise_forward_request(
393409
f"on x-enterprise-forward-request: {r.text[:200]}"
394410
),
395411
)
412+
# agent#36 — positive proof the cross-Enterprise forward fired.
413+
# A missing peer reply downstream is then attributable to the peer
414+
# side (no auto-reply handler, slow cron), not a forward that never
415+
# left this L2.
416+
logger.info(
417+
"consults x-enterprise-forward-request: peer=%s thread=%s status=%s "
418+
"— cross-Enterprise forward delivered",
419+
target_endpoint["l2_id"],
420+
payload.get("thread_id", "?"),
421+
r.status_code,
422+
)
396423
except httpx.RequestError as e:
397424
raise HTTPException(
398425
status_code=502,

0 commit comments

Comments
 (0)