Skip to content

detect._is_sensitive silently drops every design-token source file (*_tokens.dart, tokens.ts, TOKENS.md) #3527

Closed

Description

@conradkelly

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)

  1. Exempt compiled-language source extensions from the generic keyword stage. A secret store is essentially never a .dart, .swift, .kt, .go, or .rs file. Keeping the stage for .txt, .json, .yaml, .env-ish files preserves its value with far fewer false positives.
  2. Treat a plural tokens as a topic word. Credential files are overwhelmingly singular (api_token, access_token); tokens.ts / *_tokens.dart read as a collection of design tokens. Splitting the tokens? pattern into singular-flagged / plural-allowed would fix the common case cheaply.
  3. Provide an escape hatch. There is currently no way to override this from a project — .graphifyignore only 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

  1. added a commit that references this issue on Sep 15, 2026
    3eb2486
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions