ltcai 7.3.0 → 7.5.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 CHANGED
@@ -69,42 +69,42 @@ You need Lattice AI when:
69
69
  Choose the owner of the Brain. The profile is not a SaaS account by default; it
70
70
  is the local identity for the knowledge you keep.
71
71
 
72
- ![Login](output/release/v7.0.0/screenshots/01-login.png)
72
+ ![Login](output/release/v7.5.0/screenshots/01-login.png)
73
73
 
74
74
  ### 2. Environment Analysis
75
75
 
76
76
  See what kind of local AI experience this computer can support before choosing a
77
77
  model.
78
78
 
79
- ![Environment Analysis](output/release/v7.0.0/screenshots/02-environment-analysis.png)
79
+ ![Environment Analysis](output/release/v7.5.0/screenshots/02-environment-analysis.png)
80
80
 
81
81
  ### 3. Recommended Models
82
82
 
83
83
  Start with a short list: safest recommendation, faster model, stronger model.
84
84
  Advanced details stay available without overwhelming first-time users.
85
85
 
86
- ![Recommended Models](output/release/v7.0.0/screenshots/03-recommended-models.png)
86
+ ![Recommended Models](output/release/v7.5.0/screenshots/03-recommended-models.png)
87
87
 
88
88
  ### 4. Install And Load
89
89
 
90
90
  Download and load only after consent. Lattice explains model size, local
91
91
  execution, and network use before work starts.
92
92
 
93
- ![Install and Load](output/release/v7.0.0/screenshots/04-install-load-progress.png)
93
+ ![Install and Load](output/release/v7.5.0/screenshots/04-install-load-progress.png)
94
94
 
95
95
  ### 5. Brain Chat
96
96
 
97
97
  Talk normally. Useful decisions and context become memory, then appear later as
98
98
  topics, relationships, and graph structure.
99
99
 
100
- ![Brain Chat Home](output/release/v7.0.0/screenshots/05-brain-chat-home.png)
100
+ ![Brain Chat Home](output/release/v7.5.0/screenshots/05-brain-chat-home.png)
101
101
 
102
102
  ### 6. Review Center
103
103
 
104
104
  Automation results are staged for review before they become durable decisions.
105
105
  Snooze, unsnooze, run now, approve, and dismiss actions stay explicit.
106
106
 
107
- ![Review Center](output/release/v7.0.0/screenshots/13-review-center.png)
107
+ ![Review Center](output/release/v7.5.0/screenshots/13-review-center.png)
108
108
 
109
109
  ## Brain Depths
110
110
 
@@ -120,10 +120,10 @@ The user travels inward from everyday memory to deeper structure:
120
120
 
121
121
  Walkthrough:
122
122
 
123
- ![v7.0.0 Living Brain walkthrough](output/release/v7.0.0/gifs/v7.0.0-living-brain-walkthrough.gif)
123
+ ![v7.5.0 Living Brain walkthrough](output/release/v7.5.0/gifs/v7.5.0-living-brain-walkthrough.gif)
124
124
 
125
125
  Screenshot index and capture notes:
126
- [output/release/v7.0.0/SCREENSHOT_INDEX.md](output/release/v7.0.0/SCREENSHOT_INDEX.md)
126
+ [output/release/v7.5.0/SCREENSHOT_INDEX.md](output/release/v7.5.0/SCREENSHOT_INDEX.md)
127
127
 
128
128
  ## Install
129
129
 
@@ -200,32 +200,34 @@ See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for developer workflow details.
200
200
 
201
201
  ## Current Release
202
202
 
203
- The current release is **7.3.0 Runtime Contract & Retrieval Quality**:
204
-
205
- - Single-agent and multi-agent execution now share a serializable
206
- `agent-run-contract/v1` payload for run identity, mode, status, roles,
207
- timeline, retries, artifacts, and terminal state.
208
- - Agent runtime API responses include the shared contract, keeping real and
209
- simulated run history distinguishable as runtime extraction continues.
210
- - Brain quality evaluation now includes deterministic hybrid recall/ranking
211
- regression thresholds, not only "some recall exists" checks.
212
- - The 7.2.0 preview/diagnostics work remains the admin trust surface while
213
- 7.3.0 tightens the underlying run and retrieval contracts.
214
- - The roadmap focus is durability over model choice: knowledge, run evidence,
215
- and retrieval quality become measurable product assets.
216
-
217
- Expected artifacts for 7.3.0 release must use exact filenames:
218
-
219
- - `dist/ltcai-7.3.0-py3-none-any.whl`
220
- - `dist/ltcai-7.3.0.tar.gz`
221
- - `ltcai-7.3.0.tgz`
222
- - `dist/ltcai-7.3.0.vsix`
223
- - `src-tauri/target/release/bundle/dmg/Lattice AI_7.3.0_aarch64.dmg`
203
+ The current release is **7.5.0 Runtime Debt Burn-down & Release Risk Cleanup**:
204
+
205
+ - Agent runs, workflow runs, audit events, and realtime events now carry the
206
+ `agent-run-contract/v1` family envelope, so replay, admin review, and live
207
+ feeds can inspect run identity, runtime, status, timeline, and artifacts
208
+ through one contract shape.
209
+ - AgentRuntime and realtime API responses now expose compact `contracts` views
210
+ so downstream consumers can read the common envelope instead of re-parsing
211
+ surface-specific records.
212
+ - Brain quality evaluation now runs a real KnowledgeGraphStore + SearchService
213
+ corpus fixture with 250+ records, judged queries, recall, precision, NDCG,
214
+ and must-include hit-rate thresholds.
215
+ - Release risk cleanup removes stale-artifact upload ambiguity, clears npm audit
216
+ findings, and updates the Tauri 2 stack so the old `block v0.1.6`
217
+ future-incompatibility warning is gone.
218
+
219
+ Expected artifacts for 7.5.0 release must use exact filenames:
220
+
221
+ - `dist/ltcai-7.5.0-py3-none-any.whl`
222
+ - `dist/ltcai-7.5.0.tar.gz`
223
+ - `ltcai-7.5.0.tgz`
224
+ - `dist/ltcai-7.5.0.vsix`
225
+ - `src-tauri/target/release/bundle/dmg/Lattice AI_7.5.0_aarch64.dmg`
224
226
 
225
227
  Do not upload `dist/*`. Package registry publishing remains owner-run.
226
228
 
227
229
  See [docs/ROADMAP_RECOMMENDATIONS.md](docs/ROADMAP_RECOMMENDATIONS.md) for the
228
- strategic roadmap slice applied in 7.3.0 and the follow-up tracks.
230
+ strategic roadmap slices applied through 7.5.0 and the follow-up tracks.
229
231
 
230
232
  ## Known Limitations
231
233
 
@@ -242,6 +244,8 @@ strategic roadmap slice applied in 7.3.0 and the follow-up tracks.
242
244
 
243
245
  | Version | Theme |
244
246
  | --- | --- |
247
+ | 7.5.0 | Runtime Debt Burn-down & Release Risk Cleanup: API consumers get normalized contract views, retrieval quality uses a 250+ record corpus fixture, stale artifact risk is removed, npm audit is clean, and Tauri is updated past the old block warning |
248
+ | 7.4.0 | Runtime Contract Convergence & Corpus Retrieval: agent/workflow/audit/realtime records share the agent-run-contract/v1 family, and retrieval quality gates run against a real corpus-scale fixture |
245
249
  | 7.3.0 | Runtime Contract & Retrieval Quality: shared agent-run contract across runtimes plus deterministic hybrid recall/ranking regression gates |
246
250
  | 7.2.0 | Runtime Trust Baseline: agent run preview/readiness, simulation-mode guardrails, live ToolRegistry manifest/diagnostics, and tests for dispatch/governance/catalog drift |
247
251
  | 7.1.0 | Brain Usability Completion: clearer first-run onboarding, ingestion progress/emergence, richer graph controls, inline answer proof, workspace/profile/admin discovery, empty/error/consent feedback, and VS Code sync status |
package/docs/CHANGELOG.md CHANGED
@@ -4,6 +4,56 @@ 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
+ ## [7.5.0] - 2026-06-20
8
+
9
+ > Runtime Debt Burn-down & Release Risk Cleanup. Turns the 7.4.0 contract
10
+ > envelope into a consumed API surface, expands retrieval quality to a 250+
11
+ > record local corpus fixture, and removes release/security warnings.
12
+
13
+ ### Added
14
+ - `extract_contract`, `require_contract`, `contract_view`, and `contract_views`
15
+ helpers for consumers that need a surface-agnostic `agent-run-contract/v1`
16
+ projection.
17
+ - AgentRuntime status/list/detail/events and realtime feed responses now expose
18
+ compact `contracts` views alongside legacy payloads.
19
+ - Deterministic 250+ record retrieval benchmark corpus while keeping 12 judged
20
+ queries and real `KnowledgeGraphStore` + `SearchService` execution.
21
+ - Refreshed README release evidence screenshots and walkthrough GIF under
22
+ `output/release/v7.5.0/`.
23
+
24
+ ### Changed
25
+ - Tauri Rust/CLI dependencies are updated within the Tauri 2 line, removing the
26
+ old transitive `block v0.1.6` future-incompatibility warning.
27
+ - npm dependency overrides move `js-yaml` to a non-vulnerable version; `npm
28
+ audit` reports 0 vulnerabilities.
29
+ - CI lint compatibility is restored for the Brain quality gate script.
30
+ - Package/runtime/static metadata is synchronized to 7.5.0; package publish and
31
+ deployment remain owner-run only.
32
+
33
+ ## [7.4.0] - 2026-06-20
34
+
35
+ > Runtime Contract Convergence & Corpus Retrieval. Completes the
36
+ > agent-run-contract/v1 family across run storage, workflow execution, audit
37
+ > events, realtime events, and a real corpus-scale retrieval quality gate.
38
+
39
+ ### Added
40
+ - Persisted agent and workflow run rows now carry refreshed contract metadata
41
+ for queued, running, terminal, cancelled, and interrupted states.
42
+ - Workflow engine results, replay payloads, audit log events, and realtime SSE
43
+ feed events now expose the same `agent-run-contract/v1` family envelope while
44
+ preserving existing top-level compatibility fields.
45
+ - Corpus-scale retrieval fixture with 30+ documents, judged queries,
46
+ must-include expectations, and thresholds for recall, precision, NDCG, and
47
+ hit rate.
48
+ - `scripts/brain_quality_eval.py` now exercises the real local
49
+ `KnowledgeGraphStore` + `SearchService` hybrid retrieval path before scoring.
50
+
51
+ ### Changed
52
+ - `RetrievalBenchmarkRunner` reports dynamic metric aliases for the selected
53
+ `top_k` and a `must_include_hit_rate`.
54
+ - Package/runtime/static metadata is synchronized to 7.4.0; package publish and
55
+ deployment remain owner-run only.
56
+
7
57
  ## [7.3.0] - 2026-06-20
8
58
 
9
59
  > Runtime Contract & Retrieval Quality. Turns the next AgentRuntime extraction
@@ -16,12 +16,38 @@ small release-sized work. The operating principle stays unchanged:
16
16
  - Security and trust: run contracts distinguish runtime type and execution mode
17
17
  so simulated output is not presented as real execution.
18
18
 
19
+ ## 7.4.0 Applied Slice
20
+
21
+ 7.4.0 completes the next roadmap slice without deferring it:
22
+
23
+ - Runtime convergence: agent runs, workflow runs, audit events, and realtime
24
+ events all expose the `agent-run-contract/v1` family envelope while keeping
25
+ legacy top-level fields for compatibility.
26
+ - Trust and operations: persisted run rows refresh their contract through
27
+ queued, running, terminal, cancelled, and interrupted states; audit events are
28
+ contracted only after secret redaction.
29
+ - Retrieval quality and scale: the CI quality gate now seeds a real local
30
+ Knowledge Graph corpus and scores SearchService hybrid retrieval with judged
31
+ queries, recall, precision, NDCG, and must-include hit-rate thresholds.
32
+
33
+ ## 7.5.0 Applied Slice
34
+
35
+ 7.5.0 burns down the remaining 7.4.0 risk instead of deferring it:
36
+
37
+ - Contract consumption: AgentRuntime and realtime feed APIs now emit compact
38
+ `contracts` views so UI, replay, admin, and export consumers can depend on the
39
+ shared family envelope directly.
40
+ - Retrieval scale: the corpus fixture now runs against 250+ local records while
41
+ keeping judged queries, graded relevance, and must-include expectations.
42
+ - Release trust: stale artifact mixing is handled through clean exact-version
43
+ artifact generation, npm audit findings are cleared, and the Tauri 2 stack is
44
+ updated past the old `block v0.1.6` future-incompatibility warning.
45
+
19
46
  ## Near-Term Tracks
20
47
 
21
48
  1. Retrieval quality and scale
22
- - Expand fixture datasets for hybrid search.
23
- - Add latency budgets for large corpora.
24
- - Track recall, precision, and ranking regressions in CI.
49
+ - Add latency budgets for larger corpora.
50
+ - Track per-channel keyword/vector/graph diagnostics in CI.
25
51
  - Tune semantic/graph/keyword fusion by query class.
26
52
 
27
53
  2. Incremental ingestion
@@ -30,8 +56,8 @@ small release-sized work. The operating principle stays unchanged:
30
56
  - Surface conflict resolution for contradictory memories.
31
57
 
32
58
  3. Runtime convergence
33
- - Use `agent-run-contract/v1` across single-agent, multi-agent, workflows,
34
- audit logs, and UI event streams.
59
+ - Migrate remaining UI run/replay/admin components to read the API-level
60
+ compact contract views as their primary source.
35
61
  - Keep simulation mode explicit and never record it as product success.
36
62
  - Route tools through explicit registry/governance contracts.
37
63
 
@@ -26,7 +26,7 @@ from .storage import (
26
26
  storage_from_env,
27
27
  )
28
28
 
29
- __version__ = "7.3.0"
29
+ __version__ = "7.5.0"
30
30
 
31
31
  __all__ = [
32
32
  "AgentRuntime",
@@ -285,6 +285,18 @@ class StructuredContextAssembler:
285
285
  # -----------------------------
286
286
  # 6. Retrieval Benchmark Fixture Runner
287
287
  # -----------------------------
288
+ def _relevance_grades(relevant: Any) -> Dict[str, float]:
289
+ """Normalize a ``relevant`` spec into a ``{doc_id: grade}`` map.
290
+
291
+ Accepts a graded dict (``{"doc": 3}``) or a binary list/set/tuple (grade 1
292
+ for every id), so judged fixtures can express graded relevance for nDCG
293
+ while older binary fixtures keep working unchanged.
294
+ """
295
+ if isinstance(relevant, dict):
296
+ return {str(k): float(v) for k, v in relevant.items()}
297
+ return {str(doc_id): 1.0 for doc_id in (relevant or [])}
298
+
299
+
288
300
  class RetrievalBenchmarkRunner:
289
301
  def __init__(self):
290
302
  self.results: List[Dict] = []
@@ -297,25 +309,36 @@ class RetrievalBenchmarkRunner:
297
309
  precisions = []
298
310
  ndcgs = []
299
311
  for query in judged:
300
- relevant = set(query.get("relevant") or [])
312
+ grades = _relevance_grades(query.get("relevant"))
313
+ relevant = set(grades)
301
314
  retrieved = list(query.get("retrieved") or [])[:top_k]
302
315
  if not relevant:
303
316
  continue
304
317
  hits = [doc_id for doc_id in retrieved if doc_id in relevant]
305
318
  recalls.append(len(hits) / len(relevant))
306
319
  precisions.append(len(hits) / max(1, len(retrieved)))
320
+ # Graded DCG: each retrieved doc contributes its relevance grade
321
+ # discounted by log2(rank + 2). IDCG ranks the highest grades
322
+ # first, so nDCG rewards putting the *most* relevant docs on top.
323
+ # Binary fixtures fall back to grade 1 via _relevance_grades.
307
324
  dcg = sum(
308
- 1.0 / math.log2(rank + 2)
325
+ grades.get(doc_id, 0.0) / math.log2(rank + 2)
309
326
  for rank, doc_id in enumerate(retrieved)
310
- if doc_id in relevant
311
327
  )
312
- ideal = sum(1.0 / math.log2(rank + 2) for rank in range(min(len(relevant), top_k)))
328
+ ideal_grades = sorted(grades.values(), reverse=True)[:top_k]
329
+ ideal = sum(g / math.log2(rank + 2) for rank, g in enumerate(ideal_grades))
313
330
  ndcgs.append(dcg / ideal if ideal else 0.0)
314
331
  recall = sum(recalls) / len(recalls) if recalls else 0.0
315
332
  precision = sum(precisions) / len(precisions) if precisions else 0.0
316
333
  ndcg = sum(ndcgs) / len(ndcgs) if ndcgs else 0.0
317
334
  else:
318
335
  recall = precision = ndcg = 0.0
336
+ must_include = [
337
+ bool(set(query.get("must_include") or []).intersection(set(list(query.get("retrieved") or [])[:top_k])))
338
+ for query in judged
339
+ if query.get("must_include")
340
+ ]
341
+ must_include_hit_rate = sum(1 for hit in must_include if hit) / len(must_include) if must_include else 1.0
319
342
  metrics = {
320
343
  "fixture": fixture_name,
321
344
  "queries": len(queries),
@@ -323,6 +346,10 @@ class RetrievalBenchmarkRunner:
323
346
  "recall@5": round(recall, 4),
324
347
  "precision@5": round(precision, 4),
325
348
  "ndcg@5": round(ndcg, 4),
349
+ f"recall@{top_k}": round(recall, 4),
350
+ f"precision@{top_k}": round(precision, 4),
351
+ f"ndcg@{top_k}": round(ndcg, 4),
352
+ "must_include_hit_rate": round(must_include_hit_rate, 4),
326
353
  "top_k": top_k,
327
354
  "judged": len(judged),
328
355
  }
@@ -0,0 +1,92 @@
1
+ """Corpus-scale retrieval fixture for the 7.5.0 Brain quality gate."""
2
+
3
+ from __future__ import annotations
4
+
5
+ FIXTURE_NAME = "7.5.0-corpus-scale-hybrid-retrieval"
6
+ TOP_K = 5
7
+
8
+ CORE_DOCUMENTS = [
9
+ {"id": "doc:agent-runtime-contract", "type": "Decision", "title": "Agent runtime contract", "content": "Workflow run, agent run, audit event, and realtime event records must carry the agent-run-contract/v1 family envelope with run id, runtime, status, timeline, and artifacts."},
10
+ {"id": "doc:workflow-observability", "type": "Document", "title": "Workflow observability", "content": "Workflow Designer persists queued, running, awaiting approval, cancelled, interrupted, partial, failed, and ok runs with replayable timeline events."},
11
+ {"id": "doc:audit-trust", "type": "Security", "title": "Audit trust", "content": "Audit events are append-only, redacted before persistence, and linked to execution contracts for admin review without leaking secrets."},
12
+ {"id": "doc:realtime-feed", "type": "Document", "title": "Realtime execution feed", "content": "The realtime SSE bus publishes workspace, agent, workflow, and execution events with workspace scope, event type, payload, sequence, and contract metadata."},
13
+ {"id": "doc:retrieval-benchmark", "type": "Benchmark", "title": "Retrieval benchmark strategy", "content": "Hybrid retrieval quality must be checked with corpus-scale fixtures, judged queries, recall, precision, ndcg, and must-include hit rate."},
14
+ {"id": "doc:hybrid-search", "type": "Architecture", "title": "Hybrid search", "content": "SearchService fuses keyword, vector, and graph retrieval channels with weighted scores and scoped workspace filtering."},
15
+ {"id": "doc:knowledge-graph", "type": "Architecture", "title": "Knowledge graph stabilization", "content": "The Knowledge Graph preserves legacy read compatibility, non-destructive migrations, vector indexing, relationship traversal, and provenance."},
16
+ {"id": "doc:local-first", "type": "Strategy", "title": "Local-first product wedge", "content": "Lattice AI is local-first: durable knowledge, private workspace memory, local LLM routing, and model-independent context are the product wedge."},
17
+ {"id": "doc:brain-proof", "type": "UX", "title": "Brain proof and citations", "content": "Brain proof shows durable recall, source citation, graph counts, vector counts, and model continuity evidence in chat."},
18
+ {"id": "doc:onboarding", "type": "UX", "title": "Five minute onboarding loop", "content": "The first loop asks users to add a source, ask a question, see Brain proof, and understand expected installation time."},
19
+ {"id": "doc:vscode-sync", "type": "Integration", "title": "VS Code extension state", "content": "VS Code extension integration shows app connection state, indexing status, command routing, and extension-to-app sync health."},
20
+ {"id": "doc:workspace-admin", "type": "Workspace", "title": "Workspace profile admin discovery", "content": "Personal workspace, organization workspace, profile, admin, members, roles, permissions, and security surfaces must be discoverable."},
21
+ {"id": "doc:empty-error-consent", "type": "UX", "title": "Empty error consent states", "content": "Empty states, error states, consent prompts, retries, and privacy feedback should be explicit across ingestion, graph, chat, and workspace flows."},
22
+ {"id": "doc:tool-registry", "type": "Architecture", "title": "Tool registry separation", "content": "ToolRegistry separates tool definitions, permissions, dispatch, audit, and UI discovery from AgentRuntime orchestration."},
23
+ {"id": "doc:config-centralization", "type": "Architecture", "title": "Config centralization", "content": "Configuration should be centralized into explicit objects instead of hidden globals so runtime, tests, and packaging are predictable."},
24
+ {"id": "doc:server-decomposition", "type": "Architecture", "title": "Server decomposition", "content": "Server decomposition moves routers, services, runtime context, and persistence seams into focused modules with dependency injection."},
25
+ {"id": "doc:incremental-ingestion", "type": "Pipeline", "title": "Incremental ingestion", "content": "Background indexing needs duplicate detection, conflict resolution, incremental updates, and merge behavior for large personal corpora."},
26
+ {"id": "doc:vector-index-evolution", "type": "Pipeline", "title": "Vector index evolution", "content": "sqlite-vec migration, HNSW evaluation, query caching, embedding caching, and retrieval caching support larger corpora."},
27
+ {"id": "doc:security-zero-trust", "type": "Security", "title": "Zero trust defaults", "content": "Zero-trust defaults include audit logging, secret redaction, dependency vulnerability monitoring, and automated security scanning."},
28
+ {"id": "doc:agentic-hitl", "type": "Workflow", "title": "Agentic human review", "content": "Agentic workflows need human-in-the-loop review, approval gates, rollback paths, review queues, and auditable decisions."},
29
+ {"id": "doc:temporal-reasoning", "type": "Brain", "title": "Temporal reasoning", "content": "Temporal graph states, historical memory, contradiction detection, synthesis, and recommendations make the Brain proactive."},
30
+ {"id": "doc:multimodal-memory", "type": "Brain", "title": "Multimodal memory", "content": "Images, audio, video, documents, and chat should ingest into one durable Brain with retrieval and citation proof."},
31
+ {"id": "doc:developer-api", "type": "API", "title": "Developer API", "content": "A secure developer API exposes third-party access to workspace knowledge, tools, runs, contracts, and audit trails."},
32
+ {"id": "doc:team-brains", "type": "Business", "title": "Team Brains", "content": "Team Brains, encrypted sharing, premium cloud sync, hosted models, plugin marketplace, and public benchmarks support monetization."},
33
+ {"id": "doc:docker-tauri", "type": "Deployment", "title": "Deployment operations", "content": "Docker Compose deployment, one-click installation, Tauri auto-updates, rollback support, and exact release artifacts improve operations."},
34
+ {"id": "doc:model-routing", "type": "Runtime", "title": "Model orchestration", "content": "Ollama, LM Studio, MLX, and cloud models need automatic fallback, routing, and replaceable model boundaries."},
35
+ {"id": "doc:strict-quality", "type": "Quality", "title": "Strict code quality", "content": "Async-first architecture, dependency injection, centralized exceptions, mypy or pyright, TypeScript strict mode, E2E tests, and property tests reduce regressions."},
36
+ {"id": "distractor:theme-editor", "type": "Distractor", "title": "Theme editor", "content": "Color palettes, typography, and sidebar icon sizing are useful visual polish topics."},
37
+ {"id": "distractor:calendar", "type": "Distractor", "title": "Calendar reminders", "content": "Calendar reminders and meeting agenda formatting are productivity integrations."},
38
+ {"id": "distractor:billing", "type": "Distractor", "title": "Billing invoices", "content": "Invoices, payment receipts, and subscription emails can be stored but are not the Brain quality gate."},
39
+ {"id": "distractor:mobile-shell", "type": "Distractor", "title": "Mobile shell", "content": "A mobile companion can improve access with push notifications and offline cache."},
40
+ {"id": "distractor:marketing", "type": "Distractor", "title": "Marketing landing page", "content": "Landing pages and hero copy shape positioning and campaign messaging."},
41
+ ]
42
+
43
+ _DISTRACTOR_TOPICS = [
44
+ ("finance", "quarterly planning", "budget variance vendor renewal procurement forecast"),
45
+ ("design", "component polish", "spacing typography icon density color token accessibility"),
46
+ ("support", "customer escalation", "ticket triage priority response macro satisfaction"),
47
+ ("ops", "incident rotation", "oncall handoff status page maintenance window"),
48
+ ("sales", "pipeline review", "lead scoring opportunity stage forecast account"),
49
+ ("calendar", "meeting schedule", "agenda reminder availability invite followup"),
50
+ ("email", "inbox policy", "thread label archive template unsubscribe"),
51
+ ("mobile", "companion shell", "push notification offline cache deep link"),
52
+ ("billing", "invoice lifecycle", "receipt tax subscription entitlement payment"),
53
+ ("analytics", "dashboard report", "cohort funnel metric annotation export"),
54
+ ("theme", "appearance settings", "palette contrast sidebar density motion"),
55
+ ("legal", "compliance packet", "clause obligation renewal signature counterparty"),
56
+ ]
57
+
58
+
59
+ def _generated_distractors() -> list[dict[str, str]]:
60
+ """Create a deterministic local corpus large enough to exercise ranking."""
61
+ docs: list[dict[str, str]] = []
62
+ for batch in range(20):
63
+ for topic, title, terms in _DISTRACTOR_TOPICS:
64
+ docs.append({
65
+ "id": f"distractor:{topic}:{batch:02d}",
66
+ "type": "Distractor",
67
+ "title": f"{title.title()} {batch + 1}",
68
+ "content": (
69
+ f"{title} note {batch + 1}. This record discusses {terms}. "
70
+ "It is intentionally unrelated to the judged Brain quality topics "
71
+ "and exists to make local ranking tests compete against realistic noise."
72
+ ),
73
+ })
74
+ return docs
75
+
76
+
77
+ DOCUMENTS = CORE_DOCUMENTS + _generated_distractors()
78
+
79
+ QUERIES = [
80
+ {"query": "agent workflow audit realtime contract run status timeline", "relevant": {"doc:agent-runtime-contract": 3, "doc:workflow-observability": 2, "doc:audit-trust": 2, "doc:realtime-feed": 2}, "must_include": ["doc:agent-runtime-contract"]},
81
+ {"query": "workflow queued running cancelled interrupted replay approval", "relevant": {"doc:workflow-observability": 3, "doc:agentic-hitl": 2}, "must_include": ["doc:workflow-observability"]},
82
+ {"query": "audit log redacted secrets admin review contract", "relevant": {"doc:audit-trust": 3}, "must_include": ["doc:audit-trust"]},
83
+ {"query": "SSE realtime workspace event payload sequence contract", "relevant": {"doc:realtime-feed": 3, "doc:agent-runtime-contract": 2}, "must_include": ["doc:realtime-feed"]},
84
+ {"query": "hybrid retrieval keyword vector graph weighted scoped search", "relevant": {"doc:hybrid-search": 3, "doc:knowledge-graph": 2, "doc:retrieval-benchmark": 2}, "must_include": ["doc:hybrid-search"]},
85
+ {"query": "corpus scale recall precision ndcg judged queries", "relevant": {"doc:retrieval-benchmark": 3}, "must_include": ["doc:retrieval-benchmark"]},
86
+ {"query": "local first model independent durable memory brain proof citation", "relevant": {"doc:local-first": 3, "doc:brain-proof": 2}, "must_include": ["doc:local-first"]},
87
+ {"query": "incremental indexing duplicate conflict merge background ingestion", "relevant": {"doc:incremental-ingestion": 3}, "must_include": ["doc:incremental-ingestion"]},
88
+ {"query": "workspace admin profile organization members roles permissions", "relevant": {"doc:workspace-admin": 3}, "must_include": ["doc:workspace-admin"]},
89
+ {"query": "tool registry separation dependency injection runtime context", "relevant": {"doc:tool-registry": 3, "doc:server-decomposition": 2, "doc:config-centralization": 2}, "must_include": ["doc:tool-registry"]},
90
+ {"query": "human in the loop approval review queue rollback", "relevant": {"doc:agentic-hitl": 3}, "must_include": ["doc:agentic-hitl"]},
91
+ {"query": "model routing ollama lm studio mlx cloud fallback replaceable", "relevant": {"doc:model-routing": 3, "doc:local-first": 2}, "must_include": ["doc:model-routing"]},
92
+ ]
@@ -37,7 +37,7 @@ from .multi_agent import (
37
37
  MULTI_AGENT_VERSION,
38
38
  ROLE_AGENT_IDS,
39
39
  )
40
- from .contracts import multi_agent_contract
40
+ from .contracts import contract_view, contract_views, extract_contract, multi_agent_contract
41
41
 
42
42
  ROLE_DESCRIPTIONS = {
43
43
  "researcher": "Gathers workspace context and memory for the goal.",
@@ -227,6 +227,7 @@ class AgentRuntime:
227
227
  "roles": self.roles(),
228
228
  "agents": self._roster(runs),
229
229
  "runs": runs[:25],
230
+ "contracts": contract_views(runs[:25]),
230
231
  }
231
232
 
232
233
  def preview(
@@ -282,13 +283,27 @@ class AgentRuntime:
282
283
 
283
284
  # ── events / state ────────────────────────────────────────────────────
284
285
  def list_runs(self, *, scope: Optional[str] = None) -> Dict[str, Any]:
285
- return self._store.list_agents(workspace_id=scope)
286
+ listing = self._store.list_agents(workspace_id=scope)
287
+ runs = list(listing.get("runs") or [])
288
+ payload = dict(listing)
289
+ payload["contracts"] = contract_views(runs)
290
+ return payload
286
291
 
287
292
  def get_run(self, run_id: str, *, scope: Optional[str] = None) -> Dict[str, Any]:
288
- return {"run": self._store.get_agent_run(run_id, workspace_id=scope)}
293
+ run = self._store.get_agent_run(run_id, workspace_id=scope)
294
+ payload = {"run": run}
295
+ contract = extract_contract(run)
296
+ if contract is not None:
297
+ payload["contract"] = contract_view(contract)
298
+ return payload
289
299
 
290
300
  def replay(self, run_id: str, *, scope: Optional[str] = None) -> Dict[str, Any]:
291
- return {"replay": self._store.replay_agent_run(run_id, workspace_id=scope)}
301
+ replay = self._store.replay_agent_run(run_id, workspace_id=scope)
302
+ payload = {"replay": replay}
303
+ contract = extract_contract(replay)
304
+ if contract is not None:
305
+ payload["contract"] = contract_view(contract)
306
+ return payload
292
307
 
293
308
  def events(self, run_id: str, *, scope: Optional[str] = None) -> Dict[str, Any]:
294
309
  run = self._store.get_agent_run(run_id, workspace_id=scope)
@@ -300,6 +315,7 @@ class AgentRuntime:
300
315
  "current_role": run.get("current_role"),
301
316
  "timeline": run.get("timeline") or [],
302
317
  "handoffs": run.get("handoffs") or [],
318
+ "contract": contract_view(run),
303
319
  }
304
320
 
305
321
  # ── execution ─────────────────────────────────────────────────────────