delta-cube 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. delta_cube-0.5.0/.github/workflows/release.yml +21 -0
  2. delta_cube-0.5.0/.github/workflows/test.yml +41 -0
  3. delta_cube-0.5.0/.gitignore +18 -0
  4. delta_cube-0.5.0/CHANGELOG.md +368 -0
  5. delta_cube-0.5.0/LICENSE +21 -0
  6. delta_cube-0.5.0/PKG-INFO +161 -0
  7. delta_cube-0.5.0/README.md +128 -0
  8. delta_cube-0.5.0/docs/agent.md +55 -0
  9. delta_cube-0.5.0/docs/skill/SKILL.md +151 -0
  10. delta_cube-0.5.0/docs/snapshot-contract.md +195 -0
  11. delta_cube-0.5.0/plugin/.claude-plugin/plugin.json +18 -0
  12. delta_cube-0.5.0/plugin/.mcp.json +11 -0
  13. delta_cube-0.5.0/plugin/README.md +22 -0
  14. delta_cube-0.5.0/plugin/skills/delta-cube/SKILL.md +95 -0
  15. delta_cube-0.5.0/pyproject.toml +94 -0
  16. delta_cube-0.5.0/src/delta_cube/__init__.py +10 -0
  17. delta_cube-0.5.0/src/delta_cube/__main__.py +15 -0
  18. delta_cube-0.5.0/src/delta_cube/config.py +23 -0
  19. delta_cube-0.5.0/src/delta_cube/cube/__init__.py +34 -0
  20. delta_cube-0.5.0/src/delta_cube/cube/advisor.py +385 -0
  21. delta_cube-0.5.0/src/delta_cube/cube/clones.py +364 -0
  22. delta_cube-0.5.0/src/delta_cube/cube/clustering.py +498 -0
  23. delta_cube-0.5.0/src/delta_cube/cube/code_point.py +318 -0
  24. delta_cube-0.5.0/src/delta_cube/cube/contracts.py +560 -0
  25. delta_cube-0.5.0/src/delta_cube/cube/cube.py +1191 -0
  26. delta_cube-0.5.0/src/delta_cube/cube/debt.py +489 -0
  27. delta_cube-0.5.0/src/delta_cube/cube/delta.py +287 -0
  28. delta_cube-0.5.0/src/delta_cube/cube/drift.py +338 -0
  29. delta_cube-0.5.0/src/delta_cube/cube/features/__init__.py +23 -0
  30. delta_cube-0.5.0/src/delta_cube/cube/features/lexical.py +319 -0
  31. delta_cube-0.5.0/src/delta_cube/cube/features/semantic.py +394 -0
  32. delta_cube-0.5.0/src/delta_cube/cube/features/structural.py +461 -0
  33. delta_cube-0.5.0/src/delta_cube/cube/features/temporal.py +359 -0
  34. delta_cube-0.5.0/src/delta_cube/cube/graph.py +503 -0
  35. delta_cube-0.5.0/src/delta_cube/cube/review.py +1079 -0
  36. delta_cube-0.5.0/src/delta_cube/cube/smells.py +485 -0
  37. delta_cube-0.5.0/src/delta_cube/cube/suggestions.py +520 -0
  38. delta_cube-0.5.0/src/delta_cube/cube/surface.py +307 -0
  39. delta_cube-0.5.0/src/delta_cube/cube/tension.py +561 -0
  40. delta_cube-0.5.0/src/delta_cube/cube/visualizations/__init__.py +21 -0
  41. delta_cube-0.5.0/src/delta_cube/cube/visualizations/architecture.py +632 -0
  42. delta_cube-0.5.0/src/delta_cube/cube/visualizations/heatmap.py +523 -0
  43. delta_cube-0.5.0/src/delta_cube/cube/visualizations/matrix.py +463 -0
  44. delta_cube-0.5.0/src/delta_cube/cube/visualizations/timeline.py +504 -0
  45. delta_cube-0.5.0/src/delta_cube/cube/waves.py +358 -0
  46. delta_cube-0.5.0/src/delta_cube/db/__init__.py +17 -0
  47. delta_cube-0.5.0/src/delta_cube/db/analysis_store.py +221 -0
  48. delta_cube-0.5.0/src/delta_cube/db/database.py +109 -0
  49. delta_cube-0.5.0/src/delta_cube/db/projects.py +74 -0
  50. delta_cube-0.5.0/src/delta_cube/db/schema.py +183 -0
  51. delta_cube-0.5.0/src/delta_cube/server.py +25 -0
  52. delta_cube-0.5.0/src/delta_cube/tools/__init__.py +30 -0
  53. delta_cube-0.5.0/src/delta_cube/tools/analysis.py +419 -0
  54. delta_cube-0.5.0/src/delta_cube/tools/contracts.py +53 -0
  55. delta_cube-0.5.0/src/delta_cube/tools/core.py +260 -0
  56. delta_cube-0.5.0/src/delta_cube/tools/deltas.py +147 -0
  57. delta_cube-0.5.0/src/delta_cube/tools/review.py +194 -0
  58. delta_cube-0.5.0/src/delta_cube/tools/search.py +269 -0
  59. delta_cube-0.5.0/src/delta_cube/tools/visualizations.py +157 -0
  60. delta_cube-0.5.0/src/delta_cube/utils/__init__.py +26 -0
  61. delta_cube-0.5.0/src/delta_cube/utils/errors.py +53 -0
  62. delta_cube-0.5.0/src/delta_cube/utils/logger.py +24 -0
  63. delta_cube-0.5.0/src/delta_cube/visualization/__init__.py +9 -0
  64. delta_cube-0.5.0/src/delta_cube/visualization/html_export.py +467 -0
  65. delta_cube-0.5.0/tests/__init__.py +0 -0
  66. delta_cube-0.5.0/tests/test_analysis_store.py +244 -0
  67. delta_cube-0.5.0/tests/test_bug_fixes.py +331 -0
  68. delta_cube-0.5.0/tests/test_code_point_dimensions.py +79 -0
  69. delta_cube-0.5.0/tests/test_plugin.py +88 -0
  70. delta_cube-0.5.0/tests/test_review.py +1121 -0
  71. delta_cube-0.5.0/tests/test_scale.py +243 -0
  72. delta_cube-0.5.0/tests/test_schema_migration.py +76 -0
  73. delta_cube-0.5.0/tests/test_smoke.py +15 -0
  74. delta_cube-0.5.0/tests/test_tension.py +258 -0
  75. delta_cube-0.5.0/tests/test_version_sync.py +51 -0
  76. delta_cube-0.5.0/uv.lock +3243 -0
@@ -0,0 +1,21 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ id-token: write
12
+ contents: read
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: astral-sh/setup-uv@v3
16
+ - run: uv python install 3.11
17
+ - run: uv build
18
+ - name: Publish to PyPI
19
+ uses: pypa/gh-action-pypi-publish@release/v1
20
+ with:
21
+ skip-existing: true
@@ -0,0 +1,41 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.10", "3.11", "3.12"]
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: astral-sh/setup-uv@v3
19
+ with:
20
+ enable-cache: true
21
+ # This repo commits no `uv.lock`, and the action's default cache key
22
+ # globs `**/uv.lock`. With nothing to match it fails the step — not
23
+ # the install, the *setup* — so every run this workflow has ever had
24
+ # died there, before a single test body ran. Key on the file that
25
+ # does exist and that actually determines the environment.
26
+ cache-dependency-glob: "pyproject.toml"
27
+ # `uv pip install --system` needs an interpreter it can call the system
28
+ # one. `uv python install` downloads a managed build and does not make it
29
+ # that, so the install step behind it had never run either; this is the
30
+ # pairing uv documents for CI, and the one the sibling repo uses.
31
+ - uses: actions/setup-python@v5
32
+ with:
33
+ python-version: ${{ matrix.python-version }}
34
+ - name: Install
35
+ run: uv pip install --system -e ".[dev]"
36
+ - name: Lint
37
+ run: ruff check src tests
38
+ - name: Type check
39
+ run: mypy src/delta_cube || true
40
+ - name: Test
41
+ run: pytest -q
@@ -0,0 +1,18 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ .env
6
+ dist/
7
+ build/
8
+ .pytest_cache/
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .coverage
12
+ htmlcov/
13
+ *.db
14
+ *.sqlite
15
+ *.sqlite3
16
+ deltacodecube_*.html
17
+ deltacube_*.html
18
+ .DS_Store
@@ -0,0 +1,368 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ### Added
6
+
7
+ - A Claude Code plugin in `plugin/` (manifest, pinned `uvx delta-cube` MCP declaration and a `delta-cube` skill), installable from a marketplace via `git-subdir` path `plugin`.
8
+
9
+ ## [0.5.0] — 2026-11-28
10
+
11
+ ### Fixed
12
+
13
+ - `circular_dependency` smells no longer depend on indexing order. They were
14
+ found by a depth-first traversal and stored against whichever file it reached
15
+ first, so two indexes of one tree disagreed and `cube_review_changes` could
16
+ report "worse" for a comment-only edit. A cycle is now the set of files in it,
17
+ read from the edge list, and is stored once against its canonical member (the
18
+ smallest path), with `metrics.paths` naming every member. One smell per cycle
19
+ as before, so a file's smell count and debt rule are unchanged. The traversal
20
+ also missed some mutual imports (Django: 41 found, 51 now, identical across
21
+ shuffled indexes) and reported a file importing itself; the latter is gone.
22
+ Debt of files in the newly found cycles rises accordingly.
23
+
24
+ ### Added
25
+
26
+ - `cube_hotspots(path="django/forms")` ranks only the files under that
27
+ directory (relative to the project root; an absolute path under it is
28
+ accepted). Scores are the whole-project ones, so a file keeps its score
29
+ whatever the scope; the result carries `path` and `files_in_path`. A scope
30
+ with nothing under it is an error that says what `path` means.
31
+ - `cube_hotspots` leaves test files out by default (`excluded_tests`):
32
+ `tests` / `__tests__` directories, Maven `src/test`, `test_*.py`,
33
+ `*_test.py|go`, `*Test|Tests|IT.java`, `*.test|spec.js|ts`. `include_tests=True`
34
+ ranks them. `package-info.java` joins the generated/non-code exclusions
35
+ (`include_generated=True` ranks it).
36
+
37
+ ### Changed
38
+
39
+ - `cube_review_changes`: a file that was indexed but never scored (no stored
40
+ debt) is reported as a `new` finding on its own numbers instead of making the
41
+ verdict `unknown`. `counts.unscored` counts them, and an `ok` verdict says how
42
+ many files were reported without a comparison. The verdict rests on the files
43
+ that had a baseline; a new file with a high/critical smell is still `unknown`.
44
+
45
+ ### Performance
46
+
47
+ Django 5.1.4 (2,904 indexed files), unindexed project, 4 cores: the first
48
+ `cube_hotspots(refresh=True)` went from 155 s (index 53 s + refresh 103 s) to
49
+ 24-29 s over two runs (index 15-17 s + refresh 9-12 s); `cube_review_changes` on a
50
+ three-file change from 61 s to 8.5-9 s.
51
+
52
+ - Git history (change frequency, staleness, authors) is read with one
53
+ `git log --name-status -M` per repository, cached for a few seconds and
54
+ reloaded when HEAD moves, instead of one `git log --follow` process per file
55
+ per consumer (about 5,000 spawns on that index). Renames are followed as
56
+ before; a copy is no longer credited with its source's history, which
57
+ `--follow` did.
58
+ - Clone detection no longer compares every pair of files: a prefix filter
59
+ over the rarest fingerprints finds the same pairs (checked against the
60
+ brute-force comparison on Django: 8,020 clones, same order). Fingerprints of
61
+ files unchanged since the last pass are reused, and `cube_review_changes`
62
+ only counts clones of the files it scores.
63
+ - Semantic domain scoring tokenises a file once instead of scanning it once
64
+ per keyword (identical scores).
65
+ - `cube_hotspots(refresh=True)` and `calculate_technical_debt(smells=...)` no
66
+ longer run the smell pass twice.
67
+
68
+ ### Fixed
69
+
70
+ - `cube_hotspots` and `cube_review_changes` take `project` as the indexed
71
+ project's name (as `cube_list_projects` shows it) or its absolute path; a name
72
+ used to fail with "not a directory". Two indexed projects with one name are
73
+ refused, and the error for an unknown project lists the known project names.
74
+ - `cube_review_changes` called with neither `paths` nor `base` still returns an
75
+ error, but now names both ways (the files you changed, or a git ref to compare
76
+ against) with an example call of each.
77
+
78
+ - `cube_hotspots` no longer ranks generated or vendored files. Files below
79
+ directories named `migrations`, `alembic`, `node_modules`, `vendor`, `dist`,
80
+ `build` or `__generated__` (relative to the project root) are left out, the
81
+ payload reports how many as `excluded_generated`, and `include_generated=True`
82
+ turns the exclusion off. On a Flask app, six Alembic migrations were in the
83
+ top ten as orphans.
84
+ - `cube_hotspots` on a project that was never indexed names one call,
85
+ `cube_hotspots(project=..., refresh=True)`, and that call now works: with
86
+ `refresh=True` it indexes the project first (`index_ms`) instead of failing,
87
+ so the "index, then refresh" pair is gone.
88
+
89
+ - `cube_reindex` now brings the file's contracts in line with its current
90
+ imports and reports what changed under `contracts`. It used to move the
91
+ point and keep the imports the last `cube_index_directory` found, so an
92
+ import added by an edit was never an edge: a cycle closed by that edit, or a
93
+ new dependent, stayed invisible to every graph tool until the whole
94
+ directory was indexed again.
95
+
96
+ ### Added — two questions, one call each
97
+
98
+ An agent asking "did my change make this worse?" had to call `cube_reindex`,
99
+ `cube_detect_smells`, `cube_get_debt` and `cube_get_tensions`, read four full
100
+ payloads, and remember what the last three said before the edit. Asking "where
101
+ do I look first?" took `cube_analyze_graph`, `cube_get_debt` and
102
+ `cube_detect_smells` and a join done by hand.
103
+
104
+ - `cube_review_changes(paths | base, project, limit)` reads the stored snapshot
105
+ for each changed file, reindexes it the way `cube_reindex` does, reruns the
106
+ analysis and returns only the differences, under a verdict:
107
+ **`worse`** for a new or escalated high/critical smell, a tension opened by
108
+ the reindex, or a debt grade drop; **`unknown`** when there was no earlier
109
+ snapshot to compare against (it is never reported as `ok`); **`ok`**
110
+ otherwise. `base` takes a git ref and reviews what the branch changed plus
111
+ the working tree; it reaches git as one element of an argument list after
112
+ `--end-of-options`, and a value starting with `-` is refused before git runs.
113
+ - `cube_hotspots(project, limit, churn, refresh)` ranks a project's files by
114
+ `100 * (0.40*central + 0.30*debt + 0.30*smells)` from the stored snapshot and
115
+ says how old that snapshot is. With no snapshot it says so and names the call
116
+ that produces one; it runs the analysis only with `refresh=True`. Churn walks
117
+ git history, so it is opt-in and bounded to the top candidates.
118
+
119
+ What each one costs is in the payload rather than implied. Smell detection has
120
+ no per-file form — it is a pass over every indexed file in the database — so
121
+ `cube_review_changes` runs the whole pass and replaces the whole snapshot,
122
+ which leaves it current for every file rather than for the reviewed ones only.
123
+ Debt is recomputed for the reviewed files alone; every other row keeps the
124
+ `debt_computed_at` of the pass that wrote it. `scope` reports exactly that.
125
+
126
+ ### Added — contracts can follow a reindex (inside `cube_review_changes` only)
127
+
128
+ `reindex_file` moves the point and leaves the contracts as the last
129
+ `index_directory` found them. An import added since then did not exist in the
130
+ graph, so the cycle it closed, or the dependent it added, was invisible to
131
+ every analysis until the directory was indexed again.
132
+ `DeltaCodeCube.refresh_contracts_for_file` writes the difference: new imports
133
+ are inserted, removed ones deleted, and a contract that still holds is left
134
+ untouched — re-saving it would `INSERT OR REPLACE`, and with foreign keys on
135
+ that deletes the old row first, cascading away its tensions and resetting its
136
+ baseline. `cube_review_changes` calls it for every file it reviews.
137
+ **`cube_reindex` itself is unchanged and still does not refresh contracts.**
138
+
139
+ ### Added — an empty smell table can say whether it was ever filled
140
+
141
+ `code_smells` with no rows meant either "the detector found nothing" or "the
142
+ detector never ran", and nothing told them apart. Every smell pass now records
143
+ `smells_computed_at` (and `smells_count`) in a new `snapshot_meta` table, in
144
+ the same transaction as the replace. A database last analysed by an older build
145
+ falls back to the newest `detected_at`.
146
+
147
+ ### Added — a read contract, and a version to check it against
148
+
149
+ `docs/snapshot-contract.md` states what a tool reading the database directly
150
+ may rely on: where the file is, which columns of `code_points`, `file_metrics`
151
+ and `code_smells` are promised, which timestamps say how fresh a row is (two
152
+ formats are in use — UTC with offset for the snapshot, naive local time for
153
+ `code_points`), and what must not be assumed. `snapshot_meta.contract_version`
154
+ is `1`; it is bumped only when a promise in that document changes. The table is
155
+ created by the schema like every other, so an existing database gains it the
156
+ next time a server opens it.
157
+
158
+ ### Added — per-file debt without a pass per file
159
+
160
+ `calculate_files_debt(conn, paths, smells=None)` scores a chosen set of files
161
+ with the shared clone, smell and tension inputs computed once, and accepts the
162
+ result of a smell pass that has already run instead of running a second one.
163
+
164
+ ### Not changed
165
+
166
+ No existing tool changed its signature or payload. No existing table or column
167
+ changed.
168
+
169
+ ## [0.4.0] — 2026-09-21
170
+
171
+ ### Added — the analysis outlives the process that computed it
172
+
173
+ Smells, debt and centrality were derived and discarded. Each one was recomputed
174
+ from `code_points` and `contracts` on every call, returned to whoever asked,
175
+ and never written down — so anything else holding this database file could read
176
+ what had been indexed and nothing at all about what the analysis concluded. The
177
+ verdict was reachable only by *being* delta-cube, which a tool that cannot call
178
+ another MCP server is not. That is not a small gap for a database that is
179
+ machine-wide by design: the whole reason it lives at a fixed path is that other
180
+ things are meant to read it.
181
+
182
+ Two tables now hold the latest result:
183
+
184
+ - `code_smells` — one row per finding, with its type, severity, description,
185
+ suggestion and the detector's own metrics.
186
+ - `file_metrics` — one row per file carrying both debt (score, grade, the
187
+ breakdown) and centrality (in/out degree, PageRank, hub, authority,
188
+ betweenness), with **separate timestamps** for the two halves, because they
189
+ are written by separate passes and a row whose debt is fresh and whose
190
+ centrality is a week old has to be able to say so.
191
+
192
+ They hold a snapshot and never a history. An analysis is a statement about the
193
+ tree as it is now, so each smell run replaces the previous one wholesale rather
194
+ than appending — a snapshot that accumulates looks populated while describing a
195
+ tree that no longer exists, and a smell someone fixed keeps being reported. The
196
+ per-file metrics upsert instead of replacing, so running one pass cannot
197
+ silently drop the other pass's columns out of a row that still looks complete.
198
+
199
+ Persistence is wired at the module-level entry points the MCP tools call
200
+ (`detect_code_smells`, `get_smell_summary`, `calculate_technical_debt`,
201
+ `analyze_dependency_graph`), not inside the detectors, so which tool a caller
202
+ reached for cannot decide whether the snapshot is fresh. `calculate_technical_debt`
203
+ stores before `summary_only` drops `all_files`: the snapshot covers every file
204
+ whether or not this caller wanted to read them, and `analyze_dependency_graph`
205
+ stores from the graph's nodes rather than its result, because the result
206
+ carries only the top N per metric and a snapshot of the top ten is not one.
207
+
208
+ ### Added — `code_points.project`, and the question it makes askable
209
+
210
+ Every row was keyed by an absolute path, and nothing recorded which project the
211
+ path belonged to. In a machine-wide database that made "the smells in this
212
+ repository" a prefix match each caller had to build itself, and "which projects
213
+ are in here" a question with no answer at all.
214
+
215
+ `project` is resolved at index time as the nearest ancestor holding a VCS
216
+ marker — `.git`, `.hg`, `.svn` — which is how every other tool on the machine
217
+ identifies a repository, and the nearest one wins so a checkout inside a
218
+ checkout is its own project. A file under no repository gets `NULL` rather than
219
+ a guess: a column that invented a root for a scratch file would make every
220
+ scoped query quietly wrong instead of quietly empty. Resolution is cached per
221
+ directory, never raises, and is arrived at through
222
+ `_ADDED_COLUMNS`, so a database created before this release gains the column
223
+ rather than being read for one it does not have.
224
+
225
+ `cube_list_projects` is the tool that asks. Rows written before the column
226
+ existed report under a null project rather than being dropped, because they are
227
+ still in `code_points` and omitting them would make the counts disagree with
228
+ `cube_get_stats`.
229
+
230
+ ### Not changed
231
+
232
+ The GitHub repository *description* still says 63D where the code, the README
233
+ and the schema say 86D. It is a settings field rather than a file, so it cannot
234
+ be fixed from a commit.
235
+
236
+ ## [0.3.0] — 2026-09-20
237
+
238
+ ### Behaviour change — a point of the wrong length is refused, not padded
239
+
240
+ `CodePoint._normalize_vectors` zero-padded the shorter of two vectors so they
241
+ could be compared. A vector of the wrong length is not a short vector: it is a
242
+ row written by a different build of the feature extractor, and the count has
243
+ moved in this repo's own history — the schema comments described 50 lexical and
244
+ 8 structural floats while the code wrote 65 and 16. Padding reads as "this file
245
+ has none of those features" when the truth is that nobody measured them, so
246
+ every distance across that boundary came back plausible and wrong, with nothing
247
+ raised and nothing logged. It is the same defect the contract metric had one
248
+ release ago, one layer down: two things that are not comparable, compared
249
+ anyway, producing a number a caller acts on.
250
+
251
+ It now raises `DimensionMismatch`, naming both sizes and the remedy
252
+ (`cube_index_directory`). `_cosine_distance` carried a second copy of the
253
+ padding and now goes through the same rule, because fixing one would have left
254
+ the axis comparisons still padding.
255
+
256
+ **Scans skip rather than fail.** `find_similar` and `find_by_criteria` walk
257
+ every point in the database, which is machine-wide and has no project column,
258
+ so one stale row left by an unrelated repo would otherwise take the whole query
259
+ down for every project on the box. They skip what they cannot compare, count
260
+ it, and `cube_find_similar` reports the count and the remedy in its result — a
261
+ partial answer that says it is partial. Pairwise calls still raise: there the
262
+ caller named two files, and an error beats a wrong number.
263
+
264
+ ### Fixed — a tension no longer reports the wrong direction
265
+
266
+ `tension_magnitude` is `|current - baseline|`, which says how far a callee
267
+ moved and not which way. `get_tensions` reconstructed the current distance as
268
+ `baseline + magnitude`, so a change that pulled two files *together* was
269
+ reported as having pushed them apart, by twice the real amount — the best kind
270
+ of refactor read back as the worst kind of tension.
271
+
272
+ `tensions` gains a `current_distance` column, written at detection. It is
273
+ nullable and `Tension.current_distance` is now `float | None`: a row recorded
274
+ before the column existed reports `None` rather than a number nobody measured.
275
+ Severity is unaffected, deriving from the magnitude and the baseline, which
276
+ were always stored correctly.
277
+
278
+ ### Added — additive schema migrations
279
+
280
+ The schema is applied with `executescript` over `CREATE TABLE IF NOT EXISTS`,
281
+ which never revisits a table that already exists, so a column added later only
282
+ ever reached databases created after it. Every older install would keep being
283
+ read for a column it does not have — the failure `prune_stale_files` already
284
+ shipped once, against `contracts.file_a` and `file_b`, columns the schema never
285
+ had. `db/database.py` now applies declared columns additively and idempotently
286
+ on open, checked against `PRAGMA table_info` rather than a `user_version`
287
+ counter that can drift from the table it describes.
288
+
289
+ ### Fixed — the CI workflow had never run a test
290
+
291
+ Two failures stacked, and the first hid the second. `astral-sh/setup-uv` was
292
+ configured with `enable-cache: true`, whose default key globs `**/uv.lock`;
293
+ this repo commits no lockfile, so the *setup* step failed on every run the
294
+ workflow has ever had, before anything was installed. Behind it,
295
+ `uv pip install --system` was paired with `uv python install`, which downloads
296
+ a managed interpreter without making it the system one — so the install would
297
+ not have worked either. The cache now keys on `pyproject.toml`, and
298
+ `actions/setup-python` provides the interpreter, which is the pairing uv
299
+ documents for CI.
300
+
301
+ ### Fixed — the lint rule set is the repo's choice again
302
+
303
+ `ruff>=0.6.0` with no `select` means the rule set is whatever the installed
304
+ ruff calls default, and that moved: 0.16.8 enables 415 rules and reported 114
305
+ findings against a tree that was clean when it was written. Nobody chose that
306
+ set; a linter upgrade did. `[tool.ruff.lint] select` now pins the four families
307
+ that are ruff's long-standing default, the same four the sibling repo pins,
308
+ with the excluded families and the reason for each written down — `BLE001`
309
+ because an MCP handler that raises takes the server down mid-session, `DTZ`
310
+ because every stored timestamp is a naive local string and half a migration is
311
+ worse than none, `S` because subprocess and file-reader findings deserve an
312
+ audit rather than a sweep. 45 findings under that set, all fixed; 42 of them by
313
+ `--fix`.
314
+
315
+ One was left deliberately: `_extract_coupling_metrics` computed a `loc` it
316
+ never used, which reads like an oversight. Normalising by file size instead of
317
+ the fixed constants around it would move every point already stored and
318
+ invalidate every baseline recorded against them — a reindex of every repo, not
319
+ a tidy-up. The dead line is gone and the reason is in its place.
320
+
321
+ ### Fixed — the description said 63D
322
+
323
+ `pyproject.toml` still claimed 63 dimensions after the README, the skill and
324
+ the schema comments were corrected. The GitHub repository description says it
325
+ too and is not in this diff.
326
+
327
+ ### Tests
328
+
329
+ 21 before this line of work, 27 after the metric fix, **38 now**: the
330
+ dimension refusal and its scan-level skip, the tension direction, the null
331
+ `current_distance` of a legacy row, and the migration against a database built
332
+ without the column.
333
+
334
+ ## [0.2.0] — 2026-09-19
335
+
336
+ ### Behaviour change — a tension is measured on one scale
337
+
338
+ A contract's `baseline_distance` was Euclidean over the raw 86-D position and
339
+ `TensionDetector` measured the current distance as cosine. `tension_percent`
340
+ is the ratio of the two, so it compared two scales, and a callee that had not
341
+ moved could still cross the 15% threshold. Both sides now go through
342
+ `contracts.contract_distance` (cosine — the lexical two thirds of the position
343
+ are TF-IDF, and `CodePoint.distance_to` already defaulted to it).
344
+
345
+ Baselines recorded by an earlier build are Euclidean and do not compare with
346
+ the new current distance. Re-run `cube_index_directory` on each indexed repo to
347
+ record contracts again; tensions detected before that are not meaningful.
348
+
349
+ ### Fixed — the documentation described an older cube
350
+
351
+ README, the skill and the schema comments said 63 dimensions and 35 tools. The
352
+ code has been 86 (65 lexical + 16 structural + 5 semantic) and 36 for some time.
353
+ `__version__` said 1.0.0 while `pyproject.toml` said 0.1.0; both now say 0.2.0.
354
+
355
+ ### Added — tests for Delta and Tension
356
+
357
+ `tests/test_tension.py` pins the metric, the zero-movement case, a real move,
358
+ the save/read round trip, and the adaptive threshold (mean + 2σ over the last
359
+ 20 movements, clamped to [0.05, 0.50], default below 3 samples). Before this
360
+ the suite covered pruning and payload caps only.
361
+
362
+ ### Known
363
+
364
+ The database is one per machine (`$DCC_DATA_DIR/dcc.db`, default
365
+ `~/.local/share/jig/dcc.db`) with no project column; a reader scopes by
366
+ `file_path` prefix. Smells, debt and centrality are computed per call and never
367
+ persisted. `get_tensions` reconstructs `current_distance` as
368
+ `baseline + magnitude`, which is only right when the distance grew.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rixmerz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.5
2
+ Name: delta-cube
3
+ Version: 0.5.0
4
+ Summary: Multi-dimensional code indexing — represent code as points in 86D feature space for similarity search, impact analysis, and change detection.
5
+ Project-URL: Homepage, https://github.com/Rixmerz/delta-cube
6
+ Project-URL: Repository, https://github.com/Rixmerz/delta-cube
7
+ Project-URL: Issues, https://github.com/Rixmerz/delta-cube/issues
8
+ Author: Rixmerz
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: code-quality,code-smells,embeddings,mcp,refactoring,static-analysis
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Software Development :: Quality Assurance
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: fastmcp>=2.0.0
25
+ Requires-Dist: numpy>=1.24.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: mypy>=1.10.0; extra == 'dev'
28
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
29
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
30
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.6.0; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # Delta Cube
35
+
36
+ Multi-dimensional code indexing — represent code as points in **86D feature space** (lexical, structural, semantic) for similarity search, impact analysis, and change detection.
37
+
38
+ > Originally `DeltaCodeCube` (DCC). The previous standalone repo was abandoned and the code lived inside [jig](https://github.com/Rixmerz/jig) and AgentCockpit. This repo is the extracted, standalone successor.
39
+
40
+ ## What it does
41
+
42
+ Delta Cube indexes a codebase and places every file as a point in a high-dimensional feature space. From that representation it derives:
43
+
44
+ - **Similarity & clones** — find files that look alike (lexical, structural, or semantic axes); detect duplicates with Winnowing fingerprinting.
45
+ - **Contracts & tensions** — track import/dependency relationships and flag when a change moves a file too far from its dependents (a *tension*).
46
+ - **Deltas** — every reindex records the movement of a file in 86D space, with breakdown by axis.
47
+ - **Centrality** — PageRank, hub/authority, betweenness over the dependency graph.
48
+ - **Smells** — god files, orphans, circular deps, feature envy, hub overload, unstable interfaces, dead code candidates.
49
+ - **Refactoring suggestions** — split / merge / move / extract / stabilize / remove / decouple, with steps and supporting metrics.
50
+ - **Technical debt** — composite score (0–100) with grades A–F.
51
+ - **Drift detection** — semantic, contract, and temporal drift across modules.
52
+ - **Wave simulation** — propagate the impact of a change through dependents with attenuation.
53
+ - **Visualizations** — interactive HTML for architecture diagram, dependency matrix, heatmap, timeline, and a 3D scatter of the cube.
54
+
55
+ Smells, debt and centrality are **written back into the database** as a snapshot of the latest run, so a tool that only holds the file can read the verdict without running Delta Cube. The database is machine-wide, and `code_points.project` records which repository each file came from — `cube_list_projects` says what is in there and how much of it.
56
+
57
+ Two tools answer a whole question in one compact call, so an agent does not have to chain four and read their full payloads:
58
+
59
+ - **`cube_review_changes(paths=[...])`** or **`(base="main", project=...)`** — after an edit. Reindexes the changed files and returns only what got worse: new or escalated smells, new tensions, debt before→after. `verdict` is `worse` for a new/escalated high or critical smell, a new tension or a debt grade drop; `unknown` when there was no earlier snapshot to compare against; `ok` otherwise.
60
+ - **`cube_hotspots(project=...)`** — on first contact with a repository. The top N files by a documented score over centrality, debt and smells (git churn is opt-in), read from the stored snapshot, with how old that snapshot is. It never runs the analysis unless `refresh=True`, which is also the only call needed on a project never indexed (it indexes first). `project` is the indexed project's name or its absolute path (here and in `cube_review_changes`). Generated and vendored directories (`migrations`, `alembic`, `node_modules`, `vendor`, `dist`, `build`, `__generated__`) are skipped and counted in `excluded_generated`; `include_generated=True` ranks them. Test files are skipped too (`excluded_tests`; `include_tests=True` ranks them), and `package-info.java` counts as non-code. `path="django/forms"` ranks only the files under that directory, with the scores they have repo-wide.
61
+
62
+ The tables another tool may read directly, and what it must not assume about them, are in [docs/snapshot-contract.md](docs/snapshot-contract.md).
63
+
64
+ ## Install
65
+
66
+ ```bash
67
+ pip install delta-cube
68
+ # or with uv
69
+ uv tool install delta-cube
70
+ ```
71
+
72
+ Run the MCP server:
73
+
74
+ ```bash
75
+ delta-cube
76
+ # or
77
+ python -m delta_cube
78
+ # or
79
+ uvx delta-cube
80
+ ```
81
+
82
+ ## Use as an MCP server
83
+
84
+ Add to your MCP client config (Claude Code, Cursor, etc.):
85
+
86
+ ```json
87
+ {
88
+ "mcpServers": {
89
+ "delta-cube": {
90
+ "command": "uvx",
91
+ "args": ["delta-cube"]
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ ## Use as a Claude Code plugin
98
+
99
+ The `plugin/` directory is a Claude Code plugin: it declares this server
100
+ (`uvx delta-cube@<version>`, pinned to the package version) and ships a skill
101
+ that tells an agent which single call answers which question. List it in a
102
+ plugin marketplace with source `git-subdir`, path `plugin`. See
103
+ [plugin/README.md](plugin/README.md).
104
+
105
+ ## Tools (selection)
106
+
107
+ | Group | Tools |
108
+ |-------|-------|
109
+ | One-call answers | `cube_review_changes` (did this change leave these files worse? `ok` / `worse` / `unknown`), `cube_hotspots` (the few files that matter most and are in the worst shape) |
110
+ | Indexing | `cube_index_file`, `cube_index_directory`, `cube_reindex`, `cube_prune_stale` |
111
+ | Position & similarity | `cube_get_position`, `cube_find_similar`, `cube_compare`, `cube_search_by_domain`, `cube_find_by_criteria` |
112
+ | Contracts | `cube_get_contracts`, `cube_get_contract_stats` |
113
+ | Deltas & tensions | `cube_get_deltas`, `cube_get_tensions`, `cube_resolve_tension`, `cube_suggest_fix` |
114
+ | Analysis | `cube_analyze_graph`, `cube_get_centrality`, `cube_detect_smells`, `cube_cluster_files`, `cube_get_suggestions`, `cube_detect_clones`, `cube_get_debt`, `cube_analyze_surface`, `cube_detect_drift` |
115
+ | Impact | `cube_analyze_impact`, `cube_simulate_wave`, `cube_predict_impact` |
116
+ | Temporal | `cube_get_temporal` |
117
+ | Projects | `cube_list_projects` |
118
+ | Visualizations | `cube_export_html`, `cube_export_positions`, `cube_generate_timeline`, `cube_generate_matrix`, `cube_generate_heatmap`, `cube_generate_architecture` |
119
+
120
+ ## Layout
121
+
122
+ ```
123
+ src/delta_cube/
124
+ ├── server.py # FastMCP entry point
125
+ ├── __main__.py # `python -m delta_cube`
126
+ ├── config.py
127
+ ├── cube/ # Core engine
128
+ │ ├── cube.py, code_point.py, contracts.py
129
+ │ ├── delta.py, tension.py, drift.py, waves.py
130
+ │ ├── graph.py, smells.py, advisor.py, suggestions.py
131
+ │ ├── clones.py, clustering.py, debt.py, surface.py
132
+ │ ├── review.py # cube_review_changes / cube_hotspots
133
+ │ ├── features/ # Feature extractors (lexical/structural/semantic/temporal)
134
+ │ └── visualizations/ # HTML generators
135
+ ├── db/ # SQLite persistence
136
+ │ ├── schema.py, database.py
137
+ │ ├── analysis_store.py # smell/debt/centrality snapshots
138
+ │ └── projects.py # which repository a path belongs to
139
+ ├── tools/ # MCP tool registrations
140
+ ├── utils/
141
+ └── visualization/
142
+ docs/
143
+ ├── agent.md # Agent guide
144
+ ├── snapshot-contract.md # What a read-only reader of the database may rely on
145
+ └── skill/ # Claude Code skill
146
+ tests/
147
+ ```
148
+
149
+ ## Development
150
+
151
+ ```bash
152
+ git clone https://github.com/Rixmerz/delta-cube
153
+ cd delta-cube
154
+ uv venv && source .venv/bin/activate
155
+ uv pip install -e ".[dev]"
156
+ pytest
157
+ ```
158
+
159
+ ## License
160
+
161
+ MIT — see [LICENSE](LICENSE).