Repository navigation
feat: apply the bundled built-in dashboard when importing a Bot - #36544
chenmingwei23 wants to merge 2 commits into
Conversation
…t card Red tests for an import card that adopts the bundle's built-in dashboard on the new Bot and takes that page back on Undo, only at the version it adopted: - the plan gets a dashboard apply step and a card-only DELETE undo step ahead of the Bot delete; both routes are hooked and write no memory line - Undo with a dashboard changed after the import is refused (409) and the page stays; an untouched one is removed before the Bot delete - the adopt and the removal tell open Dashboard tabs (dashboard_instance_changed); a refusal or a kept page does not - remove_adopted refuses another template or version, never follows a member directory swapped for a link, holds the instance lock, takes one path segment only, and leaves nothing but the lock file (history and preview go too) - where the directory walk cannot be pinned (native Windows) the Undo still completes, the Bot is deleted and the page stays - a template the catalog gives under another origin is neither applied nor removed; an Undo without a recorded adopted version leaves the page out - a plain Bot delete and a create Undo leave a dashboard instance alone - a card stored before this step still undoes
An import card whose bundle names a built-in dashboard the receiver ships
now ends its plan with a card-only step that adopts that page on the new Bot,
and the card's Undo takes it back before it deletes the Bot.
- POST/DELETE /api/members/{slug}/dashboard/template (owner-only, card-only,
shipped templates only); POST answers the adopted instance_version; both
tell open Dashboard tabs (dashboard_instance_changed) when the page changed
- instance.remove_adopted removes the page only while the record still names
the adopted template at the adopted version, under the instance lock,
through directory descriptors pinned with O_NOFOLLOW (no rmtree by name);
the record, versions, staged preview and history file all go, so a later
adopt on the slug starts again at version 1
- where the walk cannot be pinned (native Windows) it raises PinUnsupported and
the DELETE answers 200 with kept: true, so the Undo completes and the page
stays, as after a plain Bot delete; the refusals and the kept case log one
line each (no slug)
- the dashboard {template_id, instance_version} joins the import card's
fingerprint (state read, after-write check, resumed-undo check); a card
stored before this step has no such key and is not compared
- deleting a Bot on its own does not touch its dashboard
- pins: MCP route table (354 rows), two boot chain-order pins, facade
manifests for the new helpers; feature-map row and RFC note
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: the dashboard step and its Undo follow the import card's existing card-only, owner-only step pattern, and Undo only removes the page at the version the step adopted. Notes
[DESIGN-REVIEWED] f57a6e2 Description read[DESCRIPTION-READ] 82ce2e14fe4ceea36d7e4e4c4221de8d250468b8f300ee102eb0de06a89ad6a4 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) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Every item has a named harm (#35701, the accepted What this change shipsInventory (8 items) — 8 justifiedIntent: when the receiver imports a shared Bot, it arrives with the built-in dashboard the sender chose, and the import card's Undo takes it back. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] f57a6e2 Description read[DESCRIPTION-READ] b35947b94ed294ada060c8771c662abab837677f9ab48b8a105f6ef641dc0d43 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings. Notes:
[OPUS-REVIEWED] f57a6e2 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — 🔴 changes requested (blocking)GPT 6.1 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/dashboard_templates/instance.py:1277 -- Pin the versions directory before deleting the live dashboard
[BLOCK-MERGE] f57a6e2 Adjudication (Opus 5.5) — is blocking on each finding proportionate?No adjudicable findings were listed (total=0). I'm flagging the one fenced finding (F1) instead of upholding it as written, but it keeps blocking either way. F1: The defect is real. At 🏷️ Fenced finding(s) machine-flagged as likely edge caseThe security fence keeps these findings blocking regardless of adjudication; the only clearance path is a human override. The annotate-only pass judged the condition combination each one requires extreme, and pre-drafted the override rationale below. A repository writer must independently verify a rationale before posting it — it is machine-authored, and a wrong override on a security-class finding ships exactly the class the fence exists to stop.
Replace False positive or not applicable? A repository writer can comment: |
|
Superseded by #36569: a new branch from current main that folds in the GPT 6.1 finding (pin the versions folder before the first delete), the flake-ratchet fix and the review's log assertions, in two commits. Closing this PR; the branch is kept. |
Draft. Replaces #36499, #36469 and #36016 (each stays untouched by this PR).
Ticket: none
Problem / Motivation
Goal: Importing a Bot file that names a built-in dashboard sets that dashboard on the new Bot in the same import card, and the card's Undo takes it back.
Today the card shows a Dashboard row and lists the page under "Not brought over", so the receiver must open the new Bot's Dashboard tab and pick the same built-in page by hand. Follow-up issue: Fixes #35701.
Why it matters
A shared Bot arrives looking different from the one that was sent. The sender chose that page on purpose, and the receiver has no hint which page to pick.
Not a goal
user:) dashboards: still refused at import, unchanged.builtin:<id>text as before.What changed (motivation -> approach -> change)
The import plan had no dashboard step, so the row was display-only. Approach: reuse the existing owner-only, card-only step shape (as the import-files step) for both the apply and the Undo, instead of widening any agent-facing route or changing Bot deletion.
crewmate_bundle.py:dashboardTemplateis added to "not imported" only when the receiver's shipped catalog lacks that id.change_card_catalog_plans.py: when the page is applied, the plan gets aPOST /api/members/{slug}/dashboard/templatestep after the files step and before the crons; the Undo gets aDELETEof the same path, placed before the files, rules and Bot steps, only when the dashboard step was applied and answered the version it adopted.handlers/member_import_dashboard.py: owner-only, answers only an admitted import-card step, accepts only a shipped template. POST callsinstance.adoptand returnsinstance_version; DELETE callsinstance.remove_adopted. Both senddashboard_instance_changedwhen the page changed (not on a refusal, not when the page is kept). Registered inmcp_routes.py, listed inHOOKED_ROUTES(no memory line) and armed by the existing card hook inchange_cards.py.instance.remove_adopted: holds the instance lock, removes the page only while the record still names the adopted template at the adopted version, and removes the record, the staged preview, the history file and every retained version through directory descriptors pinned oneO_NOFOLLOWstep at a time from the data home (never by name, neverrmtree). A link anywhere on the way is refused and nothing outside is touched. Only the empty directory and its lock file stay, so a later adopt on the slug starts again at version 1 with no row of the removed import.O_NOFOLLOW),remove_adoptedraisesPinUnsupported; the DELETE handler answers200 {"ok": true, "kept": true}and leaves the page, as a plain Bot delete does, so the Undo never refuses as a whole.change_cards_readers.py: the dashboard{template_id, instance_version}is part of the import card's fingerprint in_import_state,_import_after_is_written(the step response's version must equal the after-read) andresumed_undo_is_stale. A page changed after the import makes Undo refuse with 409 and a message that says what to do. A card stored before this step has nodashboardkey in its after-state and is not compared.test_dashboard_server_composition_contract_reach.pyon this base; facade manifests for the new helpers.Review findings carried over from #36499, #36469 and #36016:
instance.py, Opus 5.5 and GPT 6.1 on feat: apply the bundled built-in dashboard when importing a Bot #36469): fixed, see the Windows bullet; testtest_undo_completes_and_keeps_the_page_where_the_walk_cannot_be_pinned.dashboard_instance_changedafter adopt (member_import_dashboard.py, GPT 6.1 on feat: apply the bundled built-in dashboard when importing a Bot #36499) and after the removal (MKT review of feat: apply the bundled built-in dashboard when importing a Bot #36499): fixed.history.jsonbehind (MKT review of feat: apply the bundled built-in dashboard when importing a Bot #36499): fixed.sandbox_argv.py(GPT 6.1 on feat: apply the bundled built-in dashboard when importing a Bot #36469): not applicable, it was base drift of an old branch; this diff touches 14 files, none of them that one.Non-blocking points from the review of #36499:
remove_adopteddocstring says. Recording the pre-adopt version or refusing the apply step would be a second behaviour change that needs its own design; it stays accepted.logger.infoline (no slug). A card line saying the page stays: not done, it is a UI text change outside this PR's scope.adoptitself is not pinned, so a symlinkedmembers/<slug>ordashboardlets the POST write through the link: pre-existing, the other dashboard routes on main do the same; not changed here.test_remove_adopted_holds_the_instance_lock), the staged-preview and history removal, the not-shipped-origin refusal on both routes, an Undo without a recorded version, the origin check in_ships_builtin, and the one-path-segment guard.Backwards compatibility
Compatible: nothing that works today stops working. The new routes and plan steps are additive, deleting a Bot does not touch its dashboard (as before), and an import card stored before this step still undoes: it has no dashboard role and no
dashboardfingerprint to compare.Removes nothing: the only removal is of the page this card adopted, and only at the version it adopted.
Tests
Commit 1 holds only the tests; run against main's code (before commit 2) it gives 27 failed and 36 passed across
test_crewmate_import_dashboard.pyandtest_change_card_crewmate_import.py(the 4 that pass are guards, see below). Commit 2 holds the change and the pin updates.Local runs (pytest -n0, one file at a time, under 2 minutes each):
test_crewmate_import_dashboard.py+test_change_card_crewmate_import.py: without the change 27 failed / 36 passed; with it all pass (test_crewmate_import_dashboard.py: 30 passed). The 4 tests that pass on main are guards for behaviour that must not change: a card stored before this step, a plain Bot delete and a create Undo leaving the dashboard alone, an id the receiver does not ship, and a page the catalog gives under another origin.test_change_card*,test_crewmate_*,test_dashboard_instance*,test_dashboard_templates*, template flow and manifest, the composition contract files including the pins, page offer, agent create template, b64 routes, client route contract, member goals cards, work-ledger facade).test_dashboard_server_composition_contract_reach.py: 17 passed on this base (354 MCP route rows, digest unchanged, chain pins +2_deferredeach).test_facade_mirror_guards.pydoes not finish in 2 minutes as one file, so each of its 31 tests was run alone: all passed, including the manifest check and the tree scans that look at test patches.New in
test/test_crewmate_import_dashboard.py:test_a_shipped_builtin_dashboard_gets_an_apply_step_and_leaves_not_brought_over,test_a_builtin_id_the_receiver_does_not_ship_stays_out,test_the_step_is_in_the_import_undo_roles,test_the_route_is_hooked_and_writes_no_memory_line(POST and DELETE)test_the_card_step_sets_the_dashboard_on_the_new_bot(alsoinstance_version),test_only_the_card_step_and_only_a_shipped_template_are_accepted,test_the_adopt_tells_open_dashboard_tabs_and_a_refusal_does_nottest_undo_removes_an_untouched_dashboard_before_the_bot_delete,test_undo_with_an_edited_dashboard_is_refused_and_the_page_stays,test_undo_completes_and_keeps_the_page_where_the_walk_cannot_be_pinned,test_the_undo_route_is_card_only_and_names_a_shipped_template,test_the_undo_route_tells_open_tabs_only_when_it_removed_the_page,test_a_template_that_is_not_shipped_is_refused_by_both_routestest_remove_adopted_refuses_another_template_or_version_and_removes_nothing,test_remove_adopted_never_follows_a_member_directory_swapped_for_a_link,test_remove_adopted_leaves_only_the_lock_and_a_later_adopt_starts_clean,test_remove_adopted_holds_the_instance_lock,test_remove_adopted_takes_one_path_segment_onlytest_a_resumed_undo_compares_the_dashboard_only_when_the_card_recorded_one,test_an_edit_saved_while_the_import_ran_is_never_the_undo_baseline,test_an_undo_without_a_recorded_adopted_version_leaves_the_page_out_of_its_plantest_an_old_import_card_without_a_dashboard_step_still_undoes,test_a_plain_bot_delete_and_a_create_undo_leave_the_dashboard,test_a_page_the_catalog_gives_under_another_origin_is_not_appliedAlso:
test_import_shares_the_create_state_read_and_partial_lineasserts the "its dashboard" partial line. Tests that need a pinned directory walk are skipped where the platform lacks it.Manual verification
N/A - unit coverage sufficient: the route, the plan, the Undo and the removal are exercised end to end in the tests above. The card text changes in one place (a shipped page no longer appears under "Not brought over"); it is the existing row renderer, with no new component, so no screenshot is attached.
Related Issues
Fixes #35701
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.