fix: resolve functionsDir relative to ruleset file, not process CWD. …#48
Merged
Conversation
25f84fe to
124ece9
Compare
124ece9 to
97b35f9
Compare
eskenazit
reviewed
Jun 16, 2026
eskenazit
left a comment
Contributor
There was a problem hiding this comment.
Good fix overall — the core logic in RulesetValidator and RulesetValidatorFactory is correct and well-tested. One observation on the regression test (1).
97b35f9 to
2abcd35
Compare
2abcd35 to
f1ad2a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…Closes #44
Related Issue
Closes #44
What does this PR do?
When a ruleset declares
functionsDir: ./functions(a path relative to the ruleset file), Polychro was resolving it against the process working directory (CWD) instead of the ruleset file's parent directory. This caused custom JS functions to be silently skipped whenever--rulesetwas passed as an absolute (or otherwise non-CWD-relative) path.Root cause:
RulesetValidatorFactory.create()correctly computedbaseDirfrom the ruleset path, but never passed it tonew RulesetValidator(ruleset, includeNonRecommended). Inside that constructor,Path.of(ruleset.functionsDir())created a CWD-relative path that could not be resolved to the actual scripts.Fix:
RulesetValidator(Ruleset, Path baseDir, boolean)constructor that resolvesfunctionsDiragainstbaseDirviabaseDir.resolve(raw).normalize()whenbaseDiris non-null.baseDir = null) to preserve the current CWD-relative behaviour for inline-content rulesets.RulesetValidatorFactory.create()now extractsbaseDirfromrulesetPathand forwards it to the new three-arg constructor; the content-only path continues to use the two-arg constructor.Tests
Added
FunctionsDirResolutionTestinpolychro-ruleset-polyglot:functionsDir: ./functionsto a JUnit@TempDiralongside a copy ofunique-namespaces.js.@TempDirroot, not therules/sub-directory).naftiko-unique-namespacesdiagnostic.This test was written first (RED), then the fix was applied (GREEN), confirming the regression. All 637 existing tests in
polychro-api,polychro-ruleset, andpolychro-ruleset-polyglotcontinue to pass.Checklist
mainAgent Context (optional)