Skip to content

API Reference parrot.knowledge.wiki.models

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.knowledge.wiki.models

View source

Pydantic data models for the LLM Wiki feature (FEAT-260).

Defines all shared data structures used across the wiki package:

  • WikiPageCategory: Karpathy's wiki page type taxonomy
  • WikiConfig: per-wiki-instance configuration
  • SourceManifestEntry: tracks an ingested source document
  • WikiSearchResult: unified result from combined search
  • WikiLintReport: extended lint report with wiki-specific checks

Design notes:

  • All models follow the same Pydantic v2 pattern used throughout ai-parrot.
  • WikiConfig.search_weights is validated to ensure all values are in [0, 1] and their sum is approximately 1.0 (within 0.01 tolerance).

Class SourceManifestEntry

Tracks an ingested source document in the wiki's source manifest.

Fields:

Field Type Default Description
source_id str Stable deterministic identifier for the source (e.g., SHA-1 of the URI path).
source_uri str Absolute URI / path to the original source file.
file_hash str SHA-1 hex digest of the source file contents at ingest time.
mtime float File modification timestamp (os.stat().st_mtime) at ingest time, used for quick staleness pre-check.
ingested_at str ISO-8601 UTC timestamp of when the ingest completed.
pages_generated list[str] Ordered list of wiki page IDs that were created or updated during this ingest.
status str 'ingested' Lifecycle status. "ingested" after a successful ingest; may be "stale" or "error" as appropriate.
destination str | None None Supervised-ingestion (FEAT-402) triage destination — "wiki", "archive", or "discard". None for sources that never went through triage (e.g. wikitoolkit build).
decision_source str | None None Who/what made the triage decision — "heuristic", "model", "human", or "auto". None when not applicable.
charter_version str | None None Version of the editorial charter the decision was made against, for audit/reproducibility. None when not applicable.
composite_score float | None None The weighted composite triage score in [0, 1], or None when not applicable.
doc_metadata dict[str, Any] | None None FEAT-451 extracted DocumentMetadata as a dict (author, page_count, created_at, etc. — see parrot.knowledge.wiki.documents.DocumentMetadata). None for sources ingested before FEAT-451, or when no metadata was extracted.
content_type str | None None FEAT-451 MIME type of the source document (e.g. "application/pdf"), as resolved by the acquisition layer. None when not applicable.
loader str | None None FEAT-451 name of the loader used to extract this document (e.g. "MarkdownLoader", or "plaintext"). None when not applicable.
external_id str | None None FEAT-472 immutable external identity for the source, in "<source>:<id>" form (e.g. "fireflies:abc123") — distinct from source_id/source_uri, which are path-derived and may change when a source is renamed or moved. None for sources without an external identity.

Class WikiConfig

Configuration for a single wiki instance.

Fields:

Field Type Default Description
wiki_name str Unique identifier / human-readable name for the wiki.
storage_dir Path Root directory where all wiki data is persisted.
source_dir Path | None None Optional dedicated directory for raw source documents. Defaults to {storage_dir}/sources when omitted.
page_categories list[WikiPageCategory] Ordered list of page categories that this wiki supports. Defaults to all seven WikiPageCategory values.
search_weights dict[str, float] Relative weighting applied to each search backend during combined-search score merging. Keys must be "pageindex" and "graphindex"; values must sum to ~1.0.
lightweight_model str | None None Optional model identifier for the fast CoT (analysis) step of TwoStepIngester. Falls back to model when None.
model str | None None Optional model identifier for the heavyweight generation step of TwoStepIngester.
sync_graph bool False When True, wiki writes also mirror pages into GraphIndex. Off by default — the WikiStore plane is the wiki's retrieval backend.
storage_backend str 'sqlite' "sqlite" (default; single-file wiki.db), "memory" (in-memory indexes + OKF markdown bundle directory — no SQLite dependency), or "arangodb" (server-hosted, shared retrieval plane).
charter_path Path | None None Optional path to a supervised-ingestion editorial charter YAML file (FEAT-402, see parrot.knowledge.wiki.charter.load_charter). None when this wiki does not use supervised ingestion.

Method WikiConfig.validate_storage_backend

Check the backend name against the wiki backend registry.

validate_storage_backend(v: str) -> str

Parameter Type Default Description
v str

Returns: str

Method WikiConfig.validate_search_weights

Ensure each weight is in [0, 1] and the total is approximately 1.

validate_search_weights(v: dict[str, float]) -> dict[str, float]

Parameter Type Default Description
v dict[str, float] The raw search_weights mapping.

Returns: dict[str, float] — The validated mapping unchanged.

Raises:

  • ValueError — If any weight is outside [0, 1] or the sum deviates from 1.0 by more than 0.01.

Alias WikiLintReport

Re-exported from parrot.knowledge.lint.models.LintReport.

Class WikiPageCategory

Karpathy's wiki page type taxonomy.

Attributes:

Attribute Type Description
SUMMARY High-level summary of a source document or topic.
ENTITY Named entity page (person, organisation, product, etc.).
CONCEPT Abstract concept or idea extracted from sources.
COMPARISON Side-by-side comparison of two or more topics.
OVERVIEW Broad overview spanning multiple related topics.
SYNTHESIS LLM-synthesised insight across several sources.
ANSWER Direct answer to a query, filed as a wiki page.
ARCHIVE Supervised-ingestion archive category (FEAT-402) — content that was triaged and routed to the wiki as a page but excluded from default query ranking (retrievable only via an explicit category filter).

Class WikiSearchResult

Unified wiki search result.

Fields:

Field Type Default Description
node_id str Stable page identifier (concept_id on the WikiStore path; index node id on the legacy path).
title str Human-readable page or node title.
score float Normalised relevance score in [0, 1] after weight application.
source str Which search leg produced this result — "lexical" / "vector" (WikiStore plane) or "pageindex" / "graphindex" (legacy toolkit path).
token_count int | None None Token cost of reading the full page body — used by context packing to budget progressive disclosure.
snippet str '' Short excerpt or summary extracted from the page content.
category WikiPageCategory | None None Optional WikiPageCategory if the page has one.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally