feat(sessions): groupLabels: label sessions by owning group for dashboard badges
What
- Policy: optional
groupLabels, keyed by gid in decimal:"groupLabels": {"22": {"label": "pit", "description": "..."}}. Label is 1-24 chars of letters, digits, space,.,_,-(starts with a letter or digit, no trailing space);descriptionoptional, <=200 chars, never sent to readers. Every key must be a defined group. Validated byparsePolicy, so both the loader andPOST /admin/v1/policy/validate(and Control-owned policies) enforce it. No defaults. The field is.optional(), so the policy hash of an existing policy is unchanged. - Sessions proxy: on reads that already passed the check, each session owned by a labeled group gets
relaygate: {"gid": <n>, "label": "<label>"}:- every item of
GET /sessions/v1/sessions(which relaygate already re-serialises after filtering); - the top-level object of
GET /sessions/v1/sessions/:id/metadataand.../catalog(the dashboard's detail header reads catalog through relay-control).
- every item of
- Unlabeled sessions get no key; other views are untouched; a single-session view with no label passes byte for byte. A
relaygatekey coming from Sessions is dropped so only relaygate can say it. The owner is never named. - Docs: contract "Group labels" section + route table; README note;
examples/policy.pit.jsonlabels gid 22.
Why
So the dashboard (relay-web, via relay-control) can show a group badge such as "pit" on sessions. Companion PRs follow in relay-control (pass the field through the catalog route) and relay-web (badge + filter).
Tests
npm run typecheck, npx vitest run (151 pass): list labeling only for readable labeled sessions, metadata/catalog labeling, byte-for-byte passthrough when unlabeled, forged upstream key dropped, no labels without groupLabels, validator cases (unknown gid, bad label charset/length, leading-zero key, unknown fields), admin validate route.
🤖 Generated with Claude Code
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Adds optional groupLabels to policies so the dashboard can badge sessions by their owning group, without changing any access decisions.
- New policy field
groupLabels, keyed by gid in decimal, with a 1-24 characterlabeland optionaldescription(never sent to readers). Validated by the loader andPOST /admin/v1/policy/validate; unknown gids, bad label characters, and unknown fields are rejected. - On reads that pass the check, relaygate adds
relaygate: {"gid", "label"}to each session a labeled group owns: every item ofGET /sessions/v1/sessionsand the top-level object of.../metadataand.../catalog. Unlabeled sessions and other views pass unchanged; arelaygatekey from Sessions is dropped so only relaygate can write it.