class Trinity: def __init__(self, executive, imagine, validator): self.exec = executive self.imagine = imagine self.validator = validator def run(self, context): mode = self.exec.select_mode(context) weights = self.exec.allocate_weights(mode) context["mode"] = mode # IMAGINATION PHASE hypotheses = self.imagine.generate_hypotheses(context) # VALIDATION PHASE validated = [] for h in hypotheses: result = self.validator.validate(h, context.get("constraints", [])) if result["approved"]: validated.append(h) return { "mode": mode, "weights": weights, "hypotheses": validated }