Repository navigation
fix(agents): merge a resources patch element-wise onto the freshly-read spec - #13624
Conversation
…ad spec The document a PATCH writes back is built from a snapshot taken before the spec lock, so assigning its `resources` list whole dropped any URI a concurrent writer had added in between; only the URIs this patch itself named may move. A patch that names no resource change now leaves a malformed `resources` value untouched rather than normalising a key it never read. Co-authored-by: rnoack1 <69695077+rnoack1@users.noreply.github.com>
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the delta-merge assumption holds: [DESIGN-REVIEWED] f62936a |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Confirm What this change shipsInventory (5 items) — 5 justifiedIntent: FIX — stop an agent-detail PATCH from erasing a resource URI a concurrent writer added between the pre-lock snapshot and the locked write.
Notes for the audit trail: [FIRST-PRINCIPLES-REVIEWED] f62936a |
Opus 5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
…ad spec (kirodotdev#13624) The document a PATCH writes back is built from a snapshot taken before the spec lock, so assigning its `resources` list whole dropped any URI a concurrent writer had added in between; only the URIs this patch itself named may move. A patch that names no resource change now leaves a malformed `resources` value untouched rather than normalising a key it never read. Co-authored-by: kirocrew-worker <worker@kirocrew.local> Co-authored-by: rnoack1 <69695077+rnoack1@users.noreply.github.com>
Supersedes #11924, original author @rnoack1. In-repo replacement branch so the AI review lanes (which errored "review incomplete" on the fork — infrastructure, not a code finding) can re-run. Cherry-pick of the original change; authorship credited via
Co-authored-by: rnoack1.Problem / Motivation
api_agent_detailPATCH suffers a lost update. The document written back to the agent spec is built from a snapshot taken before the spec lock is acquired. Assigning that snapshot'sresourceslist wholesale therefore drops any resource URI a concurrent writer added between the read and the lock.Why it matters
Two overlapping edits to an agent's resources silently lose one writer's additions — a data-loss bug that is timing-dependent and hard to notice. Anyone editing an agent's resources while another writer (another tab, another client, an app) touches the same spec can have their addition erased.
What changed (motivation → approach → change)
resourcessnapshot whole, overwriting whatever landed under the lock.resourcesvalue untouched rather than normalising a key it never read.Not a product-shape change — no default, command, or user-facing capability changes. No RFC required.
Backwards compatibility
Compatible: the endpoint's request/response contract is unchanged; this only narrows what a PATCH writes back to the delta it named, fixing a lost-update rather than changing any accepted shape.
Tests
test/test_agent_detail_model_managed.py(+176) locks in:resourcesvalue alone;All 9 pass locally; the broader agent-handler suite (
test_agent_config_merge_on_write.py, 54 tests) also passes.Manual verification
N/A — unit coverage sufficient: the lost-update is reproduced deterministically by the concurrent-writer test.
Related Issues
Supersedes #11924.
Pattern harvest
Rule candidate: review-prompt
Pattern: mutating state assigned from a snapshot read before the lock, rather than merging the named delta onto the value re-read under the lock (read-modify-write outside the critical section).
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)