Skip to content

callflow-html: SECTION_ARCHETYPES relabels 80% of a foreign codebase with graphify's own architecture #2519

Open

Description

@Tomaskobel

Summary

derive_sections_from_communities discards the community label and substitutes a name from SECTION_ARCHETYPES — a hardcoded 9-entry taxonomy describing graphify's own repository (Extraction Pipeline, Graph Build, Analysis & Clustering, Serving API, CLI & Skill Installers, …).

On any other project this relabels most of the callflow document with the architecture of a different program. Measured on a 4,990-node application graph: 174 of 264 communities renamed, covering 3,978 nodes — 80% of the graph.

I'm raising this as an issue rather than a PR because the fix is a product decision, not a bug fix. Happy to implement whichever direction you prefer.

Mechanism

callflow_html.py:844:

label = label_for_community(cid, labels, community_nodes, lang)
text = _community_text(community_nodes, label)
...
if best and best_score >= 2:
    sec = grouped.setdefault(sid, {"name": pick_text(lang, zh_name, en_name), ...})

Two properties combine badly:

  1. _keyword_score counts occurrences, not distinct keywords. Two hits of the same generic word reach the threshold.
  2. The keyword sets are generic programming vocabulary — query, json, api, node, build, path, schema, python. Every codebase contains these, so the taxonomy generalises to everything.

The community label — including an LLM-generated one from .graphify_labels.json, which the user spent tokens producing — is then dropped entirely.

Measured examples

Community label Rendered as Triggered by
Data Table UI Components Analysis & Clustering query ×2 (it uses react-query)
Sidebar & Filter UI Graph Build json ×2
Campaign Create UI Tabs Serving API api ×56 (it calls APIs)
Database Schema & Extensions Graph Build schema, node, json, normalize
Recovery Reconcile CLI Analysis & Clustering query, path

A React sidebar filed under "Graph Build" is not a near-miss — the reader is told this application contains graphify's subsystems.

Why this is worse than a naming annoyance

  • Distinct communities are merged. grouped.setdefault(sid, ...) collapses every community matching an archetype into one section, so the document loses the boundaries the clustering computed. Communities are the one thing the callflow view exists to present.
  • It silently overrides paid-for output. graphify label runs an LLM to name communities; those names are then discarded at render time with no flag and no note.
  • It is invisible. Nothing in the output says a substitution happened, so the names read as findings about the code.
  • It scales with project size. More communities → more archetype hits. The bigger the codebase, the more of it is renamed.

Possible directions

  1. Prefer the real label; use archetypes only as a fallback when a community has no label. Smallest change, keeps archetypes useful for graphify's own repo.
  2. Require a much stronger signal — distinct keywords rather than occurrences, a ratio against community size, and a higher threshold.
  3. Make it opt-in (--archetypes), off by default.
  4. Keep both: archetype as the section grouping, real labels as subsection headings — no information lost.

I'd suggest (1); it is a two-line change and makes the failure mode impossible rather than less likely.

Environment

graphify 0.9.34 (07b9143), v8. Reproduced with graphify export callflow-html on a 4,990-node / 10,135-edge Python + TypeScript application graph, communities labelled via graphify label.


Related callflow renderer fixes I have open: #2508 (undirected load swapping Caller/Callee), #2510 (humanize_label truncating labels that fit), #2518 (diagram truncation disclosed only in an unrendered Mermaid comment).

Activity

  1. Tomaskobel commented on Aug 6, 2026

    @Tomaskobel
    Author

    Correcting my own recommendation — I suggested option (1) without measuring it, and it is the wrong call.

    Measured on the same 4,990-node / 264-community graph, max_sections=15:

    nodes covered by named sections
    current (archetype grouping) 3,978 — 80%
    option (1), real labels only 1,294 — 26%

    Option (1) would push 3,696 nodes (74%) into "Other". The grouping is doing real work: it packs 264 communities into ~9 sections so the document covers most of the graph. Drop it and you trade wrong names for almost no coverage — plainly worse.

    So the constraint is tighter than I framed it: the grouping needs to stay; only the naming is wrong.

    That points at option (4) instead, or a smaller variant of it:

    • Keep the archetype grouping, name each section from its own members. For example the dominant member community's label, optionally +N more — so a group reads Campaign Create UI Tabs +6 more rather than Serving API. Coverage is unchanged, and every name is derived from the user's code instead of graphify's taxonomy.
    • Or option (4) as written: archetype as the section, real labels as subsection headings — nothing lost, at the cost of a deeper document.

    Both keep the 80% coverage. Neither requires touching the keyword matching, which is the part I would otherwise have suggested tightening — and tightening it alone would have quietly cost coverage too, for the same reason.

    The generic-keyword problem in the original report stands (query ×2 → Analysis & Clustering, json ×2 → Graph Build), but it is now clearly a naming bug rather than a matching bug: even a perfectly-tuned matcher would still be applying graphify's own subsystem names to someone else's code.

    Happy to implement whichever you prefer. Given the above I would go with the first bullet — it is the smallest change that fixes the false claim without costing coverage.

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