Repository navigation
fix(snapshot): refuse a bundle restore would refuse, share one size override - #23202
Conversation
64f9bef to
89eb909
Compare
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the writer-side check fixes the cause (no writer-side limit to match the reader's), and the flag that moves the limit is off by default. Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: let a person with a large install make a backup that
[FIRST-PRINCIPLES-REVIEWED] a34a485 Description read[DESCRIPTION-READ] 687f1a2ccf400fddf08c4a7fcaa6cc9e88472156ed909dd7faf340f170629821 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: snapshot now refuses before writing a bundle that restore would refuse, and the size override is opt-in, has an upper limit, is checked the same way by both commands, and changes nothing when the flag is absent. Notes
[DESIGN-REVIEWED] a34a485 Description read[DESCRIPTION-READ] 17b2fd3c61c9bd568acb01e068567460fc78c306bcef4cef5b460cf46d50f283 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed 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 — ✅ 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: |
89eb909 to
aa79fdc
Compare
|
self-added: yes
|
|
Two reds on aa79fdc that this diff does not cause:
|
|
Backend Tests (Windows) (7) failed again on its single re-run, the same 33 cases. This is deterministic, not a flake. It hits GitHub-hosted |
aa79fdc to
a34a485
Compare
|
Rebased once onto main for the #23264 Windows fix. |
|
Review-ready at a34a485: PR Readiness passed (104 checks, 0 failing). GPT 6.1 and Opus 5.5 posted no blocking findings, and Design and First Principles both passed. Waiting on maintainer approval. |
bolichen97
left a comment
There was a problem hiding this comment.
Deep review passed — the writer and reader now share the same bounded archive limit, and the optional override remains explicit and capped.
Sensitive change review
- Head commit: a34a485
- What rule changed: local operators may raise the snapshot and restore content limit from 4 GiB to at most 1024 GiB.
- Before -> after: defaults remain 4 GiB; an explicit bounded flag raises both writer and reader limits together.
- Worst case if wrong: a very large archive could exhaust temporary disk space before extraction.
- Evidence checked: integer bounds, member-count cap, tar-header preflight, free-space refusal, path traversal checks, link checks, current-head tests and reviewer signals.
- No regression:
- Tools still work: no-flag behavior is unchanged.
- Backward compatible: old bundles and callers use the original default.
- Existing tests: current-head required checks pass.
- How to undo: revert this pull request; no data migration is required.
[Security: the override changes a decompression safety limit, but only a local operator can set it, the default remains unchanged, and path, link, member-count, header-size, and free-space guards still apply.]
Problem / Motivation
Goal:
kirocrew snapshotnever writes a bundle thatkirocrew restorerefuses, and an install larger than 4 GiB has an explicit, bounded way to back up and restore.On a large install,
kirocrew snapshotwrites a bundle andkirocrew restorethen refuses it: "This archive declares more than 4 GiB of uncompressed content, which no memory bundle produces". The restore bound_MAX_ARCHIVE_BYTESis fixed at 4 GiB, and the writer never stops at that size.Why it matters
The person hit by this has a backup on disk and no supported way to restore it, and finds out only on the new machine. That is the moment the backup exists for.
Not a goal
snapshot_mainwith the default bound and now gets the same early refusal.What changed (motivation → approach → change)
Restore guards against a decompression bomb by walking member headers and refusing past 4 GiB. Snapshot never held itself to that number. Its only check read the finished tarball back after the full compression pass, and it left the unrestorable file under the name
--keepand restore look for.kirocrew snapshot_build_snapshotholds the staged tree to the restore bound before the tarball is created. It counts entries and regular-file bytes, the same two quantities the reader counts. Over the bound it exits 1 with no bundle written and nothing pruned. A byte refusal names the largest entry,--componentsand--max-archive-gib; an entry-count refusal names only--components, since the flag does not move that bound.--max-archive-gib N(1-1024) sets the byte bound for that run. A bundle written past the default restores with any N at least as large.kirocrew restoreThe owners are
src/kiro_crew/snapshot_archive.py(_refuse_oversized_tree,archive_byte_bound, and themax_bytesparameter on_refuse_oversized_archive),src/kiro_crew/snapshot_build.py(the pre-tarball check) and thesrc/kiro_crew/snapshot.pyfacade (flag validation and the two commands).src/kiro_crew/cli_parser_admin.pyadds the flag to thekirocrewCLI. The user guidesrc/kiro_crew/docs/snapshot-and-restore.mdand the CLI specdocs/system-specs/modules/cli.mddescribe the limit and the flag.Backwards compatibility
Compatible: without
--max-archive-gib, both commands enforce the same 4 GiB and 200,000-entry bounds asmain. A bundle over the bound already exited 1 onmain. The only difference is that the refusal now lands before the tarball is published rather than after.Removes nothing: no flag, key or code path is removed. The one taken-away outcome is the unrestorable tarball
mainleft on disk after its exit-1 refusal, and nothing could read that file anyway.Tests
test/test_snapshot_archive_override.py(new, 14 tests):--componentsand not--max-archive-gib.tmp, keeps the older bundle under--keep 1, and names both remedies--max-archive-gib 1is refused by restore without the flag and restored with--max-archive-gib 2Updated pins: the CLI argument tables in
test/test_snapshot_refactor_contracts.py, the owner map intest/test_snapshot_refactor_ownership.py, and the two ordering locators intest/test_snapshot_unrestorable_refusal.pyandtest/test_snapshot_install_scoped_validation.py, which now match the call with its new keyword argument.Determinism: 20 runs at
-n0, 10 at-n 4 --dist loadgroup --max-worker-restart=2withtest_snapshot_archive_bound.pyandtest_snapshot_unrestorable_refusal.pyas co-tenants, and one shuffled@filerun (seed 24117). All green.Revert-and-retest:
prove.pycame back INCONCLUSIVE (exit 21) because the mutated run errored at collection. I substituted a manual revert: with the four production files checked out fromorigin/main, 11 of the 13 new tests fail. The 2 that pass are the no-flag round trip and the no-flag forged-header refusal, which are the unchanged behaviour they exist to lock.Local gates: the backend scoped run passed 50,679 tests with 1 failure. That failure is
test_snapshot_merge_core_files_pinned.py::test_the_rewrite_keeps_the_live_stores_access_control_acl:setfaclis unsupported on this host's filesystem, and the test fails the same way on cleanmain. black, isort, flake8, mypy, the comment-history, brand, docs-lint and file-line-cap gates all pass, as do the flake-pattern ratchet and semgrep 1.78.0 with--baseline-commit.Manual verification
N/A — the unit tests drive the real
snapshot_mainandrestore_mainagainst real tarballs on disk, and the bound is lowered by monkeypatch so the over-limit path runs without writing gigabytes.Related Issues
Closes #23171
Pattern harvest
Rule candidate: review-prompt
Pattern: a reader-side limit (size, count, schema) with no matching writer-side check, so the tool produces output it later refuses to read
Checklist