Skip to content

API Reference parrot_pipelines.planogram.comparison.definition

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

parrot_pipelines.planogram.comparison.definition

View source

Slots definition: what a fixture is expected to hold, plus the rule bindings that target it.

Alias APPEARANCE_VALUES

Re-exported from parrot_pipelines.planogram.contracts.APPEARANCE_VALUES.

Attribute AttributeValue

Class CompletenessPolicy

Minimum resolved-facing fractions for a COMPLETE assessment (1.0 = every facing resolved).

min_coverage gates the global assessment_status; min_shelf_coverage gates each shelf's ComplianceResult.assessment. Tolerance only changes completeness, never credits or scores.

Fields:

Field Type Default Description
min_coverage float 1.0
min_shelf_coverage float 1.0

Class Descriptors

Per-position product description. All optional; price is never required.

Fields:

Field Type Default Description
display_name Optional[str] None
sku Optional[str] None
family Optional[str] None
xl Optional[bool] None
colors List[str]
pack Optional[int] None
identifiers List[str]
aliases List[str]
price Optional[float] None
attributes Dict[str, AttributeValue]

Attributes:

Attribute Type Description
described bool True when display_name is non-empty (the definition of a described position).
sufficient bool True when described or carrying at least one non-empty identifier.

Class FacingDefinition

One expected physical facing with a stable id.

Fields:

Field Type Default Description
facing_id str
shelf_id str
slot int
product Optional[str] None
brand Optional[str] None
facings int 1
facing_index int 1
position Optional[int] None
descriptors Descriptors
expected_occupancy Literal['occupied', 'empty'] 'occupied'

Attribute REPORTING_META_KEY

Class ReportingPolicy

Control product labels and optional slot-presence reporting.

Fields:

Field Type Default Description
product_label Literal['display_name', 'product'] 'display_name'
slot_presence bool False
misplaced_min_confidence float 0.9

Class RuleBinding

Binds one non-product rule of planogram_config to a stable id of the definition.

Fields:

Field Type Default Description
rule_id str
kind RuleKind
target_id str
params Dict[str, Any]
mandatory bool True

Attribute RuleKind

Class ShelfDefinition

One shelf; level matches ShelfConfig.level of planogram_config when both exist.

Fields:

Field Type Default Description
shelf_id str
shelf_number int
level Optional[str] None
ordered bool True
facings List[FacingDefinition]

Class SlotsDefinition

Versioned definition of shelves, facings and zones.

Fields:

Field Type Default Description
version str '1'
meta Dict[str, Any]
shelves List[ShelfDefinition]
zones List[ZoneDefinition]

Method SlotsDefinition.all_facings

Facings in shelf order, then (slot, facing_index).

all_facings() -> List[FacingDefinition]

Returns: List[FacingDefinition]

Class SlotsDefinitionError

Invalid slots definition or rule bindings (fail fast at construction time).

Attribute VIRTUAL_SHELF_PREFIX

Class ZoneDefinition

Non-product zone (header / backlit / poster / box stack) detected apart from product rows.

Fields:

Field Type Default Description
zone_id str
kind ZoneKind
shelf_id Optional[str] None
required bool True

Attribute ZoneKind

Function definition_coverage

Return (fraction of facings with sufficient descriptors, undescribed facing_ids). Never raises.

definition_coverage(definition: SlotsDefinition) -> Tuple[float, List[str]]

Parameter Type Default Description
definition SlotsDefinition A loaded definition.

Returns: Tuple[float, List[str]] — The coverage fraction (1.0 for a definition without facings) and the ids of occupied facings lacking sufficient descriptors. Expected-empty facings count as covered, and a described occurrence of the same product counts for every occupied facing of it.

Function effective_reporting

Merge default/layout reporting with explicitly provided definition overrides.

effective_reporting(layout: Optional[Any], definition: Optional[SlotsDefinition]) -> ReportingPolicy

Parameter Type Default Description
layout Optional[Any] Optional layout-like object exposing a validated reporting policy.
definition Optional[SlotsDefinition] Optional slots definition whose metadata may provide partial overrides.

Returns: ReportingPolicy — The resolved reporting policy without mutating either input.

Function load_slots_definition

Parse and validate a slots definition.

Blocking file read for a path source — call via asyncio.to_thread from async code.

load_slots_definition(source: Union[Dict[str, Any], str, Path]) -> SlotsDefinition

Parameter Type Default Description
source Union[Dict[str, Any], str, Path] A dict (JSONB column value) or a path to a JSON file, in native or page1 layout.

Returns: SlotsDefinition — The validated definition; shelves ordered by shelf_number, facings by (slot, facing_index). Unowned zones receive deterministic virtual shelves after physical shelves.

Raises:

  • SlotsDefinitionError — unreadable / non-JSON source, schema error, or any rule of _validate.

Attribute logger

Function validate_bindings

Validate planogram_config["rule_bindings"] against the definition's stable ids.

validate_bindings(definition: SlotsDefinition, planogram_config: Dict[str, Any]) -> List[RuleBinding]

Parameter Type Default Description
definition SlotsDefinition A loaded definition.
planogram_config Dict[str, Any] The raw planogram configuration.

Returns: List[RuleBinding] — The validated bindings ([] when the key is absent).

Raises:

  • SlotsDefinitionError — malformed binding, duplicate rule_id, dangling target_id, ambiguous target_id (present in more than one of facing / zone / shelf namespaces), a fact_tag_present rule that does not target a facing, a mandatory fact_tag_present rule, an appearance rule that targets a facing or has an unknown attribute or value, a shelf with no facings that ends up with no mandatory bound rule, or a required zone without a mandatory zone_present binding targeting that zone.

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