Skip to content

GRAPH_REPORT.md: thin-community count uses a hardcoded threshold that diverges from --min-community-size #3148

Closed

Description

@yotamleo

GRAPH_REPORT.md can show a different "thin community" count in its ## Knowledge Gaps section than in its ## Summary and ## Communities headers for the very same run, whenever the run doesn't use the default community-size threshold. A separate figure in the same report — the "isolated node(s)" count — also won't match a straightforward recount of degree-<=1 nodes straight from the accompanying graph.json. Either way, a reader auditing the report's own headline numbers, or diffing them against the graph data, sees stats that don't add up, which undermines trust in the rest of the report.

Repro

  1. graphify update . --min-community-size=5 (anything other than the default 3) on a corpus with at least one community whose "real" node count falls between the two thresholds.
  2. Compare ## Summary's (<shown> shown, <thin> thin omitted) and ## Communities (<total> total, <thin> thin omitted) figures against ## Knowledge Gaps's "<K> thin communities (<min_community_size> nodes) omitted" line — K is computed against a different threshold than the number the label itself prints.
  3. Separately, for the "isolated node(s)" figure: recount nodes with degree <= 1 directly from graph.json and compare to the reported count — they won't agree, because the report's isolated-node list additionally excludes file-hub nodes, concept nodes, and rationale nodes, which isn't stated anywhere in the report output.

Evidence (HEAD 43d54acbfa9e731f7a592bb582c1f4b9d48ed73e)

  • report.py:144-148 — thin_count_summary (feeds the ## Summary and ## Communities header counts) is gated by the caller-supplied min_community_size parameter.
  • report.py:287-290 — thin_communities (feeds ## Knowledge Gaps) is gated by a hardcoded literal 3, not min_community_size — while the label text right next to it, report.py:301, still prints "(<{min_community_size} nodes) omitted".
  • cli.py:1858 and cli.py:2173 confirm min_community_size is a CLI-configurable flag (--min-community-size, default 3) that is threaded into generate(), so the two thresholds are reachably different, not just a theoretical edge case.
  • report.py:280-286 — the isolated-node list filters out file nodes and concept nodes (analyze.py:63 _is_file_node, analyze.py:165 _is_concept_node) plus any node with file_type == "rationale". Per _is_file_node's own docstring, this exclusion is deliberate for "knowledge gap reporting" — but the report text doesn't say so, so a plain degree <= 1 recount from graph.json will disagree with it.

Related prior art: #2129 (closed, NOT_PLANNED, self-withdrawn by its own reporter, no fix landed) reported a related divergence in this same community-counting code — its item 1 found the render loop and thin_count_summary use different guards for zero-real-node communities, causing the shown count to overstate what's actually rendered. Worth checking together with the hardcoded-threshold issue here, since both live in the same handful of lines.

Suggested fix

Compute the Knowledge Gaps thin-community count with the same min_community_size-gated predicate used for the Summary/Communities counts (share one helper), rather than a separate hardcoded 3. For the isolated-node count, either state the file/concept/rationale exclusion inline in the report text, or additionally print the raw degree <= 1 count so it's auditable against graph.json without reading the source.

Found while maintaining a downstream consumer of the generated report.

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