Repository navigation
fix(steering): hold the memory-silo fence when a root is a drive root - #24743
Conversation
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is a root-cause fix in the one fence predicate, both callers are listed, and it only refuses more. [DESIGN-REVIEWED] 1469998 Description read[DESCRIPTION-READ] f493e6e3f4eec5d38170d9ed6aaec0f61db530570ab6b0c72f2466209b5fdade 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 |
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This fixes a real fence at the mechanism level by reusing the existing What this change shipsInventory (2 items) — 2 justifiedIntent: keep one memory store's Markdown out of another chat's prompt when a steering root or a store sits at a drive root (
[FIRST-PRINCIPLES-REVIEWED] 1469998 Description read[DESCRIPTION-READ] b4af222b63f0de3e16b81876e5406be87f7b6fbc903634ce330bad9e150cc273 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed at b1f7ea3.
The change looks correct and minimal. sandbox_plan.path_within keeps the equality case and strips a trailing separator from the parent before it adds one, so a drive root or / now matches on both sides of the fence. For every path that does not end in a separator, the answer is the same as before. The sibling-name guard (workspace-notes against workspace) still holds because the prefix keeps its separator.
The new test fails on main for the first two asserts: on POSIX the drive root is /, and the old code tested against //. That is the right shape of proof.
No findings from me.
Two items remain before merge:
- Backend Tests shard 2 failed on
test/test_crew_log_fullscan_guard.py::test_a_warm_session_read_that_earns_a_savepoint_reads_only_the_gapwith a strict XPASS. That test is in the crew log projection code and is not related to this diff. Coverage Gate fails closed on that shard. A re-run, or a fix to that marker on main, should clear it. - This change moves the memory store fence, so a maintainer sign-off on the security side is still needed. The change only makes the fence refuse more, never less.
b1f7ea3 to
2cf762f
Compare
crosses_memory_silo tested both directions with startswith(x + os.sep). A drive root (H:\ or /) already ends in a separator, so a steering root at a drive root that contains a memory store, and a root inside a store placed at a drive root, were both cleared. Use sandbox_plan.path_within in each direction on the casefolded strings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2cf762f to
1469998
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approving at head 1469998.
This head is a rebase onto current main of the commit I reviewed earlier. git range-diff shows the single PR commit as identical (=), so my earlier review still holds.
Security checklist, answered at this head: the change only tightens the memory-silo fence. crosses_memory_silo now uses sandbox_plan.path_within in both directions instead of x + os.sep, so a drive root (/ or H:\) that already ends in a separator can no longer clear a root that contains a silo or lies inside a drive-root silo. Nothing is loosened: equality and true descendants still match, and a sibling with a shared prefix still does not. No auth, network, secret or execution surface changes.
What I verified:
- Range diff of the PR commit against the earlier reviewed head: identical patch.
- Earlier at the same patch: read both hunks (
folder_steering.py,test_chat_folder_steering_dirs.py), rantest/test_chat_folder_steering_dirs.pyand everytest_*folder_steering*file locally (205 passed), and probed the predicate directly. - Gates: readiness passed on this head, all required checks green, no AI lane BLOCK, no merge conflict, no other review requesting changes.
Problem / Motivation
Goal: Folder steering refuses a steering root that is, contains or lies inside a memory store even when the root or the store sits at a drive root (
H:\, or/).folder_steering.crosses_memory_silois the fence that keeps one memory store's Markdown out of another chat's prompt. It runs at write time (dashboard/chat_folders_paths.py, when a folder'ssteering_dirsare admitted) and again at read time (collect_folder_steering). It tests containment both ways withx.startswith(y + os.sep). A drive root already ends in a separator, soy + os.sepbecomesH:\\(or//) and the test misses both directions:workspace, or a configured workspace on that drive) is cleared;workspacesentry may name any absolute directory,H:\included) is cleared.Measured on Windows 11 / Python 3.13 at
origin/main:crosses_memory_silo(Path("G:\\"), (Path("G:\\crew\\workspace"),))isFalse, and so iscrosses_memory_silo(Path("H:\\history"), (Path("H:\\"),)). The ordinary casecrosses_memory_silo(Path("G:\\crew"), (Path("G:\\crew\\workspace"),))isTrue.Why it matters
The fence's own docstring says why it exists: a steering root over a memory store "would carry the person's memory into that member's prompt with nothing going red". In the second shape above nothing downstream catches it.
_admissible(resolved, root_resolved)uses the steering root as its base, and that root is an ordinary directory, so with a workspace atH:\and a steering root atH:\history, that store's daily history Markdown is read into every chat in the folder, a V2 member's included. The first shape is cleared by the fence today and is held back only becausesteering_target_admissiblehas the same drive-root defect and admits nothing under a drive-root base. That is an accident, not a guard.Not a goal
context_assembly/agent_spec.py::steering_target_admissible, which also appendsos.septo its base and so admits nothing under a drive-root steering root. That is a broken feature, not a leak. Fixing it here would widen what folder steering reads. Left for its own change, and it is safe to make only after this fence holds.memory_silo_fence), the degraded-fence handling, or the casefolding rule.What changed (motivation → approach → change)
y + os.sepassumesydoes not already end in a separator; a drive root or/always does.sandbox_plan.path_withinon the casefolded strings:path_within(root_cf, silo_cf) or path_within(silo_cf, root_cf).path_withinkeeps the equality case and compares againstnormpath(parent).rstrip(os.sep) + os.sep, so one call covers "is", "inside" and, reversed, "contains". The casefolding, the sibling-name guard (…/workspace-notesvs…/workspace) and the degraded-fence answer are unchanged.sandbox_planimports only the standard library, so the import adds no cycle tofolder_steering(whichcontextimports).Backwards compatibility
Compatible: for every root and silo that do not end in a separator,
path_withingives the same answer as the old test, so no steering root that is admitted today and does not cross a store changes.Reader: src/kiro_crew/dashboard/chat_folders_paths.py:_validate_steering_dirs -- crew page -- a drive-root
steering_dirsentry over a store is now refused at admission with the existing "memory store" message and SEL denial; pinned bytest_silo_fence_holds_when_either_side_is_a_drive_rooton the predicate it callsReader: src/kiro_crew/folder_steering.py:collect_folder_steering -- chat -- a stored drive-root root over a store is skipped with the existing warning, the same path a pre-validator stored value already takes;
test_folder_steering_fence.pystill passesTests
Proof: PROVEN test/test_chat_folder_steering_dirs.py::test_silo_fence_holds_when_either_side_is_a_drive_root (head b1f7ea3)
test_chat_folder_steering_dirs.py::test_silo_fence_holds_when_either_side_is_a_drive_root(new, every platform, built from the host's own drive root): a drive-root steering root over a silo crosses it; a root inside a drive-root silo crosses it; the drive root against itself crosses it. The first two fail onmain.test_silo_fence_is_case_insensitive_like_the_sensitive_path_gate(alternate case in all three directions, andworkspace-notes/WorkspaceXare NOT insideworkspace) andtest_crosses_memory_silo_clears_nothing_on_a_degraded_fence.test_chat_folder_steering_dirs.py,test_folder_steering_fence.py,test_folder_steering.py,test_chat_folders_facade.py: 41 passed, 70 skipped (POSIX-only pinned-walk cases).folder_steering.py), comment-history, brand, file-line cap, flake-pattern ratchet.Manual verification
N/A — unit coverage sufficient: the defect is a string-prefix test inside a pure predicate, and the new test drives it with the real drive root of the host it runs on.
Related Issues
Related to #24475 (same
root + os.sepdrive-root defect class; itsvalidate_cwdsite is #24504)Sibling sweep
Swept:
git grep -nE "startswith\(.{0,60}(\+ ?os\.sep|\+ ?os\.path\.sep)" -- src/kiro_crewSibling: src/kiro_crew/folder_steering.py:339 -- changed here -- both directions of the silo fence
Sibling: src/kiro_crew/context_assembly/agent_spec.py:70 -- not affected -- fails closed at a drive-root base (admits nothing); out of goal, see Not a goal
Sibling: src/kiro_crew/folder_steering.py:176 -- not affected -- skip roots are
.kiro/steeringdirs, never a drive rootSibling: src/kiro_crew/subagent_parts/agent_policy.py:941 -- tracked in #24504 -- validate_cwd allow-list
Sibling: src/kiro_crew/dashboard/terminal_commands.py:472 -- tracked in #24694 -- agent-writable PATH filter
Sibling: src/kiro_crew/name_grant.py:534 -- tracked in #24694 -- name-grant agent-tree refusal
Pattern harvest
Rule candidate: semgrep
Pattern:
x.startswith(root + os.sep)whererootcame fromrealpath/resolveof a configured directory; usesandbox_plan.path_within, since a drive root or/already ends in a separatorChecklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
🤖 Generated with Claude Code