Repository navigation
feat: preserve clustering settings across rebuilds - #4421
oleksii-tumanov wants to merge 3 commits into
Conversation
Keep explicitly chosen clustering settings with the graph so later reclustering uses the same choices. Refs Graphify-Labs#1800. AI-Assistance: OpenAI Codex
Handle overflow values during write-failure readback, preserve the previous config when serialization fails, and cover default-partition restoration. AI-Assistance: OpenAI Codex
|
Thanks for the pull request, @oleksii-tumanov. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 4 advisory finding(s) below merit a look before merge.
Not checked: tests were not run; no formal proof of the changed code.
Graphify review — findings
Persists --resolution and --exclude-hubs in .graphify_build.json after a successful cluster-only or extract run, so later rebuilds reuse them. Settings now resolve from explicit flags first, then saved values, then defaults, and a --graph pointing into another graphify-out reads that directory's config. Flags are validated up front (finite, resolution > 0, percentile 0–100, value required; exit 2 otherwise); unreadable config exits 1, and --no-cluster warns and skips adoption.
Worth a look
- --no-cluster still adopts clustering flags despite warning that they were not adopted —
graphify/cli.py:5165· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Rebuild now crashes on an undecodable or unreadable build config instead of falling back to defaults —
graphify/watch.py:166· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Non-atomic config write lets a concurrent rebuild silently use default clustering —
graphify/watch.py:255· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- _read_build_config accepts overflow JSON numbers as non-finite floats —
graphify/watch.py:156· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1051 functions depend on the 724 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_rebuild_code()— 179 callers, 60 callees - worse:
dispatch_command()— 2 callers, 135 callees - worse:
_make_graph()— 40 callers, 6 callees - new:
_adopt_cluster_settings()— 5 callers, 4 callees
Verification — 1051 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 1006 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
58 of 412 test file(s) selected (14%) via static blast radius.
tests/test_affected_cli.py— impacttests/test_agents_platform.py— impacttests/test_cache_stale_import_target.py— impacttests/test_cli_export.py— impact, changed-testtests/test_cloud_cta.py— impacttests/test_codebuddy.py— impacttests/test_compact_graph_json.py— impacttests/test_dedup_shrink_refuses_force_write.py— impacttests/test_devin.py— impacttests/test_elixir_import_resolution.py— impacttests/test_elixir_qualified_calls.py— impacttests/test_elixir_unqualified_call_scope.py— impacttests/test_explain_cli.py— impacttests/test_explain_same_file_tie.py— impacttests/test_export_direction.py— impacttests/test_external_stub_endpoints.py— impacttests/test_extract_cli.py— impacttests/test_extract_code_only_cli.py— impact, changed-testtests/test_global_add_tag_inference.py— impacttests/test_god_nodes_cli.py— impacttests/test_hollow_chunks_arm_shrink_guard.py— impacttests/test_hook_guard_token_match.py— impacttests/test_hook_out_of_project_paths.py— impacttests/test_hook_strict.py— impacttests/test_incomplete_build_guard.py— impacttests/test_incremental_unscanned_placeholders.py— impacttests/test_install.py— impacttests/test_install_references.py— impacttests/test_java_member_calls.py— impacttests/test_kotlin_grammar.py— impacttests/test_labeling.py— impacttests/test_language_override_lifecycle.py— impacttests/test_lookup_exit_codes.py— impacttests/test_lost_saved_semantic_nodes.py— impacttests/test_markdown_code_spans.py— impacttests/test_merge_chunks_validation.py— impacttests/test_multigraph_diagnostics.py— impacttests/test_no_cluster_undeclared_endpoints.py— impacttests/test_no_dedup_flag.py— impacttests/test_opencode_plugin_refresh.py— impacttests/test_partial_cache.py— impacttests/test_path_cli.py— impacttests/test_pr10_watch_overrides.py— impacttests/test_python_inherited_method_calls.py— impacttests/test_python_property_reads.py— impacttests/test_query_cli.py— impacttests/test_query_induced_edges.py— impacttests/test_query_seeds.py— impacttests/test_rust_use_trees.py— impacttests/test_skill_auto_refresh.py— impact- … and 8 more
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Docs that may be stale (advisory)
CHANGELOG.md§ 0.8.50 (2026-06-27) (lines 1275-1292): references changed symbolsmissingdocs/superpowers/plans/2026-05-04-incremental-updates-dedup.md§ Task 4: Incremental updates — semantic cache + manifest in __main__.py (lines 603-911): references changed symbolsmissinggraphify/skill-agents.md§ Step 4.5 - Graph health check (read-only integrity gate) (lines 480-505): references changed symbolsmissinggraphify/skill-agents.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 581-684): references changed symbolsmissinggraphify/skill-agents.md§ Interpreter guard for subcommands (lines 685-702): references changed symbolsmissinggraphify/skill-amp.md§ Step 4.5 - Graph health check (read-only integrity gate) (lines 480-505): references changed symbolsmissinggraphify/skill-amp.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 581-684): references changed symbolsmissinggraphify/skill-amp.md§ Interpreter guard for subcommands (lines 685-702): references changed symbolsmissinggraphify/skill-claw.md§ Step 4.5 - Graph health check (read-only integrity gate) (lines 483-508): references changed symbolsmissinggraphify/skill-claw.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 584-687): references changed symbolsmissing
…and 10 more.
· 1 grounded finding(s) anchored inline below; 3 more finding(s) on lines outside this diff (see the check run).
| return values["cluster_resolution"], values["cluster_exclude_hubs_percentile"] | ||
|
|
||
|
|
||
| def _adopt_cluster_settings(out_dir: Path, explicit: dict) -> str: |
There was a problem hiding this comment.
_adopt_cluster_settings()
high coupling complexity (Ca·Ce = 20).
Grounded coupling-delta finding (deterministic), not an LLM guess.
# Conflicts: # graphify/watch.py
What does this PR do?
After tuning a graph with
cluster-only --exclude-hubs 90 --resolution 2.5, the next watch or hook rebuild currently uses the defaults again. This change saves explicitly chosen settings beside that graph and reuses them wheneverupdate, watch, or a hook needs to recluster it.cluster-onlyand clusteredextractuse explicit flags first, then saved values, then the existing defaults. Withextract --outor a graph selected from anothergraphify-outdirectory, settings stay with that output. Fixes #1800.Type of change
Verification & Invariants
The two settings are stored in the existing
.graphify_build.json. Explicit values are saved only after the core graph outputs succeed. Invalid flags fail before writes; if a config write reports an error, the actual file is checked before reporting whether settings were saved.An update with unchanged topology still skips reclustering. Generated
/graphifyStep 4 can therefore leave a default partition while custom settings remain stored; runcluster-onlyon that output to reapply them immediately. Graph and config writes are not one transaction, and concurrent writers to the same output remain unsupported.How was this tested?
uv sync --all-extras --frozenuv run --frozen pytest tests/ -q --tb=short: 7930 passed, 15 skipped.uv run --frozen ruff check .: passed.uv run --frozen python -m tools.skillgen --check: all 134 generated artifacts match.uv run --frozen graphify update .: passed..venv/bin/pyright --pythonpath .venv/bin/python: 638 errors on both the base and this branch, with no added or removed diagnostics.The tests cover saved settings, custom outputs, invalid flags, unchanged topology, and config-write failures. An earlier full run failed the watcher config-deletion test; it passed alone on both the base and this branch, and the unchanged full-suite rerun passed.
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (Not applicable: no source fragments changed;--checkpassed.)