Skip to content

Commit ac43d66

Browse files
agents and instructions updated (#139)
1 parent dbf40cc commit ac43d66

6 files changed

Lines changed: 47 additions & 2 deletions

File tree

‎.github/agents/executor.agent.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ namespace filters::passive
121121
- **`const` correctness**: Mark all non-mutating methods `const`
122122
- **`constexpr`**: Use for compile-time calculations and lookup tables
123123
- **Fixed-size types**: Prefer `uint8_t`, `int32_t`, etc., over `int`
124+
- **Brace initialization**: Use `{}` for all variable and object initialization — `T value{}` not `T value()`, `Foo obj{arg}` not `Foo obj(arg)`.
125+
- **No pure virtual destructors**: Never use `virtual ~Interface() = 0`. Use `= default` or omit the destructor. Pure virtual dtors add a thunk and body, wasting embedded memory.
124126

125127
### Error Handling
126128

@@ -179,6 +181,8 @@ Rules:
179181
- Fixture class and type aliases inside anonymous `namespace {}`
180182
- Test macros (`TEST_F`, `TYPED_TEST`) outside anonymous namespace
181183
- Include `<gtest/gtest.h>` (not `<gmock/gmock.h>`) unless gmock matchers are needed
184+
- Use **only** `testing::StrictMock<MockType>` — never `testing::NiceMock<>` or bare `Mock<>` instantiation
185+
- Follow TDD: define all use cases and expected behaviors as tests BEFORE implementing production code
182186
- Test numerical accuracy against known reference values
183187
- Test edge cases: zero input, maximum range, saturation
184188

@@ -255,7 +259,7 @@ namespace filters::passive
255259
2. **Search for existing patterns** in the codebase — follow them exactly
256260
3. **Implement changes** one file at a time, following all rules above
257261
4. **Add `#pragma GCC optimize` and `OPTIMIZE_FOR_SPEED`** to all algorithm headers
258-
5. **Create or update tests** using `TYPED_TEST` pattern for every change
262+
5. **Define and write tests first** (TDD): specify use cases and edge cases as `TYPED_TEST` or `TEST_F` tests before implementing production code; use only `testing::StrictMock<>` for mocks
259263
6. **Update `CMakeLists.txt`** if new files were added
260264
7. **Update documentation** in `doc/` for every algorithm added or changed
261265
8. **Add launch configuration** to `.vscode/launch.json` if a new simulator was created — follow the existing `cppdbg` entry pattern; insert before the generic `"Linux Debug"` entry

‎.github/agents/planner.agent.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ For each file to create or modify, specify:
6363
- Typed test pattern using `TYPED_TEST` for multiple numeric types
6464
- Test suite covering `float`, `math::Q15`, `math::Q31`
6565
- Key test cases: numerical accuracy, edge cases, boundary conditions, stability
66+
- **TDD**: All use cases and acceptance criteria are specified as concrete test cases in the plan BEFORE implementation begins. Production code exists only to satisfy those tests.
67+
- **StrictMock only**: All mock objects use `testing::StrictMock<MockType>` — `NiceMock` is forbidden in this codebase.
6668
- Coverage sources: explicit template instantiation `.cpp` files when `EMIL_ENABLE_COVERAGE` is set
6769

6870
#### Documentation Update
@@ -147,6 +149,8 @@ Before finalizing, verify the plan against these constraints:
147149
- [ ] `TYPED_TEST_SUITE` macro outside anonymous namespace
148150
- [ ] Numerical accuracy verified against known reference values
149151
- [ ] Edge cases: zero input, maximum range, saturation conditions
152+
- [ ] All mocks use `testing::StrictMock<MockType>` — no `NiceMock`, no bare mock instantiation
153+
- [ ] No pure virtual destructors in interfaces — use `= default` or omit
150154

151155
### Documentation — ALWAYS UPDATED
152156
- [ ] `doc/{domain}/{AlgorithmName}.md` created or updated for every change

‎.github/agents/reviewer.agent.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ End with a summary: total criticals, warnings, suggestions, and overall verdict
104104
- [ ] No trailing whitespace
105105
- [ ] Blank line between method definitions
106106
- [ ] `public:` before `private:` in class declarations
107+
- [ ] Brace initialization `{}` used — not parenthesis `()` — for all variable/object initialization
107108

108109
### 7. Function Size (WARNING)
109110

@@ -121,6 +122,7 @@ End with a summary: total criticals, warnings, suggestions, and overall verdict
121122
- [ ] **DIP**: Dependencies injected via constructor, depend on abstractions
122123
- [ ] **DRY**: No duplicated code blocks (>3 similar lines = extract helper or template)
123124
- [ ] Existing utility components reused (e.g., `RecursiveBuffer` for delay lines)
125+
- [ ] No pure virtual destructors (`virtual ~Foo() = 0`) — use `= default` if a virtual destructor is needed; omit if class is never deleted polymorphically
124126

125127
### 9. Error Handling (WARNING)
126128

@@ -156,6 +158,8 @@ End with a summary: total criticals, warnings, suggestions, and overall verdict
156158
- [ ] Edge cases tested: zero input, maximum range, saturation conditions
157159
- [ ] No heap allocation in tests
158160
- [ ] Tests follow Arrange-Act-Assert pattern
161+
- [ ] **Only `StrictMock`**: `testing::StrictMock<MockType>` used for ALL mocks — `testing::NiceMock<>` and bare `Mock<>` are forbidden
162+
- [ ] Test cases and use cases defined upfront (TDD) — tests exist before or alongside the implementation
159163

160164
### 13. Documentation Alignment (CRITICAL)
161165

‎.github/copilot-instructions.md‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,23 @@ These are the most important architectural directives in this codebase. Every ne
169169
- Do not add function/method docstrings unless the API is non-obvious to a domain expert
170170
- Acceptable exceptions: legal headers, `NOLINT` annotations, and brief clarifications of non-trivial math or domain-specific constants
171171
172+
### Initialization
173+
174+
Use brace initialization `{}` for all variables and objects:
175+
176+
```cpp
177+
// GOOD
178+
T value{};
179+
Foo obj{arg1, arg2};
180+
std::array<float, 4> buffer{};
181+
182+
// BAD
183+
T value(); // declares a function, not a variable (most vexing parse)
184+
Foo obj(arg1); // use braces instead
185+
```
186+
187+
Parenthesis `()` may be used only when brace initialization causes a narrowing conversion or parsing ambiguity.
188+
172189
### Error Handling
173190

174191
- Use `std::optional` for functions that may not return a value
@@ -180,6 +197,8 @@ These are the most important architectural directives in this codebase. Every ne
180197
- Write unit tests using GoogleTest
181198
- Test with multiple numeric types (float, Q15, Q31) using typed tests
182199
- Mock dependencies for isolation
200+
- **Only `StrictMock`**: Use `testing::StrictMock<MockType>` for all mocks; `testing::NiceMock<>` and bare `Mock<>` are forbidden
201+
- **TDD**: Clarify all requirements and use cases as test cases before writing implementation code
183202
- Aim for high code coverage, especially in numerical algorithms
184203
- Verify numerical accuracy and stability
185204
- Test edge cases and boundary conditions
@@ -192,6 +211,7 @@ These are the most important architectural directives in this codebase. Every ne
192211
- Fixture class and type aliases go inside an anonymous `namespace {}`
193212
- Test macros (`TEST_F`, `TYPED_TEST`) go **outside** the anonymous namespace
194213
- Include `<gtest/gtest.h>` (not `<gmock/gmock.h>`) unless gmock matchers are needed
214+
- **Only `StrictMock`**: All mock objects must use `testing::StrictMock<MockType>` — never `testing::NiceMock<>` or bare mock types
195215

196216
#### Typed Test Pattern (multiple types)
197217

@@ -307,12 +327,16 @@ class Algorithm
307327
{
308328
T coefficient; // Works with float, Q15, Q31
309329
};
330+
331+
// Brace initialization
332+
T value{};
333+
Foo obj{arg1, arg2};
310334
```
311335
312336
## Additional Guidelines
313337
314338
- **RAII**: Use Resource Acquisition Is Initialization for resource management
315-
- **INTERFACES**: Define interfaces (pure virtual classes) for testability and flexibility
339+
- **INTERFACES**: Define interfaces (pure virtual classes) for testability and flexibility; **never declare `virtual ~Interface() = 0`** — pure virtual destructors force thunk emission in embedded binaries; use `virtual ~Interface() = default` or omit if the class is never deleted polymorphically
316340
- **NAMESPACE**: Use appropriate namespaces by domain:
317341
- `analysis::` - Signal analysis algorithms
318342
- `control_analysis::` - Control system analysis (Frequency Response, Root Locus)

‎.github/instructions/numerical-cpp.instructions.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ Apply `OPTIMIZE_FOR_SPEED` (from `numerical/math/CompilerOptimizations.hpp`) on
6464
- Self-documenting code — avoid unnecessary comments
6565
- `const` on all non-mutating methods, `constexpr` where possible
6666
- Fixed-size types: `uint8_t`, `int32_t`, etc.
67+
- **Brace initialization**: Use `{}` for all variable and object initialization — `T value{}` not `T value()`, `Foo obj{arg}` not `Foo obj(arg)`. Parenthesis `()` may be used only when brace initialization causes a narrowing conversion or ambiguity.
6768

6869
## Design
6970

7071
- SOLID principles — constructor injection, depend on abstractions
7172
- DRY — extract shared logic into helpers or templates
7273
- RAII for resource management
74+
- **No pure virtual destructors**: Never declare `virtual ~Interface() = 0`. Pure virtual destructors force the compiler to emit a thunk and a separate body, wasting memory on embedded targets. Use `virtual ~Interface() = default` if a virtual destructor is required, or omit it entirely when the class is never deleted through a base pointer.
7375
- No virtual calls in ISR-callable or real-time critical paths
7476

7577
## Documentation — MANDATORY

‎.github/instructions/testing.instructions.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,20 @@ TEST_F(TestDare, solves_simple_system)
7171
- Test macros (`TEST_F`, `TYPED_TEST`) go **outside** the anonymous namespace
7272
- Include `<gtest/gtest.h>` (not `<gmock/gmock.h>`) unless gmock matchers are needed
7373
- Use `testing::StrictMock<MockType>` for strict mock expectations
74+
- **ONLY `StrictMock`**: Never use `testing::NiceMock<>` or bare mock instantiation — `NiceMock` silences unexpected-call warnings, masking test gaps; `StrictMock` enforces all interactions explicitly
7475
- Test all three numeric types: `float`, `math::Q15`, `math::Q31`
7576
- Test numerical accuracy against known reference values (not just "doesn't crash")
7677
- Test edge cases: zero input, maximum range values, saturation conditions
7778
- Test one behavior per test — keep tests focused
7879
- Use descriptive test names that explain the scenario
7980
- Allman brace style and PascalCase naming apply to test code too
8081

82+
## TDD Approach
83+
84+
- **Clarify requirements first**: Before writing any code, define and document all use cases, inputs, outputs, and edge cases as test cases
85+
- **Write tests before implementation**: Tests define the expected behavior; implementation exists only to satisfy the tests
86+
- **Red-Green-Refactor cycle**: Write a failing test, make it pass with minimal code, then refactor while keeping tests green
87+
8188
## Coverage for Template Code
8289

8390
When `EMIL_ENABLE_COVERAGE` is set, template code needs explicit instantiation in a `.cpp` file that is compiled with coverage flags. Add to the header (guarded):

0 commit comments

Comments
 (0)