feat(controller-status): render per-controller connection status in ctrlstatus command (task 8.3)

Adds ctrlstatus_peer_status_str (mirrors ctrlstatus_role_str's
convention: 0=unknown/1=ok/2=catching-up/3=dead, safe default fallback
for any other code) and extends cmd_ctrlstatus's per-controller print
line to render it alongside each configured controller's existing
name:address, completing the CtrlPeer.status wire field added in task
8.1 and sourced in task 8.2.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
Rongsong Shen 2026-09-16 15:36:02 +00:00
parent ab5dd91537
commit 64b18d5c34
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
2 changed files with 25 additions and 3 deletions

View file

@ -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_

View file

@ -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