Skip to content

API Reference parrot_tools.contracts.toolkit

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

parrot_tools.contracts.toolkit

View source

The contracts toolkit (FEAT-539 M9).

Agent-facing surface over the same service boundary the fixed answer flow uses. Two rules matter here:

  • Tool metadata is not a permission. requires_confirmation marks a tool for HITL in transports that honour it, but the service still checks the owner role and the trusted confirmation itself — a direct invocation cannot skip either.
  • Actor and tenant never come from a tool argument. The toolkit is constructed with the trusted :class:RequestContext; a model can supply contract ids and field values, never who it is.

Class ContractsToolkit

Read and administer contracts through the shared service gate.

Parameter Type Default Description
service ContractsAnswerService The shared :class:ContractsAnswerService.
request_context RequestContext The trusted request context. Never derived from tool arguments.
library Any None Optional contract library (evidence reads, verification).
relations Any None Optional relation stage for related_contracts.
**kwargs Any {} Forwarded to :class:AbstractToolkit.

Attributes:

Attribute Type Description
name str
tool_prefix str
confirming_tools frozenset
exclude_tools tuple[str, ...]
retrieval ContractRetrieval The deterministic retrieval layer behind the service.
catalog Any The tenant-bound catalog.

Method ContractsToolkit.catalog_search

Search the contract catalog by free text.

catalog_search(query: str, top_k: int = 8) -> dict[str, Any]

Parameter Type Default Description
query str What to look for (title, summary, counterparty, clause).
top_k int 8 Maximum results (bounded by the service).

Returns: dict[str, Any] — Bounded contract briefs with their relevance rank.

Method ContractsToolkit.get_card

Return one contract's card.

get_card(contract_id: str) -> dict[str, Any]

Parameter Type Default Description
contract_id str The contract to read.

Returns: dict[str, Any] — The card brief plus term, parties, signatories and provenance summary — bounded, without the full ToC or evidence bodies.

Method ContractsToolkit.get_toc

Return a contract's table of contents.

get_toc(contract_id: str) -> dict[str, Any]

Parameter Type Default Description
contract_id str The contract to read.

Returns: dict[str, Any] — Node ids, titles and page ranges — the map for read_section.

Method ContractsToolkit.read_section

Read one indexed section body.

Retired evidence is unavailable: a node suppressed by an answer retirement is never returned, whichever version asks for it.

read_section(contract_id: str, node_id: str) -> dict[str, Any]

Parameter Type Default Description
contract_id str The contract to read.
node_id str The section node id.

Returns: dict[str, Any] — The section body, bounded, or an explicit reason.

Method ContractsToolkit.obligations

List obligations, optionally filtered.

obligations(contract_id: Optional[str] = None, kind: Optional[str] = None, standard_id: Optional[str] = None, until: Optional[str] = None) -> dict[str, Any]

Parameter Type Default Description
contract_id Optional[str] None Restrict to one contract.
kind Optional[str] None Restrict to one obligation kind.
standard_id Optional[str] None Restrict to obligations naming a standard.
until Optional[str] None ISO date bounding fixed due dates.

Returns: dict[str, Any] — Bounded obligation rows with their citable excerpt.

Method ContractsToolkit.expiring

List contracts expiring (or whose notice deadline falls) soon.

expiring(days: int = 90, by_notice: bool = True) -> dict[str, Any]

Parameter Type Default Description
days int 90 Window length in days.
by_notice bool True Use the notice deadline (with expiration fallback) instead of the expiration date.

Returns: dict[str, Any] — Bounded contract briefs ordered by the driving date.

Method ContractsToolkit.verification_queue

List cards awaiting human verification, highest priority first.

verification_queue(limit: int = 20) -> dict[str, Any]

Parameter Type Default Description
limit int 20 Maximum rows.

Returns: dict[str, Any] — Contract briefs with the reason each is queued.

Method ContractsToolkit.related_contracts

List the family and judged relations of a contract.

related_contracts(contract_id: str) -> dict[str, Any]

Parameter Type Default Description
contract_id str The contract to inspect.

Returns: dict[str, Any] — Family members plus active judged relations. Judgement itself never happens here — this only reads what was already judged.

Method ContractsToolkit.verify_card

Verify/correct fields, merge parties or override ownership.

Owner-only and confirming: the service re-checks the owner role and the trusted transport confirmation, so the metadata flag alone never authorises the write. The actor is taken from the trusted request context, never from an argument.

verify_card(contract_id: str, fields: Optional[dict[str, Any]] = None, merge_party_id: Optional[str] = None, keep_party_id: Optional[str] = None, owner_employee_id: Optional[str] = None, expected_revision: Optional[int] = None) -> dict[str, Any]

Parameter Type Default Description
contract_id str The card to verify or correct.
fields Optional[dict[str, Any]] None path -> value map; None values confirm.
merge_party_id Optional[str] None Party identity to fold into keep_party_id.
keep_party_id Optional[str] None Canonical party identity to keep.
owner_employee_id Optional[str] None New owner (an ownership override).
expected_revision Optional[int] None Revision the caller read.

Returns: dict[str, Any] — What was verified, corrected or merged.

Method ContractsToolkit.retire_answer

Retire a previously released answer and suppress its evidence.

Owner-only and confirming, enforced by the service.

retire_answer(answer_id: str, reason: str) -> dict[str, Any]

Parameter Type Default Description
answer_id str The audited answer to retire.
reason str Why it is being retired (recorded in the audit).

Returns: dict[str, Any] — The retirement record summary.

Attribute MAX_SECTION_CHARS

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