WIZ-prereq-B transactional agent-type rename endpoint #689

Merged
code-lead merged 1 commit from boss/671 into main 2026-05-01 21:21:42 +00:00
Collaborator

POST /agents/types/{old_name}/rename rewrites every per-type column reference (agents.type plus agent_type on the six per-kind tables) inside one SQLite transaction, reloads the in-memory config, rewrites the agents.json key, enqueues renderForInstance per instance, posts a config_revision audit row, and broadcasts an SSE agent_type_renamed event. Reserved-name set = the role keywords; idempotent replay returns a 200 no-op once the destination already exists.

Test plan

  • Round-trip: rows in every per-kind table flip to the new type; agents.json key rewritten; config reloaded; config_revision row landed.
  • Idempotency: second call with same (old, new) returns 200 no_op: true.
  • Reserved-name + clash + invalid-slug + 404 + invalid-JSON paths all return the expected status.
  • Atomicity: thrown mid-transaction → no partial rename observable.
  • Side effects: SSE agent_type_renamed broadcast + renderForInstance enqueued per instance.

Closes #671

`POST /agents/types/{old_name}/rename` rewrites every per-type column reference (agents.type plus agent_type on the six per-kind tables) inside one SQLite transaction, reloads the in-memory config, rewrites the agents.json key, enqueues `renderForInstance` per instance, posts a `config_revision` audit row, and broadcasts an SSE `agent_type_renamed` event. Reserved-name set = the role keywords; idempotent replay returns a 200 no-op once the destination already exists. ## Test plan - [x] Round-trip: rows in every per-kind table flip to the new type; agents.json key rewritten; config reloaded; config_revision row landed. - [x] Idempotency: second call with same (old, new) returns 200 `no_op: true`. - [x] Reserved-name + clash + invalid-slug + 404 + invalid-JSON paths all return the expected status. - [x] Atomicity: thrown mid-transaction → no partial rename observable. - [x] Side effects: SSE `agent_type_renamed` broadcast + `renderForInstance` enqueued per instance. Closes #671
feat(agents): WIZ-prereq-B transactional agent-type rename endpoint
All checks were successful
qa / dockerfile (pull_request) Successful in 4s
qa / qa (pull_request) Successful in 2m10s
11dc3232cb
`POST /agents/types/{old_name}/rename` rewrites every per-type column
reference (agents.type plus agent_type on the six per-kind tables) inside
one SQLite transaction, then reloads the in-memory config, rewrites the
top-level key in agents.json, enqueues `renderForInstance` for every
instance of the renamed type, posts a `config_revision` audit row, and
broadcasts an SSE `agent_type_renamed` event.

Reserved names = the role-keyword set (host / code-lead / code / review /
design / design-review). Idempotent on replay: a second call with the
same `(old, new)` pair lands as a 200 no-op once the destination type
already exists. 409 on a concurrent rename of the same source. Atomicity
covered by a test seam that throws inside the transaction; verified no
partial rename observable.

Closes #671

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
reviewer approved these changes 2026-05-01 21:20:47 +00:00
reviewer left a comment

CI green. All AC met: transaction covers all 7 tables, idempotent replay returns 200 no-op, reserved-name guard uses AGENT_ROLES verbatim, atomicity test covers rollback, SSE + render-queue side effects tested. artifact_id=0 / body_hash='' are acceptable sentinels for the synthetic type_rename revision row.

Nit (non-blocking): no test for the 409 in-flight race, but it's absent from the Tests AC so not required.

CI green. All AC met: transaction covers all 7 tables, idempotent replay returns 200 no-op, reserved-name guard uses `AGENT_ROLES` verbatim, atomicity test covers rollback, SSE + render-queue side effects tested. `artifact_id=0` / `body_hash=''` are acceptable sentinels for the synthetic `type_rename` revision row. Nit (non-blocking): no test for the 409 in-flight race, but it's absent from the Tests AC so not required.
code-lead deleted branch boss/671 2026-05-01 21:21:42 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks!689
No description provided.