How does compatibility work

Detailed run down on how compatibility is determined

Compatibility = same interface intent + matching attributes + a valid resource assignment.

ProtoParts expose two things: Resources and Interfaces. The validator joins them with a small set of checks to decide if parts can work together in a project.


Core concepts

ProtoPart

A part definition that groups one or more domains (electrical, mechanical, pneumatic, hydraulic, data).

Resource

An atomic endpoint inside a domain. Defined by one or more functions plus attributes. Examples:

  • Electrical: power_output, ground, digital_io with logic levels, current limits, frequency ranges.

  • Mechanical: shaft_keyed_5mm, mount_pattern_20mm, bearing_bore_8mm.

  • Fluid: hose_4mm_pushfit, pressure_input, pressure_output with pressure and temperature ratings.

Notes:

  • Each function has a direction such as source, receiver, or bidirectional.

  • A resource can be marked shareable_with other functions when physically common (e.g., ground shared with power).

Interface

A named bundle that declares capability and wiring expectations:

  • protocol: { "type": <enum>, "role": <enum> } (e.g., digital/output or digital/receiver)

  • requires: list of required functions with counts and optional shareable_with hints

  • constraints: hard rules like max_connections or requires_matching_voltage_domain

  • Optional power_delivery, description, and aliases

If two parts implement the same interface with complementary roles and pass constraints, they are compatible.


Decision flow

  1. Interface identity and role complement

    Interfaces must have the same id (or a declared alias) and complementary role values.

  2. Cardinality

    Consumer requires must be satisfiable by provider resources and vice versa, including allowed sharing.

  3. Type alignment inside the same domain

    Functions must be pairable (digital_io to digital_io, power_output to power_input, hose_4mm_pushfit to the same fitting type, etc.).

  4. Hard attribute checks

    All required attributes fall within limits. Examples:

  • Electrical: voltage range, current budget, logic level thresholds, PWM frequency

  • Data: protocol, bitrate tolerance, address availability, required pull‑ups present

  • Mechanical: bore size, pattern, fit class, envelope clearance

  • Fluid: pressure rating, temperature range, medium compatibility

  1. System checks

    Cross‑part totals and conflicts: power budget, thermal headroom, bus fanout, I²C/SPI address collisions, timing.

  2. Soft preferences and scoring

    Non‑blocking preferences like noise limits, vendor, package. These adjust a score but do not fail the match.

Outcomes

  • full_compatibility: all hard checks pass and a concrete assignment exists

  • compatible_with_adapter: intent matches but an adapter is needed (e.g., level shifter, connector converter)

  • incompatible: interface mismatch, role conflict, cardinality shortfall, or hard rule failure


Pin and port assignment

Treat resource hookup as a bipartite assignment problem. Build edges only where function and attributes are compatible. If a perfect matching exists that also satisfies hard constraints and cardinality, emit the mapping. Otherwise report the smallest adapter set that would complete the matching, if available.


Example: RC Servo 3‑wire

Intent

A controller provides 5 V power, ground, and a 50 Hz digital control signal. A servo consumes them.

Controller excerpt

Servo excerpt

Result

  • Interface ID matches. Roles complement. Cardinality satisfied.

  • Logic levels and PWM frequency compatible. Power budget checked via power_delivery and controller current rating.

  • Valid mapping: { vout5 → vdd, gnd0 → gnd, pwm0 → sig }.


Adapters

Adapters are parts that present interface_A as a consumer and interface_B as a provider, translating attributes or connectors. The validator can propose a minimal adapter set when intent matches but attributes do not.


Versioning and inheritance

  • Version interfaces with simple integers or semver. Mark backward‑compatible changes.

  • Allow specific interfaces to implement more general ones (e.g., i2c_sensor implements i2c_device).


Units and normalization

Store numbers in normalized SI in the validator. Keep user‑facing units as metadata. Matching is always performed on normalized values, with converters for display and input.


Validator output shape


Last updated

Was this helpful?