diff --git a/sandbox/agent-config/rules/orchestrator.md b/sandbox/agent-config/rules/orchestrator.md index 515efd38ec..9075c01093 100644 --- a/sandbox/agent-config/rules/orchestrator.md +++ b/sandbox/agent-config/rules/orchestrator.md @@ -41,7 +41,7 @@ BRC consensus + heartbeats: - `mcp__brc__propose` — Prefer this over `egg-orch consensus propose`. Producer broadcasts a proposal. - `mcp__brc__ack` — Prefer this over `egg-orch consensus ack`. Reviewer ACKs a proposal. - `mcp__brc__nack` — Prefer this over `egg-orch consensus nack`. Reviewer NACKs with a blocker reason. -- `mcp__brc__confirm` — Prefer this over `egg-orch consensus confirmed`. Producer confirms after all reviewers ACK. +- `mcp__brc__confirm` — Prefer this over `egg-orch consensus confirmed`. Producer confirms after all reviewers ACK. Returns `ok: True` only when the producer transitioned to CONFIRMED; on `ok: False` (status `pending_acks`) the transition was rejected — read `message` for the reason (e.g. `producer_not_fully_acked`, `global_zero_proposal`, `stale_acks`) and take corrective action before retrying. - `mcp__brc__wait_for_event` — Prefer this over `egg-orch message wait`. Block on typed BRC messages. - `mcp__brc__wait_loop` — Prefer this over `egg-orch message wait-loop`. Loop wait_for_event with retry on transient errors. - `mcp__brc__send_heartbeat` — Prefer this over `egg-orch message heartbeat`. Emit a structured HEARTBEAT to the dedicated `/heartbeat` endpoint. diff --git a/sandbox/egg_agent_tools/handlers/brc.py b/sandbox/egg_agent_tools/handlers/brc.py index e169dd55b3..927a56a842 100644 --- a/sandbox/egg_agent_tools/handlers/brc.py +++ b/sandbox/egg_agent_tools/handlers/brc.py @@ -227,6 +227,12 @@ def brc_confirm(req: dict[str, Any]) -> dict[str, Any]: pipeline_id, role: overrides. Response carries: + ok: True only when the producer transitioned to CONFIRMED. + False for "pending_acks" — the orchestrator received the + request but rejected the transition (e.g. + ``producer_not_fully_acked``, ``global_zero_proposal``, + ``stale_acks``). Inspect ``status`` and ``message`` to pick + corrective action. status: "confirmed"|"pending_acks" consensus_reached: bool (only for status=="confirmed") """ @@ -243,7 +249,7 @@ def brc_confirm(req: dict[str, Any]) -> dict[str, Any]: body = result.get("data", {}) pending = body.get("status") == "pending_acks" return { - "ok": True, + "ok": not pending, "role": role, "status": "pending_acks" if pending else "confirmed", "consensus_reached": bool(body.get("consensus_reached", False)), diff --git a/tests/sandbox/egg_agent_tools/test_cli_parity.py b/tests/sandbox/egg_agent_tools/test_cli_parity.py index 49ea5b4e03..b564faacf8 100644 --- a/tests/sandbox/egg_agent_tools/test_cli_parity.py +++ b/tests/sandbox/egg_agent_tools/test_cli_parity.py @@ -324,7 +324,7 @@ def test_pending_acks_exits_2(self): pre-refactor CLI so scripts can distinguish 'waiting' from 'confirmed').""" fake = { - "ok": True, + "ok": False, "status": "pending_acks", "consensus_reached": False, "role": "coder", diff --git a/tests/sandbox/egg_agent_tools/test_handlers_brc.py b/tests/sandbox/egg_agent_tools/test_handlers_brc.py index e81eacd485..b915627a91 100644 --- a/tests/sandbox/egg_agent_tools/test_handlers_brc.py +++ b/tests/sandbox/egg_agent_tools/test_handlers_brc.py @@ -199,6 +199,7 @@ def test_happy_confirmed(self): }, ): resp = brc.brc_confirm({"pipeline_id": "p", "role": "coder"}) + assert resp["ok"] is True assert resp["status"] == "confirmed" assert resp["consensus_reached"] is True @@ -211,6 +212,7 @@ def test_pending_acks(self): }, ): resp = brc.brc_confirm({"pipeline_id": "p", "role": "coder"}) + assert resp["ok"] is False assert resp["status"] == "pending_acks" assert resp["consensus_reached"] is False