Repository navigation
Description
Version: graphifyy 0.8.38
Summary
_GENERIC_KEYWORD_PATTERNS treats tokens? as a credential keyword, and _generic_keyword_hit flags it when it ends the filename stem. In any codebase with a design-token layer, that silently removes the whole layer from the graph — design tokens are one of the most common uses of the word "token" in source trees, and they are never secrets.
Repro
from pathlib import Path
from graphify.detect import _is_sensitive
_is_sensitive(Path("app/lib/theme/shell_tokens.dart")) # True
_is_sensitive(Path("src/design/tokens.ts")) # True
_is_sensitive(Path("src/hard-tokens.ts")) # True
_is_sensitive(Path("TOKENS.md")) # True
_is_sensitive(Path("src/api_token.txt")) # True (correct)
_is_sensitive(Path("src/tokenizer.py")) # False (correct)Impact
In one Flutter + TypeScript monorepo this dropped six files that the project's own docs call the live design-system reference — shell_tokens.dart, field_guide_tokens.dart, universal_tokens.dart, guide_atmosphere_tokens.dart, guide_motion_tokens.dart, guide_plate_tokens.dart — plus hard-tokens.ts and TOKENS.md. 154 nodes from two of those files alone. They were invisible to every graphify query, with no warning at query time.
There is a second-order effect worth flagging. watch._rebuild_code selects files via detect(), so it drops them, while a full rebuild that goes through extract.collect_files() keeps them. The two paths therefore converge on fixed points ~200 nodes apart, so committed graph artifacts churn indefinitely: the hook rewrites them, the developer restores, the next commit rewrites again.
Why the existing guard does not catch this
The _generic_keyword_hit docstring already anticipates topic-word false positives (#436, #718) and handles the mid-slug case well. But the "keyword ends the stem" rule is precisely what design-token filenames hit: the content noun is "tokens", it just names design tokens rather than credentials.
Suggested fixes (in rough order of preference)
- Exempt compiled-language source extensions from the generic keyword stage. A secret store is essentially never a
.dart,.swift,.kt,.go, or.rsfile. Keeping the stage for.txt,.json,.yaml,.env-ish files preserves its value with far fewer false positives. - Treat a plural
tokensas a topic word. Credential files are overwhelmingly singular (api_token,access_token);tokens.ts/*_tokens.dartread as a collection of design tokens. Splitting thetokens?pattern into singular-flagged / plural-allowed would fix the common case cheaply. - Provide an escape hatch. There is currently no way to override this from a project —
.graphifyignoreonly subtracts. A.graphifyallow, or honouring a negation entry, would let a project opt specific files back in.
Happy to send a PR for (1) or (2) if you have a preference.
Activity
fix: bare plural "tokens" in a prose file is no longer treated as a s…