Skip to content

fix(core): bound instruction ancestor walk at the filesystem root - #50544

Closed
holny wants to merge 1 commit into
anomalyco:v2from
holny:fix-50296-ancestor-walk
Closed

holny wants to merge 1 commit into
anomalyco:v2from
holny:fix-50296-ancestor-walk

Conversation

@holny

@holny holny commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #50296

Type of change

  • Bug fix

What does this PR do?

ancestorDirectories in packages/core/src/config/plugin/instruction.ts only stops recursing when start string-equals stop. On Windows the two path forms drift in separator or case so the walk blows past stop. Since dirname("C:\\") returns "C:\\" the recursion never bottoms out — it overflows the stack with a RangeError, the source-activation guard catches it, and core/instructions ends up unavailable for every session drain.

The walk is now iterative with an explicit filesystem-root bound, so it terminates at the root even when stop is never string-reached.

How did you verify your code works?

Added test/config/instruction-ancestors.test.ts with a case where stop is never an ancestor — the old recursive form overflows the stack on it, the new one returns the walk up to the root. bun test test/config test/instruction-state.test.ts test/instructions test/session-instructions.test.ts is 239 pass / 0 fail. bun typecheck clean.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Closes #50296

ancestorDirectories only stopped when start string-matched stop, so any path-form drift (separator or case) walked past stop and dirname at the root kept returning the root - infinite recursion, RangeError, and the source marked unavailable, blocking instruction initialization for every session. Walk iteratively with an explicit root bound instead.
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@VimWei

VimWei commented Sep 23, 2026

Copy link
Copy Markdown

#50296 (comment)

@holny

holny commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

The issue was closed as completed after #53349 landed — stopping the walk at case-variant Windows roots covers the same mismatch this PR was bounding at the filesystem root. Closing in favor of the upstream fix.

@holny holny closed this Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants