You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ac43d66
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .github/agents/executor.agent.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,6 +121,8 @@ namespace filters::passive
121
121
-**`const` correctness**: Mark all non-mutating methods `const`
122
122
-**`constexpr`**: Use for compile-time calculations and lookup tables
123
123
-**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.
124
126
125
127
### Error Handling
126
128
@@ -179,6 +181,8 @@ Rules:
179
181
- Fixture class and type aliases inside anonymous `namespace {}`
180
182
- Test macros (`TEST_F`, `TYPED_TEST`) outside anonymous namespace
181
183
- 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
182
186
- Test numerical accuracy against known reference values
183
187
- Test edge cases: zero input, maximum range, saturation
184
188
@@ -255,7 +259,7 @@ namespace filters::passive
255
259
2.**Search for existing patterns** in the codebase — follow them exactly
256
260
3.**Implement changes** one file at a time, following all rules above
257
261
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
259
263
6.**Update `CMakeLists.txt`** if new files were added
260
264
7.**Update documentation** in `doc/` for every algorithm added or changed
261
265
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
-**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.
66
68
- Coverage sources: explicit template instantiation `.cpp` files when `EMIL_ENABLE_COVERAGE` is set
67
69
68
70
#### Documentation Update
@@ -147,6 +149,8 @@ Before finalizing, verify the plan against these constraints:
-[ ] No pure virtual destructors (`virtual ~Foo() = 0`) — use `= default` if a virtual destructor is needed; omit if class is never deleted polymorphically
124
126
125
127
### 9. Error Handling (WARNING)
126
128
@@ -156,6 +158,8 @@ End with a summary: total criticals, warnings, suggestions, and overall verdict
156
158
-[ ] Edge cases tested: zero input, maximum range, saturation conditions
157
159
-[ ] No heap allocation in tests
158
160
-[ ] 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
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -169,6 +169,23 @@ These are the most important architectural directives in this codebase. Every ne
169
169
- Do not add function/method docstrings unless the API is non-obvious to a domain expert
170
170
- Acceptable exceptions: legal headers, `NOLINT` annotations, and brief clarifications of non-trivial math or domain-specific constants
171
171
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
+
172
189
### Error Handling
173
190
174
191
- 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
180
197
- Write unit tests using GoogleTest
181
198
- Test with multiple numeric types (float, Q15, Q31) using typed tests
182
199
- 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
183
202
- Aim for high code coverage, especially in numerical algorithms
184
203
- Verify numerical accuracy and stability
185
204
- Test edge cases and boundary conditions
@@ -192,6 +211,7 @@ These are the most important architectural directives in this codebase. Every ne
192
211
- Fixture class and type aliases go inside an anonymous `namespace {}`
193
212
- Test macros (`TEST_F`, `TYPED_TEST`) go **outside** the anonymous namespace
194
213
- 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
195
215
196
216
#### Typed Test Pattern (multiple types)
197
217
@@ -307,12 +327,16 @@ class Algorithm
307
327
{
308
328
T coefficient; // Works with float, Q15, Q31
309
329
};
330
+
331
+
// Brace initialization
332
+
T value{};
333
+
Foo obj{arg1, arg2};
310
334
```
311
335
312
336
## Additional Guidelines
313
337
314
338
- **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
316
340
- **NAMESPACE**: Use appropriate namespaces by domain:
317
341
- `analysis::` - Signal analysis algorithms
318
342
- `control_analysis::` - Control system analysis (Frequency Response, Root Locus)
-`const` on all non-mutating methods, `constexpr` where possible
66
66
- 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.
67
68
68
69
## Design
69
70
70
71
- SOLID principles — constructor injection, depend on abstractions
71
72
- DRY — extract shared logic into helpers or templates
72
73
- 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.
73
75
- No virtual calls in ISR-callable or real-time critical paths
- Test macros (`TEST_F`, `TYPED_TEST`) go **outside** the anonymous namespace
72
72
- Include `<gtest/gtest.h>` (not `<gmock/gmock.h>`) unless gmock matchers are needed
73
73
- 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
74
75
- Test all three numeric types: `float`, `math::Q15`, `math::Q31`
75
76
- Test numerical accuracy against known reference values (not just "doesn't crash")
76
77
- Test edge cases: zero input, maximum range values, saturation conditions
77
78
- Test one behavior per test — keep tests focused
78
79
- Use descriptive test names that explain the scenario
79
80
- Allman brace style and PascalCase naming apply to test code too
80
81
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
+
81
88
## Coverage for Template Code
82
89
83
90
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