Skip to content

feat(auth): separate diagnostics and usage permissions - #9790

Open
juliusmarminge wants to merge 9 commits into
t3code/auth-preview-scopefrom
t3code/auth-diagnostics-scope
Open

feat(auth): separate diagnostics and usage permissions#9790
juliusmarminge wants to merge 9 commits into
t3code/auth-preview-scopefrom
t3code/auth-diagnostics-scope

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Sep 4, 2026

Copy link
Copy Markdown
Member

orchestration:read exposed trace logs, host process details, resource history and usage data along with workspace activity. Clients could not receive workspace read access without those diagnostics.

Adds diagnostics:read for trace and process diagnostics, process/resource history, live resource telemetry, usage summaries and pricing refreshes. Web and mobile query and subscribe only when that environment grants access. Usage remains visible during revalidation of a known grant; initial or failed permission lookups grant nothing. Provider limits remain available under their existing permissions.

New Standard grants include the scope. The explicit Read only pairing preset includes it to preserve that preset's previous diagnostics access; custom grants can omit it. Existing clients must pair again to receive the scope. Existing grants are never expanded automatically.

RPC tests cover all seven protected reads with allowed and denied credentials, including denial of unrelated operations to a diagnostics-only client. Targeted formatting and diff checks passed.

Pairing controls with the default selection:

Before After
Before: pairing permissions After: diagnostics permission

Eight focused access-state tests cover connected checks, unavailable environments, retained grants, and session failures. Web and mobile typechecks pass.

Model: GPT-6. Harness: Codex.

Note

Separate diagnostics:read scope from orchestration-read for diagnostics and usage RPCs

  • Adds a new diagnostics:read environment scope in auth.ts and reassigns trace diagnostics, process diagnostics, resource history, usage-summary, and usage-rate refresh RPCs to require it in RpcAuthorization.ts
  • Introduces a shared resolveUsageAccess utility in usageAccess.ts that maps connection phase and session scopes into a deterministic access state (canReadDiagnostics, isPending, error message)
  • Web and mobile usage screens (UsagePage.tsx, UsageRouteScreen.tsx) and their state atoms now skip usage-summary queries and show per-environment errors when diagnostics:read is absent
  • Diagnostics settings panel (DiagnosticsSettings.tsx) and resource telemetry hooks (resourceTelemetryState.ts) gate queries and retry on diagnostics:read; telemetry retry additionally requires environment:maintain at the handler in ws.ts
  • Pairing UI in ConnectionsSettings.tsx exposes a new "View diagnostics and usage" permission and includes it in the Read-only preset
  • Behavioral Change: existing clients with only orchestration-read lose access to diagnostics reads, usage summaries, and resource telemetry; the Read only pairing preset now grants diagnostics:read when delegatable

Macroscope summarized 83294bf.


Note

High Risk
This is an authorization boundary change: existing orchestration:read clients lose diagnostics/usage unless re-paired with diagnostics:read, and RPC enforcement affects sensitive host/process data.

Overview
Introduces a dedicated diagnostics:read scope so trace/process diagnostics, resource telemetry, and usage RPCs are no longer bundled with orchestration:read. Server RPC authorization maps those methods to the new scope; serverRetryResourceTelemetry now requires both environment:maintain and diagnostics:read.

Clients use shared resolveUsageAccess to decide whether to call usage/diagnostics APIs. Web and mobile usage state skips usageSummary when access is missing, while still allowing cached totals when a known grant is revalidated. Usage and diagnostics UIs show per-environment denial messages, disable refresh when appropriate, and surface environment.error in coverage notices. Pairing settings add View diagnostics and usage and include it in the Read only preset.

Server tests assert diagnostics-only vs orchestration-only token behavior and the dual-scope requirement for telemetry retry.

Reviewed by Cursor Bugbot for commit 83294bf. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.8 KiB 15.1 KiB
Codex Thread snapshot wire 7.0 KiB 7.3 KiB
Codex Live turn WebSocket wire 6.7 KiB 7.8 KiB
Codex Live turn WebSocket decoded 58.5 KiB 66.4 KiB
Codex Live turn messages 10 21
Claude Total thread wire 13.6 KiB 15.1 KiB
Claude Thread snapshot wire 7.0 KiB 7.3 KiB
Claude Live turn WebSocket wire 6.6 KiB 7.8 KiB
Claude Live turn WebSocket decoded 57.9 KiB 66.4 KiB
Claude Live turn messages 10 21

Baseline: unavailable · PR result: 83294bf · Source CI: cancelled

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 113.8 KiB
  • Claude decoded thread snapshot: 114.5 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Comment thread apps/web/src/state/usage.ts Outdated
@juliusmarminge juliusmarminge changed the title t3code/auth diagnostics scope feat(auth): separate diagnostics and usage permissions Sep 4, 2026
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 2eef2bc to 0cd8cfe Compare September 4, 2026 21:19
Comment thread apps/mobile/src/state/usage.ts Outdated
@juliusmarminge
juliusmarminge marked this pull request as ready for review September 4, 2026 21:21
Comment thread apps/mobile/src/features/usage/UsageRouteScreen.tsx Outdated
@macroscopeapp

macroscopeapp Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR introduces a new diagnostics permission and changes authorization requirements for existing diagnostics, usage, and telemetry RPCs, with corresponding web and mobile access gating. Because it modifies authentication and authorization behavior across the contract, server, and clients, the access policy and compatibility impact require human review.

No code changes detected at 83294bf. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 0cd8cfe to 74c727c Compare September 4, 2026 21:36
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 74c727c to a46a945 Compare September 4, 2026 21:38
Comment thread apps/web/src/state/usage.ts Outdated
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from a46a945 to d4580bc Compare September 4, 2026 21:40
Comment thread apps/mobile/src/features/usage/UsageRouteScreen.tsx

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread apps/web/src/components/settings/DiagnosticsSettings.tsx
Comment thread apps/mobile/src/features/usage/UsageRouteScreen.tsx
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from d4580bc to 92f7e30 Compare September 4, 2026 21:48
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 92f7e30 to c60d179 Compare September 4, 2026 21:51
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from c60d179 to 5e27ae4 Compare September 4, 2026 22:00
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 5e27ae4 to 3b1934f Compare September 4, 2026 22:08
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 3b1934f to 85833ae Compare September 4, 2026 22:15
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 85833ae to 81b28f8 Compare September 4, 2026 22:59
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 81b28f8 to 2c50f4d Compare September 4, 2026 23:52
Comment thread apps/web/src/lib/resourceTelemetryState.ts
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch 2 times, most recently from b39eefc to 3d7689d Compare September 5, 2026 00:10
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 3d7689d to 344da99 Compare September 5, 2026 00:24

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but a cloud agent failed to start.

Reviewed by Cursor Bugbot for commit 344da99. Configure here.

Comment thread packages/client-runtime/src/state/usageAccess.ts
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 344da99 to 9c7d0db Compare September 5, 2026 00:38
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 9c7d0db to 02bfe1f Compare September 5, 2026 01:23
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 02bfe1f to 83294bf Compare September 5, 2026 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant