fix(agent): install a colour palette in one mutation, not one per token - #317
Merged
Conversation
`site_set_color_tokens` looped `createFrameworkColorToken` once per token. Each of those is its own site mutation, and any mutation that ensures a not-yet-bound collab doc registers a write gate at `synced: false` — so every remaining write in the same synchronous tick was refused with `syncing`. The action returned a token object either way and the runner recorded it as created, so the tool answered "14 tokens created" for a palette of which only the first 7 reached the relay and the database. Authored CSS then referenced `var(--case)` and `var(--rock)` that did not exist. Nothing in the flow said so: the header simply rendered white. Colour tokens now go through a single `upsertFrameworkColorTokens` action — one mutation, one gate check — which plans slugs against a growing copy so in-batch uniqueness and category canonicalization match what a sequence of single-token calls produced. It returns `accepted`, and the runner reports a refused batch as an error instead of a list of tokens nobody stored. The font and scale runners had the same silent-success shape; both now read their writes back and fail loudly when the value is absent. Test: 8 tokens land in one mutation; slugs stay unique inside a batch; re-running updates in place; a refused batch returns ok:false and stores nothing.
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.
Summary
site_set_color_tokenscould report a successful batch update even when only part of the batch was persisted. This change makes palette updates atomic at the editor-store mutation boundary and turns refused writes into explicit errors.Root cause
runSetColorTokenspreviously calledcreateFrameworkColorTokenonce per token. Each call performed its ownmutateSite, while collaboration document binding could temporarily mark the site as not writable during the same synchronous batch. Later writes were then refused assyncing.The failure was silent because the per-token action returned a token without checking whether
mutateSiteaccepted the write, and the runner reported every requested token as created.Changes
upsertFrameworkColorTokensto create or update an entire color-token batch in one site mutation.acceptedresult and fail the tool call when the collaboration gate refuses the batch.Verification
Added
src/__tests__/collab/paletteBurstWrite.test.tscovering:ok: falseand stores nothingFull test suite: 6461 passing, 0 failing.