Skip to content

API Reference parrot.knowledge.retrieval.digest

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

parrot.knowledge.retrieval.digest

View source

Derived digest computation over served bytes (spec §3.5.1, OQ-7, TASK-2273).

L0 does not carry a per-node digest — UniversalNode has none, and the only stored hash is the per-file sha1 in the SQLite files table (SQLitePersistence.is_stale). Rather than change L0 (out of scope, spec §1.2), Evidence.digest is computed at request time over the bytes actually served, so INV-2 closure holds by construction for the returned unit rather than trusting an index field.

This module is a pure function: it takes bytes it is given and hashes them. It performs no I/O — reading content at a pinned rev (git cat-file) is TASK-2275's responsibility.

Class DigestScope

Granularity a derived digest was computed at (spec §3.5.1).

Not every L0 node has a line span, so the granularity is declared rather than assumed — a coarser scope is a real (visible) weakening of invalidation precision, not a silent one.

Attributes:

Attribute Type Description
SPAN sha256 of the node's exact source line range — the strong case. Applies to SYMBOL nodes with domain_tags["lineno"]/["end_lineno"] (classes, functions).
FILE The file's own sha1 (from the files table). Fallback for nodes with no line span but a backing file — RATIONALE nodes (no lineno, RQ-4) and module nodes.
SUMMARY sha256 of title + summary. For synthetic nodes with no source file at all (CONCEPT, WIKI_PAGE).

Alias UniversalNode

Re-exported from parrot.knowledge.graphindex.schema.UniversalNode.

Function derive_digest

Compute (digest, DigestScope) for node over the bytes served.

Pure function — performs no file or network I/O. The caller supplies whatever bytes/hash are available; this function only decides which granularity applies and hashes accordingly.

derive_digest(node: UniversalNode, *, source_bytes: bytes | None, file_sha1: str | None) -> tuple[str, DigestScope]

Parameter Type Default Description
node UniversalNode The L0 node evidence is being produced for.
source_bytes bytes | None Full content of node.source_uri, if the caller has it loaded — required for DigestScope.SPAN.
file_sha1 str | None The file's per-file sha1 from the files table, if available — used for DigestScope.FILE.

Returns: tuple[str, DigestScope] — A (digest, scope) tuple. digest is a hex digest string; scope records the granularity it was computed at.

Attribute logger

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