diff --git a/.kiro/specs/controller-status/tasks.md b/.kiro/specs/controller-status/tasks.md index 6423e595..a3024f81 100644 --- a/.kiro/specs/controller-status/tasks.md +++ b/.kiro/specs/controller-status/tasks.md @@ -180,7 +180,7 @@ - _Boundary: ctrlstatus_fill_ - _Depends: 8.1_ -- [ ] 8.3 Render each configured controller's connection status in the `ctrlstatus` client command +- [x] 8.3 Render each configured controller's connection status in the `ctrlstatus` client command - Add a status-code-to-string renderer covering all four values plus a safe fallback for an unrecognized code (mirroring the existing responder-role renderer's convention), and extend the client command's existing per-controller line to print the rendered status alongside that controller's name and address. - Observable: piping `ctrlstatus` through the client prints each configured controller's connection status alongside its existing name:address line. - _Requirements: 13.1, 13.6_ diff --git a/src/harness/test.c b/src/harness/test.c index 9abbdcb7..0c20860d 100644 --- a/src/harness/test.c +++ b/src/harness/test.c @@ -3004,6 +3004,27 @@ static const char* ctrlstatus_role_str(uint8_t role) } } +/* Map a CtrlPeer.status raw value (controller-status Req 13 delta, + * design.md "Design Delta — Requirement 13", Locked Decision 2 / schema + * delta) to a display string. UNKNOWN==0, OK==1, CATCHING_UP==2, DEAD==3; + * anything else is reported verbatim so an unexpected code is never + * silently rendered as a known one (mirrors ctrlstatus_role_str above). */ +static const char* ctrlstatus_peer_status_str(uint8_t status) +{ + switch (status) { + case 0: + return "unknown"; + case 1: + return "ok"; + case 2: + return "catching-up"; + case 3: + return "dead"; + default: + return "unknown-status"; + } +} + /* `ctrlstatus` (controller-status task 4.1, Req 1.3/3.3/5.1/5.2/8.1/8.2/8.3, * design.md "cmd_ctrlstatus (test client) — State contract"). * @@ -3149,8 +3170,9 @@ int cmd_ctrlstatus(int argc, char* argv[]) continue; } - printf("\t%s\t%s:%u\n", NULLSTR(peer->name) ? "?" : peer->name, - NULLSTR(peer->host) ? "?" : peer->host, peer->port); + printf("\t%s\t%s:%u\t%s\n", NULLSTR(peer->name) ? "?" : peer->name, + NULLSTR(peer->host) ? "?" : peer->host, peer->port, + ctrlstatus_peer_status_str(peer->status)); } /* Config version + committed config version (Req 5.1) and the content