Commit 04f33ae
authored
fix(kg): rebuild the knowledge graph when the builder changes, not just the graph (#1592)
* fix(kg): rebuild the knowledge graph when the builder changes, not just the graph
`compute_kg_fingerprint` measures the input graph — node count, edge count,
community count, first 100 community keys — and `should_skip_kg_rebuild` keeps
the stored artifact whenever those four hold still. They hold still when the
*builder* changes, and this release changed it twice.
`_EDGE_TYPE_MAP` gained six types (framework, the three dynamic_* kinds, reads,
method_implements) and the export drops every unmapped type outright, so the
knowledge graph now carries edge classes it used to discard. `_curate_entry_points`
also re-ranks `project.entry_points`, which reaches get_overview, the C4
architecture view and CLAUDE.md through `entry_points_json`. Neither moves a node
or an edge count, so an existing store would serve the old artifact until some
unrelated commit happened to shift one.
KG_BUILDER_VERSION is folded into the fingerprint: one bump is one rebuild per
store, on the next ordinary `repowise update`. That rebuild is the deterministic
skeleton and curation passes over a graph the run already holds — no model, no
re-index, nothing for the user to do. Not a loop either: the new value is stored
as the artifact's fingerprint, so the following run matches and skips.
* fix(kg): say what the rebuild actually costs, and pin the version as a literal
Adversarial review of the previous commit found three claims in it that the
code does not support.
"On the next ordinary `repowise update`" is not true for a repo with no new
commits: that run returns NOOP (command.py:908) before the refresh is reached,
and the renderer-staleness gate beside it fingerprints only the file-page and
spotlight templates, so a builder bump does not retire the shortcut. A quiet
repo stays on its old artifact until something changes. That is the right trade
— the alternative is every idle repo in the world re-curating on a version bump
— but the docstring stated it as a guarantee.
"No model" is only true off the docs path. A non-None refresh result feeds
enrich_knowledge_graph (command.py:1770), one LLM call per five layers, and the
comment above that call still claimed an unchanged KG never pays it. Both now
say what happens and why it is worth paying: the layers moved, so the names the
carry-forward restored were written against the old ones.
The stability test asserted only that the constant is a non-empty str, which a
value derived from the module's own bytes — the exact failure its docstring
named — would have passed. Replaced with the literal, so bumping it is a line
somebody edits and a reviewer sees.
Not applied from the review: stamping the fingerprint into state when the disk
export fails. should_skip_kg_rebuild also requires kg_path.exists(), so a failed
export rebuilds on the next run regardless of the stored value; stamping it
would instead assert the artifact matches the current builder when the write
that would have made that true is the one that failed.
Verified end to end on a fresh microdot index: a comment-only commit at the same
version does not rebuild (fingerprint held at 2cf47159), the same commit with the
version bumped does (0630f7fd), and the commit after that does not.1 parent a17099c commit 04f33ae
3 files changed
Lines changed: 80 additions & 4 deletions
File tree
- packages
- cli/src/repowise/cli/commands/update_cmd
- core/src/repowise/core/analysis
- tests/unit/analysis
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1764 | 1764 | | |
1765 | 1765 | | |
1766 | 1766 | | |
1767 | | - | |
1768 | | - | |
1769 | | - | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
1770 | 1774 | | |
1771 | 1775 | | |
1772 | 1776 | | |
| |||
Lines changed: 42 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
208 | 218 | | |
209 | 219 | | |
210 | 220 | | |
| |||
410 | 420 | | |
411 | 421 | | |
412 | 422 | | |
413 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
414 | 454 | | |
415 | 455 | | |
416 | 456 | | |
| 457 | + | |
417 | 458 | | |
418 | 459 | | |
419 | 460 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
184 | 215 | | |
185 | 216 | | |
186 | 217 | | |
| |||
0 commit comments