Split managed state into draft and published slots - #437
Open
david-siqi-liu wants to merge 1 commit into
Open
Conversation
This was referenced Sep 1, 2026
david-siqi-liu
marked this pull request as ready for review
September 1, 2026 20:43
david-siqi-liu
force-pushed
the
david/managed-state-slots
branch
from
September 1, 2026 23:27
ba39bfa to
84859b6
Compare
`~/.ucode/managed-state.json` held one config per workspace, written both by `refresh_managed_config` (the copy fetched from the workspace on every launch) and by the authoring wizard (the admin's local, unpublished draft). The two clobbered each other: a launch wiped an in-progress draft, and a launch could apply an unpublished draft as if it were published policy. Store both under a versioned per-workspace map with separate `draft` and `published` slots. A v1 file migrates on read, with its original bytes kept at `managed-state.json.pre-v2.bak` on the next write. The map is written through a sibling temp file and renamed into place, because it now holds the admin's draft: nothing can refetch that, so a torn write would lose it outright. `load_managed_state` and `save_managed_state` stay as thin wrappers over the published slot so existing callers keep working; a follow-up moves them over. Co-authored-by: Isaac <no-reply@databricks.com>
david-siqi-liu
force-pushed
the
david/managed-state-slots
branch
from
September 2, 2026 00:38
84859b6 to
e2ca8e2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🥞 Stack (AIGTWY-4342 ucode configure)
ucode setupwith aucode configure-centered workflow #433ucode configurepath end to end #440What did you change, and why?
~/.ucode/managed-state.jsonkept one config per workspace, so an admin authoring a config and adeveloper's launch-time snapshot wrote to the same key and overwrote each other. This gives every
workspace two named slots:
draft(what an admin is authoring, never applied to any agent) andpublished(the last snapshot fetched from the workspace, the one that gets applied on launch).version: 2plus aworkspacesobject, each workspaceholding a
draftand apublishedslot.managed-state.json.pre-v2.bak.save_managed_stateandload_managed_stateremain as thin aliases over the published slot sothe existing call sites keep working unchanged. Replace
ucode setupwith aucode configure-centered workflow #433 deletes them once every caller has moved.Keeping them here holds this PR to one file of real logic instead of a mechanical rename across
six more.
published snapshot that the next launch refetches; now the same file holds a draft that nothing can
rebuild.
_migrated_workspacesand_save_slotinsrc/ucode/managed_config.py. Everythingelse follows from those two.
Behavior preserved: an empty published config still records "this workspace has no managed config",
which is what stops a server-side removal from being reapplied from stale disk state after a
transient fetch failure.
How do you know it works?
tests/test_managed_config.pycovers the v2 round trip, the v1 migration and its backup file, anunreadable or malformed file, slot isolation (writing one slot leaves the other slot and every other
workspace untouched), and a write that fails part way leaving the previous state intact. Full unit suite green locally at this layer (2179 passed, 37 skipped), and
testpluse2eare green on CI.