Skip to content

fix(ai): resolve rule file relative paths against the project dir - #758

Merged
tangcent merged 1 commit into
masterfrom
fix/754-read-rule-file-project-relative-path
Aug 31, 2026
Merged

fix(ai): resolve rule file relative paths against the project dir#758
tangcent merged 1 commit into
masterfrom
fix/754-read-rule-file-project-relative-path

Conversation

@tangcent

Copy link
Copy Markdown
Owner

Summary

  • read_rule_file failed when the agent passed a relative path (e.g. .easy.api.properties): path resolution anchored at the JVM working directory instead of the project, so the agent could not read the existing rules and generated new ones blind.
  • RuleFileResolver.absolutize() now anchors relative paths at the project base path; both the allow-list check in resolve() and the consent-granted read path in ReadRuleFileTool go through it. The tool description documents the behavior for the model.
  • Fixes [BUG] AI rule authoring: read_rule_file resolves relative path against process working directory #754

Testing

  • RuleFileResolverTest — a relative path resolves against the project dir and passes the allow-list check.
  • PerceptionToolsTestread_rule_file with a relative path returns the file content.
  • Ran: ./gradlew test --tests "com.itangcent.easyapi.core.config.config.source.RuleFileResolverTest" --tests "com.itangcent.easyapi.core.ai.tools.PerceptionToolsTest" — green.

Risks / rollback

  • Absolute paths, allow-list security checks, and the out-of-scope consent flow are unchanged. write_rule_file relative paths now land in the project instead of the IDE working directory, which is the intended behavior.
  • Single-commit revert if needed.

@github-actions github-actions Bot added the type: bug Something isn't working label Aug 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Plugin has been packaged for this PR. You can download easy-api-3.1.9.252.0.zip from the GitHub Actions workflow run by clicking on the "Artifacts" dropdown.

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.827%. Comparing base (f6f7d03) to head (319bff1).

Files with missing lines Patch % Lines
...ent/easyapi/core/config/source/RuleFileResolver.kt 75.000% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##            master      #758       +/-   ##
=============================================
- Coverage   66.827%   66.827%   -0.000%     
=============================================
  Files          443       443               
  Lines        25952     25955        +3     
  Branches      6195      6196        +1     
=============================================
+ Hits         17343     17345        +2     
  Misses        6289      6289               
- Partials      2320      2321        +1     
Flag Coverage Δ
unittests 66.827% <80.000%> (-<0.001%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...tangcent/easyapi/core/ai/tools/ReadRuleFileTool.kt 75.556% <100.000%> (ø)
...ent/easyapi/core/config/source/RuleFileResolver.kt 73.810% <75.000%> (-0.549%) ⬇️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f6f7d03...319bff1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

❌ Some commit messages don't follow the conventional format.

Invalid commits:

  • Merge branch 'master' into fix/754-read-rule-file-project-relative-path

Please update your commits to follow the format:

type: description
# or for releases:
release x.y.z

Valid types:

  • feat: New feature (type: new feature)
  • fix: Bug fix (type: bug)
  • docs: Documentation changes (type: doc)
  • test: Adding/updating tests (type: test)
  • chore: Maintenance tasks (type: chore)
  • enhance: Enhancement to existing features (type: enhancement)
  • amend: Small amendments (type: amend)
  • style: Code formatting (type: chore)
  • refactor: Code restructuring (type: enhancement)
  • perf: Performance improvements (type: enhancement)
  • build: Build system changes (type: chore)
  • release: Release version (type: release)

You can update your commit messages using:

git rebase -i HEAD~n  # where n is the number of commits to edit
# Change 'pick' to 'reword' for commits you want to edit

The AI rule-authoring assistant could not read an existing project
rule file when it passed a relative path (e.g. `.easy.api.properties`):
the read resolved against the process working directory, so the agent
generated rules without ever seeing the current configuration.

Root cause: both the allow-list resolution in RuleFileResolver and the
consent-granted read path in ReadRuleFileTool absolutised relative
paths via Paths.toAbsolutePath(), which anchors at the JVM working
directory instead of the project.

Solution: RuleFileResolver.absolutize() now anchors relative paths at
the project base path; resolve() and the consent read path go through
it, and the tool description documents the behaviour for the model.

Impact: write_rule_file also resolves relative paths against the
project now; absolute paths, the allowed-dir security checks and the
consent flow are unchanged.

Fixes: #754
@github-actions

Copy link
Copy Markdown
Contributor

📦 Plugin has been packaged for this PR. You can download easy-api-3.1.9.252.0.zip from the GitHub Actions workflow run by clicking on the "Artifacts" dropdown.

@tangcent
tangcent force-pushed the fix/754-read-rule-file-project-relative-path branch from cdedc7a to 319bff1 Compare August 31, 2026 12:25
@github-actions

Copy link
Copy Markdown
Contributor

📦 Plugin has been packaged for this PR. You can download easy-api-3.1.9.252.0.zip from the GitHub Actions workflow run by clicking on the "Artifacts" dropdown.

@tangcent
tangcent merged commit 9394091 into master Aug 31, 2026
12 checks passed
@tangcent
tangcent deleted the fix/754-read-rule-file-project-relative-path branch August 31, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] AI rule authoring: read_rule_file resolves relative path against process working directory

1 participant