zeph_config/knowledge.rs
1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Knowledge-ingest configuration (`[knowledge]`).
5//!
6//! This module defines [`KnowledgeConfig`], the optional TOML section that controls
7//! the `zeph knowledge ingest` command (spec-067, Phase 1). All fields carry sane
8//! defaults so an existing config that omits `[knowledge]` entirely still works.
9//!
10//! # Configuration example
11//!
12//! ```toml
13//! [knowledge]
14//! ingest_provider = "fast" # from [[llm.providers]]; Phase 2 graph extraction
15//! concurrency = 3
16//! max_documents = 0 # 0 = unlimited
17//! recall_include_imported = true
18//! transcript_scope = "current-project"
19//! ```
20
21use serde::{Deserialize, Serialize};
22
23/// Configuration for the `zeph knowledge` subsystem (spec-067 Phase 1).
24///
25/// Deserialised from the optional `[knowledge]` table in `config.toml`.
26/// Missing fields fall back to [`Default`] values — no migration required for
27/// existing configs that omit the section entirely.
28#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
29#[serde(default)]
30pub struct KnowledgeConfig {
31 /// Provider name from `[[llm.providers]]` used for graph extraction (Phase 2).
32 ///
33 /// Empty string → fall back to `[memory.graph].extract_provider` → primary provider.
34 /// The notes-sink (Phase 1) does not perform LLM calls; this field is reserved for
35 /// Phase 2 graph extraction and ignored until then.
36 pub ingest_provider: String,
37
38 /// Maximum number of concurrent document-processing tasks during batch extraction (Phase 2).
39 ///
40 /// Has no effect in Phase 1 (notes sink processes files sequentially via
41 /// `IngestionPipeline`). Stored now for config stability.
42 pub concurrency: usize,
43
44 /// Maximum number of documents processed per `ingest` run; `0` = unlimited.
45 ///
46 /// The CLI `--max-documents` flag overrides this value when non-zero.
47 /// Bounds cost per run (spec-067 NFR-002).
48 pub max_documents: usize,
49
50 /// Whether semantic-recall results include rows imported via `zeph knowledge ingest`.
51 ///
52 /// When `false`, only conversation-derived memory rows are surfaced.
53 /// Phase 2 recall integration honours this flag; Phase 1 notes-sink writes use it
54 /// only to document intent.
55 pub recall_include_imported: bool,
56
57 /// Scope of transcript sources eligible for ingest.
58 ///
59 /// Only `"current-project"` is honoured in Phase 1 (INV-6: project-root-anchored
60 /// sources only). Other values are reserved for future cross-project modes.
61 pub transcript_scope: String,
62}
63
64impl Default for KnowledgeConfig {
65 fn default() -> Self {
66 Self {
67 ingest_provider: String::new(),
68 concurrency: 3,
69 max_documents: 0,
70 recall_include_imported: true,
71 transcript_scope: "current-project".to_owned(),
72 }
73 }
74}