ltcai 5.2.0 → 5.3.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.
@@ -36,11 +36,11 @@ export function FirstRunGuide() {
36
36
  const readyProfile = compatProfiles.some((item) => item.chat_compatible || item.quality_status === "ok" || item.quality_status === "degraded");
37
37
 
38
38
  const steps = [
39
- { label: "Make it yours", done: Boolean(profileData.email), icon: UserCircle, action: "account", detail: "Sign in or keep a local profile." },
39
+ { label: "Make it yours", done: Boolean(profileData.email), icon: UserCircle, action: "account", detail: "Choose the owner of this local AI Brain." },
40
40
  { label: "Choose a space", done: Boolean(registry.active_workspace || workspaceData.active_workspace), icon: Users, action: "workspace-admin", detail: "Decide where memories belong." },
41
- { label: "Meet your Mac", done: recs.isSuccess, icon: Cpu, action: "models", detail: "Let Lattice inspect what can run locally." },
42
- { label: "Pick a brain", done: Boolean(topPick || currentModel), icon: Library, action: "models", detail: "Use the recommended local model." },
43
- { label: "Install locally", done: Boolean(currentModel || loadedModels.length), icon: Download, action: "models", detail: "Download only with explicit consent." },
41
+ { label: "Meet your Mac", done: recs.isSuccess, icon: Cpu, action: "models", detail: "See what local Brain experience this computer can support." },
42
+ { label: "Pick a voice", done: Boolean(topPick || currentModel), icon: Library, action: "models", detail: "Use the recommended model without rebuilding memory later." },
43
+ { label: "Install with consent", done: Boolean(currentModel || loadedModels.length), icon: Download, action: "models", detail: "Download only after an explicit click." },
44
44
  { label: "Talk to Brain", done: Boolean(readyProfile || currentModel || loadedModels.length), icon: PlayCircle, action: "chat", detail: "Confirm the model can answer." },
45
45
  { label: "Set the pace", done: Boolean(mode), icon: SlidersHorizontal, action: "settings", detail: "Stay Calm or switch deeper." },
46
46
  { label: "Explore deeply", done: true, icon: Layers3, action: "knowledge-graph", detail: "Open advanced relationships." },
@@ -55,7 +55,7 @@ export function FirstRunGuide() {
55
55
  <div className="page-kicker"><CheckCircle2 className="h-4 w-4" /> First 10 minutes</div>
56
56
  <h2>Build your living Brain without guessing.</h2>
57
57
  <p>
58
- Start with a space, let Lattice recommend a private local model, then add the first pieces of knowledge.
58
+ Start with a local Brain, let Lattice recommend a model voice, then add the first pieces of durable knowledge.
59
59
  Every step keeps the next action visible.
60
60
  </p>
61
61
  <div className="arrival-actions">
@@ -531,7 +531,7 @@ function buildDetectedFacts(analysis: FlowAnalysis | null) {
531
531
  {
532
532
  label: "Computer",
533
533
  value: appleSilicon ? "Apple Silicon Mac" : friendlyOs(profile.os),
534
- detail: "Ready for local AI workspace use",
534
+ detail: "Ready for local Digital Brain use",
535
535
  },
536
536
  {
537
537
  label: "Memory",
@@ -13,11 +13,11 @@ export const COPY: Record<Language, TextMap> = {
13
13
  "language.ko": "한국어",
14
14
  "language.en": "English",
15
15
  "brain.level": "단계",
16
- "brain.depth.1": "Living Brain",
17
- "brain.depth.2": "Memory Layer",
18
- "brain.depth.3": "Knowledge Layer",
19
- "brain.depth.4": "Relationship Layer",
20
- "brain.depth.5": "Knowledge Graph",
16
+ "brain.depth.1": "지금 기억",
17
+ "brain.depth.2": "오래된 기억",
18
+ "brain.depth.3": "주제",
19
+ "brain.depth.4": "관계",
20
+ "brain.depth.5": "전체 지식 그래프",
21
21
  "brain.view.memories": "기억 보기",
22
22
  "brain.view.topics": "주제 보기",
23
23
  "brain.view.relationships": "관계 보기",
@@ -29,11 +29,11 @@ export const COPY: Record<Language, TextMap> = {
29
29
  "brain.private": "개인 소유",
30
30
  "brain.admin": "관리자 콘솔",
31
31
  "brain.empty.kicker": "내 오래가는 기억",
32
- "brain.empty.title": "잊으면 안 되는 일부터 말해 주세요.",
33
- "brain.empty.body": "문서, 대화, 프로젝트, 결정이 Brain에 쌓이고 나중에 주제와 관계로 다시 보입니다.",
34
- "brain.prompt.remember": "이 결정을 기억해줘: ",
35
- "brain.prompt.know": "내가 이미 알고 있는 것은? ",
36
- "brain.prompt.plan": " 프로젝트 맥락을 계획으로 바꿔줘: ",
32
+ "brain.empty.title": "잊으면 안 되는 맥락부터 말해 주세요.",
33
+ "brain.empty.body": "문서, 대화, 프로젝트, 결정이 이 컴퓨터의 Brain에 쌓이고 나중에 주제와 관계로 다시 보입니다.",
34
+ "brain.prompt.remember": "이 프로젝트 목표를 기억해줘: ",
35
+ "brain.prompt.know": " 문서를 Brain에 넣고 요약해줘: ",
36
+ "brain.prompt.plan": "지난 결정들을 나중에 찾을 있게 정리해줘: ",
37
37
  "brain.placeholder": "Brain에게 말하기...",
38
38
  "brain.image": "이미지",
39
39
  "brain.unavailable": "지금은 답할 수 없음",
@@ -75,16 +75,16 @@ export const COPY: Record<Language, TextMap> = {
75
75
  "admin.kicker": "분리된 관리자 작업공간",
76
76
  "admin.title": "Admin Console",
77
77
  "admin.body": "사용자, 로그, 보안, Brain 상태는 일반 사용자 화면과 분리됩니다.",
78
- "flow.shell": "내 로컬 Brain 만들기",
79
- "flow.login.title": "내 Brain을 시작합니다.",
80
- "flow.login.body": "모델은 바뀔 있지만,문서와 대화, 결정, 기억은 사라지면 됩니다. Lattice는 지식을 내가 소유하는 개인 Brain으로 모읍니다.",
78
+ "flow.shell": "내 로컬 AI 브레인 만들기",
79
+ "flow.login.title": "내 AI 브레인의 주인을 정합니다.",
80
+ "flow.login.body": "Lattice AI는 모델이 바뀌어도지식과 맥락을 보존하는 로컬 우선 AI 브레인입니다. 대화와 기억은 기본적으로 컴퓨터에 저장됩니다.",
81
81
  "flow.name": "이름",
82
82
  "flow.email": "이메일",
83
83
  "flow.password": "비밀번호",
84
84
  "flow.password.placeholder": "로컬 Brain 비밀번호",
85
85
  "flow.login.busy": "Brain 여는 중...",
86
86
  "flow.login.submit": "내 Brain 시작하기",
87
- "flow.login.note": "기존 Brain과 다른 이메일이면 새로 만들지 않고 먼저 확인합니다.",
87
+ "flow.login.note": "이 프로필은 내 AI 브레인의 주인입니다. 기존 Brain과 다른 이메일이면 새로 만들지 않고 먼저 확인합니다.",
88
88
  "flow.login.missing": "이름과 이메일, 비밀번호를 입력하면 기존 Brain을 안전하게 확인합니다.",
89
89
  "flow.login.otherEmail": "이 컴퓨터의 기존 Brain과 다른 이메일입니다. 오타인지 확인해 주세요.",
90
90
  "flow.login.wrongPassword": "기존 Brain 이메일은 맞지만 비밀번호가 다릅니다. 비밀번호를 다시 확인해 주세요.",
@@ -95,21 +95,21 @@ export const COPY: Record<Language, TextMap> = {
95
95
  "flow.promise.model.v": "모델은 목소리이고, 자산은 Brain입니다.",
96
96
  "flow.promise.ownership.k": "사용자 소유",
97
97
  "flow.promise.ownership.v": "백업, 복원, 이동이 가능합니다.",
98
- "flow.analysis.title": "이 컴퓨터를 확인합니다.",
99
- "flow.analysis.body": "Brain클라우드에 의존하지 않고 컴퓨터에서 편하게 돌아갈 있는지 확인합니다.",
98
+ "flow.analysis.title": "이 컴퓨터에서 가능한 경험을 확인합니다.",
99
+ "flow.analysis.body": "스펙 점수가 아니라, Mac에서 어떤 로컬 AI 브레인 경험이 편한지 알려드립니다. 클라우드 모델은 선택 사항입니다.",
100
100
  "flow.analysis.finding": "가장 편한 설정을 찾는 중...",
101
101
  "flow.analysis.ready": "추천 모델을 바로 시작할 수 있게 준비했습니다.",
102
102
  "flow.analysis.wait": "잠시만 기다리면 자동으로 정리됩니다.",
103
103
  "flow.analysis.error": "Lattice가 이 컴퓨터를 끝까지 확인하지 못했습니다. 그래도 안전한 기본값으로 계속할 수 있습니다.",
104
104
  "flow.analysis.continue": "추천 모델 보기",
105
- "flow.recommend.title": "추천 모델로 시작하세요.",
106
- "flow.recommend.body": "모델은 Brain의 현재 목소리입니다. 나중에 바꿔도 기억과 지식은 그대로 남습니다.",
105
+ "flow.recommend.title": "추천대로 시작하세요.",
106
+ "flow.recommend.body": "모델은 Brain의 현재 목소리입니다. 가장 안전한 추천, 빠른 모델, 더 강한 모델만 먼저 보여드립니다.",
107
107
  "flow.recommend.primary": "추천대로 시작하기",
108
108
  "flow.recommend.unsupported": "이 컴퓨터에서 추가 확인이 필요합니다",
109
109
  "flow.recommend.back": "뒤로",
110
110
  "flow.recommend.hint": "잘 모르겠다면 추천대로 시작하면 됩니다.",
111
111
  "flow.install.title": "모델을 설치하고 시작합니다.",
112
- "flow.install.body": "이 모델이 Brain의 로컬 목소리가 됩니다. 다운로드, 확인, 로드는 사용자가 누른 뒤에만 진행됩니다.",
112
+ "flow.install.body": "이 모델이 Brain의 로컬 목소리가 됩니다. 다운로드할 때만 인터넷이 필요하고, 실행은 컴퓨터에서 진행됩니다.",
113
113
  "flow.install.wait": "Brain이 사용할 모델을 기다리고 있습니다.",
114
114
  "flow.install.prepare": "Brain 준비 중입니다.",
115
115
  "flow.install.done": "Brain이 준비되었습니다.",
@@ -119,18 +119,18 @@ export const COPY: Record<Language, TextMap> = {
119
119
  "flow.install.start": "다운로드하고 시작하기",
120
120
  "flow.install.busy": "모델 준비 중...",
121
121
  "flow.install.enter": "Brain으로 들어가기",
122
- "flow.install.local": "모든 작업은 컴퓨터에서 진행됩니다.",
122
+ "flow.install.local": "모델 다운로드와 외부 통신은 사용자가 시작할 때만 진행됩니다.",
123
123
  },
124
124
  en: {
125
125
  "language.label": "Language",
126
126
  "language.ko": "한국어",
127
127
  "language.en": "English",
128
128
  "brain.level": "Level",
129
- "brain.depth.1": "Living Brain",
130
- "brain.depth.2": "Memory Layer",
131
- "brain.depth.3": "Knowledge Layer",
132
- "brain.depth.4": "Relationship Layer",
133
- "brain.depth.5": "Knowledge Graph",
129
+ "brain.depth.1": "Now memory",
130
+ "brain.depth.2": "Older memory",
131
+ "brain.depth.3": "Topics",
132
+ "brain.depth.4": "Relationships",
133
+ "brain.depth.5": "Full knowledge graph",
134
134
  "brain.view.memories": "Memories",
135
135
  "brain.view.topics": "Topics",
136
136
  "brain.view.relationships": "Relationships",
@@ -142,11 +142,11 @@ export const COPY: Record<Language, TextMap> = {
142
142
  "brain.private": "Private",
143
143
  "brain.admin": "Admin Console",
144
144
  "brain.empty.kicker": "Durable memory",
145
- "brain.empty.title": "Start with what should not be forgotten.",
146
- "brain.empty.body": "Documents, conversations, projects, and decisions accumulate in your Brain, then reappear as topics and relationships.",
147
- "brain.prompt.remember": "Remember this decision: ",
148
- "brain.prompt.know": "What do I already know about ",
149
- "brain.prompt.plan": "Turn this project context into a plan: ",
145
+ "brain.empty.title": "Start with context that should not be forgotten.",
146
+ "brain.empty.body": "Documents, conversations, projects, and decisions accumulate in the Brain on this computer, then reappear as topics and relationships.",
147
+ "brain.prompt.remember": "Remember this project goal: ",
148
+ "brain.prompt.know": "Put this document into my Brain and summarize it: ",
149
+ "brain.prompt.plan": "Organize past decisions so I can find them later: ",
150
150
  "brain.placeholder": "Talk to your Brain...",
151
151
  "brain.image": "Image",
152
152
  "brain.unavailable": "Unavailable",
@@ -188,16 +188,16 @@ export const COPY: Record<Language, TextMap> = {
188
188
  "admin.kicker": "Separate admin workspace",
189
189
  "admin.title": "Admin Console",
190
190
  "admin.body": "Users, logs, security, and Brain health stay out of the normal user experience.",
191
- "flow.shell": "Create your local Brain",
192
- "flow.login.title": "Start your Brain.",
193
- "flow.login.body": "Models can change, but your documents, conversations, decisions, and memories should stay yours. Lattice gathers them into a personal Brain you control.",
191
+ "flow.shell": "Create your local AI Brain",
192
+ "flow.login.title": "Choose the owner of your AI Brain.",
193
+ "flow.login.body": "Lattice AI is a local-first Digital Brain that keeps your knowledge durable across any AI model. Conversations and memories are stored on this computer by default.",
194
194
  "flow.name": "Name",
195
195
  "flow.email": "Email",
196
196
  "flow.password": "Password",
197
197
  "flow.password.placeholder": "Local Brain password",
198
198
  "flow.login.busy": "Opening Brain...",
199
199
  "flow.login.submit": "Start my Brain",
200
- "flow.login.note": "If the email differs from this computer's Brain, Lattice checks before creating anything new.",
200
+ "flow.login.note": "This profile owns your AI Brain. If the email differs from this computer's Brain, Lattice checks before creating anything new.",
201
201
  "flow.login.missing": "Enter your name, email, and password so Lattice can safely check your Brain.",
202
202
  "flow.login.otherEmail": "This email differs from the Brain on this computer. Please check for a typo.",
203
203
  "flow.login.wrongPassword": "The email matches this Brain, but the password is different. Please check it again.",
@@ -208,21 +208,21 @@ export const COPY: Record<Language, TextMap> = {
208
208
  "flow.promise.model.v": "The model is the voice; the Brain is the asset.",
209
209
  "flow.promise.ownership.k": "User owned",
210
210
  "flow.promise.ownership.v": "Back up, restore, and move it.",
211
- "flow.analysis.title": "Checking this computer.",
212
- "flow.analysis.body": "Lattice checks whether your Brain can run comfortably on this computer without depending on the cloud.",
211
+ "flow.analysis.title": "Checking what this computer can do.",
212
+ "flow.analysis.body": "This is not a spec test. Lattice explains what local AI Brain experience this Mac can support. Cloud models remain optional.",
213
213
  "flow.analysis.finding": "Finding the easiest setup...",
214
214
  "flow.analysis.ready": "Your recommended model is ready to start.",
215
215
  "flow.analysis.wait": "This will be summarized automatically in a moment.",
216
216
  "flow.analysis.error": "Lattice could not finish checking this computer. You can still continue with a safe default.",
217
217
  "flow.analysis.continue": "View recommended models",
218
- "flow.recommend.title": "Start with the recommended model.",
219
- "flow.recommend.body": "The model is your Brain's current voice. You can change it later without losing memory or knowledge.",
218
+ "flow.recommend.title": "Start with the recommendation.",
219
+ "flow.recommend.body": "The model is your Brain's current voice. You see the safest recommendation, a faster model, and a stronger model first.",
220
220
  "flow.recommend.primary": "Start with recommendation",
221
221
  "flow.recommend.unsupported": "This computer needs one more check",
222
222
  "flow.recommend.back": "Back",
223
223
  "flow.recommend.hint": "If unsure, start with the recommendation.",
224
224
  "flow.install.title": "Install the model and start.",
225
- "flow.install.body": "This model becomes your Brain's local voice. Download, validation, and loading begin only after you choose to start.",
225
+ "flow.install.body": "This model becomes your Brain's local voice. Internet is needed only for download; execution happens on this computer.",
226
226
  "flow.install.wait": "Waiting for the model your Brain will use.",
227
227
  "flow.install.prepare": "Preparing your Brain.",
228
228
  "flow.install.done": "Your Brain is ready.",
@@ -232,7 +232,7 @@ export const COPY: Record<Language, TextMap> = {
232
232
  "flow.install.start": "Download and start",
233
233
  "flow.install.busy": "Preparing model...",
234
234
  "flow.install.enter": "Enter Brain",
235
- "flow.install.local": "Everything runs on this computer.",
235
+ "flow.install.local": "Downloads and external communication start only when you choose them.",
236
236
  },
237
237
  };
238
238
 
@@ -30,8 +30,8 @@ export function LibraryPage({ initialTab }: { initialTab?: string }) {
30
30
  <div className="space-y-5">
31
31
  <header className="page-hero">
32
32
  <div className="page-kicker"><Boxes className="h-4 w-4" /> Library</div>
33
- <h1 className="page-title">Choose what powers Lattice.</h1>
34
- <p className="page-copy">Pick a private local model, add skills, and connect tools without learning runtime internals.</p>
33
+ <h1 className="page-title">Choose your Brain's voice.</h1>
34
+ <p className="page-copy">Start with a short local model recommendation. Your Brain and memories stay durable when you switch later.</p>
35
35
  </header>
36
36
  <Tabs tabs={visibleTabs} value={tab} onChange={(id) => setTab(id as LibraryTab)} />
37
37
  {tab === "models" ? <ModelsPanel /> : null}
@@ -103,7 +103,7 @@ function ModelsPanel() {
103
103
  return (
104
104
  <div className="grid gap-4 xl:grid-cols-[1.2fr_0.8fr]">
105
105
  <div className="space-y-4">
106
- <DataPanel title="Guided model setup" description="5.2 registry: hardware-fit multimodal models with HF verification, download/load strategies, and clear RAM notes. Analyze, consent, download only on click." result={recs.data}>
106
+ <DataPanel title="Guided model setup" description="Lattice recommends a small set first, explains internet/download needs, and keeps every model download behind consent." result={recs.data}>
107
107
  {(data) => {
108
108
  const recommendation = (data as Record<string, unknown>).recommendations as Record<string, unknown> | undefined;
109
109
  const profile = (data as Record<string, unknown>).profile as Record<string, unknown> | undefined;
@@ -134,7 +134,7 @@ function ModelsPanel() {
134
134
  <label className="flex items-start gap-2 rounded-lg border border-border bg-background/55 p-3 text-sm leading-6">
135
135
  <input className="mt-1" type="checkbox" checked={consent} onChange={(event) => setConsent(event.target.checked)} />
136
136
  <span>
137
- Allow Lattice to install a missing local model component or download model files for this action.
137
+ Allow Lattice to install a missing local model component or download model files for this action. Download uses the internet; running the model stays local.
138
138
  </span>
139
139
  </label>
140
140
  {latestProgress ? (
@@ -151,10 +151,10 @@ function ModelsPanel() {
151
151
  );
152
152
  }}
153
153
  </DataPanel>
154
- <DataPanel title="Recommended models" result={models.data}>
154
+ <DataPanel title={mode === "basic" ? "Recommended models" : "Recommended and advanced models"} result={models.data}>
155
155
  {(data) => (
156
156
  <div className="grid gap-2">
157
- {(catalog.length ? catalog : asArray<Record<string, unknown>>((data as Record<string, unknown>).loaded)).slice(0, 14).map((model, index) => {
157
+ {(catalog.length ? catalog : asArray<Record<string, unknown>>((data as Record<string, unknown>).loaded)).slice(0, mode === "basic" ? 3 : 14).map((model, index) => {
158
158
  const id = String(model.id || model.model_id || model.name || index);
159
159
  const loaded = asArray<string>((data as Record<string, unknown>).loaded).includes(id) || (data as Record<string, unknown>).current === id || model.state === "loaded";
160
160
  const loadId = String(model.recommended_load_id || id);
@@ -178,6 +178,8 @@ function ModelsPanel() {
178
178
  const actionLabel = String(compatibility.action || loadStatus.replace(/_/g, " "));
179
179
  const badgeLabel = unsupported && mode === "basic" ? "needs attention" : unsupported ? actionLabel : loadStatus;
180
180
  const canPrepare = loadAvailable || downloadRequired;
181
+ const downloadSize = model.download_size || model.estimated_size || recommendation.download_size || recommendation.estimated_size || model.size || recommendation.size;
182
+ const maker = model.provider || recommendation.provider || model.organization || recommendation.organization;
181
183
  return (
182
184
  <div key={id} className="grid gap-3 rounded-lg border border-border bg-background/55 p-4 md:grid-cols-[1fr_auto]">
183
185
  <div className="min-w-0">
@@ -200,6 +202,11 @@ function ModelsPanel() {
200
202
  {String(hardwareNote)}
201
203
  </div>
202
204
  ) : null}
205
+ <div className="mt-2 flex flex-wrap gap-1 text-[11px] text-muted-foreground">
206
+ <Badge variant="muted">{downloadRequired ? `Download: ${String(downloadSize || "required")}` : "No download needed now"}</Badge>
207
+ <Badge variant="muted">{downloadRequired ? "Internet only during download" : "Runs locally when loaded"}</Badge>
208
+ {maker ? <Badge variant="muted">{String(maker)}</Badge> : null}
209
+ </div>
203
210
  {unsupported ? (
204
211
  <div className="mt-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-sm">
205
212
  <div className="font-medium">{mode === "basic" ? "Needs attention before loading" : actionLabel}</div>
@@ -242,6 +249,11 @@ function ModelsPanel() {
242
249
  </div>
243
250
  );
244
251
  })}
252
+ {mode === "basic" && catalog.length > 3 ? (
253
+ <div className="rounded-lg border border-border bg-background/55 p-3 text-sm text-muted-foreground">
254
+ Showing the safest short list. Switch to Advanced for the full registry, runtime details, licenses, and safety notes.
255
+ </div>
256
+ ) : null}
245
257
  </div>
246
258
  )}
247
259
  </DataPanel>
@@ -26,7 +26,7 @@ from .storage import (
26
26
  storage_from_env,
27
27
  )
28
28
 
29
- __version__ = "5.2.0"
29
+ __version__ = "5.3.0"
30
30
 
31
31
  __all__ = [
32
32
  "AgentRuntime",
@@ -14,6 +14,7 @@ import io
14
14
  import json
15
15
  import os
16
16
  import shutil
17
+ import sqlite3
17
18
  import tempfile
18
19
  import zipfile
19
20
  from dataclasses import dataclass
@@ -111,6 +112,16 @@ def _sqlite_siblings(db_path: Path) -> tuple[Path, Path, Path]:
111
112
  return (db_path, Path(str(db_path) + "-wal"), Path(str(db_path) + "-shm"))
112
113
 
113
114
 
115
+ def _checkpoint_sqlite(db_path: Path) -> None:
116
+ if not db_path.exists():
117
+ return
118
+ try:
119
+ with sqlite3.connect(str(db_path)) as conn:
120
+ conn.execute("PRAGMA wal_checkpoint(FULL)")
121
+ except sqlite3.Error:
122
+ return
123
+
124
+
114
125
  def _restore_sibling(path: Path, backup: Path) -> None:
115
126
  if backup.exists():
116
127
  shutil.copy2(backup, path)
@@ -124,6 +135,7 @@ def _replace_sqlite_atomically(src: Path, dest: Path, backup_dir: Path) -> None:
124
135
  shutil.copyfile(src, tmp)
125
136
  backups: dict[Path, Path] = {}
126
137
  try:
138
+ _checkpoint_sqlite(dest)
127
139
  for sibling in _sqlite_siblings(dest):
128
140
  if sibling.exists():
129
141
  backup = backup_dir / sibling.name
@@ -17,6 +17,7 @@ import hashlib
17
17
  import json
18
18
  import os
19
19
  import shutil
20
+ import sqlite3
20
21
  import tempfile
21
22
  import zipfile
22
23
  from datetime import datetime, timezone
@@ -72,6 +73,18 @@ def _sqlite_siblings(db_path: Path) -> tuple[Path, Path, Path]:
72
73
  return (db_path, Path(str(db_path) + "-wal"), Path(str(db_path) + "-shm"))
73
74
 
74
75
 
76
+ def _checkpoint_sqlite(db_path: Path) -> None:
77
+ if not db_path.exists():
78
+ return
79
+ try:
80
+ with sqlite3.connect(str(db_path)) as conn:
81
+ conn.execute("PRAGMA wal_checkpoint(FULL)")
82
+ except sqlite3.Error:
83
+ # Best-effort only. Existing sibling backup/restore still preserves
84
+ # the WAL files if a live connection prevents a checkpoint.
85
+ return
86
+
87
+
75
88
  def _restore_sibling(path: Path, backup: Path) -> None:
76
89
  if backup.exists():
77
90
  shutil.copy2(backup, path)
@@ -85,6 +98,7 @@ def _replace_sqlite_atomically(src: Path, dest: Path, backup_dir: Path) -> None:
85
98
  shutil.copyfile(src, tmp)
86
99
  backups: dict[Path, Path] = {}
87
100
  try:
101
+ _checkpoint_sqlite(dest)
88
102
  # -wal/-shm are transient: another live connection can checkpoint and
89
103
  # remove them between exists() and the copy/unlink. Treat a vanished
90
104
  # sibling as "nothing to preserve" instead of crashing the restore.
@@ -14,7 +14,7 @@ from datetime import datetime
14
14
  from typing import Any, Callable, Dict, List, Optional
15
15
 
16
16
 
17
- MULTI_AGENT_VERSION = "5.2.0"
17
+ MULTI_AGENT_VERSION = "5.3.0"
18
18
 
19
19
  AGENT_ROLES = ("researcher", "planner", "executor", "reviewer", "release")
20
20
  CORE_PIPELINE = ("planner", "executor", "reviewer")
@@ -1,3 +1,3 @@
1
1
  """Lattice AI - modular server package."""
2
2
 
3
- __version__ = "5.2.0"
3
+ __version__ = "5.3.0"
@@ -17,90 +17,16 @@ from __future__ import annotations
17
17
  import threading
18
18
  from typing import TYPE_CHECKING, Any, Dict, List, Optional
19
19
 
20
+ from latticeai.runtime.brain_runtime import build_brain_runtime
21
+ from latticeai.runtime.config_runtime import build_config_runtime
22
+ from latticeai.runtime.security_runtime import build_security_runtime
23
+
20
24
  if TYPE_CHECKING: # imports for annotations only — keep module import light
21
25
  from fastapi import FastAPI
22
26
 
23
27
  from latticeai.core.config import Config
24
28
 
25
29
 
26
- def build_config_runtime(config: "Optional[Config]" = None) -> Dict[str, Any]:
27
- """Build the app configuration runtime without importing heavy model code."""
28
-
29
- from latticeai.core.config import Config
30
-
31
- cfg = config if config is not None else Config.from_env()
32
- return {
33
- "CONFIG": cfg,
34
- "APP_MODE": cfg.app_mode,
35
- "IS_PUBLIC_MODE": cfg.is_public,
36
- "DEFAULT_HOST": cfg.host,
37
- "DEFAULT_PORT": cfg.port,
38
- "NETWORK_EXPOSED": cfg.network_exposed,
39
- "ENABLE_TELEGRAM": cfg.enable_telegram,
40
- "ENABLE_GRAPH": cfg.enable_graph,
41
- "AUTOLOAD_MODELS": cfg.autoload_models,
42
- "MODEL_IDLE_UNLOAD_SECONDS": cfg.model_idle_unload_seconds,
43
- "ALLOW_LOCAL_MODELS": cfg.allow_local_models,
44
- "REQUIRE_AUTH": cfg.require_auth,
45
- "ALLOW_PLAINTEXT_API_KEYS": cfg.allow_plaintext_api_keys,
46
- "CORS_ALLOW_NETWORK": cfg.cors_allow_network,
47
- "CORS_EXTRA_ORIGINS": cfg.cors_extra_origins,
48
- "PUBLIC_MODEL": cfg.public_model,
49
- "LOCAL_MODEL": cfg.local_model,
50
- "LOCAL_DRAFT_MODEL": cfg.local_draft_model,
51
- }
52
-
53
-
54
- def build_security_runtime(config: "Config") -> Dict[str, Any]:
55
- """Build auth/security-derived runtime settings from the central config."""
56
-
57
- from latticeai.core.security import configure_trusted_proxies
58
-
59
- configure_trusted_proxies(config.trusted_proxies)
60
- return {
61
- "SSO_DISCOVERY_URL": config.sso_discovery_url,
62
- "SSO_CLIENT_ID": config.sso_client_id,
63
- "SSO_CLIENT_SECRET": config.sso_client_secret,
64
- "SSO_REDIRECT_URI": config.sso_redirect_uri,
65
- "SSO_PROVIDER_NAME": config.sso_provider_name,
66
- "RATE_LIMIT_ENABLED": config.rate_limit_enabled,
67
- "OPEN_REGISTRATION": config.open_registration,
68
- "INVITE_CODE": config.invite_code,
69
- "INVITE_GATE_ENABLED": config.invite_gate_enabled,
70
- }
71
-
72
-
73
- def build_brain_runtime(
74
- *,
75
- data_dir: Any,
76
- history_file: Any,
77
- enable_graph: bool,
78
- embedder: Any,
79
- storage_engine: Any,
80
- ) -> Dict[str, Any]:
81
- """Construct Brain Core storage/conversation primitives behind one seam."""
82
-
83
- from lattice_brain import BrainCore, ConversationStore
84
-
85
- brain_core = BrainCore.from_paths(
86
- data_dir,
87
- embedder=embedder.provider,
88
- storage_engine=storage_engine,
89
- ) if enable_graph else None
90
- knowledge_graph = brain_core.knowledge if brain_core is not None else None
91
- conversations = (
92
- brain_core.conversations
93
- if brain_core is not None
94
- else ConversationStore(data_dir / "knowledge_graph.sqlite")
95
- )
96
- conversations.import_legacy_json(history_file)
97
- return {
98
- "BRAIN_CORE": brain_core,
99
- "KNOWLEDGE_GRAPH": knowledge_graph,
100
- "CONVERSATIONS": conversations,
101
- }
102
-
103
-
104
30
  def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
105
31
  """The legacy ``server_app`` assembly, moved verbatim into function scope.
106
32
 
@@ -11,7 +11,7 @@ from copy import deepcopy
11
11
  from typing import Any, Dict, List, Optional
12
12
 
13
13
 
14
- MARKETPLACE_VERSION = "5.2.0"
14
+ MARKETPLACE_VERSION = "5.3.0"
15
15
  TEMPLATE_KINDS = ("plugin", "workflow", "agent")
16
16
 
17
17
 
@@ -19,7 +19,7 @@ from pathlib import Path
19
19
  from typing import Any, Callable, Dict, Iterable, List, Optional
20
20
 
21
21
 
22
- WORKSPACE_OS_VERSION = "5.2.0"
22
+ WORKSPACE_OS_VERSION = "5.3.0"
23
23
 
24
24
  # Workspace types separate single-user Personal workspaces from shared
25
25
  # Organization workspaces. Both keep the same local-first JSON store; the type
@@ -0,0 +1,2 @@
1
+ """Runtime assembly seams for the Lattice AI application factory."""
2
+
@@ -0,0 +1,41 @@
1
+ """Brain Core runtime assembly for app startup."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict
6
+
7
+
8
+ def build_brain_runtime(
9
+ *,
10
+ data_dir: Any,
11
+ history_file: Any,
12
+ enable_graph: bool,
13
+ embedder: Any,
14
+ storage_engine: Any,
15
+ ) -> Dict[str, Any]:
16
+ """Construct Brain Core storage/conversation primitives behind one seam."""
17
+
18
+ from lattice_brain import BrainCore, ConversationStore
19
+
20
+ brain_core = (
21
+ BrainCore.from_paths(
22
+ data_dir,
23
+ embedder=embedder.provider,
24
+ storage_engine=storage_engine,
25
+ )
26
+ if enable_graph
27
+ else None
28
+ )
29
+ knowledge_graph = brain_core.knowledge if brain_core is not None else None
30
+ conversations = (
31
+ brain_core.conversations
32
+ if brain_core is not None
33
+ else ConversationStore(data_dir / "knowledge_graph.sqlite")
34
+ )
35
+ conversations.import_legacy_json(history_file)
36
+ return {
37
+ "BRAIN_CORE": brain_core,
38
+ "KNOWLEDGE_GRAPH": knowledge_graph,
39
+ "CONVERSATIONS": conversations,
40
+ }
41
+
@@ -0,0 +1,36 @@
1
+ """Configuration runtime assembly for the FastAPI composition root."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any, Dict, Optional
6
+
7
+ if TYPE_CHECKING:
8
+ from latticeai.core.config import Config
9
+
10
+
11
+ def build_config_runtime(config: "Optional[Config]" = None) -> Dict[str, Any]:
12
+ """Build app configuration values without importing model/runtime code."""
13
+
14
+ from latticeai.core.config import Config
15
+
16
+ cfg = config if config is not None else Config.from_env()
17
+ return {
18
+ "CONFIG": cfg,
19
+ "APP_MODE": cfg.app_mode,
20
+ "IS_PUBLIC_MODE": cfg.is_public,
21
+ "DEFAULT_HOST": cfg.host,
22
+ "DEFAULT_PORT": cfg.port,
23
+ "NETWORK_EXPOSED": cfg.network_exposed,
24
+ "ENABLE_TELEGRAM": cfg.enable_telegram,
25
+ "ENABLE_GRAPH": cfg.enable_graph,
26
+ "AUTOLOAD_MODELS": cfg.autoload_models,
27
+ "MODEL_IDLE_UNLOAD_SECONDS": cfg.model_idle_unload_seconds,
28
+ "ALLOW_LOCAL_MODELS": cfg.allow_local_models,
29
+ "REQUIRE_AUTH": cfg.require_auth,
30
+ "ALLOW_PLAINTEXT_API_KEYS": cfg.allow_plaintext_api_keys,
31
+ "CORS_ALLOW_NETWORK": cfg.cors_allow_network,
32
+ "CORS_EXTRA_ORIGINS": cfg.cors_extra_origins,
33
+ "PUBLIC_MODEL": cfg.public_model,
34
+ "LOCAL_MODEL": cfg.local_model,
35
+ "LOCAL_DRAFT_MODEL": cfg.local_draft_model,
36
+ }
@@ -0,0 +1,27 @@
1
+ """Security runtime assembly for app startup."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any, Dict
6
+
7
+ if TYPE_CHECKING:
8
+ from latticeai.core.config import Config
9
+
10
+
11
+ def build_security_runtime(config: "Config") -> Dict[str, Any]:
12
+ """Build auth/security-derived runtime settings from the central config."""
13
+
14
+ from latticeai.core.security import configure_trusted_proxies
15
+
16
+ configure_trusted_proxies(config.trusted_proxies)
17
+ return {
18
+ "SSO_DISCOVERY_URL": config.sso_discovery_url,
19
+ "SSO_CLIENT_ID": config.sso_client_id,
20
+ "SSO_CLIENT_SECRET": config.sso_client_secret,
21
+ "SSO_REDIRECT_URI": config.sso_redirect_uri,
22
+ "SSO_PROVIDER_NAME": config.sso_provider_name,
23
+ "RATE_LIMIT_ENABLED": config.rate_limit_enabled,
24
+ "OPEN_REGISTRATION": config.open_registration,
25
+ "INVITE_CODE": config.invite_code,
26
+ "INVITE_GATE_ENABLED": config.invite_gate_enabled,
27
+ }
@@ -20,9 +20,8 @@ are never auto-fetched by the verifier. Large models (>12GB) explicitly note
20
20
 
21
21
  from __future__ import annotations
22
22
 
23
- import datetime as _dt
24
- from dataclasses import dataclass, asdict, field
25
- from typing import Any, Dict, List, Optional, Tuple
23
+ from dataclasses import dataclass, field
24
+ from typing import Any, Dict, List, Optional
26
25
 
27
26
 
28
27
  @dataclass(frozen=True)