Skip to content

API Reference parrot.flows.dev_loop.sdd_coder.complexity_models

github-actions[bot] edited this page Nov 10, 2026 · 4 revisions

parrot.flows.dev_loop.sdd_coder.complexity_models

View source

Pydantic complexity models for deterministic SDD task routing (spec §2-§4).

No logic, no I/O. All structured values use Pydantic models, extra fields forbidden.

Attribute COMPLEXITY_ERROR_CODES

The four complexity-specific error codes (spec §2). Mirrored into sdd_coder.models.ERROR_CODES (the closed set for CoderError.code); kept local here, rather than imported back from models.py, because models.py imports from this module and a reverse import would create a cycle.

Type: frozenset[str]

Class ComplexityAssessment

Immutable complexity classification result for one task.

Fields:

Field Type Default Description
schema_version Literal[1] 1 Must be 1 for this specification.
policy_version str The ComplexityPolicy version used.
task_id str The task identifier.
classification Literal['standard', 'complex', 'unknown'] One of 'standard', 'complex', or 'unknown'.
total_points int Sum of component points per policy bands.
component_points Dict[str, int] Per-metric point contribution.
reason_codes Tuple[str, ...] Tuple of reason codes explaining the classification.
evidence ComplexityEvidence The ComplexityEvidence this assessment is based on (owned/copied).
assessment_id str SHA-256 of canonical JSON representation.

Class ComplexityBlock

A routing block preventing task dispatch.

Fields:

Field Type Default Description
task_id str The task identifier.
assessment_id Optional[str] None The ComplexityAssessment ID if available, else None.
code str One of the complexity error codes.
message str Human-readable explanation.
details Dict[str, Any] Additional diagnostic information.

Class ComplexityContract

Machine-readable contract declaring task targets and existing symbols.

Fields:

Field Type Default Description
schema_version Literal[1] 1 Must be 1 for this specification.
targets Tuple[ComplexityTarget, ...] Tuple of ComplexityTarget entries from the task.
contract_symbols Optional[Tuple[str, ...]] None Tuple of symbol IDs (e.g., 'sym:path#SymbolName') that the task's Codebase Contract verified. None indicates legacy missing coverage; empty tuple is an explicit declaration of zero symbols.

Class ComplexityEvidence

Complete evidence snapshot for one task's complexity assessment.

Fields:

Field Type Default Description
task_id str The task identifier (e.g., 'TASK-3286').
contract ComplexityContract The ComplexityContract parsed from the task.
metrics Dict[str, MetricEvidence] Dictionary of metric name to MetricEvidence.
head_sha str Git HEAD SHA at time of collection.
task_sha256 str SHA-256 of the task file content.
index_sha256 str SHA-256 of the per-spec index file.
policy_sha256 str SHA-256 of the ComplexityPolicy used.
target_hashes Dict[str, Optional[str]] Mapping from target path to content hash, or None for CREATE.
wiki_evidence_hashes Dict[str, str] Mapping from symbol root to wiki query result hash.
collector_versions Dict[str, str] Mapping from collector name to version string.
details Dict[str, Any] Additional diagnostic information including direct dependents, CREATE/MODIFY counts, impacted files, per-function values and raw results.

Class ComplexityPolicy

Versioned policy governing complexity classification and routing.

Fields:

Field Type Default Description
version str 'v1' Policy version string (e.g., 'v1').
strong_models Tuple[StrongModelIdentity, ...] () Tuple of allowed model identities for complex/unknown tasks.
bands Dict[str, Tuple[int, int]] Mapping from metric name to (min_points, max_points) tuples for scoring. Each band contributes at most 2 points.
hard_limits Dict[str, int] Mapping from metric name to threshold that triggers complex classification directly, regardless of total_points (spec §2's three named hard triggers only: cyclomatic_max, blast_symbols, downstream_tasks).
two_point_thresholds Dict[str, int] Mapping from EVERY metric name to the value at/above which it scores 2 points (spec's "inclusive bands" second boundary, all six metrics: 11/21, 10/30, 4/8, 2/3, 5/8, 2/5). Distinct from hard_limits: scoring 2 points on weighted_files/modules/acceptance_criteria contributes to total_points but never auto-triggers complex by itself, unlike the three hard_limits metrics.
score_threshold int 5 Total points at or above which a task is classified complex.
timeout_seconds int 30 Maximum seconds to wait for any measurement tool.
max_output_bytes int 8388608 Maximum bytes to capture from measurement tool output.
max_concurrency int 4 Maximum parallel measurement operations.

Class ComplexityTarget

One file target from the task's Files to Create / Modify table.

Fields:

Field Type Default Description
path str Repo-relative path to the target file.
action Literal['CREATE', 'MODIFY'] The declared action - CREATE or MODIFY.

Class MetricEvidence

Evidence snapshot for one metric family.

Fields:

Field Type Default Description
state Literal['ok', 'unknown', 'not_applicable'] Measurement outcome - ok (valid measurement), unknown (tool failed or result unavailable), not_applicable (metric does not apply to this task).
value Optional[int] None The measured integer value, or None if state is not 'ok'.
reason str Human-readable explanation of the state, including tool name/version for unknown, or the rationale for not_applicable.
source str Origin of the measurement (e.g., 'ruff', 'wikitoolkit', 'task_parser').

Class StrongModelIdentity

A canonical model candidate and its backend mapping.

Fields:

Field Type Default Description
canonical_model str The policy-level identifier (e.g., 'gpt-5.6-terra', 'sonnet-5').
backend str The backend name that provides this model (e.g., 'codex', 'claude', 'native').
model str The exact deployed model identifier as reported by the provider.
effort Optional[_SeatEffort] None Optional reasoning effort for this model. Not part of the identity key (dedup stays on (backend, model)). Adding the field changes policy_sha256 once, which invalidates cached assessments one time.

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