Skip to content

Improve rules with filters, conditions, and scoped loading#429

Merged
ericdallo merged 3 commits intomasterfrom
rules_improvement_and_tool
Apr 27, 2026
Merged

Improve rules with filters, conditions, and scoped loading#429
ericdallo merged 3 commits intomasterfrom
rules_improvement_and_tool

Conversation

@zikajk
Copy link
Copy Markdown
Member

@zikajk zikajk commented Apr 26, 2026

  • 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.

  • I added a entry in changelog under unreleased section.

  • This is not an AI slop.

- 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)
@zikajk zikajk requested a review from ericdallo April 26, 2026 16:37
…nd_tool

# Conflicts:
#	CHANGELOG.md
#	src/eca/features/chat.clj
@zikajk zikajk force-pushed the rules_improvement_and_tool branch 2 times, most recently from 40d5af8 to 0e2e0da Compare April 27, 2026 05:34
@ericdallo ericdallo requested a review from Copilot April 27, 2026 13:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :static and :path-scoped, with path matching and enforcement metadata.
  • Introduce fetch_rule tool and path-scoped rule enforcement gates for file tools (read/modify), plus prompt/catalog rendering updates.
  • Add /rules command 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.

@zikajk zikajk force-pushed the rules_improvement_and_tool branch from 0e2e0da to c3310fa Compare April 27, 2026 13:38
@zikajk zikajk force-pushed the rules_improvement_and_tool branch from c3310fa to 86cef74 Compare April 27, 2026 14:40
Copy link
Copy Markdown
Member

@ericdallo ericdallo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@ericdallo ericdallo merged commit 881d2b4 into master Apr 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants