Skip to content

feat(server,web,desktop): enforce organization-managed settings - #16931

Closed
rynorris wants to merge 4 commits into
pingdotgg:mainfrom
rynorris:feat/managed-settings
Closed

rynorris wants to merge 4 commits into
pingdotgg:mainfrom
rynorris:feat/managed-settings

Conversation

@rynorris

@rynorris rynorris commented Oct 7, 2026 •

Copy link
Copy Markdown

Before this PR

Organizations have no way to enforce T3 Code settings on the machines they manage, so some won't allow it at all. My workplace is one of them. T3 Code is blocked there until an admin can hard-disable things like telemetry reporting, T3 Connect, and incoming network connections on developer workstations. See #16883.

After this PR

Admins can deploy a managed settings policy that overrides users' server settings. I modeled it on Claude Code's managed-settings.json and Codex's managed config, since admins already know how to deploy those.

  • On macOS the server reads /Library/Application Support/T3Code/managed-settings.json and the com.t3tools.t3code MDM managed preferences domain (/Library/Managed Preferences/com.t3tools.t3code.plist). On Linux it reads /etc/t3code/managed-settings.json. Users can't write to these locations, and the MDM profile wins over the file, as in both tools.
  • A policy uses the same keys as the server's settings.json and lists only what it enforces. Nested objects merge key by key. Plain values and arrays replace the user's value.
  • The server CLI loads the policy once at startup, before it resolves its own config. Policy values beat the user's settings, project overrides, and, for OTLP export URLs, env vars. The server applies them on read and never writes them into the user's settings.json, so removing a policy gives users their own values back.
  • A policy that can't be read or parsed, or that has an unknown or invalid key, stops the server from starting. The error names the file and every bad key. Claude Code also refuses to start on an unparseable policy, and skipping one bad key would quietly leave it unenforced.
  • The config snapshot lists the managed key paths. On web and desktop a managed row shows the enforced value with a disabled control and "Managed by your organization". A managed provider instance becomes read-only.

Admin docs are in docs/user/managed-settings.md.

Before After (with a policy)
General general before general after
Providers providers before providers after

The "after" policy sets Permissions, Workspace and Auto-resume, and disables the built-in Claude instance.

==COMMIT_MSG==
Organizations can enforce T3 Code settings with a managed settings policy (macOS file or MDM profile, Linux file).
==COMMIT_MSG==

Notes

This PR only covers settings.json overrides. Telemetry, T3 Connect, and network access aren't settings keys, so each needs an explicit policy restriction enforced where that feature lives. I wrote up the plan on #16883 and want to land this base first.

Known limitations:

  • Only macOS and Linux are supported. Windows isn't yet.
  • The policy is read at startup, so a change applies on the next app or server restart.
  • An invalid policy keeps the desktop app's backend from starting, and there's no dedicated error screen for it yet. The reason is in the server log. The desktop's own OTLP export also turns off in that case.
  • Because unknown keys are rejected, a policy that uses a new setting should only go out once every machine runs a version that has it.
  • A policy only reaches the provider instances it names. Disabling the built-in Codex instance doesn't stop a user from adding a second one. Blocking a provider outright needs a future restriction.
  • Mobile Settings doesn't lock managed rows yet. The server still enforces the policy, so an edit made there reverts.
  • A client that saves a whole object containing managed keys can copy those values into the user's settings.json, where they stay after the policy is removed. Locked rows and provider cards avoid this in the UI.
  • Users can still turn off all OTLP export with OTEL_SDK_DISABLED.

🤖 Generated by Claude (Opus 5.5) in Claude Code, 👨 directed by @rnorris

rynorris and others added 4 commits October 7, 2026 21:08
Organizations can now deploy a settings policy that overrides users'
server settings, the way Claude Code's managed-settings.json and
Codex's MDM config work.

The server reads policy at startup from
/Library/Application Support/T3Code/managed-settings.json and the
com.t3tools.t3code MDM managed preferences domain on macOS, or from
/etc/t3code/managed-settings.json on Linux. The policy uses the same
shape as settings.json and is laid over the user's settings when they
are read, so managed keys also beat project overrides. It is never
written into the user's file, so removing a policy restores the user's
own values. Invalid keys or unreadable sources are logged and skipped.

The config snapshot reports the managed key paths, and Settings locks
those rows and provider cards on web and desktop.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Skipping a bad policy file or dropping a bad key left part of an
organization's policy unenforced with only a log line to show for it.
Any unreadable, unparseable, unknown, unmanageable, or invalid entry now
fails startup with an error naming the file and every bad key.

Also clarify that the unmanageable `observability` key holds
OpenTelemetry export URLs, not product telemetry.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…P export

The policy is now loaded once by the server CLI, before config
resolution, and provided to the runtime, so it can outrank flags and env
vars and an invalid policy stops the server before it binds anything.
The loader moved to @t3tools/shared so the desktop main process reads
the same policy for its own export.

With that, `observability` is manageable: a managed OTLP URL replaces
every other source for its signal, and a blank one turns that signal
off. If the desktop cannot read the policy it exports nothing.

A managed provider instance whose user config lives only in legacy
`providers.<kind>` is now seeded from that config first, so the policy
merges into the user's settings instead of replacing them.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ards

A managed row's source indicator said "Set on the environment"; it now
says "Managed by your organization". A read-only provider card, managed
or not, no longer offers "Reset provider settings", a write the server
would refuse or override.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Oct 7, 2026

@coderabbitai coderabbitai 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.

Pre-merge checks failed. Please resolve the failing checks before merging.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2a11d70c-2d56-4004-904e-d4f437ad249a
📥 Commits

Reviewing files that changed from the base of the PR and between a9fb6a8 and 88200ed.

📒 Files selected for processing (18)
  • README.md
  • apps/desktop/src/app/DesktopObservability.ts
  • apps/desktop/src/main.ts
  • apps/server/src/cli/config.test.ts
  • apps/server/src/cli/config.ts
  • apps/server/src/cli/server.ts
  • apps/server/src/serverSettings.managed.test.ts
  • apps/server/src/serverSettings.ts
  • apps/server/src/ws.ts
  • apps/web/src/components/settings/ProviderSettingsPanel.environment.test.tsx
  • apps/web/src/components/settings/ProviderSettingsPanel.tsx
  • apps/web/src/components/settings/settingsLayout.tsx
  • docs/user/managed-settings.md
  • packages/contracts/src/server.ts
  • packages/shared/package.json
  • packages/shared/src/managedSettings.test.ts
  • packages/shared/src/managedSettings.ts
  • packages/shared/src/otelEnvironment.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

This change adds host-managed settings policies for macOS and Linux, applies policy values to server settings and OTLP export endpoints, and exposes managed key paths so the settings UI can identify organization-managed controls. It also adds policy documentation and tests.

Changes

Host-managed settings

Layer / File(s) Summary
Load and validate policy documents
packages/shared/src/managedSettings.ts, packages/shared/src/managedSettings.test.ts, packages/shared/package.json, docs/user/managed-settings.md, README.md
The shared package loads platform-specific policy sources, validates and merges policy values, and provides the resulting settings. Tests and documentation cover loading, precedence, and policy behavior.
Apply policy to effective server settings
apps/server/src/serverSettings.ts, apps/server/src/serverSettings.managed.test.ts
Server settings apply managed values to effective settings without replacing persisted user settings. Project overrides for managed keys are removed, and effective settings are used for reads, updates, notifications, and startup.
Apply managed OTLP endpoints
packages/shared/src/otelEnvironment.ts, apps/server/src/cli/config.ts, apps/server/src/cli/server.ts, apps/server/src/cli/config.test.ts, apps/desktop/src/app/DesktopObservability.ts, apps/desktop/src/main.ts
Server and desktop endpoint resolution use managed trace, metric, and log URLs. The server loads host policy before resolving configuration. Tests cover managed endpoint precedence and blank managed URLs.
Expose managed paths and lock controls
packages/contracts/src/server.ts, apps/server/src/ws.ts, apps/web/src/components/settings/settingsLayout.tsx, apps/web/src/components/settings/ProviderSettingsPanel.tsx, apps/web/src/components/settings/ProviderSettingsPanel.environment.test.tsx
Server configuration includes managed setting paths. The settings UI checks those paths and marks managed rows and provider cards as read-only.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ManagedSettings
  participant WebSocketRPC
  participant SettingsRow
  participant isServerSettingManaged
  ManagedSettings->>WebSocketRPC: provide managedSettingPaths in ServerConfig
  WebSocketRPC->>SettingsRow: deliver server configuration
  SettingsRow->>isServerSettingManaged: check setting path against managed paths
  isServerSettingManaged-->>SettingsRow: return managed status
  SettingsRow->>SettingsRow: render managed row as read-only
Loading

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 88200

No specific issue is established that should prevent merging after normal checks.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 88200

Organization-managed settings create a meaningful security boundary. Recognized settings receive strong precedence, but nested policy mistakes may be accepted without enforcement, leaving telemetry export active when an administrator intended to disable it.

Retained concerns

  • Medium · security · inferred: The fail-closed policy validator explicitly rejects unknown top-level keys but does not establish equivalent rejection for nested keys. A policy such as observability.otlpTraceUrl with a blank value can be accepted by permissive settings decoding while the endpoint resolver only recognizes otlpTracesUrl. The original unknown path is still represented as managed, while existing user/environment endpoint fallback remains available. This is an inferred control-enforcement gap affecting hosts receiving the malformed policy, not an observed bypass of a correctly named managed URL.
Security review details

Security Blast Radius

  • inferred — A malformed centrally deployed policy can affect every workstation receiving it. The identified path concerns server and desktop telemetry destinations; it does not establish new remote authority to modify the host policy. Policy tampering resistance depends on administrators maintaining the documented filesystem ownership and permissions.

Security Findings and Attack Paths

  • inferred — An administrator's unknown nested OTLP key may pass ordinary settings decoding and be retained in managed-path metadata. Because managedOtlpUrl reads only exact recognized names, a user-selected environment or persisted endpoint can remain effective. Correctly named managed URLs terminate fallback resolution, which limits this concern to ineffective or malformed policy declarations rather than arbitrary override of valid policy.

Trust Boundaries and Controls

  • observed — The official server entrypoint loads policy before configuration and binding. Source read, parse, and detected validation failures terminate that load. Desktop telemetry instead supplies blank managed URLs after a load failure, disabling export. Recognized managed URLs override all endpoint fallbacks; a blank URL disables its signal.
  • observed — Effective managed settings pass through existing client redaction before snapshots and mutation responses. Redaction covers marked sensitive provider environment variables, usage-limit management keys, Bitbucket tokens, and GitHub tokens.

Resilience and Maintainability Implications

  • observed — Policy changes are restart-only, so editing or removing a policy does not change an already-running process's enforcement snapshot. Administrators must coordinate application upgrades and restarts with policy deployment; detected unknown keys intentionally prevent startup rather than permit partial enforcement.

Hardening Proposals

  • proposed — Separate strict policy validation from permissive user-settings decoding. Reject unknown keys inside known settings objects while preserving intentional map keys, and verify that declared managed paths correspond to enforceable values before advertising them as managed.

Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore (reviewers only)

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Approvability ❌ Error This pull request needs a maintainer's review. Rule: adds a subsystem and user workflow, with a large refactor across apps and packages. The diff adds the managed-settings subsystem in `packages/share… Maintainer review is required for the new managed-settings subsystem and its server, web, desktop, shared-package, and contract changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: enforcing organization-managed settings across the server, web, and desktop components.
Description check ✅ Passed The description clearly explains the problem, implementation, scope, supported platforms, limitations, and UI behavior. It includes before-and-after screenshots and identifies the related discussion. …
Full details: Approvability

Explanation

This pull request needs a maintainer's review. Rule: adds a subsystem and user workflow, with a large refactor across apps and packages. The diff adds the managed-settings subsystem in packages/shared/src/managedSettings.ts, changes server policy application in apps/server/src/serverSettings.ts and startup loading in apps/server/src/cli/server.ts, changes the web workflow in apps/web/src/components/settings/settingsLayout.tsx, changes desktop behavior in apps/desktop/src/app/DesktopObservability.ts, and extends the cross-package contract in packages/contracts/src/server.ts. The range contains 18 changed files and 836 insertions.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@maria-rcks

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

Thanks for explaining your workplace's managed-settings requirement. This introduces a new organization policy system, including machine-wide configuration, enforced precedence, and locked settings controls. Under the prior approval rule, that product direction and scope need explicit maintainer approval; linking #16883 does not establish it. Please bring the requirement to an Ideas discussion and request reconsideration after that scope is approved.

@maria-rcks maria-rcks closed this Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants