Skip to content

refactor: normalize workspace agent session metadata - #28124

Open
EhabY wants to merge 1 commit into
mainfrom
refactor/normalize-agent-session-metadata
Open

refactor: normalize workspace agent session metadata#28124
EhabY wants to merge 1 commit into
mainfrom
refactor/normalize-agent-session-metadata

Conversation

@EhabY

@EhabY EhabY commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Gives agent session accounting one canonical vocabulary for app names, so later work can report a count per app without the agent and the server disagreeing about what an app is called.

  • Adds coderd/idemetadata, a leaf package importable from both agent and coderd code, holding the canonical names and their normalization: null bytes stripped, truncated to 64 runes, trimmed, lowercased, hyphens folded to underscores.
  • Adds a family grouping for the places that need a bounded value, such as a Prometheus label or the Connection_Type enum. It is never used for storage, so a missing alias only costs an unknown label.
  • agentssh.Server keeps its session counters in a map keyed by normalized name instead of three fixed atomics, dropping entries at zero so idle apps are not reported.
  • extractMagicSessionType canonicalizes rather than classifies, so an unrecognized type flows through as itself.
  • JetBrains channel tracking takes a start/end callback instead of a counter pointer.

Wire behavior is unchanged: the agent still reports the four session_count_* fields over Agent API 2.10, Collect translates only the four canonical names those fields exist for, and TestAgent_Stats_SSH, TestAgent_Stats_Magic, and TestAgent_Stats_ReconnectingPTY still assert the old fields untouched.

Stack

  1. this PR: normalize agent session metadata
  2. feat: add workspace agent session count protocol #28125: add the Stats.session_counts protocol field
  3. perf: store workspace agent session counts as JSONB #28126: store session counts as JSONB (the only migration in the stack)
  4. feat: report arbitrary workspace agent session types #28127: report arbitrary session types

@EhabY
EhabY force-pushed the refactor/normalize-agent-session-metadata branch from 099eee9 to a75121e Compare August 13, 2026 16:29
@EhabY
EhabY requested a review from code-asher August 13, 2026 17:08
@EhabY
EhabY marked this pull request as ready for review August 13, 2026 17:08
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