|
| 1 | +# Open Points |
| 2 | + |
| 3 | +Items requiring design decisions or future attention. Each entry includes |
| 4 | +the problem, code location, options considered, and a recommendation. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## 1. KVS `as` casts — lossy integer conversions |
| 9 | + |
| 10 | +**Location:** `src/dfm_lib/src/sovd_fault_storage.rs` lines 107-111 (serialize), 132-135 (deserialize) |
| 11 | + |
| 12 | +**Problem:** |
| 13 | +`rust_kvs` only supports `i64` as its numeric type. Fault counters are |
| 14 | +stored as `u32`/`u64`, so serialization uses `as i64` (potentially |
| 15 | +truncating high-bit values) and deserialization uses `as u32`/`as u64` |
| 16 | +(wrapping on negative values, defaulting to 0 on missing keys). |
| 17 | + |
| 18 | +Affected fields: |
| 19 | +- `occurrence_counter` (`u32` → `i64` → `u32`) |
| 20 | +- `aging_counter` (`u32` → `i64` → `u32`) |
| 21 | +- `healing_counter` (`u32` → `i64` → `u32`) |
| 22 | +- `first_occurrence_secs` (`u64` → `i64` → `u64`) |
| 23 | +- `last_occurrence_secs` (`u64` → `i64` → `u64`) |
| 24 | + |
| 25 | +**Options:** |
| 26 | +1. **`TryFrom` with fallback to 0** — safe, but silently loses data on overflow. |
| 27 | +2. **`TryFrom` with `StorageError` propagation** — surfaces the problem to |
| 28 | + |
| 29 | + the caller; forces handling of corrupted/out-of-range storage. |
| 30 | + |
| 31 | +**Recommendation:** Option 2 — propagate as `StorageError`. Silent |
| 32 | +fallback to 0 can mask data corruption in long-running automotive |
| 33 | +systems where counters may accumulate over thousands of operation |
| 34 | +cycles. |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## 2. PreFailed resets the aging clock |
| 39 | + |
| 40 | +**Location:** `src/dfm_lib/src/fault_record_processor.rs` line 175 (`mark_aging_active`) |
| 41 | + |
| 42 | +**Problem:** |
| 43 | +When a `PreFailed` event arrives, `mark_aging_active` is called, which |
| 44 | +resets the aging clock to the current operation cycle. This means a |
| 45 | +fault that oscillates between `PreFailed` and `PrePassed` will never |
| 46 | +age out, even if it never reaches a full `Failed` confirmation. |
| 47 | + |
| 48 | +This is the **conservative** (automotive-safe) approach: a fault that is |
| 49 | +still intermittently signaling `PreFailed` should not be silently |
| 50 | +cleared. However, it deviates from a strict reading of ISO 14229 where |
| 51 | +only confirmed DTCs (`Failed`) start the aging counter. |
| 52 | + |
| 53 | +**Options:** |
| 54 | +1. **Keep current behavior** — conservative; any sign of fault activity |
| 55 | + keeps the DTC alive. |
| 56 | +2. **Only reset aging on `Failed`** — strict ISO 14229 interpretation; |
| 57 | + `PreFailed` alone does not prevent aging. |
| 58 | + |
| 59 | +**Recommendation:** Option 1 — maintain the current conservative |
| 60 | +behavior. In automotive safety contexts, it is preferable to keep a |
| 61 | +DTC visible longer than to risk clearing it while the underlying |
| 62 | +condition is still intermittently present. |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## 3. MAX_PATH_LENGTH coupling with LongString capacity |
| 67 | + |
| 68 | +**Location:** `src/fault_lib/src/fault_manager_sink.rs` line 215 |
| 69 | + |
| 70 | +**Problem:** |
| 71 | +`MAX_PATH_LENGTH` is a magic constant set to `128`, which must match |
| 72 | +the capacity of `LongString::StaticString<128>` used for IPC. If either |
| 73 | +value changes independently, path validation and IPC serialization will |
| 74 | +disagree, potentially causing silent truncation or runtime panics. |
| 75 | + |
| 76 | +**Options:** |
| 77 | +1. **`const_assert!`** — add a compile-time assertion that |
| 78 | + `MAX_PATH_LENGTH == LongString::CAPACITY` so any mismatch fails the |
| 79 | + build. |
| 80 | +2. **Doc comment only** — document the coupling (already done in T55) |
| 81 | + and rely on code review to keep them in sync. |
| 82 | + |
| 83 | +**Recommendation:** Option 1 if `LongString` exposes a `CAPACITY` |
| 84 | +constant. Otherwise, the existing doc comment (added in T55) is |
| 85 | +sufficient until the upstream type provides a programmatic bound. |
0 commit comments