Repository navigation
Description
Context
#2506 added isWithin(root, path, rule) to @schlessera/brain-common/internal/safe-path and moved the twelve named containment predicates onto it. Outside those twelve, about 110 inline containment checks remain under packages/*/src. They use the shapes startsWith(\${dir}/`), startsWith(dir + sep)andstartsWith(dir + "/")`. Further named copies remain as well:
withininpackages/ui-server/src/brain/private-index-cache.ts,protected-target.ts,governance-policy.ts,turn-data-tree.tsandpackages/ui-server/src/inbox/provenance.ts;underinpackages/core/src/lib/scratch.ts;insideinpackages/core/src/lib/skills/core-installation.ts,packages/core/src/lib/skills/sync.tsandpackages/core/src/lib/storage-inventory.ts(relative()-based).
Epic #2539's definition of done asks for a lint check that refuses a reintroduced inline startsWith(root + "/").
isWithin is not on main yet: it lands with #2506's PR #3424, which targets the epic/2539-security-helpers integration branch. Start from that branch (or main once the epic batch lands) after #3424 merges, and re-run the inventory grep there, since the counts above predate it.
The inventory came from this grep, which also matches some non-path prefixes, such as UI routes in ui-react:
grep -rnE 'startsWith\(\s*(`\$\{[A-Za-z_.!]+\}(/|\$\{sep\})`|[A-Za-z_.!]+ ?\+ ?(sep|"/")\s*\))' packages/*/srcIts heaviest files are packages/ui-sdk/src/server/worker-protection.ts (8), worker-native-output.ts (7), packages/ui-server/src/brain/provider-types.ts (6), packages/ui-sdk/src/server/worker-output.ts (6) and worker-launcher.ts (6).
Scope
- Replace every path-containment instance the grep finds with
isWithinand the parameters that keep its current answer, along with the named copies listed above. Leave non-path string prefixes alone, and list them. - Add a
bun run lintgate that refuses the inline shapes inpackages/*/src, with an allowlist for non-path prefixes.
Out of scope
- Changing any caller's answer, including the
/deny-direction question, which is tracked in core, ui-sdk, ui-server: rule on the containment answers the shared resolver still keeps per caller #3422. provider-hardlinks.ts(Buffer paths) and the multi-folder matcher inprovider-types.ts.
Acceptance criteria
- The grep above finds only allowlisted non-path prefixes.
- The lint gate fails on a reintroduced
startsWith(\${root}/`)` in a package source file, with a mutation receipt in the PR. - Existing tests for each touched file pass unchanged.
Verification
bun run lint
bun run test packages/core packages/ui-sdk packages/ui-serverContract impact
None.
Refs #2506
Blocked by #2506
Triage 2026-11-03: verified the blocker: #2506 is open and its PR #3424 is unmerged (base epic/2539-security-helpers), so blocked stays. Named the integration branch, linked #3422 for the deny-direction question. Brief complete; agent-ready alongside blocked.
Activity
schlessera commentedon Nov 3, 2026
Unblocked: its only blocker, #2506, closed when epic #2539 batch 2 landed on main in #3506 (merge
f4ea8ae6f). The epic branchepic/2539-security-helpersis now at that merge.schlessera commentedon Nov 4, 2026
Claimed (token
c3423-0e1c). Branchfeat/3423-iswithin-inlinefromepic/2539-security-helpers(fast-forwarded to main5c9b23d44); PR will target the epic branch.schlessera commentedon Nov 4, 2026
PR #3575 (head
5391db4b6, baseepic/2539-security-helpers) is ready for review. It moves every inline containment site and named copy ontoisWithinwithout changing any answer, and adds thecheck-inline-containmentlint gate with mutation receipts. Hosted proof is pending. Found during the run and filed separately: #3574 (a ui-server mount-timer flake under load). I keep the assignment while the PR is live.refactor(packages): route inline startsWith containment checks throug…
Merge branch 'main' into epic/2539-security-helpers
Merge pull request #3576 from schlessera/epic/2539-security-helpers