Skip to content

Add ucode apply: publish the authored managed config - #271

Open
tt-le wants to merge 1 commit into
tien/managed-apply-clientsfrom
tien/managed-apply
Open

Add ucode apply: publish the authored managed config#271
tt-le wants to merge 1 commit into
tien/managed-apply-clientsfrom
tien/managed-apply

Conversation

@tt-le

@tt-le tt-le commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Changes

Stacked on #270 — review that first. This PR's diff includes the rest of the stack until those merge.

The publish step for the manifest ucode setup authors. Validates, shows what would change, confirms, then writes it to the workspace using the clients from #270. This completes the admin path: author (ucode setup) → review (ucode setup show) → publish (ucode apply).

ucode apply             # validate, preview, confirm, publish
ucode apply --dry-run   # validate and preview without writing
ucode apply --yes       # skip the confirmation (CI)

It updates in place rather than replacing

When the workspace already has a config, apply PATCHes it using its resource name, read back from the existing-config GET (normalize_managed_config preserves name).

Delete-then-create was the original plan, since v0's Create returns ALREADY_EXISTS. But that has a window where the workspace has no managed config — and if the create failed there, every developer would silently fall back to their own settings until someone re-ran the command. The server applies the update mask inside a single entity-store update, so a failed PATCH leaves the current config intact.

It is still a whole-manifest write: every path ucode owns is sent, so a field the admin dropped on a re-run is cleared rather than left behind.

It refuses to publish when it can't tell whether a config exists

A failed existence check is the one case where "just try the create" either duplicates or silently overwrites an admin's work. So an unreadable check is a hard error naming the reason, not a warning that proceeds.

Error mapping

_explain_publish_failure covers the failures an admin will actually hit:

Server error What ucode says
FEATURE_DISABLED Names codingAgentConfigCrudEnabled and who to ask — this is the likely first experience, since the CRUD flag is off by default
PERMISSION_DENIED Workspace admin is required to author the workspace's coding config
INVALID_PARAMETER_VALUE Passed through verbatim — the server names the offending field, which beats any paraphrase
ALREADY_EXISTS Shouldn't happen once we PATCH; suggests re-running

The admin gate and validation both run before anything is sent, so an invalid manifest or a non-admin costs no round trip.

Testing

uv run pytest — 1372 passed, 6 skipped. 19 new cases.

Mutation-verified three ways: always-create instead of PATCH, publishing despite an unreadable existence check, and publishing an invalid manifest each fail a specific test. Also covers that typer.Exit(0) isn't swallowed by the command's own RuntimeError handler — the same trap setup hit, where a successful run printed ERROR 0.

Verified against a staging workspace:

╭─────────────╮
│ ucode apply │
╰─────────────╯
✔ Databricks auth already available
✔ Admin permissions verified

Configuration summary
  Default agent: Claude Code
  Claude Code: system.ai.claude-sonnet-5 (per-user)
    opus: system.ai.claude-opus-5
    sonnet: system.ai.claude-sonnet-5
  Budget policy: my_policy_name
    at 50%: Claude Code / system.ai.claude-sonnet-5
    at 90%: Codex / system.ai.gpt-5-6-sol

! This will replace the config already published on <workspace>
  (currently: claude). Every developer picks the new one up on their
  next ucode run.
✔ Dry run: the config was validated but not published.

That exercised auth, the admin check, the summary, and the existing-config detection choosing the update path — without writing.

README

Documents the publish step and drops the "no partial update yet" caveat, which the PATCH path makes untrue.

Not included

A pre-publish validation probe (launching each agent to confirm its model actually answers) is deliberately out of scope — it needs its own retry UX and would roughly double this PR. Better as a follow-up or a --probe flag.

This pull request and its description were written by Isaac.

@tt-le
tt-le force-pushed the tien/managed-apply-clients branch from d3ee7c2 to 13c66f0 Compare August 5, 2026 17:53
@tt-le
tt-le force-pushed the tien/managed-apply branch 2 times, most recently from c16711b to 8287258 Compare August 5, 2026 19:29
@tt-le
tt-le force-pushed the tien/managed-apply-clients branch from b0ba733 to 7e2ec09 Compare August 5, 2026 19:58
@tt-le
tt-le force-pushed the tien/managed-apply branch from 8287258 to be99eed Compare August 5, 2026 19:58
@tt-le
tt-le force-pushed the tien/managed-apply-clients branch from 7e2ec09 to 88f43af Compare August 5, 2026 20:49
@tt-le
tt-le force-pushed the tien/managed-apply branch from be99eed to d4fcec4 Compare August 5, 2026 20:49
@tt-le
tt-le force-pushed the tien/managed-apply-clients branch from 88f43af to b8dff9e Compare August 5, 2026 21:03
@tt-le
tt-le force-pushed the tien/managed-apply branch from d4fcec4 to 1dd8c7e Compare August 5, 2026 21:03
@tt-le
tt-le force-pushed the tien/managed-apply-clients branch from b8dff9e to 03a3f13 Compare August 5, 2026 21:12
@tt-le
tt-le force-pushed the tien/managed-apply branch from 1dd8c7e to 56a5e69 Compare August 5, 2026 21:12
The publish step for the manifest `ucode setup` authors. Validates, shows what
would change, confirms, then writes it to the workspace via the clients added in
the parent commit.

Updates in place rather than replacing. When the workspace already has a config,
`apply` PATCHes it using its resource name (read back from the existing-config
GET, which `normalize_managed_config` preserves). Delete-then-create was the
original plan — v0's Create returns ALREADY_EXISTS — but it has a window where the
workspace has *no* managed config, and if the create failed there every developer
would silently fall back to their own settings until someone re-ran the command.
The server applies the update mask inside a single entity-store update, so a
failed PATCH leaves the current config intact. It is still a whole-manifest write:
every path ucode owns is sent, so a field the admin dropped on a re-run is cleared
rather than left behind.

Refuses to publish when it cannot tell whether a config already exists. A failed
existence check used to be the one case where "just try the create" would either
duplicate or silently overwrite an admin's work, so an unreadable check is a hard
error naming the reason rather than a warning.

`_explain_publish_failure` maps the failures an admin will actually hit.
FEATURE_DISABLED is the likely first experience — the CRUD flag is off by default —
so it names `codingAgentConfigCrudEnabled` instead of printing an HTTP 400.
INVALID_PARAMETER_VALUE is passed through verbatim: the server names the offending
field, which beats any paraphrase.

`--yes` skips the confirmation for CI; `--dry-run` validates and previews without
writing. The admin gate and validation both run before anything is sent, so an
invalid manifest or a non-admin costs no round trip.

README documents the publish step and drops the "no partial update yet" caveat,
which the PATCH path makes untrue.

Verified against eng-ml-inference.staging: `apply --dry-run` authenticated,
verified admin, rendered the summary, detected the existing config, and chose the
update path without writing.

Tests: 19 cases. Mutation-verified three ways — always-create instead of PATCH,
publishing despite an unreadable existence check, and publishing an invalid
manifest each fail a specific test. Also covers that `typer.Exit(0)` isn't caught
by the command's own RuntimeError handler, the same trap `setup` hit.

Co-authored-by: Isaac
@tt-le
tt-le force-pushed the tien/managed-apply-clients branch from 03a3f13 to 32205ad Compare August 5, 2026 21:21
@tt-le
tt-le force-pushed the tien/managed-apply branch from 56a5e69 to dc06d66 Compare August 5, 2026 21:21
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.

1 participant