NFR Verification¶
What this document covers
This page documents the non-functional requirement (NFR) test
suite, a self-contained set of pytest checks that measure the
quantified quality requirements from
SRS.md §3.3 against the real recognizer, mapping
tables, auth settings, drone adapters, adapter interfaces and health
endpoints.
Each test writes a machine-generated JSON artefact to
docs/nfr/evidence/, and report.py
turns those artefacts into the traceability matrix
at the bottom of this page. The Actual column is never typed by
hand; it comes straight from a measured run.
1. Design Principles¶
The suite is deliberately narrow and cheap so it can run on every CI job without a camera, a simulator, a FastAPI app or a database.
- Add-only. The tests import the real production symbols
(
RuleBasedRecognizer,GestureAdapter,TokenService,DummyDroneAdapter,DroneAdapter,InputAdapter, and so on) but change no existing code. They verify behaviour; they do not alter it. - Pure Python. No webcam, no ASGI app, no background tasks, so the suite is fast and CI-safe on a headless runner.
- Evidence over assertion. Every test emits a JSON artefact with the measured value, the target, the machine it ran on and a UTC timestamp. The pass/fail in the matrix is derived from that artefact, so the document can never drift from the code.
2. What Each Requirement Covers¶
The suite maps to several SRS quality-requirement groups. Requirement IDs
(QR-nn) are the test-suite's own identifiers; the SRS column ties
each back to the quantified requirement in
SRS.md §3.3.
| Group | Covered by | Focus |
|---|---|---|
| NFR1 Performance | test_latency.py, test_realtime_robustness.py |
Recognition latency, bounded-queue back-pressure |
| NFR2 Security | test_security.py, test_token_validation.py, test_password_security.py |
Token lifetime, token rejection, credential handling |
| NFR3 Reliability | test_accuracy.py, test_command_mapping.py, test_realtime_robustness.py, test_safety.py |
Accuracy, confidence-gated mapping, noise suppression, fail-safe |
| NFR6 Maintainability | test_maintainability.py |
Adapter-interface conformance, code complexity |
| NFR7 Availability | test_availability.py |
Liveness probes, unauthenticated health access |
2.1 Performance¶
- QR-03 → NFR1.1 times single-frame recognition over the committed landmark dataset and reports the p95. The SRS bounds the full frame-to-dispatch path at 200 ms; this isolates the recognition stage and holds it to a tighter internal budget, leaving headroom for detection and I/O in the end-to-end measurement (deferred to Demo 3).
- QR-18 → NFR1.2 pushes 100 frames through
BoundedFrameQueue(size 2) and asserts the queue never exceeds its bound and drops the oldest frame under load, rather than blocking or growing without limit.
2.2 Security¶
- QR-07 → NFR2.1 reads the real access-token lifetime and asserts it is within the 30-minute bound.
- QR-12 → NFR2.1 is the behavioural companion to QR-07: it mints
tokens with
TokenServiceand asserts that expired, wrong-signature, wrong-audience and wrong-issuer tokens are all rejected, while a legitimate token validates. This proves the token is enforced, not just short-lived. - QR-08 / QR-09 / QR-10 → NFR2.2 cover credential handling: the bcrypt work factor is at or above the configured floor, the password-strength policy rejects every weak-password class, and identical passwords hash to distinct salted digests.
2.3 Reliability¶
- QR-01 / QR-02 → NFR3.1 run the recognizer over the labelled dataset and report overall and lowest per-gesture accuracy against the 95 % target. See the note below on which recognizer gates.
- QR-04 / QR-05 / QR-06 → NFR3.2 verify that every single-hand gesture and two-hand combination resolves to the expected command, and that the confidence gate sits at or above 0.85 (false-positive suppression).
- QR-19 → NFR3.2 confirms the
GestureStabilizerrejects a single spurious frame but still switches once a new gesture is held long enough. - QR-13 → NFR3.3 covers fail-safe:
EMERGENCY_STOPis always elevated to critical priority (and nothing else is), andemergency_stop()clears the flying state on the adapter.
2.4 Maintainability¶
- QR-20 / QR-21 → NFR6.1 verify that every concrete adapter fully
implements its interface. Each
DroneAdapterandInputAdaptersubclass is checked for unimplemented abstract methods; a half-implemented adapter cannot instantiate at runtime, so this catches a latent crash statically. Adapters that depend on optional hardware libraries are reported as skipped rather than failing the check. - QR-22 → NFR6.2 scans every function in
services/withradonand asserts none exceeds a cyclomatic-complexity budget of 15, so branching stays within a bound that keeps a function easy to change safely.
2.5 Availability¶
Genuine availability, uptime over days, can only be measured by an
external monitor polling a health endpoint continuously; that belongs in
the deployment and is cited from the monitor's own dashboard in
SAS.md. These tests verify the precondition for that
monitoring, using the live FastAPI schema without starting a server.
- QR-23 → NFR7.1 asserts that every major subsystem (core, auth, drone, gestures) exposes a liveness probe.
- QR-24 → NFR7.2 asserts those probes require no authentication, so an uptime monitor, which cannot log in, can actually reach them.
Two recognizers, one gated
The system ships two recognizers behind the same interface. The
rule-based recognizer is deterministic and zero-latency but has a
known accuracy ceiling (~56 % on this dataset), traced to a
finger-count bug in _is_thumb_up. The ML recognizer is the
engine responsible for accuracy. Confirm which recognizer QR-01/QR-02
assert against in test_accuracy.py and make sure the gate and this
note agree with the committed run, so the matrix never claims a pass
the suite does not produce.
3. Running the Suite¶
From the repository root:
That runs the NFR tests and regenerates the matrix. It is also included
in the full task test run. To invoke the steps directly:
The suite is a real gate
Every gating row is expected to pass, so task nfr-test exits
non-zero only on a genuine regression, which makes it safe to run as
a merge gate in CI. The matrix is regenerated on the same run, so a
passing build always publishes an up-to-date matrix.
Extra dependency
The complexity check (QR-22) needs radon. Add it to the dev group
with uv add --dev radon; without it, that one check is skipped
rather than failing.
4. Regenerating the Matrix¶
tests/nfr/report.py reads every docs/nfr/evidence/*.json artefact and
writes docs/nfr/MATRIX.md. The Actual column is generated here,
never edited by hand. The table below is that generated file, included
verbatim so this page always reflects the last measured run.
5. Traceability Matrix¶
NFR Traceability Matrix¶
Generated by tests/nfr/report.py from docs/nfr/evidence/. Do not edit by hand.
Every row links to its full evidence (method, raw numbers, chart) on the evidence page.
50 requirements: 46 pass, 0 fail, 2 pending, 1 informational, 1 not measured.
NFR1 Performance¶
| ID | Result | SRS | Requirement | Actual | Target | Tactic | Test |
|---|---|---|---|---|---|---|---|
| QR-03 | PASS | NFR1.1 | Recognition p95 < 50 ms (rule) | 0.0038 | < 50.0 | Pure-geometry classifier | test_latency.py |
| QR-25 | PASS | NFR1.1 | Recognition p95 < 50 ms (ML) | 0.1009 | < 50.0 | 63-feature MLP | test_latency.py |
| QR-26 | PASS | NFR1.1 | Hand detection p95 <= 100 ms, live | 14.393 | <= 100.0 | MediaPipe lite model | test_realtime_performance.py |
| QR-27 | PASS | NFR1.1 | Frame serialization p95 <= 20 ms | 1.129 | <= 20.0 | Encode once, fan out | test_latency.py |
| QR-28 | PASS | NFR1.1 | Resolve + dispatch p95 <= 30 ms | 0.0103 | <= 30.0 | Dict command maps | test_latency.py |
| QR-29 | PASS | NFR1.1 | Frame -> drone command p95 <= 200 ms | 15.925 | <= 200.0 | Bounded queue, one consumer | test_realtime_performance.py |
| QR-30 | PASS | NFR1.1 | Gesture onset -> command p95 <= 200 ms | 115.728 | <= 200.0, no missed gestures | 3-of-5 vote + 2-frame hold | test_realtime_performance.py |
| QR-35 | PASS | NFR1.1 | REST p95 <= 100 ms, 10 clients | 12.033 | <= 100.0, 0 errors | Async FastAPI | test_backend_performance.py |
| QR-37 | PASS | NFR1.1 | Command round trip p95 <= 100 ms | 1.016 | <= 100.0 | Persistent WebSocket | test_backend_performance.py |
| QR-38 | PASS | NFR1.1 | Login p95 <= 1 s | 516.477 | <= 1000.0 | bcrypt cost 13 | test_backend_performance.py |
| QR-40 | PASS | NFR1.1 | Analytics query p95 <= 250 ms | 3.545 | <= 250.0 | Aggregates in SQL | test_backend_performance.py |
| QR-41 | PASS | NFR1.1 | Cold start <= 10 s, first frame <= 3 s | 1.33 | <= 10.0 s; first gesture frame <= 3.0 s | Lazy camera start | test_resources.py |
| QR-51 | PASS | NFR1.1 | Every screen LCP <= 2.5 s | 812 | LCP <= 2500, FCP <= 1800 on every screen | Static production bundle | performance.nfr.spec.ts |
| QR-52 | PASS | NFR1.1 | Click -> command confirmed <= 200 ms | 53.7 | <= 200, every click confirmed | WS ack + history | performance.nfr.spec.ts |
| QR-18 | PASS | NFR1.2 | Pipeline stays bounded under load | 2 | <= 2 | Drop-oldest frame queue | test_realtime_robustness.py |
| QR-32 | PASS | NFR1.2 | CPU <= 70 % at 30 fps | 6.7 | <= 70.0 | Lite model, JPEG once | test_realtime_performance.py |
| QR-33 | PASS | NFR1.2 | Frames dropped <= 1 % at 30 fps | 0.0 | <= 1.0 | Consumer keeps pace | test_realtime_performance.py |
| QR-42 | PASS | NFR1.2 | No per-frame memory growth | 27.6 | <= 1024 | Bounded buffers | test_resources.py |
| QR-34 | PASS | NFR1.3 | Every client >= 24 fps (+1 stalled) | 30.0 | >= 24.0 | Per-client 1-slot queues | test_realtime_performance.py |
| QR-36 | PASS | NFR1.3 | Telemetry >= 9 Hz | 9.79 | >= 9.0 Hz, p95 gap <= 150.0 ms | 100 ms push loop | test_backend_performance.py |
| QR-39 | PASS | NFR1.3 | Telemetry write p95 <= 50 ms | 0.861 | <= 50.0 | Write every 10th tick | test_backend_performance.py |
| QR-50 | PASS | NFR1.3 | Dashboard renders >= 24 fps | 30 | >= 24 fps and >= 99% of received frames painted | Canvas + ImageBitmap | performance.nfr.spec.ts |
NFR2 Security¶
| ID | Result | SRS | Requirement | Actual | Target | Tactic | Test |
|---|---|---|---|---|---|---|---|
| QR-07 | PASS | NFR2.1 | Session token <= 30 min | 15 | <= 30 | Short-lived JWT | test_security.py |
| QR-12 | PASS | NFR2.1 | Invalid tokens rejected | 5/5 | all rejected | JWT exp/aud/iss/sig checks | test_token_validation.py |
| QR-08 | PASS | NFR2.2 | Password hash cost >= 12 rounds | 13 | >= 12 | Configurable bcrypt rounds | test_password_security.py |
| QR-09 | PASS | NFR2.2 | Weak passwords rejected | 5/5 | all rejected | Strength policy regexes | test_password_security.py |
| QR-10 | PASS | NFR2.2 | Password hashes salted | distinct | distinct | bcrypt gensalt | test_password_security.py |
NFR3 Reliability¶
| ID | Result | SRS | Requirement | Actual | Target | Tactic | Test |
|---|---|---|---|---|---|---|---|
| QR-01 | PASS | NFR3.1 | Gesture accuracy >= 95% (ML) | 99.71 | >= 95.0 | ML recognizer (MLP) | test_accuracy.py |
| QR-02 | PASS | NFR3.1 | Every gesture >= 95% (ML) | 99.0 | >= 95.0 | ML recognizer (MLP) | test_accuracy.py |
| QR-01-rule | INFO | NFR3.1 | Rule-based accuracy (informational) | 55.9 | informational (ML is the gated engine) | Rule-based ceiling | test_accuracy.py |
| QR-06 | PASS | NFR3.2 | Confidence gate >= 0.85 | 0.85 | >= 0.85 | MIN_CONFIDENCE filter | test_command_mapping.py |
| QR-19 | PASS | NFR3.2 | Single-frame noise suppressed | rejected | rejected | GestureStabilizer voting | test_realtime_robustness.py |
| QR-04 | PASS | NFR3.2 | All single-hand gestures mapped | 3/3 | all mapped | SINGLE_HAND_MAP | test_command_mapping.py |
| QR-05 | PASS | NFR3.2 | All two-hand combos resolve | 9/9 | all resolve | Two-hand maps + _resolve | test_command_mapping.py |
| QR-13 | PASS | NFR3.3 | E-stop always critical priority | 999 | == 999 | Command priority elevation | test_safety.py |
| QR-14 | PASS | NFR3.3 | E-stop grounds the drone | grounded | grounded | Adapter emergency_stop | test_safety.py |
NFR5 Usability¶
| ID | Result | SRS | Requirement | Actual | Target | Tactic | Test |
|---|---|---|---|---|---|---|---|
| QR-44 | PASS | NFR5.1 | Predicted first flight <= 5 min (KLM) | 219.8 | <= 300.0 | Keystroke-Level Model | test_usability.py |
| QR-45 | PENDING | NFR5.1 | >= 80% fly within 5 min (study) | 0/5 participants logged | >= 80.0% of >= 5 external participants | Moderated usability study | test_usability.py |
| QR-56 | PASS | NFR5.1 | Basic flight <= 6 confirmed clicks | 5 | <= 6 clicks, each confirmed within 1 s, drone landed | On-screen flight pad | usability.nfr.spec.ts |
| QR-46 | PENDING | NFR5.2 | Mean SUS >= 85, >= 5 external users | 0/5 participants logged | >= 85.0 with >= 5 external participants | System Usability Scale | test_usability.py |
| QR-55 | PASS | R1.1.2 | Gesture + command visible, no scrolling | 3/3 | 3/3, no sideways scrolling at 1024 px | Dashboard layout | usability.nfr.spec.ts |
| QR-49 | PASS | R1.1.2 | One history entry per held gesture | 2 | 2 (one per hold) | Transition-only event log | test_usability.py |
| QR-48 | PASS | R7 / US-A-02 | Keyboard + gamepad reach every command | keyboard 12/12, gamepad 12/12 | all, including EMERGENCY_STOP | Shared Command vocabulary | test_usability.py |
| QR-53 | PASS | U3 / WCAG 4.1.2 | Every control has an accessible name | 100 | 100 | Labelled controls | usability.nfr.spec.ts |
| QR-54 | PASS | U3 / WCAG 2.4.7 | Keyboard focus always visible | 100 | 100 | Focus styles | usability.nfr.spec.ts |
NFR6 Maintainability¶
| ID | Result | SRS | Requirement | Actual | Target | Tactic | Test |
|---|---|---|---|---|---|---|---|
| QR-20 | PASS | NFR6.1 | Drone adapters implement interface | 4/4 loaded | all loaded adapters complete | DroneAdapter ABC | test_maintainabiility.py |
| QR-21 | PASS | NFR6.1 | Input adapters implement interface | 4/4 loaded | all loaded adapters complete | InputAdapter ABC | test_maintainabiility.py |
| QR-22 | MISSING | NFR6.2 | No function above complexity 15 | not measured | - | Small functions | test_maintainabiility.py |
NFR7 Availability¶
| ID | Result | SRS | Requirement | Actual | Target | Tactic | Test |
|---|---|---|---|---|---|---|---|
| QR-23 | PASS | NFR7.1 | Every subsystem has a liveness probe | 4/4 | all present | /health per router | test_availability.py |
| QR-24 | PASS | NFR7.2 | Health probes need no auth | 4/4 | all unauthenticated | Open health routes | test_availability.py |
6. References¶
SRS.md§3.3, the quantified quality requirements these tests verify.POLICY.md, what the tests must achieve.testing/TESTING.md, how the wider suite is run and structured.SAS.md, the architectural decisions that realise each quality requirement, including the external availability monitor.
Tooling¶
Industry-standard tools are used where they apply:
- Lighthouse (
task nfr-lighthouse) — Core Web Vitals and accessibility scores per screen, corroborating QR-51 and QR-53/54. - Apache JMeter (
task nfr-jmeter) — concurrent REST load against the running backend, corroborating QR-35.
Neither tool can instrument the real-time gesture pipeline, which is where
most of this system's quality requirements live: frame-to-command latency,
dropped frames, hand-detection cost, WebSocket fan-out and two-hand command
resolution. Those are measured by the purpose-built harness in tests/nfr/,
which exercises the production code path with only the camera and the hand
detector substituted (tests/nfr/_perf.py).