FIELDS = ("artifact", "comparator", "reproduction", "representative", "outcome")
LABELS = ("mathematical", "artifact", "controlled", "reproduced", "representative", "operational")
def classify(record, maximum_age_days):
    errors = []
    for name in ("scenario", "claim", "evidence_origin"):
        if type(record.get(name)) is not str or not record.get(name):
            errors.append(name)
    if type(record.get("source_ids")) is not list or not record.get("source_ids"):
        errors.append("source_ids")
    age = record.get("age", {})
    if type(age.get("value")) is not int or age.get("unit") != "days":
        errors.append("age_schema")
    for name in FIELDS:
        if type(record.get(name)) is not bool:
            errors.append(name)
    if errors:
        return {"decision": "invalid", "errors": sorted(set(errors)), "ceiling": None}
    level = 0
    for name in FIELDS:
        if not record[name]:
            break
        level += 1
    if record["evidence_origin"] == "marketing" or age["value"] > maximum_age_days:
        level = min(level, 1)
    return {"decision": "classified", "errors": [], "ceiling": LABELS[level], "level": level}
common = {"scenario": "three-claim calibration packet", "source_ids": ["acm-artifact-review"],
          "age": {"value": 30, "unit": "days"}, "evidence_origin": "primary record"}
hardware = {**common, "claim": "circuit improves metric", "artifact": True, "comparator": True,
            "reproduction": True, "representative": False, "outcome": False}
pilot = {**common, "claim": "pilot creates value", "artifact": True, "comparator": True,
         "reproduction": False, "representative": True, "outcome": False}
hardware_result = classify(hardware, 90)
pilot_result = classify(pilot, 90)
bad = {key: value for key, value in hardware.items() if key != "comparator"}
bad_result = classify(bad, 90)
promoted_result = classify({**hardware, "representative": True}, 90)
assert hardware_result["ceiling"] == "reproduced" and pilot_result["ceiling"] == "controlled"
assert bad_result["decision"] == "invalid" and "comparator" in bad_result["errors"]
assert promoted_result["ceiling"] == "representative" and promoted_result["level"] > hardware_result["level"]
print(f"PASS: 71 evidence classifier hardware={hardware_result['ceiling']} pilot={pilot_result['ceiling']} invalid={bad_result['errors']} promoted={promoted_result['ceiling']}")
