cortex-kg 0.3.0__tar.gz → 0.3.2__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 (140) hide show
  1. {cortex_kg-0.3.0/src/cortex_kg.egg-info → cortex_kg-0.3.2}/PKG-INFO +1 -1
  2. cortex_kg-0.3.2/docs/cortex-vs-graphify-replacement-rating.md +257 -0
  3. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/cursor.md +36 -19
  4. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/project-workflow.md +37 -0
  5. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/templates/cortex-agent-rule.mdc +6 -0
  6. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/templates/cortex-mcp.json +3 -1
  7. cortex_kg-0.3.2/examples/sample_repo/README.md +6 -0
  8. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/pyproject.toml +1 -1
  9. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/__init__.py +1 -1
  10. cortex_kg-0.3.2/src/cortex/__main__.py +6 -0
  11. cortex_kg-0.3.2/src/cortex/analysis/__init__.py +1 -0
  12. cortex_kg-0.3.2/src/cortex/analysis/flows.py +129 -0
  13. cortex_kg-0.3.2/src/cortex/analysis/hubs.py +132 -0
  14. cortex_kg-0.3.2/src/cortex/analysis/orientation.py +82 -0
  15. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/api/graph_viz.py +97 -5
  16. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/api/rest.py +404 -18
  17. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/api/workspace_viz.py +132 -0
  18. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/api_client.py +39 -0
  19. cortex_kg-0.3.2/src/cortex/bench/__init__.py +1 -0
  20. cortex_kg-0.3.2/src/cortex/bench/graphify_parity.py +161 -0
  21. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/cli.py +407 -32
  22. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/context/generator.py +98 -6
  23. cortex_kg-0.3.2/src/cortex/doctor.py +206 -0
  24. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/extractors/base.py +3 -1
  25. cortex_kg-0.3.2/src/cortex/extractors/code_extractor.py +697 -0
  26. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/extractors/markdown_extractor.py +54 -3
  27. cortex_kg-0.3.2/src/cortex/extractors/module_resolver.py +239 -0
  28. cortex_kg-0.3.2/src/cortex/ingestion/ignore.py +213 -0
  29. cortex_kg-0.3.2/src/cortex/ingestion/pipeline.py +571 -0
  30. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/ingestion/resolver.py +104 -3
  31. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/mcp_server/server.py +387 -41
  32. cortex_kg-0.3.2/src/cortex/mcp_server/workspace_ctx.py +60 -0
  33. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/models.py +7 -0
  34. cortex_kg-0.3.2/src/cortex/retrieval/planner.py +78 -0
  35. cortex_kg-0.3.2/src/cortex/retrieval/query_engine.py +450 -0
  36. cortex_kg-0.3.2/src/cortex/retrieval/traversal.py +147 -0
  37. cortex_kg-0.3.2/src/cortex/review/pack.py +341 -0
  38. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/server_profile/neo4j_store.py +31 -1
  39. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/setup/generators.py +75 -32
  40. cortex_kg-0.3.0/src/cortex/static/brain/assets/index-ChFJ4Pm_.css → cortex_kg-0.3.2/src/cortex/static/brain/assets/index-CrChQ736.css +1 -1
  41. cortex_kg-0.3.2/src/cortex/static/brain/assets/index-CupNnt97.js +488 -0
  42. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/static/brain/index.html +2 -2
  43. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/storage/graph_store.py +40 -3
  44. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/storage/provenance.py +136 -0
  45. cortex_kg-0.3.2/src/cortex/sync/watch_manager.py +115 -0
  46. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/sync/watcher.py +3 -1
  47. {cortex_kg-0.3.0 → cortex_kg-0.3.2/src/cortex_kg.egg-info}/PKG-INFO +1 -1
  48. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex_kg.egg-info/SOURCES.txt +16 -2
  49. cortex_kg-0.3.0/src/cortex/extractors/code_extractor.py +0 -262
  50. cortex_kg-0.3.0/src/cortex/ingestion/pipeline.py +0 -268
  51. cortex_kg-0.3.0/src/cortex/retrieval/planner.py +0 -49
  52. cortex_kg-0.3.0/src/cortex/retrieval/query_engine.py +0 -243
  53. cortex_kg-0.3.0/src/cortex/retrieval/traversal.py +0 -47
  54. cortex_kg-0.3.0/src/cortex/review/pack.py +0 -141
  55. cortex_kg-0.3.0/src/cortex/static/brain/assets/index-DBshxnnz.js +0 -486
  56. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/LICENSE +0 -0
  57. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/MANIFEST.in +0 -0
  58. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/README.md +0 -0
  59. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/README.md +0 -0
  60. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/automation.md +0 -0
  61. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/benchmarks/graphify-vs-cortex-2026-07-25-post.json +0 -0
  62. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/benchmarks/graphify-vs-cortex-2026-07-25-rerun.json +0 -0
  63. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/benchmarks/graphify-vs-cortex-2026-07-25.json +0 -0
  64. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/benchmarks/graphify-vs-cortex-2026-07-25.md +0 -0
  65. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/cortex-brain.md +0 -0
  66. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/installation.md +0 -0
  67. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/other-platforms.md +0 -0
  68. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/docs/publishing.md +0 -0
  69. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/examples/sample_repo/api/openapi.yaml +0 -0
  70. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/examples/sample_repo/docs/adr-001-session-tokens.md +0 -0
  71. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/examples/sample_repo/docs/architecture.md +0 -0
  72. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/examples/sample_repo/notes/meeting-2026-07-10-billing-sync.md +0 -0
  73. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/examples/sample_repo/schema/schema.sql +0 -0
  74. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/examples/sample_repo/src/auth_service.py +0 -0
  75. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/examples/sample_repo/src/billing_service.py +0 -0
  76. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/scripts/build_brain_ui.sh +0 -0
  77. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/sdk/python/cortex_sdk/__init__.py +0 -0
  78. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/sdk/python/pyproject.toml +0 -0
  79. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/sdk/typescript/package.json +0 -0
  80. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/sdk/typescript/src/index.ts +0 -0
  81. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/sdk/typescript/tsconfig.json +0 -0
  82. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/setup.cfg +0 -0
  83. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/agents/__init__.py +0 -0
  84. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/agents/hooks.py +0 -0
  85. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/agents/writeback.py +0 -0
  86. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/api/__init__.py +0 -0
  87. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/config.py +0 -0
  88. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/context/__init__.py +0 -0
  89. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/daemon.py +0 -0
  90. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/evidence.py +0 -0
  91. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/export/__init__.py +0 -0
  92. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/export/studio.py +0 -0
  93. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/extractors/__init__.py +0 -0
  94. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/extractors/api_spec_extractor.py +0 -0
  95. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/extractors/db_schema_extractor.py +0 -0
  96. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/extractors/git_extractor.py +0 -0
  97. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/extractors/image_extractor.py +0 -0
  98. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/extractors/llm_relation_extractor.py +0 -0
  99. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/extractors/notes_extractor.py +0 -0
  100. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/extractors/pdf_extractor.py +0 -0
  101. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/ingestion/__init__.py +0 -0
  102. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/ingestion/content_hash.py +0 -0
  103. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/mcp_server/__init__.py +0 -0
  104. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/offline/__init__.py +0 -0
  105. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/offline/local_llm.py +0 -0
  106. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/ontology/__init__.py +0 -0
  107. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/ontology/registry.py +0 -0
  108. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/plugins/__init__.py +0 -0
  109. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/plugins/examples/jira_like_plugin/plugin.py +0 -0
  110. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/plugins/interface.py +0 -0
  111. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/plugins/loader.py +0 -0
  112. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/project_binding.py +0 -0
  113. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/replication/__init__.py +0 -0
  114. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/replication/crdt.py +0 -0
  115. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/retrieval/__init__.py +0 -0
  116. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/retrieval/embeddings.py +0 -0
  117. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/retrieval/fusion.py +0 -0
  118. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/review/__init__.py +0 -0
  119. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/security/__init__.py +0 -0
  120. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/security/acl.py +0 -0
  121. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/security/audit.py +0 -0
  122. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/security/encryption.py +0 -0
  123. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/security/secrets_scanner.py +0 -0
  124. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/server_profile/__init__.py +0 -0
  125. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/setup/__init__.py +0 -0
  126. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/storage/__init__.py +0 -0
  127. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/storage/keyword_store.py +0 -0
  128. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/storage/vector_store.py +0 -0
  129. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/sync/__init__.py +0 -0
  130. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/sync/change_feed.py +0 -0
  131. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/sync/job_queue.py +0 -0
  132. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/versioning/__init__.py +0 -0
  133. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/versioning/bitemporal.py +0 -0
  134. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/workspace/__init__.py +0 -0
  135. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/workspace/federation.py +0 -0
  136. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex/workspace/registry.py +0 -0
  137. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex_kg.egg-info/dependency_links.txt +0 -0
  138. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex_kg.egg-info/entry_points.txt +0 -0
  139. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex_kg.egg-info/requires.txt +0 -0
  140. {cortex_kg-0.3.0 → cortex_kg-0.3.2}/src/cortex_kg.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cortex-kg
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Cortex: a persistent, workspace-level Engineering Knowledge Graph.
5
5
  Author-email: Roshan Gamage <roshangamage01@users.noreply.github.com>
6
6
  License: MIT
@@ -0,0 +1,257 @@
1
+ # Cortex Replacement Readiness Rating
2
+ ## Goal: Can Cortex replace Graphify (with more features)?
3
+
4
+ **Date:** 2026-07-26 (updated same day after native code-graph ship)
5
+ **Corpus under test:** `lanwa-ceylon-steel-iforce`
6
+ **Cortex workspace tested:** `iforceHardware` (project `IforceSteel`)
7
+ **Graphify baseline:** `.graphify/` — 7,704 nodes / 11,399 edges (post `.graphifyignore`)
8
+ **Cortex graph:** 4,851 nodes / 10,079 edges · vectors ~1,150 / 4,851 (~24% embedded at test time)
9
+
10
+ > **Implementation note (2026-07-26):** Cortex now has a standalone native
11
+ > code-graph layer (`CodeFile` / `Function` / `Class` + `contains` / `imports` /
12
+ > `calls` / `extends`), impact file rollup, `review delta|analysis|commits`
13
+ > with explicit `--files`, hubs/communities/flows, `cortex orient` /
14
+ > `cortex doctor` / `cortex bench`. Re-ingest with `--force` is required for
15
+ > existing workspaces. Re-run `cortex bench` on iForce to refresh the scores
16
+ > below.
17
+
18
+ ---
19
+
20
+ ## Executive verdict
21
+
22
+ **Cortex cannot replace Graphify yet for this project's main Graphify jobs.**
23
+
24
+ | Question | Answer | Score |
25
+ |---|---|---|
26
+ | Can Cortex replace Graphify **today**? | **No** | **3.5 / 10** |
27
+ | Does Cortex already have **more features** than Graphify? | **Yes (broader surface)** | Feature breadth **8 / 10** |
28
+ | Is Cortex better than Graphify for **docs / architecture / agent orientation**? | **Yes** | **7.5 / 10** |
29
+ | Is Cortex better than Graphify for **code dependency / PR blast radius**? | **No — far behind** | **2 / 10** |
30
+ | Recommended posture | **Complement, don't replace** — until code-edge parity lands | — |
31
+
32
+ **Bottom line:** Cortex is already stronger as an *engineering knowledge + docs* brain. Graphify remains required for *AST import/call graphs* and reliable change impact. Replacing Graphify now would regress day-to-day coding/review workflows.
33
+
34
+ ---
35
+
36
+ ## Test environment notes (important)
37
+
38
+ These issues affected scores and must be fixed before re-rating:
39
+
40
+ 1. **MCP points at empty workspace**
41
+ `.cortex/project.json` → `workspace: "default"` (0 nodes).
42
+ Real ingest is in `iforceHardware` (4,851 nodes).
43
+ Cursor MCP `search_knowledge` against `default` returns nothing / disconnects.
44
+
45
+ 2. **Embeddings incomplete**
46
+ At test time: `vectors ≈ 1150`, `pending ≈ 3701`.
47
+ Hybrid search is mostly keyword until jobs finish; vector quality will improve.
48
+
49
+ 3. **No git root**
50
+ Workspace is not a git repo → Cortex `review/delta` returned 0 changed files.
51
+ Graphify `review-delta --files …` still works from explicit file lists.
52
+
53
+ 4. **Project summary is wrong**
54
+ `Project:IforceSteel` summary was taken from Android `README.md` UI/UX rules, not `AGENTS.md` / `docs/PROJECT_OVERVIEW.md`.
55
+
56
+ 5. **Ingest noise**
57
+ Terminal ingest scanned uploads/images and `graphify-studio` assets. Need `.cortexignore`.
58
+
59
+ ---
60
+
61
+ ## Benchmark results (same tasks as Graphify evaluation)
62
+
63
+ ### A. Product / overview orientation
64
+
65
+ | Test | Cortex result | Graphify result | Winner |
66
+ |---|---|---|---|
67
+ | Naive: “What is the Lanwa Ceylon Steel iForce project?” | `PROJECT_OVERVIEW.md` appears at **#7**; top hits are thermal print / Android audit / UI rules. `get_context` opens with wrong Project summary (Android README). | Returns PDF/test/code nodes — no product definition. | **Cortex** (weak win) |
68
+ | Targeted: “AGENTS.md Overview iForce multi-tenant SFA MERN” | **#1 AGENTS.md** + Integration Module + PROJECT_OVERVIEW. Context returns correct MERN/SFA definition + ports. | Still no AGENTS.md node. | **Cortex** |
69
+ | Customer/vendor: “Lanwa Ceylon Steel Prologics” | Hits `customersSnapshot`, ProjectCustomer pages — **no customer entity**. | Same class of miss. | Tie (both fail) |
70
+
71
+ **Overview score:** Cortex **6/10** · Graphify **2/10**
72
+
73
+ ---
74
+
75
+ ### B. Graphify-parity: code graph & impact (the replacement blocker)
76
+
77
+ | Test | Cortex result | Graphify result | Winner |
78
+ |---|---|---|---|
79
+ | Find `checkPermission` | Finds Concept in `rbac.js` | Hub node, degree 40 | Tie / Graphify clearer as hub |
80
+ | Neighbors of `checkPermission` | Only `depends_on → fs/path` + `consumes ← Project` | Imports/calls across routes | **Graphify** |
81
+ | Path `checkPermission` → SFA route symbol | Path exists but goes **through Project hub** (star topology), not real import chain | Real 2-hop: `checkPermission → rbac.js → sfa.routes.js` | **Graphify** |
82
+ | Impact of changing `checkPermission` | `affected: []` | `review-delta`: 53 nodes / 48 files | **Graphify** |
83
+ | Find integration UI code | Mixed docs + headings; weaker file localization | Precise JSX/API nodes | **Graphify** |
84
+ | `applyScope` neighbors | Only `mongoose` + Project | Degree-29 hub in reports | **Graphify** |
85
+
86
+ **Code-graph / blast-radius score:** Cortex **2/10** · Graphify **9/10**
87
+
88
+ #### Why Cortex fails here
89
+
90
+ Edge inventory in `iforceHardware`:
91
+
92
+ | Edge type | Count | Meaning for replacement |
93
+ |---|---|---|
94
+ | `consumes` | 4850 | Almost everything → Project (star hub) |
95
+ | `depends_on` | 4252 | Mostly library/tech deps, not file→file imports |
96
+ | `documents` | 853 | Doc → heading concepts |
97
+ | `references` | 124 | Doc cross-links |
98
+
99
+ **Missing vs Graphify:** `imports_from`, `imports`, `calls`, `contains` (file/symbol containment).
100
+ Without those, path/impact cannot match Graphify no matter how good search is.
101
+
102
+ ---
103
+
104
+ ### C. Where Cortex already has *more* than Graphify
105
+
106
+ | Capability | Cortex | Graphify | Notes |
107
+ |---|---|---|---|
108
+ | Markdown / doc indexing | Strong (143 Documents) | Weak (tracked but not queryable) | Cortex clear win |
109
+ | Typed ontology | 22 node types (Service, Model, Document, Decision…) | Flat code nodes | Cortex |
110
+ | Provenance excerpts | File + excerpt on hits | File + line, no prose excerpt | Cortex |
111
+ | Agent context packing | `context` / `minimal-context` with token budgets | `query --budget`, `minimal-context` | Cortex richer for docs |
112
+ | Human curation | `add_note`, `link`, confirm/reject edges | Memory / wiki / add URL | Cortex better for decisions |
113
+ | Multi-workspace | First-class | Single graph.json | Cortex |
114
+ | Missing-docs detection | `/graph/missing-docs` | No equivalent | Cortex |
115
+ | Change feed / Brain UI | Yes (`8420`) | Studio static export | Cortex |
116
+ | MCP for Cursor | Native HTTP MCP | Optional `graphify serve` stdio | Cortex (when workspace bound) |
117
+ | Community / wiki / studio | Partial APIs | Mature CLI (`wiki`, `studio`, `label`) | Graphify |
118
+ | PR review tooling | `/review/delta` (weak here) | `review-delta`, `review-analysis`, `affected-flows`, `recommend-commits` | **Graphify far ahead** |
119
+ | Execution flows | No | `flows` / `affected-flows` | Graphify |
120
+
121
+ **Feature-breadth score (raw API/CLI surface):** Cortex **8/10** · Graphify **8.5/10**
122
+ Cortex wins on knowledge/ontology; Graphify wins on review/flow tooling depth.
123
+
124
+ ---
125
+
126
+ ## Capability scorecard (Cortex alone, this project)
127
+
128
+ | Capability | Score | Evidence |
129
+ |---|---|---|
130
+ | Ingest coverage | 6/10 | 4.8k nodes from 2.8k files; noisy (uploads, studio assets) |
131
+ | Doc retrieval | 8/10 | AGENTS, Integration, Dev Guide, Distributor README findable |
132
+ | Product overview (naive) | 5/10 | PROJECT_OVERVIEW at #7; Project summary wrong |
133
+ | Symbol find (by name) | 7/10 | `checkPermission`, `applyScope`, `authorize` found |
134
+ | Real code dependency graph | **2/10** | No import/call edges; star `consumes` |
135
+ | Path usefulness | **2/10** | Hub-mediated paths only |
136
+ | Impact / blast radius | **1/10** | Empty for `checkPermission`; review/delta empty without git |
137
+ | Architecture context | 8/10 | Multi-tenant laws, RBAC guides, integration docs |
138
+ | Agent MCP readiness | 3/10 | MCP bound to empty `default` |
139
+ | Embedding readiness | 4/10 | ~24% vectors at test time |
140
+ | Curation / notes | 8/10 | Supported; Project Overview note from prior session not in this workspace |
141
+ | Noise control | 3/10 | No `.cortexignore` yet; Project summary poisoned |
142
+ | **Overall for Graphify replacement** | **3.5/10** | |
143
+ | **Overall as Graphify complement** | **7.5/10** | |
144
+
145
+ ---
146
+
147
+ ## Replacement decision matrix
148
+
149
+ ```
150
+ Replace Graphify now?
151
+ ├── Need PR blast radius / import graphs / flows → NO (keep Graphify)
152
+ ├── Need docs + architecture agent context → Cortex already better
153
+ ├── Need both → Use BOTH (recommended)
154
+ └── Want single tool eventually → Only after Cortex gains
155
+ imports/calls/contains edges
156
+ + working impact/review-delta
157
+ ```
158
+
159
+ ### Minimum bar to say “Cortex can replace Graphify”
160
+
161
+ Must pass all of these on this repo:
162
+
163
+ 1. `checkPermission` inbound neighbors include route files that `require`/`import` `rbac.js` (≥20 real consumers).
164
+ 2. Path `checkPermission → sfa.routes.js` is import-based (not via Project hub).
165
+ 3. Impact/review-delta on `rbac.js` returns a file list in the same ballpark as Graphify (~40+ files).
166
+ 4. Naive “what is this project?” returns `PROJECT_OVERVIEW` / correct Project summary in top 3.
167
+ 5. MCP workspace matches the ingested workspace (stdio `--workspace` args, or URL `X-Cortex-Workspace` header — Cursor ignores URL `env`).
168
+ 6. Embeddings finished (`pending: 0`) or keyword-only quality is proven stable.
169
+
170
+ **Current pass rate:** 0 / 6.
171
+
172
+ ---
173
+
174
+ ## What Cortex must improve to replace Graphify
175
+
176
+ ### P0 — blockers
177
+
178
+ 1. ~~**Extract real code edges:** `imports` / `calls` / `contains` / `extends` (file↔symbol).~~ **Shipped** (`code_extractor` v2 + `module_resolver`).
179
+ 2. ~~**Fix Project summary selection** — prefer `AGENTS.md` / `docs/PROJECT_OVERVIEW.md`.~~ **Shipped**.
180
+ 3. **Bind MCP to `iforceHardware`** (or re-ingest into `default` and update `.cortex/project.json`) — use `cortex doctor`.
181
+ 4. ~~**Add `.cortexignore`**.~~ **Shipped** earlier.
182
+
183
+ ### P1 — parity with Graphify review suite
184
+
185
+ 5. ~~Make `/review/delta` work from explicit file lists.~~ **Shipped** (`--files` / MCP `files`).
186
+ 6. ~~Populate reverse `depends_on` / `calls` / `imports` so `explain_impact` is non-empty.~~ **Shipped** (+ `affected_files` rollup).
187
+ 7. Finish / prioritize embedding jobs — structural code nodes no longer enqueue embeds; `cortex doctor` reports pending.
188
+ 8. ~~Boost Document nodes over low-confidence heading Concepts for overview queries.~~ **Shipped** earlier.
189
+
190
+ ### P2 — “more features” that actually win the replacement story
191
+
192
+ 9. Curated Project Overview — `cortex orient` stamps overview + hubs + flows.
193
+ 10. ~~Community labels + wiki-like orientation export.~~ **Shipped** (`cortex orient`, `/orientation`, community persist).
194
+ 11. Cross-fork surprises — `/graph/surprises` + orientation section (needs re-ingest + community persist on iForce).
195
+
196
+ ---
197
+
198
+ ## Recommended team strategy
199
+
200
+ ### Now (keep both)
201
+
202
+ | Job | Tool |
203
+ |---|---|
204
+ | “What is this / how does X work?” | **Cortex** (`context`, docs) |
205
+ | “What imports this / what breaks?” | **Graphify** (`path`, `review-delta`) |
206
+ | Architecture decisions / meeting notes | **Cortex** (`add_note`, `link`) |
207
+ | PR review blast radius | **Graphify** |
208
+ | Agent default in Cursor | Cortex MCP **after** workspace fix |
209
+
210
+ ### Next 2 weeks (make Cortex replacement-capable)
211
+
212
+ 1. Fix workspace binding + `.cortexignore` + re-ingest.
213
+ 2. Ship/enable AST import-call extractor in Cortex (or import Graphify edges into Cortex).
214
+ 3. Re-run this rating checklist (section “Minimum bar”).
215
+ 4. Only then deprecate Graphify for this repo.
216
+
217
+ ### Pragmatic hybrid (fastest win)
218
+
219
+ Import Graphify’s EXTRACTED `imports_from` / `calls` edges into Cortex as `depends_on`/`implements`, keep Cortex as the single agent front-end. That can raise replacement readiness from **~3.5 → ~7** without waiting for a full Cortex AST rewrite.
220
+
221
+ ---
222
+
223
+ ## Appendix — key raw evidence
224
+
225
+ ### Cortex graph composition (`iforceHardware`)
226
+
227
+ - Nodes: Concept 3818 · UIComponent 809 · Document 143 · Technology 41 · Model 23 · Service 15 · Project 1
228
+ - Edges: consumes 4850 · depends_on 4252 · documents 853 · references 124
229
+
230
+ ### Graphify hubs (post-ignore)
231
+
232
+ 1. `checkPermission()` (40)
233
+ 2. `applyScope()` (29)
234
+ 3. `runAllMigrations()` (24)
235
+
236
+ ### Cortex `checkPermission` neighbors
237
+
238
+ - `depends_on` → `fs`, `path`
239
+ - `consumes` ← `IforceSteel`
240
+ - Impact: `affected: []`
241
+
242
+ ### Graphify `checkPermission` impact
243
+
244
+ - 53 impacted nodes · 48 impacted files across Lanwa + Pelwatte forks
245
+
246
+ ### Targeted Cortex win
247
+
248
+ `context("AGENTS.md Overview iForce multi-tenant SFA…")` returns:
249
+
250
+ > iForce is a multi-tenant SFA & Distribution Management SaaS platform (MERN stack)… API Server port 5000 · Web Client port 5173
251
+
252
+ Graphify cannot produce this without reading files outside the graph.
253
+
254
+ ---
255
+
256
+ **Prepared for:** Prologics / Lanwa Ceylon Steel iForce team
257
+ **Recommendation:** Do **not** replace Graphify yet. Treat Cortex as the docs/architecture layer; close the code-edge gap (P0) before any cutover.
@@ -5,18 +5,20 @@ Cursor talks to Cortex over **MCP** (Model Context Protocol). Once connected, th
5
5
  ## How it works
6
6
 
7
7
  ```
8
- Your repo ──ingest──▶ serve-api (owns Kuzu) ◀──MCP /mcp── Cursor Agent
9
- ▲
8
+ Your repo ──ingest──▶ serve-api (owns Kuzu) ◀──stdio proxy── Cursor Agent
9
+ ▲ (serve-mcp)
10
10
  └── Brain UI + CLI (HTTP)
11
11
  ```
12
12
 
13
13
  1. Start **`cortex up`** (detached `serve-api`; owns the DB; Brain + MCP + CLI share it).
14
14
  2. **Ingest** a project (CLI talks to the API when it is up).
15
- 3. Cursor connects to MCP at `http://127.0.0.1:8420/mcp` (or stdio proxy).
15
+ 3. Cursor spawns **stdio** `cortex --workspace <bound> serve-mcp` (proxies to the API when up).
16
16
  4. The agent calls tools like `search_knowledge`, `get_context`, `explain_impact`, `review_delta`.
17
17
 
18
18
  Cortex models **relationships**, not files. Ask “what depends on AuthService?” not “what’s in auth_service.py?”
19
19
 
20
+ **Important:** Cursor leaves newly written MCP servers **disabled** until you toggle them on under **Settings → Tools & MCP**. Setup can write the config and rule, but cannot flip that switch for you.
21
+
20
22
  ---
21
23
 
22
24
  ## Option A — Automated project setup (recommended)
@@ -24,13 +26,13 @@ Cortex models **relationships**, not files. Ask “what depends on AuthService?
24
26
  From your **project root**:
25
27
 
26
28
  ```bash
27
- # Long-lived API + Brain + MCP endpoint (idempotent)
29
+ # Long-lived API + Brain (idempotent)
28
30
  cortex up
29
31
 
30
32
  # Index the repo (uses the API when reachable)
31
33
  cortex ingest . --project MyApp
32
34
 
33
- # Write Cursor MCP config + agent rule + .cortex/project.json
35
+ # Write Cursor MCP (stdio) + agent rule + .cortex/project.json
34
36
  cortex setup project --write --project MyApp
35
37
  ```
36
38
 
@@ -38,11 +40,15 @@ This creates:
38
40
 
39
41
  | File | Purpose |
40
42
  |---|---|
41
- | `.cursor/mcp.json` | Points Cursor at `http://127.0.0.1:8420/mcp` |
43
+ | `.cursor/mcp.json` | Stdio `serve-mcp` with `--workspace` in args (`type: stdio`) |
42
44
  | `.cursor/rules/cortex.mdc` | Tells the agent **when and how** to use Cortex |
43
45
  | `.cortex/project.json` | Path-local workspace binding (so CLI needs no `--workspace`) |
44
46
 
45
- Keep the daemon up (`cortex status`). **Reload Cursor** so MCP picks up the new config.
47
+ Then:
48
+
49
+ 1. **Enable** the `cortex` server in Cursor → Settings → Tools & MCP.
50
+ 2. Keep the daemon up (`cortex status`).
51
+ 3. Reload the window if tools do not appear.
46
52
 
47
53
  ---
48
54
 
@@ -60,13 +66,15 @@ Or write project-level MCP config:
60
66
  cortex setup cursor --write --path /path/to/your/project
61
67
  ```
62
68
 
63
- Example `.cursor/mcp.json` (shared with Brain via `serve-api`):
69
+ Default `.cursor/mcp.json` (stdio; proxies to `serve-api` when healthy):
64
70
 
65
71
  ```json
66
72
  {
67
73
  "mcpServers": {
68
74
  "cortex": {
69
- "url": "http://127.0.0.1:8420/mcp",
75
+ "type": "stdio",
76
+ "command": "cortex",
77
+ "args": ["--workspace", "default", "serve-mcp"],
70
78
  "env": {
71
79
  "CORTEX_WORKSPACE": "default"
72
80
  }
@@ -75,14 +83,23 @@ Example `.cursor/mcp.json` (shared with Brain via `serve-api`):
75
83
  }
76
84
  ```
77
85
 
78
- Stdio fallback (proxies to the API when healthy, else opens Kuzu locally):
86
+ URL mode (optional; requires `serve-api` and a workspace **header** — Cursor ignores `env` for remote MCP):
87
+
88
+ ```bash
89
+ cortex setup project --write --via-api
90
+ ```
79
91
 
80
92
  ```json
81
93
  {
82
94
  "mcpServers": {
83
95
  "cortex": {
84
- "command": "cortex",
85
- "args": ["--workspace", "default", "serve-mcp"]
96
+ "url": "http://127.0.0.1:8420/mcp",
97
+ "headers": {
98
+ "X-Cortex-Workspace": "default"
99
+ },
100
+ "env": {
101
+ "CORTEX_WORKSPACE": "default"
102
+ }
86
103
  }
87
104
  }
88
105
  }
@@ -172,17 +189,17 @@ You can edit that rule file for team-specific conventions. A copy of the templat
172
189
 
173
190
  | Problem | Fix |
174
191
  |---|---|
175
- | MCP server not listed in Cursor | Reload window; check `.cursor/mcp.json` syntax; ensure `serve-api` is running for URL configs |
176
- | Workspace locked / 503 | One `serve-api` should own the DB; point MCP at `/mcp` or use stdio proxy |
192
+ | MCP listed but tools never run | **Enable** `cortex` under Settings → Tools & MCP (setup cannot auto-enable) |
193
+ | MCP server not listed in Cursor | Reload window; check `.cursor/mcp.json` has `"type": "stdio"`; ensure `cortex` is on PATH |
194
+ | Empty search / wrong graph | URL MCP without `X-Cortex-Workspace` hits serve-api’s process workspace. Prefer stdio setup, or re-run `cortex setup project --write --via-api`. Run `cortex doctor .` |
195
+ | Workspace locked / 503 | One `serve-api` should own the DB; stdio `serve-mcp` proxies to it |
177
196
  | Empty search results | Run `cortex ingest . --project MyApp` first (with API up) |
178
197
  | Stale knowledge | Re-run ingest or `cortex watch .` |
179
- | Wrong workspace | Match `--workspace` on `serve-api` / ingest and `CORTEX_WORKSPACE` in MCP env |
180
-
181
- Test while API is running:
198
+ | Wrong workspace | Match `--workspace` on `serve-api` / ingest and in mcp.json args / header |
182
199
 
183
200
  ```bash
184
- cortex --workspace default serve-api
185
- # another terminal:
201
+ cortex doctor .
202
+ cortex --workspace default up
186
203
  cortex search "AuthService"
187
204
  ```
188
205
 
@@ -50,6 +50,31 @@ cortex context "MyApp" --format markdown
50
50
 
51
51
  ---
52
52
 
53
+ ## Excluding paths with `.cortexignore`
54
+
55
+ Cortex already skips common noise (`.git`, `node_modules`, `.venv`, `dist`,
56
+ `build`, `vendor`, lockfiles, etc.) even with no config. For anything else
57
+ project-specific, drop a `.gitignore`-style `.cortexignore` at the repo root:
58
+
59
+ ```bash
60
+ cortex ignore init . # scaffold a starter file
61
+ ```
62
+
63
+ ```gitignore
64
+ # .cortexignore
65
+ generated/
66
+ *.snap
67
+ legacy/**/*.py
68
+ !legacy/keep-this/
69
+ ```
70
+
71
+ Supports comments, blank lines, `*`/`**`/`?`/`[...]` globs, trailing `/` for
72
+ directory-only matches, and `!` to re-include a path. Ignored directories are
73
+ pruned before Cortex walks into them, so a huge ignored tree (e.g. a
74
+ committed `vendor/` dump) costs nothing at ingest time.
75
+
76
+ ---
77
+
53
78
  ## Incremental updates
54
79
 
55
80
  Re-running ingest is cheap — unchanged files are skipped via content hashing:
@@ -128,6 +153,18 @@ cortex context "BillingService" --max-tokens 1500 --format markdown
128
153
  # Graph exploration
129
154
  cortex node get <node-id>
130
155
  cortex node traverse <node-id> --depth 2 --direction both
156
+
157
+ # Code-graph impact / PR review (no git required when --files is set)
158
+ cortex review delta --files src/middleware/rbac.js
159
+ cortex review analysis --files src/middleware/rbac.js
160
+ cortex review commits --staged
161
+
162
+ # Orientation report (overview + hubs + communities + flows)
163
+ cortex orient --format markdown
164
+
165
+ # Health + Graphify replacement scorecard
166
+ cortex doctor .
167
+ cortex bench
131
168
  ```
132
169
 
133
170
  ---
@@ -31,3 +31,9 @@ After significant decisions, discoveries, or meeting outcomes:
31
31
  ## Re-index after large changes
32
32
 
33
33
  If many files changed outside the agent session, remind the user to run ingest or enable watch.
34
+
35
+ ## Shared daemon
36
+
37
+ Keep `cortex up` / `serve-api` running so Brain, Cursor MCP (stdio `serve-mcp`), and CLI
38
+ share one process. After `cortex setup project --write`, enable the **cortex** server in
39
+ Cursor Settings → Tools & MCP (Cursor does not auto-enable new MCP servers).
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "mcpServers": {
3
3
  "cortex": {
4
- "url": "http://127.0.0.1:8420/mcp",
4
+ "type": "stdio",
5
+ "command": "python3",
6
+ "args": ["-m", "cortex", "--workspace", "default", "serve-mcp"],
5
7
  "env": {
6
8
  "CORTEX_PROJECT_ROOT": ".",
7
9
  "CORTEX_WORKSPACE": "default"
@@ -0,0 +1,6 @@
1
+ # SampleApp
2
+
3
+ SampleApp is a small demo billing platform used by Cortex tests.
4
+
5
+ It provides authentication (session tokens) and billing that charges users
6
+ via Stripe after AuthService identifies the current user.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cortex-kg"
7
- version = "0.3.0"
7
+ version = "0.3.2"
8
8
  description = "Cortex: a persistent, workspace-level Engineering Knowledge Graph."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -5,4 +5,4 @@ services, decisions, people, documents, ...) rather than files. Knowledge is
5
5
  owned by the workspace and outlives any single project.
6
6
  """
7
7
 
8
- __version__ = "0.3.0"
8
+ __version__ = "0.3.2"
@@ -0,0 +1,6 @@
1
+ """Allow ``python -m cortex`` (used by ``cortex up`` to spawn serve-api)."""
2
+
3
+ from cortex.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1 @@
1
+ """Graph analysis: hubs, communities, flows, orientation."""
@@ -0,0 +1,129 @@
1
+ """Execution flows: API entry points → handler symbols via transitive calls."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Optional
6
+
7
+ from cortex.models import Candidate, Edge, Node, Provenance
8
+
9
+
10
+ def _handler_for_api(daemon, api: Node) -> Optional[Node]:
11
+ """Find the symbol that implements this API (incoming implements)."""
12
+ for edge, neighbor in daemon.graph.neighbors(api.id, edge_types=["implements"], direction="in"):
13
+ return neighbor
14
+ return None
15
+
16
+
17
+ def derive_flows(daemon, *, max_depth: int = 4, limit: int = 200) -> dict[str, Any]:
18
+ """Walk API → implements → calls* and persist ``Flow`` nodes.
19
+
20
+ Returns a report of flows created/updated. Safe to re-run (upsert by
21
+ natural key ``Flow:<api_name>``).
22
+ """
23
+ apis = daemon.graph.list_nodes(type_="API", workspace_id=daemon.workspace_id, limit=limit)
24
+ created = 0
25
+ updated = 0
26
+ flows_out: list[dict] = []
27
+
28
+ for api in apis:
29
+ handler = _handler_for_api(daemon, api)
30
+ if not handler:
31
+ continue
32
+ # BFS along outgoing calls
33
+ chain: list[Node] = [handler]
34
+ frontier = [handler.id]
35
+ seen = {handler.id}
36
+ for _ in range(max_depth):
37
+ next_frontier: list[str] = []
38
+ for nid in frontier:
39
+ for edge, neighbor in daemon.graph.neighbors(
40
+ nid, edge_types=["calls"], direction="out",
41
+ ):
42
+ if neighbor.id in seen:
43
+ continue
44
+ seen.add(neighbor.id)
45
+ chain.append(neighbor)
46
+ next_frontier.append(neighbor.id)
47
+ frontier = next_frontier
48
+ if not frontier:
49
+ break
50
+
51
+ flow_name = api.canonical_name
52
+ natural_key = f"Flow:{flow_name}"
53
+ steps = [
54
+ {
55
+ "id": n.id,
56
+ "name": n.canonical_name,
57
+ "display": (n.properties or {}).get("display_name") or n.canonical_name,
58
+ "type": n.type,
59
+ }
60
+ for n in chain
61
+ ]
62
+ files = []
63
+ seen_f = set()
64
+ for n in chain:
65
+ p = (n.properties or {}).get("path")
66
+ if p and p not in seen_f:
67
+ seen_f.add(p)
68
+ files.append(p)
69
+
70
+ existing = daemon.graph.find_by_natural_key("Flow", flow_name, daemon.workspace_id)
71
+ props = {
72
+ "api": api.canonical_name,
73
+ "steps": steps,
74
+ "files": files,
75
+ "depth": len(chain),
76
+ "layer": "code",
77
+ }
78
+ if existing:
79
+ existing.properties.update(props)
80
+ daemon.graph.upsert_node(existing)
81
+ flow = existing
82
+ updated += 1
83
+ else:
84
+ flow = Node(
85
+ type="Flow",
86
+ canonical_name=flow_name,
87
+ properties=props,
88
+ workspace_id=daemon.workspace_id,
89
+ confidence=0.85,
90
+ )
91
+ daemon.graph.upsert_node(flow)
92
+ created += 1
93
+
94
+ # Link Flow → API and Flow → first handler
95
+ for to_id, etype in ((api.id, "implements"), (handler.id, "contains")):
96
+ daemon.graph.upsert_edge(Edge(
97
+ type=etype if etype != "contains" else "relates_to",
98
+ from_id=flow.id, to_id=to_id, confidence=0.9,
99
+ properties={"via": "flow"},
100
+ ))
101
+ flows_out.append({
102
+ "id": flow.id, "name": flow_name, "steps": len(chain), "files": files,
103
+ })
104
+
105
+ return {
106
+ "flows": flows_out,
107
+ "created": created,
108
+ "updated": updated,
109
+ "apis_scanned": len(apis),
110
+ }
111
+
112
+
113
+ def affected_flows(daemon, files: list[str]) -> dict[str, Any]:
114
+ """Return flows whose step files intersect ``files``."""
115
+ wanted = {f.replace("\\", "/") for f in files}
116
+ flows = daemon.graph.list_nodes(type_="Flow", workspace_id=daemon.workspace_id, limit=500)
117
+ hit = []
118
+ for flow in flows:
119
+ flow_files = set((flow.properties or {}).get("files") or [])
120
+ overlap = sorted(flow_files & wanted)
121
+ if overlap:
122
+ hit.append({
123
+ "id": flow.id,
124
+ "name": flow.canonical_name,
125
+ "overlap": overlap,
126
+ "files": list(flow_files),
127
+ "depth": (flow.properties or {}).get("depth"),
128
+ })
129
+ return {"files": sorted(wanted), "affected_flows": hit, "count": len(hit)}