ltcai 9.2.0 → 9.4.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.
Files changed (49) hide show
  1. package/README.md +34 -22
  2. package/docs/CHANGELOG.md +49 -0
  3. package/docs/COMMUNITY_AND_PLUGINS.md +4 -3
  4. package/docs/DEVELOPMENT.md +8 -8
  5. package/docs/LEGACY_COMPATIBILITY.md +1 -1
  6. package/docs/ONBOARDING.md +2 -2
  7. package/docs/OPERATIONS.md +1 -1
  8. package/docs/TRUST_MODEL.md +1 -1
  9. package/docs/WHY_LATTICE.md +1 -1
  10. package/docs/kg-schema.md +1 -1
  11. package/docs/mcp-tools.md +1 -1
  12. package/lattice_brain/__init__.py +1 -1
  13. package/lattice_brain/runtime/multi_agent.py +1 -1
  14. package/latticeai/__init__.py +1 -1
  15. package/latticeai/api/automation_intelligence.py +129 -0
  16. package/latticeai/api/brain_intelligence.py +68 -0
  17. package/latticeai/app_factory.py +17 -0
  18. package/latticeai/core/legacy_compatibility.py +1 -1
  19. package/latticeai/core/marketplace.py +1 -1
  20. package/latticeai/core/workspace_os.py +1 -1
  21. package/latticeai/runtime/chat_wiring.py +2 -0
  22. package/latticeai/runtime/persistence_runtime.py +15 -0
  23. package/latticeai/runtime/router_registration.py +16 -0
  24. package/latticeai/services/architecture_readiness.py +1 -1
  25. package/latticeai/services/automation_intelligence.py +450 -0
  26. package/latticeai/services/brain_intelligence.py +439 -0
  27. package/latticeai/services/memory_service.py +65 -5
  28. package/latticeai/services/product_readiness.py +1 -1
  29. package/latticeai/services/router_context.py +1 -0
  30. package/package.json +1 -1
  31. package/scripts/check_current_release_docs.mjs +1 -1
  32. package/src-tauri/Cargo.lock +1 -1
  33. package/src-tauri/Cargo.toml +1 -1
  34. package/src-tauri/tauri.conf.json +1 -1
  35. package/static/app/asset-manifest.json +11 -11
  36. package/static/app/assets/Act-t9oveJO7.js +1 -0
  37. package/static/app/assets/{Brain-DBYgdcjt.js → Brain-DP-gpcEJ.js} +1 -1
  38. package/static/app/assets/{Capture-Cf3hqRtN.js → Capture-DYknDKy8.js} +1 -1
  39. package/static/app/assets/{Library-CFfkNn3s.js → Library-DLyc_g8c.js} +1 -1
  40. package/static/app/assets/{System-BOurbT-v.js → System-BZgJ7tGu.js} +1 -1
  41. package/static/app/assets/index-BeQ77vPs.js +17 -0
  42. package/static/app/assets/index-Cl4S_9Id.css +2 -0
  43. package/static/app/assets/{primitives-DcUUmhdC.js → primitives-DawfkPR4.js} +1 -1
  44. package/static/app/assets/{textarea-BklR6zN4.js → textarea-a4Ir3SZS.js} +1 -1
  45. package/static/app/index.html +2 -2
  46. package/static/sw.js +1 -1
  47. package/static/app/assets/Act-C3dBrWE-.js +0 -1
  48. package/static/app/assets/index-A3M9sElj.js +0 -17
  49. package/static/app/assets/index-Bmx9rzTc.css +0 -2
package/README.md CHANGED
@@ -1,10 +1,20 @@
1
1
  # Lattice AI
2
2
 
3
- **Lattice AI 9.2.0 is the local-first Digital Brain platform. Model-Agnostic File Generation makes "create a file" work reliably with any loaded LLM: file requests run through a strict extension-aware prompt, robust extraction, per-type validation, one corrective retry, and a deterministic repair fallback, so even small local models (gemma/qwen class) always produce a structurally valid HTML, JSON, or code file.**
3
+ **Lattice AI 9.4.0 is the local-first Digital Brain platform. Question-Driven Everyday Automation makes automating daily life effortless: the Brain mines your own recurring questions and connected knowledge folders, proposes concrete automations with your literal questions as evidence, and installs them in one click as consent-first drafts scheduled answers for questions you keep asking, digests for folders that keep growing.**
4
4
 
5
5
  **Lattice AI는 모델이 바뀌어도 내 지식과 맥락을 보존하는 로컬 우선 AI 브레인입니다.**
6
6
 
7
- > The 9.2.0 release hardens file creation end to end: chat file requests are
7
+ > The 9.4.0 release adds question-driven automation: a deterministic local
8
+ > pattern miner clusters your recurring questions (the evidence shown is your
9
+ > own words, no model call), an /api/automation surface turns patterns and
10
+ > connected folders into one-click suggestions, and every accepted suggestion
11
+ > becomes a disabled, review-gated draft workflow you enable deliberately.
12
+ > The 9.3.0 release wired the previously dormant Brain quality layer into
13
+ > the product: /api/brain health diagnosis with recommended care actions, a
14
+ > proactive insights digest, contradiction surfacing across memories and the
15
+ > graph, dry-run-first duplicate consolidation, and hybrid recall that blends
16
+ > vector similarity with lexical evidence behind an honest quality gate.
17
+ > The 9.2.0 release hardened file creation end to end: chat file requests are
8
18
  > routed to a deterministic direct-write path (including type-only requests
9
19
  > like "html 파일 만들어줘"), model replies are treated as untrusted content
10
20
  > and cleaned of fences, reasoning blocks, and chat framing, and the agent
@@ -92,10 +102,10 @@ You need Lattice AI when:
92
102
  The screenshots below are the latest checked-in visual evidence captures. They
93
103
  keep the first-run Brain flow, memory graph, source capture, model library,
94
104
  system view, admin console, and review center visible as release gates while
95
- 9.2.0 makes file generation model-agnostic: chat file requests always end in
96
- a structurally valid file regardless of which LLM is loaded, backed by
97
- extraction, validation, corrective retry, and deterministic repair. The
98
- captures below are the checked-in 9.2.0 visual release evidence for that
105
+ 9.4.0 makes everyday automation effortless: the Brain proposes automations
106
+ from your own recurring questions and connected knowledge folders, and every
107
+ accepted suggestion becomes a consent-first draft you review and enable. The
108
+ captures below are the checked-in 9.4.0 visual release evidence for that
99
109
  product flow.
100
110
 
101
111
  ### 1. Wake Brain
@@ -108,21 +118,21 @@ confirm owner, check the computer, choose the Brain voice.
108
118
  Choose the owner of the Brain. The profile is not a SaaS account by default; it
109
119
  is the local identity for the knowledge you keep.
110
120
 
111
- ![Login](output/release/v9.2.0/screenshots/01-login.png)
121
+ ![Login](output/release/v9.4.0/screenshots/01-login.png)
112
122
 
113
123
  ### 3. Recommended Models
114
124
 
115
125
  Start with a short list: safest recommendation, faster model, stronger model.
116
126
  Advanced details stay available without overwhelming first-time users.
117
127
 
118
- ![Recommended Models](output/release/v9.2.0/screenshots/02-recommended-models.png)
128
+ ![Recommended Models](output/release/v9.4.0/screenshots/02-recommended-models.png)
119
129
 
120
130
  ### 4. Install And Load
121
131
 
122
132
  Download and load only after consent. Lattice explains model size, local
123
133
  execution, and network use before work starts.
124
134
 
125
- ![Install and Load](output/release/v9.2.0/screenshots/03-install-load-progress.png)
135
+ ![Install and Load](output/release/v9.4.0/screenshots/03-install-load-progress.png)
126
136
 
127
137
  ### 5. Brain Chat
128
138
 
@@ -134,14 +144,14 @@ and its visible life signal follow real listening, recall, synthesis, and action
134
144
  state. Detailed memory rings, provenance, conversation history, and
135
145
  model/runtime proof open as overlays only when requested.
136
146
 
137
- ![One-viewport Living Brain Home](output/release/v9.2.0/screenshots/04-brain-chat-home.png)
147
+ ![One-viewport Living Brain Home](output/release/v9.4.0/screenshots/04-brain-chat-home.png)
138
148
 
139
149
  ### 6. Review Center
140
150
 
141
151
  Automation results are staged for review before they become durable decisions.
142
152
  Snooze, unsnooze, run now, approve, and dismiss actions stay explicit.
143
153
 
144
- ![Review Center](output/release/v9.2.0/screenshots/12-review-center.png)
154
+ ![Review Center](output/release/v9.4.0/screenshots/12-review-center.png)
145
155
 
146
156
  ## Brain Depths
147
157
 
@@ -157,10 +167,10 @@ The user travels inward from everyday memory to deeper structure:
157
167
 
158
168
  Walkthrough:
159
169
 
160
- ![v9.2.0 Living Brain walkthrough](output/release/v9.2.0/gifs/v9.2.0-living-brain-walkthrough.gif)
170
+ ![v9.4.0 Living Brain walkthrough](output/release/v9.4.0/gifs/v9.4.0-living-brain-walkthrough.gif)
161
171
 
162
172
  Screenshot index and capture notes:
163
- [output/release/v9.2.0/SCREENSHOT_INDEX.md](output/release/v9.2.0/SCREENSHOT_INDEX.md)
173
+ [output/release/v9.4.0/SCREENSHOT_INDEX.md](output/release/v9.4.0/SCREENSHOT_INDEX.md)
164
174
 
165
175
  ## Install
166
176
 
@@ -245,7 +255,7 @@ See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for developer workflow details.
245
255
 
246
256
  ## Current Release
247
257
 
248
- The current release is **9.2.0 — Model-Agnostic File Generation**:
258
+ The current release is **9.4.0 — Question-Driven Everyday Automation**:
249
259
 
250
260
  - A new `latticeai.core.file_generation` pipeline treats every model reply as
251
261
  untrusted content: extension-aware strict prompting, extraction of the real
@@ -264,24 +274,24 @@ The current release is **9.2.0 — Model-Agnostic File Generation**:
264
274
  - File writes report whether content was generated cleanly, retried, or
265
275
  auto-repaired in the response payload (`generation` metadata).
266
276
 
267
- Expected artifacts for 9.2.0 release must use exact filenames:
277
+ Expected artifacts for 9.4.0 release must use exact filenames:
268
278
 
269
- - `dist/ltcai-9.2.0-py3-none-any.whl`
270
- - `dist/ltcai-9.2.0.tar.gz`
271
- - `ltcai-9.2.0.tgz`
272
- - `dist/ltcai-9.2.0.vsix`
273
- - `src-tauri/target/release/bundle/dmg/Lattice AI_9.2.0_aarch64.dmg`
279
+ - `dist/ltcai-9.4.0-py3-none-any.whl`
280
+ - `dist/ltcai-9.4.0.tar.gz`
281
+ - `ltcai-9.4.0.tgz`
282
+ - `dist/ltcai-9.4.0.vsix`
283
+ - `src-tauri/target/release/bundle/dmg/Lattice AI_9.4.0_aarch64.dmg`
274
284
 
275
285
  Do not use wildcard artifact uploads. Package registry publishing remains owner-run.
276
286
 
277
287
  See [docs/ROADMAP_RECOMMENDATIONS.md](docs/ROADMAP_RECOMMENDATIONS.md) for the
278
- strategic roadmap slices applied through 9.2.0 and the follow-up tracks.
288
+ strategic roadmap slices applied through 9.4.0 and the follow-up tracks.
279
289
 
280
290
  ## Known Limitations
281
291
 
282
292
  - External package registries are owner-published and can lag behind GitHub.
283
293
  - PostgreSQL/pgvector is optional scale/migration tooling. SQLite remains the
284
- live local Brain store in 9.2.0.
294
+ live local Brain store in 9.4.0.
285
295
  - Docker, model downloads, cloud model calls, Telegram, Brain Network, and update
286
296
  checks require explicit user action.
287
297
  - Conversation does not fabricate answers when no model is loaded.
@@ -293,6 +303,8 @@ strategic roadmap slices applied through 9.2.0 and the follow-up tracks.
293
303
 
294
304
  | Version | Theme |
295
305
  | --- | --- |
306
+ | 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 |
307
+ | 9.3.0 | Proactive Brain Intelligence: the Brain diagnoses its own health, surfaces contradictions and stale knowledge, proposes consent-first duplicate consolidation, and recalls with hybrid lexical+semantic evidence behind an honest quality gate |
296
308
  | 9.2.0 | Model-Agnostic File Generation: chat file requests always produce structurally valid files with any LLM via extraction, per-type validation, corrective retry, deterministic repair, inferred file targets, and a fault-tolerant agent JSON loop |
297
309
  | 9.1.0 | Code Review Completion & Fail-Closed Runtime: all July 11 review findings closed across fail-closed security, typed runtime/model/chat boundaries, honest frontend failures and tests, and repository hygiene |
298
310
  | 9.0.0 | Code Review Closure & Runtime Cleanup: July 8 code-review follow-ups fixed, chat/runtime reliability improved, duplicated utility surfaces consolidated, runtime audit append paths moved to JSONL, and release metadata/artifacts synchronized |
package/docs/CHANGELOG.md CHANGED
@@ -4,6 +4,55 @@ 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.4.0] - 2026-07-20
8
+
9
+ ### Added
10
+ - Added `latticeai/services/automation_intelligence.py` and the
11
+ `/api/automation/*` router: recurring-question pattern mining
12
+ (deterministic local token-signature clustering with literal-question
13
+ evidence), automation suggestions from question patterns and connected
14
+ knowledge folders, idempotent consent-first install (disabled draft,
15
+ review-queue gated, local-only), and a combined overview payload.
16
+ - Added the "Automation suggestions for you" panel to the Act page with
17
+ evidence chips and one-click creation, fully ko/en localized.
18
+ - Added `tests/unit/test_automation_intelligence.py` (10 tests).
19
+
20
+ ### Changed
21
+ - Recurring question intents that match a starter recipe (daily digest,
22
+ weekly project review, follow-up radar) suggest that recipe; other
23
+ repeated questions become parameterized "scheduled answer" workflows.
24
+
25
+ ### Security
26
+ - History mining respects user/workspace scoping and excludes legacy-global
27
+ rows for scoped reads; suggestion installs carry provenance metadata and
28
+ never enable themselves.
29
+
30
+ ## [9.3.0] - 2026-07-20
31
+
32
+ ### Added
33
+ - Added `latticeai/services/brain_intelligence.py` and the `/api/brain/*`
34
+ router: health diagnosis (freshness/connectivity/search-readiness/
35
+ consistency scores with recommended care actions), proactive insights
36
+ digest, contradiction surfacing (memory pairs, temporal, CONTRADICTS
37
+ edges), and consent-first duplicate consolidation (dry-run default,
38
+ audited memory prune on apply, graph never mutated).
39
+ - Wired the previously dormant `lattice_brain.quality` layer
40
+ (MemoryQualityManager, GraphEdgeQualityManager) into the product.
41
+ - Added the "Brain intelligence check" panel to the Brain surface with full
42
+ ko/en localization, plus `latticeApi` client methods for the new endpoints.
43
+ - Added `tests/unit/test_brain_intelligence.py` (14 tests).
44
+
45
+ ### Changed
46
+ - `/api/memory/recall` is now hybrid: vector similarity blends with lexical
47
+ term evidence behind a `hybrid-evidence/v2` quality gate; results carry
48
+ `vector_score` and `evidence_kinds`; vector matches are workspace-scoped
49
+ via `filter_scoped_nodes` before they can influence rankings.
50
+
51
+ ### Fixed
52
+ - Recall no longer misses knowledge phrased differently from the query when
53
+ the vector index is available; vector-tier failures degrade recall to
54
+ lexical with the error surfaced instead of breaking the endpoint.
55
+
7
56
  ## [9.2.0] - 2026-07-20
8
57
 
9
58
  ### Added
@@ -1,13 +1,14 @@
1
1
  # Community And Plugins
2
2
 
3
- Current release: **9.2.0 — Model-Agnostic File Generation**.
3
+ Current release: **9.4.0 — Question-Driven Everyday Automation**.
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
7
7
  reliability, 8.7.0 runtime-state hygiene, 8.8.0 Brain Core extraction
8
8
  readiness, 8.9.0 scoped Tool API hardening, 9.0.0 cleanup closure, 9.1.0
9
- fail-closed review completion, and 9.2.0 model-agnostic file generation) to a
10
- product ecosystem. The
9
+ fail-closed review completion, 9.2.0 model-agnostic file generation, 9.3.0
10
+ proactive Brain intelligence, and 9.4.0 question-driven everyday automation)
11
+ to a product ecosystem. The
11
12
  immediate goal is small and practical: make it clear how
12
13
  contributors can extend the Brain without weakening local-first trust,
13
14
  workspace scoping, or release quality.
@@ -1,10 +1,10 @@
1
1
  # Lattice AI Development
2
2
 
3
- Current release: **9.2.0 — Model-Agnostic File Generation**.
3
+ Current release: **9.4.0 — Question-Driven Everyday Automation**.
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
7
- history is intentionally limited to 8.0.0-9.2.0 in `docs/CHANGELOG.md` and
7
+ history is intentionally limited to 8.0.0-9.4.0 in `docs/CHANGELOG.md` and
8
8
  `RELEASE.md`.
9
9
 
10
10
  ## Product Contract
@@ -153,10 +153,10 @@ For user-facing, API, runtime, release, or packaging changes, check:
153
153
  Release/publish examples must use exact target-version filenames. Do not
154
154
  document wildcard artifact upload commands.
155
155
 
156
- For 9.2.0 release work, exact artifacts are:
156
+ For 9.4.0 release work, exact artifacts are:
157
157
 
158
- - `dist/ltcai-9.2.0-py3-none-any.whl`
159
- - `dist/ltcai-9.2.0.tar.gz`
160
- - `ltcai-9.2.0.tgz`
161
- - `dist/ltcai-9.2.0.vsix`
162
- - `src-tauri/target/release/bundle/dmg/Lattice AI_9.2.0_aarch64.dmg`
158
+ - `dist/ltcai-9.4.0-py3-none-any.whl`
159
+ - `dist/ltcai-9.4.0.tar.gz`
160
+ - `ltcai-9.4.0.tgz`
161
+ - `dist/ltcai-9.4.0.vsix`
162
+ - `src-tauri/target/release/bundle/dmg/Lattice AI_9.4.0_aarch64.dmg`
@@ -1,6 +1,6 @@
1
1
  # Legacy Compatibility Map
2
2
 
3
- Current target: **9.2.0 — Model-Agnostic File Generation**.
3
+ Current target: **9.4.0 — Question-Driven Everyday Automation**.
4
4
 
5
5
  Lattice AI is moving toward a smaller, modular architecture centered on
6
6
  `lattice_brain`, `latticeai.services`, `latticeai.api`, and `latticeai.runtime`.
@@ -1,6 +1,6 @@
1
1
  # Lattice AI Onboarding
2
2
 
3
- Current release: **9.2.0 — Model-Agnostic File Generation**.
3
+ Current release: **9.4.0 — Question-Driven Everyday Automation**.
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
@@ -40,7 +40,7 @@ read the docs first.
40
40
 
41
41
  ## Release Gate
42
42
 
43
- 9.2.0 treats onboarding as a release gate, not marketing copy. The current
43
+ 9.4.0 treats onboarding as a release gate, not marketing copy. The current
44
44
  machine-checkable product readiness report requires this five-minute contract,
45
45
  the Brain Home surface, setup helpers, graph ingestion tests, and exact release
46
46
  artifact documentation before the release can be called complete.
@@ -1,4 +1,4 @@
1
- # Lattice AI — Operations Guide (v9.2.0)
1
+ # Lattice AI — Operations Guide (v9.4.0)
2
2
 
3
3
  ## 1. 데이터 파일 위치
4
4
 
@@ -1,6 +1,6 @@
1
1
  # Lattice AI Trust Model
2
2
 
3
- Current release: **9.2.0 — Model-Agnostic File Generation**.
3
+ Current release: **9.4.0 — Question-Driven Everyday Automation**.
4
4
 
5
5
  Lattice AI is local-first, explicit about external communication, and honest
6
6
  when a capability is unavailable.
@@ -1,6 +1,6 @@
1
1
  # Why Lattice AI Exists
2
2
 
3
- Current release: **9.2.0 — Model-Agnostic File Generation**.
3
+ Current release: **9.4.0 — Question-Driven Everyday Automation**.
4
4
 
5
5
  **Lattice AI is a local-first Digital Brain that keeps your knowledge durable
6
6
  across any AI model.**
package/docs/kg-schema.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Knowledge Graph Schema
2
2
 
3
- Current release: **9.2.0 — Model-Agnostic File Generation**.
3
+ Current release: **9.4.0 — Question-Driven Everyday Automation**.
4
4
 
5
5
  명세 출처: `lattice_ai_full_spec.pptx` 슬라이드 20·21·22
6
6
  구현: `kg_schema.py`
package/docs/mcp-tools.md CHANGED
@@ -1,4 +1,4 @@
1
- # MCP 도구 카탈로그 (v9.2.0)
1
+ # MCP 도구 카탈로그 (v9.4.0)
2
2
 
3
3
  Lattice AI는 MCP(Model Context Protocol) 서버로 동작하여 Claude Desktop, Cursor 등에서 직접 도구를 사용할 수 있습니다.
4
4
 
@@ -26,7 +26,7 @@ from .storage import (
26
26
  storage_from_env,
27
27
  )
28
28
 
29
- __version__ = "9.2.0"
29
+ __version__ = "9.4.0"
30
30
 
31
31
  __all__ = [
32
32
  "AgentRuntime",
@@ -21,7 +21,7 @@ from .contracts import multi_agent_contract
21
21
  from ..utils import now_iso as _now
22
22
 
23
23
 
24
- MULTI_AGENT_VERSION = "9.2.0"
24
+ MULTI_AGENT_VERSION = "9.4.0"
25
25
 
26
26
  AGENT_ROLES = ("researcher", "planner", "executor", "reviewer", "release")
27
27
  CORE_PIPELINE = ("planner", "executor", "reviewer")
@@ -1,3 +1,3 @@
1
1
  """Lattice AI - modular server package."""
2
2
 
3
- __version__ = "9.2.0"
3
+ __version__ = "9.4.0"
@@ -0,0 +1,129 @@
1
+ """Question-driven everyday automation API router (v9.4.0).
2
+
3
+ Exposes :class:`~latticeai.services.automation_intelligence.AutomationIntelligenceService`:
4
+ recurring-question patterns with evidence, automation suggestions (from the
5
+ user's own questions and connected knowledge folders), one-click consent-first
6
+ install, and a combined overview for the automation surface.
7
+
8
+ Installs follow the same consent contract as the starter recipes: the
9
+ workflow is created as a disabled draft (unless the user explicitly asks to
10
+ enable), review-queue gated, local-only, and idempotent per suggestion.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from typing import Any, Callable, Optional
16
+
17
+ from fastapi import APIRouter, HTTPException, Request
18
+ from pydantic import BaseModel
19
+
20
+ from latticeai.services.automation_intelligence import AutomationIntelligenceService
21
+ from latticeai.services.brain_automation import find_installed_recipe_workflow
22
+
23
+
24
+ class SuggestionInstallRequest(BaseModel):
25
+ suggestion_id: str
26
+ enabled: bool = False
27
+
28
+
29
+ def create_automation_intelligence_router(
30
+ *,
31
+ service: AutomationIntelligenceService,
32
+ store: Any,
33
+ require_user: Callable[[Request], str],
34
+ gate_read: Callable[[Request], Optional[str]],
35
+ gate_write: Callable[[Request], Optional[str]],
36
+ append_audit_event: Callable[..., None],
37
+ workspace_graph: Callable[[], Any],
38
+ ) -> APIRouter:
39
+ from lattice_brain.workflow import legacy_steps_from_nodes, validate_definition
40
+
41
+ router = APIRouter()
42
+
43
+ @router.get("/api/automation/patterns")
44
+ async def automation_patterns(request: Request):
45
+ user = require_user(request)
46
+ scope = gate_read(request)
47
+ return service.question_patterns(user_email=user, workspace_id=scope)
48
+
49
+ @router.get("/api/automation/suggestions")
50
+ async def automation_suggestions(request: Request):
51
+ user = require_user(request)
52
+ scope = gate_read(request)
53
+ return service.suggestions(user_email=user, workspace_id=scope)
54
+
55
+ @router.get("/api/automation/overview")
56
+ async def automation_overview(request: Request):
57
+ user = require_user(request)
58
+ scope = gate_read(request)
59
+ return service.overview(user_email=user, workspace_id=scope)
60
+
61
+ @router.post("/api/automation/install")
62
+ async def automation_install(req: SuggestionInstallRequest, request: Request):
63
+ user = require_user(request)
64
+ scope = gate_write(request)
65
+ suggestion = service.find_suggestion(
66
+ req.suggestion_id, user_email=user, workspace_id=scope
67
+ )
68
+ if suggestion is None:
69
+ raise HTTPException(
70
+ status_code=404,
71
+ detail=f"Automation suggestion not found: {req.suggestion_id}",
72
+ )
73
+ definition = service.build_suggestion_workflow(suggestion, enabled=req.enabled)
74
+
75
+ # Idempotent per suggestion: reuse the workflow provenance match used
76
+ # for recipes, keyed on suggestion_id instead of recipe_id.
77
+ existing = None
78
+ for workflow in store.list_workflows(workspace_id=scope).get("workflows") or []:
79
+ metadata = (workflow or {}).get("metadata") or {}
80
+ if (
81
+ metadata.get("created_from") == "automation_suggestion"
82
+ and metadata.get("suggestion_id") == req.suggestion_id
83
+ ):
84
+ existing = workflow
85
+ break
86
+ if existing is None and suggestion.get("recipe_id"):
87
+ existing = find_installed_recipe_workflow(
88
+ store.list_workflows(workspace_id=scope).get("workflows"),
89
+ suggestion["recipe_id"],
90
+ )
91
+ if existing is not None:
92
+ return {
93
+ "workflow": existing,
94
+ "suggestion": suggestion,
95
+ "enabled": bool((existing.get("metadata") or {}).get("automation_state") == "enabled"),
96
+ "already_installed": True,
97
+ }
98
+
99
+ errors = validate_definition({"name": definition["name"], "nodes": definition["nodes"]})
100
+ if errors:
101
+ raise HTTPException(status_code=400, detail={"validation_errors": errors})
102
+ workflow = store.create_workflow(
103
+ name=definition["name"],
104
+ steps=legacy_steps_from_nodes(definition["nodes"]),
105
+ nodes=definition["nodes"],
106
+ metadata=definition["metadata"],
107
+ user_email=user or None,
108
+ graph=workspace_graph(),
109
+ workspace_id=scope,
110
+ )
111
+ append_audit_event(
112
+ "automation_suggestion_installed",
113
+ user_email=user,
114
+ workflow_id=workflow.get("id"),
115
+ suggestion_id=req.suggestion_id,
116
+ suggestion_kind=suggestion.get("kind"),
117
+ enabled=bool(req.enabled),
118
+ )
119
+ return {
120
+ "workflow": workflow,
121
+ "suggestion": suggestion,
122
+ "enabled": bool(req.enabled),
123
+ "already_installed": False,
124
+ }
125
+
126
+ return router
127
+
128
+
129
+ __all__ = ["create_automation_intelligence_router"]
@@ -0,0 +1,68 @@
1
+ """Proactive Brain Intelligence API router (v9.3.0).
2
+
3
+ Exposes :class:`~latticeai.services.brain_intelligence.BrainIntelligenceService`:
4
+ health diagnosis, proactive insights, contradiction surfacing, and consent-first
5
+ consolidation. Read endpoints use the workspace read gate; consolidation with
6
+ ``apply=true`` is a write and is audited.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import Callable, Optional
12
+
13
+ from fastapi import APIRouter, Request
14
+ from pydantic import BaseModel
15
+
16
+ from latticeai.services.brain_intelligence import BrainIntelligenceService
17
+
18
+
19
+ class ConsolidateRequest(BaseModel):
20
+ apply: bool = False
21
+
22
+
23
+ def create_brain_intelligence_router(
24
+ *,
25
+ service: BrainIntelligenceService,
26
+ require_user: Callable[[Request], str],
27
+ gate_read: Callable[[Request], Optional[str]],
28
+ gate_write: Callable[[Request], Optional[str]],
29
+ append_audit_event: Callable[..., None],
30
+ ) -> APIRouter:
31
+ router = APIRouter()
32
+
33
+ @router.get("/api/brain/health")
34
+ async def brain_health(request: Request):
35
+ user = require_user(request)
36
+ scope = gate_read(request)
37
+ return service.health_report(user_email=user, workspace_id=scope)
38
+
39
+ @router.get("/api/brain/insights")
40
+ async def brain_insights(request: Request):
41
+ user = require_user(request)
42
+ scope = gate_read(request)
43
+ return service.insights(user_email=user, workspace_id=scope)
44
+
45
+ @router.get("/api/brain/contradictions")
46
+ async def brain_contradictions(request: Request):
47
+ user = require_user(request)
48
+ scope = gate_read(request)
49
+ return service.contradictions(user_email=user, workspace_id=scope)
50
+
51
+ @router.post("/api/brain/consolidate")
52
+ async def brain_consolidate(req: ConsolidateRequest, request: Request):
53
+ user = require_user(request)
54
+ scope = gate_write(request) if req.apply else gate_read(request)
55
+ result = service.consolidate(apply=req.apply, user_email=user, workspace_id=scope)
56
+ append_audit_event(
57
+ "brain_consolidate",
58
+ user_email=user,
59
+ mode=result.get("mode"),
60
+ duplicate_memories=result.get("duplicate_memory_count", 0),
61
+ pruned=result.get("pruned", 0),
62
+ )
63
+ return result
64
+
65
+ return router
66
+
67
+
68
+ __all__ = ["create_brain_intelligence_router"]
@@ -165,6 +165,8 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
165
165
  from latticeai.api.hooks import create_hooks_router
166
166
  from latticeai.core.product_hardening import build_product_hardening_status
167
167
  from latticeai.api.agent_registry import create_agent_registry_router
168
+ from latticeai.api.automation_intelligence import create_automation_intelligence_router
169
+ from latticeai.api.brain_intelligence import create_brain_intelligence_router
168
170
  from latticeai.api.memory import create_memory_router
169
171
  from latticeai.api.browser import create_browser_router
170
172
  from latticeai.api.portability import create_portability_router
@@ -383,6 +385,8 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
383
385
  TEMPLATE_CATALOG = _persistence_runtime["TEMPLATE_CATALOG"]
384
386
  AGENT_REGISTRY = _persistence_runtime["AGENT_REGISTRY"]
385
387
  MEMORY_SERVICE = _persistence_runtime["MEMORY_SERVICE"]
388
+ BRAIN_INTELLIGENCE = _persistence_runtime["BRAIN_INTELLIGENCE"]
389
+ AUTOMATION_INTELLIGENCE = _persistence_runtime["AUTOMATION_INTELLIGENCE"]
386
390
  INGESTION_PIPELINE = _persistence_runtime["INGESTION_PIPELINE"]
387
391
  DEVICE_IDENTITY = _persistence_runtime["DEVICE_IDENTITY"]
388
392
  KG_PORTABILITY = _persistence_runtime["KG_PORTABILITY"]
@@ -1017,6 +1021,17 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
1017
1021
  create_realtime_router=create_realtime_router,
1018
1022
  realtime_bus=REALTIME_BUS,
1019
1023
  )
1024
+ app.include_router(
1025
+ create_automation_intelligence_router(
1026
+ service=AUTOMATION_INTELLIGENCE,
1027
+ store=WORKSPACE_OS,
1028
+ require_user=require_user,
1029
+ gate_read=PLATFORM.gate_read,
1030
+ gate_write=PLATFORM.gate_write,
1031
+ append_audit_event=append_audit_event,
1032
+ workspace_graph=_workspace_graph,
1033
+ )
1034
+ )
1020
1035
 
1021
1036
 
1022
1037
  # ── Health & Info ──────────────────────────────────────────────────────────────
@@ -1114,6 +1129,7 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
1114
1129
  memory_service=MEMORY_SERVICE,
1115
1130
  platform=PLATFORM,
1116
1131
  active_model_getter=lambda: router.current_model_id or "",
1132
+ brain_intelligence=BRAIN_INTELLIGENCE,
1117
1133
  )
1118
1134
  register_interaction_routers(
1119
1135
  app,
@@ -1124,6 +1140,7 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
1124
1140
  create_hooks_router=create_hooks_router,
1125
1141
  create_agent_registry_router=create_agent_registry_router,
1126
1142
  create_memory_router=create_memory_router,
1143
+ create_brain_intelligence_router=create_brain_intelligence_router,
1127
1144
  )
1128
1145
 
1129
1146
  from latticeai.api.review_queue import create_review_queue_router
@@ -14,7 +14,7 @@ from pathlib import Path
14
14
  from typing import Any, Dict, List
15
15
 
16
16
 
17
- LEGACY_COMPATIBILITY_VERSION = "9.2.0"
17
+ LEGACY_COMPATIBILITY_VERSION = "9.4.0"
18
18
 
19
19
 
20
20
  @dataclass(frozen=True)
@@ -11,7 +11,7 @@ from copy import deepcopy
11
11
  from typing import Any, Dict, List, Optional
12
12
 
13
13
 
14
- MARKETPLACE_VERSION = "9.2.0"
14
+ MARKETPLACE_VERSION = "9.4.0"
15
15
  TEMPLATE_KINDS = ("plugin", "workflow", "agent", "ingestion_bridge")
16
16
 
17
17
 
@@ -49,7 +49,7 @@ __all__ = [
49
49
  "remove_skill_directory",
50
50
  ]
51
51
 
52
- WORKSPACE_OS_VERSION = "9.2.0"
52
+ WORKSPACE_OS_VERSION = "9.4.0"
53
53
 
54
54
  # Workspace types separate single-user Personal workspaces from shared
55
55
  # Organization workspaces. Both keep the same local-first JSON store; the type
@@ -65,6 +65,7 @@ def build_interaction_contexts(
65
65
  memory_service: Any,
66
66
  platform: Any,
67
67
  active_model_getter: Any = None,
68
+ brain_intelligence: Any = None,
68
69
  ) -> tuple[ToolRouterContext, InteractionRouterContext]:
69
70
  tool_router_context = ToolRouterContext(
70
71
  config=config,
@@ -105,6 +106,7 @@ def build_interaction_contexts(
105
106
  memory_service=memory_service,
106
107
  platform=platform,
107
108
  active_model_getter=active_model_getter,
109
+ brain_intelligence=brain_intelligence,
108
110
  )
109
111
  return tool_router_context, interaction_router_context
110
112