Skip to content

API Reference parrot.observability.recorders.spec_usage

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

parrot.observability.recorders.spec_usage

View source

SpecUsageRecorder — durable per-feature usage sink (FEAT-783 M5).

A SINK, not an EventProvider: the existing UsageRecordingSubscriber owns the subscription (run_ledger.py:1-14 pattern). Root resolution reuses FEAT-554's rule (main checkout via git-common-dir; refused inside the worktree base) so rows outlive git worktree remove. cumulative_cost_usd is process-cumulative: readers must never sum it.

Alias AbstractLogger

Re-exported from parrot.observability.recorders.base.AbstractLogger.

Attribute SPEC_USAGE_SUBDIR

Class SpecUsageRecorder

Append one JSONL row per attributed UsageRecord to <root>/<feat_id>.jsonl.

Parameter Type Default Description
root Optional[Path] None Explicit absolute durable root, or None to derive the main checkout.
worktree_base_path str Parent directory containing disposable worktrees.

Attributes:

Attribute Type Description
name str
root Path The validated durable root.

Method SpecUsageRecorder.record

Append one row keyed by feat_id. Fail-open: never raises, warns once.

record(record: UsageRecord) -> None

Parameter Type Default Description
record UsageRecord Normalized usage record to persist.

Method SpecUsageRecorder.aclose

Await in-flight writes. Unlike RunLedgerRecorder.aclose this is not a no-op.

aclose() -> None

Alias UsageRecord

Re-exported from parrot.observability.recorders.models.UsageRecord.

Function default_spec_usage_root

Return the ONE canonical spec-usage root: <durable coder root>/spec-usage.

default_spec_usage_root(worktree_base_path: str, configured: Optional[str] = None) -> Path

Parameter Type Default Description
worktree_base_path str Parent directory containing disposable worktrees (the root must stay outside it).
configured Optional[str] None Optional explicit durable coder root (same meaning as the coder telemetry directory).

Returns: Path — The validated absolute usage root.

Raises:

  • ValueError — The derived root is relative, unresolvable, or inside the worktree base.

Attribute logger

Function read_spec_usage

Read every row for feat_id; malformed lines are skipped.

read_spec_usage(root: Path, feat_id: str) -> list[UsageRecord]

Parameter Type Default Description
root Path Directory containing per-feature JSONL files.
feat_id str Feature identifier used to select the guarded filename.

Returns: list[UsageRecord] — Valid usage records in file order, or an empty list when the file is absent.

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