Deterministic operators
← Relifold documentation

Assign

Recover labeled relationships between two Spaces with deterministic code.

Assign applies a trusted labeled relationship function to X and Y values.

Worked example

Assign(
    name="assign-orders-to-bands",
    input_spaces=("orders", "price-bands"),
    output_space="order-bands",
    primary_key="id",
    evidence=("total", "name", "minimum", "maximum"),
    labels=("low", "medium", "high"),
    fn=lambda order, band: (
        band["name"]
        if band["minimum"] <= order["total"] < band["maximum"]
        else None
    ),
    max_assignments_per_x=1,
)

Callable contract

fn(x_row, y_row) -> label | None. Returned labels must be declared.

Rows available to the callable

Each row argument contains the declared primary-key fields and the declared evidence fields available for that input role. If the callable reads a field that is not part of the primary key, declare it as evidence.

One primary-key shape identifies values independently on both sides, so every primary-key column must exist in every input Space. When the two roles use different names for their central values, first use deterministic transforms to copy them to a common alias.

ParameterDefaultMeaning
input_spacesrequiredThe Space or Spaces read by the task.
output_spacerequiredThe Space that receives the task output.
namerequiredA stable task name used in sessions, reviews, and metrics.
primary_keyidThe field, or tuple of fields, that identifies one task input. Duplicate primary-key values are evaluated once.
evidencenoneOptional fields made available to the callable in addition to the primary key.
fnrequiredA deterministic callable that completely defines the operation's decision. Use an importable named function from your package, or PythonFunction(name=..., source=...) when authoring through the hosted API or node editor. Pairwise endomorphic functions may declare an exact indexed candidate_gate.
function_parametersregistered defaultsTyped values bound to parameters declared by the registered function. Finite candidate sets let reviewed evidence support parameter advice.
ParameterDefaultMeaning
labelsrequiredThe complete allowed assignment vocabulary.
max_assignments_per_xunlimitedValidate that each X has at most this many authoritative Y assignments.
max_assignments_per_yunlimitedValidate that each Y has at most this many authoritative X assignments.
exact_xfalseRequire every X to have exactly its declared maximum.
exact_yfalseRequire every Y to have exactly its declared maximum.

Output

Labeled X-to-Y assignments.

Design guidance

Deterministic degree fields validate the complete labeled relation. A violation fails the task; Assign never discards a true label or fabricates a missing assignment.