Skip to content

feat(sessions): groupLabels: label sessions by owning group for dashboard badges - #39

Merged
khaliqgant merged 1 commit into
mainfrom
feat/group-labels
Nov 16, 2026
Merged

khaliqgant merged 1 commit into
mainfrom
feat/group-labels

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

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); description optional, <=200 chars, never sent to readers. Every key must be a defined group. Validated by parsePolicy, so both the loader and POST /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/metadata and .../catalog (the dashboard's detail header reads catalog through relay-control).
  • Unlabeled sessions get no key; other views are untouched; a single-session view with no label passes byte for byte. A relaygate key 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.json labels 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
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 character label and optional description (never sent to readers). Validated by the loader and POST /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 of GET /sessions/v1/sessions and the top-level object of .../metadata and .../catalog. Unlabeled sessions and other views pass unchanged; a relaygate key from Sessions is dropped so only relaygate can write it.

Written for commit e196af4. Summary will update on new commits.

View guided diff Turn on auto-fix

…th their group's label

An optional `groupLabels` map in the policy ({"22": {"label": "pit"}}) gives
groups a display label. Session lists, and the metadata and catalog views of one
session, then carry `relaygate: {gid, label}` for each readable session a
labeled group owns, so a dashboard can badge them. Labels grant nothing; no
defaults; unlabeled sessions and other views pass unchanged (single-session
views byte for byte); an upstream `relaygate` key is dropped. Validated by the
loader and POST /admin/v1/policy/validate (known gids, 1-24 plain characters).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T22:04:34.676608Z e196af4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

Policy can define display labels for groups. Readable session lists, metadata, and catalog responses add the owning group ID and label when configured. Policy validation and session tests cover label constraints, access checks, and response handling.

Changes: Group labels

Layer / File(s) Summary
Define and validate group labels
src/policy.ts, examples/policy.pit.json, test/admin.test.ts, test/sessions.test.ts, docs/contract.md
Policy accepts optional group labels for defined GIDs. Labels and optional descriptions have validation limits. The example and policy tests cover valid and invalid entries.
Annotate session lists
src/sessions.ts, test/sessions.test.ts, README.md
Readable sessions with a stored owner and configured label receive relaygate metadata containing the GID and label. Tests cover filtering, cursor preservation, and missing labels.
Annotate metadata and catalog reads
src/sessions.ts, test/sessions.test.ts, docs/contract.md
Successful metadata and catalog object responses receive local relaygate metadata when a label is available. Upstream relaygate data is removed. Other views and ineligible responses remain unchanged.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant SessionsRoute
  participant UpstreamSessionAPI
  participant groupLabel
  Client->>SessionsRoute: Request metadata or catalog
  SessionsRoute->>UpstreamSessionAPI: Read session view
  UpstreamSessionAPI-->>SessionsRoute: Return upstream response
  SessionsRoute->>groupLabel: Look up label for stored owner
  groupLabel-->>SessionsRoute: Return label or undefined
  SessionsRoute-->>Client: Return response with local relaygate metadata when available
Loading
Merge Risk: Minimal · up to e196a

This change adds optional group labels to session list, metadata and catalog responses. Labels are display-only, apply only to sessions the caller can already read, and leave unlabeled views unchanged. No merge-blocking risk is evident.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit reads the policy by moonlit light,
“Group labels,” I whisper, “fit just right.”
A session list gets gid and name,
Metadata and catalogs do the same.
Upstream labels hop away,
And tests keep every field at bay.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant