Skip to content

Health Software Common Practices

HSCP-T-019 · open test

Human oversight matrix of an AI system

Serves HSCP-G-066, HSCP-G-029 · Recipe: HSCP-R-032

Code under the licence Apache 2.0 · Python 3.10 or later, standard library only, no network access

What the test checks

The artefact is the oversight matrix delivered with the version, a JSON file: systeme (nom, version, agit) and usages (usage, impact, supervision, validation_avant_versement, validation_groupee, actions, and actions_systeme when the system acts).

The test accepts the matrix if each use has an impact (important, modere, faible), an oversight level (integrale, allegee) and validation before filing in the record; if a high impact has a full review without bulk validation; if each use offers ignorer and arreter; and, for a system that acts, if its actions are classified (autonome, approbation, interdite) with no high-impact action executed on its own.

Running the test

python3 verifier.py matrice.json

--json gives the answer in JSON. Exit code: 0 artefact accepted, 1 artefact rejected, 2 incorrect call. Python 3.10 or later, no dependencies.

Examples

  • exemples/valide/: three uses, a severity rating under full review, a draft letter under light review, an appointment booking whose sending waits for approval. Accepted.
  • exemples/refuse/: severity rating under light review with bulk validation, without ignore or stop; a use without oversight; an emergency referral triggered without approval; an action regime outside the list. Rejected.

What the test does not say

  • It does not say that impacts are correctly classified: the review with the organisation judges that.
  • It does not say that the product behaves as the matrix says: the test run of each version shows that.
  • It does not say that validations are made with care.

Code

Download the test (zip archive: program, examples, README, licence) (9 KB) · verifier.py

The code and its messages are not translated (French).

#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 les contributeurs des Gestes communs du logiciel de santé
"""HSCP-T-019 : matrice de supervision humaine d'un système d'IA.

    python3 verifier.py <matrice.json> [--json]

Lit un objet JSON : systeme (nom, version, agit) et usages (usage, impact, supervision, validation_avant_versement,
validation_groupee, actions, actions_systeme si le système agit : action, regime, impact).
Refus : fichier illisible ; aucun usage ; impact ou supervision hors liste ; validation avant versement absente ;
impact important sans revue intégrale ou avec validation groupée ; usage sans les actions ignorer et arrêter ;
système qui agit sans actions classées ; action hors régime ; action d'impact important exécutée sans approbation.
Il ne dit pas que les impacts sont bien classés ni que le produit se comporte comme la matrice le dit.

Codes de retour : 0 pièce acceptée, 1 pièce refusée, 2 appel incorrect.
Bibliothèque standard seulement, aucun accès réseau.
"""
import argparse
import json
import sys

ID = "HSCP-T-019"
IMPACTS = {"important", "modere", "faible"}
SUPERVISIONS = {"integrale", "allegee"}
ACTIONS = {"accepter", "corriger", "ignorer", "arreter"}
REGIMES = {"autonome", "approbation", "interdite"}


def verifier(d):
    refus = []
    s, usages = d.get("systeme") or {}, d.get("usages")
    if not s.get("nom") or not s.get("version") or not isinstance(usages, list) or not usages:
        return ["systeme (nom, version) ou usages absents"], 0
    for i, u in enumerate(usages, 1):
        nom = f"usage « {u.get('usage') or i} »"
        if u.get("impact") not in IMPACTS or u.get("supervision") not in SUPERVISIONS:
            refus.append(f"{nom} : impact ou supervision absent ou hors liste")
            continue
        if u.get("validation_avant_versement") is not True:
            refus.append(f"{nom} : pas de validation avant versement au dossier")
        if u["impact"] == "important":
            if u["supervision"] != "integrale":
                refus.append(f"{nom} : impact important sans revue intégrale")
            if u.get("validation_groupee") is True:
                refus.append(f"{nom} : impact important avec validation groupée")
        a = set(u.get("actions") or [])
        if a - ACTIONS:
            refus.append(f"{nom} : action(s) hors liste : {', '.join(sorted(a - ACTIONS))}")
        if not {"ignorer", "arreter"} <= a:
            refus.append(f"{nom} : ignorer et arrêter doivent être offerts")
        if s.get("agit") is True:
            ax = u.get("actions_systeme")
            if ax is None:
                continue
            for x in ax:
                if x.get("regime") not in REGIMES:
                    refus.append(f"{nom}, action « {x.get('action')} » : régime absent ou hors liste")
                elif x["regime"] == "autonome" and (x.get("impact") or u["impact"]) == "important":
                    refus.append(f"{nom}, action « {x.get('action')} » : impact important exécuté sans approbation")
    if s.get("agit") is True and not any(u.get("actions_systeme") for u in usages):
        refus.append("système qui agit sans actions classées")
    return refus, len(usages)


def main(argv):
    p = argparse.ArgumentParser(prog="verifier.py", description=__doc__.splitlines()[0])
    p.add_argument("fichier")
    p.add_argument("--json", action="store_true")
    try:
        a = p.parse_args(argv)
    except SystemExit:
        return 2
    try:
        d = json.load(open(a.fichier, encoding="utf-8"))
        assert isinstance(d, dict)
    except (OSError, ValueError, AssertionError) as e:
        print(f"{ID} : pièce illisible : {e}", file=sys.stderr)
        return 2
    refus, n = verifier(d)
    if a.json:
        print(json.dumps({"test": ID, "accepte": not refus, "usages": n, "refus": refus}, ensure_ascii=False, indent=2))
    else:
        print(f"{ID} : {'pièce acceptée' if not refus else 'pièce refusée'} ({n} usage(s))")
        for x in refus:
            print("  refus :", x)
    return 0 if not refus else 1


if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))

Files of the test