Skip to content

risk_tier

risk_tier

Deterministic risk tier assignment for edits.

The teacher cannot pick its own tier. After the teacher emits edits, the planner overwrites each edit's risk_tier from the lookup table below. If the teacher attempted a different tier, it is silently overwritten and the discrepancy is logged but not surfaced as an error.

See spec §4.1 (tier table) and §6.2.

Classes

Functions

assign_tier

assign_tier(op: EditOp) -> EditRiskTier

Return the deterministic risk tier for a given edit op.

Source code in src/openjarvis/learning/distillation/plan/risk_tier.py
def assign_tier(op: EditOp) -> EditRiskTier:
    """Return the deterministic risk tier for a given edit op."""
    return TIER_TABLE[op]

assign_tiers

assign_tiers(edits: Sequence[Edit]) -> list[Edit]

Overwrite each edit's risk_tier from the canonical lookup table.

Returns a new list of Edit objects (pydantic copies). If the teacher had a different tier, it is silently overwritten and logged.

Source code in src/openjarvis/learning/distillation/plan/risk_tier.py
def assign_tiers(edits: Sequence[Edit]) -> list[Edit]:
    """Overwrite each edit's risk_tier from the canonical lookup table.

    Returns a new list of Edit objects (pydantic copies). If the teacher
    had a different tier, it is silently overwritten and logged.
    """
    result = []
    for edit in edits:
        correct_tier = assign_tier(edit.op)
        if edit.risk_tier != correct_tier:
            logger.info(
                "Edit %s: overwriting teacher tier %s%s (op=%s)",
                edit.id,
                edit.risk_tier.value,
                correct_tier.value,
                edit.op.value,
            )
        result.append(edit.model_copy(update={"risk_tier": correct_tier}))
    return result