Repository navigation
Description
graphifyy version: 0.7.7
Skill: ~/.claude/skills/graphify/SKILL.md confirmed to contain the rationale-attribute rule from the #563 fix
Corpus: Codex monorepo root, 39 files (31 Python, 8 markdown/yaml), ~13k words
Backend: Claude subagents (general-purpose type), 2 chunks (~20 files each)
TL;DR
Issue #563 was closed by updating skill.md to instruct the LLM:
store as a
rationaleattribute on the relevant concept node — do NOT create a separate rationale node or fragment node
The prompt fix is in place (verified in my installed skill). But the LLM still produces rationale-as-node stubs at significant rate. 125 nodes (32% of post-merge total) had file_type:'rationale' and labels matching docstring-fragment patterns.
The prompt-level constraint isn't enforceable. Need a validator-side guard in the merge step.
Concrete numbers from this run
- Total post-merge nodes: 373
- Nodes with
file_type='rationale': 125 (32% of nodes) - Of those, labels matching
^.*_rationale_\d+$ID pattern: 116 - Remaining 9 had prettier labels ("Django Modular Monolith Architecture", "PDPA Compliance and AES-256-GCM PII Encryption") but were still standalone nodes weakly connected to one parent — also a rule violation per the prompt's "Only create a node for something that is itself a named entity or concept".
- Weakly-connected nodes (deg ≤ 1): 195 — of which 116 are rationale stubs. The single biggest source of graph noise on a docs-heavy repo.
Effect on graph quality:
- Settings Tab Helpers community cohesion: 0.06 (lowest in graph) — pulled down because 18 of its 48 nodes are rationale stubs each connected to exactly one parent.
- 23 singleton communities, ~half of them rationale stubs that didn't even attach to a parent.
- Inflates god-node centrality: removing the stubs dropped
Helios Backend APIfrom a top-10 god node back to a normal-degree node.
Distribution by chunk
The two semantic-extraction subagents behaved differently:
| Chunk | Files | Nodes emitted | Rationale stubs | Stub rate |
|---|---|---|---|---|
| chunk_01 | 20 (8 docs + 12 code) | 68 | ~70 | high |
| chunk_02 | 19 (mostly tests) | 66 | ~55 | medium |
Both chunks received the identical prompt with the rationale-attribute rule. Stub emission was high regardless.
Why prompt-only fix is insufficient
The model sees rich rationale prose in source (docstrings, AGENTS.md, ADR-style comments) and serializes them as nodes because:
- "Don't create rationale nodes" is a soft prohibition; "extract entities and relationships" is the dominant instruction.
- The schema example still includes
\"file_type\":\"...|rationale\"as a valid value, which signals "this is allowed in some context" — combined with the don't-create-it rule, models tend to err toward emission rather than omission, especially under chunked extraction where they can't see what other chunks did. - The model ID-format rules use the node label to derive the ID, so a rationale-attribute (which doesn't have an independent label) has no obvious ID slot — making the structural path easier than the attribute path.
Suggested fixes (any one would help; combined is best)
A. Validator-side strip in merge step. In extract_corpus_parallel (Kimi backend) and merge_chunks (subagent path), drop nodes where:
n['file_type'] == 'rationale' and (
re.match(r'^[a-z0-9_]+_rationale_\d+$', n['id']) or
not _is_named_entity_label(n['label']) # heuristic: contains a noun phrase, not just a sentence fragment
)For the 9 "prettier-label" rationale nodes, optionally hoist them to attrs.rationale of the most-connected concept node in the same source_file. Lossless and addresses the root concern.
B. Tighten the schema. Remove rationale from file_type in the JSON schema example shown to the LLM. The validator can still accept it for back-compat, but the LLM stops seeing it as a documented option.
C. Add a hard rejection rule. Replace the soft "do NOT create a separate rationale node" with a check the model can verify: "Before emitting any node with file_type: 'rationale', confirm its label is a named entity (concept name, principle, design pattern). If it's a sentence fragment, attach it as a rationale attribute on a code/document node instead." This gives the model a verifiable test to run before serializing.
Reproduction
Any docs-heavy monorepo will trigger this. Specifically reproducible on the public Codex code (private fork of Rooftopiq's monorepo, but the symptom is independent of repo content — it's any corpus with multi-paragraph docstrings or AGENTS.md / CLAUDE.md / ADR-style markdown).
Related
- Two extractor bugs systematically inflate god-node centrality (rationale fragments + calls direction inversion) #563 (closed) — prompt-level fix that this run shows is necessary but not sufficient.
- Chunk-extraction prompt omits rationale from valid file_types — model hallucinates 'concept' on every doc/paper run #657 (closed) — adjacent fix for the
concept-instead-of-rationalehallucination. - Semantic layer is mostly disconnected from the AST graph #198 (open) — different but adjacent: AST/semantic merge alignment. The rationale stubs amplify that issue because they pollute the side that should be enriching the AST graph.
Activity
fix worktree hook crash, prune isolated code nodes, restore rationale…