gabriel / musehub public
feat BREAKING dev
AI Agent gabriel · 140 days ago · May 3, 2026 · Diff

feat: rewrite GravityProvider as SQL derivation — no muse CLI required

Derives gravity scores from existing blast columns written by intel.code, using the exact formula from muse code gravity:

denom = max(1, total_tracked_symbols - 1) gravity_pct = round(blast / denom * 100, 1)

Column mapping: gravity_direct_dependents ← blast_direct gravity_transitive_dependents ← blast gravity_pct ← derived formula

gravity_max_depth and gravity_depth_distribution are not derivable from blast data and remain NULL.

Deletes 8 obsolete Phase 3 provider tests that mocked the muse CLI. Adds 20 Phase 5 TDD tests covering formula, mapping, denominator scoping, edge cases, idempotency, and preservation.

sha256:f3e8273e1ddb5b20fc5f671bc02850e808b7bc5d9f998411d0e662428566c791 sha
+44 ~2 −17 symbols
sha256:81bf30fea6376a833b8dd5d3176f81bd1ed48421b750e5909d8ec14d3124aa9d snapshot
+44
symbols added
~2
symbols modified
−17
symbols removed
0
dead code introduced
Semantic Changes 63 symbols
~ tests/test_phase5_gravity_derived.py .py 43 symbols added
+ TestColumnMapping class class TestColumnMapping L223–261
+ test_P5_05_gravity_direct_dependents_equals_blast_direct method async_method test_P5_05_gravity_direct_dependents_equals_blast_direct L226–242
+ test_P5_06_gravity_transitive_dependents_equals_blast method async_method test_P5_06_gravity_transitive_dependents_equals_blast L245–261
+ TestDenominator class class TestDenominator L268–349
+ test_P5_07_import_kind_excluded_from_denominator method async_method test_P5_07_import_kind_excluded_from_denominator L271–297
+ test_P5_08_null_kind_excluded_from_denominator method async_method test_P5_08_null_kind_excluded_from_denominator L300–321
+ test_P5_09_all_tracked_kinds_count_in_denominator method async_method test_P5_09_all_tracked_kinds_count_in_denominator L324–349
+ TestEdgeCases class class TestEdgeCases L356–398
+ test_P5_10_single_symbol_denom_is_one method async_method test_P5_10_single_symbol_denom_is_one L359–377
+ test_P5_11_zero_blast_yields_zero_pct method async_method test_P5_11_zero_blast_yields_zero_pct L380–398
+ TestEmpty class class TestEmpty L553–587
+ test_P5_17_no_rows_returns_empty method async_method test_P5_17_no_rows_returns_empty L556–567
+ test_P5_18_only_import_kind_rows_returns_empty method async_method test_P5_18_only_import_kind_rows_returns_empty L570–587
+ TestFormula class class TestFormula L133–216
+ test_P5_02_gravity_pct_matches_formula method async_method test_P5_02_gravity_pct_matches_formula L136–164
+ test_P5_03_gravity_pct_fractional_rounding method async_method test_P5_03_gravity_pct_fractional_rounding L167–192
+ test_P5_04_all_symbols_get_gravity_pct method async_method test_P5_04_all_symbols_get_gravity_pct L195–216
+ TestIdempotent class class TestIdempotent L518–546
+ test_P5_16_second_run_yields_same_pct method async_method test_P5_16_second_run_yields_same_pct L521–546
+ TestNoSubprocess class class TestNoSubprocess L93–126
+ test_P5_01_compute_never_spawns_subprocess method async_method test_P5_01_compute_never_spawns_subprocess L96–126
+ TestNotDerivable class class TestNotDerivable L594–634
+ test_P5_19_gravity_max_depth_stays_null method async_method test_P5_19_gravity_max_depth_stays_null L597–614
+ test_P5_20_gravity_depth_distribution_stays_null method async_method test_P5_20_gravity_depth_distribution_stays_null L617–634
+ TestPreserve class class TestPreserve L469–511
+ test_P5_14_churn_preserved_after_compute method async_method test_P5_14_churn_preserved_after_compute L472–490
+ test_P5_15_blast_columns_preserved_after_compute method async_method test_P5_15_blast_columns_preserved_after_compute L493–511
+ TestWriteBehavior class class TestWriteBehavior L405–462
+ test_P5_12_row_count_unchanged_after_compute method async_method test_P5_12_row_count_unchanged_after_compute L408–440
+ test_P5_13_returns_intel_results_tuple method async_method test_P5_13_returns_intel_results_tuple L443–462
+ _TRACKED_KINDS variable variable _TRACKED_KINDS L47–47
+ _get_row function async_function _get_row L73–80
+ _gravity_pct function function _gravity_pct L83–86
+ _seed_symbols function async_function _seed_symbols L54–70
+ AsyncSession import import AsyncSession L40–40
+ annotations import import annotations L35–35
+ create_repo import import create_repo L44–44
+ db import import db L43–43
+ func function import func L41–41
+ pg_insert import import pg_insert L39–39
+ pytest import import pytest L37–37
+ pytest_asyncio import import pytest_asyncio L38–38
+ select import import select L41–41
~ musehub/services/musehub_intel_providers.py .py 1 symbol added, 2 symbols modified
+ _GRAVITY_TRACKED_KINDS variable variable _GRAVITY_TRACKED_KINDS L946–948
~ tests/test_phase3_gravity_provider.py .py 17 symbols removed
TestGravityProviderEmpty class class TestGravityProviderEmpty L379–408
test_P3_42_empty_symbols_returns_empty_list method async_method test_P3_42_empty_symbols_returns_empty_list L382–394
test_P3_43_missing_symbols_key_returns_empty_list method async_method test_P3_43_missing_symbols_key_returns_empty_list L397–408
TestGravityProviderError class class TestGravityProviderError L415–430
test_P3_44_nonzero_exit_returns_empty_list method async_method test_P3_44_nonzero_exit_returns_empty_list L418–430
TestGravityProviderIdempotent class class TestGravityProviderIdempotent L304–372
test_P3_40_gravity_upsert_idempotent method async_method test_P3_40_gravity_upsert_idempotent L307–326
test_P3_41_gravity_upsert_overwrites_stale_value method async_method test_P3_41_gravity_upsert_overwrites_stale_value L329–372
TestGravityProviderJsonb class class TestGravityProviderJsonb L246–297
test_P3_38_depth_dist_stored_as_dict method async_method test_P3_38_depth_dist_stored_as_dict L249–271
test_P3_39_depth_dist_shallow_broad_shape method async_method test_P3_39_depth_dist_shallow_broad_shape L274–297
TestGravityProviderPreserve class class TestGravityProviderPreserve L198–239
test_P3_37_gravity_upsert_preserves_churn method async_method test_P3_37_gravity_upsert_preserves_churn L201–239
TestGravityProviderWrite class class TestGravityProviderWrite L122–191
test_P3_34_gravity_upserts_symbol_intel_rows method async_method test_P3_34_gravity_upserts_symbol_intel_rows L125–145
test_P3_35_gravity_all_six_columns_written method async_method test_P3_35_gravity_all_six_columns_written L148–173
test_P3_36_gravity_returns_non_empty_intel_results method async_method test_P3_36_gravity_returns_non_empty_intel_results L176–191
← Older Oldest on dev
All commits
Newer → Latest on dev

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:f3e8273e1ddb5b20fc5f671bc02850e808b7bc5d9f998411d0e662428566c791 --body "your comment"