.cceignore: patterns starting with '.' never match root entries (lstrip("./")), and cce index --path bypasses directory exclusions
1. Dotted patterns never match at the project root
matches_any (src/context_engine/indexer/ignorefile.py) normalizes the path with:
rel = rel_path.replace("\\", "/").lstrip("./")
str.lstrip strips a set of characters, so every leading . is removed as well. A root-level .pytest-tmp-ci is then matched as pytest-tmp-ci, so .pytest-tmp*/, .env, .mcp.json or .claude/settings.local.json in .cceignore exclude nothing at the root. For example, with .cceignore containing .pytest-tmp*/, matches_any(".pytest-tmp-ci", True, patterns) returns False.
Impact: in our repository, 27 pytest --basetemp directories (.pytest-tmp-*) made up about 90% of the index despite a .cceignore entry.
Suggested fix: strip only a leading ./ prefix (e.g. rel[2:] if rel.startswith("./") else rel, then lstrip("/")), plus a test with dotted root entries.
Workaround we use: list each dotted pattern a second time without its dot.
2. cce index --path <dir> bypasses directory exclusions
For a directory target, the walk starts inside <dir> and never tests <dir> itself or its ancestors against .cceignore. cce index --path data therefore indexes data/ even when data/ is excluded. The single-file target path does check ancestors (_cceignore_matches_file). This is close to #127, but concerns .cceignore directory rules rather than secret filenames.
Checked against v0.4.26 and current main (7507115).
🤖 Generated with Claude Code
Thanks for filing this — we hit it independently and can add two things.
Confirmed on 0.4.26, and main is still unfixed. The normalisation is unchanged:
# Normalise: forward slashes, no leading "./"
rel = rel_path.replace("\\", "/").lstrip("./")
str.lstrip(chars) strips any leading characters in the set {'.', '/'}, repeatedly — the
comment shows the intent is the two-character prefix "./". The leading dot is gone before any
comparison, so no pattern beginning with . can ever match.
1. It reaches the directory walk, not just the matcher. Our repro builds a real tree and runs the real iterator:
import tempfile
from pathlib import Path
from context_engine.indexer.ignorefile import load_ignore_patterns
from context_engine.indexer.pipeline import _iter_project_files
d = Path(tempfile.mkdtemp())
for sub in ('.web-cache', 'scratch'):
(d / sub).mkdir()
(d / sub / 'f.txt').write_text('x')
(d / '.cceignore').write_text('.web-cache/\nscratch/\n')
pats = load_ignore_patterns(d)
print(sorted(str(p.relative_to(d)) for p in
_iter_project_files(d, set(), set(), cceignore_patterns=pats)))
# ['.cceignore', '.web-cache/f.txt'] <-- .web-cache/ did NOT take effect
# scratch/f.txt correctly excluded
The files are read and embedded. Nothing errors, nothing warns.
2. The opposite direction is broken too, and it's the one with teeth: undotted patterns
over-match their dotted siblings. Because the dot is stripped from the path, a pattern aimed at an
undotted directory also swallows the dotted one. Routed through _cceignore_matches_file — how
pipeline.py:270 actually calls it, with the ancestor re-check:
from context_engine.indexer.pipeline import _cceignore_matches_file
_cceignore_matches_file('.env/foo', ['env/']) # True <- should be False
_cceignore_matches_file('.secrets/token', ['secrets/']) # True <- should be False
_cceignore_matches_file('.github/workflows/ci.yml', ['github/']) # True <- should be False
This matters more than the no-op: someone who writes a pattern for secrets/ silently also excludes
.secrets/ — they think they scoped an index and instead created a hole.
Isolated, the bug is visible in one call:
matches_any('.web-cache', is_dir=True, ['.web-cache/']) # False <- expect True
matches_any('.web-cache', is_dir=True, ['web-cache/']) # True
Note that is_dir=False hides it: a trailing-slash pattern short-circuits at
if is_dir_pat and not is_dir: continue, so the bug is only reachable via the directory case or the
ancestor re-check. A test that passes a file would look green.
3. Why it hasn't been widely reported. DEFAULT_IGNORE (config.py:14) is a name-only list
checked as entry.name in ignore_set — a set-membership test that runs before the buggy matcher —
and it already covers .next, .cache, .venv, .tox, .mypy_cache, .pytest_cache,
.ruff_cache, .pnpm-store. The most common hidden directories are therefore handled by the other
mechanism, masking this. What stays exposed: .github/, .storybook/, .terraform/, .vscode/,
.claude/, .web-cache/ and similar.
4. The workaround has a hard expressiveness limit. Writing the directory undotted (web-cache/)
does work, but with the dot gone the pattern becomes a tree-wide basename match, so it cannot
distinguish a hidden directory from a visible one of the same name. Concrete case: we cannot exclude
.impeccable/, because impeccable/ would also take out our skills/impeccable/. No .cceignore
form expresses "the hidden one only".
What we'd like
rel.removeprefix("./")instead of.lstrip("./")— or an explicitif rel.startswith("./"): rel = rel[2:]. The fix must not strip a bare leading dot.- Regression tests. Note the
is_dirargument matters: pass a file with a directory-only pattern and it short-circuits atis_dir_pat and not is_dir, so the assertion stays red even after your fix. Use the directory form, or_cceignore_matches_file(which re-checks ancestors). All three fail on 0.4.26:assert matches_any('.web-cache', is_dir=True, ['.web-cache/']) is True assert _cceignore_matches_file('.web-cache/x.html', ['.web-cache/']) is True assert _cceignore_matches_file('.env/foo', ['env/']) is False # no over-match - Worth re-confirming the second half of the original title (
cce index --pathbypassing directory exclusions) against currentmain: on 0.4.26 the ancestor re-check in_cceignore_matches_filedoes appear to fire, so that half may have been fixed since Oct 4.
Minor and unrelated: chunker.py:168 uses the same construct (name = name.lstrip(".")). That may
well be intentional — flagging it only so the class gets a look.
Thanks — small change, large blast radius, because a silently-dead ignore pattern means an index quietly fills with generated files.