Skip to content

feat(aidd-context): check existing rules for overlap or conflicts during rule generation #791

Closed

Description

@waewoo

Problem

aidd-context:05-rule-generate captures a rule intent, writes the rule for the selected target tools, then validates the generated files against the rule-authoring and tool-path contracts.

The workflow does not currently make comparison with the project's existing rules an explicit validation step before writing the candidate rule. As the rule corpus grows, a generated rule can duplicate an existing instruction, partially overlap it, contradict it, or introduce a different scope or priority for an already-covered concern.

This matters because repository-level AGENTS.md already requires checking whether an existing instruction, finding, or rule covers or contradicts a new one, then merging, removing, or clarifying it when necessary. The principle exists, but is not an explicit 05-rule-generate contract.

Scope

  • Discover existing project rules relevant to the candidate before writing it through the canonical 05-rule-generate/references/tool-paths.md reference; do not add a tool-specific path list to this assessment.
  • Assess the candidate policy, intent, and scope rather than comparing only its topic or title.
  • Exclude expected cross-tool renderings of the same canonical policy from duplicate findings and filter rules whose scopes are disjoint from the candidate.
  • Classify the candidate as new, covered, overlap, conflict, or needs review.
  • Surface the existing rule files involved in every non-new result.
  • Add an explicit pre-write assessment step between capture and write: 01 capture → 02 assess existing rules → 03 write → 04 validate.
  • Stop before writing until the user has explicitly chosen how to handle the assessment result.
  • Offer resolutions such as keeping the existing rule, merging, updating, clarifying scope or priority, creating anyway, or cancelling.
  • Require explicit user approval before modifying an existing rule.
  • Keep this as a guard inside 05-rule-generate, not a new skill.
  • Preserve the existing write and validation contracts.

Acceptance criteria

  • The workflow performs an explicit assessment step after capture and before writing.
  • Rule sources are discovered through the canonical 05-rule-generate/references/tool-paths.md reference.
  • Given a candidate whose policy is already expressed by an applicable existing rule, rule-generate identifies that rule before creating a duplicate.
  • Given compatible but partially redundant instructions, the workflow reports overlap and identifies both rule sources.
  • Given Always use pytest for unit tests and Use unittest for all unit tests, the workflow reports conflict before writing the candidate.
  • Rules with disjoint scopes are excluded from overlap and conflict findings.
  • Expected cross-tool renderings of the same canonical policy are not reported as duplicates.
  • Each candidate is classified as new, covered, overlap, conflict, or needs review.
  • Every non-new result identifies the involved rule files.
  • The user makes an explicit decision before the candidate is written.
  • The user can explicitly choose how to resolve an overlap or conflict.
  • Existing rule files are never modified without explicit user approval.
  • A candidate classified as new continues through the existing write and validation workflow.
  • Existing structural, path, frontmatter, and per-tool validation behavior remains unchanged.

Prior art in this repo

  • AGENTS.md#L27 already requires checking whether an existing instruction, finding, or rule covers or contradicts a new one before adding it.
  • 05-rule-generate/SKILL.md#L8-L19 defines the current three-action flow: capture, write, validate; this issue adds the pre-write assessment step.
  • tool-paths.md is the canonical source for supported rule surfaces and target paths.
  • 01-capture-rule.md#L3-L28 captures topic, category, slug, scope, and write mode; it does not define semantic comparison with the existing rule corpus.
  • 02-write-rule.md#L3-L26 builds and renders the rule for supported tools.
  • 03-validate.md#L3-L22 validates written files against the authoring and tool-path contracts, but does not define a cross-rule consistency check.

I searched the repository's open and closed issues and pull requests for an equivalent semantic duplicate, overlap, or conflict proposal. Issue #788 concerns current Kilo/OpenCode output paths, not semantic consistency, so it is not a duplicate.

Out of scope

Activity

  1. added theissue type on Sep 7, 2026
  2. blafourcade commented on Sep 14, 2026

    @blafourcade
    Contributor

    Rule discovery must keep one source of truth. This issue should consume 05-rule-generate/references/tool-paths.md rather than add a Kilo-specific path list.

    When #788 adds Kilo to that reference, the overlap and conflict check should pick it up through the same discovery path as every other tool.

    Update — 2026-09-23

    #788 was superseded by #913 and #914. #913 now owns OpenCode rule wiring; #914 owns Kilo-native path and detection support. This semantic guard should still consume 05-rule-generate/references/tool-paths.md and inherit those changes without a tool-specific path list.

  3. blafourcade commented on Sep 14, 2026

    @blafourcade
    Contributor

    The comparison needs the candidate policy, not only its topic, so it should not be folded into capture-rule.

    Add one pre-write action instead:

    01 capture → 02 assess existing rules → 03 write → 04 validate

    The new action discovers rule sources from the canonical path reference, excludes expected cross-tool renderings of the same policy, filters disjoint scopes, and reports new, covered, overlap, conflict, or needs review with the files involved. It stops for an explicit user decision before any write.

    This is a guard inside 05-rule-generate, not a new skill. #792 remains the separate, read-only retrospective audit of an entire existing corpus.

  4. moved this from Ideation to Todo in AIDD Roadmapon Sep 14, 2026
  5. waewoo commented on Sep 14, 2026

    @waewoo
    ContributorAuthor

    Thanks, this clarifies the pre-write seam.

    I updated the issue to add an explicit assessment step between capture and write, reuse 05-rule-generate/references/tool-paths.md as the single discovery source, exclude expected cross-tool renderings and disjoint scopes, and classify results as new, covered, overlap, conflict, or needs review.

    The workflow will stop for an explicit user decision before writing, while #792 remains the separate retrospective audit of an existing rule corpus.

  6. changed the issue type fromtoon Sep 23, 2026
  7. moved this from Todo to In Progress in AIDD Roadmapon Oct 12, 2026
  8. moved this from In Progress to In review in AIDD Roadmapon Oct 12, 2026
  9. 2 remaining items

  10. blafourcade commented on Oct 16, 2026

    @blafourcade
    Contributor

    Merged in #1006 (708eefa) on next. Deviations from the original plan: the assessment lives inside capture-rule (two actions, capture-rule and write-rule), and tool-paths.md became rule-publication.md. Writer gained --plan and --check --publish. Not replayed on Codex, Cursor, OpenCode (no access): replay checklist is in the #1006 description.

  11. moved this from In review to Done in AIDD Roadmapon Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    Priority

    Medium

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions