EXPECTED_UNITS = {"sensitivity": "nT/sqrt(Hz)", "mission_drift": "m", "power": "W"}
def assess(sheet):
    errors = []
    if type(sheet.get("scenario")) is not str or not sheet.get("source_ids"):
        errors.append("scenario_or_sources")
    measurements = sheet.get("measurements", {})
    passes = {}
    for name, unit in EXPECTED_UNITS.items():
        row = measurements.get(name, {})
        if (type(row.get("value")) not in (int, float) or
                type(row.get("limit")) not in (int, float) or row.get("unit") != unit or
                not row.get("method") or type(row.get("incumbent")) not in (int, float)):
            errors.append(name + "_schema")
        else:
            passes[name] = row["value"] <= row["limit"]
    decision = "invalid" if errors else ("procurement-test" if all(passes.values()) else "field-trial")
    return {"decision": decision, "errors": sorted(errors), "passes": passes,
            "failed": sorted(name for name, passed in passes.items() if not passed)}
sheet = {"scenario": "GPS-denied 60-minute mission", "source_ids": ["gao-quantum"],
         "measurements": {
             "sensitivity": {"value": 1.0, "limit": 1.2, "incumbent": 1.1,
                             "unit": "nT/sqrt(Hz)", "method": "shielded calibration"},
             "mission_drift": {"value": 180.0, "limit": 100.0, "incumbent": 95.0,
                               "unit": "m", "method": "one-hour blind route"},
             "power": {"value": 42.0, "limit": 50.0, "incumbent": 35.0,
                       "unit": "W", "method": "battery-rail meter"}}}
base_result = assess(sheet)
bad = {**sheet, "measurements": {**sheet["measurements"],
       "mission_drift": {key: value for key, value in sheet["measurements"]["mission_drift"].items()
                         if key != "method"}}}
bad_result = assess(bad)
improved = {**sheet, "measurements": {**sheet["measurements"],
            "mission_drift": {**sheet["measurements"]["mission_drift"], "value": 90.0}}}
improved_result = assess(improved)
assert base_result["passes"]["sensitivity"] and base_result["failed"] == ["mission_drift"]
assert bad_result["decision"] == "invalid" and "mission_drift_schema" in bad_result["errors"]
assert improved_result["decision"] == "procurement-test"
print(f"PASS: 70 instrument dossier failed={base_result['failed']} invalid={bad_result['errors']} drift90m={improved_result['decision']}")
