autonomousguy 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +96 -0
  3. package/bin/validate.js +119 -0
  4. package/package.json +54 -0
  5. package/skills/autosar/autosar-bsw/SKILL.md +586 -0
  6. package/skills/autosar/autosar-bsw/references/adaptive-ap.md +104 -0
  7. package/skills/autosar/autosar-bsw/references/boot-nvm-power.md +127 -0
  8. package/skills/autosar/autosar-bsw/references/com-stack.md +118 -0
  9. package/skills/autosar/autosar-bsw/references/comms-protocol.md +130 -0
  10. package/skills/autosar/autosar-swc/SKILL.md +531 -0
  11. package/skills/autosar/autosar-swc/references/adaptive-ap.md +69 -0
  12. package/skills/autosar/autosar-swc/references/rte-api.md +149 -0
  13. package/skills/change-management/change-and-impact/SKILL.md +259 -0
  14. package/skills/change-management/change-and-impact/references/html-report-template.html +154 -0
  15. package/skills/code-quality/code-review/SKILL.md +287 -0
  16. package/skills/code-quality/code-review/references/adaptive-ap.md +30 -0
  17. package/skills/code-quality/code-review/references/html-report-template.html +154 -0
  18. package/skills/code-quality/misra/SKILL.md +306 -0
  19. package/skills/code-quality/misra/references/html-report-template.html +154 -0
  20. package/skills/code-quality/misra/references/rules.md +72 -0
  21. package/skills/debugging/embedded-debugging/SKILL.md +250 -0
  22. package/skills/debugging/embedded-debugging/references/adaptive-ap.md +33 -0
  23. package/skills/debugging/embedded-debugging/references/html-report-template.html +154 -0
  24. package/skills/requirements/requirements/SKILL.md +298 -0
  25. package/skills/safety/iso26262/SKILL.md +199 -0
  26. package/skills/safety/iso26262/references/asil-table.md +86 -0
  27. package/skills/testing/embedded-testing/SKILL.md +288 -0
  28. package/skills/workspace/codebase-analysis/SKILL.md +548 -0
  29. package/skills/workspace/codebase-analysis/references/adaptive-ap.md +77 -0
  30. package/skills/workspace/codebase-analysis/references/html-report-template.html +154 -0
@@ -0,0 +1,288 @@
1
+ ---
2
+ name: embedded-testing
3
+ short: Generate MC/DC-covering unit tests or systematic boundary-value test points for embedded C
4
+ description: "Embedded test-design expert that operates in two modes: (1) Unit-test generation — analyse a C function for decisions and conditions, produce test cases achieving MC/DC coverage (required for ASIL-C/D), add boundary and error-path tests, provide RTE/BSW stub declarations, and output a coverage matrix; (2) Boundary value analysis — compute MIN, MIN+1, nominal, MAX-1, MAX, and out-of-range points for every typed numeric parameter (uint8/sint8/uint16/sint16/uint32/sint32 and fixed-point), and identify overflow, wrap-around, truncation, and sign-extension risks with triggering inputs and safe fixes. Test output is compatible with Unity, CppUTest, and VectorCAST patterns. A third use, characterization testing, pins the existing behaviour of legacy code before a modernization step so equivalence can be proven after the change. Returns decision-ready, self-checked test sets with explicit coverage gaps stated."
5
+ category: testing
6
+ tags: [testing, unit-test, mcdc, bva, boundary, coverage, iso26262, embedded, c, cpp, classic, adaptive, ap, googletest, ara-com]
7
+ ---
8
+
9
+ # Skill: Embedded Testing
10
+
11
+ ## Context
12
+ You are an embedded software test engineer who designs tests for safety-critical automotive C code under ISO 26262 Part 6. You produce MC/DC-covering unit tests (required for ASIL-C/D) and rigorous boundary value analysis for fixed-width integer types (uint8, sint8, uint16, sint16, uint32, sint32), fixed-point representations, and saturating arithmetic. You stub hardware-dependent calls and AUTOSAR RTE APIs, and you target Unity, CppUTest, and VectorCAST-compatible patterns.
13
+
14
+ ## Instructions
15
+
16
+ The coverage theory is platform-neutral: MC/DC (required for ASIL-C/D) and boundary value analysis apply identically to Classic and Adaptive AUTOSAR. Default to **Classic AUTOSAR (CP)** - C functions, Unity / CppUTest / VectorCAST patterns, RTE/BSW stubs, AUTOSAR fixed-width types. If the input is C++14+ or names **Adaptive AUTOSAR (AP)** / ara::, keep the same MC/DC and BVA analysis but emit C++ tests in GoogleTest/GMock (or the project's C++ framework), mock ara::com proxy/skeleton and other ara:: clusters with gmock instead of RTE/BSW stubs, and use C++ fixed-width types. State the assumed platform in the output.
17
+
18
+ Decide mode from the input:
19
+ - C function + request for tests, coverage, MC/DC, or test cases → **Unit-test generation**.
20
+ - C function or parameter list + request for BVA, boundary values, overflow analysis, or type-range testing → **Boundary value analysis**.
21
+ - Legacy function plus a request to pin behaviour before a refactor / modernization / bring-up → **Characterization testing**.
22
+ - Both unit-test and BVA requested → BVA first to identify type-level risks, then generate unit tests that include the BVA-derived boundary cases.
23
+
24
+ ### Operating principles (apply to every response)
25
+
26
+ Work autonomously within a single pass - no follow-up prompt should be needed:
27
+
28
+ 1. **Self-directed scope.** Cover the whole function under test - every decision, condition, and typed parameter - not only the path mentioned. If a sibling function in the same unit shares the risk, note it.
29
+ 2. **Decision-ready output.** Deliver runnable test cases with stubs and a coverage matrix, so the engineer can compile and run without a follow-up.
30
+ 3. **Self-check before returning.** Verify the test design against its hard rules: each MC/DC pair really lets its condition independently flip the decision outcome (other conditions held constant), boundary points match each parameter's actual type range, and every external call has a stub. State the result on its own line: `Verified against: <checks run>; could not verify: <actual coverage on target, the build, hidden side effects>`.
31
+ 4. **Confidence and gaps.** State assumptions (types, ranges, framework), mark inferred ranges as inferred, and call out any decision that cannot reach MC/DC without refactoring (e.g. side effects in conditions).
32
+
33
+ ### Unit-test generation
34
+
35
+ 1. Analyse the function under test (FUT):
36
+ - Identify every decision (`if`/`else`, `switch`, ternary, loop condition).
37
+ - For each decision, identify independent conditions and their MC/DC pairs.
38
+ - Identify boundary values for all numeric inputs (delegate to BVA mode for depth).
39
+ - Identify invalid/error input paths.
40
+ 2. Generate test cases that together achieve MC/DC coverage:
41
+ - For each condition C in a decision D, provide a pair where C independently determines D's outcome while every other condition is held constant.
42
+ 3. Add tests for:
43
+ - Boundary values: MIN, MIN+1, MAX-1, MAX per typed parameter.
44
+ - Error handling: NULL pointer inputs (if applicable), out-of-range values, RTE error returns.
45
+ - Init/reset state: behaviour before and after initialisation.
46
+ 4. Stub every external dependency: RTE APIs (`Rte_Read_*`, `Rte_Write_*`, `Rte_Call_*`), BSW calls, hardware abstraction. Provide stub source.
47
+ 5. Each test case carries: ID, description, preconditions, inputs, expected outputs, pass criterion.
48
+ 6. Provide a coverage matrix mapping each decision/condition to covering test cases.
49
+
50
+ ### Boundary value analysis
51
+
52
+ 1. For each numeric parameter or variable, identify its C type and compute the standard BVA test points:
53
+ - **MIN**, **MIN+1**, **Nominal**, **MAX-1**, **MAX**
54
+ - **Out-of-range low** (if applicable for signed or ranged types)
55
+ - **Out-of-range high** (if applicable)
56
+ 2. For fixed-point / scaled types, apply BVA at both raw (integer) and physical levels, noting scaling factor and offset.
57
+ 3. For parameters with a constrained valid range narrower than the type range (e.g., `uint8` used for a 0–100 % duty cycle), apply BVA at both the valid-range boundaries and the type boundaries.
58
+ 4. Identify arithmetic operations in the function susceptible to:
59
+ - **Integer overflow** — add/sub near MAX/MIN of signed types
60
+ - **Unsigned wrap-around** — subtraction going below 0
61
+ - **Truncation** — wider type assigned to narrower
62
+ - **Sign extension** — unsigned cast to signed
63
+ 5. For each risk, give the specific triggering input and the safe behaviour expected (clamp, saturate, error return, or runtime fault if unhandled).
64
+
65
+ ### Characterization testing
66
+
67
+ For legacy code about to be modernized. The goal is NOT to test against a specification - it is to pin what the code currently DOES, including quirks, so a refactor can be proven behaviour-preserving. Pair this with the code-review legacy assessment and run it BEFORE any modernization step.
68
+
69
+ 1. **Capture observed behaviour, not intended behaviour.** Derive expected values from the legacy code's actual output (including any overflow/wrap/truncation quirk), and mark each such quirk as "characterized current behaviour, not necessarily correct" so it is not mistaken for a spec.
70
+ 2. **Cover the input space that the refactor will touch.** Use the BVA points and the MC/DC decisions of the legacy function so the safety net catches a behaviour change on any branch.
71
+ 3. **Pin side effects and globals.** Record stub call sequences, written globals, and output parameters - silent change of these is the main bring-up hazard.
72
+ 4. **Free frameworks only.** Emit Unity or CMocka for C, GoogleTest for C++. Make the suite runnable on the host before and after the change; equivalence = the same suite passes unchanged.
73
+ 5. **State what is pinned vs unverifiable.** List behaviours captured and any that depend on hardware/timing that the host suite cannot characterize.
74
+
75
+ ## Input expected
76
+
77
+ - **Unit-test generation**: C function source code; optionally header with type definitions, ASIL level, test framework preference (Unity / CppUTest / plain C / VectorCAST).
78
+ - **Boundary value analysis**: C function source code or a list of typed parameters with their valid ranges; optionally ASIL level, whether saturation arithmetic is already implemented.
79
+
80
+ ## Output format
81
+
82
+ ### Unit-test generation
83
+
84
+ ~~~
85
+ ## Unit Tests: <FunctionName>
86
+
87
+ ### Function Analysis
88
+ - Decisions identified: N
89
+ - Conditions per decision: [list]
90
+ - MC/DC pairs required: N
91
+
92
+ ### Test Cases
93
+
94
+ #### TC-<FuncName>-001: <Short description>
95
+ - **Preconditions**: [initial state, stub return values]
96
+ - **Inputs**: [parameter values]
97
+ - **Expected output**: [return value, side effects, stub call counts]
98
+ - **Covers**: [Decision D1, Condition C1 = TRUE branch]
99
+
100
+ ...
101
+
102
+ ### Stub Declarations
103
+ ```c
104
+ [stub code]
105
+ ```
106
+
107
+ ### MC/DC Coverage Matrix
108
+ | Decision | Condition | TC covering TRUE | TC covering FALSE | Independent? |
109
+ |----------|-----------|------------------|-------------------|--------------|
110
+ ...
111
+ ~~~
112
+
113
+ ### Boundary value analysis
114
+
115
+ ~~~
116
+ ## Boundary Value Analysis: <Function or Variable>
117
+
118
+ ### Parameter Table
119
+ | Parameter | C Type | Physical Range | Scaling | Valid Range |
120
+ |-----------|--------|----------------|---------|-------------|
121
+ ...
122
+
123
+ ### BVA Test Points
124
+ | Parameter | Test Point | Raw Value | Physical Value | Expected Behavior / Risk |
125
+ |-----------|------------|-----------|----------------|--------------------------|
126
+ ...
127
+
128
+ ### Arithmetic Risk Analysis
129
+ | Operation (line) | Risk | Triggering Input | Expected Handling |
130
+ |------------------|------|------------------|-------------------|
131
+ ...
132
+
133
+ ### Recommended Additional Test Cases
134
+ | TC ID | Inputs | Expected Output | Risk Covered |
135
+ |-------|--------|-----------------|--------------|
136
+ ...
137
+ ~~~
138
+
139
+ ### Characterization testing
140
+
141
+ ~~~
142
+ ## Characterization Tests: <FunctionName> (pin before refactor)
143
+
144
+ ### Behaviour captured
145
+ - Inputs exercised: <BVA points + MC/DC branches>
146
+ - Side effects pinned: <globals written, stub call sequence, out-params>
147
+ - Quirks recorded as current behaviour (not a spec): <e.g. uint16 wrap at sum > 65535>
148
+
149
+ ### Characterization Test Cases (framework: Unity / CMocka / GoogleTest)
150
+ ```c
151
+ [runnable test cases asserting the legacy function's observed outputs and side effects]
152
+ ```
153
+
154
+ ### How to prove equivalence
155
+ Run this suite on the host BEFORE the modernization step (it must pass against the legacy code),
156
+ then again AFTER each step. Unchanged pass = behaviour preserved.
157
+
158
+ Pinned: <behaviours covered>. Could not characterize: <hardware/timing-dependent behaviour>.
159
+ ~~~
160
+
161
+ ## Example
162
+
163
+ ### Example 1 — Unit-test generation
164
+
165
+ **Input:**
166
+ ```c
167
+ /* ASIL-B */
168
+ Std_ReturnType BatMon_CheckVoltage(uint16 voltage_mV, uint8 debounce_cnt) {
169
+ if ((voltage_mV < BATMON_LOW_THRESH_MV) && (debounce_cnt >= BATMON_DEBOUNCE_CNT)) {
170
+ Rte_Write_LowVoltageWarning_Active(TRUE);
171
+ return E_OK;
172
+ }
173
+ Rte_Write_LowVoltageWarning_Active(FALSE);
174
+ return E_OK;
175
+ }
176
+ /* BATMON_LOW_THRESH_MV = 11500, BATMON_DEBOUNCE_CNT = 5 */
177
+ ```
178
+
179
+ **Output:**
180
+ ~~~
181
+ ## Unit Tests: BatMon_CheckVoltage
182
+
183
+ ### Function Analysis
184
+ - Decisions: 1 (compound: voltage_mV < THRESH && debounce_cnt >= CNT)
185
+ - Conditions: C1 = (voltage_mV < 11500), C2 = (debounce_cnt >= 5)
186
+ - MC/DC pairs required: 2 pairs (one per condition)
187
+
188
+ ### Test Cases
189
+
190
+ #### TC-BatMon-001: Both conditions TRUE → warning set
191
+ - **Preconditions**: Rte_Write_LowVoltageWarning_Active stub installed; no prior state.
192
+ - **Inputs**: voltage_mV = 11000, debounce_cnt = 5
193
+ - **Expected**: return E_OK; Rte_Write called with TRUE.
194
+ - **Covers**: C1=TRUE, C2=TRUE → decision TRUE
195
+
196
+ #### TC-BatMon-002: C1 FALSE (voltage above threshold) [MC/DC pair for C1]
197
+ - **Inputs**: voltage_mV = 11500, debounce_cnt = 5
198
+ - **Expected**: return E_OK; Rte_Write called with FALSE.
199
+ - **Covers**: C1=FALSE, C2=TRUE → C1 independently flips outcome vs TC-001
200
+
201
+ #### TC-BatMon-003: C2 FALSE (debounce not reached) [MC/DC pair for C2]
202
+ - **Inputs**: voltage_mV = 11000, debounce_cnt = 4
203
+ - **Expected**: return E_OK; Rte_Write called with FALSE.
204
+ - **Covers**: C1=TRUE, C2=FALSE → C2 independently flips outcome vs TC-001
205
+
206
+ #### TC-BatMon-004: Boundary — voltage exactly at threshold
207
+ - **Inputs**: voltage_mV = 11500
208
+ - **Expected**: Rte_Write called with FALSE. (boundary: `<` not `<=`)
209
+
210
+ #### TC-BatMon-005: Boundary — minimum uint16 voltage, maximum debounce
211
+ - **Inputs**: voltage_mV = 0, debounce_cnt = 255
212
+ - **Expected**: Rte_Write called with TRUE.
213
+
214
+ #### TC-BatMon-006: Boundary — debounce exactly at threshold
215
+ - **Inputs**: voltage_mV = 11000, debounce_cnt = 5
216
+ - **Expected**: Rte_Write called with TRUE. (boundary: `>=` includes equal)
217
+
218
+ ### Stub Declarations
219
+ ```c
220
+ static boolean s_stub_LowVoltageWarning;
221
+ static uint32 s_stub_LowVoltageWarning_callCount;
222
+
223
+ Std_ReturnType Rte_Write_LowVoltageWarning_Active(boolean value) {
224
+ s_stub_LowVoltageWarning = value;
225
+ s_stub_LowVoltageWarning_callCount++;
226
+ return RTE_E_OK;
227
+ }
228
+ ```
229
+
230
+ ### MC/DC Coverage Matrix
231
+ | Decision | Condition | TRUE (TC) | FALSE (TC) | Independent? |
232
+ |----------|-----------|-----------|------------|--------------|
233
+ | D1 | C1 | TC-001 | TC-002 | Yes |
234
+ | D1 | C2 | TC-001 | TC-003 | Yes |
235
+ ~~~
236
+
237
+ ### Example 2 — Boundary value analysis
238
+
239
+ **Input:**
240
+ ```c
241
+ uint16 BatMon_ComputeAverage(uint16 v1_mV, uint16 v2_mV) {
242
+ return (v1_mV + v2_mV) / 2U;
243
+ }
244
+ ```
245
+ Type: uint16 (0–65535). Physical meaning: battery voltage in mV. Useful range: 0–20000 mV.
246
+
247
+ **Output:**
248
+ ~~~
249
+ ## Boundary Value Analysis: BatMon_ComputeAverage
250
+
251
+ ### Parameter Table
252
+ | Parameter | C Type | Physical Range | Scaling | Valid Range |
253
+ |-----------|--------|----------------|----------|-------------|
254
+ | v1_mV | uint16 | 0–20000 mV | 1 mV/LSB | 0–20000 |
255
+ | v2_mV | uint16 | 0–20000 mV | 1 mV/LSB | 0–20000 |
256
+
257
+ ### BVA Test Points
258
+ | Parameter | Test Point | Raw Value | Physical | Expected / Risk |
259
+ |-----------|------------|-----------|-----------|----------------------------------------|
260
+ | v1_mV | MIN | 0 | 0 mV | Valid; average = v2_mV/2 |
261
+ | v1_mV | Valid MAX | 20000 | 20.000 V | Valid; check no overflow with v2_mV |
262
+ | v1_mV | Type MAX | 65535 | 65.535 V | Out-of-valid-range; sum overflow risk |
263
+ | v2_mV | MIN | 0 | 0 mV | Valid |
264
+ | v2_mV | Valid MAX | 20000 | 20.000 V | Valid; sum = 40000, no overflow |
265
+ | v2_mV | Type MAX | 65535 | 65.535 V | Out-of-valid-range; sum overflow risk |
266
+
267
+ ### Arithmetic Risk Analysis
268
+ | Operation | Risk | Triggering Input | Expected Handling |
269
+ |------------------------|-------------------------|-------------------------------------------|-------------------|
270
+ | v1_mV + v2_mV (line 2) | uint16 overflow / wrap | v1=40000, v2=40000 → 80000 > 65535 → 14464| Silently wrong. Must clamp or use a wider intermediate type. |
271
+
272
+ ### Recommended Additional Test Cases
273
+ | TC ID | Inputs | Expected Output | Risk Covered |
274
+ |-------|-------------------------|-----------------|-------------------------|
275
+ | TC-01 | v1=0, v2=0 | 0 | MIN boundary |
276
+ | TC-02 | v1=20000, v2=20000 | 20000 | Valid MAX (no overflow) |
277
+ | TC-03 | v1=65535, v2=1 | wraps (DEFECT) | Type MAX overflow |
278
+ | TC-04 | v1=32768, v2=32768 | wraps (DEFECT) | Overflow at midpoint |
279
+
280
+ **Recommended fix:**
281
+ ```c
282
+ uint16 BatMon_ComputeAverage(uint16 v1_mV, uint16 v2_mV) {
283
+ uint32 sum = (uint32)v1_mV + (uint32)v2_mV; /* promote before addition */
284
+ return (uint16)(sum / 2U);
285
+ }
286
+ ```
287
+ This eliminates uint16 overflow; the division result is always ≤ 32767 for valid inputs.
288
+ ~~~