diff --git a/site/src/content/guides-grpcprocctl.tsx b/site/src/content/guides-grpcprocctl.tsx
index 88bc26e..11fbc8c 100644
--- a/site/src/content/guides-grpcprocctl.tsx
+++ b/site/src/content/guides-grpcprocctl.tsx
@@ -285,6 +285,14 @@ orders order-17 charging stuck 5 1 2026-10-05T11:49:2
--node, --prefix, --limit.
>
],
+ [
+ groups [group],
+ <>
+ A process groups scope's groups, with their members on every node and
+ on this one, and its other nodes and their states; or one group's members: --node,{' '}
+ --scope, --prefix, --limit.
+ >
+ ],
[
watch,
<>
diff --git a/site/src/content/guides-mcp.tsx b/site/src/content/guides-mcp.tsx
index 3b97ad4..f02a5a4 100644
--- a/site/src/content/guides-mcp.tsx
+++ b/site/src/content/guides-mcp.tsx
@@ -60,7 +60,9 @@ export const guidesMcp: Doc = {
[cron_jobs, 'Cron processes and their jobs, on a node or all of them.'],
[saga_runs, 'Saga runs by saga and status, a page at a time.'],
[saga_run, 'One saga run: the error that stopped it, its waiting signals, and its data when the engine shows it.'],
- [global_names, 'Who holds a global name, or every name with a prefix, such as room:.']
+ [global_names, 'Who holds a global name, or every name with a prefix, such as room:.'],
+ [process_groups, 'A grpcproc/groups scope’s groups and its other nodes, as one node’s copy has them.'],
+ [group_members, 'One grpcproc/groups group’s members on every node, by pid.']
]}
/>
diff --git a/site/src/content/guides-web.tsx b/site/src/content/guides-web.tsx
index 2aca017..09ab211 100644
--- a/site/src/content/guides-web.tsx
+++ b/site/src/content/guides-web.tsx
@@ -1,6 +1,7 @@
import { Code } from '../code.tsx';
import { Screenshot } from '../components/Figure.tsx';
-import { A, C, Table } from '../components/prose.tsx';
+import { A, C, Ext, Table } from '../components/prose.tsx';
+import { file } from '../config.ts';
import type { Doc } from './types.ts';
export const guidesWeb: Doc = {
@@ -59,6 +60,14 @@ grpcprocctl --plaintext --addr 10.0.0.5:9000 web # http://localhost:9911`}global name.
>
],
+ [
+ 'Groups',
+ <>
+ The process groups scopes the node runs, as its copy has them: each
+ group's members on every node and on this one, a group's members once picked, and the
+ other nodes of the scope with their states.
+ >
+ ],
['Supervision', 'Each process under the one that started it, coloured by state, mailbox or activity.'],
['Events', 'Spawns, exits with their reasons, links and dead letters, streamed as they happen.'],
[
diff --git a/tools/README.md b/tools/README.md
index 0d7ca5d..b43a045 100644
--- a/tools/README.md
+++ b/tools/README.md
@@ -72,6 +72,7 @@ monitors: 2
| `ps` | processes: `--node`, `--name`, `--label`, `--state`, `--min-mailbox`, `--sort pid\|mailbox\|received\|sent\|busy`, `--limit` |
| `inspect ` | one process, with what it says about itself: `--node`, `--wait` |
| `names [name]` | [global names](https://floatdrop.github.io/grpcproc/concepts/addressing/#global): who holds one, or a list: `--node`, `--prefix`, `--limit` |
+| `groups [group]` | a [grpcproc/groups](../groups/README.md) scope's groups, with their members on every node and on this one, and the scope's other nodes and their states; or one group's members: `--node`, `--scope`, `--prefix`, `--limit` |
| `watch` | stream spawns, exits, links, dead letters: `--node`, `--kind`, `--count` |
| `exit [reason]` | ask a process to exit |
| `loglevel ` | change one process's log level |
@@ -94,7 +95,7 @@ what its MCP server reports.
A pid is written as grpcproc prints it, ``; a name is
looked up on `--node`, by default the node serving the Inspector.
-`--json` before `node`, `nodes`, `ps`, `inspect`, `names`, `watch`, `leader`, `cron` or `saga` prints the same
+`--json` before `node`, `nodes`, `ps`, `inspect`, `names`, `groups`, `watch`, `leader`, `cron` or `saga` prints the same
data as JSON: one indented value, or for `watch` one compact event per line,
so `grpcprocctl --json watch | jq` sees events as they happen. The objects
are those the MCP tools return, which wrap lists in an object of their own.
@@ -218,6 +219,10 @@ through the same Inspector and refreshes every second:
and how electors are named, asking 32 nodes at a time; a node that
cannot be asked is listed with why. A cron process spawned with a label
of its own is shown by `grpcprocctl cron --node`, not here.
+- **Groups**: the grpcproc/groups scopes the node runs, as its copy has
+ them: each group's members on every node and on this one, by prefix, a
+ group's members once picked, and the other nodes of the scope with their
+ states (synced, syncing, absent, unreachable).
- **Sagas**: the grpcproc/saga engines reachable from here and the sagas
each runs, and a saga's runs a page at a time, by status, as
`grpcprocctl saga runs` lists them. A run opens beside them, as `saga
@@ -243,7 +248,7 @@ so a page elsewhere cannot reach it through the browser; a change must come
from the page itself. On any other address, put it behind something that
authenticates. The API behind the page returns the objects `--json`
prints, `/api/nodes` with when the walk ended: `/api/nodes`, `/api/node`, `/api/processes`, `/api/process`,
-`/api/crons`, `/api/elections`, `/api/sagas`, `/api/saga/runs`,
+`/api/names`, `/api/groups`, `/api/group`, `/api/crons`, `/api/elections`, `/api/sagas`, `/api/saga/runs`,
`/api/saga/run`, and `/api/events` as server-sent events.
## For an AI agent
@@ -267,6 +272,7 @@ or a busy process means) and offers:
| `saga_runs` | saga runs by saga and status, a page at a time |
| `saga_run` | one saga run: its state, error and waiting signals, and its data when the engine shows it |
| `global_names` | who holds a global name, or every name with a prefix |
+| `process_groups`, `group_members` | a groups scope's groups and other nodes, as one node's copy has them; one group's members |
| `exit_process`, `set_log_level`, `move_leader`, `cordon_node`, `uncordon_node`, `enable_cron_job`, `disable_cron_job`, `remove_cron_job`, `resume_saga_run` | only with `--allow-writes` |
So "orders are slow since the deploy" becomes: list processes by mailbox,
diff --git a/tools/cli/cli.go b/tools/cli/cli.go
index 92bbb06..3422d34 100644
--- a/tools/cli/cli.go
+++ b/tools/cli/cli.go
@@ -84,6 +84,7 @@ Commands:
ps processes (--node, --name, --label, --state, --min-mailbox, --sort, --limit)
inspect one process, and what it says about itself (--node, --wait)
names [name] global names: who holds one, or a list (--node, --prefix, --limit)
+ groups [group] grpcproc/groups: a scope's groups and peers, or one group's members (--node, --scope, --prefix, --limit)
watch stream events (--node, --kind, --count)
exit [reason] ask a process to exit (--node)
loglevel set a process's log level (--node)
@@ -252,7 +253,7 @@ func init() {
commands = map[string]command{
"node": cmdNode, "nodes": cmdNodes, "ps": cmdPS, "inspect": cmdInspect, "watch": cmdWatch,
"exit": cmdExit, "loglevel": cmdLogLevel, "dot": cmdDot, "mcp": cmdMCP, "leader": cmdLeader, "cron": cmdCron, "saga": cmdSaga,
- "web": cmdWeb, "names": cmdNames,
+ "web": cmdWeb, "names": cmdNames, "groups": cmdGroups,
}
}
@@ -428,6 +429,70 @@ func cmdNames(ctx context.Context, a *app, args []string) error {
return a.table("NAME\tPID", rows)
}
+func cmdGroups(ctx context.Context, a *app, args []string) error {
+ var node, scope, prefix string
+ var limit int
+ fs, err := a.flags("groups", args, func(fs *flag.FlagSet) {
+ fs.StringVar(&node, "node", "", "node whose copy of the groups to read, by default the one serving the Inspector")
+ fs.StringVar(&scope, "scope", "", "scope to read, by default the one named default, or the node's first")
+ fs.StringVar(&prefix, "prefix", "", "only groups whose names start with this")
+ fs.IntVar(&limit, "limit", 0, "show at most this many groups, or members (0: 1000)")
+ })
+ if err != nil {
+ return err
+ }
+ ctx, cancel := a.request(ctx)
+ defer cancel()
+ switch fs.NArg() {
+ case 0:
+ case 1:
+ m, err := a.client.GroupMembers(ctx, node, scope, fs.Arg(0), limit)
+ if err != nil {
+ return err
+ }
+ if a.json {
+ return a.printJSON(m)
+ }
+ rows := make([][]string, 0, len(m.Members))
+ for _, pid := range m.Members {
+ rows = append(rows, []string{pid})
+ }
+ return a.omitted(a.table("PID", rows), m.Omitted, "members")
+ default:
+ return usageError{"want at most one group"}
+ }
+ v, err := a.client.Groups(ctx, node, scope, prefix, limit)
+ if err != nil {
+ return err
+ }
+ if a.json {
+ return a.printJSON(v)
+ }
+ fmt.Fprintf(a.env.Stdout, "scope %s on %s (it runs %s)\n\n", v.Scope, v.Node, strings.Join(v.Scopes, ", "))
+ rows := make([][]string, 0, len(v.Groups))
+ for _, g := range v.Groups {
+ rows = append(rows, []string{g.Name, strconv.Itoa(g.Members), strconv.Itoa(g.Local), strconv.Itoa(g.Nodes)})
+ }
+ err = a.omitted(a.table("GROUP\tMEMBERS\tLOCAL\tNODES", rows), v.Omitted, "groups")
+ if err == nil {
+ rows = rows[:0]
+ for _, p := range v.Peers {
+ rows = append(rows, []string{p.Node, p.State, strconv.Itoa(p.Members), p.Scope})
+ }
+ fmt.Fprintln(a.env.Stdout)
+ err = a.table("PEER\tSTATE\tMEMBERS\tSCOPE", rows)
+ }
+ return err
+}
+
+// omitted says how many rows a limit left out, after a table that printed.
+func (a *app) omitted(err error, n int, what string) error {
+ if err == nil && n > 0 {
+ fmt.Fprintf(a.env.Stdout, "… %d more %s past --limit\n", n, what)
+ }
+ return err
+}
+
func cmdPS(ctx context.Context, a *app, args []string) error {
var node, sortBy string
var limit int
diff --git a/tools/cli/cli_test.go b/tools/cli/cli_test.go
index 93bd350..2e43def 100644
--- a/tools/cli/cli_test.go
+++ b/tools/cli/cli_test.go
@@ -301,7 +301,7 @@ func TestMCPCommand(t *testing.T) {
t.Fatalf("mcp reports version %q", v)
}
tools, err := session.ListTools(t.Context(), nil)
- if err != nil || len(tools.Tools) != 19 {
+ if err != nil || len(tools.Tools) != 21 {
t.Fatalf("%v %v", tools, err)
}
_ = session.Close()
diff --git a/tools/cli/groups_test.go b/tools/cli/groups_test.go
new file mode 100644
index 0000000..3f9eb77
--- /dev/null
+++ b/tools/cli/groups_test.go
@@ -0,0 +1,37 @@
+package cli_test
+
+import (
+ "strings"
+ "testing"
+
+ "github.com/floatdrop/grpcproc/tools/internal/testcluster"
+)
+
+func TestGroups(t *testing.T) {
+ f := testcluster.Start(t, "c")
+ f.Groups(t)
+ has(t, ok(t, run(t, f, "groups")),
+ "scope default on a (it runs broken, default, rooms)",
+ "GROUP MEMBERS LOCAL NODES", "chat 2 1 2", "echo 1 0 1",
+ "PEER STATE MEMBERS SCOPE", "b synced 2 set({ scope: e.target.value, group: '' }) });
+ const prefix = h('input', { type: 'search', placeholder: 'prefix, such as room:', value: p.prefix || '', oninput: debounce((e) => set({ prefix: e.target.value }), 300) });
+ const list = h('div');
+ const members = h('div');
+ const peers = h('div');
+ let scopes = '';
+ const nodeLink = (n) => h('a', { href: href('node', { node: n }), onclick: (e) => e.stopPropagation() }, n);
+ const page = {
+ every: 2000,
+ el: h(
+ 'div',
+ null,
+ head('Process groups', `The grpcproc/groups scopes ${node} runs, as its copy has them: each group's members on every node, and the other nodes of the scope. Pick a group to see its members.`),
+ b.el,
+ h('div', { class: 'scope' }, h('label', null, 'scope', select(scope)), h('label', null, 'groups starting with', prefix)),
+ list,
+ members,
+ h('h2', null, 'Nodes of the scope'),
+ peers,
+ ),
+ banner: b.set,
+ update(np) {
+ const what = (x) => [x.scope || '', x.prefix || '', x.group || ''].join('\n');
+ const refetch = what(np) !== what(p);
+ p = np;
+ if (refetch) run(page);
+ },
+ async tick(stale) {
+ const q = { node, scope: p.scope || '' };
+ const [v, m] = await Promise.all([api('/api/groups', { ...q, prefix: p.prefix || '' }), p.group ? api('/api/group', { ...q, group: p.group }) : null]);
+ if (stale()) return;
+ // Options are made again only when they change, so an open select stays open.
+ if (JSON.stringify(v.scopes) !== scopes) {
+ scopes = JSON.stringify(v.scopes);
+ scope.replaceChildren(...v.scopes.map((s) => h('option', { value: s }, s)));
+ }
+ scope.value = v.scope;
+ list.replaceChildren(
+ table(
+ [
+ { t: 'Group', get: (g) => h('b', null, g.name) },
+ { t: 'Members', num: true, get: (g) => fmtInt(g.members) },
+ { t: `On ${node}`, num: true, get: (g) => fmtInt(g.local) },
+ { t: 'Nodes', num: true, get: (g) => fmtInt(g.nodes) },
+ ],
+ v.groups,
+ {
+ onRow: (g) => set({ group: g.name === p.group ? '' : g.name }, false),
+ rowClass: (g) => g.name === p.group && 'sel',
+ empty: p.prefix ? `No group of ${v.scope} starts with ${p.prefix}.` : `No process is in a group of ${v.scope}.`,
+ },
+ ),
+ v.omitted ? h('p', { class: 'muted' }, `${fmtInt(v.omitted)} more groups: narrow them with a prefix.`) : '',
+ );
+ members.replaceChildren(
+ ...(m
+ ? [
+ h('h2', null, `Members of ${m.group}`),
+ table(
+ [
+ { t: 'Process', get: (pid) => pidLink(pid) },
+ { t: 'Node', get: (pid) => nodeLink(nodeOf(pid)) },
+ ],
+ m.members,
+ { empty: `${m.group} has no members.` },
+ ),
+ m.omitted ? h('p', { class: 'muted' }, `${fmtInt(m.omitted)} more members.`) : '',
+ ]
+ : []),
+ );
+ peers.replaceChildren(
+ table(
+ [
+ { t: 'Node', get: (x) => nodeLink(x.node) },
+ { t: 'State', get: (x) => pill(x.state) },
+ { t: 'Members', num: true, get: (x) => fmtInt(x.members) },
+ { t: 'Scope', get: (x) => pidLink(x.scope) },
+ ],
+ v.peers,
+ { rowClass: (x) => x.state === 'unreachable' && 'backlog', empty: `${v.scope} on ${node} knows no other node.` },
+ ),
+ );
+ },
+ };
+ return page;
+}
+
function electionsPage() {
const b = banner();
const list = h('div');
@@ -1742,6 +1833,7 @@ const pages = {
node: { make: nodePage, node: true, title: 'Node' },
processes: { make: processesPage, node: true, title: 'Processes' },
names: { make: namesPage, node: true, title: 'Global names' },
+ groups: { make: groupsPage, node: true, title: 'Process groups' },
tree: { make: treePage, node: true, title: 'Supervision' },
events: { make: eventsPage, node: true, title: 'Events' },
cron: { make: cronPage, title: 'Cron' },
diff --git a/tools/web/ui/index.html b/tools/web/ui/index.html
index f4104b3..04df956 100644
--- a/tools/web/ui/index.html
+++ b/tools/web/ui/index.html
@@ -44,6 +44,7 @@
Modules
+ - Groups
- Cron
- Elections
- Sagas
diff --git a/tools/web/web.go b/tools/web/web.go
index 528659e..d1c40f9 100644
--- a/tools/web/web.go
+++ b/tools/web/web.go
@@ -87,6 +87,14 @@ func New(c *client.Client, o Options) http.Handler {
limit, _ := strconv.Atoi(q.Get("limit")) // 0, the node's default, unless a number
return s.c.Names(ctx, q.Get("node"), q.Get("prefix"), limit)
}))
+ mux.HandleFunc("GET /api/groups", s.read(func(ctx context.Context, q url.Values) (any, error) {
+ limit, _ := strconv.Atoi(q.Get("limit")) // 0, the default, unless a number
+ return s.c.Groups(ctx, q.Get("node"), q.Get("scope"), q.Get("prefix"), limit)
+ }))
+ mux.HandleFunc("GET /api/group", s.read(func(ctx context.Context, q url.Values) (any, error) {
+ limit, _ := strconv.Atoi(q.Get("limit"))
+ return s.c.GroupMembers(ctx, q.Get("node"), q.Get("scope"), q.Get("group"), limit)
+ }))
mux.HandleFunc("GET /api/crons", s.across(
func(ctx context.Context, node string) (any, error) { return s.c.Crons(ctx, node) },
func(ctx context.Context, nodes []client.NodeView) (any, error) {