Repository navigation
fix: keep the live workspace agent config on restore - #38689
chenmingwei23 wants to merge 4 commits into
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. One rider goes beyond the Goal: the "Restored notes" listing. The PR works without it, so it is a note. Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: restoring someone else's snapshot can't turn on permissions, hooks or MCP servers for this install's next agent session. FIX.
[FIRST-PRINCIPLES-REVIEWED] 662449b Description read[DESCRIPTION-READ] c3193d2c3865f871131a619ab859066513af27ee96b5d2580b9cd57ad4e1cc6e That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the hold-back runs once on the staged bundle, before either mode reads it, and covers both writers (CLI restore and dashboard import). The take-away is declared as Notes
[DESIGN-REVIEWED] 662449b Description read[DESCRIPTION-READ] 83f7f6422247a8d78a7b3c33c76f344abb2fb54fcf447d48225d508b6022443c 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 |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 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: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings. Notes:
[OPUS-REVIEWED] 662449b Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
407ffe9 to
bc08210
Compare
56185e3 to
adc85aa
Compare
adc85aa to
cecccb6
Compare
|
GPT 6.1 finding at 8fcd28a (src/kiro_crew/crew_mode.py:603, session-list decision): not caused by this PR.
So no code change is made here. The block is a security-fenced finding on code this PR does not touch; it needs a repository writer's override, not a fix in this PR. |
|
/ai-review override gpt 8fcd28a pre-existing: Finding is in src/kiro_crew/crew_mode.py:603, which this PR does not change (diff: snapshot.py, portability.py, docs, tests). Pre-existing code outside scope; answered in #38689 (comment) |
Human judgment recorded@chenmingwei23 recorded a pre-existing release (class
This decision applies only to this commit. A new push requires a new judgment. |
|
Human judgment recorded, but the following reviewer lane(s) could not be re-run automatically: GPT 6.1. Re-run the lane's latest workflow run for |
8fcd28a to
0215486
Compare
0215486 to
730d161
Compare
20731d6 to
e47eaf0
Compare
e47eaf0 to
3573cd0
Compare
3573cd0 to
56d320c
Compare
Red first. Restoring the workspace component, in Replace or Merge, currently installs the archive's agent config (.claude/, .mcp.json, .kiro/, .pi/ and the other harness names), in workspace/ and in its project folders at any depth, over or beside the live ones, so an archive can set permissions, hooks and MCP servers for the next agent session started there. One row per name, at depth 0, 1 and 2, plus the notes the summary must name. The dashboard zip import (apply_import_zip) is driven in both modes too.
Restore now removes every harness's project config (.claude/, .mcp.json, .kiro/, .codex/, .goose/, .goosehints, .opencode/, opencode.json(c), .pi/, .mimocode/, mimocode.json(c)), at any depth under workspace/, from the staged bundle, in Replace and Merge. Replace stages this install's own copy in their place, so the whole-tree swap keeps it. The result names what was left out. CLAUDE.md and AGENTS.md stay restorable, and the result names each one it installed. The dashboard zip import runs the same hold-back before either mode and reports held_agent_config in its summary. The new code is declared in the link-screen and snapshot ownership registries.
56d320c to
ec1c57d
Compare
Problem / Motivation
Goal: Restoring a snapshot archive never lets the archive's agent-config files decide how this install's next agent session runs.
kirocrew restoreof theworkspacecomponent replaces the wholeworkspace/tree (Replace) or adds every missing file to it (Merge). That tree is where agent sessions start, inworkspace/itself and in its project folders. It can hold.claude/settings.local.json(permission mode, allow rules, hooks),.claude/skills/, and.mcp.json(MCP servers). Nothing is filtered or held back, so an archive from someone else can turn onbypassPermissions, add shell hooks, or add MCP servers for the next session.Why it matters
A restore is a routine thing to do with a file somebody sent you. After it, the next agent session in a restored folder can run commands with no prompts. The operator never reviewed that file.
Not a goal
CLAUDE.mdandAGENTS.mdstay restorable: they are notes with no permissions, hooks or servers of their own.configcomponent keys, memory, crons and hooks are other work).What changed (motivation -> approach -> change)
Symptom: the archive's
.claude/and.mcp.jsonland in the live workspace. Cause: restore copies the stagedworkspace/tree as it is. Change: before either mode reads the staged bundle,_hold_back_agent_config(insnapshot.py, next to_hold_back_executables) removes every agent-config name at any depth under the stagedworkspace/(names matched case-insensitively, links unlinked and never followed). The names are.claude,.mcp.json,.kiro,.codex,.goose,.goosehints,.opencode,opencode.json,opencode.jsonc,.pi,.mimocode,mimocode.json,mimocode.jsonc. They come from the project config the harness code reads or fences (acp/claude_settings_sources.py:171,acp/kas_settings_mcp.py:209,acp/session_mcp.py:1501,acp/kas_skill_scope.py:128,agent_sdk/native_allow_stores.py:126-143);.codex,.gooseand.goosehintswere named by the security review and nothing in this tree reads them. A test fails if a name inPROJECT_ALLOW_STORESis not held back.Checked, no project config name found: antigravity, copilot, deepseek, strands. Where I looked:
agent_sdk/native_allow_stores.py:99(copilot has only~/.copilotrows),:106-118(NATIVE_ALLOW_STORES_NONE: antigravity, deepseek and strands have no on-disk config known),:125-144(PROJECT_ALLOW_STORES, no entry for them). No code for them.node_modules,.git,.venvandvenvincluded, so an agent config inside one of those is neither lost nor installed (shortcut:comment in the code: the live walk reads the whole workspace tree).workspace/.apply_import_zipinportability.py) runs the same hold-back on the extracted copy before either mode, so Replace and Merge both see the held-back staging. Its summary gets aheld_agent_configlist ofworkspace/<path>entries. The call is a local import inside the function becausetest_portability_facade.pypins which namesportabilitybinds fromsnapshot. Listing restored notes is CLI only; the import summary does not list them (Follow-up).CLAUDE.mdandAGENTS.mdstay restorable. The summary printsRestored notes: workspace/<path>for each one a restore installed (Replace: all outside held directories; Merge: only those the live tree lacked).CLAUDE.md/AGENTS.mdnotes it installed (the CLI restore does;portability.py:899only reports held agent config).CLAUDE.mdandAGENTS.mdback too. They are instructions an agent reads, so that decision is separate from the settings, hooks and servers held back here.snapshot-and-restore.md.Backwards compatibility
Breaking: a restore no longer installs any of the agent-config names listed under "What changed" (
.claude/,.mcp.json,.kiro/with its skills and steering,.codex/,.goose/,.goosehints,.opencode/,opencode.json(c),.pi/,.mimocode/,mimocode.json(c)) from an archive'sworkspace/, at any depth. Someone restoring their own backup onto a fresh home gets none of them back and copies them by hand; the summary names each one left out. Writer sweep on origin/main @ e3b3b13:kirocrew restorewrites these paths through theworkspacetree copy in Replace (_do_replace_mutations) and Merge (_do_merge), both fed from the staged bundle this change edits. Thememorycomponent namesworkspace/memoryandworkspace/knowledgeonly, so it is not affected. The dashboard import (portability.py,apply_import_zip) also writes aworkspace/tree; it runs the same hold-back (see Sibling sweep).Reader: src/kiro_crew/snapshot.py:restore_main -- entry: release (CLI restore) -- stages the bundle once and both modes read the edited copy; tests
test_replace_keeps_the_live_agent_config,test_merge_never_installs_the_archives_agent_config.Reader: src/kiro_crew/snapshot_restore.py:_do_replace_mutations -- entry: release (CLI restore, Replace) -- unchanged; it copies the staged tree, which now holds the live copies.
Reader: src/kiro_crew/snapshot_merge_driver.py:_do_merge -- entry: release (CLI restore, Merge) -- unchanged; it skips what the staged tree no longer carries.
Tests
test/test_snapshot_restore_agent_config.py(87 tests) andtest/test_portability_import_agent_config.py(4 tests):workspace/,workspace/proj/,workspace/a/b/) x mode (Replace, Merge): the archive's copy is not installed and a plain file beside it is;PROJECT_ALLOW_STORESis held back;venv,node_modules/pkg): a live agent config under a dependency directory survives Replace and the archive's copy there is not installed;test/test_portability_import_agent_config.py, 4 more tests:apply_import_zipin Replace and Merge keeps the live.mcp.json, installs no archive.claude/,proj/.mcp.jsonora/b/.kiro/, still imports a plain file, andheld_agent_confignames the four held paths.Red/green record: there is no local pytest on the machine this was written on, so CI is the record. Commit 1 (bc08210) is tests only and was pushed first. On it, run 44153487197 failed 85 tests, the same count as the new tests (only the first 10 per job are annotated; the other 75 were not read one by one): New-test stability (ubuntu-latest and windows-latest) and Backend Tests (3.12, 4) and (Windows, 4) report "85 tests failed or errored", and the annotated ones are
test_every_harness_config_name_is_held_back_at_any_depth[...]with "AssertionError: from the archive was installed". Latest red record: commit 1 alone (cecccb6) failed 89 tests, the 85 CLI rows plus the 4 import rows (New-test stability reports "89 tests failed or errored"; annotated ones aretest_every_harness_config_name_is_held_back_at_any_depth[...]andtest_import_holds_back_the_archives_agent_config[replace|merge]with "the live .mcp.json was replaced" / "assert not True", andtest_import_names_each_held_back_path[...]with "assert set() == {...}"). Commit 2 holds the fix and one registry row that declares the new code (test/link_screen_sites.py:snapshot.py::_hold_back_agent_config, which refuses on a link). The per-name ownership table intest/test_snapshot_refactor_ownership.pyno longer exists on main, so there is no row for it. (The commit shas quoted in this record are from earlier heads, before the rebase onto main.) On its first head (56185e3) run 44164101257 showed the 85 new tests green and only those two registry tests red; its CI run is the green record.Proof: not provable -- no local pytest; red run 44153487197 on the tests-only first commit is the record.
Review note at head 8fcd28a (answered in a PR comment, no code change): the GPT 6.1 finding at
crew_mode.py:603is on a file this PR does not touch and a line already on main.Review notes at head 56185e3 (answered, no code change):
workspace/before this change. Phase one backs the live tree up with_backup_tree_or_refuse(snapshot_restore.py:997-998, defined at:504-532), whose skip reporter is fatal on a symlink or non-regular file, and it runs on the wholeworkspace/tree whenever the archive carries it. The new keep-the-live-copy step uses the same pinned primitives on a subset of the same files, so it refuses no input that was accepted before. By reading only; not run.Out of scope: links in the live agent config
Replace already refuses a workspace that holds a live symlink or hard link before this change runs: the pre-Replace backup (src/kiro_crew/snapshot_restore.py, _backup_tree_or_refuse, fatal skip reporter) stops first. CI run 44384822036 shows that refusal. This PR does not change link handling; the agent-config hold-back only runs on workspaces the backup accepts.
Manual verification
N/A -- unit coverage sufficient: the tests drive
restore_mainend to end on a real tar archive and a real data home.Screenshots / video
N/A -- no user-visible UI change (CLI restore output gains a short list of held files).
Related Issues
None.
Sibling sweep
Swept: git grep -n "_hold_back_executables" -- src/
Swept: git grep -n ""workspace", "plan_memory"" -- src/kiro_crew/
Sibling: src/kiro_crew/portability.py:1038 -- changed here: the dashboard import merges the archive's
workspace/tree, soapply_import_zipnow holds the same names back first (both modes, tests intest/test_portability_import_agent_config.py).Pattern harvest
Not generalizable: one restore path copied a whole tree that holds files the agent obeys; the fix is specific to those names.
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.