AI in safety-related systems
Why This Matters
When a recommender is wrong, you watch a bad film. When the model in a car’s emergency brake is wrong, someone can die. Safety engineering has decades of practice for conventional software: requirements traced to code, deterministic behaviour, evidence that holds. AI undermines each of those. This lesson is about what breaks, and what testers do about it.
What you will learn
- What makes a system safety-related
- The five challenges AI adds to safety, and the mitigations for each
- What changes in the test approach when a model controls something dangerous
Syllabus: AI-2.1.2.
Safety-related systems
A safety-related system is one whose failure can harm people, property or the environment: braking and steering in a car, a medical device that doses a drug, a robot next to workers, control systems in a power plant. Such systems are developed under functional safety standards (for example ISO 26262 for road vehicles and IEC 61508 in general) that demand rigorous, documented evidence that the system is safe enough.
Five challenges AI adds
1. Specifications
Safety engineering starts from precise requirements, traced all the way to the implementation and the tests. With ML, requirements often start vague (“recognise pedestrians”) and the real specification ends up implicitly encoded in the training data: the model does what the examples showed it. Which pedestrians? Children, wheelchairs, people carrying a large box? If the data did not contain them, neither does the specification, and traceability from requirement to implementation is weak.
For testers: make the specification explicit. Write down the operating conditions and the situations the model must handle (the operational design domain), check that the training and test data cover them (lesson 37), and trace tests to those situations instead of to code.
2. Non-determinism
Even a well-tested model can behave unexpectedly: random number generation, or a tiny change in the input, can change the output. Safety evidence based on “it passed the test” is weaker when the next run may differ.
For testers: statistical testing with enough cases to give real confidence (lesson 44), robustness and adversarial testing (lessons 45, 46), and treating the variation itself as something to measure.
3. Self-learning
A system that keeps learning drifts from the state that was tested, so the safety evidence collected before deployment may no longer be valid. Mitigations named in the syllabus:
- control the learning data: decide what the system may learn from, and check it
- add safety guards outside the model: a conventional component that limits what the model can do, such as a content moderation filter on prompts, or a hard limit on the speed a model may request
For testers: test the guards as safety components in their own right, test the learning mechanism, and keep testing in production (lessons 25 and 47).
4. Explainability and transparency
Safety requires knowing why the system did something, both to trust it beforehand and to investigate an accident afterwards. Explainability tools such as LIME (Local Interpretable Model-agnostic Explanations) show which parts of an input mattered for a decision. But they are not available for every model, and they can cost performance.
For testers: use explanations as a test oracle where you can (did the model look at the pedestrian, or at the zebra crossing?), and require logging that makes decisions reconstructable.
5. Evolving regulations
Mature functional safety standards do not cover AI, and some forbid techniques that AI depends on. Standards for AI in safety are still being written. The EU AI Act treats AI used as a safety component in regulated products (aviation, medical devices, cars, machinery) as high-risk (lesson 4).
For testers: the test approach has to combine the existing safety standard for the conventional parts with the AI-specific evidence the Act and new standards ask for.
A common architecture: keep the AI inside a safe envelope
Because the model’s behaviour cannot be fully proven, safety-related systems often put a conventional, verifiable component around it:
sensors ──> ML model ──> proposed action ──> SAFETY MONITOR ──> actuator
(conventional code:
limits, plausibility,
fallback to safe state)
The model may propose; the monitor decides what is allowed. The monitor is deterministic and can be developed and tested under the existing safety standard. Testing then has two parts: the model (statistically, for performance and robustness) and the monitor (exhaustively, as safety-critical conventional software), plus the combination.
Exercise
Case study. A hospital wants an AI system that proposes the insulin dose for patients in intensive care, based on blood glucose, weight and medication. A nurse confirms every dose before it is given.
For each of the five challenges, name one concrete risk for this system and one test or mitigation.
Show suggested answer
| Challenge | Risk | Test or mitigation |
|---|---|---|
| Specifications | “Propose the right dose” is vague; patients with kidney failure were rare in the training data, so the model’s behaviour for them was never really specified | Write down the patient groups and conditions it must handle; check the data covers them; test per group |
| Non-determinism | Two runs for the same patient give different doses | Run the same inputs many times and measure the spread; set a maximum allowed variation as an acceptance criterion |
| Self-learning | If it learns from accepted doses, nurses’ habits drift into the model and the tested behaviour is gone | Lock the model, or control and review what it learns from; retest after each update |
| Explainability | The nurse cannot judge a proposal she does not understand, and confirms it anyway | Show the main factors behind each proposal; test whether nurses can spot a wrong proposal (a usability test of the oversight) |
| Regulation | It is a medical device and high-risk under the EU AI Act | Combine medical device testing with AI-specific evidence; a conventional safety monitor caps the dose at a maximum per kg body weight, and is tested as safety-critical software |
The nurse is a human oversight measure, but only if she can actually catch errors. Testing whether the oversight works is part of testing the system.
Exam-style questions
1. Why can a self-learning system undermine the safety evidence collected before deployment?
- A. Self-learning systems cannot be tested before deployment
- B. Its behaviour can drift from the state that was tested
- C. Self-learning systems are always non-deterministic
- D. Safety standards forbid testing self-learning systems
Show answer
2. Why are specifications a particular challenge for ML in safety-related systems?
- A. ML systems do not need requirements
- B. Requirements often start vague and are implicitly encoded in the training data, so traceability to the implementation is weak
- C. ML systems are always specified more precisely than conventional systems
- D. Specifications cannot be written in natural language
Show answer
3. What is LIME?
- A. A functional safety standard for AI
- B. A tool that explains which parts of an input influenced a model’s decision
- C. A method to generate training data
- D. A hardware accelerator for safety-related systems