Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
Feat/l2 chunk size (#6660)
ShaoZegangByte5e0ed4305a19
diff --git a/docs/en/concepts/03-context-layers.md b/docs/en/concepts/03-context-layers.mdindex 2048e723c..5380b1af2 100644--- a/docs/en/concepts/03-context-layers.md+++ b/docs/en/concepts/03-context-layers.md@@ -148,7 +148,7 @@ API authentication guide covering OAuth 2.0, JWT tokens, and API keys.- `unsampled_entries`: direct entries not sampled, with `sampled + unsampled = total`.- `pending_child_changes`: direct-child change events not yet reflected in the current body (repeated changes to one child count separately).-When the direct-entry count exceeds `semantic.overview_sample_limit` (32 by default), OpenViking uses deterministic, order-preserving stable sampling. Repeated refreshes of an unchanged tree choose the same sample, reducing differences caused by sampling. Model-generated text can still change between refreshes.+Summary generation collects all direct-child summaries without a count cap. The existing overview budget remains 60000 characters by default; oversized summary inputs are batched or truncated. `semantic.overview_sample_limit` remains only a small-directory threshold for freshness scheduling.`pending_child_changes > 0` means the body is still readable but is known to lag behind lower-level changes. A successful parent refresh resets the value to 0 as part of the new coverage metadata.diff --git a/docs/en/concepts/06-extraction.md b/docs/en/concepts/06-extraction.mdindex f09714677..945f7542f 100644--- a/docs/en/concepts/06-extraction.md+++ b/docs/en/concepts/06-extraction.md@@ -40,7 +40,7 @@ The internal `registry.parse()` interface is asynchronous and returns a `ParseRe### Document Splitting-The Markdown parser organizes sections by headings and size, merging short sections and splitting oversized content. Defaults are `max_section_size=2048` tokens and `max_section_chars=6000` characters. The configuration also declares `section_size_flexibility=0.3`, but the current Markdown splitting code does not use it. A single oversized table row may remain intact. These are splitting targets, not absolute limits on every output file.+The Markdown parser organizes sections by headings and character count. The default `max_section_chars` is 2000; `max_section_size` and `section_size_flexibility` remain accepted for configuration compatibility but do not control splitting. Ordinary text obeys the character limit; an oversized table row remains intact. Explicit `no_split` mode preserves the entire body.Behavior varies by parser and `parse_mode`. Use `parse_mode="no_split"` for supported imports when a single file is needed; see [Resource Management](../api/02-resources.md).@@ -92,7 +92,7 @@ L0/L1 are directory sidecars, not per-file sidecars. Parent-summary generation c### Freshness, Sampling, and Parent Refresh-Each generation records direct-child coverage and uses stable sampling above `semantic.overview_sample_limit` (default 32). Resource/skill parent refreshes depend on child L0 body changes and freshness thresholds; unchanged L0 bodies do not propagate. `pending_child_changes` counts change events awaiting refresh, including repeated changes to the same child. See [Context Layers](03-context-layers.md#freshness-and-stable-sampling) for thresholds, manual refresh behavior, and deferred updates.+Each generation collects all direct-child summaries without a 32-entry sample cap. The existing `semantic.max_overview_prompt_chars` budget (60000 characters by default) and batching/truncation behavior are unchanged. Resource/skill parent refreshes depend on child L0 body changes and freshness thresholds; unchanged L0 bodies do not propagate. `pending_child_changes` counts change events awaiting refresh, including repeated changes to the same child. See [Context Layers](03-context-layers.md#freshness-and-stable-sampling) for thresholds, manual refresh behavior, and deferred updates.### Processing Limits@@ -101,7 +101,7 @@ Each generation records direct-child coverage and uses stable sampling above `se| `vlm.max_concurrent` | 32 | Semantic-processing concurrency, passed to `SemanticProcessor.max_concurrent_llm` || `max_images_per_call` | 10 | `VLMProcessor` constructor parameter: images per call; not an `ov.conf` field || `max_sections_per_call` | 20 | `VLMProcessor` constructor parameter: sections per call; not an `ov.conf` field |-| `semantic.overview_sample_limit` | 32 | Maximum direct-child sample used for one directory summary |+| `semantic.overview_sample_limit` | 32 | Small-directory threshold for freshness scheduling, not a summary input count cap |## Code Skeleton Extractiondiff --git a/docs/zh/concepts/03-context-layers.md b/docs/zh/concepts/03-context-layers.mdindex 678ba4d56..a049f8b2c 100644--- a/docs/zh/concepts/03-context-layers.md+++ b/docs/zh/concepts/03-context-layers.md@@ -148,7 +148,7 @@ API 认证指南,涵盖 OAuth 2.0、JWT 令牌和 API 密钥。- `unsampled_entries`:未采样的直接子项数,满足 `sampled + unsampled = total`。- `pending_child_changes`:尚未反映到当前正文中的直接子项变化事件数(同一子项重复变化会分别计数)。-当直接子项超过 `semantic.overview_sample_limit`(默认 32)时,系统使用确定性、保序的稳定采样。相同目录树重复刷新会选择相同样本,减少采样变化带来的正文差异;模型重新生成的正文仍可能不同。+摘要生成收集全部直接子项,不再按条数采样。保留原有 60000 字符摘要预算及分批、截断逻辑。`semantic.overview_sample_limit` 仅保留为 freshness 调度的小目录阈值。`pending_child_changes > 0` 表示正文仍然可读,但已知落后于下层变化。父目录刷新成功后,该值会随新的覆盖率元数据重置为 0。diff --git a/docs/zh/concepts/06-extraction.md b/docs/zh/concepts/06-extraction.mdindex 32614cfb8..17da36d28 100644--- a/docs/zh/concepts/06-extraction.md+++ b/docs/zh/concepts/06-extraction.md@@ -40,7 +40,7 @@ Parser 负责文档格式转换和结构化,在临时目录创建文件结构### 文档分节-Markdown 解析器按标题和大小组织章节,合并较短小节,拆分过长内容。默认 `max_section_size` 为 2048 tokens,`max_section_chars` 为 6000 字符。配置还定义了 `section_size_flexibility=0.3`,但当前 Markdown 分节代码未使用该值。过长的单个表格行可以保持完整。这些值是分节目标,不能当作每个输出文件的绝对上限。+Markdown 解析器按标题和字符数组织章节,合并较短小节,拆分过长内容。默认 `max_section_chars` 为 2000 字符;`max_section_size` 和 `section_size_flexibility` 仅保留配置兼容,不参与分节。普通文本遵守字符上限,过长的单个表格行仍保持完整。显式 `no_split` 模式不拆分正文。不同解析器和 `parse_mode` 的行为不同。需要保持单文件时,可在支持的导入中使用 `parse_mode="no_split"`,详见[资源管理](../api/02-resources.md)。@@ -92,7 +92,7 @@ L0/L1 是目录级 sidecar,不是 per-file sidecar。生成父目录摘要时### Freshness、采样与父级刷新-每次生成都会记录直接子项覆盖情况,超过 `semantic.overview_sample_limit`(默认 32)时使用稳定采样。resource/skill 的父级刷新取决于子目录 L0 正文变化和 freshness 阈值,L0 正文不变时不向上传播。`pending_child_changes` 统计等待刷新的变化事件,同一子项重复变化也会分别计数。阈值、手动刷新和延后更新的规则见[上下文层级](03-context-layers.md)。+每次生成都会收集全部直接子项摘要,不再按 32 条采样;保留原有 `semantic.max_overview_prompt_chars`(默认 60000 字符)预算及分批、截断逻辑。resource/skill 的父级刷新取决于子目录 L0 正文变化和 freshness 阈值,L0 正文不变时不向上传播。`pending_child_changes` 统计等待刷新的变化事件,同一子项重复变化也会分别计数。阈值、手动刷新和延后更新的规则见[上下文层级](03-context-layers.md)。### 处理限制@@ -101,7 +101,7 @@ L0/L1 是目录级 sidecar,不是 per-file sidecar。生成父目录摘要时| `vlm.max_concurrent` | 32 | 语义处理并发上限,传入 `SemanticProcessor.max_concurrent_llm` || `max_images_per_call` | 10 | `VLMProcessor` 构造参数:单次最大图片数,非 `ov.conf` 字段 || `max_sections_per_call` | 20 | `VLMProcessor` 构造参数:单次最大章节数,非 `ov.conf` 字段 |-| `semantic.overview_sample_limit` | 32 | 单个目录摘要使用的直接子项样本上限 |+| `semantic.overview_sample_limit` | 32 | freshness 调度的小目录阈值,不限制摘要输入条数 |## 代码骨架提取diff --git a/openviking/parse/parsers/markdown.py b/openviking/parse/parsers/markdown.pyindex c4c98f4af..4f5ea1736 100644--- a/openviking/parse/parsers/markdown.py+++ b/openviking/parse/parsers/markdown.py@@ -7,13 +7,13 @@ This parser implements the new simplified architecture:- Parse structure and create directory structure directly in VikingFS- No LLM calls during parsing (semantic generation moved to SemanticQueue)- Support mixed directory structure (files + subdirectories)-- Small sections (< 800 tokens) are merged with adjacent sections+- Small sections (< 512 characters) are merged with adjacent sectionsThe parser handles scenarios:-1. Small files (< 4000 tokens) → save as single file with original name+1. Small files (<= 2000 characters) → save as single file with original name2. Large files with sections → split by sections with merge logic3. Sections with subsections → section becomes directory-4. Small sections (< 800 tokens) → merged with adjacent sections+4. Small sections (< 512 characters) → merged with adjacent sections5. Oversized sections without subsections → split by paragraphs"""@@ -180,11 +180,7 @@ class MarkdownParser(BaseParser):"""# Configuration constants- DEFAULT_MAX_SECTION_SIZE = 2048 # Maximum tokens per section- DEFAULT_MIN_SECTION_TOKENS = 512 # Minimum tokens to create a separate section- # Worst-case token density used by _estimate_token_count (CJK ~0.7 tok/char).- # Used to bound force-split chunk size so it also respects the token budget.- MAX_TOKENS_PER_CHAR = 0.7+ DEFAULT_MIN_SECTION_CHARS = 512 # Minimum chars to create a separate sectionTABLE_HEADER_REPEAT_MAX_CHARS = 1024MAX_MERGED_FILENAME_LENGTH = 32 # Maximum length for merged section filenames@@ -664,87 +660,46 @@ class MarkdownParser(BaseParser):return headingsdef _smart_split_content(self, content: str, max_size: int) -> List[str]:- """- Split oversized content by paragraphs, force split single oversized paragraphs.-- Targets both the token estimate limit (max_size) and the character limit- (self.config.max_section_chars). A single oversized Markdown table row is- kept intact so downstream semantic and embedding stages can apply their own- input limits without destroying the source table structure.-- Args:- content: Content to split- max_size: Maximum size per part (in tokens)-- Returns:- List of content parts- """- max_chars = self.config.max_section_chars- if max_chars <= 0:- # Char limit disabled (misconfigured); fall back to token-only splitting- max_chars = len(content) + 1+ """Split by character budget, preserving an indivisible Markdown table row."""+ max_chars = min(max_size, self.config.max_section_chars)paragraphs = content.split("\n\n")parts = []current = ""- current_tokens = 0for para in paragraphs:- para_tokens = self._estimate_token_count(para)- para_len = len(para)-- # Single paragraph too long (by tokens or chars): force split by characters.- # If the already accumulated prefix is very short, merge it into this- # oversized paragraph first so we do not create a low-value tiny chunk- # like `section_1.md` that only contains the heading/introduction.- if para_tokens > max_size or para_len > max_chars:+ if len(para) > max_chars:if current:- if current_tokens < self.DEFAULT_MIN_SECTION_TOKENS:+ if len(current) < self.DEFAULT_MIN_SECTION_CHARS:para = current + "\n\n" + paraelse:parts.append(current.strip())current = ""- current_tokens = 0- # Step by the smaller of the char limit and the token-safe- # width, so a paragraph that is under max_chars but over- # max_size tokens (e.g. dense CJK text) is still split enough- # to keep every chunk within the token budget.- token_safe_chars = max(1, int(max_size / self.MAX_TOKENS_PER_CHAR))- step = min(max_chars, token_safe_chars)- table_parts = self._split_markdown_table_by_rows(- para,- max_size=max_size,- max_chars=step,- )+ table_parts = self._split_markdown_table_by_rows(para, max_chars=max_chars)if table_parts:parts.extend(table_parts)else:- for i in range(0, len(para), step):- parts.append(para[i : i + step].strip())- elif (- current_tokens + para_tokens > max_size or len(current) + len(para) + 2 > max_chars- ) and current:+ parts.extend(+ para[i : i + max_chars].strip() for i in range(0, len(para), max_chars)+ )+ elif current and len(current) + len(para) + 2 > max_chars:parts.append(current.strip())current = para- current_tokens = para_tokenselse:current = current + "\n\n" + para if current else para- current_tokens += para_tokensif current.strip():- # Avoid emitting a tiny trailing chunk when all earlier content has- # already been split out (for example, a huge paragraph followed by- # a short "no data" tail). Fold the tail back into the previous part.- if parts and current_tokens < self.DEFAULT_MIN_SECTION_TOKENS:- parts[-1] = f"{parts[-1]}\n\n{current.strip()}".strip()+ tail = current.strip()+ if parts and len(parts[-1]) + 2 + len(tail) <= max_chars:+ parts[-1] = f"{parts[-1]}\n\n{tail}"else:- parts.append(current.strip())+ parts.append(tail)return parts if parts else [content]@staticmethoddef _is_markdown_table_row(line: str) -> bool:stripped = line.strip()- return stripped.startswith("|") and stripped.endswith("|") and "|" in stripped[1:-1]+ return len(stripped) >= 2 and stripped.startswith("|") and stripped.endswith("|")@staticmethoddef _is_markdown_table_separator(line: str) -> bool:@@ -758,7 +713,6 @@ class MarkdownParser(BaseParser):self,content: str,*,- max_size: int,max_chars: int,) -> Optional[List[str]]:"""Split a single oversized Markdown table without cutting rows.@@ -794,40 +748,35 @@ class MarkdownParser(BaseParser):rows = lines[table_start + 2 : table_end]header_text = "\n".join(header)repeat_header = (- len(header_text) <= self.TABLE_HEADER_REPEAT_MAX_CHARS- and len(header_text) < max_chars- and self._estimate_token_count(header_text) < max_size+ len(header_text) <= self.TABLE_HEADER_REPEAT_MAX_CHARS and len(header_text) < max_chars)parts: List[str] = []current_lines: List[str] = []- current_data_rows = 0def flush() -> None:- nonlocal current_lines, current_data_rows+ nonlocal current_linesif current_lines:parts.append("\n".join(current_lines).strip())current_lines = []- current_data_rows = 0if prefix:- current_lines.extend([prefix, ""])- current_lines.extend(header)+ parts.extend(prefix[i : i + max_chars] for i in range(0, len(prefix), max_chars))- for row in rows:- candidate_lines = [*current_lines, row]- candidate = "\n".join(candidate_lines)- if (- current_lines- and (len(candidate) > max_chars or self._estimate_token_count(candidate) > max_size)- and current_data_rows > 0- ):+ # Keep the header and separator together until the first data row is handled.+ current_lines.extend(header)+ for index, row in enumerate(rows):+ candidate = "\n".join([*current_lines, row])+ if current_lines and len(candidate) > max_chars:+ if index == 0 and len(row) > max_chars:+ current_lines = [*header, row]+ continueflush()- current_lines = [*header, row] if repeat_header else [row]- current_data_rows = 1- else:- current_lines.append(row)- current_data_rows += 1+ if len(row) > max_chars or (+ repeat_header and len(header_text) + 1 + len(row) <= max_chars+ ):+ current_lines.extend(header)+ current_lines.append(row)flush()return parts or None@@ -1419,12 +1368,9 @@ class MarkdownParser(BaseParser):source_path: Source file path for namingsplit_content: Whether large Markdown may be split into multiple files"""- max_size = self.config.max_section_size or self.DEFAULT_MAX_SECTION_SIZE+ max_size = self.config.max_section_charsmax_chars = self.config.max_section_chars- min_size = self.DEFAULT_MIN_SECTION_TOKENS-- # Estimate document size- estimated_tokens = self._estimate_token_count(content)+ min_size = self.DEFAULT_MIN_SECTION_CHARS# Create root directoryops.append(_LayoutOp("mkdir", root_dir))@@ -1440,8 +1386,8 @@ class MarkdownParser(BaseParser):logger.debug(f"[MarkdownParser] No-split document planned as: {file_path}")return- # Small document: save as single file (check both token and char limits)- if estimated_tokens <= max_size and len(content) <= max_chars:+ # Small document: save as single file (character budget)+ if len(content) <= max_chars:file_path = f"{root_dir}/{doc_name}.md"ops.append(_LayoutOp("write", file_path, content))return@@ -1461,12 +1407,12 @@ class MarkdownParser(BaseParser):if first_heading_start > 0:pre_content = content[:first_heading_start].strip()if pre_content:- pre_tokens = self._estimate_token_count(pre_content)+ pre_chars = len(pre_content)sections.append({"name": doc_name,"content": pre_content,- "tokens": pre_tokens,+ "chars": pre_chars,"has_children": False,"heading_idx": None,}@@ -1526,24 +1472,24 @@ class MarkdownParser(BaseParser):buffered_section = Nonefor sec in expanded:- name, tokens, content_text = sec["name"], sec["tokens"], sec["content"]+ name, chars, content_text = sec["name"], sec["chars"], sec["content"]has_children = sec["has_children"]# Handle small sections- if tokens < min_size:- if pending and sum(t for _, _, t in pending) + tokens > max_size:+ if chars < min_size:+ if pending and sum(t for _, _, t in pending) + chars > max_size:await flush_buffered()await self._save_merged(ops, parent_dir, pending)pending = []- pending.append((name, content_text, tokens))+ pending.append((name, content_text, chars))continueif pending:await flush_buffered()# Try merge with pending- if self._can_merge(pending, tokens, max_size, has_children):- pending.append((name, content_text, tokens))+ if self._can_merge(pending, chars, max_size, has_children):+ pending.append((name, content_text, chars))await self._save_merged(ops, parent_dir, pending)pending = []continue@@ -1575,13 +1521,13 @@ class MarkdownParser(BaseParser):await flush_buffered()- def _can_merge(self, pending: List, tokens: int, max_size: int, has_children: bool) -> bool:+ def _can_merge(self, pending: List, chars: int, max_size: int, has_children: bool) -> bool:"""Check if section can merge with pending."""- return sum(t for _, _, t in pending) + tokens <= max_size and not has_children+ return sum(t for _, _, t in pending) + chars <= max_size and not has_childrendef _should_merge_pending_into_next(self, pending: List[Tuple[str, str, int]]) -> bool:"""Prefer folding a single tiny pending section into the next section."""- return len(pending) == 1 and pending[0][2] <= self.DEFAULT_MIN_SECTION_TOKENS+ return len(pending) == 1 and pending[0][2] <= self.DEFAULT_MIN_SECTION_CHARSdef _merge_pending_into_next_section(self, pending: List[Tuple[str, str, int]], section: Dict[str, Any]@@ -1590,7 +1536,7 @@ class MarkdownParser(BaseParser):_, pending_content, _ = pending[0]merged = dict(section)merged["content"] = f"{pending_content}\n\n{section['content']}".strip()- merged["tokens"] = self._estimate_token_count(merged["content"])+ merged["chars"] = len(merged["content"])if merged.get("has_children"):direct_content = section.get("direct_content", "").strip()@@ -1609,7 +1555,7 @@ class MarkdownParser(BaseParser):_, pending_content, _ = pending[0]merged = dict(section)merged["content"] = f"{section['content']}\n\n{pending_content}".strip()- merged["tokens"] = self._estimate_token_count(merged["content"])+ merged["chars"] = len(merged["content"])if merged.get("has_children"):direct_content = section.get("direct_content", "").strip()@@ -1632,11 +1578,11 @@ class MarkdownParser(BaseParser):min_size: int,) -> None:"""Plan a single section (file or directory) into ``ops``."""- name, tokens, content_text = section["name"], section["tokens"], section["content"]+ name, content_text = section["name"], section["content"]has_children = section["has_children"]- # Fits in one file (check both token and char limits)- if tokens <= max_size and len(content_text) <= self.config.max_section_chars:+ # Fits in one file (character budget)+ if len(content_text) <= max_size:ops.append(_LayoutOp("write", f"{parent_dir}/{name}.md", content_text))return@@ -1669,7 +1615,7 @@ class MarkdownParser(BaseParser):{"name": name,"content": section["direct_content"],- "tokens": self._estimate_token_count(section["direct_content"]),+ "chars": len(section["direct_content"]),"has_children": False,"heading_idx": None,}@@ -1740,7 +1686,7 @@ class MarkdownParser(BaseParser):content = "\n\n".join(c for _, c, _ in sections)max_chars = self.config.max_section_charsif len(content) > max_chars:- max_size = self.config.max_section_size or self.DEFAULT_MAX_SECTION_SIZE+ max_size = self.config.max_section_charsparts = self._smart_split_content(content, max_size)for i, part in enumerate(parts, 1):ops.append(_LayoutOp("write", f"{parent_dir}/{name}_{i}.md", part))@@ -1754,7 +1700,7 @@ class MarkdownParser(BaseParser):idx: int,) -> Dict[str, Any]:"""- Get section info including content, tokens, children info.+ Get section info including content, chars, children info.Args:content: Full markdown content@@ -1793,7 +1739,7 @@ class MarkdownParser(BaseParser):heading_prefix = "#" * levelsection_start = end_pos # After heading linefull_content = f"{heading_prefix} {title}\n\n{content[section_start:section_end].strip()}"- full_tokens = self._estimate_token_count(full_content)+ full_chars = len(full_content)direct_content = ""if has_children:@@ -1804,17 +1750,9 @@ class MarkdownParser(BaseParser):return {"name": section_name,"content": full_content,- "tokens": full_tokens,+ "chars": full_chars,"has_children": has_children,"heading_idx": idx,"direct_content": direct_content,"child_indices": child_indices,}-- def _estimate_token_count(self, content: str) -> int:- # CJK characters (Chinese, Japanese, Korean): ~0.7 token per char- # Other characters (including Latin, Arabic, Cyrillic, etc.): ~0.3 token per char- # This provides better coverage for multilingual documents- cjk_chars = len(re.findall(r"[\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]", content))- other_chars = len(re.findall(r"[^\s]", content)) - cjk_chars- return int(cjk_chars * self.MAX_TOKENS_PER_CHAR + other_chars * 0.3)diff --git a/openviking/parse/understanding_api.py b/openviking/parse/understanding_api.pyindex 9d55a28e8..aecf44af1 100644--- a/openviking/parse/understanding_api.py+++ b/openviking/parse/understanding_api.py@@ -795,7 +795,7 @@ class UnderstandingAPI(BaseParser):parse_output_store,viking_fs=get_viking_fs() if parse_output_store is None else None,)- resource_rel = str(resource_name).strip("/")+ resource_rel = str(resource_name).strip("/").strip() or "unnamed"try:await writer.mkdir(resource_rel)diff --git a/openviking/storage/queuefs/semantic_executor.py b/openviking/storage/queuefs/semantic_executor.pyindex 1287b08ac..f07a680a1 100644--- a/openviking/storage/queuefs/semantic_executor.py+++ b/openviking/storage/queuefs/semantic_executor.py@@ -22,7 +22,6 @@ from openviking.storage.abstract_overview import (AbstractOverviewFormatError,AbstractOverviewWriteResult,body_for_preview,- deterministic_sample,freshness_metadata,read_abstract_overview_pending_snapshot,write_abstract_overview,@@ -35,7 +34,6 @@ from openviking.telemetry import bind_ingestion_source_type, bind_telemetry, getfrom openviking.utils.content_hash import content_md5from openviking.utils.ingest_options import IngestOptionsfrom openviking_cli.utils import VikingURI-from openviking_cli.utils.config import get_openviking_configfrom openviking_cli.utils.logger import get_loggerlogger = get_logger(__name__)@@ -583,17 +581,12 @@ class SemanticTreeExecutor:self._schedule_overview(dir_uri)return False- sample_limit = getattr(- get_openviking_config().semantic,- "overview_sample_limit",- 32,- )direct_entries = sorted([("directory", uri) for uri in children_dirs]+ [("file", uri) for uri in file_paths],key=lambda item: item[1].rsplit("/", 1)[-1],)- sampled_entries = deterministic_sample(direct_entries, sample_limit)+ sampled_entries = direct_entriessampled_children_dirs = {uri for kind, uri in sampled_entries if kind == "directory"}sampled_file_paths = {uri for kind, uri in sampled_entries if kind == "file"}pending_snapshot = 0@@ -791,13 +784,12 @@ class SemanticTreeExecutor:children_dirs: List[str],file_paths: List[str],) -> DirNode:- """Sample the target directory first, then read only existing summaries."""+ """Read existing summaries for all direct children of the target directory."""candidates = sorted([("file", uri) for uri in file_paths] + [("directory", uri) for uri in children_dirs],key=lambda item: (item[1].rsplit("/", 1)[-1], item[0], item[1]),)- sample_limit = getattr(get_openviking_config().semantic, "overview_sample_limit", 32)- primary = deterministic_sample(candidates, sample_limit)+ primary = candidatesloaded = await self._load_transfer_candidates(primary)selected = [candidate for candidate in primary if candidate in loaded]diff --git a/openviking/storage/queuefs/semantic_processor.py b/openviking/storage/queuefs/semantic_processor.pyindex 03d39b4a9..e8146cc60 100644--- a/openviking/storage/queuefs/semantic_processor.py+++ b/openviking/storage/queuefs/semantic_processor.py@@ -42,7 +42,6 @@ from openviking.service.task_work_index import detach_task_context, get_task_confrom openviking.storage.abstract_overview import (AbstractOverviewWriteResult,body_for_preview,- deterministic_sample,freshness_metadata,markdown_safe_viking_uri,parse_overview_file_summaries,@@ -1072,15 +1071,9 @@ class SemanticProcessor(DequeueHandlerBase):await asyncio.gather(*[_gen(i, fp) for i, fp in batch])completed_summaries = [s for s in file_summaries if s is not None]- sample_limit = getattr(- get_openviking_config().semantic,- "overview_sample_limit",- 32,- )- sampled_summaries = deterministic_sample(completed_summaries, sample_limit)generated_content = await self._generate_overview(dir_uri,- sampled_summaries,+ completed_summaries,[],llm_sem=llm_sem,total_files=len(file_paths),@@ -1098,7 +1091,7 @@ class SemanticProcessor(DequeueHandlerBase):ctx=ctx,lock=lock,total_entries=len(file_paths),- sampled_entries=len(sampled_summaries),+ sampled_entries=len(completed_summaries),)except LockAcquisitionError:raisediff --git a/openviking_cli/utils/config/parser_config.py b/openviking_cli/utils/config/parser_config.pyindex 26cfcd99c..c5c04f986 100644--- a/openviking_cli/utils/config/parser_config.py+++ b/openviking_cli/utils/config/parser_config.py@@ -29,7 +29,7 @@ class ParserConfig:enabled: Whether the parser is enabledmax_content_length: Maximum content length to process (characters)encoding: Default file encoding- max_section_size: Maximum tokens per section before splitting+ max_section_size: Legacy option, ignored by native Markdown splittingsection_size_flexibility: Allow overflow to maintain coherence (0.0-1.0)max_section_chars: Target character limit per section. A single oversizedMarkdown table row may remain intact to preserve table semantics.@@ -40,9 +40,9 @@ class ParserConfig:encoding: str = "utf-8"# Smart splitting configuration- max_section_size: int = 2048 # Maximum tokens per section before splitting+ max_section_size: int = 2048 # Legacy compatibility; splitting uses max_section_charssection_size_flexibility: float = 0.3 # Allow 30% overflow to maintain coherence- max_section_chars: int = 6000 # Target character limit per section+ max_section_chars: int = 2000 # Target character limit per section@classmethoddef from_dict(cls, data: Dict[str, Any]) -> "ParserConfig":@@ -707,7 +707,7 @@ class SemanticConfig:"""Maximum number of file summaries per batch when splitting oversized prompts."""overview_sample_limit: int = 32- """Maximum direct-child summaries used in one generated directory sidecar."""+ """Small-directory threshold for freshness scheduling; not a summary count cap."""freshness_refresh_ratio: float = 0.10"""Pending direct-child change ratio that refreshes a wide directory."""diff --git a/tests/parse/test_markdown_split_token_budget.py b/tests/parse/test_markdown_split_token_budget.pyindex 3749301ee..80dca106a 100644--- a/tests/parse/test_markdown_split_token_budget.py+++ b/tests/parse/test_markdown_split_token_budget.py@@ -1,27 +1,74 @@-"""Regression test: _smart_split_content must respect the token budget.+"""Native section limits use characters, independently of legacy token settings."""-The force-split branch previously stepped through an oversized paragraph by-``max_chars`` only. A paragraph that is under the character limit but over the-token budget (e.g. dense CJK text, weighted ~0.7 token/char) was therefore-emitted as a single chunk that exceeded ``max_size`` tokens.-"""+import pytestfrom openviking.parse.parsers.markdown import MarkdownParser+from openviking_cli.utils.config.parser_config import ParserConfig-def test_smart_split_enforces_token_budget_for_cjk_paragraph():[email protected]("character", ["中", "a", "🙂"])+def test_smart_split_character_budget_preserves_content(character):parser = MarkdownParser()- max_size = 2048- # 5000 CJK chars ~= 3500 estimated tokens (> max_size) but < the default- # char limit, so the char-only force-split produced one over-budget chunk.- paragraph = "\u4e2d" * 5000- parts = parser._smart_split_content(paragraph, max_size=max_size)- worst = max(parser._estimate_token_count(p) for p in parts)- assert worst <= max_size, f"chunk has {worst} tokens, exceeds max_size={max_size}"+ paragraph = character * 5000+ parts = parser._smart_split_content(paragraph, max_size=2000)+ assert [len(part) for part in parts] == [2000, 2000, 1000]+ assert "".join(parts) == paragraph-def test_smart_split_preserves_content():+def test_short_tail_does_not_overflow_character_budget():parser = MarkdownParser()- paragraph = "\u4e2d" * 5000- parts = parser._smart_split_content(paragraph, max_size=2048)- assert "".join(parts) == paragraph+ parts = parser._smart_split_content("中" * 4000 + "\n\ntail", max_size=2000)+ assert all(len(part) <= 2000 for part in parts)+ assert parts[-1] == "tail"++[email protected]("with_headings", [False, True])+async def test_layout_uses_character_budget_ignoring_legacy_tokens(with_headings):+ parser = MarkdownParser(ParserConfig(max_section_size=1))+ content = ("# Title\n\n" if with_headings else "") + "中" * 1990+ layout = await parser._compute_layout(content, "viking://temp/test", resource_name="doc")+ writes = [op for op in layout.ops if op.kind == "write"]+ assert len(writes) == 1+ assert writes[0].content == content+++async def test_heading_merges_stay_within_character_budget():+ parser = MarkdownParser()+ content = "\n\n".join(f"## Heading {i}\n\n" + "文" * 750 for i in range(12))+ layout = await parser._compute_layout(content, "viking://temp/test", resource_name="doc")+ writes = [op for op in layout.ops if op.kind == "write"]+ assert all(len(op.content) <= 2000 for op in writes)+ assert sum(op.content.count("文") for op in writes) == 9000++[email protected]("leading_row", ["", "| short |\n"])+def test_oversized_table_row_remains_intact_with_header(leading_row):+ parser = MarkdownParser()+ row = "| " + "文" * 2500 + " |"+ header = "| Column |\n| --- |"+ content = header + "\n" + leading_row + row+ parts = parser._smart_split_content(content, max_size=2000)+ assert header + "\n" + row in parts+ assert header not in parts+ assert sum(part.count(row) for part in parts) == 1+++def test_table_header_does_not_push_ordinary_rows_over_budget():+ parser = MarkdownParser()+ rows = ["| " + "文" * 1950 + " |" for _ in range(2)]+ content = "| " + "标题" * 40 + " |\n| --- |\n" + "\n".join(rows)+ parts = parser._smart_split_content(content, max_size=2000)+ assert all(len(part) <= 2000 for part in parts)+ assert sum(part.count("文") for part in parts) == 3900+ assert all(any(row in part for part in parts) for row in rows)++[email protected]("header_size", [1990, 2100])+def test_oversized_header_and_row_stay_together_without_duplicate_header(header_size):+ parser = MarkdownParser()+ header = "| " + "H" * header_size + " | X |\n| --- | --- |"+ row = "| " + "文" * 2500 + " | Y |"+ content = header + "\n" + row+ assert parser._smart_split_content(content, max_size=2000) == [content]diff --git a/tests/parse/test_understanding_api_artifact_images.py b/tests/parse/test_understanding_api_artifact_images.pyindex e70e11555..91f7e9796 100644--- a/tests/parse/test_understanding_api_artifact_images.py+++ b/tests/parse/test_understanding_api_artifact_images.py@@ -118,3 +118,35 @@ async def test_unpack_artifact_supports_local_output_store(tmp_path: Path):assert ref.resource_rel == "resource"assert Path(ref.root, "resource", "section.md").read_text() == "content"assert set(await read_artifact_manifest(store, ref)) == {"resource/section.md"}++[email protected]("title", ["Title ", "Title\t\n", "Title\u00a0\u3000"])[email protected]("backend", ["agfs", "local"])+async def test_title_whitespace_uses_one_artifact_root(tmp_path, title, backend):+ class TrimmingFS(_FakeVikingFS):+ async def mkdir(self, uri, exist_ok=False):+ self.dirs.add(uri.strip())++ async def write_file_bytes(self, uri, content):+ self.dirs.add(uri.rsplit("/", 1)[0])+ await super().write_file_bytes(uri, content)++ archive_path = tmp_path / "artifact.zip"+ with zipfile.ZipFile(archive_path, "w") as archive:+ archive.writestr("document/body.md", "content")+ fs = TrimmingFS()+ options = {}+ if backend == "local":+ options["parse_output_store"] = LocalParseOutputStore(str(tmp_path / "artifacts"))+ with patch("openviking.parse.understanding_api.get_viking_fs", return_value=fs):+ ref = await UnderstandingAPI.__new__(UnderstandingAPI)._unpack_zip_to_temp_dir(+ archive_path, title, **options+ )+ assert ref.resource_rel == "Title"+ if backend == "local":+ assert [p.name for p in Path(ref.root).iterdir() if p.is_dir()] == ["Title"]+ assert Path(ref.root, "Title/body.md").read_text() == "content"+ else:+ assert fs.dirs - {ref.root} == {f"{ref.root}/Title"}+ assert fs.files[f"{ref.root}/Title/body.md"] == b"content"diff --git a/tests/storage/test_semantic_executor_incremental.py b/tests/storage/test_semantic_executor_incremental.pyindex ccf83d8c0..dd0a7e792 100644--- a/tests/storage/test_semantic_executor_incremental.py+++ b/tests/storage/test_semantic_executor_incremental.py@@ -2,7 +2,6 @@# SPDX-License-Identifier: AGPL-3.0import re-from types import SimpleNamespacefrom unittest.mock import AsyncMock, MagicMockimport pytest@@ -10,7 +9,6 @@ import pytestfrom openviking.core.context import ContextLevelfrom openviking.server.identity import RequestContext, Rolefrom openviking.storage.abstract_overview import (- deterministic_sample,freshness_metadata,parse_abstract_overview,render_abstract_overview,@@ -283,10 +281,6 @@ async def test_semantic_plan_repair_regenerates_and_reembeds_directory(monkeypatmonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)plan = SemanticPlan(root_uri,@@ -344,10 +338,6 @@ async def test_skill_plan_repair_regenerates_and_reembeds_skill_root(monkeypatchmonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)processor._skill_root_semantics = AsyncMock(return_value=("skill overview", "skill abstract"))plan = SemanticPlan(@@ -422,10 +412,6 @@ async def test_direct_incremental_update_uses_changes_without_temp_sync(monkeypamonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)ctx = RequestContext(user=UserIdentifier("acc1", "user1"), role=Role.USER)@@ -477,10 +463,6 @@ async def test_direct_incremental_created_file_forces_vector_upsert(monkeypatch)monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(processor=processor,@@ -530,10 +512,6 @@ async def test_modified_file_with_same_abstract_still_propagates(monkeypatch):monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(@@ -578,10 +556,6 @@ async def test_modified_file_with_different_abstract_still_propagates(monkeypatcmonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(@@ -616,10 +590,6 @@ async def test_added_file_with_matching_stale_abstract_still_propagates(monkeypamonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(@@ -657,10 +627,6 @@ async def test_deleted_last_nested_file_still_refreshes_existing_ancestor(monkeymonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(@@ -697,10 +663,6 @@ async def test_artifact_files_drive_tree_structure_when_target_listing_is_empty(monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)ctx = RequestContext(user=UserIdentifier("acc1", "user1"), role=Role.USER)@@ -737,10 +699,6 @@ async def test_direct_incremental_reuses_vector_abstract_without_overview(monkeymonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(@@ -773,10 +731,6 @@ async def test_missing_target_file_fails_instead_of_using_empty_summary(tmp_pathmonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )executor = SemanticTreeExecutor(processor=_FakeProcessor(fake_fs),context_type="resource",@@ -815,10 +769,6 @@ async def test_content_write_tags_apply_only_to_changed_file(monkeypatch):monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)ctx = RequestContext(user=UserIdentifier("acc1", "user1"), role=Role.USER)@@ -853,10 +803,6 @@ async def test_content_write_uses_per_file_ingest_options(monkeypatch):monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)first_options = IngestOptions(search_tags=["team=search"])second_options = IngestOptions(search_tags=[], search_tag_mode="clear")@@ -900,10 +846,6 @@ async def test_content_write_with_same_abstract_updates_file_and_parent(monkeypamonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)tag_options = IngestOptions(search_tags=["team=search"])@@ -941,10 +883,6 @@ async def test_content_write_keeps_matching_upstream_md5(monkeypatch):monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(@@ -977,10 +915,6 @@ async def test_semantic_generate_hashes_read_content_when_manifest_md5_is_missinmonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(@@ -1001,11 +935,10 @@ async def test_semantic_generate_hashes_read_content_when_manifest_md5_is_missin@pytest.mark.asyncio-async def test_pending_refresh_rebuilds_every_sampled_file_summary(monkeypatch):+async def test_pending_refresh_rebuilds_every_file_summary(monkeypatch):root_uri = "viking://resources/wide"file_names = [f"file-{idx:03}.txt" for idx in range(40)]file_paths = [f"{root_uri}/{name}" for name in file_names]- sampled_paths = deterministic_sample(file_paths, 4)changed_path = f"{root_uri}/file-020.txt"old_overview = "FILES:\n" + "\n".join(f"- {name}: old-summary" for name in file_names)metadata = {"freshness": freshness_metadata(40, 4, pending=4)}@@ -1026,10 +959,6 @@ async def test_pending_refresh_rebuilds_every_sampled_file_summary(monkeypatch):monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=4)),- )processor = _FakeProcessor(fake_fs)ctx = RequestContext(user=UserIdentifier("acc1", "user1"), role=Role.USER)@@ -1047,7 +976,7 @@ async def test_pending_refresh_rebuilds_every_sampled_file_summary(monkeypatch):await executor.run(root_uri)- assert set(processor.summarized_files) == set(sampled_paths) | {changed_path}+ assert set(processor.summarized_files) == set(file_paths)assert processor.vectorized_files == [changed_path]overview = parse_abstract_overview(fake_fs._file_contents[f"{root_uri}/.overview.md"])assert overview.metadata["freshness"]["pending_child_changes"] == 0@@ -1064,10 +993,6 @@ async def test_directory_vectorization_retries_after_matching_sidecar_write(monkmonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)vectorize_directory = AsyncMock(side_effect=[RuntimeError("temporary failure"), None])@@ -1132,10 +1057,6 @@ async def test_content_copy_rebuilds_target_overview_from_target_l2_summaries(momonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs,transfer_summaries={@@ -1181,10 +1102,6 @@ async def test_transfer_rebuild_generates_file_summary_and_vector(monkeypatch):monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(processor=processor,@@ -1227,10 +1144,6 @@ async def test_recursive_transfer_rebuild_generates_subtree_vectors(monkeypatch)monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(processor=processor,@@ -1250,7 +1163,7 @@ async def test_recursive_transfer_rebuild_generates_subtree_vectors(monkeypatch)@pytest.mark.asyncio-async def test_content_copy_samples_before_loading_summaries(monkeypatch):+async def test_content_copy_loads_all_existing_summaries(monkeypatch):root_uri = "viking://resources/archive"file_paths = [f"{root_uri}/{name}.txt" for name in "abcde"]fake_fs = _FakeVikingFS(@@ -1260,10 +1173,6 @@ async def test_content_copy_samples_before_loading_summaries(monkeypatch):monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=2)),- )processor = _FakeProcessor(fake_fs,transfer_summaries={path: f"summary-{path.rsplit('/', 1)[-1]}" for path in file_paths},@@ -1282,16 +1191,16 @@ async def test_content_copy_samples_before_loading_summaries(monkeypatch):await executor.run(root_uri)- assert processor.transfer_summary_calls == [[file_paths[0], file_paths[-1]]]+ assert processor.transfer_summary_calls == [file_paths]assert processor.summarized_files == []overview = parse_abstract_overview(fake_fs._file_contents[f"{root_uri}/.overview.md"]).bodyassert "a.txt" in overviewassert "e.txt" in overview- assert "c.txt" not in overview+ assert "c.txt" in overview@pytest.mark.asyncio-async def test_content_copy_does_not_backfill_missing_sample_summary(monkeypatch):+async def test_content_copy_reports_missing_summary_among_all_children(monkeypatch):root_uri = "viking://resources/archive"file_paths = [f"{root_uri}/{name}.txt" for name in "abcde"]fake_fs = _FakeVikingFS(@@ -1301,10 +1210,6 @@ async def test_content_copy_does_not_backfill_missing_sample_summary(monkeypatchmonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=2)),- )processor = _FakeProcessor(fake_fs,transfer_summaries={path: f"summary-{path.rsplit('/', 1)[-1]}" for path in file_paths[1:]},@@ -1323,12 +1228,12 @@ async def test_content_copy_does_not_backfill_missing_sample_summary(monkeypatchawait executor.run(root_uri)- assert processor.transfer_summary_calls == [[file_paths[0], file_paths[-1]]]+ assert processor.transfer_summary_calls == [file_paths]overview_doc = parse_abstract_overview(fake_fs._file_contents[f"{root_uri}/.overview.md"])assert "a.txt" not in overview_doc.body- assert "b.txt" not in overview_doc.body+ assert "b.txt" in overview_doc.bodyassert "e.txt" in overview_doc.body- assert overview_doc.metadata["freshness"].get("missing_summary_entries") is None+ assert overview_doc.metadata["freshness"].get("missing_summary_entries") == 1@pytest.mark.asyncio@@ -1348,10 +1253,6 @@ async def test_content_copy_with_no_ready_summaries_preserves_existing_sidecars(monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(processor=processor,@@ -1388,10 +1289,6 @@ async def test_content_copy_rebuilds_semantics_when_move_leaves_source_directorymonkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)executor = SemanticTreeExecutor(processor=processor,@@ -1426,10 +1323,6 @@ async def test_content_copy_propagates_vector_summary_read_failure(monkeypatch):monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor(fake_fs)async def fail_summary_read(file_paths, ctx=None):diff --git a/tests/storage/test_semantic_executor_skip_files.py b/tests/storage/test_semantic_executor_skip_files.pyindex 02292ed16..c8a74080c 100644--- a/tests/storage/test_semantic_executor_skip_files.py+++ b/tests/storage/test_semantic_executor_skip_files.py@@ -1,8 +1,6 @@# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.# SPDX-License-Identifier: AGPL-3.0-from types import SimpleNamespace-import pytestfrom openviking.server.identity import RequestContext, Role@@ -109,10 +107,6 @@ async def test_messages_jsonl_excluded_from_summary(monkeypatch):monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor()ctx = RequestContext(user=UserIdentifier("acc1", "user1"), role=Role.USER)@@ -148,10 +142,6 @@ async def test_messages_jsonl_excluded_in_subdirectory(monkeypatch):monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor()ctx = RequestContext(user=UserIdentifier("acc1", "user1"), role=Role.USER)@@ -182,10 +172,6 @@ async def test_unlistable_semantic_root_is_not_materialized_as_directory(monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor()ctx = RequestContext(user=UserIdentifier("acc1", "user1"), role=Role.USER)@@ -211,10 +197,6 @@ async def test_empty_semantic_directory_still_receives_sidecars(monkeypatch):monkeypatch.setattr("openviking.storage.queuefs.semantic_executor.get_viking_fs", lambda: fake_fs)- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",- lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),- )processor = _FakeProcessor()ctx = RequestContext(user=UserIdentifier("acc1", "user1"), role=Role.USER)diff --git a/tests/storage/test_semantic_executor_stats.py b/tests/storage/test_semantic_executor_stats.pyindex f64edbe4b..0b542288e 100644--- a/tests/storage/test_semantic_executor_stats.py+++ b/tests/storage/test_semantic_executor_stats.py@@ -163,7 +163,7 @@ class _ScheduledExecutor:def _patch_semantic_config(monkeypatch, *, overview_sample_limit=32):monkeypatch.setattr(- "openviking.storage.queuefs.semantic_executor.get_openviking_config",+ "openviking.storage.queuefs.semantic_processor.get_openviking_config",lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=overview_sample_limit)),@@ -255,7 +255,7 @@ async def test_semantic_executor_bounds_active_node_work(monkeypatch):@pytest.mark.asyncio-async def test_incremental_wide_directory_samples_before_summary_work(monkeypatch):+async def test_incremental_wide_directory_includes_all_summary_inputs(monkeypatch):root_uri = "viking://resources/wide"tree = {root_uri: [{"name": f"file-{idx:03}.txt", "isDir": False} for idx in range(40)],@@ -282,14 +282,13 @@ async def test_incremental_wide_directory_samples_before_summary_work(monkeypatcawait executor.run(root_uri)- # Four deterministic aggregation inputs plus the changed file, when it is- # outside that sample, are the only files that need summary preparation.- assert len(processor.summarized_files) <= 5- assert executor.get_stats().total_nodes <= 6+ assert len(processor.summarized_files) == 40+ assert executor.get_stats().total_nodes == 41+ assert len(processor.overview_inputs[-1][1]) == 40@pytest.mark.asyncio-async def test_non_recursive_memory_samples_files_and_reads_child_abstracts(monkeypatch):+async def test_non_recursive_memory_includes_files_and_reads_child_abstracts(monkeypatch):root_uri = "viking://user/alice/memories"child_a = f"{root_uri}/a-child"child_d = f"{root_uri}/d-child"@@ -325,13 +324,16 @@ async def test_non_recursive_memory_samples_files_and_reads_child_abstracts(monkawait executor.run(root_uri)- assert processor.summarized_files == [f"{root_uri}/c.md", f"{root_uri}/f.md"]- assert executor.get_stats().total_nodes == 3+ assert processor.summarized_files == [f"{root_uri}/{name}.md" for name in ("b", "c", "e", "f")]+ assert executor.get_stats().total_nodes == 5assert processor.vectorized_files == []assert processor.vectorized_dirs == []_, file_summaries, child_abstracts, coverage = processor.overview_inputs[-1]- assert [item["name"] for item in file_summaries] == ["c.md", "f.md"]- assert child_abstracts == [{"name": "a-child", "abstract": "child a abstract"}]+ assert [item["name"] for item in file_summaries] == ["b.md", "c.md", "e.md", "f.md"]+ assert child_abstracts == [+ {"name": "a-child", "abstract": "child a abstract"},+ {"name": "d-child", "abstract": ""},+ ]assert coverage["total_files"] == 4assert coverage["total_children"] == 2diff --git a/tests/storage/test_semantic_processor_overview_batching.py b/tests/storage/test_semantic_processor_overview_batching.pyindex 6a253f062..97cba77b6 100644--- a/tests/storage/test_semantic_processor_overview_batching.py+++ b/tests/storage/test_semantic_processor_overview_batching.py@@ -159,3 +159,18 @@ async def test_batched_merge_resolves_placeholders_from_merge_output(monkeypatch"[second](viking://resources/业务%20docs/第二章%23file.md)")assert "viking://input_sample_" not in overview+++async def test_overview_includes_more_than_32_children_under_budget(monkeypatch):+ from openviking_cli.utils.config.parser_config import SemanticConfig++ vlm = RecordingVLM()+ config = SimpleNamespace(semantic=SemanticConfig(), output_language_override="en")+ monkeypatch.setattr(semantic_processor_module, "get_openviking_config", lambda: config)+ files = [{"name": f"file-{i:03}.md", "summary": f"marker-{i:03}"} for i in range(40)]+ await SemanticProcessor(vlm_resolver=_TestVLMResolver(vlm))._generate_overview(+ "viking://resources/wide", files, []+ )+ assert len(vlm.prompts) == 1+ assert all(item["summary"] in vlm.prompts[0] for item in files)