Skip to content

Team mode M10: Usage per member and role model allowlists #4148

Closed

Description

@DoodleBears

Parent: hub #4138 (spec #4137, ADR-0336). Blocked by: #4142.

Behavior

  • Token and cost usage is attributed to Human ID and Bot. The Owner and Admins can view it per member.
  • Roles may restrict which configured models their members' Bots can use; this is enforced at model selection.
  • Provider keys are never shown to members.
  • No quotas in this slice.

Acceptance

  • Usage totals reconcile with existing usage owners.
  • Selecting a disallowed model is refused.

Activity

  1. DoodleBears commented on Nov 14, 2026

    @DoodleBears
    ContributorAuthor

    Agent work claim

    M10 wire contract (agreed before parallel work; Claude = UI, Codex = logic)

    Based on main after M1 (#4163) and M3 (#4164). M2 (#4166), M4, M9 (#4167) are open in parallel; whichever lands later reconciles migrations and member-methods.ts.

    Usage attribution

    • Usage receipts gain a Human ID: the Human whose message started the Session's root turn when known (Channel message author, Human DM, Tob), else the Bot's owner Human (M2 owner; Owner for Host Bots and Bots without an owner). Background work (schedules, Assignments, idle compaction) is attributed to the Human that created it when recorded, else the Bot owner.
    • Existing rows are attributed to the Owner (legacy: true on the period when any legacy rows fall inside it). No row is ever dropped or double-counted.
    • usageByMember { period: 'today'|'week'|'month'|'quarter' } → { period, start, end, timezone, members: [{ humanId, displayName, deleted?: true, totals, bots: [{ slug, displayName, totals }] }], legacy: boolean } where totals is the existing UsageOverviewBuckets. Requires usage.view (Owner always). Refusal permission-required (details.permission: 'usage.view'). Sum of member totals equals overviewUsage totals for the same period (regression test).
    • Members keep seeing only their own Bots' rows in overviewUsage (no other members' Bots).

    Role model allowlists

    • Each Host Role gains models: { kind: 'all' } | { kind: 'only', routes: string[] } where a route key is <provider>/<model> (effort is not restricted). Default all for every existing and new Role. Set through roleUpdate { roleId, models } (needs roles.manage, ceilings unchanged; the built-in Admin role stays all).
    • A member's allowed set is the union of their Roles (any all → all). The Owner is unrestricted.
    • modelsAllowed → { all: true } | { all: false, routes: string[] } for the caller (also returned on teamMode.viewer.models).
    • Enforcement at model selection for any Bot owned by a member (Bot model plan, Assignment default, subagent route, per-Session model switch, Tob): a disallowed route is refused with model-not-allowed (details.route). A Bot whose current route became disallowed keeps its setting but its next turn is refused with the same code and a Human-visible notice; get/list mark it modelAllowed: false.
    • Provider keys and credential readiness details are never returned to members: member-methods.ts excludes every credentials/provider-key method, and a regression proves a member call is refused.

    CLI: usage members --period week, roles update <roleId> --models all|<provider/model,…>, models allowed; --as for all.

    Client (Claude): Settings › Team › Usage (per-member table with per-Bot breakdown, period picker; shown with usage.view), Role editor › Models (All models / Only these with a model checklist), model pickers hide disallowed routes for members and mark a Bot whose route is disallowed; en + zh.

    Tests: per-member totals reconcile with overviewUsage; attribution of a member's DM turn to that member; legacy rows to Owner; disallowed model refused through every selection path and at turn start; Owner unrestricted; member cannot read provider keys; CLI --as parity.

  2. DoodleBears commented on Nov 14, 2026

    @DoodleBears
    ContributorAuthor

    Outcome

    Merged in #4186 (migrations 148 and 149, after Environment E4's 147). Usage is attributed to the Human who started each turn (own Bots, shared-Channel mentions, subagents and Assignment turns), with legacy rows under the Owner; the Owner and usage.view holders see it per member and per Bot. Roles limit model routes (union across roles, grants capped by the actor's own allowlist); members get a filtered catalog with no credential details; a Bot on a disallowed route fails its turn with a plain explanation. Verified with real model turns on an isolated Host; CI green; all review findings fixed.

    State: done. Claim released.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions