Skip to content

fix(steering): hold the memory-silo fence when a root is a drive root - #24743

Merged
bolichen97 merged 1 commit into
kirodotdev:mainfrom
leonlaiyc:claude/steering-silo-drive-root
Oct 27, 2026
Merged

bolichen97 merged 1 commit into
kirodotdev:mainfrom
leonlaiyc:claude/steering-silo-drive-root

Conversation

@leonlaiyc

Copy link
Copy Markdown
Contributor

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_silo is 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's steering_dirs are admitted) and again at read time (collect_folder_steering). It tests containment both ways with x.startswith(y + os.sep). A drive root already ends in a separator, so y + os.sep becomes H:\\ (or //) and the test misses both directions:

  • a steering root at a drive root that contains a silo (the data home's workspace, or a configured workspace on that drive) is cleared;
  • a steering root inside a silo that is itself a drive root (a workspaces entry 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"),)) is False, and so is crosses_memory_silo(Path("H:\\history"), (Path("H:\\"),)). The ordinary case crosses_memory_silo(Path("G:\\crew"), (Path("G:\\crew\\workspace"),)) is True.

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 at H:\ and a steering root at H:\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 because steering_target_admissible has 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 appends os.sep to 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.
  • What counts as a silo (memory_silo_fence), the degraded-fence handling, or the casefolding rule.
  • The dashboard file API and terminal/name-grant sites of the same class (fix(terminal): count paths under a drive-root project as agent-writable #24694, and a sibling PR for the file API).

What changed (motivation → approach → change)

  • Symptom → cause: y + os.sep assumes y does not already end in a separator; a drive root or / always does.
  • Change: both directions now ask sandbox_plan.path_within on the casefolded strings: path_within(root_cf, silo_cf) or path_within(silo_cf, root_cf). path_within keeps the equality case and compares against normpath(parent).rstrip(os.sep) + os.sep, so one call covers "is", "inside" and, reversed, "contains". The casefolding, the sibling-name guard (…/workspace-notes vs …/workspace) and the degraded-fence answer are unchanged.
  • sandbox_plan imports only the standard library, so the import adds no cycle to folder_steering (which context imports).

Backwards compatibility

Compatible: for every root and silo that do not end in a separator, path_within gives 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_dirs entry over a store is now refused at admission with the existing "memory store" message and SEL denial; pinned by test_silo_fence_holds_when_either_side_is_a_drive_root on the predicate it calls
Reader: 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.py still passes

Tests

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 on main.
  • Existing guards still pass: test_silo_fence_is_case_insensitive_like_the_sensitive_path_gate (alternate case in all three directions, and workspace-notes / WorkspaceX are NOT inside workspace) and test_crosses_memory_silo_clears_nothing_on_a_degraded_fence.
  • Windows 11, Python 3.13: 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).
  • black, isort, flake8, mypy (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.sep drive-root defect class; its validate_cwd site is #24504)

Sibling sweep

Swept: git grep -nE "startswith\(.{0,60}(\+ ?os\.sep|\+ ?os\.path\.sep)" -- src/kiro_crew
Sibling: 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/steering dirs, never a drive root
Sibling: 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) where root came from realpath/resolve of a configured directory; use sandbox_plan.path_within, since a drive root or / already ends in a separator

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

Contribution License Agreement

🤖 Generated with Claude Code

@leonlaiyc
leonlaiyc requested review from a team and KiroCrewCaptain as code owners October 27, 2026 05:42
@leonlaiyc
leonlaiyc requested a review from bolichen97 October 27, 2026 05:42
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 1469998ef5dae2b794d066b75cd4c01693c7c85d via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .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 Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 1469998ef5dae2b794d066b75cd4c01693c7c85d 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 Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 1469998ef5dae2b794d066b75cd4c01693c7c85d via the fork AI-review pipeline — 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

This fixes a real fence at the mechanism level by reusing the existing sandbox_plan.path_within. The other sites with the same defect are tracked in #24504 and #24694, or ruled out of the Goal.

What this change ships

Inventory (2 items) — 2 justified

Intent: keep one memory store's Markdown out of another chat's prompt when a steering root or a store sits at a drive root (H:\, /). FIX.

  1. A steering root at a drive root that contains a memory store is now refused at admission and skipped at read time. — justified
  2. A steering root inside a memory store that sits at a drive root is now refused or skipped the same way. — justified

[FIRST-PRINCIPLES-REVIEWED] 1469998

Description read

[DESCRIPTION-READ] b4af222b63f0de3e16b81876e5406be87f7b6fbc903634ce330bad9e150cc273

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 Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 1469998ef5dae2b794d066b75cd4c01693c7c85d via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 1469998

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 1469998ef5dae2b794d066b75cd4c01693c7c85d via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 1469998

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

  1. 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_gap with 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.
  2. 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.

@bolichen97
bolichen97 force-pushed the claude/steering-silo-drive-root branch from b1f7ea3 to 2cf762f Compare October 27, 2026 13:05
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 27, 2026
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>
@bolichen97
bolichen97 force-pushed the claude/steering-silo-drive-root branch from 2cf762f to 1469998 Compare October 27, 2026 17:05
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 27, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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), ran test/test_chat_folder_steering_dirs.py and every test_*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.

@bolichen97
bolichen97 merged commit 506901b into kirodotdev:main Oct 27, 2026
105 of 107 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants