Skip to content

API Reference parrot_pipelines.planogram.contracts

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

parrot_pipelines.planogram.contracts

View source

Shared Pydantic contracts of the perceive → identify → compare cycle (FEAT-574).

Attribute APPEARANCE_UNDETERMINED

Type: FrozenSet[str]

Attribute APPEARANCE_VALUES

Type: Dict[str, FrozenSet[str]]

Class AddedShape

A shape the LLM proposes that perception missed. Has no authority over existing ids.

Fields:

Field Type Default Description
box_norm List[int]
kind ShapeKind ShapeKind.UNKNOWN
product Optional[str] None
brand Optional[str] None
text Optional[str] None
descriptors Dict[str, Any]
raw_confidence float 0.0
evidence List[str]

Attribute AppearanceColor

Attribute AppearanceFinish

Class AssessmentStatus

Completeness of an assessment — independent of whether violations exist.

Class ComparisonResult

Stage-3 output.

Fields:

Field Type Default Description
compliance_results List[ComplianceResult]
position_results List[PositionResult]
products_found List[SlotPresence]
shelf_scores List[ShelfScore]
overall_compliance_score float 0.0
strict_compliance_score Optional[float] None
overall_compliant bool False
coverage Optional[float] None
detected_products int 0
definition_coverage Optional[float] None
evidence_quality Optional[float] None
assessment_status AssessmentStatus AssessmentStatus.INCONCLUSIVE
errors List[str]

Class CreditPolicy

Strict / lenient credit per FacingStatus.

Fields:

Field Type Default Description
strict Dict[FacingStatus, float]
lenient Dict[FacingStatus, float]

Method CreditPolicy.default

Default credits: presence at the expected slot is a full lenient match.

default() -> 'CreditPolicy'

Returns: 'CreditPolicy'

Method CreditPolicy.is_resolved

Whether occupancy/compliance was resolved for coverage.

is_resolved(status: FacingStatus) -> bool

Parameter Type Default Description
status FacingStatus

Returns: bool

Class CycleContext

Per-run shared services handed to every hook.

Fields:

Field Type Default Description
vision Any None
executor Any None
ocr Any None
definition Optional[Any] None
bindings List[Any]
credit_policy CreditPolicy
evidence_weights EvidenceWeights
output_dir Optional[Path] None
layout Any None
reference_bank List[ReferenceImage]
roi_prompt Optional[str] None
images Dict[str, Any]
errors List[str]

Class EvidenceWeights

Evidence-quality weight per source. NEVER multiplies compliance credit.

Fields:

Field Type Default Description
cv float 1.0
llm_added float 0.5
llm float 0.5
legacy_llm float 0.5

Method EvidenceWeights.weight_for

Weight of one source.

weight_for(source: ObservationSource) -> float

Parameter Type Default Description
source ObservationSource

Returns: float

Class FacingStatus

Decision for one expected facing.

Class FixtureMembership

Whether a shape belongs to the fixture under assessment.

Class Identification

Stage-2 output for one shape or slot. Also the item type the LLM returns.

Fields:

Field Type Default Description
shape_id str
image_id Optional[str] None
product Optional[str] None
brand Optional[str] None
text Optional[str] None
descriptors Dict[str, Any]
occupancy str 'unknown'
raw_confidence float 0.0
evidence List[str]
source ObservationSource ObservationSource.CV
uncertain bool False
reference_id Optional[str] None

Class IdentificationResponse

Structured output of one identification call.

Fields:

Field Type Default Description
existing_identifications List[Identification]
added_shapes List[AddedShape]

Class IdentificationResult

Stage-2 output for one image, after validation.

Fields:

Field Type Default Description
image_id str 'img0'
identifications List[Identification]
added List[Shape]
rule_observations List[RuleObservation]
errors List[str]

Class IdentifyStrategy

LLM call granularity declared by a planogram type.

Class ObservationRef

Provenance of one observation that supports a facing decision.

Fields:

Field Type Default Description
image_id str
shape_id str
source ObservationSource
raw_confidence float 0.0
product Optional[str] None
occupancy str 'unknown'

Class ObservationSource

Who produced an observation. Never implies SKU identity.

Class OcrReading

Local read keyed by an observed target id.

Fields:

Field Type Default Description
text str ''
confidence float 0.0

Class PerceptionResult

Stage-1 output for one image.

Fields:

Field Type Default Description
image_id str 'img0'
image_size Tuple[int, int] (0, 0)
shapes List[Shape]
slots List[Slot]
zones List[Shape]
row_count int 0
detection_source str 'cv'
ocr_available bool False
ocr_readings Dict[str, OcrReading]
errors List[str]

Class PositionResult

Decision for one expected facing, merged across photos.

Fields:

Field Type Default Description
facing_id str
shelf_id str
status FacingStatus FacingStatus.NOT_ASSESSED
strict_credit float 0.0
lenient_credit float 0.0
identity Optional[str] None
observations List[ObservationRef]
notes List[str]

Class ReferenceImage

Per-run encoded reference with opaque prompt label and catalogue metadata.

Fields:

Field Type Default Description
label str
image bytes
catalog_key str
brand Optional[str] None

Class RenderRecord

Render of one input image.

Fields:

Field Type Default Description
image_id str
rendered_image Optional[Any] None
overlay_path Optional[str] None

Class RuleObservation

Neutral crop-tied observation, not an expected-rule verdict.

Fields:

Field Type Default Description
image_id str
target_id str
kind Literal['illumination', 'visual_features', 'zone_present', 'appearance', 'visual_checklist']
value str | bool | List[str] | Dict[str, str] | Dict[str, int] | None None
assessed bool False
source ObservationSource
evidence List[str]

Class RuleOutcome

Result of one bound non-product rule.

Fields:

Field Type Default Description
rule_id str
assessed bool False
passed Optional[bool] None
score float 1.0
penalty float 0.0
detail Optional[str] None
observations List[ObservationRef]

Class Shape

One perceived shape, in SOURCE-image pixels.

Fields:

Field Type Default Description
shape_id str
image_id str
kind ShapeKind ShapeKind.UNKNOWN
box DetectionBox
profile Optional[str] None
row_index Optional[int] None
slot_index Optional[int] None
ocr_text Optional[str] None
ocr_confidence Optional[float] None
source ObservationSource ObservationSource.CV
membership FixtureMembership FixtureMembership.UNCERTAIN
membership_evidence List[str]

Class ShapeKind

Kind of a perceived shape.

Class ShelfScore

Per-shelf measures (spec §2 scoring contract).

Fields:

Field Type Default Description
shelf_id str
shelf_level str
expected_facings int 0
facing_strict float 0.0
facing_lenient float 0.0
strict_score float 0.0
lenient_score float 0.0
coverage float 0.0
visible_fraction float 0.0
occupied_facings int 0
occupied_fraction float 0.0
rule_results List[RuleOutcome]
info_results List[RuleOutcome]

Class Slot

A product position derived from shapes (or gap-filled).

Fields:

Field Type Default Description
slot_id str
image_id str
row_index int
slot_index int
box DetectionBox
anchor_shape_id Optional[str] None
inferred bool False

Class SlotPresence

Presence of the expected model in one logical shelf slot.

Fields:

Field Type Default Description
shelf_id str
shelf_level Optional[str] None
slot int
position Optional[int] None
facing_ids List[str]
model str
sku Optional[str] None
brand Optional[str] None
display_name Optional[str] None
found Optional[bool] None
misplaced bool False
status FacingStatus
confidence Optional[float] None
facings int 1
facings_found int 0
observed Optional[str] None

Class ZoneAppearance

Closed-vocabulary appearance of one observed zone crop, as the model reads it.

Fields:

Field Type Default Description
background_color AppearanceColor 'unknown'
border_color Union[AppearanceColor, Literal['none']] 'unknown'
finish AppearanceFinish 'unknown'
base_surface_color Union[AppearanceColor, Literal['not_visible']] 'unknown'

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