Skip to content

API Reference parrot.knowledge.wiki.decisions.render

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

parrot.knowledge.wiki.decisions.render

View source

Budgeted dossier packing and rendering (FEAT-578 Module 4).

The packing invariant (spec §2): a hit is emitted only WITH its origin/status/freshness labels and at least one citation. When the budget cannot hold that minimum, the hit is omitted and truncated is set — the labels are never dropped to make room, because an unlabeled candidate reads like a documented decision (AC3, AC9).

Attribute DEFAULT_BUDGET_TOKENS

Attribute DEFAULT_LIMIT

Alias DecisionDiagnostic

Re-exported from parrot.knowledge.wiki.decisions.models.DecisionDiagnostic.

Alias DecisionDossier

Re-exported from parrot.knowledge.wiki.decisions.models.DecisionDossier.

Alias DecisionHit

Re-exported from parrot.knowledge.wiki.decisions.models.DecisionHit.

Attribute MAX_LIMIT

Attribute MIN_BUDGET_TOKENS

Attribute MIN_LIMIT

Function clamp_budget

Raise budget_tokens to the 256-token floor (spec §2).

clamp_budget(budget_tokens: int) -> int

Parameter Type Default Description
budget_tokens int

Returns: int

Function clamp_limit

Clamp limit into 1..50 (spec §2).

clamp_limit(limit: int) -> int

Parameter Type Default Description
limit int

Returns: int

Alias estimate_tokens

Re-exported from parrot.knowledge.wiki.store.estimate_tokens.

Function labels_of

The mandatory label prefix, e.g. [INFERRED / UNREVIEWED / stale].

labels_of(hit: DecisionHit) -> str

Parameter Type Default Description
hit DecisionHit

Returns: str

Function minimum_cost

Token cost of the shortest LEGAL rendering of hit.

That floor is labels + decision id + one citation reference, with the excerpt fully elided. A hit that does not fit this is omitted, never emitted without its labels.

minimum_cost(hit: DecisionHit) -> int

Parameter Type Default Description
hit DecisionHit

Returns: int

Function pack_dossier

Assemble a dossier within limit hits and budget_tokens.

Documented hits are packed before candidates, so a tight budget drops candidates first. truncated is set whenever any hit was omitted or any excerpt shortened.

pack_dossier(documented: list[DecisionHit], candidates: list[DecisionHit], *, limit: int = DEFAULT_LIMIT, budget_tokens: int = DEFAULT_BUDGET_TOKENS, status: str = 'ok', alternatives: list[str] | None = None, diagnostics: list[DecisionDiagnostic] | None = None) -> DecisionDossier

Parameter Type Default Description
documented list[DecisionHit] Already-ranked documented hits.
candidates list[DecisionHit] Already-ranked inferred hits. Kept in their own group — never merged into documented (AC3).
limit int DEFAULT_LIMIT Total hits across both groups, clamped to 1..50.
budget_tokens int DEFAULT_BUDGET_TOKENS Estimated output budget, floored at 256.
status str 'ok'
alternatives list[str] | None None
diagnostics list[DecisionDiagnostic] | None None

Returns: DecisionDossier

Function render_dossier_text

Human-readable rendering for CLI and tool text output.

Emits two clearly separated sections. The candidate section is headed so that a reader cannot mistake it for documented history, even when the documented section is empty.

render_dossier_text(dossier: DecisionDossier) -> str

Parameter Type Default Description
dossier DecisionDossier

Returns: str

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