Skip to content

feat: apply the bundled built-in dashboard when importing a Bot - #36569

Merged
bolichen97 merged 2 commits into
mainfrom
crewmate-import-dashboard-undo-4
Nov 17, 2026
Merged

bolichen97 merged 2 commits into
mainfrom
crewmate-import-dashboard-undo-4

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Draft. Replaces #36544, #36499, #36469 and #36016 (each stays untouched by this PR). The two commits of this PR were rewritten once (force-with-lease on this draft branch, as the repository owner allows for a draft) to fold in the review findings below. They were rewritten again to keep an existing dashboard on import, per the review (option: skip the adopt when the slug already holds a page), and once more to keep a record this build cannot read as well (a newer-schema record, a record with no template), by using the repository's existing instance_adopt.adopt_if_empty instead of a second emptiness test. The last rewrite is also rebased onto a main that carries #36652: the previous head failed test_mate_conductor_parity.py::test_every_shared_rule_has_an_ultra_counterpart_or_a_named_gap (the goal_plan rule), a test this PR does not touch.

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

  • Custom (user:) dashboards: still refused at import, unchanged.
  • A built-in id the receiver does not ship: still listed under "Not brought over".
  • Any change to what a bundle carries or to export.
  • Any change to what deleting a Bot removes: a plain Bot delete leaves its dashboard instance, as today.
  • A display-name formatter for the Dashboard row: the card still shows the 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: dashboardTemplate is 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 a POST /api/members/{slug}/dashboard/template step after the files step and before the crons; the Undo gets a DELETE of the same path, placed before the files, rules and Bot steps, only when the dashboard step was applied and answered the version it adopted.
  • New handlers/member_import_dashboard.py: owner-only, answers only an admitted import-card step, accepts only a shipped template. POST calls instance_adopt.adopt_if_empty and returns instance_version; DELETE calls instance.remove_adopted. Both send dashboard_instance_changed when the page changed (not on a refusal, not when the page is kept). Registered in mcp_routes.py, listed in HOOKED_ROUTES (no memory line) and armed by the existing card hook in change_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 one O_NOFOLLOW step at a time from the data home (never by name, never rmtree). 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. It can only ever see the history the import itself began, because the step never adopts over an existing page.
  • Where the directory walk cannot be pinned (native Windows has no O_NOFOLLOW), remove_adopted raises PinUnsupported; the DELETE handler answers 200 {"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) and resumed_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 no dashboard key in its after-state and is not compared.
  • A failed dashboard step is named in the partial summary ("its dashboard").
  • Pins: MCP route table (354 rows) and the two boot chain-order pins, recomputed by running test_dashboard_server_composition_contract_reach.py on this base; facade manifests for the new helpers.
  • Docs: feature-map row (resolved against main's current text) and an RFC note.

Review findings carried over from #36499, #36469 and #36016:

Non-blocking points from the review of #36499:

  • Import onto a slug that already has a dashboard (review of this PR: the dashboard step could replace a page the owner already has, with no consent; and Undo then removed that page's retained versions): fixed. The dashboard step adopts only onto an empty slug (instance_adopt.adopt_if_empty, the existing helper: check and write under one lock, empty means no stored record at all). When the slug already holds anything, a page or a record this build cannot read (a newer-schema record, a record with no template; found by the reviewer of the previous head), it adopts nothing and leaves the stored bytes untouched, answers 200 with kept_existing and no instance_version, sends no tab update, and the Undo plan, which leaves the page out when no version was recorded, has nothing of the import's to remove: the page and all its versions stay. The card result line stays the generic "Done" line and does not claim a dashboard was applied. Tests: test_the_adopt_step_keeps_a_page_the_slug_already_holds, test_an_import_onto_a_slug_with_a_page_keeps_it_and_its_undo_leaves_it, test_the_adopt_step_keeps_a_record_this_build_cannot_read and test_an_import_onto_an_unreadable_record_keeps_it_and_its_undo_leaves_it (both for a newer schema and for no template, the record bytes compared before and after), test_the_adopt_step_keeps_a_page_from_an_earlier_import (version 1), test_the_adopt_step_that_keeps_what_the_slug_holds_logs_one_plain_line; the empty-slug apply and Undo tests are unchanged.
  • No pinned walk: done, one logger.info line (no slug). A card line saying the page stays: not done, UI wording is out of scope for this PR (the result line stays the generic one and claims no dashboard).
  • The three 409 refusals: done, each logs one line (no slug).
  • adopt itself is not pinned, so a symlinked members/<slug> or dashboard lets the POST write through the link: pre-existing, the other dashboard routes on main do the same; not changed here.
  • Surviving mutations: added tests for the instance lock (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 dashboard fingerprint 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 42 failed and 36 passed across test_crewmate_import_dashboard.py and test_change_card_crewmate_import.py (4 of the 36 tests in the first file pass on main: they 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 42 failed / 36 passed; with it all pass (test_crewmate_import_dashboard.py: 45 passed, 78 with the card test file); the unreadable-record tests (both shapes, handler and card flow), the kept-line log test and the refused-adopt test also fail against the previous head of this PR (6 failed / 72 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.
  • Touched area, each file alone: 53 files, 2394 tests, all passed (every 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, and test_flake_pattern_ratchet.py). test_dashboard_server_composition_contract_reach.py passes on this base (354 MCP route rows, digest unchanged, chain pins +2 _deferred each). scripts/docs-lint.sh exits 0; black, isort and flake8 are clean on the changed files.
  • test_facade_mirror_guards.py does not finish in 2 minutes as one file, so each of its tests is run alone: all 31 passed, none failed, on the final tree. Local mypy on the changed modules (Python 3.14) shows one error in cli_gateway_boot.py:126 (asyncio.PidfdChildWatcher), outside this diff; CI uses 3.12. The no-pin simulation (pinned directory walk forced off) gives 69 passed / 9 skipped for the two import test files.

New in test/test_crewmate_import_dashboard.py:

  • plan and route shape: 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)
  • adopt: test_the_card_step_sets_the_dashboard_on_the_new_bot (also instance_version), test_only_the_card_step_and_only_a_shipped_template_are_accepted, test_the_adopt_tells_open_dashboard_tabs_and_a_refusal_does_not
  • Undo: test_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_routes
  • logs: test_a_refused_adopt_logs_one_plain_line, test_a_changed_page_logs_one_plain_line, test_a_kept_page_logs_one_plain_line, test_a_refused_removal_logs_one_plain_line (each drops out when its log line is removed)
  • removal: test_a_removal_that_stops_half_way_can_be_retried, test_remove_adopted_pins_the_versions_folder_before_it_deletes_anything, test_a_refused_versions_folder_is_a_409_not_a_500, test_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_only
  • fingerprint: test_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_plan
  • kept page: test_adopt_if_empty_adopts_an_empty_slug_and_keeps_a_page_it_finds, test_the_adopt_step_keeps_a_page_the_slug_already_holds, test_an_import_onto_a_slug_with_a_page_keeps_it_and_its_undo_leaves_it
  • old and neighbouring behaviour: test_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_applied

Also: test_import_shares_the_create_state_read_and_partial_line asserts 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision b551187a3fdc9b5938a29f78ff2e13498f568d9e touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of b551187a3fdc9b5938a29f78ff2e13498f568d9e — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the step reuses the existing owner-only, card-only import-step shape, adopts only into an empty slot, and Undo is fingerprinted and fails safe (keeps the page) where it cannot pin the removal walk.

Notes

  • The new pinned-walk deletion in instance_remove.py is a second removal primitive inside dashboard_templates/. If a later change needs to remove an instance (for example on Bot delete), it should go through remove_adopted and not add a third path.
  • _ships_builtin treats any catalog read failure as "not shipped". If the catalog breaks briefly, the page lands under "Not brought over" and nothing logs why.

[DESIGN-REVIEWED] b551187

Description read

[DESCRIPTION-READ] 6eea48c0d8a8736dc1da184491c9323f06552cb76fa432cc311a851c73b40031

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of b551187a3fdc9b5938a29f78ff2e13498f568d9e — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Fixes #35701. The base RFC already covers the shape: rfc-crewmate-share is partial, and its card table reads "Dashboard | the builtin: template, or the default". No item duplicates an existing mechanism.

What this change ships

Inventory (10 items) — 9 justified

Intent: when someone imports a shared Bot, it should arrive with the built-in dashboard the sender chose, and Undo should take that dashboard back. This is an ADDITION.

  1. Importing a Bot now sets the bundled built-in dashboard on the new Bot. — justified
  2. A shipped built-in page no longer appears under "Not brought over". — justified
  3. The card's Undo removes the page it adopted, with its versions, history and preview. — justified
  4. A slug that already holds a dashboard keeps it, and Undo leaves it alone. — justified
  5. Undo refuses with guidance when the page changed after the import. — justified
  6. On native Windows, Undo keeps the page and finishes the rest. — justified
  7. New owner-only, card-only routes POST/DELETE /api/members/{slug}/dashboard/template. — justified
  8. Open Dashboard tabs reload after the adopt or the removal. — justified
  9. The partial summary names "its dashboard" when that step fails. — justified
  10. adopt_if_empty now treats an unparseable record as occupied, and Crew Mode's board adopt gets the same change (dashboard_agentic.py:1853). — undeclared: the outcome stays False, only the warning log goes away

[FIRST-PRINCIPLES-REVIEWED] b551187

Description read

[DESCRIPTION-READ] 4402396e1c715dd5d8d2d68441dcfbaf2f44ed50f5031ca90db63435b8afede8

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed b551187a3fdc9b5938a29f78ff2e13498f568d9e — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] b551187

Verdict parsed from the review's SHA-scoped output markers for commit b551187a3fdc9b5938a29f78ff2e13498f568d9e.

False positive or not applicable? A repository writer can comment:
/ai-review override fable b551187a3fdc9b5938a29f78ff2e13498f568d9e false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of b551187a3fdc9b5938a29f78ff2e13498f568d9e and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b551187

False positive or not applicable? A repository writer can comment:
/ai-review override gpt b551187a3fdc9b5938a29f78ff2e13498f568d9e false-positive: <reason, 20 to 500 characters>

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

VERDICT CHANGES at ce1f783

Non-author review, read-only. Head read by GraphQL at 2026-11-13T10:55:30Z (DRAFT, 2 commits, base b9ddf79). I ran the tests and mutation checks locally (Python 3.12.16, CI pins, pytest -n 0).

One blocking finding, everything else is fixed.

BLOCKING

  1. Two new tests fail where there is no pinned directory walk (native Windows). This is the likely cause of the red "New-test stability (windows-latest)" check and will redden Backend Tests (Windows). Reproduced locally by running test/test_crewmate_import_dashboard.py with pinned_fs.supports_pinned_walk patched to False: 2 failed, 27 passed, 7 skipped.
    • test/test_crewmate_import_dashboard.py:499 (test_the_undo_route_tells_open_tabs_only_when_it_removed_the_page): the first DELETE (instance_version 7, "the page moved on") expects 409 and no broadcast. Without the pinned walk remove_adopted raises PinUnsupported before the version compare and the route answers 200 {"kept": true}. assert (200 == 409 ...). The supports_pinned_walk guard covers only the second block.
    • :640 (test_a_changed_page_logs_one_plain_line): no needs_pinned_walk mark; expects 409 plus the "page changed" log line, gets 200 assert 200 == 409.
      Fix is in the tests only: mark both @needs_pinned_walk, or move the stale request inside the guard. The production behaviour (Windows keeps the page) is as designed. The PR body says "Tests that need a pinned directory walk are skipped where the platform lacks it"; that is not true for these two.

NON-BLOCKING

  1. instance.py remove_adopted (about :1290-1303) unlinks instance.json first, then preview, history and versions. If a later unlink fails (OSError), the record is already gone: the route answers 409 and a retry returns False ("changed") forever while the Bot stays. Rare; unlinking the record last, or treating a missing record with leftovers as removable, would close it. Read only, no failure injection run.
  2. Import onto a slug that already has a dashboard: Undo removes every retained version of that older page too. Not done by design, stated in the docstring.
  3. Windows: the page is kept and the card shows no line saying so (a log line exists). Not done, UI out of scope as stated.
  4. adopt() itself is not pinned (pre-existing): a linked members/ or dashboard path is written through by the new POST step as by main's own routes.

CHECKED AT THIS HEAD

  • Broadcast: dashboard_instance_changed {"slug"} is sent after adopt (POST) and after a removed Undo only; not on refusal, not on keep. FIXED. Mutations: no broadcast in POST fails :160 (assert [] == [('dashboard_instance_changed', {'slug': 'scout'})]); none in DELETE fails :503; broadcast on a refused Undo fails :499 side of that test.
  • history.json and preview.json are unlinked; only .lock stays; a later adopt starts at version 1 with one history row. FIXED. Mutations keeping preview.json or history.json fail :457 (assert ['preview.json'] == [] / ['history.json'] == []).
  • GPT 6.1's order finding: versions/ is opened pinned before the first unlink, a link there gives a 409 with nothing deleted. FIXED. Mutation that moves the open after the first unlink fails test_remove_adopted_pins_the_versions_folder_before_it_deletes_anything (:569).
  • Log lines: three constant INFO lines, no slug, path or template id. Dropping any one fails its caplog test (:601).
  • Undo after an edit is refused (409) before any step; the lock is covered (no lock fails :474 DID NOT RAISE); the slug-segment guard, builtin-origin check, _ships_builtin origin check and undo-without-version are all covered. No path traversal reachable: bad ids are refused by validation, the handler resolves the template from the shipped catalog only.
  • Delete racing adopt: not reachable (no forget; plain Bot delete leaves the page; remove_adopted and adopt serialize on .lock, which a test now proves).
  • Pins on this base: routes 354, new digest, boot-chain pins; they pass.
  • Naming rule: no new product-name literal in prose, docs rows or messages.

TESTS (python 3.12.16, CI pins, -p no:cacheprovider -n 0)

  • test/test_crewmate_import_dashboard.py: 36 passed, 4.0 s (Linux).
  • test_dashboard_server_composition_contract_reach.py + test_change_card_crewmate_import.py + test_facade_mirror_guards.py: 120 passed, 114 s.
  • Commit 1 (02fca55) tests on b9ddf79 code: 32 failed / 4 passed plus 1 failed / 32 passed = 33 failed, 36 passed, matching the PR body.

MUTATIONS (each applied alone, file restored, git status clean): lock removed, template compare, version compare, O_NOFOLLOW, record unlink, preview/history/versions kept, versions open moved after unlink, versions link guard, Windows fallback to 409, card-only check, builtin-origin check (handler and bundle), card hook flag, stale check and after-written compare, undo step without version, slug guard, three broadcasts, three log lines: each caught by at least one test. None survive.

CI at 10:55:30Z (rollup FAILURE): red are GPT 6.1 Review (text not read by me) and New-test stability (windows-latest) (cause reproduced above, finding 1). Backend Tests (3.12 and Windows), Windows Fail-Closed Sandbox Contract, Electron Shell Tests, E2E and PR Readiness were still running or queued. Source Gates, Flake Pattern Ratchet, Await Fast Gate and Coverage Gate are green. I did not read CI logs.

NOT CHECKED: full CI results beyond the above; the GPT 6.1 text; the 52-file local run in the PR body; merge with the current main tip (9807bdd); an end-to-end double import.

@chenmingwei23
chenmingwei23 force-pushed the crewmate-import-dashboard-undo-4 branch from ce1f783 to afd0b4c Compare November 13, 2026 11:13
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

VERDICT APPROVE at afd0b4c (previous reviewed head ce1f783)

Non-author review, read-only. The head moved by a force-push onto a newer main (base ca95636). I fetched both heads by sha and compared the trees of the 14 PR files: the only changes since ce1f783 are the two below.

WHAT CHANGED (ce1f783 -> afd0b4c)

  1. test/test_crewmate_import_dashboard.py: the stale-version request in test_the_undo_route_tells_open_tabs_only_when_it_removed_the_page now sits inside the supports_pinned_walk guard, and test_a_changed_page_logs_one_plain_line has @needs_pinned_walk. My blocking finding (and GPT 6.1's, the same one) is FIXED. Checked by running the whole file with pinned_fs.supports_pinned_walk patched to False: 28 passed, 9 skipped, 0 failed (was 2 failed).
  2. instance.py remove_adopted: the record (instance.json) is now unlinked LAST, with a comment. My non-blocking finding 2 (a removal that stops half way strands the Undo) is FIXED. New test test_a_removal_that_stops_half_way_can_be_retried injects an rmdir failure, checks the record is still there, retries, and ends with only .lock left.
    Mutation: moving the record unlink back to the start fails that new test (assert False); not unlinking the record at all fails the refuse test and the untouched-undo test (assert 2 == 0, assert 1 == 0).

OPEN ITEMS (all non-blocking, none new)

  • Import onto a slug that already has a dashboard: Undo removes every retained version of that older page (stated in the docstring; by design).
  • Windows keeps the page with a log line only, no card line (by design).
  • adopt() itself is not pinned (pre-existing).

CHECKED AT THIS HEAD (python 3.12.16, CI pins, pytest -n 0)

  • test/test_crewmate_import_dashboard.py: 37 passed, 3.3 s.
  • test_dashboard_server_composition_contract_reach.py + test_change_card_crewmate_import.py + test_facade_mirror_guards.py: 120 passed, 113 s (pins right on the new base; they were not copied).
  • Commit 1 (316d42e) on ca95636 code: 33 failed / 4 passed in the new file, 1 failed / 32 passed in test_change_card_crewmate_import.py = 34 failed, 36 passed.
  • Mutations, each applied alone and restored, all caught: no lock; template and version compare; O_NOFOLLOW; versions folder pin guard and versions kept; preview.json and history.json kept; record unlink first or never; Windows fallback to 409; card-only check; builtin-origin check (handler and bundle); card hook flag; stale-check and after-written compare; undo step without recorded version; slug guard; the three broadcasts (POST, DELETE-removed, broadcast on a refused Undo); the three log lines. None survive.
  • Broadcast, history unlink, versions-open order, constant log lines, lock, G-A (not reachable) and G-B (Undo after an edit is refused before any step) were re-confirmed at this head as in my previous comment.
  • Naming rule: no new product-name literal in prose.

CI at 11:28:37Z (GraphQL, rollup FAILURE, 46 success, 20 skipped, 19 in progress, 7 failed): red are Dependency License Gate, Design Review, First Principles Review, GPT 6.1 Review, Opus 5.5 Review, Publish readiness signal and UX Review. I have not read their text. All seven turned red together on the new head, while the Backend Tests (Linux and Windows), Build Desktop and E2E were still running, so they may be a bot or quota error rather than code; the author should read them. Source Gates, Flake Pattern Ratchet, Await Fast Gate and Coverage Gate are not in the red list. My verdict covers code and tests only.

NOT CHECKED: the text of the seven red checks; the 53-file local run in the PR body; an end-to-end double import.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 13, 2026
@chenmingwei23
chenmingwei23 marked this pull request as ready for review November 13, 2026 12:45
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 13, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes on one part. I read the whole diff, tests and docs included. The card step, the card-only gate, the shipped-template check, the pinned removal and the Undo guard all look right to me, and all 104 checks are green.

The part to change: the dashboard step can replace a dashboard the owner already has, with no consent.

  • instance.adopt over an existing instance is allowed and is an ordinary version bump (its docstring on main says so). api_member_import_dashboard calls it without checking whether the new Bot's slug already holds a page.
  • The PR's own remove_adopted docstring names this case: "the adopt landed on a leftover instance of an older Bot with the same slug". A plain Bot delete leaves the dashboard behind (test_a_plain_bot_delete_and_a_create_undo_leave_the_dashboard pins that), so importing a Bot onto such a slug replaces that page with the built-in one. The card only shows the dashboard_template row, so pressing it does not say a page will be replaced.
  • Undo then removes the leftover's retained versions too, and the docstring marks that "accepted". So a page the owner built is both replaced on apply and gone after Undo.

Please keep an existing page. Either:

  1. Skip the adopt when the slug already holds a page (answer 200 and record no instance_version, so the import goes on and the Undo plan, which already leaves the page out without a recorded version, has nothing to remove). _import_after_is_written needs to accept that case. Or
  2. Show on the card that an existing dashboard will be replaced, so the press is the consent, and have the Undo restore the previous version instead of removing the history.

A test for an import onto a slug that already holds a page would pin either choice.

I will look again when the head moves.

@chenmingwei23
chenmingwei23 marked this pull request as draft November 13, 2026 14:32
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Nov 13, 2026
@chenmingwei23
chenmingwei23 force-pushed the crewmate-import-dashboard-undo-4 branch 2 times, most recently from 4708a65 to 9421646 Compare November 13, 2026 15:14
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

The head moved to 9421646 (still two commits). Option 1 was taken: an import onto a slug that already holds a dashboard now keeps that page and its versions (no adopt, answer 200 with kept_existing, no instance_version), and Undo leaves it alone. Tests cover the occupied slug, the Undo after it, and the empty slug.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

VERDICT CHANGES at 9421646 (old reviewed head afd0b4c)

Non-author, read-only delta review. Head read by GraphQL at 2026-11-13T15:42:55Z: DRAFT, OPEN, 2 commits (4889162 tests, 9421646 fix), base d4b0a0b. I read the whole diff against the merge base and the delta against the old head (trees, history was rewritten), and ran the code. The human reviewer's concern is FIXED for every page the gateway can read. One hole of the same kind is left, with a small fix.

1. BLOCKING: an unreadable record is still replaced (same class as the human finding)

src/kiro_crew/dashboard_templates/instance.py:1221 keeps a page only when read(slug).instance_version > 0. A record the gateway cannot read as a page reads as state "error" with version 0: a record written by a newer gateway (schema other than ours), or a record with no template. The import step adopts straight over it.
Ran it (scratch probe, fresh data home): record {"schema": 999, "instance_version": 5, ...} -> adopt_if_empty answered "adopted v6" and rewrote instance.json. Record with an empty template -> "adopted v1", rewritten.
main already has the right helper: src/kiro_crew/dashboard_templates/instance_adopt.py:20 adopt_if_empty (same name, same job: loads and checks the template, takes the same lock, keeps ANY state other than "empty"). On the same two records it answers None and leaves the file byte-identical.
Fix (smallest): call instance_adopt.adopt_if_empty from the handler (member_import_dashboard.py:75) and drop the new _adopt / adopt_if_empty split in instance.py (instance.py:1186-1233 goes back to main's adopt; fewer lines). If you keep the new code, test state != STATE_EMPTY instead of instance_version > 0. Add one test with a schema-999 record: the step answers kept_existing and the file is unchanged.

2. The human reviewer's concern: FIXED (ran it)

  • Occupied slug: POST answers 200 {"ok", "slug", "template_id", "kept_existing": true}, no instance_version, no broadcast, page and versions unchanged (test_the_adopt_step_keeps_a_page_the_slug_already_holds, :725).
  • Full card flow on an occupied slug: apply 4 x 200, the stored Undo plan has no dashboard step, Undo 2 x 200, page still v2, Bot gone (test_an_import_onto_a_slug_with_a_page_keeps_it_and_its_undo_leaves_it, :747).
  • Empty slug still applies and Undo still removes it (the unchanged apply/Undo tests pass).
  • The same tests on the OLD head code fail: the occupied page became ('standup', 3) there, so the test reproduces the human finding.
  • Other paths that reach adopt: the resumed Undo reads no version for a kept page and compares nothing (readers.py _import_state / resumed_undo_is_stale); the card hook flag is set only on the card's own step (handlers/change_cards.py, mutation caught); the MCP route table has the two routes but the handler answers 403 card_only without the flag; adopt in agent_panel_dashboard.py:1226 and dashboard_agentic.py are separate agent/crew-mode paths, not the import.
  • Idempotency: a page an earlier import left at v1 (Bot deleted, page stays) is kept by a second import (probe: second adopt_if_empty -> None, page stays v1). Not covered by a test; see 3b.
  • Card text: the kept page shows only in the step answer and the logs; the card's own "Dashboard" row (change_card_catalog_plans.py:1432) still reads as if it will be set. Docs (feature-map row, RFC clause) say the page is kept. non-blocking, see 3c.

3. Non-blocking

a. Same helper duplicated (see 1); two functions named adopt_if_empty now exist in dashboard_templates.
b. Mutation N7 (keep only when version > 1) SURVIVES: both new "kept" tests use a v2 page, none uses an untouched v1 page. Add one v1 case.
c. The card does not say a page was kept; one line in the result summary would help (follow-up is fine).
d. Mutation L4 (drop the new "kept the page" log line) SURVIVES: that line has no caplog test.

4. Earlier findings re-checked at this head

Broadcast in POST and in DELETE-removed only (B1, B2, B3 caught; none on kept_existing, B4 caught): FIXED. history.json and preview.json unlinked (M6a, M6b caught): FIXED. Record unlinked last (R1 caught, retry test): FIXED. caplog assertions for the log lines (L1, L2, L3, L5 caught): FIXED. Windows-safe tests (needs_pinned_walk, stale request inside the guard): FIXED, with supports_pinned_walk patched False: 64 passed, 9 skipped, 0 failed. Pinned versions folder opened before the first unlink (V1 caught; the order test passes): FIXED. Lock (M1 caught): FIXED. Undo after an edit refused (M10, M11 caught): FIXED. Idempotent remove / adopt after remove starts at v1: FIXED. Pins on the new base: the reach file passes. Naming: no added prose line names the product. Not done by design (unchanged, non-blocking): no card line on Windows keep; older same-slug versions are removed when the import's own page is undone (now only the import's own history, since an occupied slug is never adopted over).

5. Tests run (python 3.12.16, CI pins, kc-heavy, nice 10, -n 0, -p no:cacheprovider)

  • test_crewmate_import_dashboard.py + test_change_card_crewmate_import.py: 73 passed, 6.4 s.
  • test_dashboard_server_composition_contract_reach.py + test_facade_mirror_guards.py: 87 passed, 110 s.
  • Same two import files with supports_pinned_walk False: 64 passed, 9 skipped, 0 failed.
  • Commit 1 (4889162 tests only) on main code (d4b0a0b): 37 failed, 36 passed (author's number confirmed). On the old fix afd0b4c: 4 failed (kept_existing missing, adopt_if_empty missing, occupied page replaced at v3), 69 passed.

6. Mutations (each alone, file restored with git checkout, git status clean at the end)

CAUGHT: M1 no lock; M2 no version compare; M3 no template compare; M4b walk follows links; M5 keep versions; M6a keep preview; M6b keep history; M7 Windows 409; M9 no built-in origin check; M11 no version compare in after-is-written; M13 ships-builtin always true; M14 no card flag; M15 no slug guard; M16 no record unlink; B1-B4; L1, L2, L3, L5; V1; R1 (record first); N1 no occupied-slug guard (test_adopt_if_empty..., :719 page replaced v3); N2 guard on an empty slug (KeyError instance_version); N3 occupied answers a version so Undo removes it (KeyError kept_existing); N4 Undo step planned without a version; N5 kept case fails after-is-written; N6 handler uses plain adopt.
SURVIVE: L4 (kept log untested), N7 (v1 page untested), M4 variant on the record read only (the walk itself is pinned and M4b is caught, so equivalent).

7. CI at 2026-11-13T15:42:55Z (GraphQL, head unchanged since the 15:24:11Z read)

Rollup FAILURE. Red: Design Review, First Principles Review, GPT 6.1 Review, Opus 5.5 Review, Publish readiness signal, UX Review (the bot comments on the PR are for the old head afd0b4c, none for this head: likely re-run needed, cause not read), and a NEW red: Backend Tests (3.12, 3) (cause not read; I made no REST or log call). In progress: Backend Tests 3.12 shards 1, 4-8, Windows 1-8, E2E (stub ACP). Pending: PR Readiness (a gate). 48 success, 21 skipped. Gates ci-summary and PR Gate Summary not decided yet. The author should read shard 3 first.

8. Not checked

Full 53-file suite (CI runs it), a real Windows run, merge with the current main tip e995d0b (the pin file had no overlap at the base; not merged here), the card UI, the red CI bot texts.

@chenmingwei23
chenmingwei23 force-pushed the crewmate-import-dashboard-undo-4 branch from 9421646 to 52e4ded Compare November 13, 2026 17:00
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

The head moved to 52e4ded (still two commits, rebased onto current main). Since 9421646: a slug whose dashboard record exists but cannot be read (a newer schema, or no template) is now kept byte-identical, using the same emptiness test as adopt_if_empty on main; tests cover both shapes, a page from an earlier import, and the kept log line.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 16, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Holding this PR as a draft. On b790a48 the GPT 6.1 lane and the Windows new-test stability job both fail on one line: test/test_crewmate_import_dashboard.py:212 expects 409 for an Undo naming another template, but native Windows cannot pin the directory walk, so the route answers 200 with kept: true (the page is correctly left alone). Production code is not affected. The test fix branches on pinned_fs.supports_pinned_walk() (409 when pinned, otherwise 200 with kept: true); it is prepared locally and not pushed. Opus 5.5 reports no findings on this head.

@chenmingwei23
chenmingwei23 force-pushed the crewmate-import-dashboard-undo-4 branch from b790a48 to c4add91 Compare November 16, 2026 04:56
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Re: GPT 6.1 finding at test/test_crewmate_import_dashboard.py:212.

The head is now c4add91 (still two commits, same base as before). The only change is in that test: the mismatched-template Undo expects 409 when the platform can pin the directory walk, and 200 with kept: true otherwise (native Windows), which is what the route answers. No production code changed.

@chenmingwei23
chenmingwei23 marked this pull request as ready for review November 16, 2026 05:57
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 16, 2026
@KiroCrewCaptain

KiroCrewCaptain commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 14% chance that this change introduces a defect, above the 12% limit for approving on its own.

Importing a Bot now applies the shipped built-in dashboard it names, through an owner-only step that runs only from the import card, and the card's Undo removes only that template at the version it adopted. Old cards keep their plan, recorded results and Undo, because whether the step is present depends on the card's stored "Not brought over" list. A slug that already holds a page, or a record this build can't read, is kept, the step records no version and the Undo leaves it. The page's template and version are part of what both the first Undo step and a resumed Undo compare. The removal opens every folder without following links and holds the instance lock; it opens versions before deleting anything and deletes the record last, so it can be retried. On Windows the Undo answers "kept" instead of refusing. The Crew Mode board step shares adopt_if_empty and returns the same result as before (False). The PR adds a large dedicated test file; CI, Windows included, and every AI lane passed. No blocking issue found.

Tier: 2, held for a person: changes requested.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit b551187a3f · 1660 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

This PR needs a maintainer before it can merge. Two things are open. The change request from @bolichen97 (posted at afd0b4c, about the dashboard step replacing an existing page) is still open. The PR also edits design docs (docs/feature-map/README.md, the crewmate share RFC and the dashboard instances spec). @bolichen97, please look at the current head again. It appears to take your option 1: the step adopts only onto an empty slug and answers 200 with kept_existing and no instance_version. Its Undo then leaves the page alone.

Review result on this head: no blocking finding. The review checked these points:

  • Both new routes go through the owner-only write check. They need the card-only request attribute that the change-card hook sets for a crewmate.import dashboard step, and they accept only a template whose catalog origin is built-in.
  • Undo is a compare-and-delete under the instance lock. It runs only at the recorded template id and instance_version, walks the folders with O_NOFOLLOW, and removes the record last so a removal that stops part way can be retried.
  • The review ran the 107 tests in test/test_crewmate_import_dashboard.py and test/test_change_card_crewmate_import.py at this head, and they pass. They bind no ports, use no sleeps, and keep the data home under tmp_path.

Security: the new write and delete paths are reachable only by the owner through an armed import card. They never widen an agent-facing dashboard route, and they cannot remove a page the card did not adopt.

Done well: the tests that replace a member or dashboard folder with a link after the folder is opened show that nothing behind the link is read or changed.

Optional:

  • crewmate_sdk.py:45 calls crewmate_import_params on the event loop. With a builtin: template, that now walks the whole template catalog. Wrapping the call in asyncio.to_thread would keep that work off the loop.
  • The kept-existing guards in change_cards_readers.py (the isinstance(adopted, int) check near line 1107 and the kept branch of _import_after_is_written near line 1153) are not covered by any test, because the card-flow harness copies the guard. Two small unit tests next to the fingerprint test would cover them.
  • _holds_something changes the shared adopt_if_empty helper. The Crew Mode board caller now returns False on an unreadable record without its warning log. The PR body says the helper is reused unchanged. Either keep the helper unchanged or update the body to say so.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed head c4add91. My earlier change request (at afd0b4c: an existing page could be replaced without consent) is resolved. The step now goes through instance_adopt.adopt_if_empty, keeps any existing page or unreadable record, records no instance_version, and the Undo leaves it alone.

Also checked:

  • It merges cleanly onto current main (60d432d, 358 commits past this base). The code it depends on (instance, instance_adopt, the card catalog and plans, crewmate_bundle, change_cards_readers) has not changed on main since the base.
  • On the merged tree, this PR's tests pass (124), and so do the related suites: route table, boot chain pins, facade, feature map and line caps (2675).
  • Both routes need an owner write plus the card-only flag that only the card hook sets. Only shipped templates are accepted. The removal works through pinned descriptors, opens versions before any delete, and deletes the record last. The Undo fingerprint covers both template and version.

I have no blocking findings. The code change approver asks for a person to decide, because of the size and the design-doc edits, so a maintainer signs off before I approve.

AI-assisted, sent by Bolin Review bot

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 17, 2026
…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, holds the instance lock,
  takes one path segment only, and leaves nothing but the lock file (history
  and preview go too)
- where the page cannot be removed through directory descriptors (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
- the routes' log lines are constant text (no slug, path, template or error text)
- a removal that stops half way keeps the record, so the Undo can be retried and finish
- an import onto a slug that already holds a dashboard keeps that page and its versions: the step adopts nothing, answers no version, and the Undo has nothing of the import's to remove
- the same holds for anything stored for the slug that this build cannot read (a newer-schema record, a record with no template): kept byte-identical, answered kept_existing, no broadcast, left by the Undo; a page from an earlier import (version 1) is kept; the kept line logs once
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
- the handler applies the page through instance_adopt.adopt_if_empty
- 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 (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; the record goes last, so a removal that stops half way
  can be retried
- where directory descriptors are unavailable (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, two boot chain-order pins, facade manifests for the
  new functions; feature-map row and RFC note
- an import onto a slug that already holds a dashboard keeps that page and all its
  versions: the step adopts nothing (instance_adopt.adopt_if_empty, the one emptiness test: anything stored counts, readable or not), answers kept_existing with no
  instance_version, and the card's Undo has nothing of the import's to remove
@chenmingwei23
chenmingwei23 force-pushed the crewmate-import-dashboard-undo-4 branch from c4add91 to b551187 Compare November 17, 2026 18:37
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 17, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving b551187 as the maintainer sign-off. Since my re-review at c4add91 this is a rebase onto current main; the only code-line difference is the pinned boot-chain baseline (_deferred count), which follows main. My earlier findings stand: an existing page is never replaced, only shipped templates are accepted, and the Undo leaves a kept page alone.

AI-assisted, sent by Bolin Review bot

@bolichen97
bolichen97 merged commit c15e18d into main Nov 17, 2026
100 checks passed
@bolichen97
bolichen97 deleted the crewmate-import-dashboard-undo-4 branch November 17, 2026 22:42
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crewmate import applies the bundled built-in dashboard in the same change card

3 participants