Skip to content

fix(cli): refuse a blocked backup root on every apply surface - #1227

Draft
HugoXK wants to merge 1 commit into
mainfrom
agent/1226-blocked-backup-root
Draft

HugoXK wants to merge 1 commit into
mainfrom
agent/1226-blocked-backup-root

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1226

What changed

show --diff, apply --dry-run, apply, apply --install-to and apply --from now refuse a tree write whose backup directory cannot be created, before anything is written, with one sentence naming the blocker:

cannot write <slot>: '<backup root>' is a file, not a directory

Before, with a regular file at $AGENTDESCENT_HOME/backups: the previews exited 0 and advertised the write; apply and --install-to exited 2 with cannot write <dest>: Not a directory (the backup's errno printed against a destination that is a good directory); apply --from exited 2 with cannot write <slot>: Not a directory.

The backup slot was the one path the walk writes that _check_apply_paths checked only against the operator allowlist; the filesystem refusals covered dest and every written leaf. The fix is that one call over backup, in the same funnel, so no surface can drift.

A text artifact is unaffected (its .bak-N sits beside dest) and --no-backup needs no slot; both are pinned by control rows.

Reads at this tip

Both readers name 71aa5c3cfbe7d1d1c736536a7f79b83a77b2d827:

  • Security — Blocking: none. Delta is evolution.py:1672-1673 (one call in _check_apply_paths); instrumented all five surfaces against a blocked root — one check event with backup != None on each, five identical refusals, zero write primitives, dest bytes+mtime unchanged, blocked root untouched. --no-backup, a dangling symlink at backups, a file at backups/<name>-<digest> and AGENTDESCENT_HOME itself a symlink are all handled; the planted race fails closed (message mislabelled against dest, pre-existing). backups a symlink to a directory outside home is not refused — pre-existing, unchanged by this commit, out of this card. 21 passed; hygiene grep clean.
  • Test — Blocking: none. Red first at base 3759b546 + only the new file → 2 failed, 3 passed (test_tree_surfaces_name_the_blocked_backup_root line 120 assert show_error, test_apply_from_names_the_blocked_backup_root line 103 assert 0 == 2); tip → 5 passed; deleting the added line from the tip tree reproduces 2 failed, 3 passed, so the rows pin the fix itself. All five surfaces return cannot write <slot>: '<backup root>' is a file, not a directory with dest bytes+mtime identical, blocked root intact and no backups/ created; family 18 passed. No UI surface (CLI text only).
  • Seat accounting: 2 of 2 available seats have read this sha (Security, Test). The third seat is unavailable, not pending — Reviewer's route resolves CSI_API_KEY, which is not set — so 2/2 is this card's ceiling, not 3/3.
  • CI at this tip: 12 checks, 10 success + deploy and apply labels (live only) skipped, zero failures.

Verification at the tip

Tip SHA: 71aa5c3
Ran:

  • red first at base 3759b546, new file only: 2 failed, 3 passed in 4.27s (the two refusal rows; the three controls already held)
  • at the tip, new file: 5 passed in 7.82s
  • refusal family together (test_apply_blocked_parent.py, test_apply_blocked_child.py, test_apply_blocked_leaf.py, test_apply_backup_blocked.py): 18 passed in 7.61s
  • python -m tools.changelog_fragments check → 5 fragments OK
  • python -m tools.gen_api_docs --check → docs/api.md is up to date
  • pytest -q at the tip: 19 failed, 8016 passed, 51 skipped — all 19 fail identically on base 3759b546 (6 test_era_srbench MemoryError in the sandbox, 12 test_sandbox_container docker-engine rows, 1 test_genesis_example toolchain mount), so they are this host, not this PR
    Not run:
  • mkdocs build --strict — no file under docs/ or mkdocs.yml changes in this PR

The backup slot is a path the apply walk writes, and `_check_apply_paths`
only ran the operator allowlist guard over it. A regular file at
`$AGENTDESCENT_HOME/backups` therefore passed both previews and then failed
the real tree write with the backup's errno printed against `dest`, a
directory that is perfectly good -- the #1208 defect on the last leaf.

This branch has not been deployed

No deployments
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.

fix(cli): refuse a blocked backup root instead of failing the write with its errno

1 participant