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

Workspace read access also exposed trace logs, host process details, resource history, and usage data. Add diagnostics:read so those diagnostics can be granted independently.

Web and mobile queries and subscriptions follow each selected environment's grant. Usage retains a known grant during revalidation, loads environments progressively, and retries only failed environments. Initial or failed permission lookups grant no diagnostics access. Provider limits retain their existing permissions; pricing-override edits separately recheck settings:write on the owning environment.

New Standard grants and the explicit Read only preset include diagnostics access, preserving the preset's previous behavior. Custom grants can omit it. Existing credentials keep their recorded scopes; older servers must be upgraded before they can issue the new scope, then the client needs a fresh grant.

Earlier focused suites passed for all seven protected RPC reads with allowed and denied credentials, scope-loading failures and retained grants, multi-environment Usage retries, and pricing-edit revocation. Scoped web and mobile typechecks passed during stack verification. The pairing captures below predate the final integration.

Earlier-revision pairing UI, captured before the final stack integration:

Before After
Before: pairing permissions After: diagnostics permission

Model: GPT 6 Astra. Harness: Codex.

Note

Add diagnostics-read scope and gate usage/diagnostics access on it

  • Adds diagnostics-read to the scope schema in auth.ts and to the RPC_REQUIRED_SCOPES map in RpcAuthorization.ts for trace/process diagnostics, resource history, telemetry subscription, usage summary, and usage-rate RPCs
  • Adds a shared resolveUsageAccess resolver in usageAccess.ts that converts connection state and session scopes into a diagnostics-access result, keeping cached grants usable while offline
  • Web (UsagePage.tsx, usage.ts, resourceTelemetryState.ts, DiagnosticsSettings.tsx) and mobile (UsageRouteScreen.tsx, usage.ts) now skip RPCs for environments lacking diagnostics-read and show per-environment access or connection errors instead of usage data
  • The connection-pairing UI in ConnectionsSettings.tsx can now delegate diagnostics-read independently, and it is included in the read-only pairing preset
  • Risk: diagnostics-read is added to the standard client scope set; existing clients without this scope in their session will be denied usage and diagnostics RPCs until re-paired or re-authenticated

Macroscope summarized 11ff72c.


Note

High Risk
Authorization boundary changes: clients with only orchestration:read lose usage and diagnostics until re-paired, and several RPCs move to a new required scope.

Overview
Introduces diagnostics:read so trace/process diagnostics, resource telemetry/history, and usage RPCs are no longer bundled with orchestration:read. Server RPC scope maps and serverRetryResourceTelemetry now require diagnostics:read (retry also still needs environment:maintain via dual-scope enforcement in ws.ts).

Clients use shared resolveUsageAccess to decide per-environment access from connection phase and session scopes. Web and mobile skip usage/diagnostics queries when the grant is missing, show per-environment error copy instead of charts, and disable refresh when nothing can read diagnostics; pairing UI can delegate the new scope (included in the read-only preset).

diagnostics:read is added to standard client scopes in contracts; existing tokens keep their old scopes until re-issued. New server tests cover diagnostics-only vs orchestration-only access.

Reviewed by Cursor Bugbot for commit 0fd319b. 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.5 KiB 15.1 KiB
Codex Thread snapshot wire 7.0 KiB 7.3 KiB
Codex Live turn WebSocket wire 6.5 KiB 7.8 KiB
Codex Live turn WebSocket decoded 57.0 KiB 66.4 KiB
Codex Live turn messages 8 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: 11ff72c · Source CI: success

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:read permission, changes server RPC authorization and telemetry retry requirements, and adds that permission to standard client defaults. Because it changes authentication boundaries and default grants across server, web, and mobile code, human review is warranted.

No code changes detected at 11ff72c. 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 afbfcd7 to 7772ff6 Compare September 5, 2026 04:25

@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 7772ff6. Configure here.

Comment thread packages/contracts/src/auth.ts
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 7772ff6 to aabaea6 Compare September 5, 2026 04:59
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch 2 times, most recently from ede5299 to 4055e63 Compare September 5, 2026 07:18
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 4055e63 to 0fd319b Compare September 5, 2026 07:49
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 0fd319b to 4defe1b Compare September 5, 2026 08:12
@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 4defe1b to b450779 Compare September 5, 2026 08:42
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from b450779 to c6e88f0 Compare September 5, 2026 08:58
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from c6e88f0 to 69b9ac7 Compare September 5, 2026 09:55
@juliusmarminge
juliusmarminge force-pushed the t3code/auth-diagnostics-scope branch from 69b9ac7 to 11ff72c Compare September 5, 2026 10:06
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