Improve rules with filters, conditions, and scoped loading#429
Merged
Improve rules with filters, conditions, and scoped loading#429
Conversation
- Add YAML frontmatter support for filtering rules by agent, model, paths, and enforcement mode. - Split rules into static prompt-injected rules and path-scoped rules that can be loaded on demand with `fetch_rule`. - Add condition-variable rendering, `/rules` inspection, docs, and tests for the expanded rules behavior. - Add template variables documentation (as that can be used in Rules as well)
…nd_tool # Conflicts: # CHANGELOG.md # src/eca/features/chat.clj
40d5af8 to
0e2e0da
Compare
There was a problem hiding this comment.
Pull request overview
This PR expands ECA’s rules system to support YAML-frontmatter filtering (agent/model/path/enforcement), splits rules into static vs path-scoped (on-demand) loading via a new fetch_rule tool, and adds Selmer condition-variable rendering plus /rules inspection with accompanying docs/tests.
Changes:
- Add YAML frontmatter parsing and rule filtering/partitioning into
:staticand:path-scoped, with path matching and enforcement metadata. - Introduce
fetch_ruletool and path-scoped rule enforcement gates for file tools (read/modify), plus prompt/catalog rendering updates. - Add
/rulescommand output, documentation updates, and comprehensive unit/integration tests.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
test/eca/shared_test.clj |
Adds coverage for new path normalization, Selmer rendering fallback behavior, and frontmatter parsing errors. |
test/eca/features/tools_test.clj |
Adds end-to-end tests for eca__fetch_rule and rule-enforced file tool flows. |
test/eca/features/tools/filesystem_test.clj |
Verifies enforcement gating behavior in filesystem tools depending on fetch_rule availability. |
test/eca/features/rules_test.clj |
Large expansion of rules tests for filtering, partitioning, matching, id lookup, and real-file loading. |
test/eca/features/prompt_test.clj |
Updates prompt-building tests for static/global/project rule grouping and path-scoped catalog rendering. |
test/eca/features/commands_test.clj |
Adds /rules command tests to validate output structure and filtering metadata display. |
test/eca/features/chat_test.clj |
Adds prompt cache reuse test to ensure cache keying includes both agent and model. |
src/eca/shared.clj |
Implements YAML frontmatter parsing, symlink-safe normalization, path-inside-root?, and safe-selmer-render. |
src/eca/oauth.clj |
Minor require/order changes to support Selmer usage consistently. |
src/eca/features/tools/util.clj |
Adds tool-available? helper and updates workspace path checks to use normalized path logic. |
src/eca/features/tools/skill.clj |
Adds :enabled-fn so skill tool is enabled only when skills exist. |
src/eca/features/tools/path_rules.clj |
New module to track per-chat validated path rules and compute missing enforced rules for read/modify. |
src/eca/features/tools/filesystem.clj |
Integrates path-scoped rule enforcement into read_file, write_file, and edit_file. |
src/eca/features/tools/fetch_rule.clj |
New fetch_rule tool: validates rule+path match, renders content with Selmer ctx, records validation. |
src/eca/features/tools.clj |
Wires fetch_rule into native tools and standardizes Selmer rendering via shared/safe-selmer-render. |
src/eca/features/rules.clj |
Reworks rule loading: parse frontmatter, filter by agent/model, partition static vs path-scoped, add path matching. |
src/eca/features/prompt.clj |
Updates prompt assembly to render static rules with grouping and include a path-scoped catalog when available. |
src/eca/features/commands.clj |
Adds /rules command implementation and formatting for static vs path-scoped rule visibility. |
src/eca/features/chat.clj |
Updates rule loading callsite and prompt-cache keying to include model (agent+model cache correctness). |
src/eca/config.clj |
Allows eca__fetch_rule in default approval policies for relevant agents/modes. |
resources/prompts/tools/fetch_rule.md |
Adds tool help text explaining id/path contract, glob semantics, and enforcement behavior. |
mkdocs.yml |
Adds “Templates” doc page to navigation. |
integration-test/integration/chat/commands_test.clj |
Ensures /rules appears in the available commands list. |
docs/config/template.md |
Documents Selmer condition variables for prompts/rules (including tool-enabled flags). |
docs/config/rules.md |
Major documentation update for rule sources, static vs path-scoped rules, frontmatter fields, and enforcement. |
docs/config/agents.md |
Links agent prompt customization to the new templates documentation. |
CHANGELOG.md |
Adds an unreleased entry describing the expanded rules functionality. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0e2e0da to
c3310fa
Compare
c3310fa to
86cef74
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.
Add YAML frontmatter support for filtering rules by agent, model, paths, and enforcement mode.
Split rules into static prompt-injected rules and path-scoped rules that can be loaded on demand with
fetch_rule.Add condition-variable rendering,
/rulesinspection, docs, and tests for the expanded rules behavior.I added a entry in changelog under unreleased section.
This is not an AI slop.