Repository navigation
feat(workflows): remove a saved workflow from the library - #19040
jeeshofone wants to merge 1 commit into
Conversation
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS The committed screenshots cover every new control and state, so nothing blocks. No blind first-time reader has seen them, because this is a fork. Pushing the branch to this repository runs that pass. Notes
[UX-REVIEWED] 5423c59 Description read[DESCRIPTION-READ] b7449b126957038ea94636ea2a7da2298ddd7837a10db8f6bc6ab3374dfda2ec That sha256 names everything this verdict read: the PR description, plus the 27 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: a tombstone keeps lineage working and reserves refs so a saved Notes
[DESIGN-REVIEWED] 5423c59 Description read[DESCRIPTION-READ] 1ad5b20f509bb6e3e03d7f02c304da4854ca18fef5de46d1824cfc3f124eda41 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Removal fills a real gap. The rest is machinery for hand-placed library files, which agents cannot write. It is heavy but reversible, so these are notes. Notes
What this change shipsInventory (8 items) — 4 justifiedIntent: a dashboard user removes a stale saved workflow while drafts and runs adapted from it keep their lineage. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 5423c59 Description read[DESCRIPTION-READ] 604c5f65d9ec27061478c206077294effd7a1a0c64b715faca3205b14f0cc40c That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
6054055 to
d809070
Compare
|
|
|
|
|
|
|
|
Delta 6054055 -> d809070 (one commit, rebased onto main f071625):
Local on the pushed head: black/isort/flake8, mypy src 0 errors, scripts/check_* guards, ratchets + facade + error-code contract, 1274 neighbour tests, boot smoke, docs-lint, website tsc/eslint/i18n/ui-index, full vitest (47985 passed, on the pre-rebase base; re-ran tsc + affected suites after the rebase). |
d809070 to
0bba3fe
Compare
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HOLD at 0444a4d. The upheld GPT finding on 630bf0f is answered: advertised commands now come from the same per-read ref index that resolution uses. The other current-head lane notes have replies, all five AI lanes pass on this head, and every check is green. What still blocks, and what clears each:
Our earlier change request at f66ca8b is superseded by this hold. — crew-pr-reviewer (r131) |
|
Head Rebase. The only textual conflict was the MCP route-table pin in
Evidence. The capture script passes at this head, and every frame asserts its state. The frames match the committed ones apart from editor load timing, with one exception: on the new base the disabled Remove in the two Gates on this head. Backend: the related pytest set (1871 files) plus every |
|
|
|
HOLD at ae6c24d for human review. The r131 points are answered. The rebase onto main clears the conflict in What still holds it: the PR adds an owner-gated — crew-pr-reviewer (r133) |
|
Head |
A saved workflow could only be removed by moving its JSON file out of the
library folder from a terminal, which also broke every draft and run
adapted from it ("workflow lineage does not resolve to a saved revision").
Removal is now a tombstone written under the library's cross-process lock,
onto every file that holds a live copy of the record, without re-running
the save-time source gate. A removed definition leaves list, search, slug
and id lookup, /workflow, workflow_library_list, saved runs and the
authoring examples, and still resolves by id for lineage, so adapted
drafts and runs keep saving. A revision is written to the file its
record was read from, so a save never replaces a tombstone of the same
id.
The id and the slug a record holds when it is removed are reserved for
good, whether a later ref matches as an id or as a slug; a slug given up
by an earlier rename is not covered (kirodotdev#23680). Every read by ref refuses
the id and the slug of a removed record before matching, and slug
allocation never hands out an id or slug on disk. One index per library
read decides which record each ref reaches, and every list offers a
record only under a ref that reaches it: a slug or id that a removed
record holds, or that another record answers to first, is not offered.
With neither reaching it, the library lists it as having no slash
command and every other list leaves it out.
One owner-only DELETE /api/workflows/definitions/{ref} route backs a
Remove action with a confirmation in Customize > Workflows. No agent, MCP
or CLI path can remove a saved workflow. Save and Remove send the id the
editor shows as expected_id; a ref that now resolves to a different
workflow answers 409, and nothing is written or removed.
Fixes kirodotdev#18998
Integration (in-process gateway) on First-pass check: R1-R8 OK. |
|
Moved to #27528: same commits, now on a branch of this repo so CI uses the CodeBuild fleet. Review history stays here. |
Problem / Motivation
Goal: A user can remove a saved workflow from the library in the dashboard, and everything that was adapted from it keeps working.
Once a workflow is saved to the library, nothing in Kiro Crew can remove it. A stale workflow stays in Customize > Workflows, still runs from
/workflow <slug>, is offered to agents byworkflow_library_list, and seeds authoring. The only way out is moving its JSON file out of the library folder, which breaks the lineage of every draft or run adapted from it.Why it matters
Stale workflows stay runnable and steer agents; the workaround breaks lineage.
Not a goal
What changed (motivation → approach → change)
Removal is a tombstone, not a hard delete:
workflows/library.py: removal writes a tombstone (every revision kept) under the library's cross-process lock. A removed definition leaves every list, lookup and run path and the authoring examples. The tombstone addsremoved_at(and a v1 record's defaultformat), skips re-gating stored revisions, and replaces every file holding a live copy, so a record saved under older redaction rules or placed by hand is removed too. A revision lands in the file its record came from, never on a same-id tombstone.workflows/library.pykeeps one set, the id and slug of every removed record: every read by ref refuses a ref in it (ids match before slugs), and slug allocation never hands out an id or slug on disk. One index per read decides which record each ref reaches, and every list offers a record only under a ref that reaches it: a record's own slug or id that a removed record holds, or that another record answers to first (a hand-placed record whose id is its slug), is listed inshadowed_refs(computed, never stored) and not offered. With neither reaching it, the dashboard shows No slash command with actions off, and/workflow(chat_turn/slash_commands.py) andworkflow_library_list(mcp_tools/workflows.py) leave it out; the latter never prints an id that does not reach it. Dashboard requests go to the id, else the slug, whichever reaches the record. An unreadable tombstone releases its refs and is logged as a warning.workflows/service.py: lineage resolution reads tombstoned definitions and checks every copy of the parent's id, so drafts and runs adapted from a removed workflow keep saving; it never goes through the ref refusal. A run of a removed workflow says why it can't be saved.dashboard/handlers/workflows.py,server_runtime/mcp_routes.py: one owner-onlyDELETE /api/workflows/definitions/{ref}route, behind the same owner guard as the sibling PATCH route, with one audit event per removal. Unknown or already-removed refs answer 404. PATCH and DELETE take an optionalexpected_id: a ref that now reaches another workflow answers 409, and nothing changes.WorkflowLibraryTab.tsx,api/client/workflows.ts): a Remove action, right-aligned and apart from Save. The confirmation leads with a bold "Kiro Crew can't undo this.", then says, with the real slug, what stops and what keeps working. Above the editor, behind a divider, sits the outcome: a status line naming the removed workflow, orErrorNotice(cause in a collapsedErrorDetails) and a "Try removing again" button. The retry is offered, by its current ref, only while the latest read gives the workflow one. Save and Remove send the shown id; a 404 or 409 re-reads the library afresh and drops the row only if the record is gone. Once any removal settles, failed ones included, the tab reads the library again, so no row keeps a ref the removal stopped reaching. The filter matches the shown ref, and a workflow no ref reaches has read-only fields. Strings in every catalog.docs/workflows.md(the/workflowuser doc).Why not a hard delete: drafts and runs name it by id. Why not release the slug: a saved
/workflow <slug>would run whatever takes it next.Backwards compatibility
Compatible: nothing changes until a user removes a workflow. The dashboard's Run sends the workflow's id, which the run route has always accepted.
Reader: src/kiro_crew/workflows/library.py:list -- crew page -- removed definitions are excluded by design; test_removed_definition_is_absent_from_every_user_facing_read
Reader: src/kiro_crew/workflows/service.py:save_definition -- chat -- a removed parent still resolves by id; test_a_draft_adapted_from_a_removed_workflow_still_saves, test_a_run_adapted_from_a_removed_workflow_still_promotes
Reader: src/kiro_crew/workflows/library.py:get -- chat -- a ref a removed record holds, as an id or a slug, answers not found on get, the GET, PATCH, DELETE and run routes,
/workflowandworkflow_run, and a record carrying it still answers by its other ref; test_definition_routes_on_a_claimed_removed_slug, test_a_hand_written_id_equal_to_a_removed_slug_answers_not_found_by_it, test_routes_and_tools_refuse_a_hand_written_id_equal_to_a_removed_slug, test_a_record_whose_id_is_reserved_is_changed_and_removed_by_its_slugReader: src/kiro_crew/workflows/library.py:get -- cron -- a saved
/workflow <slug>answers not found after a removal and never runs a workflow saved later under that slug or id; test_removed_workflow_no_longer_lists_runs_or_seeds_authoring, test_a_removed_slug_stays_dead_when_a_hand_written_record_claims_it, test_a_new_slug_never_equals_an_id_on_disk, test_a_hand_written_slug_equal_to_a_removed_id_answers_not_found_by_it, test_a_restored_copy_of_a_removed_record_is_reached_by_no_refTests
test/test_workflows_library_remove.py: the tombstone is the stored record plusremoved_at(and a v1 record'sformat), field for field (mutations -> red); absent from every user-facing read; the slug stays reserved for create and rename (mutation -> red); a record saved under older redaction rules is removable (mutation -> red); every copy of one id, under any file name, is gone from list/get//workflow/run (mutation -> red); a copy a failed removal leaves live answers only to its own free slug (mutation -> red); a removal waits for an in-flight revision and keeps it (mutation -> red); adapted drafts and runs still save and promote, also from a revision only a later copy of the parent holds (old code -> red); a record carrying a removed record's slug or id answers not found by that ref on every reader and route, and by its other ref everywhere; one holding both is listed but reached by nothing, and the chat and agent lists leave it out; a restored tombstone copy is reached by nothing; a PATCH through a restored copy's free slug leaves the same id's tombstone intact, keeps the retired slug refused and gives a create the next number, and a record under another file name is revised in place (mutation -> red); a DELETE or PATCH by a slug that moved to another workflow answers 409 with the shownexpected_idand changes nothing, a malformed one is a 400, and a copy left beside its tombstone is removed in its own file (mutations -> red); the agent list never prints a reserved id; a new slug never equals an id on disk, live or removed, and a hand-written slug equal to a removed id answers not found (old code -> red); a free id beats another record's slug in either folder order, and the other record is listed under its own id in every list and that command runs it (old code and mutation -> red); of two records sharing a slug only the one it reaches is offered it; a revision offers the refs its own write leaves reaching it (mutation -> red); lineage still resolves removed and reserved-id parents;shadowed_refsis never stored and a stored copy is ignored; a run of a removed workflow says why it can't be saved; an unreadable file is warned about once until it changes, and again if it breaks after reading;workflow_library_listnever prints/workflowor/workflow None(mutations -> red).test_workflow_definition_handlers.py,test_r7_owner_gate_*: DELETE tombstones, audits, is owner-gated; unknown/removed 404; write failure has a code.test_slash_command_no_channel.py: on KAS the/menu keeps/workflowand leaves harness commands out, and/workflowsent through the KAS gate offers and starts a workflow whose slug a removed one holds by its id, its slug answers not found, the harness never gets the text and no KAS notice is shown (a mutation on either side -> red).website/src/test/WorkflowLibraryTab.test.tsx: the confirmation's slug bullet, real slug, no suffix; the row drops only after the server confirms; after a removal, after a failed one that tombstoned one of two copies, and after a second removal confirmed while the first one's re-read is in flight, the library is read again and a survivor whose id the removed slug now holds runs and saves by its own slug (mutations -> red); a list read in flight when the removal lands cannot bring the row back (old code -> red); switching or starting a new workflow mid-removal keeps edits, leaves the other Remove unbusy (mutation -> red) and still shows a late failure; a 500 renders ErrorNotice, cause behind a collapsed Details, then a retry it describes (mutation -> red) that re-sends with no second dialog; a pending retry shows no failure line (mutation -> red) and keeps focus; focus moves on success; no stale failure; a 404 drops the row only when a fresh read no longer has it, else shows the failure, and a retry goes to the ref that read gives (mutation -> red); Run, Save and Remove go to the id, else the slug when the id does not reach the workflow, and are off when neither works, with No slash command, a note and read-only fields; Save and Remove send the shown id, a Remove 409 re-reads the library and keeps the row, a 404 re-read does not join a list read in flight, the retry is not offered once no ref reaches the workflow, and the filter finds a row by the ref it shows (mutations -> red); a slug that does not reach the workflow, held by a removed one or another workflow's id, shows/workflow <id>in the row, the header and the confirmation, and Run goes to the id (old code -> red).Run locally on main 278fc2d. Backend: the related pytest set from
scripts/run_scoped_tests.py(1871 files) plus everytest_*ratchet*andtest_ws_event_scoping*file. That covers this PR's tests, the dashboard composition contract (the MCP route table counts main's new route and the DELETE route, 314 rows) and the owner-gate, error-code and event-scoping contracts. Frontend: the related vitest set (2503 files) withI18N_BASE_REF,tsc, eslint,i18n:checkandlint:i18nwithI18N_BASE_REF, andi18n:pseudo, which leavesen-XA.jsonunchanged. Gates: all 24 inpre_push_gate.py, among them black, isort, flake8,mypy src/kiro_crew/, docs, feature-map and comment-history. The capture script passes, and its frames each assert their state. Every test that failed in these runs fails the same way on main 278fc2d on this machine, and none is in a file this PR touches.Manual verification
Every state, light and dark, asserted by the capture script.
Screenshots / video
All variants
Related Issues
Fixes #18998
Checklist
Contribution License Agreement
Contributed under the project's Apache-2.0 license.