Repository Summary
| Description | |
| Checkout URI | https://github.com/marunigno-ship-it/QERRA-v2-classical.git |
| VCS Type | git |
| VCS Version | main |
| Last Updated | 2026-11-30 |
| Dev Status | UNKNOWN |
| Released | UNRELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
| Name | Version |
|---|---|
| qerra_core | 2.5.0 |
README
QERRA-v2 Classical
A fully explainable, classical three-layer pipeline for AI systems and autonomous robots.
Physical safety (Supervisory Gate + QERRA-HSR) → moral filtering (SEMEV-12) → flourishing-ranked choice (QERRA-THRIVE) — 27 named, auditable vectors (3 + 12 + 12), deterministic rule bounds.
The Idea in One Sentence
Values and ethics can screen and rank what a robot wants to do, but only a deterministic gate decides what the wheels do.
The setting this is built for: a transport cobot in a hospital corridor yields and slows near people, and the Gate is intended to command a stop when specified monitored fault conditions are detected. A Gate process or communication failure still requires an independent downstream command timeout or hardware safety function; this prototype does not demonstrate that the robot stops safely by itself after process failure. The system can leave a record a safety officer can audit.
Status in one paragraph. QERRA is a simulation-based research prototype. It is not a certified safety system, it has not been tested on hardware, and a 0.0 wheel command is a software setpoint, not an emergency stop. The deterministic gate (Gate Core v0.5) is demonstrated in Webots and, as a standalone ROS 2 node (
qerra_gate_nodev0.3.2), is built, executed and tested under ROS 2 Jazzy in GitHub Actions (live DDS topic traffic, dual-protocol reflex co-execution, Pattern B topic remapping, Nav2-compatible exterior command-interface tests,/odomingestion tests including a live DDS/odompublisher, and LaserScan metadata validation tests). Package metadata is v2.5.0 (Gate Core v0.5, ROS 2 Node v0.3.2), incorporating the measured-velocity dynamic stopping envelope, standstill-qualified dwell, 10-point LaserScan metadata and REP-117 bounds validation, and empirical ROS 2 Jazzy timing characterization. Current test counts are in Running the Tests, measured timing is in Empirical ROS 2 timing and contention, and the GitHub Actions workflows (tests.ymlandros2_jazzy.yml) are the live source of truth for CI runs. The Pattern B tests exercise a Nav2-compatible external command interface; they do not launch a complete Nav2 stack. The optional standstill-qualified recovery dwell is opt-in, and the archived Webots runs predate it and the measured-velocity stopping envelope. Localhost is an assumed trusted process boundary, and two documented exploit scenarios show what that assumption leaves open. See the frozen Technical Brief and Known limitations.
| Layer | Role | Evidence today |
|---|---|---|
Layer 1A: Supervisory Gate (gate/) |
The component that decides wheel commands. In the Webots controller it is the only process that writes wheel velocities. Pure standard-library integer state machine enforcing a dynamic stopping envelope $d_{stop}(v_{ref})$ with $v_{ref} = \max(v_{cmd}, v_{meas})$, where $v_{meas}$ is the chassis forward speed derived from measured wheel feedback, watchdog liveness (150 ms), and fail-closed latched recovery with operator reset. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required: bool = False, w_standstill_tol_urad_s: int = 50_000 urad/s): when enabled, the 1.0 s calm dwell waits for verified physical standstill from measured wheel speeds, without generating a deceleration trajectory (an open-loop TRIP_BRAKING was intentionally rejected to keep Doer-Checker separation; the Gate commands (0, 0) immediately upon any trip). Both the Webots controller and the ROS 2 node can log every tick to a SHA-256 rolling hash chain, and the node trips fail-closed if a log write fails (requirement R-10). |
Demonstrated in simulation: Demos 7, 8, 9 and 10 (the archived runs predate the standstill-qualified dwell and the measured-velocity envelope). Flight log verifiable offline with verify_log.py --replay. Core invariants (zero actuator authority outside RUN, stopping-envelope lower bound, clock monotonicity, standstill-dwell gating, HSR stream-monitor properties) are checked by stdlib property tests over defined input grids (tests/test_gate_invariants.py). Also packaged as a standalone ROS 2 node (qerra_gate_node v0.3.2) with parameterised timing profiles (96 ms simulation, 160 ms for a 10 Hz scanner), built and tested under ROS 2 Jazzy in CI: live DDS topic traffic, dual-protocol reflex integration, Pattern B topic remapping, Nav2-compatible exterior command-interface integration, /odom ingestion and watchdog tests (isolated stubs plus a live DDS /odom publisher), and LaserScan metadata validation. Software-side timing was measured once inside the ros:jazzy container (see Empirical ROS 2 timing and contention); it is an observation, not a bound. The Nav2 exterior tests use a Nav2-compatible command-source harness, not a running Nav2 stack. Current counts: see Running the Tests. Simulation and CI evidence only. |
Layer 1B: QERRA-HSR (hsr/) |
A 3-vector reflex signal (immediate_physical_distress, human_isolation, environmental_hazard_proximity) under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. The Gate acts on it when it is wired in (CRITICAL trips the gate). In the ROS 2 node a pure-function stream monitor (step_hsr_stream), wrapped by the shared pure-Python receiver gate/hsr_receiver.py (ros2/hsr_receiver.py is a compatibility shim), checks packet sequence order, detects frozen frames, and allows a counter rebase only after both at least 5 qualifying control ticks and at least 160 ms of elapsed observation time. Telemetry arrives over UDP (default, used by Webots) or over a ROS topic (hsr_source="topic", in which case no UDP socket is opened). Pure Python, Apache-2.0. (“HSR” here is this project’s own name and is unrelated to Toyota’s Human Support Robot.) |
Built and unit-tested (see Running the Tests). Evaluated in Webots Demos 6, 9 and 10 with a stabilised 1.0 s dwell and Property HSR-5 recovery directives. The stream monitor has edge-case matrix tests and a 159 ms / 160 ms rebase boundary test in the host suite, and the ROS-topic path is exercised by live multi-node tests in the container (dwell, acute distress, frame freeze, staleness). All HSR input in the demonstrations is injected or synthetic. |
| Layer 2: SEMEV-12 | Advisory screening of text task instructions against 12 moral and coercion vectors. MiniLM embeddings with deterministic scoring gates and negation pre-filtering. Not part of the physical safety function. | Built, unit-tested and benchmarked (15 regression cases, 80-case baseline, active adversarial suite). The adversarial benchmark documents known evasion vectors. |
| Layer 3: QERRA-THRIVE | Advisory values ranking for actions that have passed safety and moral screening (pacing, personal space, clear signalling, flora/animal protection). Native PyTrees integration. | Built and unit-tested across human-centered and ecological suites. Heuristic weights; not yet evaluated with human participants. |
Where to start:
- Safety and robotics engineers:
TECHNICAL_BRIEF_ROS2_GATE.md(frozen executive architecture reference and permalink),SAFETY_CONCEPT.md(v0.12),QERRA-HSR-Design-v0.1.md,LIMITATIONS.md,verify_log.py, the ROS 2 Integration section, and the Demo 7, 8, 9 and 10 sections below. - Ethics, human-robot interaction and standards readers: the SEMEV-12 and QERRA-THRIVE sections below,
SEMEV-12_Whitepaper.md,QERRA-THRIVE_framework_documentation.md, and the two benchmark files.
What QERRA Does
QERRA-v2 Classical is an open-source execution guard for autonomous robots and AI systems.
A mobile robot should never rely on an unpredictable neural network to make safety-relevant physical motion decisions. If a complex model lags or hallucinates, a 70 kg machine can crush someone.
QERRA addresses this by splitting safety into three separate, accountable jobs that run in a strict sequence:
-
The Deterministic Gate & Assistive Reflex (Layer 1A & 1B):
-
Layer 1A — The Supervisory Gate (
gate/): Pure-function, standard-library-only integer state machine that decides velocity commands. It evaluates velocity proposals from untrusted planners against a dynamic kinematic stopping envelope ($d_{stop} = \lceil v_{ref}^2 / (2a_{design}) \rceil + \lceil v_{ref} \cdot t_{react} \rceil + margin$, with $a_{design} = 0.5\ \text{m/s}^2$ (500 mm/s$^2$) and $margin = 300\ \text{mm}$; use $v_{ref}$ in mm/s, $a_{design}$ in mm/s$^2$, and $t_{react}$ in seconds (or $t_{react,us} / 10^6$) to obtain millimetres). The reference speed is $v_{ref} = \max(v_{cmd}, v_{meas})$.gate/gate_core.pyderives $v_{meas}$ (chassis_forward_mmps) from the measured wheel speedsmeas_left_urad_sandmeas_right_urad_sthrough differential-drive kinematics: $\lceil (left + right) \cdot wheel_radius_mm / 2{,}000{,}000 \rceil$ when positive, otherwise 0. Pure in-place yaw rotation ($left + right = 0$) therefore evaluates to 0 mm/s forward translation and does not enlarge the forward stopping distance. When measurements are missing, stale or invalid (None), $v_{meas}$ is 0 and $v_{ref}$ falls back to the commanded speed. Reaction time is parameterised: the Webots controller used a 32 ms lockstep allowance ($d_{stop} = 346\ \text{mm}$ at 196 mm/s cruise, 347 mm at 200 mm/s), while the ROS 2 node exposes a 96 ms simulation profile ($d_{stop} = 358\ \text{mm}$ at 196 mm/s, 360 mm at 200 mm/s) and a 160 ms profile for a 10 Hz scanner ($d_{stop} = 371\ \text{mm}$ at 196 mm/s, 372 mm at 200 mm/s). The 96 ms and 160 ms values are engineering estimates, not measured latencies. The gate trips fail-closed on obstacle breach, clock anomalies, invalid sensor scans, proposer stalls ($\ge 150\ \text{ms}$), or, when a flight log is configured, a failed log write orfsync(requirement R-10), and enforces a 1.0 s continuous-clear dwell and a manual operator reset before recovery. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required, defaultFalse;w_standstill_tol_urad_s = 50_000urad/s): when enabled, the calm dwell waits for verified physical standstill from measured wheel speeds. In verified simulation (TIAGo base in Webots R2025a,RUN_1791713619, recorded before the measured-velocity term existed), a commanded cruise was halted with $36\ \text{mm}$ of physical coasting after a trip at 337 mm clearance (standstill at 301 mm). -
Layer 1B — QERRA-HSR Reflex (
hsr/): Pure Python threshold reflex under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. Evaluates distress telemetry, human isolation, and proximity hazards to issue reflex states (CLEAR,MONITOR,CRITICAL) and Property HSR-5 human-in-the-loop recovery directives. The Gate trips onCRITICAL. In the ROS 2 node, incoming telemetry passes through a pure stream monitor (step_hsr_stream, wrapped by the shared receivergate/hsr_receiver.py;ros2/hsr_receiver.pyis a compatibility shim) that checks packet order, detects frozen frames, and presents no valid status ((None, None)) during a fault or a rebase dwell. Withhsr_required=truethe gate core turns that intoTRIP_HSR_INVALID. InMode.RUN,MONITORimposes no velocity cap: the existing 3.0 rad/s (0.294 m/s) envelope holds. While latched inMode.TRIPPEDorMode.AWAITING_RESET,MONITORblocks clear-dwell completion and causes operator reset rejection.
-
Layer 1A — The Supervisory Gate (
-
The Moral Conscience (SEMEV-12): A 12-dimensional ethical filter that evaluates text instructions before the robot moves. If someone orders the robot to do something abusive, deceptive, or coercive (such as forcing a worker through a break or falsifying safety records), the robot refuses the command, illuminates an amber LED, logs the refusal reason, and physically shakes its head “No” in simulation.
- The Social Manners (QERRA-THRIVE): A 12-vector ranker for tasks that are already physically safe and morally clean. It selects the most considerate way to move, such as quiet “whisper mode” in hospital corridors or keeping off garden lawns unless an emergency overrides etiquette.
The decision logic is deterministic, inspectable, and auditable. Every result outputs the exact vectors that triggered, human-readable reasoning, and a concrete recovery directive.
⚖️ Authorship & License
QERRA-v2 Classical is designed and developed by Marussa Metocharaki.
- Open Source License: The entire repository is licensed under the Apache License 2.0.
- Permissive Robotics Architecture: Permissive for chassis-local ROS 2 integration, academic research, and commercial robotics adoption.
-
Original Work & Archival: The core frameworks, vector logic, and scoring architectures are timestamped and permanently archived on Zenodo.
DOI (Zenodo): https://doi.org/10.5281/zenodo.24625489 ORCID: https://orcid.org/0009-0009-4100-9881
Quickstart
Public example endpoint (no API key required):
curl https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/example
Main endpoint (/analyze) requires the public test key:
x-api-key: TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
Full documentation:
https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/docs
Try QERRA in a Behavior Tree — 2 minutes, no ROS 2 required
QERRA-v2 includes a standalone PyTrees Condition node that calls the live API directly over HTTP. No ROS 2 installation, no qerra_msgs package, no build step.
pip install py_trees requests
export QERRA_API_KEY=TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
python test_bt_tick.py --live
This runs a real Behavior Tree against the live two-layer API (SEMEV-12 + QERRA-HSR), showing both a SAFE scenario (ethical check passes, task executes) and a HIGH RISK scenario (ethical check blocks, robot holds and requests human review).
```bash python test_bt_tick.py –live –risk # high risk scenario only python test_bt_tick.py –live –safe # safe scenario only python test_bt_tick.py # offline mock mode, no API call
File truncated at 100 lines see the full file
CONTRIBUTING
Repository Summary
| Description | |
| Checkout URI | https://github.com/marunigno-ship-it/QERRA-v2-classical.git |
| VCS Type | git |
| VCS Version | main |
| Last Updated | 2026-11-30 |
| Dev Status | UNKNOWN |
| Released | UNRELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
| Name | Version |
|---|---|
| qerra_core | 2.5.0 |
README
QERRA-v2 Classical
A fully explainable, classical three-layer pipeline for AI systems and autonomous robots.
Physical safety (Supervisory Gate + QERRA-HSR) → moral filtering (SEMEV-12) → flourishing-ranked choice (QERRA-THRIVE) — 27 named, auditable vectors (3 + 12 + 12), deterministic rule bounds.
The Idea in One Sentence
Values and ethics can screen and rank what a robot wants to do, but only a deterministic gate decides what the wheels do.
The setting this is built for: a transport cobot in a hospital corridor yields and slows near people, and the Gate is intended to command a stop when specified monitored fault conditions are detected. A Gate process or communication failure still requires an independent downstream command timeout or hardware safety function; this prototype does not demonstrate that the robot stops safely by itself after process failure. The system can leave a record a safety officer can audit.
Status in one paragraph. QERRA is a simulation-based research prototype. It is not a certified safety system, it has not been tested on hardware, and a 0.0 wheel command is a software setpoint, not an emergency stop. The deterministic gate (Gate Core v0.5) is demonstrated in Webots and, as a standalone ROS 2 node (
qerra_gate_nodev0.3.2), is built, executed and tested under ROS 2 Jazzy in GitHub Actions (live DDS topic traffic, dual-protocol reflex co-execution, Pattern B topic remapping, Nav2-compatible exterior command-interface tests,/odomingestion tests including a live DDS/odompublisher, and LaserScan metadata validation tests). Package metadata is v2.5.0 (Gate Core v0.5, ROS 2 Node v0.3.2), incorporating the measured-velocity dynamic stopping envelope, standstill-qualified dwell, 10-point LaserScan metadata and REP-117 bounds validation, and empirical ROS 2 Jazzy timing characterization. Current test counts are in Running the Tests, measured timing is in Empirical ROS 2 timing and contention, and the GitHub Actions workflows (tests.ymlandros2_jazzy.yml) are the live source of truth for CI runs. The Pattern B tests exercise a Nav2-compatible external command interface; they do not launch a complete Nav2 stack. The optional standstill-qualified recovery dwell is opt-in, and the archived Webots runs predate it and the measured-velocity stopping envelope. Localhost is an assumed trusted process boundary, and two documented exploit scenarios show what that assumption leaves open. See the frozen Technical Brief and Known limitations.
| Layer | Role | Evidence today |
|---|---|---|
Layer 1A: Supervisory Gate (gate/) |
The component that decides wheel commands. In the Webots controller it is the only process that writes wheel velocities. Pure standard-library integer state machine enforcing a dynamic stopping envelope $d_{stop}(v_{ref})$ with $v_{ref} = \max(v_{cmd}, v_{meas})$, where $v_{meas}$ is the chassis forward speed derived from measured wheel feedback, watchdog liveness (150 ms), and fail-closed latched recovery with operator reset. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required: bool = False, w_standstill_tol_urad_s: int = 50_000 urad/s): when enabled, the 1.0 s calm dwell waits for verified physical standstill from measured wheel speeds, without generating a deceleration trajectory (an open-loop TRIP_BRAKING was intentionally rejected to keep Doer-Checker separation; the Gate commands (0, 0) immediately upon any trip). Both the Webots controller and the ROS 2 node can log every tick to a SHA-256 rolling hash chain, and the node trips fail-closed if a log write fails (requirement R-10). |
Demonstrated in simulation: Demos 7, 8, 9 and 10 (the archived runs predate the standstill-qualified dwell and the measured-velocity envelope). Flight log verifiable offline with verify_log.py --replay. Core invariants (zero actuator authority outside RUN, stopping-envelope lower bound, clock monotonicity, standstill-dwell gating, HSR stream-monitor properties) are checked by stdlib property tests over defined input grids (tests/test_gate_invariants.py). Also packaged as a standalone ROS 2 node (qerra_gate_node v0.3.2) with parameterised timing profiles (96 ms simulation, 160 ms for a 10 Hz scanner), built and tested under ROS 2 Jazzy in CI: live DDS topic traffic, dual-protocol reflex integration, Pattern B topic remapping, Nav2-compatible exterior command-interface integration, /odom ingestion and watchdog tests (isolated stubs plus a live DDS /odom publisher), and LaserScan metadata validation. Software-side timing was measured once inside the ros:jazzy container (see Empirical ROS 2 timing and contention); it is an observation, not a bound. The Nav2 exterior tests use a Nav2-compatible command-source harness, not a running Nav2 stack. Current counts: see Running the Tests. Simulation and CI evidence only. |
Layer 1B: QERRA-HSR (hsr/) |
A 3-vector reflex signal (immediate_physical_distress, human_isolation, environmental_hazard_proximity) under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. The Gate acts on it when it is wired in (CRITICAL trips the gate). In the ROS 2 node a pure-function stream monitor (step_hsr_stream), wrapped by the shared pure-Python receiver gate/hsr_receiver.py (ros2/hsr_receiver.py is a compatibility shim), checks packet sequence order, detects frozen frames, and allows a counter rebase only after both at least 5 qualifying control ticks and at least 160 ms of elapsed observation time. Telemetry arrives over UDP (default, used by Webots) or over a ROS topic (hsr_source="topic", in which case no UDP socket is opened). Pure Python, Apache-2.0. (“HSR” here is this project’s own name and is unrelated to Toyota’s Human Support Robot.) |
Built and unit-tested (see Running the Tests). Evaluated in Webots Demos 6, 9 and 10 with a stabilised 1.0 s dwell and Property HSR-5 recovery directives. The stream monitor has edge-case matrix tests and a 159 ms / 160 ms rebase boundary test in the host suite, and the ROS-topic path is exercised by live multi-node tests in the container (dwell, acute distress, frame freeze, staleness). All HSR input in the demonstrations is injected or synthetic. |
| Layer 2: SEMEV-12 | Advisory screening of text task instructions against 12 moral and coercion vectors. MiniLM embeddings with deterministic scoring gates and negation pre-filtering. Not part of the physical safety function. | Built, unit-tested and benchmarked (15 regression cases, 80-case baseline, active adversarial suite). The adversarial benchmark documents known evasion vectors. |
| Layer 3: QERRA-THRIVE | Advisory values ranking for actions that have passed safety and moral screening (pacing, personal space, clear signalling, flora/animal protection). Native PyTrees integration. | Built and unit-tested across human-centered and ecological suites. Heuristic weights; not yet evaluated with human participants. |
Where to start:
- Safety and robotics engineers:
TECHNICAL_BRIEF_ROS2_GATE.md(frozen executive architecture reference and permalink),SAFETY_CONCEPT.md(v0.12),QERRA-HSR-Design-v0.1.md,LIMITATIONS.md,verify_log.py, the ROS 2 Integration section, and the Demo 7, 8, 9 and 10 sections below. - Ethics, human-robot interaction and standards readers: the SEMEV-12 and QERRA-THRIVE sections below,
SEMEV-12_Whitepaper.md,QERRA-THRIVE_framework_documentation.md, and the two benchmark files.
What QERRA Does
QERRA-v2 Classical is an open-source execution guard for autonomous robots and AI systems.
A mobile robot should never rely on an unpredictable neural network to make safety-relevant physical motion decisions. If a complex model lags or hallucinates, a 70 kg machine can crush someone.
QERRA addresses this by splitting safety into three separate, accountable jobs that run in a strict sequence:
-
The Deterministic Gate & Assistive Reflex (Layer 1A & 1B):
-
Layer 1A — The Supervisory Gate (
gate/): Pure-function, standard-library-only integer state machine that decides velocity commands. It evaluates velocity proposals from untrusted planners against a dynamic kinematic stopping envelope ($d_{stop} = \lceil v_{ref}^2 / (2a_{design}) \rceil + \lceil v_{ref} \cdot t_{react} \rceil + margin$, with $a_{design} = 0.5\ \text{m/s}^2$ (500 mm/s$^2$) and $margin = 300\ \text{mm}$; use $v_{ref}$ in mm/s, $a_{design}$ in mm/s$^2$, and $t_{react}$ in seconds (or $t_{react,us} / 10^6$) to obtain millimetres). The reference speed is $v_{ref} = \max(v_{cmd}, v_{meas})$.gate/gate_core.pyderives $v_{meas}$ (chassis_forward_mmps) from the measured wheel speedsmeas_left_urad_sandmeas_right_urad_sthrough differential-drive kinematics: $\lceil (left + right) \cdot wheel_radius_mm / 2{,}000{,}000 \rceil$ when positive, otherwise 0. Pure in-place yaw rotation ($left + right = 0$) therefore evaluates to 0 mm/s forward translation and does not enlarge the forward stopping distance. When measurements are missing, stale or invalid (None), $v_{meas}$ is 0 and $v_{ref}$ falls back to the commanded speed. Reaction time is parameterised: the Webots controller used a 32 ms lockstep allowance ($d_{stop} = 346\ \text{mm}$ at 196 mm/s cruise, 347 mm at 200 mm/s), while the ROS 2 node exposes a 96 ms simulation profile ($d_{stop} = 358\ \text{mm}$ at 196 mm/s, 360 mm at 200 mm/s) and a 160 ms profile for a 10 Hz scanner ($d_{stop} = 371\ \text{mm}$ at 196 mm/s, 372 mm at 200 mm/s). The 96 ms and 160 ms values are engineering estimates, not measured latencies. The gate trips fail-closed on obstacle breach, clock anomalies, invalid sensor scans, proposer stalls ($\ge 150\ \text{ms}$), or, when a flight log is configured, a failed log write orfsync(requirement R-10), and enforces a 1.0 s continuous-clear dwell and a manual operator reset before recovery. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required, defaultFalse;w_standstill_tol_urad_s = 50_000urad/s): when enabled, the calm dwell waits for verified physical standstill from measured wheel speeds. In verified simulation (TIAGo base in Webots R2025a,RUN_1791713619, recorded before the measured-velocity term existed), a commanded cruise was halted with $36\ \text{mm}$ of physical coasting after a trip at 337 mm clearance (standstill at 301 mm). -
Layer 1B — QERRA-HSR Reflex (
hsr/): Pure Python threshold reflex under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. Evaluates distress telemetry, human isolation, and proximity hazards to issue reflex states (CLEAR,MONITOR,CRITICAL) and Property HSR-5 human-in-the-loop recovery directives. The Gate trips onCRITICAL. In the ROS 2 node, incoming telemetry passes through a pure stream monitor (step_hsr_stream, wrapped by the shared receivergate/hsr_receiver.py;ros2/hsr_receiver.pyis a compatibility shim) that checks packet order, detects frozen frames, and presents no valid status ((None, None)) during a fault or a rebase dwell. Withhsr_required=truethe gate core turns that intoTRIP_HSR_INVALID. InMode.RUN,MONITORimposes no velocity cap: the existing 3.0 rad/s (0.294 m/s) envelope holds. While latched inMode.TRIPPEDorMode.AWAITING_RESET,MONITORblocks clear-dwell completion and causes operator reset rejection.
-
Layer 1A — The Supervisory Gate (
-
The Moral Conscience (SEMEV-12): A 12-dimensional ethical filter that evaluates text instructions before the robot moves. If someone orders the robot to do something abusive, deceptive, or coercive (such as forcing a worker through a break or falsifying safety records), the robot refuses the command, illuminates an amber LED, logs the refusal reason, and physically shakes its head “No” in simulation.
- The Social Manners (QERRA-THRIVE): A 12-vector ranker for tasks that are already physically safe and morally clean. It selects the most considerate way to move, such as quiet “whisper mode” in hospital corridors or keeping off garden lawns unless an emergency overrides etiquette.
The decision logic is deterministic, inspectable, and auditable. Every result outputs the exact vectors that triggered, human-readable reasoning, and a concrete recovery directive.
⚖️ Authorship & License
QERRA-v2 Classical is designed and developed by Marussa Metocharaki.
- Open Source License: The entire repository is licensed under the Apache License 2.0.
- Permissive Robotics Architecture: Permissive for chassis-local ROS 2 integration, academic research, and commercial robotics adoption.
-
Original Work & Archival: The core frameworks, vector logic, and scoring architectures are timestamped and permanently archived on Zenodo.
DOI (Zenodo): https://doi.org/10.5281/zenodo.24625489 ORCID: https://orcid.org/0009-0009-4100-9881
Quickstart
Public example endpoint (no API key required):
curl https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/example
Main endpoint (/analyze) requires the public test key:
x-api-key: TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
Full documentation:
https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/docs
Try QERRA in a Behavior Tree — 2 minutes, no ROS 2 required
QERRA-v2 includes a standalone PyTrees Condition node that calls the live API directly over HTTP. No ROS 2 installation, no qerra_msgs package, no build step.
pip install py_trees requests
export QERRA_API_KEY=TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
python test_bt_tick.py --live
This runs a real Behavior Tree against the live two-layer API (SEMEV-12 + QERRA-HSR), showing both a SAFE scenario (ethical check passes, task executes) and a HIGH RISK scenario (ethical check blocks, robot holds and requests human review).
```bash python test_bt_tick.py –live –risk # high risk scenario only python test_bt_tick.py –live –safe # safe scenario only python test_bt_tick.py # offline mock mode, no API call
File truncated at 100 lines see the full file
CONTRIBUTING
Repository Summary
| Description | |
| Checkout URI | https://github.com/marunigno-ship-it/QERRA-v2-classical.git |
| VCS Type | git |
| VCS Version | main |
| Last Updated | 2026-11-30 |
| Dev Status | UNKNOWN |
| Released | UNRELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
| Name | Version |
|---|---|
| qerra_core | 2.5.0 |
README
QERRA-v2 Classical
A fully explainable, classical three-layer pipeline for AI systems and autonomous robots.
Physical safety (Supervisory Gate + QERRA-HSR) → moral filtering (SEMEV-12) → flourishing-ranked choice (QERRA-THRIVE) — 27 named, auditable vectors (3 + 12 + 12), deterministic rule bounds.
The Idea in One Sentence
Values and ethics can screen and rank what a robot wants to do, but only a deterministic gate decides what the wheels do.
The setting this is built for: a transport cobot in a hospital corridor yields and slows near people, and the Gate is intended to command a stop when specified monitored fault conditions are detected. A Gate process or communication failure still requires an independent downstream command timeout or hardware safety function; this prototype does not demonstrate that the robot stops safely by itself after process failure. The system can leave a record a safety officer can audit.
Status in one paragraph. QERRA is a simulation-based research prototype. It is not a certified safety system, it has not been tested on hardware, and a 0.0 wheel command is a software setpoint, not an emergency stop. The deterministic gate (Gate Core v0.5) is demonstrated in Webots and, as a standalone ROS 2 node (
qerra_gate_nodev0.3.2), is built, executed and tested under ROS 2 Jazzy in GitHub Actions (live DDS topic traffic, dual-protocol reflex co-execution, Pattern B topic remapping, Nav2-compatible exterior command-interface tests,/odomingestion tests including a live DDS/odompublisher, and LaserScan metadata validation tests). Package metadata is v2.5.0 (Gate Core v0.5, ROS 2 Node v0.3.2), incorporating the measured-velocity dynamic stopping envelope, standstill-qualified dwell, 10-point LaserScan metadata and REP-117 bounds validation, and empirical ROS 2 Jazzy timing characterization. Current test counts are in Running the Tests, measured timing is in Empirical ROS 2 timing and contention, and the GitHub Actions workflows (tests.ymlandros2_jazzy.yml) are the live source of truth for CI runs. The Pattern B tests exercise a Nav2-compatible external command interface; they do not launch a complete Nav2 stack. The optional standstill-qualified recovery dwell is opt-in, and the archived Webots runs predate it and the measured-velocity stopping envelope. Localhost is an assumed trusted process boundary, and two documented exploit scenarios show what that assumption leaves open. See the frozen Technical Brief and Known limitations.
| Layer | Role | Evidence today |
|---|---|---|
Layer 1A: Supervisory Gate (gate/) |
The component that decides wheel commands. In the Webots controller it is the only process that writes wheel velocities. Pure standard-library integer state machine enforcing a dynamic stopping envelope $d_{stop}(v_{ref})$ with $v_{ref} = \max(v_{cmd}, v_{meas})$, where $v_{meas}$ is the chassis forward speed derived from measured wheel feedback, watchdog liveness (150 ms), and fail-closed latched recovery with operator reset. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required: bool = False, w_standstill_tol_urad_s: int = 50_000 urad/s): when enabled, the 1.0 s calm dwell waits for verified physical standstill from measured wheel speeds, without generating a deceleration trajectory (an open-loop TRIP_BRAKING was intentionally rejected to keep Doer-Checker separation; the Gate commands (0, 0) immediately upon any trip). Both the Webots controller and the ROS 2 node can log every tick to a SHA-256 rolling hash chain, and the node trips fail-closed if a log write fails (requirement R-10). |
Demonstrated in simulation: Demos 7, 8, 9 and 10 (the archived runs predate the standstill-qualified dwell and the measured-velocity envelope). Flight log verifiable offline with verify_log.py --replay. Core invariants (zero actuator authority outside RUN, stopping-envelope lower bound, clock monotonicity, standstill-dwell gating, HSR stream-monitor properties) are checked by stdlib property tests over defined input grids (tests/test_gate_invariants.py). Also packaged as a standalone ROS 2 node (qerra_gate_node v0.3.2) with parameterised timing profiles (96 ms simulation, 160 ms for a 10 Hz scanner), built and tested under ROS 2 Jazzy in CI: live DDS topic traffic, dual-protocol reflex integration, Pattern B topic remapping, Nav2-compatible exterior command-interface integration, /odom ingestion and watchdog tests (isolated stubs plus a live DDS /odom publisher), and LaserScan metadata validation. Software-side timing was measured once inside the ros:jazzy container (see Empirical ROS 2 timing and contention); it is an observation, not a bound. The Nav2 exterior tests use a Nav2-compatible command-source harness, not a running Nav2 stack. Current counts: see Running the Tests. Simulation and CI evidence only. |
Layer 1B: QERRA-HSR (hsr/) |
A 3-vector reflex signal (immediate_physical_distress, human_isolation, environmental_hazard_proximity) under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. The Gate acts on it when it is wired in (CRITICAL trips the gate). In the ROS 2 node a pure-function stream monitor (step_hsr_stream), wrapped by the shared pure-Python receiver gate/hsr_receiver.py (ros2/hsr_receiver.py is a compatibility shim), checks packet sequence order, detects frozen frames, and allows a counter rebase only after both at least 5 qualifying control ticks and at least 160 ms of elapsed observation time. Telemetry arrives over UDP (default, used by Webots) or over a ROS topic (hsr_source="topic", in which case no UDP socket is opened). Pure Python, Apache-2.0. (“HSR” here is this project’s own name and is unrelated to Toyota’s Human Support Robot.) |
Built and unit-tested (see Running the Tests). Evaluated in Webots Demos 6, 9 and 10 with a stabilised 1.0 s dwell and Property HSR-5 recovery directives. The stream monitor has edge-case matrix tests and a 159 ms / 160 ms rebase boundary test in the host suite, and the ROS-topic path is exercised by live multi-node tests in the container (dwell, acute distress, frame freeze, staleness). All HSR input in the demonstrations is injected or synthetic. |
| Layer 2: SEMEV-12 | Advisory screening of text task instructions against 12 moral and coercion vectors. MiniLM embeddings with deterministic scoring gates and negation pre-filtering. Not part of the physical safety function. | Built, unit-tested and benchmarked (15 regression cases, 80-case baseline, active adversarial suite). The adversarial benchmark documents known evasion vectors. |
| Layer 3: QERRA-THRIVE | Advisory values ranking for actions that have passed safety and moral screening (pacing, personal space, clear signalling, flora/animal protection). Native PyTrees integration. | Built and unit-tested across human-centered and ecological suites. Heuristic weights; not yet evaluated with human participants. |
Where to start:
- Safety and robotics engineers:
TECHNICAL_BRIEF_ROS2_GATE.md(frozen executive architecture reference and permalink),SAFETY_CONCEPT.md(v0.12),QERRA-HSR-Design-v0.1.md,LIMITATIONS.md,verify_log.py, the ROS 2 Integration section, and the Demo 7, 8, 9 and 10 sections below. - Ethics, human-robot interaction and standards readers: the SEMEV-12 and QERRA-THRIVE sections below,
SEMEV-12_Whitepaper.md,QERRA-THRIVE_framework_documentation.md, and the two benchmark files.
What QERRA Does
QERRA-v2 Classical is an open-source execution guard for autonomous robots and AI systems.
A mobile robot should never rely on an unpredictable neural network to make safety-relevant physical motion decisions. If a complex model lags or hallucinates, a 70 kg machine can crush someone.
QERRA addresses this by splitting safety into three separate, accountable jobs that run in a strict sequence:
-
The Deterministic Gate & Assistive Reflex (Layer 1A & 1B):
-
Layer 1A — The Supervisory Gate (
gate/): Pure-function, standard-library-only integer state machine that decides velocity commands. It evaluates velocity proposals from untrusted planners against a dynamic kinematic stopping envelope ($d_{stop} = \lceil v_{ref}^2 / (2a_{design}) \rceil + \lceil v_{ref} \cdot t_{react} \rceil + margin$, with $a_{design} = 0.5\ \text{m/s}^2$ (500 mm/s$^2$) and $margin = 300\ \text{mm}$; use $v_{ref}$ in mm/s, $a_{design}$ in mm/s$^2$, and $t_{react}$ in seconds (or $t_{react,us} / 10^6$) to obtain millimetres). The reference speed is $v_{ref} = \max(v_{cmd}, v_{meas})$.gate/gate_core.pyderives $v_{meas}$ (chassis_forward_mmps) from the measured wheel speedsmeas_left_urad_sandmeas_right_urad_sthrough differential-drive kinematics: $\lceil (left + right) \cdot wheel_radius_mm / 2{,}000{,}000 \rceil$ when positive, otherwise 0. Pure in-place yaw rotation ($left + right = 0$) therefore evaluates to 0 mm/s forward translation and does not enlarge the forward stopping distance. When measurements are missing, stale or invalid (None), $v_{meas}$ is 0 and $v_{ref}$ falls back to the commanded speed. Reaction time is parameterised: the Webots controller used a 32 ms lockstep allowance ($d_{stop} = 346\ \text{mm}$ at 196 mm/s cruise, 347 mm at 200 mm/s), while the ROS 2 node exposes a 96 ms simulation profile ($d_{stop} = 358\ \text{mm}$ at 196 mm/s, 360 mm at 200 mm/s) and a 160 ms profile for a 10 Hz scanner ($d_{stop} = 371\ \text{mm}$ at 196 mm/s, 372 mm at 200 mm/s). The 96 ms and 160 ms values are engineering estimates, not measured latencies. The gate trips fail-closed on obstacle breach, clock anomalies, invalid sensor scans, proposer stalls ($\ge 150\ \text{ms}$), or, when a flight log is configured, a failed log write orfsync(requirement R-10), and enforces a 1.0 s continuous-clear dwell and a manual operator reset before recovery. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required, defaultFalse;w_standstill_tol_urad_s = 50_000urad/s): when enabled, the calm dwell waits for verified physical standstill from measured wheel speeds. In verified simulation (TIAGo base in Webots R2025a,RUN_1791713619, recorded before the measured-velocity term existed), a commanded cruise was halted with $36\ \text{mm}$ of physical coasting after a trip at 337 mm clearance (standstill at 301 mm). -
Layer 1B — QERRA-HSR Reflex (
hsr/): Pure Python threshold reflex under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. Evaluates distress telemetry, human isolation, and proximity hazards to issue reflex states (CLEAR,MONITOR,CRITICAL) and Property HSR-5 human-in-the-loop recovery directives. The Gate trips onCRITICAL. In the ROS 2 node, incoming telemetry passes through a pure stream monitor (step_hsr_stream, wrapped by the shared receivergate/hsr_receiver.py;ros2/hsr_receiver.pyis a compatibility shim) that checks packet order, detects frozen frames, and presents no valid status ((None, None)) during a fault or a rebase dwell. Withhsr_required=truethe gate core turns that intoTRIP_HSR_INVALID. InMode.RUN,MONITORimposes no velocity cap: the existing 3.0 rad/s (0.294 m/s) envelope holds. While latched inMode.TRIPPEDorMode.AWAITING_RESET,MONITORblocks clear-dwell completion and causes operator reset rejection.
-
Layer 1A — The Supervisory Gate (
-
The Moral Conscience (SEMEV-12): A 12-dimensional ethical filter that evaluates text instructions before the robot moves. If someone orders the robot to do something abusive, deceptive, or coercive (such as forcing a worker through a break or falsifying safety records), the robot refuses the command, illuminates an amber LED, logs the refusal reason, and physically shakes its head “No” in simulation.
- The Social Manners (QERRA-THRIVE): A 12-vector ranker for tasks that are already physically safe and morally clean. It selects the most considerate way to move, such as quiet “whisper mode” in hospital corridors or keeping off garden lawns unless an emergency overrides etiquette.
The decision logic is deterministic, inspectable, and auditable. Every result outputs the exact vectors that triggered, human-readable reasoning, and a concrete recovery directive.
⚖️ Authorship & License
QERRA-v2 Classical is designed and developed by Marussa Metocharaki.
- Open Source License: The entire repository is licensed under the Apache License 2.0.
- Permissive Robotics Architecture: Permissive for chassis-local ROS 2 integration, academic research, and commercial robotics adoption.
-
Original Work & Archival: The core frameworks, vector logic, and scoring architectures are timestamped and permanently archived on Zenodo.
DOI (Zenodo): https://doi.org/10.5281/zenodo.24625489 ORCID: https://orcid.org/0009-0009-4100-9881
Quickstart
Public example endpoint (no API key required):
curl https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/example
Main endpoint (/analyze) requires the public test key:
x-api-key: TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
Full documentation:
https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/docs
Try QERRA in a Behavior Tree — 2 minutes, no ROS 2 required
QERRA-v2 includes a standalone PyTrees Condition node that calls the live API directly over HTTP. No ROS 2 installation, no qerra_msgs package, no build step.
pip install py_trees requests
export QERRA_API_KEY=TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
python test_bt_tick.py --live
This runs a real Behavior Tree against the live two-layer API (SEMEV-12 + QERRA-HSR), showing both a SAFE scenario (ethical check passes, task executes) and a HIGH RISK scenario (ethical check blocks, robot holds and requests human review).
```bash python test_bt_tick.py –live –risk # high risk scenario only python test_bt_tick.py –live –safe # safe scenario only python test_bt_tick.py # offline mock mode, no API call
File truncated at 100 lines see the full file
CONTRIBUTING
Repository Summary
| Description | |
| Checkout URI | https://github.com/marunigno-ship-it/QERRA-v2-classical.git |
| VCS Type | git |
| VCS Version | main |
| Last Updated | 2026-11-30 |
| Dev Status | UNKNOWN |
| Released | UNRELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
| Name | Version |
|---|---|
| qerra_core | 2.5.0 |
README
QERRA-v2 Classical
A fully explainable, classical three-layer pipeline for AI systems and autonomous robots.
Physical safety (Supervisory Gate + QERRA-HSR) → moral filtering (SEMEV-12) → flourishing-ranked choice (QERRA-THRIVE) — 27 named, auditable vectors (3 + 12 + 12), deterministic rule bounds.
The Idea in One Sentence
Values and ethics can screen and rank what a robot wants to do, but only a deterministic gate decides what the wheels do.
The setting this is built for: a transport cobot in a hospital corridor yields and slows near people, and the Gate is intended to command a stop when specified monitored fault conditions are detected. A Gate process or communication failure still requires an independent downstream command timeout or hardware safety function; this prototype does not demonstrate that the robot stops safely by itself after process failure. The system can leave a record a safety officer can audit.
Status in one paragraph. QERRA is a simulation-based research prototype. It is not a certified safety system, it has not been tested on hardware, and a 0.0 wheel command is a software setpoint, not an emergency stop. The deterministic gate (Gate Core v0.5) is demonstrated in Webots and, as a standalone ROS 2 node (
qerra_gate_nodev0.3.2), is built, executed and tested under ROS 2 Jazzy in GitHub Actions (live DDS topic traffic, dual-protocol reflex co-execution, Pattern B topic remapping, Nav2-compatible exterior command-interface tests,/odomingestion tests including a live DDS/odompublisher, and LaserScan metadata validation tests). Package metadata is v2.5.0 (Gate Core v0.5, ROS 2 Node v0.3.2), incorporating the measured-velocity dynamic stopping envelope, standstill-qualified dwell, 10-point LaserScan metadata and REP-117 bounds validation, and empirical ROS 2 Jazzy timing characterization. Current test counts are in Running the Tests, measured timing is in Empirical ROS 2 timing and contention, and the GitHub Actions workflows (tests.ymlandros2_jazzy.yml) are the live source of truth for CI runs. The Pattern B tests exercise a Nav2-compatible external command interface; they do not launch a complete Nav2 stack. The optional standstill-qualified recovery dwell is opt-in, and the archived Webots runs predate it and the measured-velocity stopping envelope. Localhost is an assumed trusted process boundary, and two documented exploit scenarios show what that assumption leaves open. See the frozen Technical Brief and Known limitations.
| Layer | Role | Evidence today |
|---|---|---|
Layer 1A: Supervisory Gate (gate/) |
The component that decides wheel commands. In the Webots controller it is the only process that writes wheel velocities. Pure standard-library integer state machine enforcing a dynamic stopping envelope $d_{stop}(v_{ref})$ with $v_{ref} = \max(v_{cmd}, v_{meas})$, where $v_{meas}$ is the chassis forward speed derived from measured wheel feedback, watchdog liveness (150 ms), and fail-closed latched recovery with operator reset. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required: bool = False, w_standstill_tol_urad_s: int = 50_000 urad/s): when enabled, the 1.0 s calm dwell waits for verified physical standstill from measured wheel speeds, without generating a deceleration trajectory (an open-loop TRIP_BRAKING was intentionally rejected to keep Doer-Checker separation; the Gate commands (0, 0) immediately upon any trip). Both the Webots controller and the ROS 2 node can log every tick to a SHA-256 rolling hash chain, and the node trips fail-closed if a log write fails (requirement R-10). |
Demonstrated in simulation: Demos 7, 8, 9 and 10 (the archived runs predate the standstill-qualified dwell and the measured-velocity envelope). Flight log verifiable offline with verify_log.py --replay. Core invariants (zero actuator authority outside RUN, stopping-envelope lower bound, clock monotonicity, standstill-dwell gating, HSR stream-monitor properties) are checked by stdlib property tests over defined input grids (tests/test_gate_invariants.py). Also packaged as a standalone ROS 2 node (qerra_gate_node v0.3.2) with parameterised timing profiles (96 ms simulation, 160 ms for a 10 Hz scanner), built and tested under ROS 2 Jazzy in CI: live DDS topic traffic, dual-protocol reflex integration, Pattern B topic remapping, Nav2-compatible exterior command-interface integration, /odom ingestion and watchdog tests (isolated stubs plus a live DDS /odom publisher), and LaserScan metadata validation. Software-side timing was measured once inside the ros:jazzy container (see Empirical ROS 2 timing and contention); it is an observation, not a bound. The Nav2 exterior tests use a Nav2-compatible command-source harness, not a running Nav2 stack. Current counts: see Running the Tests. Simulation and CI evidence only. |
Layer 1B: QERRA-HSR (hsr/) |
A 3-vector reflex signal (immediate_physical_distress, human_isolation, environmental_hazard_proximity) under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. The Gate acts on it when it is wired in (CRITICAL trips the gate). In the ROS 2 node a pure-function stream monitor (step_hsr_stream), wrapped by the shared pure-Python receiver gate/hsr_receiver.py (ros2/hsr_receiver.py is a compatibility shim), checks packet sequence order, detects frozen frames, and allows a counter rebase only after both at least 5 qualifying control ticks and at least 160 ms of elapsed observation time. Telemetry arrives over UDP (default, used by Webots) or over a ROS topic (hsr_source="topic", in which case no UDP socket is opened). Pure Python, Apache-2.0. (“HSR” here is this project’s own name and is unrelated to Toyota’s Human Support Robot.) |
Built and unit-tested (see Running the Tests). Evaluated in Webots Demos 6, 9 and 10 with a stabilised 1.0 s dwell and Property HSR-5 recovery directives. The stream monitor has edge-case matrix tests and a 159 ms / 160 ms rebase boundary test in the host suite, and the ROS-topic path is exercised by live multi-node tests in the container (dwell, acute distress, frame freeze, staleness). All HSR input in the demonstrations is injected or synthetic. |
| Layer 2: SEMEV-12 | Advisory screening of text task instructions against 12 moral and coercion vectors. MiniLM embeddings with deterministic scoring gates and negation pre-filtering. Not part of the physical safety function. | Built, unit-tested and benchmarked (15 regression cases, 80-case baseline, active adversarial suite). The adversarial benchmark documents known evasion vectors. |
| Layer 3: QERRA-THRIVE | Advisory values ranking for actions that have passed safety and moral screening (pacing, personal space, clear signalling, flora/animal protection). Native PyTrees integration. | Built and unit-tested across human-centered and ecological suites. Heuristic weights; not yet evaluated with human participants. |
Where to start:
- Safety and robotics engineers:
TECHNICAL_BRIEF_ROS2_GATE.md(frozen executive architecture reference and permalink),SAFETY_CONCEPT.md(v0.12),QERRA-HSR-Design-v0.1.md,LIMITATIONS.md,verify_log.py, the ROS 2 Integration section, and the Demo 7, 8, 9 and 10 sections below. - Ethics, human-robot interaction and standards readers: the SEMEV-12 and QERRA-THRIVE sections below,
SEMEV-12_Whitepaper.md,QERRA-THRIVE_framework_documentation.md, and the two benchmark files.
What QERRA Does
QERRA-v2 Classical is an open-source execution guard for autonomous robots and AI systems.
A mobile robot should never rely on an unpredictable neural network to make safety-relevant physical motion decisions. If a complex model lags or hallucinates, a 70 kg machine can crush someone.
QERRA addresses this by splitting safety into three separate, accountable jobs that run in a strict sequence:
-
The Deterministic Gate & Assistive Reflex (Layer 1A & 1B):
-
Layer 1A — The Supervisory Gate (
gate/): Pure-function, standard-library-only integer state machine that decides velocity commands. It evaluates velocity proposals from untrusted planners against a dynamic kinematic stopping envelope ($d_{stop} = \lceil v_{ref}^2 / (2a_{design}) \rceil + \lceil v_{ref} \cdot t_{react} \rceil + margin$, with $a_{design} = 0.5\ \text{m/s}^2$ (500 mm/s$^2$) and $margin = 300\ \text{mm}$; use $v_{ref}$ in mm/s, $a_{design}$ in mm/s$^2$, and $t_{react}$ in seconds (or $t_{react,us} / 10^6$) to obtain millimetres). The reference speed is $v_{ref} = \max(v_{cmd}, v_{meas})$.gate/gate_core.pyderives $v_{meas}$ (chassis_forward_mmps) from the measured wheel speedsmeas_left_urad_sandmeas_right_urad_sthrough differential-drive kinematics: $\lceil (left + right) \cdot wheel_radius_mm / 2{,}000{,}000 \rceil$ when positive, otherwise 0. Pure in-place yaw rotation ($left + right = 0$) therefore evaluates to 0 mm/s forward translation and does not enlarge the forward stopping distance. When measurements are missing, stale or invalid (None), $v_{meas}$ is 0 and $v_{ref}$ falls back to the commanded speed. Reaction time is parameterised: the Webots controller used a 32 ms lockstep allowance ($d_{stop} = 346\ \text{mm}$ at 196 mm/s cruise, 347 mm at 200 mm/s), while the ROS 2 node exposes a 96 ms simulation profile ($d_{stop} = 358\ \text{mm}$ at 196 mm/s, 360 mm at 200 mm/s) and a 160 ms profile for a 10 Hz scanner ($d_{stop} = 371\ \text{mm}$ at 196 mm/s, 372 mm at 200 mm/s). The 96 ms and 160 ms values are engineering estimates, not measured latencies. The gate trips fail-closed on obstacle breach, clock anomalies, invalid sensor scans, proposer stalls ($\ge 150\ \text{ms}$), or, when a flight log is configured, a failed log write orfsync(requirement R-10), and enforces a 1.0 s continuous-clear dwell and a manual operator reset before recovery. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required, defaultFalse;w_standstill_tol_urad_s = 50_000urad/s): when enabled, the calm dwell waits for verified physical standstill from measured wheel speeds. In verified simulation (TIAGo base in Webots R2025a,RUN_1791713619, recorded before the measured-velocity term existed), a commanded cruise was halted with $36\ \text{mm}$ of physical coasting after a trip at 337 mm clearance (standstill at 301 mm). -
Layer 1B — QERRA-HSR Reflex (
hsr/): Pure Python threshold reflex under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. Evaluates distress telemetry, human isolation, and proximity hazards to issue reflex states (CLEAR,MONITOR,CRITICAL) and Property HSR-5 human-in-the-loop recovery directives. The Gate trips onCRITICAL. In the ROS 2 node, incoming telemetry passes through a pure stream monitor (step_hsr_stream, wrapped by the shared receivergate/hsr_receiver.py;ros2/hsr_receiver.pyis a compatibility shim) that checks packet order, detects frozen frames, and presents no valid status ((None, None)) during a fault or a rebase dwell. Withhsr_required=truethe gate core turns that intoTRIP_HSR_INVALID. InMode.RUN,MONITORimposes no velocity cap: the existing 3.0 rad/s (0.294 m/s) envelope holds. While latched inMode.TRIPPEDorMode.AWAITING_RESET,MONITORblocks clear-dwell completion and causes operator reset rejection.
-
Layer 1A — The Supervisory Gate (
-
The Moral Conscience (SEMEV-12): A 12-dimensional ethical filter that evaluates text instructions before the robot moves. If someone orders the robot to do something abusive, deceptive, or coercive (such as forcing a worker through a break or falsifying safety records), the robot refuses the command, illuminates an amber LED, logs the refusal reason, and physically shakes its head “No” in simulation.
- The Social Manners (QERRA-THRIVE): A 12-vector ranker for tasks that are already physically safe and morally clean. It selects the most considerate way to move, such as quiet “whisper mode” in hospital corridors or keeping off garden lawns unless an emergency overrides etiquette.
The decision logic is deterministic, inspectable, and auditable. Every result outputs the exact vectors that triggered, human-readable reasoning, and a concrete recovery directive.
⚖️ Authorship & License
QERRA-v2 Classical is designed and developed by Marussa Metocharaki.
- Open Source License: The entire repository is licensed under the Apache License 2.0.
- Permissive Robotics Architecture: Permissive for chassis-local ROS 2 integration, academic research, and commercial robotics adoption.
-
Original Work & Archival: The core frameworks, vector logic, and scoring architectures are timestamped and permanently archived on Zenodo.
DOI (Zenodo): https://doi.org/10.5281/zenodo.24625489 ORCID: https://orcid.org/0009-0009-4100-9881
Quickstart
Public example endpoint (no API key required):
curl https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/example
Main endpoint (/analyze) requires the public test key:
x-api-key: TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
Full documentation:
https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/docs
Try QERRA in a Behavior Tree — 2 minutes, no ROS 2 required
QERRA-v2 includes a standalone PyTrees Condition node that calls the live API directly over HTTP. No ROS 2 installation, no qerra_msgs package, no build step.
pip install py_trees requests
export QERRA_API_KEY=TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
python test_bt_tick.py --live
This runs a real Behavior Tree against the live two-layer API (SEMEV-12 + QERRA-HSR), showing both a SAFE scenario (ethical check passes, task executes) and a HIGH RISK scenario (ethical check blocks, robot holds and requests human review).
```bash python test_bt_tick.py –live –risk # high risk scenario only python test_bt_tick.py –live –safe # safe scenario only python test_bt_tick.py # offline mock mode, no API call
File truncated at 100 lines see the full file
CONTRIBUTING
Repository Summary
| Description | |
| Checkout URI | https://github.com/marunigno-ship-it/QERRA-v2-classical.git |
| VCS Type | git |
| VCS Version | main |
| Last Updated | 2026-11-30 |
| Dev Status | UNKNOWN |
| Released | UNRELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
| Name | Version |
|---|---|
| qerra_core | 2.5.0 |
README
QERRA-v2 Classical
A fully explainable, classical three-layer pipeline for AI systems and autonomous robots.
Physical safety (Supervisory Gate + QERRA-HSR) → moral filtering (SEMEV-12) → flourishing-ranked choice (QERRA-THRIVE) — 27 named, auditable vectors (3 + 12 + 12), deterministic rule bounds.
The Idea in One Sentence
Values and ethics can screen and rank what a robot wants to do, but only a deterministic gate decides what the wheels do.
The setting this is built for: a transport cobot in a hospital corridor yields and slows near people, and the Gate is intended to command a stop when specified monitored fault conditions are detected. A Gate process or communication failure still requires an independent downstream command timeout or hardware safety function; this prototype does not demonstrate that the robot stops safely by itself after process failure. The system can leave a record a safety officer can audit.
Status in one paragraph. QERRA is a simulation-based research prototype. It is not a certified safety system, it has not been tested on hardware, and a 0.0 wheel command is a software setpoint, not an emergency stop. The deterministic gate (Gate Core v0.5) is demonstrated in Webots and, as a standalone ROS 2 node (
qerra_gate_nodev0.3.2), is built, executed and tested under ROS 2 Jazzy in GitHub Actions (live DDS topic traffic, dual-protocol reflex co-execution, Pattern B topic remapping, Nav2-compatible exterior command-interface tests,/odomingestion tests including a live DDS/odompublisher, and LaserScan metadata validation tests). Package metadata is v2.5.0 (Gate Core v0.5, ROS 2 Node v0.3.2), incorporating the measured-velocity dynamic stopping envelope, standstill-qualified dwell, 10-point LaserScan metadata and REP-117 bounds validation, and empirical ROS 2 Jazzy timing characterization. Current test counts are in Running the Tests, measured timing is in Empirical ROS 2 timing and contention, and the GitHub Actions workflows (tests.ymlandros2_jazzy.yml) are the live source of truth for CI runs. The Pattern B tests exercise a Nav2-compatible external command interface; they do not launch a complete Nav2 stack. The optional standstill-qualified recovery dwell is opt-in, and the archived Webots runs predate it and the measured-velocity stopping envelope. Localhost is an assumed trusted process boundary, and two documented exploit scenarios show what that assumption leaves open. See the frozen Technical Brief and Known limitations.
| Layer | Role | Evidence today |
|---|---|---|
Layer 1A: Supervisory Gate (gate/) |
The component that decides wheel commands. In the Webots controller it is the only process that writes wheel velocities. Pure standard-library integer state machine enforcing a dynamic stopping envelope $d_{stop}(v_{ref})$ with $v_{ref} = \max(v_{cmd}, v_{meas})$, where $v_{meas}$ is the chassis forward speed derived from measured wheel feedback, watchdog liveness (150 ms), and fail-closed latched recovery with operator reset. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required: bool = False, w_standstill_tol_urad_s: int = 50_000 urad/s): when enabled, the 1.0 s calm dwell waits for verified physical standstill from measured wheel speeds, without generating a deceleration trajectory (an open-loop TRIP_BRAKING was intentionally rejected to keep Doer-Checker separation; the Gate commands (0, 0) immediately upon any trip). Both the Webots controller and the ROS 2 node can log every tick to a SHA-256 rolling hash chain, and the node trips fail-closed if a log write fails (requirement R-10). |
Demonstrated in simulation: Demos 7, 8, 9 and 10 (the archived runs predate the standstill-qualified dwell and the measured-velocity envelope). Flight log verifiable offline with verify_log.py --replay. Core invariants (zero actuator authority outside RUN, stopping-envelope lower bound, clock monotonicity, standstill-dwell gating, HSR stream-monitor properties) are checked by stdlib property tests over defined input grids (tests/test_gate_invariants.py). Also packaged as a standalone ROS 2 node (qerra_gate_node v0.3.2) with parameterised timing profiles (96 ms simulation, 160 ms for a 10 Hz scanner), built and tested under ROS 2 Jazzy in CI: live DDS topic traffic, dual-protocol reflex integration, Pattern B topic remapping, Nav2-compatible exterior command-interface integration, /odom ingestion and watchdog tests (isolated stubs plus a live DDS /odom publisher), and LaserScan metadata validation. Software-side timing was measured once inside the ros:jazzy container (see Empirical ROS 2 timing and contention); it is an observation, not a bound. The Nav2 exterior tests use a Nav2-compatible command-source harness, not a running Nav2 stack. Current counts: see Running the Tests. Simulation and CI evidence only. |
Layer 1B: QERRA-HSR (hsr/) |
A 3-vector reflex signal (immediate_physical_distress, human_isolation, environmental_hazard_proximity) under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. The Gate acts on it when it is wired in (CRITICAL trips the gate). In the ROS 2 node a pure-function stream monitor (step_hsr_stream), wrapped by the shared pure-Python receiver gate/hsr_receiver.py (ros2/hsr_receiver.py is a compatibility shim), checks packet sequence order, detects frozen frames, and allows a counter rebase only after both at least 5 qualifying control ticks and at least 160 ms of elapsed observation time. Telemetry arrives over UDP (default, used by Webots) or over a ROS topic (hsr_source="topic", in which case no UDP socket is opened). Pure Python, Apache-2.0. (“HSR” here is this project’s own name and is unrelated to Toyota’s Human Support Robot.) |
Built and unit-tested (see Running the Tests). Evaluated in Webots Demos 6, 9 and 10 with a stabilised 1.0 s dwell and Property HSR-5 recovery directives. The stream monitor has edge-case matrix tests and a 159 ms / 160 ms rebase boundary test in the host suite, and the ROS-topic path is exercised by live multi-node tests in the container (dwell, acute distress, frame freeze, staleness). All HSR input in the demonstrations is injected or synthetic. |
| Layer 2: SEMEV-12 | Advisory screening of text task instructions against 12 moral and coercion vectors. MiniLM embeddings with deterministic scoring gates and negation pre-filtering. Not part of the physical safety function. | Built, unit-tested and benchmarked (15 regression cases, 80-case baseline, active adversarial suite). The adversarial benchmark documents known evasion vectors. |
| Layer 3: QERRA-THRIVE | Advisory values ranking for actions that have passed safety and moral screening (pacing, personal space, clear signalling, flora/animal protection). Native PyTrees integration. | Built and unit-tested across human-centered and ecological suites. Heuristic weights; not yet evaluated with human participants. |
Where to start:
- Safety and robotics engineers:
TECHNICAL_BRIEF_ROS2_GATE.md(frozen executive architecture reference and permalink),SAFETY_CONCEPT.md(v0.12),QERRA-HSR-Design-v0.1.md,LIMITATIONS.md,verify_log.py, the ROS 2 Integration section, and the Demo 7, 8, 9 and 10 sections below. - Ethics, human-robot interaction and standards readers: the SEMEV-12 and QERRA-THRIVE sections below,
SEMEV-12_Whitepaper.md,QERRA-THRIVE_framework_documentation.md, and the two benchmark files.
What QERRA Does
QERRA-v2 Classical is an open-source execution guard for autonomous robots and AI systems.
A mobile robot should never rely on an unpredictable neural network to make safety-relevant physical motion decisions. If a complex model lags or hallucinates, a 70 kg machine can crush someone.
QERRA addresses this by splitting safety into three separate, accountable jobs that run in a strict sequence:
-
The Deterministic Gate & Assistive Reflex (Layer 1A & 1B):
-
Layer 1A — The Supervisory Gate (
gate/): Pure-function, standard-library-only integer state machine that decides velocity commands. It evaluates velocity proposals from untrusted planners against a dynamic kinematic stopping envelope ($d_{stop} = \lceil v_{ref}^2 / (2a_{design}) \rceil + \lceil v_{ref} \cdot t_{react} \rceil + margin$, with $a_{design} = 0.5\ \text{m/s}^2$ (500 mm/s$^2$) and $margin = 300\ \text{mm}$; use $v_{ref}$ in mm/s, $a_{design}$ in mm/s$^2$, and $t_{react}$ in seconds (or $t_{react,us} / 10^6$) to obtain millimetres). The reference speed is $v_{ref} = \max(v_{cmd}, v_{meas})$.gate/gate_core.pyderives $v_{meas}$ (chassis_forward_mmps) from the measured wheel speedsmeas_left_urad_sandmeas_right_urad_sthrough differential-drive kinematics: $\lceil (left + right) \cdot wheel_radius_mm / 2{,}000{,}000 \rceil$ when positive, otherwise 0. Pure in-place yaw rotation ($left + right = 0$) therefore evaluates to 0 mm/s forward translation and does not enlarge the forward stopping distance. When measurements are missing, stale or invalid (None), $v_{meas}$ is 0 and $v_{ref}$ falls back to the commanded speed. Reaction time is parameterised: the Webots controller used a 32 ms lockstep allowance ($d_{stop} = 346\ \text{mm}$ at 196 mm/s cruise, 347 mm at 200 mm/s), while the ROS 2 node exposes a 96 ms simulation profile ($d_{stop} = 358\ \text{mm}$ at 196 mm/s, 360 mm at 200 mm/s) and a 160 ms profile for a 10 Hz scanner ($d_{stop} = 371\ \text{mm}$ at 196 mm/s, 372 mm at 200 mm/s). The 96 ms and 160 ms values are engineering estimates, not measured latencies. The gate trips fail-closed on obstacle breach, clock anomalies, invalid sensor scans, proposer stalls ($\ge 150\ \text{ms}$), or, when a flight log is configured, a failed log write orfsync(requirement R-10), and enforces a 1.0 s continuous-clear dwell and a manual operator reset before recovery. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required, defaultFalse;w_standstill_tol_urad_s = 50_000urad/s): when enabled, the calm dwell waits for verified physical standstill from measured wheel speeds. In verified simulation (TIAGo base in Webots R2025a,RUN_1791713619, recorded before the measured-velocity term existed), a commanded cruise was halted with $36\ \text{mm}$ of physical coasting after a trip at 337 mm clearance (standstill at 301 mm). -
Layer 1B — QERRA-HSR Reflex (
hsr/): Pure Python threshold reflex under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. Evaluates distress telemetry, human isolation, and proximity hazards to issue reflex states (CLEAR,MONITOR,CRITICAL) and Property HSR-5 human-in-the-loop recovery directives. The Gate trips onCRITICAL. In the ROS 2 node, incoming telemetry passes through a pure stream monitor (step_hsr_stream, wrapped by the shared receivergate/hsr_receiver.py;ros2/hsr_receiver.pyis a compatibility shim) that checks packet order, detects frozen frames, and presents no valid status ((None, None)) during a fault or a rebase dwell. Withhsr_required=truethe gate core turns that intoTRIP_HSR_INVALID. InMode.RUN,MONITORimposes no velocity cap: the existing 3.0 rad/s (0.294 m/s) envelope holds. While latched inMode.TRIPPEDorMode.AWAITING_RESET,MONITORblocks clear-dwell completion and causes operator reset rejection.
-
Layer 1A — The Supervisory Gate (
-
The Moral Conscience (SEMEV-12): A 12-dimensional ethical filter that evaluates text instructions before the robot moves. If someone orders the robot to do something abusive, deceptive, or coercive (such as forcing a worker through a break or falsifying safety records), the robot refuses the command, illuminates an amber LED, logs the refusal reason, and physically shakes its head “No” in simulation.
- The Social Manners (QERRA-THRIVE): A 12-vector ranker for tasks that are already physically safe and morally clean. It selects the most considerate way to move, such as quiet “whisper mode” in hospital corridors or keeping off garden lawns unless an emergency overrides etiquette.
The decision logic is deterministic, inspectable, and auditable. Every result outputs the exact vectors that triggered, human-readable reasoning, and a concrete recovery directive.
⚖️ Authorship & License
QERRA-v2 Classical is designed and developed by Marussa Metocharaki.
- Open Source License: The entire repository is licensed under the Apache License 2.0.
- Permissive Robotics Architecture: Permissive for chassis-local ROS 2 integration, academic research, and commercial robotics adoption.
-
Original Work & Archival: The core frameworks, vector logic, and scoring architectures are timestamped and permanently archived on Zenodo.
DOI (Zenodo): https://doi.org/10.5281/zenodo.24625489 ORCID: https://orcid.org/0009-0009-4100-9881
Quickstart
Public example endpoint (no API key required):
curl https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/example
Main endpoint (/analyze) requires the public test key:
x-api-key: TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
Full documentation:
https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/docs
Try QERRA in a Behavior Tree — 2 minutes, no ROS 2 required
QERRA-v2 includes a standalone PyTrees Condition node that calls the live API directly over HTTP. No ROS 2 installation, no qerra_msgs package, no build step.
pip install py_trees requests
export QERRA_API_KEY=TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
python test_bt_tick.py --live
This runs a real Behavior Tree against the live two-layer API (SEMEV-12 + QERRA-HSR), showing both a SAFE scenario (ethical check passes, task executes) and a HIGH RISK scenario (ethical check blocks, robot holds and requests human review).
```bash python test_bt_tick.py –live –risk # high risk scenario only python test_bt_tick.py –live –safe # safe scenario only python test_bt_tick.py # offline mock mode, no API call
File truncated at 100 lines see the full file
CONTRIBUTING
Repository Summary
| Description | |
| Checkout URI | https://github.com/marunigno-ship-it/QERRA-v2-classical.git |
| VCS Type | git |
| VCS Version | main |
| Last Updated | 2026-11-30 |
| Dev Status | UNKNOWN |
| Released | UNRELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
| Name | Version |
|---|---|
| qerra_core | 2.5.0 |
README
QERRA-v2 Classical
A fully explainable, classical three-layer pipeline for AI systems and autonomous robots.
Physical safety (Supervisory Gate + QERRA-HSR) → moral filtering (SEMEV-12) → flourishing-ranked choice (QERRA-THRIVE) — 27 named, auditable vectors (3 + 12 + 12), deterministic rule bounds.
The Idea in One Sentence
Values and ethics can screen and rank what a robot wants to do, but only a deterministic gate decides what the wheels do.
The setting this is built for: a transport cobot in a hospital corridor yields and slows near people, and the Gate is intended to command a stop when specified monitored fault conditions are detected. A Gate process or communication failure still requires an independent downstream command timeout or hardware safety function; this prototype does not demonstrate that the robot stops safely by itself after process failure. The system can leave a record a safety officer can audit.
Status in one paragraph. QERRA is a simulation-based research prototype. It is not a certified safety system, it has not been tested on hardware, and a 0.0 wheel command is a software setpoint, not an emergency stop. The deterministic gate (Gate Core v0.5) is demonstrated in Webots and, as a standalone ROS 2 node (
qerra_gate_nodev0.3.2), is built, executed and tested under ROS 2 Jazzy in GitHub Actions (live DDS topic traffic, dual-protocol reflex co-execution, Pattern B topic remapping, Nav2-compatible exterior command-interface tests,/odomingestion tests including a live DDS/odompublisher, and LaserScan metadata validation tests). Package metadata is v2.5.0 (Gate Core v0.5, ROS 2 Node v0.3.2), incorporating the measured-velocity dynamic stopping envelope, standstill-qualified dwell, 10-point LaserScan metadata and REP-117 bounds validation, and empirical ROS 2 Jazzy timing characterization. Current test counts are in Running the Tests, measured timing is in Empirical ROS 2 timing and contention, and the GitHub Actions workflows (tests.ymlandros2_jazzy.yml) are the live source of truth for CI runs. The Pattern B tests exercise a Nav2-compatible external command interface; they do not launch a complete Nav2 stack. The optional standstill-qualified recovery dwell is opt-in, and the archived Webots runs predate it and the measured-velocity stopping envelope. Localhost is an assumed trusted process boundary, and two documented exploit scenarios show what that assumption leaves open. See the frozen Technical Brief and Known limitations.
| Layer | Role | Evidence today |
|---|---|---|
Layer 1A: Supervisory Gate (gate/) |
The component that decides wheel commands. In the Webots controller it is the only process that writes wheel velocities. Pure standard-library integer state machine enforcing a dynamic stopping envelope $d_{stop}(v_{ref})$ with $v_{ref} = \max(v_{cmd}, v_{meas})$, where $v_{meas}$ is the chassis forward speed derived from measured wheel feedback, watchdog liveness (150 ms), and fail-closed latched recovery with operator reset. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required: bool = False, w_standstill_tol_urad_s: int = 50_000 urad/s): when enabled, the 1.0 s calm dwell waits for verified physical standstill from measured wheel speeds, without generating a deceleration trajectory (an open-loop TRIP_BRAKING was intentionally rejected to keep Doer-Checker separation; the Gate commands (0, 0) immediately upon any trip). Both the Webots controller and the ROS 2 node can log every tick to a SHA-256 rolling hash chain, and the node trips fail-closed if a log write fails (requirement R-10). |
Demonstrated in simulation: Demos 7, 8, 9 and 10 (the archived runs predate the standstill-qualified dwell and the measured-velocity envelope). Flight log verifiable offline with verify_log.py --replay. Core invariants (zero actuator authority outside RUN, stopping-envelope lower bound, clock monotonicity, standstill-dwell gating, HSR stream-monitor properties) are checked by stdlib property tests over defined input grids (tests/test_gate_invariants.py). Also packaged as a standalone ROS 2 node (qerra_gate_node v0.3.2) with parameterised timing profiles (96 ms simulation, 160 ms for a 10 Hz scanner), built and tested under ROS 2 Jazzy in CI: live DDS topic traffic, dual-protocol reflex integration, Pattern B topic remapping, Nav2-compatible exterior command-interface integration, /odom ingestion and watchdog tests (isolated stubs plus a live DDS /odom publisher), and LaserScan metadata validation. Software-side timing was measured once inside the ros:jazzy container (see Empirical ROS 2 timing and contention); it is an observation, not a bound. The Nav2 exterior tests use a Nav2-compatible command-source harness, not a running Nav2 stack. Current counts: see Running the Tests. Simulation and CI evidence only. |
Layer 1B: QERRA-HSR (hsr/) |
A 3-vector reflex signal (immediate_physical_distress, human_isolation, environmental_hazard_proximity) under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. The Gate acts on it when it is wired in (CRITICAL trips the gate). In the ROS 2 node a pure-function stream monitor (step_hsr_stream), wrapped by the shared pure-Python receiver gate/hsr_receiver.py (ros2/hsr_receiver.py is a compatibility shim), checks packet sequence order, detects frozen frames, and allows a counter rebase only after both at least 5 qualifying control ticks and at least 160 ms of elapsed observation time. Telemetry arrives over UDP (default, used by Webots) or over a ROS topic (hsr_source="topic", in which case no UDP socket is opened). Pure Python, Apache-2.0. (“HSR” here is this project’s own name and is unrelated to Toyota’s Human Support Robot.) |
Built and unit-tested (see Running the Tests). Evaluated in Webots Demos 6, 9 and 10 with a stabilised 1.0 s dwell and Property HSR-5 recovery directives. The stream monitor has edge-case matrix tests and a 159 ms / 160 ms rebase boundary test in the host suite, and the ROS-topic path is exercised by live multi-node tests in the container (dwell, acute distress, frame freeze, staleness). All HSR input in the demonstrations is injected or synthetic. |
| Layer 2: SEMEV-12 | Advisory screening of text task instructions against 12 moral and coercion vectors. MiniLM embeddings with deterministic scoring gates and negation pre-filtering. Not part of the physical safety function. | Built, unit-tested and benchmarked (15 regression cases, 80-case baseline, active adversarial suite). The adversarial benchmark documents known evasion vectors. |
| Layer 3: QERRA-THRIVE | Advisory values ranking for actions that have passed safety and moral screening (pacing, personal space, clear signalling, flora/animal protection). Native PyTrees integration. | Built and unit-tested across human-centered and ecological suites. Heuristic weights; not yet evaluated with human participants. |
Where to start:
- Safety and robotics engineers:
TECHNICAL_BRIEF_ROS2_GATE.md(frozen executive architecture reference and permalink),SAFETY_CONCEPT.md(v0.12),QERRA-HSR-Design-v0.1.md,LIMITATIONS.md,verify_log.py, the ROS 2 Integration section, and the Demo 7, 8, 9 and 10 sections below. - Ethics, human-robot interaction and standards readers: the SEMEV-12 and QERRA-THRIVE sections below,
SEMEV-12_Whitepaper.md,QERRA-THRIVE_framework_documentation.md, and the two benchmark files.
What QERRA Does
QERRA-v2 Classical is an open-source execution guard for autonomous robots and AI systems.
A mobile robot should never rely on an unpredictable neural network to make safety-relevant physical motion decisions. If a complex model lags or hallucinates, a 70 kg machine can crush someone.
QERRA addresses this by splitting safety into three separate, accountable jobs that run in a strict sequence:
-
The Deterministic Gate & Assistive Reflex (Layer 1A & 1B):
-
Layer 1A — The Supervisory Gate (
gate/): Pure-function, standard-library-only integer state machine that decides velocity commands. It evaluates velocity proposals from untrusted planners against a dynamic kinematic stopping envelope ($d_{stop} = \lceil v_{ref}^2 / (2a_{design}) \rceil + \lceil v_{ref} \cdot t_{react} \rceil + margin$, with $a_{design} = 0.5\ \text{m/s}^2$ (500 mm/s$^2$) and $margin = 300\ \text{mm}$; use $v_{ref}$ in mm/s, $a_{design}$ in mm/s$^2$, and $t_{react}$ in seconds (or $t_{react,us} / 10^6$) to obtain millimetres). The reference speed is $v_{ref} = \max(v_{cmd}, v_{meas})$.gate/gate_core.pyderives $v_{meas}$ (chassis_forward_mmps) from the measured wheel speedsmeas_left_urad_sandmeas_right_urad_sthrough differential-drive kinematics: $\lceil (left + right) \cdot wheel_radius_mm / 2{,}000{,}000 \rceil$ when positive, otherwise 0. Pure in-place yaw rotation ($left + right = 0$) therefore evaluates to 0 mm/s forward translation and does not enlarge the forward stopping distance. When measurements are missing, stale or invalid (None), $v_{meas}$ is 0 and $v_{ref}$ falls back to the commanded speed. Reaction time is parameterised: the Webots controller used a 32 ms lockstep allowance ($d_{stop} = 346\ \text{mm}$ at 196 mm/s cruise, 347 mm at 200 mm/s), while the ROS 2 node exposes a 96 ms simulation profile ($d_{stop} = 358\ \text{mm}$ at 196 mm/s, 360 mm at 200 mm/s) and a 160 ms profile for a 10 Hz scanner ($d_{stop} = 371\ \text{mm}$ at 196 mm/s, 372 mm at 200 mm/s). The 96 ms and 160 ms values are engineering estimates, not measured latencies. The gate trips fail-closed on obstacle breach, clock anomalies, invalid sensor scans, proposer stalls ($\ge 150\ \text{ms}$), or, when a flight log is configured, a failed log write orfsync(requirement R-10), and enforces a 1.0 s continuous-clear dwell and a manual operator reset before recovery. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required, defaultFalse;w_standstill_tol_urad_s = 50_000urad/s): when enabled, the calm dwell waits for verified physical standstill from measured wheel speeds. In verified simulation (TIAGo base in Webots R2025a,RUN_1791713619, recorded before the measured-velocity term existed), a commanded cruise was halted with $36\ \text{mm}$ of physical coasting after a trip at 337 mm clearance (standstill at 301 mm). -
Layer 1B — QERRA-HSR Reflex (
hsr/): Pure Python threshold reflex under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. Evaluates distress telemetry, human isolation, and proximity hazards to issue reflex states (CLEAR,MONITOR,CRITICAL) and Property HSR-5 human-in-the-loop recovery directives. The Gate trips onCRITICAL. In the ROS 2 node, incoming telemetry passes through a pure stream monitor (step_hsr_stream, wrapped by the shared receivergate/hsr_receiver.py;ros2/hsr_receiver.pyis a compatibility shim) that checks packet order, detects frozen frames, and presents no valid status ((None, None)) during a fault or a rebase dwell. Withhsr_required=truethe gate core turns that intoTRIP_HSR_INVALID. InMode.RUN,MONITORimposes no velocity cap: the existing 3.0 rad/s (0.294 m/s) envelope holds. While latched inMode.TRIPPEDorMode.AWAITING_RESET,MONITORblocks clear-dwell completion and causes operator reset rejection.
-
Layer 1A — The Supervisory Gate (
-
The Moral Conscience (SEMEV-12): A 12-dimensional ethical filter that evaluates text instructions before the robot moves. If someone orders the robot to do something abusive, deceptive, or coercive (such as forcing a worker through a break or falsifying safety records), the robot refuses the command, illuminates an amber LED, logs the refusal reason, and physically shakes its head “No” in simulation.
- The Social Manners (QERRA-THRIVE): A 12-vector ranker for tasks that are already physically safe and morally clean. It selects the most considerate way to move, such as quiet “whisper mode” in hospital corridors or keeping off garden lawns unless an emergency overrides etiquette.
The decision logic is deterministic, inspectable, and auditable. Every result outputs the exact vectors that triggered, human-readable reasoning, and a concrete recovery directive.
⚖️ Authorship & License
QERRA-v2 Classical is designed and developed by Marussa Metocharaki.
- Open Source License: The entire repository is licensed under the Apache License 2.0.
- Permissive Robotics Architecture: Permissive for chassis-local ROS 2 integration, academic research, and commercial robotics adoption.
-
Original Work & Archival: The core frameworks, vector logic, and scoring architectures are timestamped and permanently archived on Zenodo.
DOI (Zenodo): https://doi.org/10.5281/zenodo.24625489 ORCID: https://orcid.org/0009-0009-4100-9881
Quickstart
Public example endpoint (no API key required):
curl https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/example
Main endpoint (/analyze) requires the public test key:
x-api-key: TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
Full documentation:
https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/docs
Try QERRA in a Behavior Tree — 2 minutes, no ROS 2 required
QERRA-v2 includes a standalone PyTrees Condition node that calls the live API directly over HTTP. No ROS 2 installation, no qerra_msgs package, no build step.
pip install py_trees requests
export QERRA_API_KEY=TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
python test_bt_tick.py --live
This runs a real Behavior Tree against the live two-layer API (SEMEV-12 + QERRA-HSR), showing both a SAFE scenario (ethical check passes, task executes) and a HIGH RISK scenario (ethical check blocks, robot holds and requests human review).
```bash python test_bt_tick.py –live –risk # high risk scenario only python test_bt_tick.py –live –safe # safe scenario only python test_bt_tick.py # offline mock mode, no API call
File truncated at 100 lines see the full file
CONTRIBUTING
Repository Summary
| Description | |
| Checkout URI | https://github.com/marunigno-ship-it/QERRA-v2-classical.git |
| VCS Type | git |
| VCS Version | main |
| Last Updated | 2026-11-30 |
| Dev Status | UNKNOWN |
| Released | UNRELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
| Name | Version |
|---|---|
| qerra_core | 2.5.0 |
README
QERRA-v2 Classical
A fully explainable, classical three-layer pipeline for AI systems and autonomous robots.
Physical safety (Supervisory Gate + QERRA-HSR) → moral filtering (SEMEV-12) → flourishing-ranked choice (QERRA-THRIVE) — 27 named, auditable vectors (3 + 12 + 12), deterministic rule bounds.
The Idea in One Sentence
Values and ethics can screen and rank what a robot wants to do, but only a deterministic gate decides what the wheels do.
The setting this is built for: a transport cobot in a hospital corridor yields and slows near people, and the Gate is intended to command a stop when specified monitored fault conditions are detected. A Gate process or communication failure still requires an independent downstream command timeout or hardware safety function; this prototype does not demonstrate that the robot stops safely by itself after process failure. The system can leave a record a safety officer can audit.
Status in one paragraph. QERRA is a simulation-based research prototype. It is not a certified safety system, it has not been tested on hardware, and a 0.0 wheel command is a software setpoint, not an emergency stop. The deterministic gate (Gate Core v0.5) is demonstrated in Webots and, as a standalone ROS 2 node (
qerra_gate_nodev0.3.2), is built, executed and tested under ROS 2 Jazzy in GitHub Actions (live DDS topic traffic, dual-protocol reflex co-execution, Pattern B topic remapping, Nav2-compatible exterior command-interface tests,/odomingestion tests including a live DDS/odompublisher, and LaserScan metadata validation tests). Package metadata is v2.5.0 (Gate Core v0.5, ROS 2 Node v0.3.2), incorporating the measured-velocity dynamic stopping envelope, standstill-qualified dwell, 10-point LaserScan metadata and REP-117 bounds validation, and empirical ROS 2 Jazzy timing characterization. Current test counts are in Running the Tests, measured timing is in Empirical ROS 2 timing and contention, and the GitHub Actions workflows (tests.ymlandros2_jazzy.yml) are the live source of truth for CI runs. The Pattern B tests exercise a Nav2-compatible external command interface; they do not launch a complete Nav2 stack. The optional standstill-qualified recovery dwell is opt-in, and the archived Webots runs predate it and the measured-velocity stopping envelope. Localhost is an assumed trusted process boundary, and two documented exploit scenarios show what that assumption leaves open. See the frozen Technical Brief and Known limitations.
| Layer | Role | Evidence today |
|---|---|---|
Layer 1A: Supervisory Gate (gate/) |
The component that decides wheel commands. In the Webots controller it is the only process that writes wheel velocities. Pure standard-library integer state machine enforcing a dynamic stopping envelope $d_{stop}(v_{ref})$ with $v_{ref} = \max(v_{cmd}, v_{meas})$, where $v_{meas}$ is the chassis forward speed derived from measured wheel feedback, watchdog liveness (150 ms), and fail-closed latched recovery with operator reset. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required: bool = False, w_standstill_tol_urad_s: int = 50_000 urad/s): when enabled, the 1.0 s calm dwell waits for verified physical standstill from measured wheel speeds, without generating a deceleration trajectory (an open-loop TRIP_BRAKING was intentionally rejected to keep Doer-Checker separation; the Gate commands (0, 0) immediately upon any trip). Both the Webots controller and the ROS 2 node can log every tick to a SHA-256 rolling hash chain, and the node trips fail-closed if a log write fails (requirement R-10). |
Demonstrated in simulation: Demos 7, 8, 9 and 10 (the archived runs predate the standstill-qualified dwell and the measured-velocity envelope). Flight log verifiable offline with verify_log.py --replay. Core invariants (zero actuator authority outside RUN, stopping-envelope lower bound, clock monotonicity, standstill-dwell gating, HSR stream-monitor properties) are checked by stdlib property tests over defined input grids (tests/test_gate_invariants.py). Also packaged as a standalone ROS 2 node (qerra_gate_node v0.3.2) with parameterised timing profiles (96 ms simulation, 160 ms for a 10 Hz scanner), built and tested under ROS 2 Jazzy in CI: live DDS topic traffic, dual-protocol reflex integration, Pattern B topic remapping, Nav2-compatible exterior command-interface integration, /odom ingestion and watchdog tests (isolated stubs plus a live DDS /odom publisher), and LaserScan metadata validation. Software-side timing was measured once inside the ros:jazzy container (see Empirical ROS 2 timing and contention); it is an observation, not a bound. The Nav2 exterior tests use a Nav2-compatible command-source harness, not a running Nav2 stack. Current counts: see Running the Tests. Simulation and CI evidence only. |
Layer 1B: QERRA-HSR (hsr/) |
A 3-vector reflex signal (immediate_physical_distress, human_isolation, environmental_hazard_proximity) under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. The Gate acts on it when it is wired in (CRITICAL trips the gate). In the ROS 2 node a pure-function stream monitor (step_hsr_stream), wrapped by the shared pure-Python receiver gate/hsr_receiver.py (ros2/hsr_receiver.py is a compatibility shim), checks packet sequence order, detects frozen frames, and allows a counter rebase only after both at least 5 qualifying control ticks and at least 160 ms of elapsed observation time. Telemetry arrives over UDP (default, used by Webots) or over a ROS topic (hsr_source="topic", in which case no UDP socket is opened). Pure Python, Apache-2.0. (“HSR” here is this project’s own name and is unrelated to Toyota’s Human Support Robot.) |
Built and unit-tested (see Running the Tests). Evaluated in Webots Demos 6, 9 and 10 with a stabilised 1.0 s dwell and Property HSR-5 recovery directives. The stream monitor has edge-case matrix tests and a 159 ms / 160 ms rebase boundary test in the host suite, and the ROS-topic path is exercised by live multi-node tests in the container (dwell, acute distress, frame freeze, staleness). All HSR input in the demonstrations is injected or synthetic. |
| Layer 2: SEMEV-12 | Advisory screening of text task instructions against 12 moral and coercion vectors. MiniLM embeddings with deterministic scoring gates and negation pre-filtering. Not part of the physical safety function. | Built, unit-tested and benchmarked (15 regression cases, 80-case baseline, active adversarial suite). The adversarial benchmark documents known evasion vectors. |
| Layer 3: QERRA-THRIVE | Advisory values ranking for actions that have passed safety and moral screening (pacing, personal space, clear signalling, flora/animal protection). Native PyTrees integration. | Built and unit-tested across human-centered and ecological suites. Heuristic weights; not yet evaluated with human participants. |
Where to start:
- Safety and robotics engineers:
TECHNICAL_BRIEF_ROS2_GATE.md(frozen executive architecture reference and permalink),SAFETY_CONCEPT.md(v0.12),QERRA-HSR-Design-v0.1.md,LIMITATIONS.md,verify_log.py, the ROS 2 Integration section, and the Demo 7, 8, 9 and 10 sections below. - Ethics, human-robot interaction and standards readers: the SEMEV-12 and QERRA-THRIVE sections below,
SEMEV-12_Whitepaper.md,QERRA-THRIVE_framework_documentation.md, and the two benchmark files.
What QERRA Does
QERRA-v2 Classical is an open-source execution guard for autonomous robots and AI systems.
A mobile robot should never rely on an unpredictable neural network to make safety-relevant physical motion decisions. If a complex model lags or hallucinates, a 70 kg machine can crush someone.
QERRA addresses this by splitting safety into three separate, accountable jobs that run in a strict sequence:
-
The Deterministic Gate & Assistive Reflex (Layer 1A & 1B):
-
Layer 1A — The Supervisory Gate (
gate/): Pure-function, standard-library-only integer state machine that decides velocity commands. It evaluates velocity proposals from untrusted planners against a dynamic kinematic stopping envelope ($d_{stop} = \lceil v_{ref}^2 / (2a_{design}) \rceil + \lceil v_{ref} \cdot t_{react} \rceil + margin$, with $a_{design} = 0.5\ \text{m/s}^2$ (500 mm/s$^2$) and $margin = 300\ \text{mm}$; use $v_{ref}$ in mm/s, $a_{design}$ in mm/s$^2$, and $t_{react}$ in seconds (or $t_{react,us} / 10^6$) to obtain millimetres). The reference speed is $v_{ref} = \max(v_{cmd}, v_{meas})$.gate/gate_core.pyderives $v_{meas}$ (chassis_forward_mmps) from the measured wheel speedsmeas_left_urad_sandmeas_right_urad_sthrough differential-drive kinematics: $\lceil (left + right) \cdot wheel_radius_mm / 2{,}000{,}000 \rceil$ when positive, otherwise 0. Pure in-place yaw rotation ($left + right = 0$) therefore evaluates to 0 mm/s forward translation and does not enlarge the forward stopping distance. When measurements are missing, stale or invalid (None), $v_{meas}$ is 0 and $v_{ref}$ falls back to the commanded speed. Reaction time is parameterised: the Webots controller used a 32 ms lockstep allowance ($d_{stop} = 346\ \text{mm}$ at 196 mm/s cruise, 347 mm at 200 mm/s), while the ROS 2 node exposes a 96 ms simulation profile ($d_{stop} = 358\ \text{mm}$ at 196 mm/s, 360 mm at 200 mm/s) and a 160 ms profile for a 10 Hz scanner ($d_{stop} = 371\ \text{mm}$ at 196 mm/s, 372 mm at 200 mm/s). The 96 ms and 160 ms values are engineering estimates, not measured latencies. The gate trips fail-closed on obstacle breach, clock anomalies, invalid sensor scans, proposer stalls ($\ge 150\ \text{ms}$), or, when a flight log is configured, a failed log write orfsync(requirement R-10), and enforces a 1.0 s continuous-clear dwell and a manual operator reset before recovery. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required, defaultFalse;w_standstill_tol_urad_s = 50_000urad/s): when enabled, the calm dwell waits for verified physical standstill from measured wheel speeds. In verified simulation (TIAGo base in Webots R2025a,RUN_1791713619, recorded before the measured-velocity term existed), a commanded cruise was halted with $36\ \text{mm}$ of physical coasting after a trip at 337 mm clearance (standstill at 301 mm). -
Layer 1B — QERRA-HSR Reflex (
hsr/): Pure Python threshold reflex under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. Evaluates distress telemetry, human isolation, and proximity hazards to issue reflex states (CLEAR,MONITOR,CRITICAL) and Property HSR-5 human-in-the-loop recovery directives. The Gate trips onCRITICAL. In the ROS 2 node, incoming telemetry passes through a pure stream monitor (step_hsr_stream, wrapped by the shared receivergate/hsr_receiver.py;ros2/hsr_receiver.pyis a compatibility shim) that checks packet order, detects frozen frames, and presents no valid status ((None, None)) during a fault or a rebase dwell. Withhsr_required=truethe gate core turns that intoTRIP_HSR_INVALID. InMode.RUN,MONITORimposes no velocity cap: the existing 3.0 rad/s (0.294 m/s) envelope holds. While latched inMode.TRIPPEDorMode.AWAITING_RESET,MONITORblocks clear-dwell completion and causes operator reset rejection.
-
Layer 1A — The Supervisory Gate (
-
The Moral Conscience (SEMEV-12): A 12-dimensional ethical filter that evaluates text instructions before the robot moves. If someone orders the robot to do something abusive, deceptive, or coercive (such as forcing a worker through a break or falsifying safety records), the robot refuses the command, illuminates an amber LED, logs the refusal reason, and physically shakes its head “No” in simulation.
- The Social Manners (QERRA-THRIVE): A 12-vector ranker for tasks that are already physically safe and morally clean. It selects the most considerate way to move, such as quiet “whisper mode” in hospital corridors or keeping off garden lawns unless an emergency overrides etiquette.
The decision logic is deterministic, inspectable, and auditable. Every result outputs the exact vectors that triggered, human-readable reasoning, and a concrete recovery directive.
⚖️ Authorship & License
QERRA-v2 Classical is designed and developed by Marussa Metocharaki.
- Open Source License: The entire repository is licensed under the Apache License 2.0.
- Permissive Robotics Architecture: Permissive for chassis-local ROS 2 integration, academic research, and commercial robotics adoption.
-
Original Work & Archival: The core frameworks, vector logic, and scoring architectures are timestamped and permanently archived on Zenodo.
DOI (Zenodo): https://doi.org/10.5281/zenodo.24625489 ORCID: https://orcid.org/0009-0009-4100-9881
Quickstart
Public example endpoint (no API key required):
curl https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/example
Main endpoint (/analyze) requires the public test key:
x-api-key: TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
Full documentation:
https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/docs
Try QERRA in a Behavior Tree — 2 minutes, no ROS 2 required
QERRA-v2 includes a standalone PyTrees Condition node that calls the live API directly over HTTP. No ROS 2 installation, no qerra_msgs package, no build step.
pip install py_trees requests
export QERRA_API_KEY=TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
python test_bt_tick.py --live
This runs a real Behavior Tree against the live two-layer API (SEMEV-12 + QERRA-HSR), showing both a SAFE scenario (ethical check passes, task executes) and a HIGH RISK scenario (ethical check blocks, robot holds and requests human review).
```bash python test_bt_tick.py –live –risk # high risk scenario only python test_bt_tick.py –live –safe # safe scenario only python test_bt_tick.py # offline mock mode, no API call
File truncated at 100 lines see the full file
CONTRIBUTING
Repository Summary
| Description | |
| Checkout URI | https://github.com/marunigno-ship-it/QERRA-v2-classical.git |
| VCS Type | git |
| VCS Version | main |
| Last Updated | 2026-11-30 |
| Dev Status | UNKNOWN |
| Released | UNRELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
| Name | Version |
|---|---|
| qerra_core | 2.5.0 |
README
QERRA-v2 Classical
A fully explainable, classical three-layer pipeline for AI systems and autonomous robots.
Physical safety (Supervisory Gate + QERRA-HSR) → moral filtering (SEMEV-12) → flourishing-ranked choice (QERRA-THRIVE) — 27 named, auditable vectors (3 + 12 + 12), deterministic rule bounds.
The Idea in One Sentence
Values and ethics can screen and rank what a robot wants to do, but only a deterministic gate decides what the wheels do.
The setting this is built for: a transport cobot in a hospital corridor yields and slows near people, and the Gate is intended to command a stop when specified monitored fault conditions are detected. A Gate process or communication failure still requires an independent downstream command timeout or hardware safety function; this prototype does not demonstrate that the robot stops safely by itself after process failure. The system can leave a record a safety officer can audit.
Status in one paragraph. QERRA is a simulation-based research prototype. It is not a certified safety system, it has not been tested on hardware, and a 0.0 wheel command is a software setpoint, not an emergency stop. The deterministic gate (Gate Core v0.5) is demonstrated in Webots and, as a standalone ROS 2 node (
qerra_gate_nodev0.3.2), is built, executed and tested under ROS 2 Jazzy in GitHub Actions (live DDS topic traffic, dual-protocol reflex co-execution, Pattern B topic remapping, Nav2-compatible exterior command-interface tests,/odomingestion tests including a live DDS/odompublisher, and LaserScan metadata validation tests). Package metadata is v2.5.0 (Gate Core v0.5, ROS 2 Node v0.3.2), incorporating the measured-velocity dynamic stopping envelope, standstill-qualified dwell, 10-point LaserScan metadata and REP-117 bounds validation, and empirical ROS 2 Jazzy timing characterization. Current test counts are in Running the Tests, measured timing is in Empirical ROS 2 timing and contention, and the GitHub Actions workflows (tests.ymlandros2_jazzy.yml) are the live source of truth for CI runs. The Pattern B tests exercise a Nav2-compatible external command interface; they do not launch a complete Nav2 stack. The optional standstill-qualified recovery dwell is opt-in, and the archived Webots runs predate it and the measured-velocity stopping envelope. Localhost is an assumed trusted process boundary, and two documented exploit scenarios show what that assumption leaves open. See the frozen Technical Brief and Known limitations.
| Layer | Role | Evidence today |
|---|---|---|
Layer 1A: Supervisory Gate (gate/) |
The component that decides wheel commands. In the Webots controller it is the only process that writes wheel velocities. Pure standard-library integer state machine enforcing a dynamic stopping envelope $d_{stop}(v_{ref})$ with $v_{ref} = \max(v_{cmd}, v_{meas})$, where $v_{meas}$ is the chassis forward speed derived from measured wheel feedback, watchdog liveness (150 ms), and fail-closed latched recovery with operator reset. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required: bool = False, w_standstill_tol_urad_s: int = 50_000 urad/s): when enabled, the 1.0 s calm dwell waits for verified physical standstill from measured wheel speeds, without generating a deceleration trajectory (an open-loop TRIP_BRAKING was intentionally rejected to keep Doer-Checker separation; the Gate commands (0, 0) immediately upon any trip). Both the Webots controller and the ROS 2 node can log every tick to a SHA-256 rolling hash chain, and the node trips fail-closed if a log write fails (requirement R-10). |
Demonstrated in simulation: Demos 7, 8, 9 and 10 (the archived runs predate the standstill-qualified dwell and the measured-velocity envelope). Flight log verifiable offline with verify_log.py --replay. Core invariants (zero actuator authority outside RUN, stopping-envelope lower bound, clock monotonicity, standstill-dwell gating, HSR stream-monitor properties) are checked by stdlib property tests over defined input grids (tests/test_gate_invariants.py). Also packaged as a standalone ROS 2 node (qerra_gate_node v0.3.2) with parameterised timing profiles (96 ms simulation, 160 ms for a 10 Hz scanner), built and tested under ROS 2 Jazzy in CI: live DDS topic traffic, dual-protocol reflex integration, Pattern B topic remapping, Nav2-compatible exterior command-interface integration, /odom ingestion and watchdog tests (isolated stubs plus a live DDS /odom publisher), and LaserScan metadata validation. Software-side timing was measured once inside the ros:jazzy container (see Empirical ROS 2 timing and contention); it is an observation, not a bound. The Nav2 exterior tests use a Nav2-compatible command-source harness, not a running Nav2 stack. Current counts: see Running the Tests. Simulation and CI evidence only. |
Layer 1B: QERRA-HSR (hsr/) |
A 3-vector reflex signal (immediate_physical_distress, human_isolation, environmental_hazard_proximity) under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. The Gate acts on it when it is wired in (CRITICAL trips the gate). In the ROS 2 node a pure-function stream monitor (step_hsr_stream), wrapped by the shared pure-Python receiver gate/hsr_receiver.py (ros2/hsr_receiver.py is a compatibility shim), checks packet sequence order, detects frozen frames, and allows a counter rebase only after both at least 5 qualifying control ticks and at least 160 ms of elapsed observation time. Telemetry arrives over UDP (default, used by Webots) or over a ROS topic (hsr_source="topic", in which case no UDP socket is opened). Pure Python, Apache-2.0. (“HSR” here is this project’s own name and is unrelated to Toyota’s Human Support Robot.) |
Built and unit-tested (see Running the Tests). Evaluated in Webots Demos 6, 9 and 10 with a stabilised 1.0 s dwell and Property HSR-5 recovery directives. The stream monitor has edge-case matrix tests and a 159 ms / 160 ms rebase boundary test in the host suite, and the ROS-topic path is exercised by live multi-node tests in the container (dwell, acute distress, frame freeze, staleness). All HSR input in the demonstrations is injected or synthetic. |
| Layer 2: SEMEV-12 | Advisory screening of text task instructions against 12 moral and coercion vectors. MiniLM embeddings with deterministic scoring gates and negation pre-filtering. Not part of the physical safety function. | Built, unit-tested and benchmarked (15 regression cases, 80-case baseline, active adversarial suite). The adversarial benchmark documents known evasion vectors. |
| Layer 3: QERRA-THRIVE | Advisory values ranking for actions that have passed safety and moral screening (pacing, personal space, clear signalling, flora/animal protection). Native PyTrees integration. | Built and unit-tested across human-centered and ecological suites. Heuristic weights; not yet evaluated with human participants. |
Where to start:
- Safety and robotics engineers:
TECHNICAL_BRIEF_ROS2_GATE.md(frozen executive architecture reference and permalink),SAFETY_CONCEPT.md(v0.12),QERRA-HSR-Design-v0.1.md,LIMITATIONS.md,verify_log.py, the ROS 2 Integration section, and the Demo 7, 8, 9 and 10 sections below. - Ethics, human-robot interaction and standards readers: the SEMEV-12 and QERRA-THRIVE sections below,
SEMEV-12_Whitepaper.md,QERRA-THRIVE_framework_documentation.md, and the two benchmark files.
What QERRA Does
QERRA-v2 Classical is an open-source execution guard for autonomous robots and AI systems.
A mobile robot should never rely on an unpredictable neural network to make safety-relevant physical motion decisions. If a complex model lags or hallucinates, a 70 kg machine can crush someone.
QERRA addresses this by splitting safety into three separate, accountable jobs that run in a strict sequence:
-
The Deterministic Gate & Assistive Reflex (Layer 1A & 1B):
-
Layer 1A — The Supervisory Gate (
gate/): Pure-function, standard-library-only integer state machine that decides velocity commands. It evaluates velocity proposals from untrusted planners against a dynamic kinematic stopping envelope ($d_{stop} = \lceil v_{ref}^2 / (2a_{design}) \rceil + \lceil v_{ref} \cdot t_{react} \rceil + margin$, with $a_{design} = 0.5\ \text{m/s}^2$ (500 mm/s$^2$) and $margin = 300\ \text{mm}$; use $v_{ref}$ in mm/s, $a_{design}$ in mm/s$^2$, and $t_{react}$ in seconds (or $t_{react,us} / 10^6$) to obtain millimetres). The reference speed is $v_{ref} = \max(v_{cmd}, v_{meas})$.gate/gate_core.pyderives $v_{meas}$ (chassis_forward_mmps) from the measured wheel speedsmeas_left_urad_sandmeas_right_urad_sthrough differential-drive kinematics: $\lceil (left + right) \cdot wheel_radius_mm / 2{,}000{,}000 \rceil$ when positive, otherwise 0. Pure in-place yaw rotation ($left + right = 0$) therefore evaluates to 0 mm/s forward translation and does not enlarge the forward stopping distance. When measurements are missing, stale or invalid (None), $v_{meas}$ is 0 and $v_{ref}$ falls back to the commanded speed. Reaction time is parameterised: the Webots controller used a 32 ms lockstep allowance ($d_{stop} = 346\ \text{mm}$ at 196 mm/s cruise, 347 mm at 200 mm/s), while the ROS 2 node exposes a 96 ms simulation profile ($d_{stop} = 358\ \text{mm}$ at 196 mm/s, 360 mm at 200 mm/s) and a 160 ms profile for a 10 Hz scanner ($d_{stop} = 371\ \text{mm}$ at 196 mm/s, 372 mm at 200 mm/s). The 96 ms and 160 ms values are engineering estimates, not measured latencies. The gate trips fail-closed on obstacle breach, clock anomalies, invalid sensor scans, proposer stalls ($\ge 150\ \text{ms}$), or, when a flight log is configured, a failed log write orfsync(requirement R-10), and enforces a 1.0 s continuous-clear dwell and a manual operator reset before recovery. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required, defaultFalse;w_standstill_tol_urad_s = 50_000urad/s): when enabled, the calm dwell waits for verified physical standstill from measured wheel speeds. In verified simulation (TIAGo base in Webots R2025a,RUN_1791713619, recorded before the measured-velocity term existed), a commanded cruise was halted with $36\ \text{mm}$ of physical coasting after a trip at 337 mm clearance (standstill at 301 mm). -
Layer 1B — QERRA-HSR Reflex (
hsr/): Pure Python threshold reflex under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. Evaluates distress telemetry, human isolation, and proximity hazards to issue reflex states (CLEAR,MONITOR,CRITICAL) and Property HSR-5 human-in-the-loop recovery directives. The Gate trips onCRITICAL. In the ROS 2 node, incoming telemetry passes through a pure stream monitor (step_hsr_stream, wrapped by the shared receivergate/hsr_receiver.py;ros2/hsr_receiver.pyis a compatibility shim) that checks packet order, detects frozen frames, and presents no valid status ((None, None)) during a fault or a rebase dwell. Withhsr_required=truethe gate core turns that intoTRIP_HSR_INVALID. InMode.RUN,MONITORimposes no velocity cap: the existing 3.0 rad/s (0.294 m/s) envelope holds. While latched inMode.TRIPPEDorMode.AWAITING_RESET,MONITORblocks clear-dwell completion and causes operator reset rejection.
-
Layer 1A — The Supervisory Gate (
-
The Moral Conscience (SEMEV-12): A 12-dimensional ethical filter that evaluates text instructions before the robot moves. If someone orders the robot to do something abusive, deceptive, or coercive (such as forcing a worker through a break or falsifying safety records), the robot refuses the command, illuminates an amber LED, logs the refusal reason, and physically shakes its head “No” in simulation.
- The Social Manners (QERRA-THRIVE): A 12-vector ranker for tasks that are already physically safe and morally clean. It selects the most considerate way to move, such as quiet “whisper mode” in hospital corridors or keeping off garden lawns unless an emergency overrides etiquette.
The decision logic is deterministic, inspectable, and auditable. Every result outputs the exact vectors that triggered, human-readable reasoning, and a concrete recovery directive.
⚖️ Authorship & License
QERRA-v2 Classical is designed and developed by Marussa Metocharaki.
- Open Source License: The entire repository is licensed under the Apache License 2.0.
- Permissive Robotics Architecture: Permissive for chassis-local ROS 2 integration, academic research, and commercial robotics adoption.
-
Original Work & Archival: The core frameworks, vector logic, and scoring architectures are timestamped and permanently archived on Zenodo.
DOI (Zenodo): https://doi.org/10.5281/zenodo.24625489 ORCID: https://orcid.org/0009-0009-4100-9881
Quickstart
Public example endpoint (no API key required):
curl https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/example
Main endpoint (/analyze) requires the public test key:
x-api-key: TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
Full documentation:
https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/docs
Try QERRA in a Behavior Tree — 2 minutes, no ROS 2 required
QERRA-v2 includes a standalone PyTrees Condition node that calls the live API directly over HTTP. No ROS 2 installation, no qerra_msgs package, no build step.
pip install py_trees requests
export QERRA_API_KEY=TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
python test_bt_tick.py --live
This runs a real Behavior Tree against the live two-layer API (SEMEV-12 + QERRA-HSR), showing both a SAFE scenario (ethical check passes, task executes) and a HIGH RISK scenario (ethical check blocks, robot holds and requests human review).
```bash python test_bt_tick.py –live –risk # high risk scenario only python test_bt_tick.py –live –safe # safe scenario only python test_bt_tick.py # offline mock mode, no API call
File truncated at 100 lines see the full file
CONTRIBUTING
Repository Summary
| Description | |
| Checkout URI | https://github.com/marunigno-ship-it/QERRA-v2-classical.git |
| VCS Type | git |
| VCS Version | main |
| Last Updated | 2026-11-30 |
| Dev Status | UNKNOWN |
| Released | UNRELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
| Name | Version |
|---|---|
| qerra_core | 2.5.0 |
README
QERRA-v2 Classical
A fully explainable, classical three-layer pipeline for AI systems and autonomous robots.
Physical safety (Supervisory Gate + QERRA-HSR) → moral filtering (SEMEV-12) → flourishing-ranked choice (QERRA-THRIVE) — 27 named, auditable vectors (3 + 12 + 12), deterministic rule bounds.
The Idea in One Sentence
Values and ethics can screen and rank what a robot wants to do, but only a deterministic gate decides what the wheels do.
The setting this is built for: a transport cobot in a hospital corridor yields and slows near people, and the Gate is intended to command a stop when specified monitored fault conditions are detected. A Gate process or communication failure still requires an independent downstream command timeout or hardware safety function; this prototype does not demonstrate that the robot stops safely by itself after process failure. The system can leave a record a safety officer can audit.
Status in one paragraph. QERRA is a simulation-based research prototype. It is not a certified safety system, it has not been tested on hardware, and a 0.0 wheel command is a software setpoint, not an emergency stop. The deterministic gate (Gate Core v0.5) is demonstrated in Webots and, as a standalone ROS 2 node (
qerra_gate_nodev0.3.2), is built, executed and tested under ROS 2 Jazzy in GitHub Actions (live DDS topic traffic, dual-protocol reflex co-execution, Pattern B topic remapping, Nav2-compatible exterior command-interface tests,/odomingestion tests including a live DDS/odompublisher, and LaserScan metadata validation tests). Package metadata is v2.5.0 (Gate Core v0.5, ROS 2 Node v0.3.2), incorporating the measured-velocity dynamic stopping envelope, standstill-qualified dwell, 10-point LaserScan metadata and REP-117 bounds validation, and empirical ROS 2 Jazzy timing characterization. Current test counts are in Running the Tests, measured timing is in Empirical ROS 2 timing and contention, and the GitHub Actions workflows (tests.ymlandros2_jazzy.yml) are the live source of truth for CI runs. The Pattern B tests exercise a Nav2-compatible external command interface; they do not launch a complete Nav2 stack. The optional standstill-qualified recovery dwell is opt-in, and the archived Webots runs predate it and the measured-velocity stopping envelope. Localhost is an assumed trusted process boundary, and two documented exploit scenarios show what that assumption leaves open. See the frozen Technical Brief and Known limitations.
| Layer | Role | Evidence today |
|---|---|---|
Layer 1A: Supervisory Gate (gate/) |
The component that decides wheel commands. In the Webots controller it is the only process that writes wheel velocities. Pure standard-library integer state machine enforcing a dynamic stopping envelope $d_{stop}(v_{ref})$ with $v_{ref} = \max(v_{cmd}, v_{meas})$, where $v_{meas}$ is the chassis forward speed derived from measured wheel feedback, watchdog liveness (150 ms), and fail-closed latched recovery with operator reset. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required: bool = False, w_standstill_tol_urad_s: int = 50_000 urad/s): when enabled, the 1.0 s calm dwell waits for verified physical standstill from measured wheel speeds, without generating a deceleration trajectory (an open-loop TRIP_BRAKING was intentionally rejected to keep Doer-Checker separation; the Gate commands (0, 0) immediately upon any trip). Both the Webots controller and the ROS 2 node can log every tick to a SHA-256 rolling hash chain, and the node trips fail-closed if a log write fails (requirement R-10). |
Demonstrated in simulation: Demos 7, 8, 9 and 10 (the archived runs predate the standstill-qualified dwell and the measured-velocity envelope). Flight log verifiable offline with verify_log.py --replay. Core invariants (zero actuator authority outside RUN, stopping-envelope lower bound, clock monotonicity, standstill-dwell gating, HSR stream-monitor properties) are checked by stdlib property tests over defined input grids (tests/test_gate_invariants.py). Also packaged as a standalone ROS 2 node (qerra_gate_node v0.3.2) with parameterised timing profiles (96 ms simulation, 160 ms for a 10 Hz scanner), built and tested under ROS 2 Jazzy in CI: live DDS topic traffic, dual-protocol reflex integration, Pattern B topic remapping, Nav2-compatible exterior command-interface integration, /odom ingestion and watchdog tests (isolated stubs plus a live DDS /odom publisher), and LaserScan metadata validation. Software-side timing was measured once inside the ros:jazzy container (see Empirical ROS 2 timing and contention); it is an observation, not a bound. The Nav2 exterior tests use a Nav2-compatible command-source harness, not a running Nav2 stack. Current counts: see Running the Tests. Simulation and CI evidence only. |
Layer 1B: QERRA-HSR (hsr/) |
A 3-vector reflex signal (immediate_physical_distress, human_isolation, environmental_hazard_proximity) under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. The Gate acts on it when it is wired in (CRITICAL trips the gate). In the ROS 2 node a pure-function stream monitor (step_hsr_stream), wrapped by the shared pure-Python receiver gate/hsr_receiver.py (ros2/hsr_receiver.py is a compatibility shim), checks packet sequence order, detects frozen frames, and allows a counter rebase only after both at least 5 qualifying control ticks and at least 160 ms of elapsed observation time. Telemetry arrives over UDP (default, used by Webots) or over a ROS topic (hsr_source="topic", in which case no UDP socket is opened). Pure Python, Apache-2.0. (“HSR” here is this project’s own name and is unrelated to Toyota’s Human Support Robot.) |
Built and unit-tested (see Running the Tests). Evaluated in Webots Demos 6, 9 and 10 with a stabilised 1.0 s dwell and Property HSR-5 recovery directives. The stream monitor has edge-case matrix tests and a 159 ms / 160 ms rebase boundary test in the host suite, and the ROS-topic path is exercised by live multi-node tests in the container (dwell, acute distress, frame freeze, staleness). All HSR input in the demonstrations is injected or synthetic. |
| Layer 2: SEMEV-12 | Advisory screening of text task instructions against 12 moral and coercion vectors. MiniLM embeddings with deterministic scoring gates and negation pre-filtering. Not part of the physical safety function. | Built, unit-tested and benchmarked (15 regression cases, 80-case baseline, active adversarial suite). The adversarial benchmark documents known evasion vectors. |
| Layer 3: QERRA-THRIVE | Advisory values ranking for actions that have passed safety and moral screening (pacing, personal space, clear signalling, flora/animal protection). Native PyTrees integration. | Built and unit-tested across human-centered and ecological suites. Heuristic weights; not yet evaluated with human participants. |
Where to start:
- Safety and robotics engineers:
TECHNICAL_BRIEF_ROS2_GATE.md(frozen executive architecture reference and permalink),SAFETY_CONCEPT.md(v0.12),QERRA-HSR-Design-v0.1.md,LIMITATIONS.md,verify_log.py, the ROS 2 Integration section, and the Demo 7, 8, 9 and 10 sections below. - Ethics, human-robot interaction and standards readers: the SEMEV-12 and QERRA-THRIVE sections below,
SEMEV-12_Whitepaper.md,QERRA-THRIVE_framework_documentation.md, and the two benchmark files.
What QERRA Does
QERRA-v2 Classical is an open-source execution guard for autonomous robots and AI systems.
A mobile robot should never rely on an unpredictable neural network to make safety-relevant physical motion decisions. If a complex model lags or hallucinates, a 70 kg machine can crush someone.
QERRA addresses this by splitting safety into three separate, accountable jobs that run in a strict sequence:
-
The Deterministic Gate & Assistive Reflex (Layer 1A & 1B):
-
Layer 1A — The Supervisory Gate (
gate/): Pure-function, standard-library-only integer state machine that decides velocity commands. It evaluates velocity proposals from untrusted planners against a dynamic kinematic stopping envelope ($d_{stop} = \lceil v_{ref}^2 / (2a_{design}) \rceil + \lceil v_{ref} \cdot t_{react} \rceil + margin$, with $a_{design} = 0.5\ \text{m/s}^2$ (500 mm/s$^2$) and $margin = 300\ \text{mm}$; use $v_{ref}$ in mm/s, $a_{design}$ in mm/s$^2$, and $t_{react}$ in seconds (or $t_{react,us} / 10^6$) to obtain millimetres). The reference speed is $v_{ref} = \max(v_{cmd}, v_{meas})$.gate/gate_core.pyderives $v_{meas}$ (chassis_forward_mmps) from the measured wheel speedsmeas_left_urad_sandmeas_right_urad_sthrough differential-drive kinematics: $\lceil (left + right) \cdot wheel_radius_mm / 2{,}000{,}000 \rceil$ when positive, otherwise 0. Pure in-place yaw rotation ($left + right = 0$) therefore evaluates to 0 mm/s forward translation and does not enlarge the forward stopping distance. When measurements are missing, stale or invalid (None), $v_{meas}$ is 0 and $v_{ref}$ falls back to the commanded speed. Reaction time is parameterised: the Webots controller used a 32 ms lockstep allowance ($d_{stop} = 346\ \text{mm}$ at 196 mm/s cruise, 347 mm at 200 mm/s), while the ROS 2 node exposes a 96 ms simulation profile ($d_{stop} = 358\ \text{mm}$ at 196 mm/s, 360 mm at 200 mm/s) and a 160 ms profile for a 10 Hz scanner ($d_{stop} = 371\ \text{mm}$ at 196 mm/s, 372 mm at 200 mm/s). The 96 ms and 160 ms values are engineering estimates, not measured latencies. The gate trips fail-closed on obstacle breach, clock anomalies, invalid sensor scans, proposer stalls ($\ge 150\ \text{ms}$), or, when a flight log is configured, a failed log write orfsync(requirement R-10), and enforces a 1.0 s continuous-clear dwell and a manual operator reset before recovery. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required, defaultFalse;w_standstill_tol_urad_s = 50_000urad/s): when enabled, the calm dwell waits for verified physical standstill from measured wheel speeds. In verified simulation (TIAGo base in Webots R2025a,RUN_1791713619, recorded before the measured-velocity term existed), a commanded cruise was halted with $36\ \text{mm}$ of physical coasting after a trip at 337 mm clearance (standstill at 301 mm). -
Layer 1B — QERRA-HSR Reflex (
hsr/): Pure Python threshold reflex under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. Evaluates distress telemetry, human isolation, and proximity hazards to issue reflex states (CLEAR,MONITOR,CRITICAL) and Property HSR-5 human-in-the-loop recovery directives. The Gate trips onCRITICAL. In the ROS 2 node, incoming telemetry passes through a pure stream monitor (step_hsr_stream, wrapped by the shared receivergate/hsr_receiver.py;ros2/hsr_receiver.pyis a compatibility shim) that checks packet order, detects frozen frames, and presents no valid status ((None, None)) during a fault or a rebase dwell. Withhsr_required=truethe gate core turns that intoTRIP_HSR_INVALID. InMode.RUN,MONITORimposes no velocity cap: the existing 3.0 rad/s (0.294 m/s) envelope holds. While latched inMode.TRIPPEDorMode.AWAITING_RESET,MONITORblocks clear-dwell completion and causes operator reset rejection.
-
Layer 1A — The Supervisory Gate (
-
The Moral Conscience (SEMEV-12): A 12-dimensional ethical filter that evaluates text instructions before the robot moves. If someone orders the robot to do something abusive, deceptive, or coercive (such as forcing a worker through a break or falsifying safety records), the robot refuses the command, illuminates an amber LED, logs the refusal reason, and physically shakes its head “No” in simulation.
- The Social Manners (QERRA-THRIVE): A 12-vector ranker for tasks that are already physically safe and morally clean. It selects the most considerate way to move, such as quiet “whisper mode” in hospital corridors or keeping off garden lawns unless an emergency overrides etiquette.
The decision logic is deterministic, inspectable, and auditable. Every result outputs the exact vectors that triggered, human-readable reasoning, and a concrete recovery directive.
⚖️ Authorship & License
QERRA-v2 Classical is designed and developed by Marussa Metocharaki.
- Open Source License: The entire repository is licensed under the Apache License 2.0.
- Permissive Robotics Architecture: Permissive for chassis-local ROS 2 integration, academic research, and commercial robotics adoption.
-
Original Work & Archival: The core frameworks, vector logic, and scoring architectures are timestamped and permanently archived on Zenodo.
DOI (Zenodo): https://doi.org/10.5281/zenodo.24625489 ORCID: https://orcid.org/0009-0009-4100-9881
Quickstart
Public example endpoint (no API key required):
curl https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/example
Main endpoint (/analyze) requires the public test key:
x-api-key: TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
Full documentation:
https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/docs
Try QERRA in a Behavior Tree — 2 minutes, no ROS 2 required
QERRA-v2 includes a standalone PyTrees Condition node that calls the live API directly over HTTP. No ROS 2 installation, no qerra_msgs package, no build step.
pip install py_trees requests
export QERRA_API_KEY=TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
python test_bt_tick.py --live
This runs a real Behavior Tree against the live two-layer API (SEMEV-12 + QERRA-HSR), showing both a SAFE scenario (ethical check passes, task executes) and a HIGH RISK scenario (ethical check blocks, robot holds and requests human review).
```bash python test_bt_tick.py –live –risk # high risk scenario only python test_bt_tick.py –live –safe # safe scenario only python test_bt_tick.py # offline mock mode, no API call
File truncated at 100 lines see the full file
CONTRIBUTING
Repository Summary
| Description | |
| Checkout URI | https://github.com/marunigno-ship-it/QERRA-v2-classical.git |
| VCS Type | git |
| VCS Version | main |
| Last Updated | 2026-11-30 |
| Dev Status | UNKNOWN |
| Released | UNRELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
| Name | Version |
|---|---|
| qerra_core | 2.5.0 |
README
QERRA-v2 Classical
A fully explainable, classical three-layer pipeline for AI systems and autonomous robots.
Physical safety (Supervisory Gate + QERRA-HSR) → moral filtering (SEMEV-12) → flourishing-ranked choice (QERRA-THRIVE) — 27 named, auditable vectors (3 + 12 + 12), deterministic rule bounds.
The Idea in One Sentence
Values and ethics can screen and rank what a robot wants to do, but only a deterministic gate decides what the wheels do.
The setting this is built for: a transport cobot in a hospital corridor yields and slows near people, and the Gate is intended to command a stop when specified monitored fault conditions are detected. A Gate process or communication failure still requires an independent downstream command timeout or hardware safety function; this prototype does not demonstrate that the robot stops safely by itself after process failure. The system can leave a record a safety officer can audit.
Status in one paragraph. QERRA is a simulation-based research prototype. It is not a certified safety system, it has not been tested on hardware, and a 0.0 wheel command is a software setpoint, not an emergency stop. The deterministic gate (Gate Core v0.5) is demonstrated in Webots and, as a standalone ROS 2 node (
qerra_gate_nodev0.3.2), is built, executed and tested under ROS 2 Jazzy in GitHub Actions (live DDS topic traffic, dual-protocol reflex co-execution, Pattern B topic remapping, Nav2-compatible exterior command-interface tests,/odomingestion tests including a live DDS/odompublisher, and LaserScan metadata validation tests). Package metadata is v2.5.0 (Gate Core v0.5, ROS 2 Node v0.3.2), incorporating the measured-velocity dynamic stopping envelope, standstill-qualified dwell, 10-point LaserScan metadata and REP-117 bounds validation, and empirical ROS 2 Jazzy timing characterization. Current test counts are in Running the Tests, measured timing is in Empirical ROS 2 timing and contention, and the GitHub Actions workflows (tests.ymlandros2_jazzy.yml) are the live source of truth for CI runs. The Pattern B tests exercise a Nav2-compatible external command interface; they do not launch a complete Nav2 stack. The optional standstill-qualified recovery dwell is opt-in, and the archived Webots runs predate it and the measured-velocity stopping envelope. Localhost is an assumed trusted process boundary, and two documented exploit scenarios show what that assumption leaves open. See the frozen Technical Brief and Known limitations.
| Layer | Role | Evidence today |
|---|---|---|
Layer 1A: Supervisory Gate (gate/) |
The component that decides wheel commands. In the Webots controller it is the only process that writes wheel velocities. Pure standard-library integer state machine enforcing a dynamic stopping envelope $d_{stop}(v_{ref})$ with $v_{ref} = \max(v_{cmd}, v_{meas})$, where $v_{meas}$ is the chassis forward speed derived from measured wheel feedback, watchdog liveness (150 ms), and fail-closed latched recovery with operator reset. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required: bool = False, w_standstill_tol_urad_s: int = 50_000 urad/s): when enabled, the 1.0 s calm dwell waits for verified physical standstill from measured wheel speeds, without generating a deceleration trajectory (an open-loop TRIP_BRAKING was intentionally rejected to keep Doer-Checker separation; the Gate commands (0, 0) immediately upon any trip). Both the Webots controller and the ROS 2 node can log every tick to a SHA-256 rolling hash chain, and the node trips fail-closed if a log write fails (requirement R-10). |
Demonstrated in simulation: Demos 7, 8, 9 and 10 (the archived runs predate the standstill-qualified dwell and the measured-velocity envelope). Flight log verifiable offline with verify_log.py --replay. Core invariants (zero actuator authority outside RUN, stopping-envelope lower bound, clock monotonicity, standstill-dwell gating, HSR stream-monitor properties) are checked by stdlib property tests over defined input grids (tests/test_gate_invariants.py). Also packaged as a standalone ROS 2 node (qerra_gate_node v0.3.2) with parameterised timing profiles (96 ms simulation, 160 ms for a 10 Hz scanner), built and tested under ROS 2 Jazzy in CI: live DDS topic traffic, dual-protocol reflex integration, Pattern B topic remapping, Nav2-compatible exterior command-interface integration, /odom ingestion and watchdog tests (isolated stubs plus a live DDS /odom publisher), and LaserScan metadata validation. Software-side timing was measured once inside the ros:jazzy container (see Empirical ROS 2 timing and contention); it is an observation, not a bound. The Nav2 exterior tests use a Nav2-compatible command-source harness, not a running Nav2 stack. Current counts: see Running the Tests. Simulation and CI evidence only. |
Layer 1B: QERRA-HSR (hsr/) |
A 3-vector reflex signal (immediate_physical_distress, human_isolation, environmental_hazard_proximity) under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. The Gate acts on it when it is wired in (CRITICAL trips the gate). In the ROS 2 node a pure-function stream monitor (step_hsr_stream), wrapped by the shared pure-Python receiver gate/hsr_receiver.py (ros2/hsr_receiver.py is a compatibility shim), checks packet sequence order, detects frozen frames, and allows a counter rebase only after both at least 5 qualifying control ticks and at least 160 ms of elapsed observation time. Telemetry arrives over UDP (default, used by Webots) or over a ROS topic (hsr_source="topic", in which case no UDP socket is opened). Pure Python, Apache-2.0. (“HSR” here is this project’s own name and is unrelated to Toyota’s Human Support Robot.) |
Built and unit-tested (see Running the Tests). Evaluated in Webots Demos 6, 9 and 10 with a stabilised 1.0 s dwell and Property HSR-5 recovery directives. The stream monitor has edge-case matrix tests and a 159 ms / 160 ms rebase boundary test in the host suite, and the ROS-topic path is exercised by live multi-node tests in the container (dwell, acute distress, frame freeze, staleness). All HSR input in the demonstrations is injected or synthetic. |
| Layer 2: SEMEV-12 | Advisory screening of text task instructions against 12 moral and coercion vectors. MiniLM embeddings with deterministic scoring gates and negation pre-filtering. Not part of the physical safety function. | Built, unit-tested and benchmarked (15 regression cases, 80-case baseline, active adversarial suite). The adversarial benchmark documents known evasion vectors. |
| Layer 3: QERRA-THRIVE | Advisory values ranking for actions that have passed safety and moral screening (pacing, personal space, clear signalling, flora/animal protection). Native PyTrees integration. | Built and unit-tested across human-centered and ecological suites. Heuristic weights; not yet evaluated with human participants. |
Where to start:
- Safety and robotics engineers:
TECHNICAL_BRIEF_ROS2_GATE.md(frozen executive architecture reference and permalink),SAFETY_CONCEPT.md(v0.12),QERRA-HSR-Design-v0.1.md,LIMITATIONS.md,verify_log.py, the ROS 2 Integration section, and the Demo 7, 8, 9 and 10 sections below. - Ethics, human-robot interaction and standards readers: the SEMEV-12 and QERRA-THRIVE sections below,
SEMEV-12_Whitepaper.md,QERRA-THRIVE_framework_documentation.md, and the two benchmark files.
What QERRA Does
QERRA-v2 Classical is an open-source execution guard for autonomous robots and AI systems.
A mobile robot should never rely on an unpredictable neural network to make safety-relevant physical motion decisions. If a complex model lags or hallucinates, a 70 kg machine can crush someone.
QERRA addresses this by splitting safety into three separate, accountable jobs that run in a strict sequence:
-
The Deterministic Gate & Assistive Reflex (Layer 1A & 1B):
-
Layer 1A — The Supervisory Gate (
gate/): Pure-function, standard-library-only integer state machine that decides velocity commands. It evaluates velocity proposals from untrusted planners against a dynamic kinematic stopping envelope ($d_{stop} = \lceil v_{ref}^2 / (2a_{design}) \rceil + \lceil v_{ref} \cdot t_{react} \rceil + margin$, with $a_{design} = 0.5\ \text{m/s}^2$ (500 mm/s$^2$) and $margin = 300\ \text{mm}$; use $v_{ref}$ in mm/s, $a_{design}$ in mm/s$^2$, and $t_{react}$ in seconds (or $t_{react,us} / 10^6$) to obtain millimetres). The reference speed is $v_{ref} = \max(v_{cmd}, v_{meas})$.gate/gate_core.pyderives $v_{meas}$ (chassis_forward_mmps) from the measured wheel speedsmeas_left_urad_sandmeas_right_urad_sthrough differential-drive kinematics: $\lceil (left + right) \cdot wheel_radius_mm / 2{,}000{,}000 \rceil$ when positive, otherwise 0. Pure in-place yaw rotation ($left + right = 0$) therefore evaluates to 0 mm/s forward translation and does not enlarge the forward stopping distance. When measurements are missing, stale or invalid (None), $v_{meas}$ is 0 and $v_{ref}$ falls back to the commanded speed. Reaction time is parameterised: the Webots controller used a 32 ms lockstep allowance ($d_{stop} = 346\ \text{mm}$ at 196 mm/s cruise, 347 mm at 200 mm/s), while the ROS 2 node exposes a 96 ms simulation profile ($d_{stop} = 358\ \text{mm}$ at 196 mm/s, 360 mm at 200 mm/s) and a 160 ms profile for a 10 Hz scanner ($d_{stop} = 371\ \text{mm}$ at 196 mm/s, 372 mm at 200 mm/s). The 96 ms and 160 ms values are engineering estimates, not measured latencies. The gate trips fail-closed on obstacle breach, clock anomalies, invalid sensor scans, proposer stalls ($\ge 150\ \text{ms}$), or, when a flight log is configured, a failed log write orfsync(requirement R-10), and enforces a 1.0 s continuous-clear dwell and a manual operator reset before recovery. Gate Core v0.5 adds an optional standstill-qualified recovery dwell (standstill_required, defaultFalse;w_standstill_tol_urad_s = 50_000urad/s): when enabled, the calm dwell waits for verified physical standstill from measured wheel speeds. In verified simulation (TIAGo base in Webots R2025a,RUN_1791713619, recorded before the measured-velocity term existed), a commanded cruise was halted with $36\ \text{mm}$ of physical coasting after a trip at 337 mm clearance (standstill at 301 mm). -
Layer 1B — QERRA-HSR Reflex (
hsr/): Pure Python threshold reflex under ISO 13482 as an informative design reference for assistive and healthcare mobile cobots. Evaluates distress telemetry, human isolation, and proximity hazards to issue reflex states (CLEAR,MONITOR,CRITICAL) and Property HSR-5 human-in-the-loop recovery directives. The Gate trips onCRITICAL. In the ROS 2 node, incoming telemetry passes through a pure stream monitor (step_hsr_stream, wrapped by the shared receivergate/hsr_receiver.py;ros2/hsr_receiver.pyis a compatibility shim) that checks packet order, detects frozen frames, and presents no valid status ((None, None)) during a fault or a rebase dwell. Withhsr_required=truethe gate core turns that intoTRIP_HSR_INVALID. InMode.RUN,MONITORimposes no velocity cap: the existing 3.0 rad/s (0.294 m/s) envelope holds. While latched inMode.TRIPPEDorMode.AWAITING_RESET,MONITORblocks clear-dwell completion and causes operator reset rejection.
-
Layer 1A — The Supervisory Gate (
-
The Moral Conscience (SEMEV-12): A 12-dimensional ethical filter that evaluates text instructions before the robot moves. If someone orders the robot to do something abusive, deceptive, or coercive (such as forcing a worker through a break or falsifying safety records), the robot refuses the command, illuminates an amber LED, logs the refusal reason, and physically shakes its head “No” in simulation.
- The Social Manners (QERRA-THRIVE): A 12-vector ranker for tasks that are already physically safe and morally clean. It selects the most considerate way to move, such as quiet “whisper mode” in hospital corridors or keeping off garden lawns unless an emergency overrides etiquette.
The decision logic is deterministic, inspectable, and auditable. Every result outputs the exact vectors that triggered, human-readable reasoning, and a concrete recovery directive.
⚖️ Authorship & License
QERRA-v2 Classical is designed and developed by Marussa Metocharaki.
- Open Source License: The entire repository is licensed under the Apache License 2.0.
- Permissive Robotics Architecture: Permissive for chassis-local ROS 2 integration, academic research, and commercial robotics adoption.
-
Original Work & Archival: The core frameworks, vector logic, and scoring architectures are timestamped and permanently archived on Zenodo.
DOI (Zenodo): https://doi.org/10.5281/zenodo.24625489 ORCID: https://orcid.org/0009-0009-4100-9881
Quickstart
Public example endpoint (no API key required):
curl https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/example
Main endpoint (/analyze) requires the public test key:
x-api-key: TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
Full documentation:
https://qerra-v2-api-classical-qerra-v2-api-classical.hf.space/docs
Try QERRA in a Behavior Tree — 2 minutes, no ROS 2 required
QERRA-v2 includes a standalone PyTrees Condition node that calls the live API directly over HTTP. No ROS 2 installation, no qerra_msgs package, no build step.
pip install py_trees requests
export QERRA_API_KEY=TEST-2026-QERRA-CLASSICAL-PUBLIC-KEY-98765
python test_bt_tick.py --live
This runs a real Behavior Tree against the live two-layer API (SEMEV-12 + QERRA-HSR), showing both a SAFE scenario (ethical check passes, task executes) and a HIGH RISK scenario (ethical check blocks, robot holds and requests human review).
```bash python test_bt_tick.py –live –risk # high risk scenario only python test_bt_tick.py –live –safe # safe scenario only python test_bt_tick.py # offline mock mode, no API call
File truncated at 100 lines see the full file