Skip to content

fix: say why a member backup fails inside the agent sandbox - #31510

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/29365-member-backup-sandbox-hint
Nov 7, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/29365-member-backup-sandbox-hint

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: kirocrew memory backup and the pre-update copy of kirocrew update, run inside the agent sandbox, say in one line per member store that member stores cannot be backed up there and where to do it instead, rather than failing each one with bare [Errno 30] Read-only file system tracebacks.

Inside the agent sandbox memory_stores/ is read-only on purpose, and member backups are written inside it (memory_stores/.member-backups/<store>/). So every member store's backup fails there: kirocrew memory backup prints 2 failed after two EROFS tracebacks per store, one from tightening the backup directory and one from opening its lock file, and the pre-update copy refuses the update and points at the log, where the same tracebacks are.

Why it matters

Someone who runs the backup or an update from a sandboxed shell reads those tracebacks as a broken install or a failing disk (the reporter checked dmesg and findmnt to rule that out), when the refusal is deliberate and the remedy is to run the command from the dashboard or their own terminal.

Not a goal

  • Making member backups succeed inside the sandbox: that needs a sandbox-writable backup directory or a gateway-side backup request, both sandbox policy changes. The read-only seal on memory_stores is unchanged.
  • Changing the pre-update copy's fail-closed refusal: an update with no fresh copy of a member store is still refused.
  • Named V1 stores, whose backups/ sits in the same read-only directory but fails through a SQLite open rather than an OSError; they keep today's traceback.
  • kirocrew memory restore run inside the sandbox, a separate verb that stages into the same read-only directory.
  • Silencing the directory-tightening warning on macOS, whose sandbox refuses the write with EPERM without a read-only mount; the hint line is still logged there.

What changed (motivation → approach → change)

Symptom: in the sandbox each member store failed its backup with bare EROFS tracebacks. Cause: the backup pass logged every failed copy with its full traceback, and the member store-use lock always tried to chmod its directory first, which cannot work on a read-only mount.

Change: the backup pass (memory_backup.back_up_all_stores) recognises a member backup whose write was refused under memory_stores/.member-backups/ (EROFS, EACCES or EPERM naming a path there, decided from the failure the same way kirocrew config set explains its sealed config) and logs one warning per store with no traceback:

WARNING kiro_crew.memory_backup: memory backup of <home>/memory_stores/member-alice/memory.db not taken: member stores are read-only inside the agent sandbox: back up from the dashboard or from your own terminal. Outside the sandbox, check the permissions of <home>/memory_stores/.member-backups ([Errno 30] Read-only file system: '<home>/memory_stores/.member-backups/member-alice/.store-use.lock')

On a confirmed read-only mount the store-use lock skips tightening an existing backup directory, so nothing is printed before that line. The memory spec records the behaviour and the named V1 limit.

Backwards compatibility

Compatible: the backup pass returns the same four counters and fails the same stores; only the log line for a member copy refused under .member-backups/ changes, and the skipped chmod is one that always fails on a read-only mount.

Removes nothing: no counter, verb, file or config key is removed or renamed, and every write a backup makes outside a read-only mount is unchanged.

Tests

test/test_member_memory_backup.py::test_a_read_only_member_backups_view_reports_the_sandbox_hint puts two member stores on a simulated read-only .member-backups/: the read-only probe answers yes, and the two writes a real read-only mount refuses (the directory chmod and the lock open) raise EROFS. Both stores count as failed, each logs the hint, and no record from any logger carries a traceback.

Proof: PROVEN test/test_member_memory_backup.py::test_a_read_only_member_backups_view_reports_the_sandbox_hint (head 585cf75)

Determinism: 20 runs at -n0, 10 runs at -n 4 --dist loadgroup --max-worker-restart=2 with test_member_memory_backup_legacy.py and test_memory_backup.py as co-tenants, and a shuffled order of both member backup files (63 tests, seed 27024), all green.

Manual verification

On Linux, a scratch data home with two member stores and their backup directories (one normal kirocrew memory backup first), then memory_stores bind-mounted read-only in a user namespace (unshare -rm, mount -o remount,bind,ro): kirocrew memory backup printed exactly one hint line per store, as above, then Backed up 0 store(s); removed 0 old; 2 failed; 1 skipped (nothing to copy). and exited 1. The same held with one store's .member-backups/<store>/ removed first. snapshot_memory_before_update() under the same mount logged the same two lines and returned the usual Pre-update memory snapshot failed: 2 store(s) not copied. refusal.

Screenshots / video

N/A — backend only; no frontend file changes.

Related Issues

Closes #29365

Sibling sweep

Swept: git grep -nE "memory_backup.backup_store(|_open_store_use_lock(" -- src/
Sibling: src/kiro_crew/memory_backup.py -- changed here
Sibling: src/kiro_crew/member_memory_backup.py -- changed here
Sibling: src/kiro_crew/dashboard/handlers/memory_admin.py -- not affected -- the dashboard's back-up-now runs in the gateway, outside the sandbox, so its member backups write normally
Named V1 stores share the read-only leaf but fail through a different call (listed under Not a goal).

Pattern harvest

Not generalizable: the sandbox's read-only leaves already explain a refused write where one is reported (kirocrew config set); this pass was the one place that buried the refusal in a per-store traceback.

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

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 15:45
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 15:45
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision e4f50e87198445955f0da3dbdaa69595ec3b42e2 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 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The change only rewrites how a refused member backup is logged and skips a chmod that cannot work on a read-only mount. Counters, fail-closed refusal and the sandbox seal stay as they were.

Notes

  • The hint says "inside the agent sandbox" for any EROFS/EACCES/EPERM under .member-backups/. On a host with genuinely wrong permissions outside the sandbox, the operator gets a sandbox-first explanation, partly offset by the "Outside the sandbox, check the permissions" clause.

[DESIGN-REVIEWED] e4f50e8

Description read

[DESCRIPTION-READ] 687e1fa1fadcd3ee74f4fa7b84acccab9a370da5b332c7a5ebca820211cfbca6

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 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of e4f50e87198445955f0da3dbdaa69595ec3b42e2 — 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

Nothing blocks: the fix comes from linked issue #29365, reuses memory_stores.is_lock_write_refusal and the hint pattern from cli_config, and the description names the read-only seal as cause and leaves it in place.

What this change ships

Inventory (3 items) — 3 justified

Intent: when someone runs kirocrew memory backup or kirocrew update in the agent sandbox, they should be told why member backups fail and where to run them instead, not see errno tracebacks. FIX.

  1. Running kirocrew memory backup or the pre-update copy in the sandbox now logs one hint line per member store instead of EROFS tracebacks — justified
  2. On a read-only mount, the store-use lock no longer tries to tighten an existing backup directory, so no traceback appears before the hint — justified
  3. The memory spec's fail-soft paragraph records the hint and the named V1 store limit — justified

[FIRST-PRINCIPLES-REVIEWED] e4f50e8

Description read

[DESCRIPTION-READ] 7a6a35b24c06a5fce21d39b692040f4be8a5be08dc9317ccae97d037dd4abf50

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 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] e4f50e8

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

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

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e4f50e8

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

@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/memory-skills-hooks.md and other docs/system-specs/modules/ files since this head went green (b764e20 -> 8dbdf04); CI re-running.
[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 6, 2026
Inside the agent sandbox memory_stores is read-only by design, and
member backups are written inside it, so `kirocrew memory backup` and
the pre-update copy of `kirocrew update` run there failed every member
store with bare EROFS tracebacks. The seal stays. The backup pass logs
one line per member store instead: member stores are read-only in the
sandbox, back up from the dashboard or your own terminal, plus the
errno. It is decided from the refused write's path, the way
`kirocrew config set` already does, and the store-use lock no longer
tries to tighten its directory on a read-only mount, so no traceback
comes first.
@bolichen97
bolichen97 force-pushed the fix/29365-member-backup-sandbox-hint branch from 7586705 to e4f50e8 Compare November 7, 2026 02:35
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/memory-skills-hooks.md and other docs/system-specs/modules/ files since this head went green (8dbdf04 -> c5c4de1); CI re-running.

The backend reds on the previous head were main's at 8dbdf04 (test_the_package_stays_within_its_line_budget and test_only_the_allowed_workflows_use_pull_request_target); #31625 and #31803 fixed them on main. The patch is unchanged.
[operator: bolichen97]

@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 7, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved for the on-call. Review lanes pass on e4f50e8, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit 8237603 into main Nov 7, 2026
97 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/29365-member-backup-sandbox-hint branch November 7, 2026 03:30
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 7, 2026
buluoray added a commit that referenced this pull request Nov 7, 2026
Inside the agent sandbox memory_stores is read-only by design, and
member backups are written inside it, so `kirocrew memory backup` and
the pre-update copy of `kirocrew update` run there failed every member
store with bare EROFS tracebacks. The seal stays. The backup pass logs
one line per member store instead: member stores are read-only in the
sandbox, back up from the dashboard or your own terminal, plus the
errno. It is decided from the refused write's path, the way
`kirocrew config set` already does, and the store-use lock no longer
tries to tighten its directory on a read-only mount, so no traceback
comes first.

(cherry picked from commit 8237603)

Original author: Bolin Chen (#31510). test/test_member_memory_backup.py import hand-resolved: added only import errno; release never imported gc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants