Skip to content

fix(config): merge ignore.files and index_skip_files instead of overwriting - #477

Merged
ajianaz merged 1 commit into
developfrom
fix/ignore-config-merge-overwrite
Aug 4, 2026
Merged

fix(config): merge ignore.files and index_skip_files instead of overwriting#477
ajianaz merged 1 commit into
developfrom
fix/ignore-config-merge-overwrite

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

What

Config merge in CoraFile::merge_into used clone_from/clone for two Vec fields with non-empty defaults:

  1. ignore.files (line 530) — defaults: node_modules/**, dist/**, target/**, .git/**
  2. rules_config.index_skip_files (line 620) — defaults: *.config.ts, *.config.js, *.config.mjs, etc.

When a user specified any custom value in .cora.yaml, all defaults were silently overwritten — not merged.

Fix: extend defaults with user values, with deduplication to avoid redundant entries.

Why

Bug impact across all cora commands:

Command Affected path Symptom
cora review context_chainignore_patterns Build artifacts (target/debug/*, node_modules/) leak into review context, wasting tokens and confusing the LLM
cora scan walk_projectexclude_patterns Dependencies and compiled output enter scan scope
cora index (scanner) index_skip_files Framework config files (vite.config.ts, next.config.js) generate false-positive findings
cora config show Display Effective config only shows user patterns, hiding that defaults were lost

Root cause: clone_from(v) replaces the entire Vec. Should be extend(v) with dedup check.

Testing

  • cargo test --bin cora776 passed, 0 failed
  • cargo test --test *22 passed (cli_basic + config_loading)
  • cargo clippy --bin cora -- -D warningsclean
  • cora review pre-commit hook — No issues found
  • Manual smoke test: .cora.yaml with ignore.files: [vendor/**, *.lock]cora config show correctly displays node_modules/**, dist/**, target/**, .git/**, vendor/**, *.lock

New tests added:

  • merge_ignore (updated) — asserts defaults preserved + user value present
  • merge_ignore_files_dedup — verifies no duplicate when user specifies a default pattern
  • merge_index_skip_files_preserves_defaults — asserts default skip files preserved + user value present

Notes

  • ignore.rules merge left as clone_from — default is empty [], so clone is correct behavior
  • focus merge left as clone_from — intentionally overwrite (focus narrowing is a valid use case, not a safety issue)
  • Pre-existing bug found: --config flag does not load file (separate issue, not fixed in this PR)

…riting

Config merge used clone_from/clone for ignore.files and index_skip_files,
which silently overwrote default patterns when a user specified any custom
value. This caused build artifacts (target/**, dist/**, node_modules/**,
.git/**) and framework config files (*.config.ts, *.config.js) to leak
into review context, scan walks, and index-based scanner output.

Fix: extend defaults with user values instead of replacing, with
deduplication to avoid redundant entries.

Impact:
- cora review: context_chain now correctly filters default-ignored paths
- cora scan: walk_project exclude patterns now include defaults
- cora index: index-based scanner skip files preserved
- cora config show: effective config displays merged patterns

Tests: 3 new tests (merge_ignore updated, dedup, index_skip_files).
776 unit + 22 integration tests pass. Clippy clean.
@ajianaz
ajianaz merged commit 586e4fa into develop Aug 4, 2026
13 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.

1 participant