def _is_active_room_object(
    state: state_def.State, objkey: str, var_assignments: dict[t.Variable, str]
) -> bool:
    """
    Determine if an object should be active for the given assignment

    if there is a `room` var specified, `objkey` must be a descendent of that room
    if there is an `obj` var specified, `objkey must not be a descendent of any other obj

    """

    for var, assignment in var_assignments.items():
        if assignment is None:
            continue
        match var.name:
            case "room":
                room_ancestors = find_ancestors_of_type(
                    state, objkey, r.Domain({t.Semantics.Room})
                )
                if assignment not in room_ancestors:
                    logger.debug(
                        f"{objkey} is inactive due to room {room_ancestors=} {assignment=}"
                    )
                    return False
            case "obj":
                obj_ancestors = find_ancestors_of_type(
                    state, objkey, r.Domain({t.Semantics.Object})
                )
                if len(obj_ancestors) and objkey not in obj_ancestors:
                    logger.debug(
                        f"{objkey} is inactive due to obj {assignment=} {obj_ancestors=}"
                    )
                    return False
            case _:
                raise NotImplementedError(
                    f"{_is_active_room_object.__name__} encountered unknown variable {var}. "
                    "Greedy stages with vars besides room/obj are not yet supported"
                )

    return True

    Determine if an object should be active for the given assignment

    if there is a `room` var specified, `objkey` must be a descendent of that room
    if there is an `obj` var specified, `objkey must not be a descendent of any other obj

    
infinigen/core/constraints/example_solver/greedy/active_for_stage.py