ltcai 9.6.0 → 9.7.0
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.
- package/README.md +52 -42
- package/auto_setup.py +11 -1
- package/docs/CHANGELOG.md +54 -0
- package/docs/COMMUNITY_AND_PLUGINS.md +1 -1
- package/docs/DEVELOPMENT.md +1 -1
- package/docs/ONBOARDING.md +1 -1
- package/docs/PERFORMANCE.md +106 -0
- package/docs/TRUST_MODEL.md +1 -1
- package/docs/WHY_LATTICE.md +1 -1
- package/docs/kg-schema.md +1 -1
- package/kg_schema.py +11 -1
- package/knowledge_graph.py +12 -2
- package/knowledge_graph_api.py +11 -1
- package/lattice_brain/__init__.py +1 -1
- package/lattice_brain/graph/proactive.py +583 -0
- package/lattice_brain/graph/retrieval.py +211 -7
- package/lattice_brain/graph/retrieval_vector.py +102 -0
- package/lattice_brain/ingestion.py +360 -4
- package/lattice_brain/quality.py +44 -9
- package/lattice_brain/runtime/multi_agent.py +38 -2
- package/latticeai/__init__.py +1 -1
- package/latticeai/api/brain_intelligence.py +27 -2
- package/latticeai/api/change_proposals.py +32 -3
- package/latticeai/api/review_queue.py +66 -2
- package/latticeai/app_factory.py +3 -0
- package/latticeai/core/agent.py +193 -135
- package/latticeai/core/agent_eval.py +155 -4
- package/latticeai/core/legacy_compatibility.py +15 -1
- package/latticeai/core/marketplace.py +1 -1
- package/latticeai/core/workspace_os.py +1 -1
- package/latticeai/runtime/router_registration.py +2 -0
- package/latticeai/services/architecture_readiness.py +1 -1
- package/latticeai/services/brain_intelligence.py +97 -1
- package/latticeai/services/change_proposals.py +56 -4
- package/latticeai/services/product_readiness.py +1 -1
- package/latticeai/services/review_queue.py +43 -2
- package/llm_router.py +10 -1
- package/local_knowledge_api.py +10 -1
- package/ltcai_cli.py +11 -1
- package/mcp_registry.py +10 -1
- package/p_reinforce.py +10 -1
- package/package.json +1 -1
- package/scripts/brain_quality_eval.py +1 -1
- package/scripts/check_current_release_docs.mjs +1 -1
- package/scripts/profile_kg.py +360 -0
- package/setup_wizard.py +10 -1
- package/src-tauri/Cargo.lock +1 -1
- package/src-tauri/Cargo.toml +1 -1
- package/src-tauri/tauri.conf.json +1 -1
- package/static/app/asset-manifest.json +10 -10
- package/static/app/assets/{Act-BkOEmwBi.js → Act-B6c39ays.js} +2 -1
- package/static/app/assets/{Brain-C9ITUsQ_.js → Brain-D7Qg4k6M.js} +1 -1
- package/static/app/assets/{Capture-C-ppTeud.js → Capture-VF_di68r.js} +1 -1
- package/static/app/assets/{Library-CGQbgWTu.js → Library-D_Gis2PA.js} +1 -1
- package/static/app/assets/{System-djmj0n2_.js → System-C5s5H2ov.js} +1 -1
- package/static/app/assets/{index-AF0-4XVv.js → index-DJC_2oub.js} +3 -3
- package/static/app/assets/{primitives-jbb2qv4Q.js → primitives-DL4Nip8C.js} +1 -1
- package/static/app/assets/{textarea-CFoo0OxJ.js → textarea-woZfCXHy.js} +1 -1
- package/static/app/index.html +1 -1
- package/static/sw.js +1 -1
package/README.md
CHANGED
|
@@ -132,21 +132,21 @@ confirm owner, check the computer, choose the Brain voice.
|
|
|
132
132
|
Choose the owner of the Brain. The profile is not a SaaS account by default; it
|
|
133
133
|
is the local identity for the knowledge you keep.
|
|
134
134
|
|
|
135
|
-

|
|
136
136
|
|
|
137
137
|
### 3. Recommended Models
|
|
138
138
|
|
|
139
139
|
Start with a short list: safest recommendation, faster model, stronger model.
|
|
140
140
|
Advanced details stay available without overwhelming first-time users.
|
|
141
141
|
|
|
142
|
-

|
|
143
143
|
|
|
144
144
|
### 4. Install And Load
|
|
145
145
|
|
|
146
146
|
Download and load only after consent. Lattice explains model size, local
|
|
147
147
|
execution, and network use before work starts.
|
|
148
148
|
|
|
149
|
-

|
|
150
150
|
|
|
151
151
|
### 5. Brain Chat
|
|
152
152
|
|
|
@@ -158,14 +158,14 @@ and its visible life signal follow real listening, recall, synthesis, and action
|
|
|
158
158
|
state. Detailed memory rings, provenance, conversation history, and
|
|
159
159
|
model/runtime proof open as overlays only when requested.
|
|
160
160
|
|
|
161
|
-

|
|
162
162
|
|
|
163
163
|
### 6. Review Center
|
|
164
164
|
|
|
165
165
|
Automation results are staged for review before they become durable decisions.
|
|
166
166
|
Snooze, unsnooze, run now, approve, and dismiss actions stay explicit.
|
|
167
167
|
|
|
168
|
-

|
|
169
169
|
|
|
170
170
|
## Brain Depths
|
|
171
171
|
|
|
@@ -181,10 +181,10 @@ The user travels inward from everyday memory to deeper structure:
|
|
|
181
181
|
|
|
182
182
|
Walkthrough:
|
|
183
183
|
|
|
184
|
-

|
|
185
185
|
|
|
186
186
|
Screenshot index and capture notes:
|
|
187
|
-
[output/release/v9.
|
|
187
|
+
[output/release/v9.7.0/SCREENSHOT_INDEX.md](output/release/v9.7.0/SCREENSHOT_INDEX.md)
|
|
188
188
|
|
|
189
189
|
## Install
|
|
190
190
|
|
|
@@ -269,50 +269,59 @@ See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for developer workflow details.
|
|
|
269
269
|
|
|
270
270
|
## Current Release
|
|
271
271
|
|
|
272
|
-
The current release is **9.
|
|
273
|
-
|
|
274
|
-
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
- `
|
|
302
|
-
-
|
|
303
|
-
|
|
304
|
-
|
|
272
|
+
The current release is **9.7.0 — Proactive Hybrid Brain**:
|
|
273
|
+
|
|
274
|
+
- Retrieval is unified: `KnowledgeGraphStore.hybrid_search()` fuses lexical
|
|
275
|
+
and vector search in the graph layer itself (normalized scores, per-source
|
|
276
|
+
provenance, rank fusion), degrades honestly to `lexical_only` when the
|
|
277
|
+
vector index is unavailable, and `context_for_query()` can opt into it.
|
|
278
|
+
- The vector index stays in sync automatically: every successful ingest runs
|
|
279
|
+
an incremental `index_node_incremental()` pass (opt-out via
|
|
280
|
+
`LATTICEAI_AUTO_VECTOR_INDEX`), and failures downgrade to an explicit
|
|
281
|
+
`pending` status that the next `rebuild_vector_index` picks up.
|
|
282
|
+
- Ingestion covers whole folders: `ingest_folder()` walks directories with
|
|
283
|
+
`.latticeignore` support (gitignore-like globs), size/extension filters,
|
|
284
|
+
and optional background scheduling; `ingest_web_page()` formalizes the
|
|
285
|
+
web seam — fetching/parsing stays upstream, the graph receives clean text.
|
|
286
|
+
- The Brain is proactive in the graph layer: `lattice_brain/graph/proactive.py`
|
|
287
|
+
finds duplicate and contradictory knowledge, produces a combined quality
|
|
288
|
+
report with stale-node and edge-quality signals, and plans consent-first
|
|
289
|
+
duplicate consolidation — surfaced at `GET /api/brain/duplicates`,
|
|
290
|
+
`GET /api/brain/quality-report`, and the existing contradiction/consolidate
|
|
291
|
+
endpoints.
|
|
292
|
+
- The change-governance loop is closed: Review Center approval now applies
|
|
293
|
+
staged proposals through the single application path (no more
|
|
294
|
+
status-only approvals), proposals carry tool/risk/change-class/conversation
|
|
295
|
+
provenance, reject records a reason, and pending-proposal counts badge the
|
|
296
|
+
review inbox.
|
|
297
|
+
- The agent evaluation gate grew to 12 scenarios, adding file-generation
|
|
298
|
+
happy path and recovery, a 3-step multi-step workflow chain, and a
|
|
299
|
+
governed-write proposal path that pins the approve()-excludes-governed-tools
|
|
300
|
+
invariant.
|
|
301
|
+
- Engineering health: `SingleAgentRuntime.execute` decomposed into focused
|
|
302
|
+
helpers, multi-agent/single-agent runtime consistency pinned by tests, all
|
|
303
|
+
root legacy modules emit deprecation warnings pointing at their package
|
|
304
|
+
homes, and `scripts/profile_kg.py` + `docs/PERFORMANCE.md` establish a
|
|
305
|
+
measured KG performance baseline.
|
|
306
|
+
|
|
307
|
+
Expected artifacts for 9.7.0 release must use exact filenames:
|
|
308
|
+
|
|
309
|
+
- `dist/ltcai-9.7.0-py3-none-any.whl`
|
|
310
|
+
- `dist/ltcai-9.7.0.tar.gz`
|
|
311
|
+
- `ltcai-9.7.0.tgz`
|
|
312
|
+
- `dist/ltcai-9.7.0.vsix`
|
|
313
|
+
- `src-tauri/target/release/bundle/dmg/Lattice AI_9.7.0_aarch64.dmg`
|
|
305
314
|
|
|
306
315
|
Do not use wildcard artifact uploads. Package registry publishing remains owner-run.
|
|
307
316
|
|
|
308
317
|
See [docs/ROADMAP_RECOMMENDATIONS.md](docs/ROADMAP_RECOMMENDATIONS.md) for the
|
|
309
|
-
strategic roadmap slices applied through 9.
|
|
318
|
+
strategic roadmap slices applied through 9.7.0 and the follow-up tracks.
|
|
310
319
|
|
|
311
320
|
## Known Limitations
|
|
312
321
|
|
|
313
322
|
- External package registries are owner-published and can lag behind GitHub.
|
|
314
323
|
- PostgreSQL/pgvector is optional scale/migration tooling. SQLite remains the
|
|
315
|
-
live local Brain store in 9.
|
|
324
|
+
live local Brain store in 9.7.0.
|
|
316
325
|
- Docker, model downloads, cloud model calls, Telegram, Brain Network, and update
|
|
317
326
|
checks require explicit user action.
|
|
318
327
|
- Conversation does not fabricate answers when no model is loaded.
|
|
@@ -324,6 +333,7 @@ strategic roadmap slices applied through 9.6.0 and the follow-up tracks.
|
|
|
324
333
|
|
|
325
334
|
| Version | Theme |
|
|
326
335
|
| --- | --- |
|
|
336
|
+
| 9.7.0 | Proactive Hybrid Brain: graph-native hybrid lexical+vector retrieval with automatic incremental vector indexing, folder ingestion with `.latticeignore`, proactive duplicate/contradiction detection and quality reporting in the graph layer, and a fully closed proposal→Review Center→apply governance loop |
|
|
327
337
|
| 9.6.0 | Trusted Agent Loop: observable agent reasoning (LoopTrace + loop API payload), python-literal/fence/think weak-model repairs with escalating corrections, a deterministic CI agent-eval harness, and proposal-first change governance where edits/deletions of existing files become reviewable diffs |
|
|
328
338
|
| 9.5.0 | Command Center: a Cmd+K palette searching knowledge, conversations, automations, and pages in one query, plus a daily briefing with Brain state at a glance and state-derived one-click quick actions |
|
|
329
339
|
| 9.4.0 | Question-Driven Everyday Automation: the Brain mines recurring user questions and connected knowledge folders into one-click, consent-first automation suggestions installed as review-gated drafts |
|
package/auto_setup.py
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"""Compatibility shim for :mod:`latticeai.setup.auto_setup`."""
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import warnings
|
|
4
|
+
|
|
5
|
+
warnings.warn(
|
|
6
|
+
"Importing 'auto_setup' from the repository root is deprecated; "
|
|
7
|
+
"use 'from latticeai.setup import auto_setup' instead. "
|
|
8
|
+
"The root shim will be removed in a future major release.",
|
|
9
|
+
DeprecationWarning,
|
|
10
|
+
stacklevel=2,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from latticeai.setup import auto_setup as _impl # noqa: E402
|
|
4
14
|
|
|
5
15
|
|
|
6
16
|
if __name__ == "__main__":
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,60 @@ The top entry is either the current unreleased main-branch work or the current
|
|
|
4
4
|
release line. Older entries are historical and may describe behavior as it
|
|
5
5
|
existed at that release.
|
|
6
6
|
|
|
7
|
+
## [9.7.0] - 2026-07-20
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Added `KnowledgeGraphStore.hybrid_search()`: graph-native fusion of
|
|
11
|
+
lexical and vector retrieval with normalized scores, per-source
|
|
12
|
+
provenance, chunk→parent roll-up, workspace scoping, and an honest
|
|
13
|
+
`lexical_only` fallback; `context_for_query()` gains an opt-in
|
|
14
|
+
`use_hybrid` flag.
|
|
15
|
+
- Added `index_node_incremental()` and automatic post-ingest vector-index
|
|
16
|
+
sync in `IngestionPipeline` (opt-out `LATTICEAI_AUTO_VECTOR_INDEX`);
|
|
17
|
+
vector failures downgrade to `indexing_status: pending` instead of
|
|
18
|
+
failing the ingest.
|
|
19
|
+
- Added `IngestionPipeline.ingest_folder()` (recursive walk,
|
|
20
|
+
`.latticeignore` gitignore-like filtering, size/extension limits,
|
|
21
|
+
optional background queue) and `ingest_web_page()` (formalized
|
|
22
|
+
extracted-text web seam; fetching/parsing stays upstream).
|
|
23
|
+
- Added `lattice_brain/graph/proactive.py` (`ProactiveBrain`): duplicate
|
|
24
|
+
detection, contradiction detection, combined `quality_report()`,
|
|
25
|
+
consent-first `consolidate_duplicates()` planning, and the pure
|
|
26
|
+
`gate_ingest_candidate()` quality-gating seam.
|
|
27
|
+
- Added `GET /api/brain/duplicates` and `GET /api/brain/quality-report`;
|
|
28
|
+
`/api/brain/contradictions` and `/api/brain/consolidate` return
|
|
29
|
+
graph-layer results additively.
|
|
30
|
+
- Added `GET /api/proposals/counts`, `GET /api/proposals/{id}` (diff +
|
|
31
|
+
staged content), reject-with-reason, and
|
|
32
|
+
`GET /automation/reviews/counts`; the Review Center UI gains a
|
|
33
|
+
`change_proposal` filter, diff preview, tier/deletion badges, a
|
|
34
|
+
pending-count badge, and a reject-reason input (ko/en parity).
|
|
35
|
+
- Added 4 agent-eval scenarios (12 total): file-generation happy path,
|
|
36
|
+
file-generation recovery, multi-step workflow chain, and a
|
|
37
|
+
governed-write proposal path pinning the
|
|
38
|
+
approve()-excludes-governed-tools invariant.
|
|
39
|
+
- Added `tests/unit/test_runtime_consistency.py`,
|
|
40
|
+
`scripts/profile_kg.py`, and `docs/PERFORMANCE.md` (measured synthetic
|
|
41
|
+
KG baseline; flags brute-force `vector_search()` as the next
|
|
42
|
+
optimization target).
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
- Review Center approval of `change_proposal` items now applies the staged
|
|
46
|
+
content through `ChangeProposalService.approve_and_apply` (single
|
|
47
|
+
application path, 409 on replay) instead of only flipping status.
|
|
48
|
+
- Change proposals carry tool/risk/change-class/conversation-id
|
|
49
|
+
provenance; the agent loop forwards `conversation_id` to the governor.
|
|
50
|
+
- `SingleAgentRuntime.execute` decomposed into six focused helpers
|
|
51
|
+
(behavior-preserving); the multi-agent orchestrator surfaces real
|
|
52
|
+
failure reasons in `execution_failed` timeline events.
|
|
53
|
+
- All root legacy modules emit `DeprecationWarning` pointing at their
|
|
54
|
+
package homes; the legacy-compatibility registry tracks all 13 shims.
|
|
55
|
+
|
|
56
|
+
### Security
|
|
57
|
+
- Proposal apply/reject stays fail-closed end-to-end: approval applies
|
|
58
|
+
exactly the reviewed staged content, replays are rejected with 409, and
|
|
59
|
+
reject reasons land in provenance for audit.
|
|
60
|
+
|
|
7
61
|
## [9.6.0] - 2026-07-20
|
|
8
62
|
|
|
9
63
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Community And Plugins
|
|
2
2
|
|
|
3
|
-
Current release: **9.
|
|
3
|
+
Current release: **9.7.0 — Proactive Hybrid Brain**.
|
|
4
4
|
|
|
5
5
|
LatticeAI defines the path from a strong local-first framework (8.4.0
|
|
6
6
|
action-aware baseline, 8.5.0 registry+DI hardening, 8.6.0 capture/navigation
|
package/docs/DEVELOPMENT.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Lattice AI Development
|
|
2
2
|
|
|
3
|
-
Current release: **9.
|
|
3
|
+
Current release: **9.7.0 — Proactive Hybrid Brain**.
|
|
4
4
|
|
|
5
5
|
This document is for contributors working on the local-first Digital Brain
|
|
6
6
|
codebase. Product positioning and quick start stay in `README.md`; release
|
package/docs/ONBOARDING.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Lattice AI Onboarding
|
|
2
2
|
|
|
3
|
-
Current release: **9.
|
|
3
|
+
Current release: **9.7.0 — Proactive Hybrid Brain**.
|
|
4
4
|
|
|
5
5
|
The first-run goal is a five-minute path from "I opened the app" to "my Brain
|
|
6
6
|
has a source, a question, and proof." This page is the product contract behind
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Knowledge Graph Performance Baseline
|
|
2
|
+
|
|
3
|
+
Synthetic performance and memory baseline for `KnowledgeGraphStore`
|
|
4
|
+
(`lattice_brain/graph/`). Measured with `scripts/profile_kg.py`.
|
|
5
|
+
|
|
6
|
+
**This is a synthetic baseline, not a real-workload benchmark.** Use it for
|
|
7
|
+
release-over-release regression comparison, not as a marketing number.
|
|
8
|
+
|
|
9
|
+
## Methodology
|
|
10
|
+
|
|
11
|
+
- `scripts/profile_kg.py` builds a throwaway store the same way the unit tests
|
|
12
|
+
do (`KnowledgeGraphStore(tmp/graph.sqlite, tmp/blobs)`) and ingests N
|
|
13
|
+
synthetic text sources through the real `ingest_source()` pipeline
|
|
14
|
+
(chunking, rule-based concept/triple extraction, provenance edges).
|
|
15
|
+
- Corpus: fixed-vocabulary English + Korean text, seeded RNG (`--seed`,
|
|
16
|
+
default 42), ~60% short (~40 words) / 30% medium (~160) / 10% long (~520)
|
|
17
|
+
documents with recurring entities so concept nodes are shared and edges form.
|
|
18
|
+
- Fully offline: no LLM router is registered (extraction takes the rules
|
|
19
|
+
path) and the embedder is the built-in deterministic hash model. No network,
|
|
20
|
+
no model downloads.
|
|
21
|
+
- Timing: `time.perf_counter()` per call; p50/p95/mean over all calls in a
|
|
22
|
+
phase. Memory: `tracemalloc` peak, reset per phase.
|
|
23
|
+
- Caveat: tracemalloc runs for the whole profile and roughly doubles Python
|
|
24
|
+
allocation cost, so absolute timings are conservative upper bounds.
|
|
25
|
+
- Caveat: the synthetic vocabulary is small, so FTS selectivity and concept
|
|
26
|
+
density differ from real user data; every tenth query is a guaranteed miss
|
|
27
|
+
to avoid measuring only warm hits.
|
|
28
|
+
|
|
29
|
+
Run it:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
.venv/bin/python scripts/profile_kg.py # 5000 sources, 50 queries
|
|
33
|
+
.venv/bin/python scripts/profile_kg.py --nodes 500 # quick run (~10 s)
|
|
34
|
+
.venv/bin/python scripts/profile_kg.py --json # machine-readable
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Measured baseline (2026-07-20, v9.6.0 working tree)
|
|
38
|
+
|
|
39
|
+
Apple Silicon (darwin), Python 3.x from `.venv`, SQLite with FTS5 trigram
|
|
40
|
+
available, tracemalloc enabled.
|
|
41
|
+
|
|
42
|
+
### 500 sources (quick profile, ~9 s total)
|
|
43
|
+
|
|
44
|
+
Graph produced: 2,019 nodes / 6,546 edges, 21.2 MB SQLite file.
|
|
45
|
+
|
|
46
|
+
| phase | calls | p50 ms | p95 ms | wall s | peak MB |
|
|
47
|
+
|----------------------|------:|-------:|-------:|-------:|--------:|
|
|
48
|
+
| ingest_source | 500 | 6.9 | 17.7 | 4.1 | 0.6 |
|
|
49
|
+
| search | 50 | 1.2 | 2.5 | 0.07 | 0.6 |
|
|
50
|
+
| context_for_query | 50 | 1.0 | 2.4 | 0.06 | 0.5 |
|
|
51
|
+
| neighbors | 50 | 0.35 | 0.45 | 0.02 | 0.6 |
|
|
52
|
+
| traverse (depth 2) | 50 | 4.8 | 5.2 | 0.24 | 1.1 |
|
|
53
|
+
| stats | 5 | 1.5 | 1.7 | 0.01 | 0.4 |
|
|
54
|
+
| rebuild_vector_index | 1 | 1319 | 1319 | 1.3 | 5.0 |
|
|
55
|
+
| vector_search | 10 | 287 | 294 | 2.9 | 14.4 |
|
|
56
|
+
|
|
57
|
+
Ingestion throughput: **~122 items/sec** (412 KB corpus).
|
|
58
|
+
|
|
59
|
+
### 5000 sources (default profile, ~2.5 min total)
|
|
60
|
+
|
|
61
|
+
Graph produced: 18,426 nodes / 62,534 edges, 198.8 MB SQLite file
|
|
62
|
+
(4.26 MB corpus). Measured while other processes shared the CPU, so treat as
|
|
63
|
+
an upper bound.
|
|
64
|
+
|
|
65
|
+
| phase | calls | p50 ms | p95 ms | wall s | peak MB |
|
|
66
|
+
|----------------------|------:|-------:|-------:|-------:|--------:|
|
|
67
|
+
| ingest_source | 5000 | 20.1 | 54.6 | 119.9 | 1.4 |
|
|
68
|
+
| search | 50 | 4.3 | 19.8 | 0.40 | 1.2 |
|
|
69
|
+
| context_for_query | 50 | 4.1 | 18.5 | 0.40 | 1.2 |
|
|
70
|
+
| neighbors | 50 | 0.39 | 0.50 | 0.03 | 1.2 |
|
|
71
|
+
| traverse (depth 2) | 50 | 12.2 | 15.8 | 0.64 | 1.7 |
|
|
72
|
+
| stats | 5 | 13.1 | 13.5 | 0.07 | 1.1 |
|
|
73
|
+
| rebuild_vector_index | 1 | 14624 | 14624 | 14.6 | 45.6 |
|
|
74
|
+
| vector_search | 10 | 1732 | 1774 | 17.4 | 83.5 |
|
|
75
|
+
|
|
76
|
+
Ingestion throughput: **~42 items/sec** at this scale.
|
|
77
|
+
|
|
78
|
+
Scaling signal (500 → 5000 sources, 10x): per-item ingest p50 grew ~3x
|
|
79
|
+
(6.9 ms → 20.1 ms) — ingestion cost is superlinear in DB size (FTS triggers,
|
|
80
|
+
dedup lookups, edge upserts against growing tables). `vector_search` p50 grew
|
|
81
|
+
~6x (287 ms → 1732 ms), consistent with its O(index size) brute-force scan.
|
|
82
|
+
Keyword search p50 grew ~3.6x but stays under 5 ms.
|
|
83
|
+
|
|
84
|
+
Regenerate with `.venv/bin/python scripts/profile_kg.py` after graph-layer
|
|
85
|
+
changes and compare against these tables.
|
|
86
|
+
|
|
87
|
+
## Observations
|
|
88
|
+
|
|
89
|
+
- Keyword `search()` / `context_for_query()` stay low-millisecond thanks to
|
|
90
|
+
the FTS5 trigram index; they are not the scaling bottleneck.
|
|
91
|
+
- `traverse(depth=2)` cost grows with edge fan-out (synthetic corpus creates
|
|
92
|
+
dense shared-concept hubs); p95 is ~5 ms at 500 sources and ~16 ms at 5000.
|
|
93
|
+
- `vector_search()` is a brute-force scan over every stored embedding
|
|
94
|
+
(O(index size) per query). It is the dominant cost at scale and the first
|
|
95
|
+
candidate for an ANN/pruning optimization if vector recall becomes a hot
|
|
96
|
+
path. The profiler caps vector queries at 10 for this reason.
|
|
97
|
+
- `rebuild_vector_index(full=True)` embeds documents and chunks with the hash
|
|
98
|
+
embedder; with a real embedding provider expect this phase to be slower by
|
|
99
|
+
the provider's per-call latency times the item count.
|
|
100
|
+
|
|
101
|
+
## Regression workflow
|
|
102
|
+
|
|
103
|
+
1. Before a graph-layer change: `.venv/bin/python scripts/profile_kg.py --nodes 500 --json > /tmp/kg-before.json`
|
|
104
|
+
2. After the change: same command to `/tmp/kg-after.json`.
|
|
105
|
+
3. Compare phase p50/p95 and `db_size_mb`; investigate anything that moved
|
|
106
|
+
more than ~20% beyond run-to-run noise.
|
package/docs/TRUST_MODEL.md
CHANGED
package/docs/WHY_LATTICE.md
CHANGED
package/docs/kg-schema.md
CHANGED
package/kg_schema.py
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
"""Compatibility shim for the v4 Knowledge Graph schema."""
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import warnings as _warnings
|
|
4
|
+
|
|
5
|
+
_warnings.warn(
|
|
6
|
+
"Importing 'kg_schema' from the repository root is deprecated; "
|
|
7
|
+
"use 'from lattice_brain.graph.schema import ...' instead. "
|
|
8
|
+
"The root shim will be removed in a future major release.",
|
|
9
|
+
DeprecationWarning,
|
|
10
|
+
stacklevel=2,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from lattice_brain.graph.schema import * # noqa: F403,F401,E402
|
package/knowledge_graph.py
CHANGED
|
@@ -4,7 +4,17 @@ The implementation now lives under :mod:`lattice_brain`. Root imports are
|
|
|
4
4
|
kept for older integrations and tests.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import warnings as _warnings
|
|
8
|
+
|
|
9
|
+
_warnings.warn(
|
|
10
|
+
"Importing 'knowledge_graph' from the repository root is deprecated; "
|
|
11
|
+
"use 'from lattice_brain.graph.store import KnowledgeGraphStore' instead. "
|
|
12
|
+
"The root shim will be removed in a future major release.",
|
|
13
|
+
DeprecationWarning,
|
|
14
|
+
stacklevel=2,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
from lattice_brain.graph._kg_common import ( # noqa: F401,E402
|
|
8
18
|
EDGE_VERB,
|
|
9
19
|
GRAPH_SCHEMA_VERSION,
|
|
10
20
|
LOCAL_CODE_EXTENSIONS,
|
|
@@ -24,7 +34,7 @@ from lattice_brain.graph._kg_common import ( # noqa: F401
|
|
|
24
34
|
_slug,
|
|
25
35
|
set_llm_router,
|
|
26
36
|
)
|
|
27
|
-
from lattice_brain.graph.store import KnowledgeGraphStore
|
|
37
|
+
from lattice_brain.graph.store import KnowledgeGraphStore # noqa: E402
|
|
28
38
|
|
|
29
39
|
__all__ = [
|
|
30
40
|
"KnowledgeGraphStore",
|
package/knowledge_graph_api.py
CHANGED
|
@@ -6,7 +6,17 @@ importable for the deprecation window and will be removed in a future major
|
|
|
6
6
|
release.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
import warnings as _warnings
|
|
10
|
+
|
|
11
|
+
_warnings.warn(
|
|
12
|
+
"Importing 'knowledge_graph_api' from the repository root is deprecated; "
|
|
13
|
+
"use 'from latticeai.api.knowledge_graph import create_knowledge_graph_router' instead. "
|
|
14
|
+
"The root shim will be removed in a future major release.",
|
|
15
|
+
DeprecationWarning,
|
|
16
|
+
stacklevel=2,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
from latticeai.api.knowledge_graph import ( # noqa: F401,E402
|
|
10
20
|
KnowledgeGraphIngestRequest,
|
|
11
21
|
create_knowledge_graph_router,
|
|
12
22
|
)
|