Skip to content

Global settings claude codex - #319

Merged
AarushiShah-db merged 13 commits into
mainfrom
global-settings-claude-codex
Aug 14, 2026
Merged

Global settings claude codex#319
AarushiShah-db merged 13 commits into
mainfrom
global-settings-claude-codex

Conversation

@AarushiShah-db

@AarushiShah-db AarushiShah-db commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

When an admin marks an agent machine-wide in ucode setup (use_as_global_settings), ucode now also writes the agent's
native config file so a bare claude/codex hits the gateway — not just ucode . It keeps writing the existing
ucode-private file too, so ucode is unchanged.

Only claude and codex qualify: their gateway auth self-refreshes, so the native file keeps working indefinitely. Other
agents bake a short-lived token with no bare-launch refresher (copilot has no native config file at all), so the
machine-wide prompt in ucode setup is now only asked for claude and codex.

ucode revert surgically prunes only ucode's keys from the native file — never deletes it, never touches the user's own
settings. Also fixes a latent hydrate_state bug that dropped the native tracking.

31 new tests; full suite green except one pre-existing environmental e2e failure. ruff + ty clean.

globalsettings.mov

@AarushiShah-db

Copy link
Copy Markdown
Collaborator Author

btw @lilly-luo we can only support claude/codex for global settings right now because the other agents don't have auth self-refresh capabilities ( the token would expire within 1 hr) so the user needs to continue using ucode for the other ones

Comment thread src/ucode/agents/claude.py Outdated
Comment thread src/ucode/databricks.py
Comment thread src/ucode/agents/codex.py Outdated
When an admin marks an agent machine-wide in `ucode setup`, also write the
agent's own native config file (~/.claude/settings.json, ~/.codex/config.toml)
so a bare `claude`/`codex` hits the gateway, not just `ucode <agent>`. Only
claude and codex qualify — their auth self-refreshes — so the machine-wide
prompt is now only asked for those two. Revert surgically prunes just ucode's
keys from the native file, and hydrate_state no longer drops the tracking.

Co-authored-by: Isaac
Addresses Isaac Review findings on this PR:

- mark_tool_managed dropped the persisted native descriptor whenever a
  re-launch wrote no native file (use_as_global_settings unset, a relayed
  Claude launch, or a legacy-layout Codex launch). ucode's keys stayed in
  the user's shared file but revert could no longer find them. Preserve the
  prior descriptor when native is None (revert wipes state wholesale, so no
  stale descriptor lingers).

- claude revert_native_config path-pruned whole hook-event arrays
  (hooks.Stop, hooks.PreToolUse/SessionStart/SubagentStart), deleting the
  user's own hooks. Route hook-event keys through the marker-matched removers
  (remove_smart_routing_hooks / _remove_tracing_stop_hook), symmetric with
  the write path; only plain keys go to prune_key_paths.

Co-authored-by: Isaac
@AarushiShah-db
AarushiShah-db force-pushed the global-settings-claude-codex branch from c617547 to cb8f9ce Compare August 13, 2026 21:57
Under use_as_global_settings, write the agent's OS-level managed settings file
so a bare `claude`/`codex` picks up the gateway, not just `ucode <agent>`:
  - claude: /etc/claude-code/managed-settings.json (mac: /Library/…) — JSON
  - codex:  /etc/codex/managed_config.toml — TOML

New managed_files.py mirrors isaac (devtools/ai/llm_lib/core/config.py): a drift
check reads the world-readable file with no sudo and no-ops when unchanged (so no
password prompt on the common launch), else temp-file -> `sudo cp` with
chattr/chflags immutable handling and actionable errors. Revert surgically prunes
only ucode's keys via the same sudo path. Renames the transient flag
write_native_config -> write_managed_config.

Co-authored-by: Isaac
@AarushiShah-db
AarushiShah-db force-pushed the global-settings-claude-codex branch from cb8f9ce to 712c8d7 Compare August 13, 2026 22:01
…dirs

Manual testing on an enterprise-managed box surfaced three issues:

- read_json_safe/read_toml_safe did an unguarded path.exists(), which raises
  PermissionError (not a clean "absent") when the file sits under a root-locked
  dir like a 750 /etc/codex — crashing the whole launch. Guard it -> treat as
  empty/absent.
- managed_files._clear_immutable had the same unguarded path.exists() inside the
  sudo write, so the write aborted with a misleading "cannot write without root"
  before the chmod that opens the dir. Guard it; root's `cp` overwrites anyway.
- The "enterprise managed settings may override your admin's config" warning
  fired even when ucode itself authored that managed file under
  use_as_global_settings. Suppress it (both sites) when ucode owns the file.

Co-authored-by: Isaac
Name the exact file each answer writes (Claude Code's managed-settings.json /
Codex's managed_config.toml) and spell out the payoff: "yes" means a bare
`claude`/`codex` reaches the gateway on its own (no ucode needed), "no" keeps a
ucode-only settings file.

Co-authored-by: Isaac
The provider-launch e2e tests only prove routing reaches the Model Provider
Service; a real "Credit balance is too low" from the provider account is an
environmental condition, not a ucode bug, so skip it like the existing
no-permission case rather than failing CI. Generalize _skip_if_no_permission ->
_skip_if_provider_unusable to cover both.

Co-authored-by: Isaac
Comment thread src/ucode/agents/claude.py Outdated
Comment thread src/ucode/managed_files.py
Comment thread src/ucode/agents/claude.py Outdated
Comment thread src/ucode/cli.py Outdated
Comment thread src/ucode/agents/claude.py Outdated
Comment thread src/ucode/agents/codex.py Outdated
Comment thread src/ucode/agents/codex.py Outdated
Comment thread src/ucode/agents/codex.py Outdated
Comment thread src/ucode/managed_files.py Outdated
Comment thread src/ucode/managed_files.py
Comment thread src/ucode/managed_files.py Outdated
Comment thread src/ucode/managed_resolve.py Outdated
Comment thread src/ucode/state.py Outdated
@AarushiShah-db
AarushiShah-db enabled auto-merge (squash) August 14, 2026 17:02
@AarushiShah-db
AarushiShah-db merged commit eb89248 into main Aug 14, 2026
2 checks passed
@AarushiShah-db
AarushiShah-db deleted the global-settings-claude-codex branch August 14, 2026 17:56
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.

2 participants