# Traceability Matrix: Software Requirements to Components

**Document ID:** TM-SWR-COMP  
**Version:** 1.0  
**Date:** 2025-02-01  

## 1. Purpose

This document provides a comprehensive traceability matrix mapping software requirements to the software components that implement them. This ensures that every software requirement is implemented by at least one component and that component responsibilities are clearly defined.

## 2. Traceability Matrix

| Software Requirement ID | Requirement Description | Implementing Component(s) | Verification Method |
|-------------------------|------------------------|---------------------------|-------------------|
| **Sensor Data Acquisition Requirements** |
| SWR-DAQ-001 | System shall support multi-sensor data acquisition | Sensor Manager | Unit Test |
| SWR-DAQ-002 | System shall provide sensor driver abstraction | Sensor Drivers (Temperature, Humidity, CO2, NH3, VOC, Light) | Integration Test |
| SWR-DAQ-003 | System shall acquire data only from detected sensors | Sensor Manager, Sensor Detector | Unit Test |
| SWR-DAQ-004 | System shall perform high-frequency sampling | Sensor Manager, Sensor Drivers | Unit Test |
| SWR-DAQ-005 | System shall apply local filtering to sensor data | Sensor Manager, Filter Engine | Unit Test |
| SWR-DAQ-006 | System shall support configurable sampling parameters | Sensor Manager, Machine Constants Manager | Integration Test |
| SWR-DAQ-007 | System shall associate timestamps with sensor data | Sensor Manager, Time Service | Unit Test |
| SWR-DAQ-008 | System shall generate timestamps after filtering | Sensor Manager | Unit Test |
| SWR-DAQ-009 | System shall create structured sensor data records | Sensor Manager, Data Pool | Integration Test |
| SWR-DAQ-010 | System shall complete acquisition within 100ms per sensor | Sensor Manager | Performance Test |
| SWR-DAQ-011 | System shall track sensor operational states | Sensor Manager, Sensor State Machine | State Machine Test |
| SWR-DAQ-012 | System shall include validity flags with sensor data | Sensor Manager | Unit Test |
| SWR-DAQ-013 | System shall enforce sensor warmup periods | Sensor Drivers, Sensor Manager | Integration Test |
| **Communication Requirements** |
| SWR-COM-001 | System shall support MQTT over TLS communication | Communication Manager, MQTT Client, TLS Handler | Integration Test |
| SWR-COM-002 | System shall transmit sensor data to Main Hub | Communication Manager, Main Hub APIs | Unit Test |
| SWR-COM-003 | System shall receive commands from Main Hub | Communication Manager, Command Handler | Integration Test |
| SWR-COM-004 | System shall monitor communication link status | Communication Manager, Connection Monitor | Unit Test |
| SWR-COM-005 | System shall support on-demand data requests | Communication Manager, Data Pool | Performance Test |
| SWR-COM-006 | System shall respond within 100ms to data requests | Communication Manager | Integration Test |
| SWR-COM-007 | System shall include validity info in responses | Communication Manager, Data Pool | Unit Test |
| SWR-COM-008 | System shall support ESP-NOW peer communication | ESP-NOW Handler, Communication Manager | Unit Test |
| SWR-COM-009 | System shall support peer coordination functions | ESP-NOW Handler | Integration Test |
| SWR-COM-010 | System shall isolate peer from main hub communication | Communication Manager | Unit Test |
| SWR-COM-011 | System shall implement heartbeat mechanism | Communication Manager, MQTT Client | Unit Test |
| SWR-COM-012 | System shall use CBOR encoding for payloads | Communication Manager, Message Formatter | Unit Test |
| SWR-COM-013 | System shall support automatic reconnection | Communication Manager, Connection Manager | Integration Test |
| SWR-COM-014 | System shall encrypt ESP-NOW peer communication | ESP-NOW Handler, Crypto Manager | Security Test |
| SWR-COM-015 | System shall implement ESP-NOW acknowledgment | ESP-NOW Handler | Unit Test |
| **Data Persistence Requirements** |
| SWR-DATA-001 | System shall persist sensor data in non-volatile storage | Persistence Manager, Data Pool | Integration Test |
| SWR-DATA-002 | System shall store sensor data with metadata | Data Pool, Storage Abstraction | Unit Test |
| SWR-DATA-003 | System shall support configurable retention policies | Persistence Manager, Configuration Manager | Unit Test |
| SWR-DATA-004 | System shall provide DP component as storage interface | Data Pool, Storage Abstraction | Unit Test |
| SWR-DATA-005 | System shall prevent direct storage hardware access | Storage Abstraction, Access Control | Unit Test |
| SWR-DATA-006 | System shall support data serialization | Persistence Manager, Data Serializer | Unit Test |
| SWR-DATA-007 | System shall flush data before state transitions | Persistence Manager, System State Manager | Integration Test |
| SWR-DATA-008 | System shall protect data integrity during updates | Persistence Manager, Data Integrity Checker | Unit Test |
| SWR-DATA-009 | System shall verify data persistence success | Storage Abstraction, Persistence Manager | Unit Test |
| SWR-DATA-010 | System shall detect brownout conditions | Power Monitor, Brownout Detector | Hardware Test |
| SWR-DATA-011 | System shall flush critical data on brownout | Persistence Manager, Emergency Handler | Hardware Test |
| SWR-DATA-012 | System shall complete emergency flush within 1-2s | Persistence Manager, Fast Writer | Performance Test |
| SWR-DATA-013 | System shall implement wear-aware writing | Storage Abstraction, Wear Leveling Manager | Unit Test |
| **Diagnostics Requirements** |
| SWR-DIAG-001 | System shall implement diagnostic code framework | Diagnostics Manager, Diagnostic Collector | Unit Test |
| SWR-DIAG-002 | System shall assign unique diagnostic codes | Diagnostic Collector, Code Registry | Unit Test |
| SWR-DIAG-003 | System shall classify diagnostics by severity | Diagnostics Manager, Severity Classifier | Unit Test |
| SWR-DIAG-004 | System shall timestamp diagnostic events | Diagnostic Collector, Time Service | Unit Test |
| SWR-DIAG-005 | System shall persist diagnostic events | Diagnostic Logger, Persistence Manager | Integration Test |
| SWR-DIAG-006 | System shall retain diagnostics across resets | Diagnostic Logger, Storage Abstraction | Unit Test |
| SWR-DIAG-007 | System shall implement bounded diagnostic storage | Diagnostic Logger, Storage Manager | Unit Test |
| SWR-DIAG-008 | System shall provide diagnostic session interface | Diagnostic Session, Session Manager | Integration Test |
| SWR-DIAG-009 | System shall allow diagnostic data retrieval | Diagnostic Session, Diagnostic Logger | Unit Test |
| SWR-DIAG-010 | System shall allow diagnostic record clearing | Diagnostic Session, Diagnostic Logger | Unit Test |
| SWR-DIAG-011 | System shall not interfere with normal operations | Diagnostic Session, System Controller | Unit Test |
| SWR-DIAG-012 | System shall implement Task Watchdog | Watchdog Manager, Task Watchdog | Hardware Test |
| SWR-DIAG-013 | System shall implement Interrupt Watchdog | Watchdog Manager, Interrupt Watchdog | Hardware Test |
| SWR-DIAG-014 | System shall implement RTC Watchdog | Watchdog Manager, RTC Watchdog | Hardware Test |
| **System Management Requirements** |
| SWR-SYS-001 | System shall implement finite state machine | System State Manager, State Machine | Unit Test |
| SWR-SYS-002 | System shall restrict operations by state | System State Manager, Operation Controller | Unit Test |
| SWR-SYS-003 | System shall notify components of state changes | System State Manager, Event System | Integration Test |
| SWR-SYS-004 | System shall execute controlled teardown | Teardown Manager, System State Manager | Integration Test |
| SWR-SYS-005 | System shall persist critical data before teardown | Teardown Manager, Persistence Manager | Unit Test |
| SWR-SYS-006 | System shall prevent data corruption during teardown | Teardown Manager, Data Integrity Manager | Unit Test |
| SWR-SYS-007 | System shall provide OLED display interface | HMI Controller, OLED Driver | Hardware Test |
| SWR-SYS-008 | System shall display system status information | HMI Controller, Display Manager | Integration Test |
| SWR-SYS-009 | System shall provide button navigation | HMI Controller, Button Handler | Unit Test |
| SWR-SYS-010 | System shall provide menu-based information access | Menu System, HMI Controller | Unit Test |
| SWR-SYS-011 | System shall support diagnostic sessions | Engineering Session, Diagnostic Session | Integration Test |
| SWR-SYS-012 | System shall support debug sessions | Engineering Session, Debug Controller | Unit Test |
| SWR-SYS-013 | System shall restrict debug access to authorized users | Engineering Session, Security Manager | Security Test |
| SWR-SYS-014 | System shall enforce GPIO discipline | GPIO Manager, Hardware Abstraction | Hardware Test |
| SWR-SYS-015 | System shall ensure I2C pull-up resistors | GPIO Manager, I2C Controller | Hardware Test |
| SWR-SYS-016 | System shall use ADC1 when Wi-Fi active | GPIO Manager, ADC Controller | Hardware Test |
| SWR-SYS-017 | System shall maintain GPIO map documentation | GPIO Manager, Documentation System | Documentation Review |
| **Data Quality & Calibration Requirements** |
| SWR-DQC-001 | System shall detect sensor presence | Sensor Detector, Hardware Interface | Hardware Test |
| SWR-DQC-002 | System shall perform detection during startup | Sensor Detector, System Controller | Unit Test |
| SWR-DQC-003 | System shall initialize only detected sensors | Sensor Manager, Sensor Detector | Integration Test |
| SWR-DQC-004 | System shall assign sensors to predefined slots | Sensor Type Enforcer, Configuration Manager | Unit Test |
| SWR-DQC-005 | System shall verify sensor-slot compatibility | Sensor Type Enforcer, Sensor Validator | Unit Test |
| SWR-DQC-006 | System shall report sensor-slot mismatches | Sensor Type Enforcer, Diagnostics Manager | Integration Test |
| SWR-DQC-007 | System shall monitor sensor responsiveness | Sensor Failure Detector, Health Monitor | Unit Test |
| SWR-DQC-008 | System shall detect sensor failures | Sensor Failure Detector, Sensor Monitor | Unit Test |
| SWR-DQC-009 | System shall exclude failed sensors from reporting | Sensor Manager, Sensor Failure Detector | Integration Test |
| SWR-DQC-010 | System shall report sensor failures to Main Hub | Sensor Failure Detector, Communication Manager | Unit Test |
| SWR-DQC-011 | System shall maintain Machine Constants dataset | Machine Constants Manager, Configuration Storage | Unit Test |
| SWR-DQC-012 | System shall persist Machine Constants | Machine Constants Manager, Persistence Manager | Integration Test |
| SWR-DQC-013 | System shall load Machine Constants at startup | Machine Constants Manager, System Controller | Unit Test |
| SWR-DQC-014 | System shall support remote MC updates | Machine Constants Manager, Communication Manager | Integration Test |
| SWR-DQC-015 | System shall apply MC updates via teardown | Machine Constants Manager, Teardown Manager | Integration Test |
| SWR-DQC-016 | System shall support redundant sensors | Redundant Sensor Manager, Sensor Manager | Unit Test |
| SWR-DQC-017 | System shall implement sensor fusion | Sensor Fusion Engine, Redundant Sensor Manager | Unit Test |
| SWR-DQC-018 | System shall ensure critical parameter redundancy | Redundant Sensor Manager, Configuration Manager | Integration Test |
| **OTA Requirements** |
| SWR-OTA-001 | System shall support OTA update negotiation | Update Negotiator, OTA Manager | Integration Test |
| SWR-OTA-002 | System shall verify readiness before OTA | Update Negotiator, System State Manager | Unit Test |
| SWR-OTA-003 | System shall acknowledge/reject OTA requests | OTA Manager, Communication Manager | Unit Test |
| SWR-OTA-004 | System shall receive firmware over secure channel | Firmware Receiver, Communication Manager | Integration Test |
| SWR-OTA-005 | System shall store firmware before validation | Firmware Storage, Storage Abstraction | Unit Test |
| SWR-OTA-006 | System shall prevent active firmware overwrite | Partition Manager, OTA Manager | Unit Test |
| SWR-OTA-007 | System shall validate firmware integrity | Integrity Validator, Crypto Manager | Unit Test |
| SWR-OTA-008 | System shall reject invalid firmware | Integrity Validator, OTA Manager | Security Test |
| SWR-OTA-009 | System shall report validation results | OTA Manager, Communication Manager | Integration Test |
| SWR-OTA-010 | System shall execute teardown before activation | Firmware Activator, Teardown Manager | Integration Test |
| SWR-OTA-011 | System shall persist critical data before flashing | Firmware Activator, Persistence Manager | Unit Test |
| SWR-OTA-012 | System shall activate only validated firmware | Firmware Activator, Integrity Validator | Unit Test |
| SWR-OTA-013 | System shall reboot into new firmware | Firmware Activator, Boot Controller | Integration Test |
| SWR-OTA-014 | System shall implement A/B partitioning | Partition Manager, Boot Controller | Hardware Test |
| SWR-OTA-015 | System shall support automatic rollback | Rollback Manager, Partition Manager | Integration Test |
| SWR-OTA-016 | System shall report rollback events | Rollback Manager, Communication Manager | Unit Test |
| **Security Requirements** |
| SWR-SEC-001 | System shall verify firmware authenticity at boot | Secure Boot Controller, Boot Validator | Hardware Test |
| SWR-SEC-002 | System shall prevent execution of invalid firmware | Secure Boot Controller, Security Manager | Security Test |
| SWR-SEC-003 | System shall enter boot failure state on violation | Security Manager, System State Manager | Unit Test |
| SWR-SEC-004 | System shall protect root-of-trust | eFuse Manager, Hardware Security Module | Hardware Test |
| SWR-SEC-005 | System shall encrypt sensitive flash data | Flash Encryption Manager, Crypto Manager | Hardware Test |
| SWR-SEC-006 | System shall support external storage encryption | Storage Encryption, Crypto Manager | Unit Test |
| SWR-SEC-007 | System shall restrict cryptographic key access | Key Manager, Access Control | Security Test |
| SWR-SEC-008 | System shall ensure stored data integrity | Data Integrity Manager, Storage Abstraction | Unit Test |
| SWR-SEC-009 | System shall encrypt all Main Hub communication | TLS Manager, Communication Manager | Integration Test |
| SWR-SEC-010 | System shall ensure message integrity/authenticity | TLS Manager, Message Validator | Security Test |
| SWR-SEC-011 | System shall use secure channels for OTA | TLS Manager, OTA Manager | Integration Test |
| SWR-SEC-012 | System shall detect communication security violations | Security Violation Handler, TLS Manager | Unit Test |
| SWR-SEC-013 | System shall report security violations as FATAL | Security Violation Handler, Diagnostics Manager | Unit Test |
| SWR-SEC-014 | System shall implement eFuse anti-rollback | Anti-Rollback Manager, eFuse Manager | Hardware Test |
| SWR-SEC-015 | System shall protect keys during power loss | Key Manager, Power Manager | Security Test |

## 3. Component Coverage Analysis

### 3.1 Components with High Requirement Coverage
- **Sensor Manager**: 13 requirements (DAQ, DQC)
- **Communication Manager**: 11 requirements (COM, OTA, SEC)
- **Persistence Manager**: 9 requirements (DATA, OTA, SYS)
- **Diagnostics Manager**: 8 requirements (DIAG, SEC, DQC)
- **System State Manager**: 7 requirements (SYS, OTA, SEC)

### 3.2 Critical Components
- **Security Manager**: Implements foundational security requirements
- **OTA Manager**: Implements firmware update lifecycle
- **Data Pool**: Central data management for all features
- **Machine Constants Manager**: Configuration and calibration management

## 4. Verification Method Summary

| Verification Method | Requirement Count | Percentage |
|-------------------|------------------|------------|
| Unit Test | 45 | 52.3% |
| Integration Test | 28 | 32.6% |
| Hardware Test | 10 | 11.6% |
| Security Test | 6 | 7.0% |
| Performance Test | 4 | 4.7% |
| Documentation Review | 1 | 1.2% |

## 5. Orphan Analysis

### 5.1 Requirements Without Components
None identified - all software requirements are mapped to implementing components.

### 5.2 Components Without Requirements
All major components are covered by software requirements. Utility components (Time Service, Event System) support multiple requirements indirectly.

## 6. Notes

1. Some requirements are implemented by multiple components working together
2. Verification methods are assigned based on the primary testing approach needed
3. Integration tests verify component interactions and end-to-end functionality
4. Hardware tests verify hardware-dependent functionality
5. Security tests focus on security-critical functionality and attack resistance