Q:

How to make a tag effect a relation

I'm working on a project using Python Flask-SQLAlchemy with a model like this:
car has components,
components can have errors
car has a hybrid_property 'broken' which is true when one of its components has errors.
Tags can be added and are assigned in a table(car_id, error_id, tag_id)
one of the tags will be something like 'irrelevant'
if all of a car's components' errors are tagged as irrelevant, broken should be false.
Is there a way to achieve this without hard-coding it into the hybrid property?

A:

Of course there is. But you certainly do not want to do that; i'd be a horrible and unmaintainable mess.
Your domain model seems fine to me; hard-coding this into the hybrid property also seems perfectly fine to me. It would go something like this (pseudo-java, i dont know python, sorry):
// in Car

public boolean isBroken() {
    return this.components.stream()
       .flatMap(Component::getErrors)
       .anyMatch(Error::isRelevant);
}

// in Error

public boolean isRelevant() {
    return !this.hasTag(ErrorTags.IRRELEVANT);
}

EDIT: After thinking about it for a bit something else came to my mind:
The question really is whether the error is relevant to the Component or to the Car. If the error is irrelevant for both component and car, it'd be better to include that logic into the component:
// in Component
public boolean isBroken() {
    return this.errors.stream().anyMatch(Error::isRelevantForComponent);
}

If the error is relevant for the component but not for the car, that logic should be in the car class.
If you actually decide to go into that level of detail, the irrelevant tag should have another attribute context that describes in what context the error is relevant. You can then set that proeprty either to "CAR" or to "COMPONENT" describing that the error is irrelevant or relevant to the car respectively.

