Skip to content

fix(detect): strip inline comments from .graphifyignore patterns#605

Closed
LEELADEVS wants to merge 1 commit into
Graphify-Labs:v5from
LEELADEVS:fix/inline-comment-strip-graphifyignore
Closed

fix(detect): strip inline comments from .graphifyignore patterns#605
LEELADEVS wants to merge 1 commit into
Graphify-Labs:v5from
LEELADEVS:fix/inline-comment-strip-graphifyignore

Conversation

@LEELADEVS

Copy link
Copy Markdown

Summary

_load_graphifyignore only handled full-line comments. Inline comments like vendor/ # legacy code were loaded as a single pattern including the trailing whitespace and comment text, which fnmatch could not match against any real path → the entry silently did not ignore anything.

Real-world impact

In our knowledge corpus (640 files, gitignore-style .graphifyignore with inline-documented patterns), 52 + 12 files in two categories were marked as changed on every --update run because their patterns had inline comments. This caused unnecessary LLM re-extraction ($1-3 per run) and noisy diff output.

The fix lets users document patterns inline (a common gitignore convention even though git itself does not support it natively):

chitta/varta/    # daily CEO briefings, regenerated nightly
chitta/spanda/   # webhook event cache

Behavior

Input line Before After
vendor/ # legacy code pattern = vendor/ # legacy code (matches nothing) pattern = vendor/ (matches vendor/...)
*.log (no inline comment) pattern = *.log pattern = *.log (unchanged)
# full-line comment skipped skipped (unchanged)
path#with#hash.py (no whitespace before #) pattern = path#with#hash.py pattern = path#with#hash.py (unchanged — gitignore semantics)
file \# name.py (escaped hash) pattern = file \# name.py pattern = file # name.py (literal # preserved)

Tests

Three new tests added to tests/test_detect.py:

  • test_graphifyignore_inline_comments_stripped — main case
  • test_graphifyignore_inline_comment_requires_whitespace_before_hash# without whitespace stays literal
  • test_graphifyignore_escaped_hash_is_literal\# escape

All 9 .graphifyignore tests pass.

Notes

  • Backward compatible: patterns without inline comments behave identically.
  • Docstring updated to describe the inline-comment + escape semantics as a documented gitignore extension.
  • The whitespace-before-# requirement matches user intuition while preserving the rare case of # as a literal filename character.

The previous implementation only handled full-line comments (lines starting
with #). Inline comments like `chitta/varta/  # daily briefings` were loaded
as a single pattern including the trailing whitespace and comment text,
which fnmatch then failed to match against any real path → the directory
was silently NOT ignored.

Real-world impact (LEELA shiva repo, 2026-04-29):
  - .graphifyignore had `chitta/varta/  # daily briefings` (52 files)
  - All 52 files appeared as "changed" on every --update run
  - Same for `chitta/spanda/  # webhooks cache` (12 files)
  - Total ~$1-3 wasted per --update on re-extracting ephemeral cron output

Fix: when reading each pattern line, scan for whitespace + '#' and drop the
remainder. Backslash-hash (\#) keeps a literal '#' in the pattern (rare).
Documentation updated to describe the gitignore-extension semantics.

Tests added (3):
  - test_graphifyignore_inline_comments_stripped — main case
  - test_graphifyignore_inline_comment_requires_whitespace_before_hash —
    'path#with#hash.py' is a literal pattern, not a comment
  - test_graphifyignore_escaped_hash_is_literal — \# escape

All 9 .graphifyignore tests pass.
safishamsi added a commit that referenced this pull request May 1, 2026
…ne comments, query boost, cache race, markdownify, content hash

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@safishamsi

Copy link
Copy Markdown
Collaborator

The requested changes have been implemented in 3fdae8f. _parse_gitignore_line now strips inline comments (whitespace + # suffix) while preserving path#hash.py literals and \# escapes. Shipped in v0.6.2.

@safishamsi safishamsi closed this May 1, 2026
matzls pushed a commit to matzls/graphify that referenced this pull request May 10, 2026
…bs#638 Graphify-Labs#589 Graphify-Labs#586 Graphify-Labs#593: kimi thinking, manifest, inline comments, query boost, cache race, markdownify, content hash

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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