feat(state): carry channel lifecycle from the Messaging Service to the dashboard

archie-core-8cda.6.8's carrier. The service now records channel lifecycle and has
nowhere to put it: /api/channels answered with nothing because
webui.Server.Channels had no production source, and reload answered 501 for the
same reason. This adds the surface the register decided on, following the split
archie-core-ymut established for config snapshots -- a pair of administrative RPCs
whose writer is one process and whose reader is the UI -- and wires both ends.

Wire and store: PutChannelStatus / ListChannelStatus, with ChannelStatus carrying
id, name, state, detail, configured, reload_supported and observed_at. The store
holds one row per channel and replaces the reported set, so a channel the reporter
no longer mentions is deleted rather than left standing as a stale "running"; an
empty report clears the table, because hosting no channels is a fact worth
reporting. A row without an id is refused: it could never be replaced or removed
by a later report.

Writer: the service publishes on every lifecycle transition through a coalescing
signal -- a burst of transitions is one write, since a reader only wants the latest
state of every channel -- plus a start-up report and a final report after shutdown,
so a stopped service leaves the store honest. A failed write is logged and retried
on the next signal; the dashboard losing channel state is worth a warning and never
worth failing a channel start over.

Reader: webui.Server.Channels becomes a source rather than a concrete manager, and
webui.RemoteChannelStatus reads the store the way RemoteConfigView reads the config
snapshot. A store it cannot reach reports nothing rather than a stale "running",
and a state the reader does not recognise is carried through rather than dropped.

The contract's own index gains the group in the same change that adds the RPCs --
a surface the grouped table does not list is one nobody finds -- and the count moves
to 51. The register records why the surface is the State Store rather than a
resource kind, and why reload gets its own surface rather than a field here: reading
status must not be able to retrigger an action, a transient request is not
distinguishable from state once anything polls it, and it would invert the
writer/reader relationship the precedent establishes.

Verified: task check exit 0. New coverage: the store's replace-the-set semantics
and its refusal of an id-less row, the reader's mapping including an unknown state,
and the publisher's start-up, transition and final reports.
This commit is contained in:
sam committed 2026-09-22 08:04:44 +10:00
1 parent fb265f2ad0
commit d6f526ce4f
23 files changed
+1445 -406

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -53,6 +53,8 @@ const (
StateStoreService_TokensByDay_FullMethodName = "/state.v1.StateStoreService/TokensByDay"
StateStoreService_PutConfigSnapshot_FullMethodName = "/state.v1.StateStoreService/PutConfigSnapshot"
StateStoreService_GetConfigSnapshot_FullMethodName = "/state.v1.StateStoreService/GetConfigSnapshot"
StateStoreService_PutChannelStatus_FullMethodName = "/state.v1.StateStoreService/PutChannelStatus"
StateStoreService_ListChannelStatus_FullMethodName = "/state.v1.StateStoreService/ListChannelStatus"
StateStoreService_PutApplyStatus_FullMethodName = "/state.v1.StateStoreService/PutApplyStatus"
StateStoreService_ListApplyStatus_FullMethodName = "/state.v1.StateStoreService/ListApplyStatus"
StateStoreService_ReadTaskLog_FullMethodName = "/state.v1.StateStoreService/ReadTaskLog"
@@ -137,6 +139,14 @@ type StateStoreServiceClient interface {
// configuration page").
PutConfigSnapshot(ctx context.Context, in *PutConfigSnapshotRequest, opts ...grpc.CallOption) (*PutConfigSnapshotResponse, error)
GetConfigSnapshot(ctx context.Context, in *GetConfigSnapshotRequest, opts ...grpc.CallOption) (*GetConfigSnapshotResponse, error)
// Channel status is what the process HOSTING the channels observes about them:
// one row per channel, written by the Messaging Service and read by the UI
// process. Administrative like the config snapshot, and for the same reason --
// a task-scoped grant reaches neither, so authorizesTaskScopedCall admits only
// the administrative token. It is runtime state rather than a settings
// document, which is why it is not a ControlPlaneService resource kind.
PutChannelStatus(ctx context.Context, in *PutChannelStatusRequest, opts ...grpc.CallOption) (*PutChannelStatusResponse, error)
ListChannelStatus(ctx context.Context, in *ListChannelStatusRequest, opts ...grpc.CallOption) (*ListChannelStatusResponse, error)
// Apply status: which version of a control-plane resource each process is
// running, and why it could not. Every process that applies a resource
// publishes; the UI process reads (docs/prds/control-plane-apply-status.md).
@@ -545,6 +555,26 @@ func (c *stateStoreServiceClient) GetConfigSnapshot(ctx context.Context, in *Get
return out, nil
}
func (c *stateStoreServiceClient) PutChannelStatus(ctx context.Context, in *PutChannelStatusRequest, opts ...grpc.CallOption) (*PutChannelStatusResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PutChannelStatusResponse)
err := c.cc.Invoke(ctx, StateStoreService_PutChannelStatus_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *stateStoreServiceClient) ListChannelStatus(ctx context.Context, in *ListChannelStatusRequest, opts ...grpc.CallOption) (*ListChannelStatusResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListChannelStatusResponse)
err := c.cc.Invoke(ctx, StateStoreService_ListChannelStatus_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *stateStoreServiceClient) PutApplyStatus(ctx context.Context, in *PutApplyStatusRequest, opts ...grpc.CallOption) (*PutApplyStatusResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PutApplyStatusResponse)
@@ -881,6 +911,14 @@ type StateStoreServiceServer interface {
// configuration page").
PutConfigSnapshot(context.Context, *PutConfigSnapshotRequest) (*PutConfigSnapshotResponse, error)
GetConfigSnapshot(context.Context, *GetConfigSnapshotRequest) (*GetConfigSnapshotResponse, error)
// Channel status is what the process HOSTING the channels observes about them:
// one row per channel, written by the Messaging Service and read by the UI
// process. Administrative like the config snapshot, and for the same reason --
// a task-scoped grant reaches neither, so authorizesTaskScopedCall admits only
// the administrative token. It is runtime state rather than a settings
// document, which is why it is not a ControlPlaneService resource kind.
PutChannelStatus(context.Context, *PutChannelStatusRequest) (*PutChannelStatusResponse, error)
ListChannelStatus(context.Context, *ListChannelStatusRequest) (*ListChannelStatusResponse, error)
// Apply status: which version of a control-plane resource each process is
// running, and why it could not. Every process that applies a resource
// publishes; the UI process reads (docs/prds/control-plane-apply-status.md).
@@ -1051,6 +1089,12 @@ func (UnimplementedStateStoreServiceServer) PutConfigSnapshot(context.Context, *
func (UnimplementedStateStoreServiceServer) GetConfigSnapshot(context.Context, *GetConfigSnapshotRequest) (*GetConfigSnapshotResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetConfigSnapshot not implemented")
}
func (UnimplementedStateStoreServiceServer) PutChannelStatus(context.Context, *PutChannelStatusRequest) (*PutChannelStatusResponse, error) {
return nil, status.Error(codes.Unimplemented, "method PutChannelStatus not implemented")
}
func (UnimplementedStateStoreServiceServer) ListChannelStatus(context.Context, *ListChannelStatusRequest) (*ListChannelStatusResponse, error) {
return nil, status.Error(codes.Unimplemented, "method ListChannelStatus not implemented")
}
func (UnimplementedStateStoreServiceServer) PutApplyStatus(context.Context, *PutApplyStatusRequest) (*PutApplyStatusResponse, error) {
return nil, status.Error(codes.Unimplemented, "method PutApplyStatus not implemented")
}
@@ -1759,6 +1803,42 @@ func _StateStoreService_GetConfigSnapshot_Handler(srv interface{}, ctx context.C
return interceptor(ctx, in, info, handler)
}
func _StateStoreService_PutChannelStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PutChannelStatusRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StateStoreServiceServer).PutChannelStatus(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: StateStoreService_PutChannelStatus_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StateStoreServiceServer).PutChannelStatus(ctx, req.(*PutChannelStatusRequest))
}
return interceptor(ctx, in, info, handler)
}
func _StateStoreService_ListChannelStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListChannelStatusRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StateStoreServiceServer).ListChannelStatus(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: StateStoreService_ListChannelStatus_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StateStoreServiceServer).ListChannelStatus(ctx, req.(*ListChannelStatusRequest))
}
return interceptor(ctx, in, info, handler)
}
func _StateStoreService_PutApplyStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PutApplyStatusRequest)
if err := dec(in); err != nil {
@@ -2331,6 +2411,14 @@ var StateStoreService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetConfigSnapshot",
Handler: _StateStoreService_GetConfigSnapshot_Handler,
},
{
MethodName: "PutChannelStatus",
Handler: _StateStoreService_PutChannelStatus_Handler,
},
{
MethodName: "ListChannelStatus",
Handler: _StateStoreService_ListChannelStatus_Handler,
},
{
MethodName: "PutApplyStatus",
Handler: _StateStoreService_PutApplyStatus_Handler,