codecortex 0.29.3__py3-none-any.whl → 0.30.0__py3-none-any.whl
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.
- {codecortex-0.29.3.dist-info → codecortex-0.30.0.dist-info}/METADATA +9 -8
- codecortex-0.30.0.dist-info/RECORD +96 -0
- codeintel/__init__.py +1 -1
- codeintel/__main__.py +18 -11
- codeintel/c4/__init__.py +1 -0
- codeintel/{c4_check.py → c4/check.py} +106 -9
- codeintel/{c4_layers.py → c4/layers.py} +2 -2
- codeintel/{c4.py → c4/model.py} +18 -10
- codeintel/{commands → cli}/c4.py +7 -7
- codeintel/{commands → cli}/doctor.py +2 -2
- codeintel/{commands → cli}/graph.py +2 -2
- codeintel/{commands → cli}/index.py +34 -11
- codeintel/{commands → cli}/install.py +4 -4
- codeintel/{commands → cli}/map.py +17 -6
- codeintel/{commands → cli}/prompt.py +2 -2
- codeintel/{commands → cli}/query.py +4 -4
- codeintel/{commands → cli}/reset.py +7 -4
- codeintel/{commands → cli}/serve.py +1 -1
- codeintel/{commands → cli}/serve_http.py +2 -2
- codeintel/{commands → cli}/setup.py +2 -2
- codeintel/{commands → cli}/status.py +4 -4
- codeintel/{commands → cli}/uninstall.py +3 -3
- codeintel/core/__init__.py +3 -0
- codeintel/{config.py → core/config.py} +1 -1
- codeintel/core/containment.py +265 -0
- codeintel/{filelock.py → core/filelock.py} +1 -1
- codeintel/core/paths.py +104 -0
- codeintel/{provider.py → core/provider.py} +4 -1
- codeintel/{query_ops.py → core/query_ops.py} +2 -2
- codeintel/{redact.py → core/redact.py} +50 -13
- codeintel/{source_kind.py → core/source_kind.py} +10 -0
- codeintel/engines/__init__.py +3 -0
- codeintel/engines/graph/__init__.py +1 -0
- codeintel/{graph_answer.py → engines/graph/answer.py} +381 -28
- codeintel/{graph_backend.py → engines/graph/backend.py} +70 -6
- codeintel/engines/graph/blindspots.py +521 -0
- codeintel/{graph_changed.py → engines/graph/changed.py} +8 -8
- codeintel/{changed_range.py → engines/graph/changed_range.py} +86 -26
- codeintel/{graph_confidence.py → engines/graph/confidence.py} +18 -3
- codeintel/{graph_dispatch.py → engines/graph/dispatch.py} +334 -12
- codeintel/{graph_edges.py → engines/graph/edges.py} +10 -1
- codeintel/{graph_ops.py → engines/graph/ops.py} +266 -25
- codeintel/{providers/graph.py → engines/graph/provider.py} +283 -49
- codeintel/{qualifier_scan.py → engines/graph/qualifier_scan.py} +3 -3
- codeintel/{graph_render.py → engines/graph/render.py} +24 -13
- codeintel/{graph_resolution.py → engines/graph/resolution.py} +1 -1
- codeintel/{symbol_diff.py → engines/graph/symbol_diff.py} +2 -2
- codeintel/{graph_targets.py → engines/graph/targets.py} +1 -1
- codeintel/engines/lsp/__init__.py +1 -0
- codeintel/{lang_config.py → engines/lsp/lang_config.py} +3 -3
- codeintel/{providers/lsp.py → engines/lsp/provider.py} +4 -4
- codeintel/{providers → engines}/none.py +1 -1
- codeintel/engines/semantic/__init__.py +1 -0
- codeintel/{semantic_db.py → engines/semantic/db.py} +13 -5
- codeintel/{indexer.py → engines/semantic/indexer.py} +11 -11
- codeintel/{providers/semantic.py → engines/semantic/provider.py} +209 -20
- codeintel/{searcher.py → engines/semantic/searcher.py} +3 -3
- codeintel/gateway/__init__.py +1 -0
- codeintel/{auth.py → gateway/auth.py} +2 -2
- codeintel/{cache.py → gateway/cache.py} +17 -7
- codeintel/gateway/factory.py +51 -0
- codeintel/{gateway.py → gateway/gateway.py} +222 -35
- codeintel/{reindexer.py → gateway/reindexer.py} +151 -19
- codeintel/mapping/__init__.py +1 -0
- codeintel/{grapher.py → mapping/grapher.py} +3 -3
- codeintel/{mapper.py → mapping/mapper.py} +19 -7
- codeintel/{viewer → mapping/viewer}/__init__.py +1 -1
- codeintel/setup/__init__.py +1 -0
- codeintel/{agent_prompt.py → setup/agent_prompt.py} +46 -11
- codeintel/{doctor.py → setup/doctor.py} +19 -6
- codeintel/{injector.py → setup/injector.py} +40 -36
- codeintel/{installer.py → setup/installer.py} +1 -1
- codeintel/{onboarding.py → setup/onboarding.py} +9 -9
- codeintel/{reset.py → setup/reset.py} +16 -28
- codeintel/transports/__init__.py +1 -0
- codeintel/{http_server.py → transports/http.py} +12 -9
- codeintel/{server.py → transports/mcp.py} +60 -60
- codecortex-0.29.3.dist-info/RECORD +0 -85
- codeintel/containment.py +0 -95
- codeintel/paths.py +0 -31
- codeintel/providers/__init__.py +0 -0
- {codecortex-0.29.3.dist-info → codecortex-0.30.0.dist-info}/WHEEL +0 -0
- {codecortex-0.29.3.dist-info → codecortex-0.30.0.dist-info}/entry_points.txt +0 -0
- {codecortex-0.29.3.dist-info → codecortex-0.30.0.dist-info}/licenses/LICENSE +0 -0
- {codecortex-0.29.3.dist-info → codecortex-0.30.0.dist-info}/top_level.txt +0 -0
- /codeintel/{commands → cli}/__init__.py +0 -0
- /codeintel/{commands → cli}/_common.py +0 -0
- /codeintel/{commands → cli}/gen_token.py +0 -0
- /codeintel/{loc.py → core/loc.py} +0 -0
- /codeintel/{logconfig.py → core/logconfig.py} +0 -0
- /codeintel/{outcome.py → core/outcome.py} +0 -0
- /codeintel/{per_thread.py → core/per_thread.py} +0 -0
- /codeintel/{progress.py → core/progress.py} +0 -0
- /codeintel/{term.py → core/term.py} +0 -0
- /codeintel/{wire_text.py → engines/graph/wire_text.py} +0 -0
- /codeintel/{policy.py → gateway/policy.py} +0 -0
- /codeintel/{viewer → mapping/viewer}/graph_template.html +0 -0
- /codeintel/{verify.py → setup/verify.py} +0 -0
- /codeintel/{metrics.py → transports/metrics.py} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codecortex
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.30.0
|
|
4
4
|
Summary: Local-first, MCP-native code-intelligence server — graph, LSP, and semantic search behind one safe code.query tool for coding agents.
|
|
5
5
|
Author: Shammai Hamilton
|
|
6
6
|
License-Expression: MIT
|
|
@@ -242,7 +242,7 @@ It's one call: `code.query(op, target, engine="auto")`. In `auto` mode (the defa
|
|
|
242
242
|
| Who calls this? | `callers` | graph | caller symbols + files |
|
|
243
243
|
| What does this call? | `callees` | graph | callee symbols + files |
|
|
244
244
|
| Blast radius of a change | `impact` | graph | callers **and** callees together |
|
|
245
|
-
| Trace a call chain up/downstream | `chain` | graph | ordered hops, each labelled with how it was resolved |
|
|
245
|
+
| Trace a call chain up/downstream | `chain` (`"A->B"` for the path from A to B) | graph | ordered hops, each labelled with how it was resolved (`[unstated]` when the backend did not say) |
|
|
246
246
|
| Find symbols by pattern | `pattern` | graph | matching nodes + locations |
|
|
247
247
|
| Project shape at a glance | `overview` | graph → lsp | modules, node/edge counts, languages |
|
|
248
248
|
| Everything about one symbol | `context` | graph + lsp | both views merged |
|
|
@@ -306,7 +306,7 @@ model {
|
|
|
306
306
|
providers = area 'providers' {
|
|
307
307
|
lsp = module 'lsp' {
|
|
308
308
|
technology 'Python'
|
|
309
|
-
metadata { path 'src/codeintel/
|
|
309
|
+
metadata { path 'src/codeintel/engines/lsp/provider.py' churn '12' fan_out '2' }
|
|
310
310
|
}
|
|
311
311
|
graph = module 'graph' { /* … */ }
|
|
312
312
|
}
|
|
@@ -345,7 +345,7 @@ Full reference: **[docs/c4.md](docs/c4.md)**. Why LikeC4 and not something else,
|
|
|
345
345
|
- **It never throws.** Every call returns the same JSON envelope; a missing or broken backend degrades to `null` *with a reason*. No exceptions, no 500s, no malformed output for the agent to trip over — so you never wrap `code.query` in a `try`.
|
|
346
346
|
- **One tool, not three.** Register a single MCP server and it auto-routes each question to graph, LSP, or semantic — instead of wiring up three backends with three response shapes and three failure modes.
|
|
347
347
|
- **Degrades instead of breaking.** No graph backend installed? That engine returns `null` and the agent falls back to grep. The semantic engine needs nothing external, so codeintel is useful the moment it's installed and only gets sharper as you add backends.
|
|
348
|
-
- **Fast on repeat, and the cache
|
|
348
|
+
- **Fast on repeat, and the cache follows the index.** A content-hash cache returns instantly for unchanged code and is invalidated by a reindex from any process — the server's own background pass, a `codeintel index` in another terminal, or a `codeintel reset` that deletes the index — because its key includes the index files' modification times. The semantic index is one file per embedding model, shared by every project on the machine, so indexing one project also invalidates other projects' cached answers: a re-ask costs a recompute, never a stale answer. It never serves an answer from an index that has since been rewritten. The cache is bounded (LRU), so a long-running server holds steady memory. (The *cache* is always consistent with the index; how current the index itself is depends on the engine — see [Keeping answers fresh](#keeping-answers-fresh).)
|
|
349
349
|
- **Concurrency-safe.** The HTTP transport handles requests on threads, so one slow query (an LSP session warming, a first-time index) can't block every other agent.
|
|
350
350
|
- **Honest about its own health.** `codeintel doctor` answers three separate questions per engine — *installed?* *runnable?* *is this repo indexed?* — with the single command to fix each gap, so "installed" is never mistaken for "working". And a readiness claim is one a query can actually honor: install a missing backend mid-session and the running server picks it up on the next call, rather than reporting the engine healthy while quietly routing around it until you restart the host.
|
|
351
351
|
|
|
@@ -424,8 +424,9 @@ rather than a bare reason.
|
|
|
424
424
|
|
|
425
425
|
One more honest caveat. For targets that are **symbol names or free text** (most of them —
|
|
426
426
|
`callers`, `impact`, `hotspots`, `search`), there is no file whose content hash could change, so a
|
|
427
|
-
cached answer is invalidated only when a background reindex completes,
|
|
428
|
-
|
|
427
|
+
cached answer is invalidated only when the index is rewritten (a background reindex completes,
|
|
428
|
+
or `codeintel index` runs), and background passes are debounced (~30s). An edit followed
|
|
429
|
+
immediately by the same query can therefore return the pre-edit answer.
|
|
429
430
|
Targets that are real file paths are content-hashed and refresh as soon as the bytes change.
|
|
430
431
|
|
|
431
432
|
Pass `--engine auto` (the default) and codeintel chooses the best engine per operation. Pass `--engine both` or `--engine all` to fan out to multiple engines and merge results.
|
|
@@ -497,7 +498,7 @@ Config is **validated on load** — an out-of-range number, a misspelled enum, o
|
|
|
497
498
|
| `CODEINTEL_LOG_FORMAT=json` | Structured (JSON-per-line) logs for ELK / Splunk / Datadog |
|
|
498
499
|
| `CODEINTEL_HTTP_ACCESS_LOG=1` | One log line per HTTP request (method, path, status, latency) |
|
|
499
500
|
| `CODEINTEL_DEBUG=1` | Log the full traceback of any error the never-throw contract swallows (silent by default) — the switch for diagnosing an unexpected `null` |
|
|
500
|
-
| `CODEINTEL_REINDEX=off` | Disable the background reindexer
|
|
501
|
+
| `CODEINTEL_REINDEX=off` | Disable the background reindexer. Graph answers are **not** indexed inline: run `codeintel index <root>` to refresh them, and the cache notices the new index on the next query. (Semantic `search` still indexes inline, on every query, while the reindexer is off.) |
|
|
501
502
|
| `CODEINTEL_HOME` | Where per-machine state lives (default `~/.codeintel`) — the index cache, the global `config.toml`, and `auth.toml`. Set this when the process has **no resolvable home directory** — a container running as a UID with no passwd entry and no `$HOME`, which is common when an agent runs in one. Without it, `Path.home()` raises and every command fails somewhere far from the cause. |
|
|
502
503
|
|
|
503
504
|
## Privacy & dependencies
|
|
@@ -630,7 +631,7 @@ jobs cover the contract itself: `graph-contract` installs the pinned `codebase-m
|
|
|
630
631
|
the live graph tests — and **fails if they skipped**, because a silently-skipped contract test is
|
|
631
632
|
how a total backend outage stayed green here once — while the nightly corpus job runs that same
|
|
632
633
|
real backend against pinned third-party repositories. `lsp-contract` runs the live serena tests
|
|
633
|
-
against the exact serena commit the provider launches (`
|
|
634
|
+
against the exact serena commit the provider launches (`engines/lsp/provider.py`'s `_SERENA_REV`), and it
|
|
634
635
|
**gates**: a serena regression turns CI red, and moving to a newer serena means bumping that pin
|
|
635
636
|
with the contract job green against it. The release canary — the only check that
|
|
636
637
|
asserts on real answer text from a built wheel — still covers **the semantic engine only**.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
codecortex-0.30.0.dist-info/licenses/LICENSE,sha256=DIRvhlH8EulEUOYQxKDFFiimJrlVT5-kCKxQIgi2m7c,1073
|
|
2
|
+
codeintel/__init__.py,sha256=OlatFEFA4ttqSSIiV8jdE-sq3KG5zu2hnC4B4mzWF3s,23
|
|
3
|
+
codeintel/__main__.py,sha256=NSdi_mJ_sYJ6smUt7qk6hn6qWXNtSt8kbxXzgFXmT_4,39697
|
|
4
|
+
codeintel/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
codeintel/c4/__init__.py,sha256=r_-uwBs3UOQRCmpTzE0hJVqxi8NljBeiESFKTpgY3v4,95
|
|
6
|
+
codeintel/c4/check.py,sha256=JY0szeiMPSr8TmEKT_MWemzbDrmUijvD3Yh9TmWz2lQ,28728
|
|
7
|
+
codeintel/c4/layers.py,sha256=nWJqXJlz4qTWKwGcTWmPd2UOnRbgFepwUxBKyoDlmnI,32758
|
|
8
|
+
codeintel/c4/model.py,sha256=uMzrD_umgR0zxiSl4QNQFXZqnVJVxdHQmAkQ1uYbvPQ,73722
|
|
9
|
+
codeintel/cli/__init__.py,sha256=Q97C8VWbsAX4y_4Zz6EJHXmQa5RDlxZa4amfCs7kYf8,323
|
|
10
|
+
codeintel/cli/_common.py,sha256=L30AmFvG1l5LXQPN2WzyFV6Z6hhrCZT6J_09sDzjM3I,2286
|
|
11
|
+
codeintel/cli/c4.py,sha256=sQJgMGdtqTp3BR2fKS9aKsHQ87UeZEXAmanQYQFkhZ4,17449
|
|
12
|
+
codeintel/cli/doctor.py,sha256=1vTXBUHomZuxIvQmGmp6Qh2t9FNBSNyx7coAW8YsvSk,598
|
|
13
|
+
codeintel/cli/gen_token.py,sha256=U1cyDanurDotzg8j-QwEc-poE-I_bNipYu0CqXilM8M,212
|
|
14
|
+
codeintel/cli/graph.py,sha256=n1uVG177craz4r3ZJRT9coSu_reoR-3KxcbtAJouN4I,1395
|
|
15
|
+
codeintel/cli/index.py,sha256=EzXxw8-LeaYCasMrNmhLC5gaNNVSv66VhbfwloqSYYE,11029
|
|
16
|
+
codeintel/cli/install.py,sha256=-UjlVVAUwb19PulRExgxTA0BKVKh791_CtbzkDmBe_M,5960
|
|
17
|
+
codeintel/cli/map.py,sha256=Xi49aUhmAGeJA-zTs8Xnq39rfNU2Gf8icyphEANmu60,2096
|
|
18
|
+
codeintel/cli/prompt.py,sha256=hDuZC4Ec1MhuTtVPktiHCvUXE0IxXzUWZkYL8Lyxb4U,1301
|
|
19
|
+
codeintel/cli/query.py,sha256=_CsGpfZGpNPc_l1PVWile80n1khuZb8Dy1XVFHxcKkw,5445
|
|
20
|
+
codeintel/cli/reset.py,sha256=PBrLOGr-Ze0h8Nmv45OFzAaOx-a2WaPeNo4M5_RbTW4,1239
|
|
21
|
+
codeintel/cli/serve.py,sha256=N0YHAezUcDRwNTJVOPqaV1XzvVtg1f8Pok_aX_XXieE,238
|
|
22
|
+
codeintel/cli/serve_http.py,sha256=nwavZaGUyQyyKtIJlJk8ybRZ8_A86UcZ_salvi11H54,740
|
|
23
|
+
codeintel/cli/setup.py,sha256=f2uv51RwX-PGcLsQQNcechFHPzc_ZzTXdkiJ_j8t91Y,1001
|
|
24
|
+
codeintel/cli/status.py,sha256=W-KNk2OQZaxA4CLUV45rgQMiSLqJNex3f6YqaJuTDW4,5010
|
|
25
|
+
codeintel/cli/uninstall.py,sha256=-rirf7TaEb-ogepsMpouuqasoOOShI_6PxPXVcwDV04,5123
|
|
26
|
+
codeintel/core/__init__.py,sha256=Oe8lOOIKYPil3ijp0k9W67tPPIV8PWPVq2gXHXqrKZY,139
|
|
27
|
+
codeintel/core/config.py,sha256=4WT4aobJrzDDMrUkYWEAhTWEpJmBcYl6RyC3B0LadjE,5181
|
|
28
|
+
codeintel/core/containment.py,sha256=coZQmhx2rjmP2nXffMBtJrHK9N68cVHU6Df921MbGBI,13108
|
|
29
|
+
codeintel/core/filelock.py,sha256=j2jGCoc7pp7au8wdw7_z9oq-SyN0JhtiJMrX0CveukY,7083
|
|
30
|
+
codeintel/core/loc.py,sha256=BCOTB-LsF3PzuMNVbpue0hzSHyVGoDsxM22dP8pn2PM,3710
|
|
31
|
+
codeintel/core/logconfig.py,sha256=i15tVUgHvXE3UoMutMhsaj8578-A0anYSn8-YFZIbxY,1859
|
|
32
|
+
codeintel/core/outcome.py,sha256=LgZAEtOCvA9Z_dCv-dSklBdkTq3q8slOr50-gf-PYz0,5230
|
|
33
|
+
codeintel/core/paths.py,sha256=p-nlGVQsDEpbVj3yr61Kjk1x_IzM-ojAwne7yvyEAhE,4937
|
|
34
|
+
codeintel/core/per_thread.py,sha256=2Ha6mVc-SfKrqzkn5K6TtMX_n37VSH3kUI-942YZDbs,2774
|
|
35
|
+
codeintel/core/progress.py,sha256=tUi8Gg8M5lpQLO3sneXuNbPGtnBtwZcbXFF5hHIIwuo,3233
|
|
36
|
+
codeintel/core/provider.py,sha256=ukLtD-Ztf8OC6_vA7272CYwq5POBSb9L3E1NwhLwBO4,13443
|
|
37
|
+
codeintel/core/query_ops.py,sha256=Ael3ipAf9a4jjBd491_3YYlsEhnyC97K4CEx-lLZ4A0,1878
|
|
38
|
+
codeintel/core/redact.py,sha256=mJT95TFE6zTX0MDgHo0_LzcaVHt4GVMZsAYVcOQRWs4,11846
|
|
39
|
+
codeintel/core/source_kind.py,sha256=uVKOfgmrY32W1N33Fs5Lv2Mcd6T5S71dQWEhAWhOiro,13615
|
|
40
|
+
codeintel/core/term.py,sha256=FePzFnzk-TTyRwZiVY_Em5D0-WqULGZqTnKsSsjA8qY,17720
|
|
41
|
+
codeintel/engines/__init__.py,sha256=vadR8fAsJkNuRsjVof1G2PCkQnPjSwq5iD83AXbXUDs,168
|
|
42
|
+
codeintel/engines/none.py,sha256=efPpA4kGoEBYvEf5pZqckUc8SqH5QHMDC5-1ekjv-E0,788
|
|
43
|
+
codeintel/engines/graph/__init__.py,sha256=SB3C44bnneoojC7EQDQaWqlYK4lGPPWL8gHHRu3bhbs,78
|
|
44
|
+
codeintel/engines/graph/answer.py,sha256=sL_Cyn97NvlU80O6rVygvx3Mwfs5xTpGOMlZeuWXxg8,113909
|
|
45
|
+
codeintel/engines/graph/backend.py,sha256=UzHmxJaPS7o9ZA00Nb5pFuF9yf8VwVOdP8g5IW39L3g,30084
|
|
46
|
+
codeintel/engines/graph/blindspots.py,sha256=Tk8Ka72z2Y0jiqGMVJIqcu_kzNx3Rb4Yedrs9d4025U,24402
|
|
47
|
+
codeintel/engines/graph/changed.py,sha256=fRL1XbBOEvi-3fVD75k6XxdVKJkynOOyiCc8GvwCTwk,56493
|
|
48
|
+
codeintel/engines/graph/changed_range.py,sha256=B1nMMaCL1SMG40S0PnCg9GTWd3RGQDYGe-G1770ZLz0,27344
|
|
49
|
+
codeintel/engines/graph/confidence.py,sha256=gIylsnSS7Kme9i-6kWac3vt0pRmpayh6tby_MGvi_3M,26733
|
|
50
|
+
codeintel/engines/graph/dispatch.py,sha256=WVE1eq3sOpJDWVL3MfPC2drbCo_HcRBfermUabraDI4,86794
|
|
51
|
+
codeintel/engines/graph/edges.py,sha256=cPWTpjYIzrIsPiK7wERaj4Y0FvsKPhzkWXE2NCWo2cs,8604
|
|
52
|
+
codeintel/engines/graph/ops.py,sha256=YMU6xwJ5bNv9kSfXJIA9W4Zkrs_BZxX6gsYinlmPycg,69024
|
|
53
|
+
codeintel/engines/graph/provider.py,sha256=Bgxi_cgizo3SbR6YeCBpgWvvTMBNfAIKVsA6W9XsEew,73472
|
|
54
|
+
codeintel/engines/graph/qualifier_scan.py,sha256=n8DUSdLpIpMAXgPpMEa94GFiWVkpwnzOqvaPUQ_NwJo,20186
|
|
55
|
+
codeintel/engines/graph/render.py,sha256=i9lQa10NHOkXNFZ-Y-vfLj8wKRgQablyYpBsig5UbBM,16770
|
|
56
|
+
codeintel/engines/graph/resolution.py,sha256=pzBcRfgW5H1Si7Q6Y2OiR3Bdhhzo4WWPWSlwlPambWc,16037
|
|
57
|
+
codeintel/engines/graph/symbol_diff.py,sha256=Enm7PeMnKd64BWb95-GpNJ1QjUDfpBrtJFl38U934ds,31363
|
|
58
|
+
codeintel/engines/graph/targets.py,sha256=5F54bIpFywFPdBNQdYyHEMN5yaljC14MDUoiUJT5ubI,6657
|
|
59
|
+
codeintel/engines/graph/wire_text.py,sha256=cmM4Q3jaCDSdL3uGQcpyaJ5if00DSHk45jPozogeQq0,17528
|
|
60
|
+
codeintel/engines/lsp/__init__.py,sha256=n538c2QCnkIVGmeJAh_hnIoOtWJTDpEDxvmUDgu5aTQ,83
|
|
61
|
+
codeintel/engines/lsp/lang_config.py,sha256=ExEaGe6bJc9puQSaEQNGFP1RVtyuX7wj6Hn46-_2ukU,13071
|
|
62
|
+
codeintel/engines/lsp/provider.py,sha256=cVd946w2EFZMNBJxQki52mPr2Z2CL3tK6A3CNut1TuY,71121
|
|
63
|
+
codeintel/engines/semantic/__init__.py,sha256=owvaznjxLyGxDm-2PUIrr-BH99lgU2FIoAQEN-cII4g,67
|
|
64
|
+
codeintel/engines/semantic/db.py,sha256=0IaUumZiygs49_UB5kiqcjK7PmfL_RGPPakzXq82HjY,32098
|
|
65
|
+
codeintel/engines/semantic/indexer.py,sha256=nZhCP5A1uyIhjQdU-_c9tJn6rNJD1T7sQLHftEEfi9Q,54881
|
|
66
|
+
codeintel/engines/semantic/provider.py,sha256=J6Ssn0ZDCeUjjtFetB7T6OpsFd2JDOKf6aI9Evxa5fU,66020
|
|
67
|
+
codeintel/engines/semantic/searcher.py,sha256=kKS0Sa6GlXhJcbNfudR1z9uwhfRVqGIuVGBfIW1RG7c,24943
|
|
68
|
+
codeintel/gateway/__init__.py,sha256=QK6m-HNde5usl0-Wv944VuTjDalBlNcCubjR5nFRWKA,100
|
|
69
|
+
codeintel/gateway/auth.py,sha256=jAK4iibFAv5fDO2L9hVDgBcJ8WcK6_NDaHcR34fQWIs,7324
|
|
70
|
+
codeintel/gateway/cache.py,sha256=hdXo9heXdtb4qtDruQpikGOuuzHgt-aiKwFKPhyL9yA,5067
|
|
71
|
+
codeintel/gateway/factory.py,sha256=f5UP5VnqrY6UoIiFBVuS7MCIwgoEiaLZHeYVvwPep3I,2240
|
|
72
|
+
codeintel/gateway/gateway.py,sha256=8oH_CcXCdHaybvfgxd0eJa0k735QXn36hYTcAUCJOog,53956
|
|
73
|
+
codeintel/gateway/policy.py,sha256=3QVZzcSjRkJildbUfIjl6UL3l8ZsToZu4jG-WbXFRcQ,4296
|
|
74
|
+
codeintel/gateway/reindexer.py,sha256=gIizPDt38TRxhGNto4eXo_DRWm9-E6pC4QdmJez8DJA,20978
|
|
75
|
+
codeintel/mapping/__init__.py,sha256=R41Nz3s1dunD4EwscQj10VHkIUS59o3VxlPTJnjFbQI,89
|
|
76
|
+
codeintel/mapping/grapher.py,sha256=-gel2h3rwo4rvetNqU1s2-dyNS6ezZcO17u3LJM3fYk,6595
|
|
77
|
+
codeintel/mapping/mapper.py,sha256=_yZGN4NEsk_aEQg7UNVknY9gKed4rY9HYs_eXpeOmw4,20858
|
|
78
|
+
codeintel/mapping/viewer/__init__.py,sha256=7L13Iwr9EUhzx9HFkSiXZuittOwi_3mScMCMPfBH2D0,109
|
|
79
|
+
codeintel/mapping/viewer/graph_template.html,sha256=Oi6IRS7Rsa5j8q_FCEfAQHf7UQi1JsH37jVuw-NvuNo,38786
|
|
80
|
+
codeintel/setup/__init__.py,sha256=J7ucWcKakUhyPxt3rYvzTv3UwUg1rLgYgjGH1bEUsQw,88
|
|
81
|
+
codeintel/setup/agent_prompt.py,sha256=s7cAhr4KJClNDU_7Wz_-JPNERRDAnPCqhIn3LSm8z1s,7495
|
|
82
|
+
codeintel/setup/doctor.py,sha256=sDgjVOi60WC7jU_qv16a8piASQvROTUnYfl7nXFP1WM,25594
|
|
83
|
+
codeintel/setup/injector.py,sha256=S0oT1n9bWeU3Whh7_N6B_6mAcQrULuYSkJCKUZXvfQk,13776
|
|
84
|
+
codeintel/setup/installer.py,sha256=BqASK4Tifw6IdIhEIDBpLQdQlHg9b1rzl8LHzLFYHBM,27940
|
|
85
|
+
codeintel/setup/onboarding.py,sha256=jw6UI_3Drg5AIJ1XbkinVpNsts_xwcIqstFccD22hXw,16794
|
|
86
|
+
codeintel/setup/reset.py,sha256=0T6sPzeJoFQufFD2dbk4lZFSoRd2Oo_76HDqk-IY6OU,12252
|
|
87
|
+
codeintel/setup/verify.py,sha256=M1fyNIzEJJMZrY0a9WQevepktD7j7lvDXgrk481kI5Y,15386
|
|
88
|
+
codeintel/transports/__init__.py,sha256=yBe6z7jerealUf3bxfsD2suY1WOKZ7-37mPuCERnX2g,84
|
|
89
|
+
codeintel/transports/http.py,sha256=Y469FoCe1C8CCg0vUcH_aWU6wmkGVqqaiCwSqwD9O2s,17477
|
|
90
|
+
codeintel/transports/mcp.py,sha256=zC05qBkIq0XAbTWWLSqAQPo-nDeORMTp1rt1CE-ERyU,40469
|
|
91
|
+
codeintel/transports/metrics.py,sha256=-wqyPPSB8wr4GuP5YsI5qSzxNq-ck33Zy5XUrtY5E_I,3930
|
|
92
|
+
codecortex-0.30.0.dist-info/METADATA,sha256=pMGcoMm_buXPFxanRnbv0b5O-T_6Uc-6-Yh9AHCum04,49612
|
|
93
|
+
codecortex-0.30.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
94
|
+
codecortex-0.30.0.dist-info/entry_points.txt,sha256=zrYfo95-8JkK0G2e5f9d94sYqqim7ZrdCW8knIfSy2U,54
|
|
95
|
+
codecortex-0.30.0.dist-info/top_level.txt,sha256=DF3TH1hHLWrrnX-7HhfMX0OnS2EXgqPRhPbiL_oSekw,10
|
|
96
|
+
codecortex-0.30.0.dist-info/RECORD,,
|
codeintel/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.
|
|
1
|
+
__version__ = "0.30.0"
|
codeintel/__main__.py
CHANGED
|
@@ -7,9 +7,9 @@ from importlib import import_module
|
|
|
7
7
|
from typing import NoReturn
|
|
8
8
|
|
|
9
9
|
from codeintel import __version__
|
|
10
|
-
from codeintel.query_ops import QUERY_OPS
|
|
10
|
+
from codeintel.core.query_ops import QUERY_OPS
|
|
11
11
|
|
|
12
|
-
# `--engine`'s canonical values live in `codeintel.gateway._KNOWN_ENGINES` (a set — order is not
|
|
12
|
+
# `--engine`'s canonical values live in `codeintel.gateway.gateway._KNOWN_ENGINES` (a set — order is not
|
|
13
13
|
# meaningful there). This fixes a presentation order for help text and `choices=`. Membership is
|
|
14
14
|
# pinned to the gateway's set by test_cli_help.py, which is where the guard belongs: importing
|
|
15
15
|
# gateway here just to assert at module scope would pull it into every CLI startup.
|
|
@@ -50,7 +50,7 @@ _COMMAND_GROUPS: list[tuple[str, list[tuple[str, str]]]] = [
|
|
|
50
50
|
("Check health", [
|
|
51
51
|
("doctor", "Per-engine health + index status, with the fix for each gap"),
|
|
52
52
|
("status", "Engine readiness and index age at a glance"),
|
|
53
|
-
("reset", "Clear the semantic
|
|
53
|
+
("reset", "Clear the semantic and graph indexes (corrupt or stale DB)"),
|
|
54
54
|
]),
|
|
55
55
|
("Run as a server", [
|
|
56
56
|
("serve", "Start the MCP server over stdio — what an agent host launches"),
|
|
@@ -68,7 +68,7 @@ _COMMANDS = [name for _group, items in _COMMAND_GROUPS for name, _desc in items]
|
|
|
68
68
|
# engine" after `_COMMAND_GROUPS` had moved on to naming the actual ops).
|
|
69
69
|
_DESCRIPTIONS: dict[str, str] = {name: desc for _group, items in _COMMAND_GROUPS for name, desc in items}
|
|
70
70
|
|
|
71
|
-
# Each command's body lives in codeintel.
|
|
71
|
+
# Each command's body lives in codeintel.cli.<module> as `run(args) -> int`. The mapping is
|
|
72
72
|
# spelled out rather than derived from the command name so the target of any command is greppable,
|
|
73
73
|
# and the import happens at dispatch time so `codeintel serve` never pays for the semantic
|
|
74
74
|
# engine's imports (nor serve-http for the graph's).
|
|
@@ -152,9 +152,9 @@ def _formatter_class(prog: str) -> argparse.RawDescriptionHelpFormatter:
|
|
|
152
152
|
def render_help() -> str:
|
|
153
153
|
"""The `codeintel` / `codeintel help` screen: grouped, colored, with real examples.
|
|
154
154
|
|
|
155
|
-
Color comes from codeintel.term, so it auto-degrades on a pipe, under NO_COLOR, and on a dumb
|
|
155
|
+
Color comes from codeintel.core.term, so it auto-degrades on a pipe, under NO_COLOR, and on a dumb
|
|
156
156
|
terminal — same as every other human-facing command."""
|
|
157
|
-
from codeintel.term import c
|
|
157
|
+
from codeintel.core.term import c
|
|
158
158
|
|
|
159
159
|
width = max(len(name) for name in _COMMANDS)
|
|
160
160
|
out = [
|
|
@@ -235,7 +235,7 @@ def _suggest(unknown: str) -> list[str]:
|
|
|
235
235
|
def _unknown_command(name: str) -> int:
|
|
236
236
|
"""Report an unrecognized command with a way forward. argparse's own error dumps the full list
|
|
237
237
|
of choices and stops there, which is a dead end for a one-character typo."""
|
|
238
|
-
from codeintel.term import c_err as e
|
|
238
|
+
from codeintel.core.term import c_err as e
|
|
239
239
|
|
|
240
240
|
print(e.red(f"unknown command: {name!r}"), file=sys.stderr)
|
|
241
241
|
matches = _suggest(name)
|
|
@@ -353,6 +353,7 @@ For agents that cannot read an MCP config: paste the output into the
|
|
|
353
353
|
conversation.""",
|
|
354
354
|
"reset": """examples:
|
|
355
355
|
codeintel reset .
|
|
356
|
+
codeintel reset --semantic-only . clear semantic only, keep the graph
|
|
356
357
|
codeintel reset --all --yes wipe every repo, no prompt
|
|
357
358
|
|
|
358
359
|
Recovers from a corrupt or stale index. Re-index afterwards.""",
|
|
@@ -384,7 +385,7 @@ class _RootArgumentParser(argparse.ArgumentParser):
|
|
|
384
385
|
subcommand's own short, specific usage line — only the wide top-level wall is replaced."""
|
|
385
386
|
|
|
386
387
|
def error(self, message: str) -> NoReturn:
|
|
387
|
-
from codeintel.term import c_err as e
|
|
388
|
+
from codeintel.core.term import c_err as e
|
|
388
389
|
|
|
389
390
|
print(e.red(f"codeintel: error: {message}"), file=sys.stderr)
|
|
390
391
|
print("\n " + e.dim("run `codeintel help` to see every command, grouped"), file=sys.stderr)
|
|
@@ -658,6 +659,8 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
658
659
|
reset_parser.add_argument("project_root", nargs="?", default=None, help="Project root (default: cwd)")
|
|
659
660
|
reset_parser.add_argument("--all", action="store_true",
|
|
660
661
|
help="Clear the ENTIRE index (all projects), not just this repo")
|
|
662
|
+
reset_parser.add_argument("--semantic-only", action="store_true",
|
|
663
|
+
help="Clear only the semantic index; keep the graph index")
|
|
661
664
|
reset_parser.add_argument("--yes", "-y", action="store_true", help="Skip the confirmation prompt")
|
|
662
665
|
reset_parser.add_argument("--json", action="store_true", help="Emit the structured JSON report")
|
|
663
666
|
|
|
@@ -694,14 +697,14 @@ def main() -> None:
|
|
|
694
697
|
# screen. Without this, the command a new user actually types was the ONE path that missed
|
|
695
698
|
# render_help() and fell back to stock argparse.
|
|
696
699
|
if not argv or argv[0] in ("help", "-h", "--help"):
|
|
697
|
-
from codeintel import term
|
|
700
|
+
from codeintel.core import term
|
|
698
701
|
term.configure(no_color=False, ascii_mode=None)
|
|
699
702
|
print(render_help())
|
|
700
703
|
sys.exit(0)
|
|
701
704
|
|
|
702
705
|
args = parser.parse_args()
|
|
703
706
|
|
|
704
|
-
from codeintel import term
|
|
707
|
+
from codeintel.core import term
|
|
705
708
|
term.configure(
|
|
706
709
|
no_color=getattr(args, "no_color", False),
|
|
707
710
|
ascii_mode=(True if getattr(args, "ascii", False) else None),
|
|
@@ -712,7 +715,11 @@ def main() -> None:
|
|
|
712
715
|
print(render_help()) # "help" (`codeintel --no-color help`) — both skip the early-return
|
|
713
716
|
# above because argv[0] is the flag, not the command/"help" itself
|
|
714
717
|
sys.exit(0)
|
|
715
|
-
|
|
718
|
+
try:
|
|
719
|
+
status = int(import_module(f"codeintel.cli.{module}").run(args))
|
|
720
|
+
except KeyboardInterrupt:
|
|
721
|
+
print("interrupted", file=sys.stderr)
|
|
722
|
+
status = 130
|
|
716
723
|
if args.command in _NATIVE_RUNTIME_COMMANDS:
|
|
717
724
|
_native_safe_exit(status)
|
|
718
725
|
sys.exit(status)
|
codeintel/c4/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Layer 3 (tools): the `codeintel c4` architecture model, layer inference and layer check."""
|
|
@@ -27,7 +27,7 @@ from __future__ import annotations
|
|
|
27
27
|
from collections.abc import Iterable
|
|
28
28
|
from typing import Any
|
|
29
29
|
|
|
30
|
-
from codeintel.
|
|
30
|
+
from codeintel.c4.layers import assign_declared_layers, compute_layers, glob_match
|
|
31
31
|
|
|
32
32
|
# `rule` is a stable machine id and the set is an API: it is what a future allowlist keys on, what a
|
|
33
33
|
# suppression file references, and what SARIF's `ruleId` maps to. Renaming one after release breaks
|
|
@@ -103,7 +103,7 @@ def _match_allow(entry: dict[str, Any], from_paths: list[str], to_paths: list[st
|
|
|
103
103
|
|
|
104
104
|
Matched against file paths first (the stable identity, per §3.3) and element ids second, so an
|
|
105
105
|
entry written either way works. Globs are honoured through the same segment matcher membership
|
|
106
|
-
uses, so `from = "src/codeintel/
|
|
106
|
+
uses, so `from = "src/codeintel/engines/**"` behaves as an author would expect.
|
|
107
107
|
"""
|
|
108
108
|
src, dst = entry.get("from") or "", entry.get("to") or ""
|
|
109
109
|
if not src or not dst:
|
|
@@ -116,6 +116,28 @@ def _match_allow(entry: dict[str, Any], from_paths: list[str], to_paths: list[st
|
|
|
116
116
|
return hits(src, from_paths, from_element) and hits(dst, to_paths, to_element)
|
|
117
117
|
|
|
118
118
|
|
|
119
|
+
def _match_allow_file(entry: dict[str, Any], from_file: str, to_file: str) -> bool:
|
|
120
|
+
"""Does an allowlist entry cover one file-level import edge?
|
|
121
|
+
|
|
122
|
+
The file pair is what the depth cannot move: the same import rolls up to a different element pair
|
|
123
|
+
at every `--depth`, and an element's own paths become a directory once it is rolled up, so an
|
|
124
|
+
entry naming a file matches here at every depth auto-fit picks.
|
|
125
|
+
"""
|
|
126
|
+
src, dst = entry.get("from") or "", entry.get("to") or ""
|
|
127
|
+
if not src or not dst:
|
|
128
|
+
return False
|
|
129
|
+
return ((src == from_file or glob_match(src, from_file))
|
|
130
|
+
and (dst == to_file or glob_match(dst, to_file)))
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def _file_edges(rel: dict[str, Any]) -> list[tuple[str, str, int]]:
|
|
134
|
+
"""The relation's IMPORTS file pairs, or ``[]`` when the payload carries none (a hand-built
|
|
135
|
+
payload or an older `--json`), which keeps the element-path matching."""
|
|
136
|
+
return [(str(item[0]), str(item[1]), item[2] if isinstance(item[2], int) else 0)
|
|
137
|
+
for item in rel.get("import_files") or []
|
|
138
|
+
if isinstance(item, (list, tuple)) and len(item) >= 3]
|
|
139
|
+
|
|
140
|
+
|
|
119
141
|
def _cycle_record(cycle: dict[str, Any], depth: int) -> dict[str, Any]:
|
|
120
142
|
"""A `cycle` finding. Gating, because unlike an advisory up-edge an import cycle is a
|
|
121
143
|
source-confirmed structural fact — and no declared order can be satisfied until it is broken.
|
|
@@ -135,6 +157,40 @@ def _cycle_record(cycle: dict[str, Any], depth: int) -> dict[str, Any]:
|
|
|
135
157
|
edge_source="cycle", confirmed_by=["imports"], depth=depth)
|
|
136
158
|
|
|
137
159
|
|
|
160
|
+
_TRUNCATED_CYCLE_REASON = ("only allowlisted edges hold this cycle together (between members "
|
|
161
|
+
"not listed here)")
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def _allowed_cycle_breaker(cycle: dict[str, Any], cycles: list[dict[str, Any]],
|
|
165
|
+
remaining: list[dict[str, Any]],
|
|
166
|
+
allowed: dict[tuple[str, str], dict[str, Any]]) -> dict[str, Any] | None:
|
|
167
|
+
"""The allowlist entry whose edge breaks this cycle, or ``None`` when the cycle stays gating.
|
|
168
|
+
|
|
169
|
+
Removing edges only splits a strongly connected component, so every cycle left after removing the
|
|
170
|
+
allowlisted relations lies inside one of the original cycles. This one is allowed when none of
|
|
171
|
+
the remaining cycles shares a member with it. `members` is capped, so a remaining cycle that
|
|
172
|
+
shares a member with no original cycle's listed members could lie in any truncated one: then
|
|
173
|
+
every truncated cycle stays gating rather than being excused on a guess.
|
|
174
|
+
"""
|
|
175
|
+
if not allowed:
|
|
176
|
+
return None
|
|
177
|
+
members = set(cycle.get("members") or [])
|
|
178
|
+
if any(members & set(r.get("members") or []) for r in remaining):
|
|
179
|
+
return None
|
|
180
|
+
if cycle.get("members_omitted"):
|
|
181
|
+
listed = [set(c.get("members") or []) for c in cycles]
|
|
182
|
+
if any(not any(set(r.get("members") or []) & m for m in listed) for r in remaining):
|
|
183
|
+
return None
|
|
184
|
+
# The cycle vanished, so an allowed relation lies inside it. With `members` capped it may join
|
|
185
|
+
# two unlisted members: then no one entry can be named, and quoting some other entry's reason
|
|
186
|
+
# would misattribute it, so the cycle is allowed under a generic reason and no index.
|
|
187
|
+
ordered = sorted(allowed.items())
|
|
188
|
+
inside = [entry for (a, b), entry in ordered if a in members and b in members]
|
|
189
|
+
if inside:
|
|
190
|
+
return inside[0]
|
|
191
|
+
return {"reason": _TRUNCATED_CYCLE_REASON, "index": None}
|
|
192
|
+
|
|
193
|
+
|
|
138
194
|
def check_layers(payload: dict, parsed: dict[str, Any]) -> dict[str, Any]:
|
|
139
195
|
"""Compute every §5.2 finding class for one payload against one declared config. Never raises.
|
|
140
196
|
|
|
@@ -181,6 +237,8 @@ def check_layers(payload: dict, parsed: dict[str, Any]) -> dict[str, Any]:
|
|
|
181
237
|
findings: list[dict[str, Any]] = []
|
|
182
238
|
allow_entries: list[dict[str, Any]] = list(parsed.get("allow") or [])
|
|
183
239
|
allow_used: set[int] = set()
|
|
240
|
+
# Element pairs whose violation the allowlist fully excused, with the entry that did it.
|
|
241
|
+
allowed_relations: dict[tuple[str, str], dict[str, Any]] = {}
|
|
184
242
|
|
|
185
243
|
# ── allowlist hygiene: an entry with no reason is a GATING finding ─────────────────────────────
|
|
186
244
|
# The single rule that separates an allowlist from a mute button. Reported before any violation so
|
|
@@ -249,11 +307,36 @@ def check_layers(payload: dict, parsed: dict[str, Any]) -> dict[str, Any]:
|
|
|
249
307
|
|
|
250
308
|
from_paths = paths_of.get(a, [])
|
|
251
309
|
to_paths = paths_of.get(b, [])
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
310
|
+
reasoned = [e for e in allow_entries if e.get("reason")]
|
|
311
|
+
file_edges = _file_edges(rel)
|
|
312
|
+
if file_edges:
|
|
313
|
+
# Matched per file edge, so the result does not depend on the depth (ticket 14). An entry
|
|
314
|
+
# naming both element ids still allows the whole relation. The violation is allowed only
|
|
315
|
+
# when every file edge is; one unmatched edge keeps it gating and becomes its witness.
|
|
316
|
+
by_ids = [e for e in reasoned if e.get("from") == a and e.get("to") == b]
|
|
317
|
+
allow_used.update(e["index"] for e in by_ids)
|
|
318
|
+
first_allow: list[dict[str, Any] | None] = []
|
|
319
|
+
for from_file, to_file, _n in file_edges:
|
|
320
|
+
hits = by_ids + [e for e in reasoned if e not in by_ids
|
|
321
|
+
and _match_allow_file(e, from_file, to_file)]
|
|
322
|
+
allow_used.update(e["index"] for e in hits)
|
|
323
|
+
first_allow.append(min(hits, key=lambda e: e["index"]) if hits else None)
|
|
324
|
+
unmatched = [edge for edge, hit in zip(file_edges, first_allow, strict=True) if hit is None]
|
|
325
|
+
allowed_by = (None if unmatched
|
|
326
|
+
else min((h for h in first_allow if h is not None),
|
|
327
|
+
key=lambda e: e["index"]))
|
|
328
|
+
shown = (unmatched or file_edges)[0]
|
|
329
|
+
witness = {"from": shown[0], "to": shown[1], "n": shown[2]}
|
|
330
|
+
witnesses_total = len(file_edges)
|
|
331
|
+
else:
|
|
332
|
+
allowed_by = next((e for e in reasoned
|
|
333
|
+
if _match_allow(e, from_paths, to_paths, a, b)), None)
|
|
334
|
+
if allowed_by is not None:
|
|
335
|
+
allow_used.add(allowed_by["index"])
|
|
336
|
+
witness = _witness(from_paths, to_paths, weight)
|
|
337
|
+
witnesses_total = max(1, len(from_paths) * len(to_paths))
|
|
255
338
|
if allowed_by is not None:
|
|
256
|
-
|
|
339
|
+
allowed_relations[(a, b)] = allowed_by
|
|
257
340
|
|
|
258
341
|
findings.append(_record(
|
|
259
342
|
rule=RULE_ORDER, kind="violation",
|
|
@@ -261,8 +344,7 @@ def check_layers(payload: dict, parsed: dict[str, Any]) -> dict[str, Any]:
|
|
|
261
344
|
message=message,
|
|
262
345
|
from_element=a, to_element=b,
|
|
263
346
|
from_paths=from_paths[:PATHS_REPORT_CAP], to_paths=to_paths[:PATHS_REPORT_CAP],
|
|
264
|
-
witness=
|
|
265
|
-
witnesses_total=max(1, len(from_paths) * len(to_paths)), weight=weight,
|
|
347
|
+
witness=witness, witnesses_total=witnesses_total, weight=weight,
|
|
266
348
|
from_layer=layer_of[a], from_layer_index=from_index,
|
|
267
349
|
to_layer=layer_of[b], to_layer_index=to_index,
|
|
268
350
|
direction=direction, layers_skipped=skipped,
|
|
@@ -272,7 +354,21 @@ def check_layers(payload: dict, parsed: dict[str, Any]) -> dict[str, Any]:
|
|
|
272
354
|
allow_index=(allowed_by or {}).get("index"), depth=depth))
|
|
273
355
|
|
|
274
356
|
# ── cycles: source-confirmed structural facts, so they gate (§5.2) ─────────────────────────────
|
|
275
|
-
|
|
357
|
+
# A cycle that disappears once the fully allowlisted relations are removed exists only through
|
|
358
|
+
# allowlisted edges: it stays visible, demoted to info like the violation that allowed it.
|
|
359
|
+
cycles = list(inferred.get("cycles") or [])
|
|
360
|
+
remaining: list[dict[str, Any]] = []
|
|
361
|
+
if cycles and allowed_relations:
|
|
362
|
+
kept = [r for r in relations
|
|
363
|
+
if (str(r.get("from") or ""), str(r.get("to") or "")) not in allowed_relations]
|
|
364
|
+
remaining = list(compute_layers(elements, kept).get("cycles") or [])
|
|
365
|
+
for cycle in cycles:
|
|
366
|
+
record = _cycle_record(cycle, depth)
|
|
367
|
+
breaker = _allowed_cycle_breaker(cycle, cycles, remaining, allowed_relations)
|
|
368
|
+
if breaker is not None:
|
|
369
|
+
record.update(severity="info", allowlisted=True,
|
|
370
|
+
allow_reason=breaker.get("reason"), allow_index=breaker.get("index"))
|
|
371
|
+
findings.append(record)
|
|
276
372
|
|
|
277
373
|
# ── unassigned: gating only under require_all (§3.5) ──────────────────────────────────────────
|
|
278
374
|
require_all = switches.get("require_all", False)
|
|
@@ -403,6 +499,7 @@ def render_report(payload: dict, check: dict[str, Any]) -> str:
|
|
|
403
499
|
lines.append(f"CYCLES ({len(cycles)})")
|
|
404
500
|
lines += [f" {finding['rule']} {finding['weight']} elements: "
|
|
405
501
|
f"{', '.join(finding['cycle_members'] or [])}"
|
|
502
|
+
+ (f" ALLOWED: {finding['allow_reason']}" if finding["allowlisted"] else "")
|
|
406
503
|
for finding in cycles]
|
|
407
504
|
|
|
408
505
|
for kind, heading in (("unassigned", "UNASSIGNED"), ("split", "SPLIT"),
|
|
@@ -45,7 +45,7 @@ from typing import Any
|
|
|
45
45
|
# correct and there is no fixed point to iterate to.
|
|
46
46
|
#
|
|
47
47
|
# What `unassigned` does NOT mean is "unrelated", and the distinction cost a wrong line of output
|
|
48
|
-
# before it was caught. `IMPORTS` is MODULE-LEVEL only: `src/codeintel/doctor.py` has seven
|
|
48
|
+
# before it was caught. `IMPORTS` is MODULE-LEVEL only: `src/codeintel/setup/doctor.py` has seven
|
|
49
49
|
# `codeintel` imports and every one is inside a function, so it has zero IMPORTS edges while being
|
|
50
50
|
# heavily coupled. Zero degree here is a fact about the edge source, not about the architecture,
|
|
51
51
|
# and anything rendering this set must say so.
|
|
@@ -467,7 +467,7 @@ def _specificity(pattern: str) -> tuple[int, int]:
|
|
|
467
467
|
"""How specific a pattern is: (literal segments before the first wildcard, pattern length).
|
|
468
468
|
|
|
469
469
|
Most-specific-wins is what lets ``core = ["src/codeintel/*.py"]`` act as a catch-all while
|
|
470
|
-
``gateway = ["src/codeintel/gateway.py"]`` still claims its own file, with no obligation on the
|
|
470
|
+
``gateway = ["src/codeintel/gateway/gateway.py"]`` still claims its own file, with no obligation on the
|
|
471
471
|
author to list specific patterns before general ones. First-match-in-order would also work, but
|
|
472
472
|
only if authors happen to get the ordering right, and getting it wrong is invisible.
|
|
473
473
|
"""
|
codeintel/{c4.py → c4/model.py}
RENAMED
|
@@ -39,7 +39,7 @@ import os
|
|
|
39
39
|
from datetime import UTC, datetime
|
|
40
40
|
from typing import Any
|
|
41
41
|
|
|
42
|
-
from codeintel.provider import log_swallowed
|
|
42
|
+
from codeintel.core.provider import log_swallowed
|
|
43
43
|
|
|
44
44
|
VIEW_ELEMENT_CAP = 100 # measured: 200 elems -> 113s, 300 -> did not finish
|
|
45
45
|
MAX_DEPTH = 8 # fit search ceiling; beyond it every element is a file
|
|
@@ -466,7 +466,7 @@ def index_repo(project_root: Any, *, timeout_ms: int = INDEX_TIMEOUT_MS) -> dict
|
|
|
466
466
|
sent one fix looking in the wrong place.
|
|
467
467
|
"""
|
|
468
468
|
try:
|
|
469
|
-
from codeintel.
|
|
469
|
+
from codeintel.engines.graph.provider import GraphProvider
|
|
470
470
|
|
|
471
471
|
p = GraphProvider()
|
|
472
472
|
if not getattr(p, "available", False):
|
|
@@ -495,8 +495,8 @@ def build_c4_payload(project_root: Any, *, depth: int | None = None, scope: tupl
|
|
|
495
495
|
payload at an auto-fit (or requested) directory depth. Never raises -- returns a flat `reason`
|
|
496
496
|
string and empty lists on any failure."""
|
|
497
497
|
try:
|
|
498
|
-
from codeintel.
|
|
499
|
-
from codeintel.
|
|
498
|
+
from codeintel.engines.graph.provider import GraphProvider
|
|
499
|
+
from codeintel.engines.graph.render import _repo_display_name
|
|
500
500
|
|
|
501
501
|
p = GraphProvider()
|
|
502
502
|
if not getattr(p, "available", False):
|
|
@@ -597,6 +597,9 @@ def build_c4_payload(project_root: Any, *, depth: int | None = None, scope: tupl
|
|
|
597
597
|
# references to a single fabricated import edge.
|
|
598
598
|
rel_weights: dict[tuple, dict[str, int]] = {}
|
|
599
599
|
rel_sources: dict[tuple, set] = {}
|
|
600
|
+
# The IMPORTS file pairs behind each element pair, so `--check` can match `[[layers.allow]]`
|
|
601
|
+
# against files rather than against element paths that move with the auto-fit depth.
|
|
602
|
+
rel_import_files: dict[tuple, dict[tuple[str, str], int]] = {}
|
|
600
603
|
dropped: list[dict] = []
|
|
601
604
|
internal_by_elem: dict[str, int] = {}
|
|
602
605
|
edges_internal = 0
|
|
@@ -634,6 +637,9 @@ def build_c4_payload(project_root: Any, *, depth: int | None = None, scope: tupl
|
|
|
634
637
|
per_source = rel_weights.setdefault(pair, {})
|
|
635
638
|
per_source[source] = per_source.get(source, 0) + n
|
|
636
639
|
rel_sources.setdefault(pair, set()).add(source)
|
|
640
|
+
if source == "imports":
|
|
641
|
+
files = rel_import_files.setdefault(pair, {})
|
|
642
|
+
files[(a_fp, b_fp)] = files.get((a_fp, b_fp), 0) + n
|
|
637
643
|
|
|
638
644
|
# `imports` when an IMPORTS edge contributed at all (literally true even if CALLS|USAGE also
|
|
639
645
|
# confirmed it); `calls_usage` only when IMPORTS never saw this pair — never the reverse, so
|
|
@@ -652,7 +658,9 @@ def build_c4_payload(project_root: Any, *, depth: int | None = None, scope: tupl
|
|
|
652
658
|
"n": sum(w.get(src, 0) for src in counted),
|
|
653
659
|
"n_imports": w.get("imports", 0),
|
|
654
660
|
"n_calls_usage": w.get("calls_usage", 0),
|
|
655
|
-
"kind": "imports" if "imports" in rel_sources[(a, b)] else "calls_usage"
|
|
661
|
+
"kind": "imports" if "imports" in rel_sources[(a, b)] else "calls_usage",
|
|
662
|
+
"import_files": [[fa, fb, k] for (fa, fb), k
|
|
663
|
+
in sorted(rel_import_files.get((a, b), {}).items())]}
|
|
656
664
|
for (a, b), w in rel_weights.items()
|
|
657
665
|
]
|
|
658
666
|
edges_from_imports_only = sum(1 for s in rel_sources.values() if s == {"imports"})
|
|
@@ -773,14 +781,14 @@ def build_c4_payload(project_root: Any, *, depth: int | None = None, scope: tupl
|
|
|
773
781
|
# and relations already in hand, no extra query. Gating it behind `--layers` would mean the
|
|
774
782
|
# flag changes what the payload CONTAINS rather than what the CLI prints, and `--json`
|
|
775
783
|
# consumers would then see a different shape depending on an unrelated flag.
|
|
776
|
-
from codeintel.
|
|
784
|
+
from codeintel.c4.layers import compute_layers
|
|
777
785
|
|
|
778
786
|
try:
|
|
779
787
|
layers = compute_layers(elements, relations)
|
|
780
788
|
except Exception as exc:
|
|
781
789
|
# Never lose a whole model for a derived section — the same rule churn follows above.
|
|
782
790
|
log_swallowed("c4.build_c4_payload.layers", exc)
|
|
783
|
-
from codeintel.
|
|
791
|
+
from codeintel.c4.layers import empty_layers
|
|
784
792
|
|
|
785
793
|
layers = empty_layers()
|
|
786
794
|
|
|
@@ -789,13 +797,13 @@ def build_c4_payload(project_root: Any, *, depth: int | None = None, scope: tupl
|
|
|
789
797
|
# the code path that prints a report. `config.py` preserves the unknown `[layers]` key
|
|
790
798
|
# already, so this needs no change there — but it arrives unvalidated, which is why
|
|
791
799
|
# `parse_layers_config` exists.
|
|
792
|
-
from codeintel.
|
|
793
|
-
from codeintel.
|
|
800
|
+
from codeintel.c4.check import check_layers
|
|
801
|
+
from codeintel.c4.layers import parse_layers_config
|
|
794
802
|
|
|
795
803
|
findings: list[dict[str, Any]] = []
|
|
796
804
|
declared: dict[str, Any] = {}
|
|
797
805
|
try:
|
|
798
|
-
from codeintel.config import load_config
|
|
806
|
+
from codeintel.core.config import load_config
|
|
799
807
|
|
|
800
808
|
parsed_layers = parse_layers_config(load_config(str(project_root or "")))
|
|
801
809
|
if parsed_layers.get("present"):
|
codeintel/{commands → cli}/c4.py
RENAMED
|
@@ -5,8 +5,8 @@ import os
|
|
|
5
5
|
import time
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
8
|
-
from codeintel import
|
|
9
|
-
from codeintel.
|
|
8
|
+
from codeintel.c4 import check as _c4_check
|
|
9
|
+
from codeintel.cli._common import never_raise, require_dir, resolve_root
|
|
10
10
|
|
|
11
11
|
_REASON_FIX = {
|
|
12
12
|
"engine-unavailable": "run `codeintel doctor` to check the graph backend",
|
|
@@ -37,7 +37,7 @@ def _settle(build: Any, payload: dict) -> dict:
|
|
|
37
37
|
raises — a clock or provider failure degrades to the payload already in hand.
|
|
38
38
|
"""
|
|
39
39
|
try:
|
|
40
|
-
from codeintel import c4
|
|
40
|
+
from codeintel.c4 import model as c4
|
|
41
41
|
|
|
42
42
|
deadline = time.monotonic() + SETTLE_SECONDS
|
|
43
43
|
while (payload.get("reason") or "") in c4.INDEXABLE_REASONS:
|
|
@@ -98,7 +98,7 @@ def _print_layers(payload: dict) -> None:
|
|
|
98
98
|
"""Print the inferred layer bands, top to bottom, plus cycles and what was left out.
|
|
99
99
|
|
|
100
100
|
Elements are named by their ELEMENT ID, not their title. Titles collide — this repo alone has two
|
|
101
|
-
elements titled `c4` (`src/codeintel/c4.py` and `src/codeintel/
|
|
101
|
+
elements titled `c4` (`src/codeintel/c4/model.py` and `src/codeintel/cli/c4.py`) and two titled
|
|
102
102
|
`graph`, sitting in different bands. A first draft of this function printed titles, and the output
|
|
103
103
|
showed `c4` twice in one band and `graph` in two, which reads as a bug in the ranking rather than
|
|
104
104
|
an ambiguity in the label. A shared prefix is trimmed once, and named, to keep ids readable.
|
|
@@ -113,7 +113,7 @@ def _print_layers(payload: dict) -> None:
|
|
|
113
113
|
problems" would be the absence of an opinion dressed as a clean bill of health.
|
|
114
114
|
* **An excluded element is not known to be unrelated.** This is the correction that matters most:
|
|
115
115
|
`unassigned` means "no MODULE-LEVEL import edge either way", and that is not the same fact.
|
|
116
|
-
`src/codeintel/doctor.py` has seven `codeintel` imports, every one of them inside a function,
|
|
116
|
+
`src/codeintel/setup/doctor.py` has seven `codeintel` imports, every one of them inside a function,
|
|
117
117
|
so `IMPORTS` sees none of them — it is heavily related and completely invisible here. An earlier
|
|
118
118
|
draft of this line called such elements "unrelated rather than foundational", which was a claim
|
|
119
119
|
about the world the edge source cannot support.
|
|
@@ -211,7 +211,7 @@ def _run_check(payload: dict, declared: dict, wants: str) -> int:
|
|
|
211
211
|
# success to any CI step gating on $? while nothing was produced — same reasoning as graph.py.
|
|
212
212
|
@never_raise("c4 failed: {exc}", code=1)
|
|
213
213
|
def run(args: Any) -> int:
|
|
214
|
-
from codeintel import c4
|
|
214
|
+
from codeintel.c4 import model as c4
|
|
215
215
|
|
|
216
216
|
project_root = resolve_root(args)
|
|
217
217
|
problem = require_dir(project_root, "c4")
|
|
@@ -283,7 +283,7 @@ def run(args: Any) -> int:
|
|
|
283
283
|
# emits TOML meant to be redirected into a file, so it must never share stdout with a progress
|
|
284
284
|
# line — hence it returns before the writing path rather than decorating it.
|
|
285
285
|
if getattr(args, "suggest_config", False):
|
|
286
|
-
from codeintel.
|
|
286
|
+
from codeintel.c4.layers import suggest_config
|
|
287
287
|
|
|
288
288
|
layers = payload.get("layers") or {}
|
|
289
289
|
print(suggest_config(layers.get("ranks") or {}, payload.get("elements") or []),
|