Skip to content

C/C++ repository collapses to 5 leaf nodes during dependency analysis. Silent fallback to whole-repository mode #75

Description

@StefanZoerner

On a mid-sized C++ codebase, Phase 1 (dependency analysis) parses all files successfully but extracts only 5 leaf nodes (2065 tokens) from 786 functions. CodeWiki then silently falls back to whole-repository documentation mode, so the generated documentation would not be based on the actual source code. The run continues as if everything were fine.

Reproduction

git clone https://github.com/dungeons-of-moria/umoria
cd umoria
codewiki generate --output ./codewiki-docs --verbose

Observed behavior

Parsing itself succeeds:

[00:00] Phase 1/5: Dependency Analysis
[00:00]   Initializing dependency analyzer...
[00:00]   Parsing source files...
[11:18:39] INFO     📊 Parsing 77 source files (this may take a few minutes)...
[11:18:39] INFO       [1/77] src/character.cpp (0.0s elapsed, ~0.0s remaining)
[11:18:39] INFO       [2/77] src/character.h (0.0s elapsed, ~0.5s remaining)
...

But only 5 leaf nodes survive, and clustering is skipped:

00:01]     File: src/character.h::Class_t
[00:01]     ... and 788 more files
[00:01]   Dependency Analysis complete (1.1s)

[00:01] Phase 2/5: Module Clustering
[00:01]   Clustering modules with LLM...
[00:01]   Preparing 5 leaf nodes for clustering (2065 tokens, threshold 12000)
[00:01]   Skipping LLM clustering; selected leaf nodes fit within the module token threshold
[11:18:40] INFO     Module clustering input for repository: 5 leaf nodes, 2065 tokens, threshold 12000
[11:18:40] INFO     Skipping LLM module clustering for repository because 2065 tokens fit within the 12000-token threshold; using whole-module documentation mode.
[00:01]   Created 0 modules; continuing in whole-repository documentation mode
[00:01]   Module Clustering complete (0.0s)

The "2065 tokens" conclusion is drawn from the leaf-node set, not from the actual repository size (~30k+ LOC), so the "repo can fit in the context window" decision is based on incorrect data.

Occurs independently of LLM/provider

The collapse happens entirely within Phase 1 static analysis, before any LLM request is made; the LLM clustering step is skipped as a consequence of the collapse. Model and provider configuration are therefore irrelevant for reproduction (verified: no request reached the configured backend during these runs).

Expected behavior

Leaf-node extraction should produce a node set roughly reflecting the function/file count. Or — if the graph analysis cannot produce a usable decomposition — the run should fail.

Environment

CodeWiki 1.0.1 · Python 3.12 · pydantic-ai >=1.0.6,<2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions