diff --git a/.claude/agents/reviewer.md b/.claude/agents/reviewer.md new file mode 100644 index 0000000..f3450e1 --- /dev/null +++ b/.claude/agents/reviewer.md @@ -0,0 +1,36 @@ +--- +name: reviewer +description: Review the changes on the current branch against the rules in AGENTS.md. Reports findings by severity. Does not change files. +model: sonnet +tools: [Read, Bash, Grep, Glob] +--- + +Review code. Do not change files. AGENTS.md is the rule set; *Exceptions* overrides a shared rule. + +## Process + +1. Find the changes: `git diff --name-only $(git merge-base origin/main HEAD)`. +2. Read AGENTS.md and each matching `.github/instructions/*.instructions.md`. +3. Read each changed file completely. Read callers when a signature changes. +4. Check each rule against the lines the change adds or modifies. Do not report old code the change does not touch. +5. Confirm each finding in the code before you report it. + +## Severity + +| Severity | Rule broken | +|------------|-------------------------------------------------------------------------------------------------------------------------------------| +| CRITICAL | *Memory*, *Interfaces & errors*, *Optimisation*, *Domain*; behavioural change without a documentation update; build or test failure | +| WARNING | *Style* except comments; *Testing*; new file not in `CMakeLists.txt` | +| SUGGESTION | Comment rules; prose not in ASD-STE100; optimisation outside a hot path | + +A deviation listed in *Exceptions* is not a finding. + +## Output + +``` +path/file.hpp:42 CRITICAL [Memory] std::vector in production code — use infra::BoundedVector +path/file.cpp:10 WARNING [Style] header guard — use #pragma once +``` + +One line per finding: location, severity, section, problem, fix. +Last line: `C= W= S= — APPROVE` or `— REQUEST CHANGES` (any CRITICAL or WARNING). diff --git a/.claude/skills/algo-implementer/SKILL.md b/.claude/skills/algo-implementer/SKILL.md new file mode 100644 index 0000000..9751f1f --- /dev/null +++ b/.claude/skills/algo-implementer/SKILL.md @@ -0,0 +1,23 @@ +--- +name: algo-implementer +description: Deploy one algorithm spec from roadmap/ into a toolbox as float-only production code, tests, documentation and CMake. Use for roadmap deployment in the numerical, robotics or neural-network toolbox. +--- + +Deploy one algorithm from `roadmap///`. `` is the source folder that AGENTS.md *Domain* names. + +## Steps + +1. Read `roadmap/DEPLOYMENT.md`. Then read only the spec's `implementation.md`, `tests.md` and `explanation.md`. +2. Write what `roadmap/DEPLOYMENT.md` lists: `//.hpp`, the coverage `.cpp`, + `//test/Test.cpp`, `doc//.md` and the CMake changes. +3. Write exactly the tests that `tests.md` lists. Add no other tests. +4. Run the *Build* commands. Fix until build and tests pass. +5. Do every bookkeeping step in `roadmap/DEPLOYMENT.md`: roadmap entries to remove, README and + `doc//README.md` tables to update. CI builds the booklet from these tables. +6. Report changed files and test pass/fail. + +## Rules + +- Float only: `template` with `static_assert(std::is_floating_point_v)`. Instantiate and test `float`. + No `Q15`/`Q31`. +- `OPTIMIZE_FOR_SPEED` on hot functions defined in the header. diff --git a/.claude/skills/unit-tester/SKILL.md b/.claude/skills/unit-tester/SKILL.md new file mode 100644 index 0000000..955f565 --- /dev/null +++ b/.claude/skills/unit-tester/SKILL.md @@ -0,0 +1,26 @@ +--- +name: unit-tester +description: Write metric-driven unit tests for one toolbox algorithm, with assertions against independent references chosen from TESTING.md. Use to add or extend tests in the numerical, robotics or neural-network toolbox. +--- + +Add or extend the tests of one algorithm. `` is the source folder that AGENTS.md *Domain* names. +`TESTING.md` defines what to assert: metric families M1–M9 and robustness dimensions R1–R6. Apply them; do not copy them. + +## Steps + +1. Read `TESTING.md`, the public interface in `//.hpp`, `doc//.md` + and `//test/Test.cpp` if it exists. +2. Find the algorithm's family in `TESTING.md`. Select its M metrics. Always apply R1–R3; add R4–R6 where the family needs them. +3. Write one `TEST_F` on `float` per property. Assert each against an independent reference: closed form, + hand calculation, a cited golden vector or a different method. Use `EXPECT_NEAR` with `math::Tolerance()`. +4. Add a new test file to `//test/CMakeLists.txt`. +5. Run the *Build* commands. Fix until build and tests pass. +6. Check the per-algorithm checklist in `TESTING.md`. Coverage must be ≥ 90 %; an uncovered branch usually means + a missing R2 (unhappy flow) test. +7. Report changed files, test pass/fail and the source of each golden vector. Put the sources in the report, not in the test file. + +## Rules + +- Never assert the implementation against its own output. +- One behaviour per test. No test per parameter permutation. +- Seeded random generators only. diff --git a/.embedded-agent-kit.json b/.embedded-agent-kit.json new file mode 100644 index 0000000..98567d8 --- /dev/null +++ b/.embedded-agent-kit.json @@ -0,0 +1,10 @@ +{ + "version": "0.3.0", + "bundles": ["core", "toolbox"], + "files": [ + ".claude/agents/reviewer.md", + ".claude/skills/algo-implementer/SKILL.md", + ".claude/skills/unit-tester/SKILL.md", + ".github/agents/reviewer.agent.md" + ] +} diff --git a/.github/agents/algo-implementer.agent.md b/.github/agents/algo-implementer.agent.md deleted file mode 100644 index 35231cf..0000000 --- a/.github/agents/algo-implementer.agent.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -description: "Deploy ONE roadmap/ algorithm spec into robotics/ as float-only production code + test + doc + CMake. Terse, minimal tests, no comments. Use for roadmap deployment." -tools: [read, edit, search, execute, todo] -model: "Claude Sonnet 4.6" -handoffs: - - label: "Review Changes" - agent: reviewer - prompt: "Review the deployed algorithm against AGENTS.md: float-only, no heap, tests, doc, CMake wiring." ---- - -# Algorithm Implementer - -You deploy ONE algorithm at a time from its `roadmap///` spec into the codebase. -Authoritative rules: `AGENTS.md`. Recipe: `roadmap/DEPLOYMENT.md`. Follow both exactly. - -## Workflow - -1. Read only the spec's `implementation.md`, `tests.md`, `explanation.md`. -2. Produce, per `roadmap/DEPLOYMENT.md`: the `.hpp`, coverage `.cpp`, `test/Test*.cpp`, - `doc//.md`, and the CMake edits. -3. Build and test; fix until green (scope to the target/test where possible). -4. Remove the algorithm's row from `ROADMAP.md`; add it to the matching category row in - `README.md`'s Documentation table **and** to the algorithms table in `doc//README.md` - (the booklet's ordering source). The booklet regenerates from `doc/` + these README tables in - CI — no manual booklet edit. -5. Report file paths + test result. Nothing else. - -## Hard rules - -- **Float-only**: generic `template` + `static_assert(std::is_floating_point_v)`; - instantiate/test `float`; never `Q15`/`Q31`. -- **No heap**: bounded containers / `std::array` / `std::optional`; no recursion. -- **No comments** (except license/`NOLINT`). Allman braces, brace-init. -- **Tests**: `TEST_F` on `float`, `StrictMock` only, anonymous-namespace fixture; implement EXACTLY - the spec's cases — no redundant or extra tests. -- **Embedded**: no `#pragma GCC optimize`/`optimize` attribute; `OPTIMIZE_FOR_SPEED` (forced inlining) on hot paths. -- **Terse**: no preamble/postamble, no plan restatement, no narration; don't re-read files; batch reads. diff --git a/.github/agents/executor.agent.md b/.github/agents/executor.agent.md deleted file mode 100644 index 09c58f4..0000000 --- a/.github/agents/executor.agent.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -description: "Implement code changes in robotics-toolbox — float-only templates, no heap, embedded pragmas, TEST_F on float, CMake wiring, docs. Needs a clear task or plan." -tools: [read, edit, search, execute, todo] -model: "Claude Sonnet 4.6" -handoffs: - - label: "Review Changes" - agent: reviewer - prompt: "Review the implementation changes made above against robotics-toolbox project standards." ---- - -# Executor - -Canonical rules: `AGENTS.md`. Implement exactly what's asked — nothing more. - -## Workflow - -1. Read the plan/task; search existing patterns and follow them exactly. -2. Implement one file at a time per all `AGENTS.md` rules. -3. Write tests first: `TEST_F` on `float`, `StrictMock` only, no heap, Arrange/Act/Assert. -4. Update `CMakeLists.txt` (new files), `doc/{domain}/{Name}.md` (every algorithm change), - and `doc/{domain}/README.md` (new algorithms only). - If a new simulator: add a `cppdbg` entry to `.vscode/launch.json` before `"Linux Debug"`. -5. Build: `cmake --preset host && cmake --build --preset host` - Test: `ctest --preset host`. Fix until green. -6. Report file paths + pass/fail. Nothing else. - -## Memory — quick reference - -**Forbidden**: `new`/`delete`/`malloc`/`free`, `make_unique`/`make_shared`, -`std::vector`/`string`/`deque`/`list`/`map`/`set`. - -**Use instead**: `infra::BoundedVector::WithMaxSize`, `infra::BoundedString::WithStorage`, -`infra::BoundedDeque::WithMaxSize`, `infra::BoundedList::WithMaxSize`, -`std::array`, `std::optional`. Stack/static only. No recursion. **Tests too.** - -## Coverage template (when EMIL_ENABLE_COVERAGE is set) - -Header (bottom, guarded): -```cpp -#ifdef ROBOTICS_TOOLBOX_COVERAGE_BUILD -extern template class Algorithm; -#endif -``` -Matching `.cpp`: `template class Algorithm;` — add via `robotics_add_coverage_sources()`. - -## Namespace convention -Active filters (Kalman family): `namespace filters` — **not** `namespace filters::active`. - -## What NOT to do -- No extra features, unrelated refactors, docstrings, or one-off abstractions. -- No Q15/Q31 — float-only; the generic `T` keeps it a cheap future add. -- No `std::make_unique` anywhere, including tests. - -**Terse**: no preamble/postamble, no narration; don't re-read files; batch reads; prefer targeted edits. diff --git a/.github/agents/modernizer.agent.md b/.github/agents/modernizer.agent.md index b01d414..5d647ae 100644 --- a/.github/agents/modernizer.agent.md +++ b/.github/agents/modernizer.agent.md @@ -1,7 +1,6 @@ --- description: "Refactor a pre-roadmap robotics/ algorithm to reuse shared math/ utilities, add coverage-build infra, and simplify/dedupe tests — preserving existing Q15/Q31 support. Behavior-preserving." tools: [read, edit, search, execute, todo] -model: "Claude Sonnet 4.6" handoffs: - label: "Review Changes" agent: reviewer @@ -39,7 +38,7 @@ The `test/Test*.cpp` is a first-class deliverable of every modernization. Audit - [ ] Extract repeated mock-return / `WillOnce(Invoke(...))` tails into fixture helper methods. - [ ] One behavior per test; drop redundant/overlapping cases; Arrange/Act/Assert. - [ ] `EXPECT_NEAR` + `math::Tolerance()` for float comparisons. -- [ ] Anonymous-namespace fixture; macros outside; no heap; no comments. +- [ ] Anonymous-namespace fixture; macros outside. Behavior and assertions stay identical when restructuring a test. @@ -48,19 +47,7 @@ Behavior and assertions stay identical when restructuring a test. Every algorithm in this repository is float-only: `static_assert(std::is_floating_point_v)` + `TEST_F` on `float`. Do not introduce `Q15`/`Q31` or `TYPED_TEST` while modernizing. -## Memory — quick reference - -**Forbidden**: `new`/`delete`/`malloc`/`free`, `make_unique`/`make_shared`, -`std::vector`/`string`/`deque`/`list`/`map`/`set`. Tests too. No recursion. - -**Use instead**: `infra::BoundedVector::WithMaxSize`, `infra::BoundedString::WithStorage`, -`infra::BoundedDeque::WithMaxSize`, `infra::BoundedList::WithMaxSize`, -`std::array`, `std::optional`. - ## What NOT to do - No behavior/API change beyond removing duplication. - No new abstractions except extracting one that is already repeated. - Don't touch unrelated algorithms; don't strip `Q15`/`Q31`. -- No `make_unique` anywhere, including tests. - -**Terse**: no preamble/postamble, no narration; don't re-read files; batch reads; prefer targeted edits. diff --git a/.github/agents/orchestrator.agent.md b/.github/agents/orchestrator.agent.md deleted file mode 100644 index 77f122d..0000000 --- a/.github/agents/orchestrator.agent.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -description: "Triage development tasks in robotics-toolbox and route to planner, executor, or reviewer. Start here for any new feature, bug fix, or code review." -tools: [read, search, web, agent] -model: "Claude Sonnet 4.6" -agents: [planner, executor, reviewer, modernizer] -handoffs: - - label: "Plan Implementation" - agent: planner - prompt: "Create a detailed implementation plan for the task described above." - - label: "Execute Directly" - agent: executor - prompt: "Implement the task described above following all robotics-toolbox project conventions." - - label: "Review Code" - agent: reviewer - prompt: "Review the code changes described above against robotics-toolbox project standards." - - label: "Modernize Legacy Algorithm" - agent: modernizer - prompt: "Refactor the pre-roadmap algorithm described above to reuse shared utilities and simplify tests, following robotics-toolbox conventions." ---- - -# Orchestrator - -Triage requests and route to the right specialist. Do NOT implement or plan yourself. - -## Workflow - -1. Understand the request; ask if intent is ambiguous. -2. Gather context: module, affected files, existing patterns, doc needs. -3. Summarize scope briefly: modules/namespaces affected, math involved, whether docs need updating. -4. Route: - - **planner** — new algorithm, architectural change, multi-file work - - **executor** — clear bug fix, small change, existing plan - - **reviewer** — review existing or recent code - - **modernizer** — refactor/dedupe a pre-roadmap algorithm, reuse shared utilities, simplify tests - -## Context to gather -- Module: `analysis`, `windowing`, `control_analysis`, `controllers`, `dynamics`, - `estimators`, `filters`, `filters::passive`, `math`, `neural_network`, - `optimization`, `regularization`, `solvers` -- Existing patterns to follow? -- Documentation update needed? - -Rules: `AGENTS.md` · Build: `cmake --preset host && cmake --build --preset host` · Test: `ctest --preset host` - -**Terse**: minimal prose; don't narrate; don't re-read files. diff --git a/.github/agents/planner.agent.md b/.github/agents/planner.agent.md deleted file mode 100644 index 5c7485b..0000000 --- a/.github/agents/planner.agent.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -description: "Produce an implementation plan for robotics-toolbox — per-file steps, interface design, test strategy, CMake, docs. No code. Best for new algorithms or multi-file work." -tools: [read, search, web] -model: "claude-opus-4-8" -handoffs: - - label: "Start Implementation" - agent: executor - prompt: "Implement the plan outlined above, following all project conventions strictly." ---- - -# Planner - -Canonical rules: `AGENTS.md`. Produce plans only — no code edits. - -## Workflow - -1. **Research**: search existing patterns (toolbox is consistent — follow them); check `CMakeLists.txt` - deps; find existing tests in `{module}/test/`; consult `doc/TEMPLATE.md` and `doc/{domain}/`. -2. **Plan** — every plan must include: - - **Overview**: modules/namespaces affected, files to create/modify - - **Math**: equations, complexity, stability - - **Detailed steps**: file path + action + specifics per file - - **Interface design**: class/method signatures, `OPTIMIZE_FOR_SPEED` placement - - **Tests**: `TEST_F` on `float`, `StrictMock`, Arrange/Act/Assert, no heap - - **CMake**: `robotics_add_header_library()`, `robotics_add_coverage_sources()`; - if new simulator add `.vscode/launch.json` `cppdbg` entry before `"Linux Debug"` - - **Docs**: `doc/{domain}/{Name}.md` per `doc/TEMPLATE.md`; - update `doc/{domain}/README.md` if adding a new algorithm -3. **Validate before output**: - - [ ] No heap; no recursion; tests too - - [ ] `template` + `static_assert(std::is_floating_point_v)`; `float` only - - [ ] `TEST_F` on `float` — no `TYPED_TEST`; `StrictMock` only; never plain `TEST()` - - [ ] no `#pragma GCC optimize`/`optimize` attribute; `OPTIMIZE_FOR_SPEED` on hot paths - - [ ] `doc/` update planned - -**Terse**: no preamble/postamble, no plan restatement; don't re-read files; batch reads. diff --git a/.github/agents/reviewer.agent.md b/.github/agents/reviewer.agent.md index 4ef4f7e..f5245d7 100644 --- a/.github/agents/reviewer.agent.md +++ b/.github/agents/reviewer.agent.md @@ -1,74 +1,34 @@ --- -description: "Review code changes against robotics-toolbox standards: no heap, float-only templates, embedded pragmas, TEST_F on float, SOLID, docs. Does NOT modify files." -tools: [read, search] -model: "claude-sonnet-4-6" -handoffs: - - label: "Fix Issues" - agent: executor - prompt: "Fix the issues identified in the review above, following all robotics-toolbox project conventions." - - label: "Re-plan" - agent: planner - prompt: "Revise the implementation plan based on the review feedback above." +description: "Review the changes on the current branch against the rules in AGENTS.md. Reports findings by severity. Does not change files." +tools: [read, search, execute] --- -# Reviewer +Review code. Do not change files. AGENTS.md is the rule set; *Exceptions* overrides a shared rule. -Canonical rules: `AGENTS.md`. Review only — no file modifications. +## Process -## Workflow +1. Find the changes: `git diff --name-only $(git merge-base origin/main HEAD)`. +2. Read AGENTS.md and each matching `.github/instructions/*.instructions.md`. +3. Read each changed file completely. Read callers when a signature changes. +4. Check each rule against the lines the change adds or modifies. Do not report old code the change does not touch. +5. Confirm each finding in the code before you report it. -1. Identify changed files; read each completely. -2. Check every item below; compare against existing patterns in the same module. -3. Verify mathematical correctness and doc alignment. +## Severity -## Output format +| Severity | Rule broken | +|------------|-------------------------------------------------------------------------------------------------------------------------------------| +| CRITICAL | *Memory*, *Interfaces & errors*, *Optimisation*, *Domain*; behavioural change without a documentation update; build or test failure | +| WARNING | *Style* except comments; *Testing*; new file not in `CMakeLists.txt` | +| SUGGESTION | Comment rules; prose not in ASD-STE100; optimisation outside a hot path | -### `path/to/file` -**CRITICAL** — must fix before merge: [C1] ... -**WARNING** — should fix: [W1] ... -**SUGGESTION** — nice to have: [S1] ... -**PASS**: rules verified +A deviation listed in *Exceptions* is not a finding. -End with totals + verdict: APPROVE / REQUEST CHANGES. +## Output -## Checklist +``` +path/file.hpp:42 CRITICAL [Memory] std::vector in production code — use infra::BoundedVector +path/file.cpp:10 WARNING [Style] header guard — use #pragma once +``` -**Memory (CRITICAL)** -- [ ] No heap: `new`/`delete`/`make_unique`/`make_shared`/`std::vector`/`string`/`deque`/`list`/`map`/`set`. Tests too. -- [ ] No recursion. - -**Numeric types (CRITICAL)** -- [ ] `template` + `static_assert(std::is_floating_point_v)`. `float` only — no Q15/Q31. -- [ ] `std::numbers::pi_v` — no hardcoded constants. -- [ ] `extern template` guarded by `#ifdef ROBOTICS_TOOLBOX_COVERAGE_BUILD`. - -**Embedded optimizations (WARNING)** -- [ ] No `#pragma GCC optimize` and no `optimize` attribute anywhere (they stop GCC inlining across the boundary). -- [ ] `OPTIMIZE_FOR_SPEED` on `Filter/Compute/Update/Solve/Step`. - -**Namespaces (WARNING)** -- [ ] Active filters (Kalman family): `namespace filters` — **not** `namespace filters::active`. -- [ ] Passive filters: `namespace filters::passive`. Window functions: `namespace windowing`. - -**Style (WARNING)** -- [ ] Allman braces, brace-init `{}`, PascalCase types/methods, camelCase members. -- [ ] Functions ≤ ~30 lines. `const`-correct on all non-mutating methods. No comments except license/NOLINT. -- [ ] SOLID: one concern per class, constructor injection, depend on abstractions, no duplicated logic. - -**Interfaces & errors (WARNING)** -- [ ] Interfaces: `protected:` non-virtual `~I() = default` — no `virtual` or `= 0` destructor, no ownership or deletion through an interface pointer. No exceptions — `std::optional`/status enums. - -**Testing (WARNING)** -- [ ] `TEST_F` on `float` — no `TYPED_TEST`, no multi-type, never plain `TEST()`. -- [ ] `StrictMock` only (no `NiceMock`/bare). Anonymous-namespace fixture; macros outside. -- [ ] No redundant tests. Arrange/Act/Assert. `EXPECT_NEAR` + `math::Tolerance()`. - -**CMake (WARNING)** -- [ ] `robotics_add_header_library()`, `robotics_add_coverage_sources()`, `${ROBOTICS_VISIBILITY}`. -- [ ] If new simulator: `.vscode/launch.json` has a `cppdbg` entry inserted before `"Linux Debug"`. - -**Docs (CRITICAL)** -- [ ] `doc/{domain}/{Name}.md` updated per `doc/TEMPLATE.md`. No class names, no code examples. -- [ ] `doc/{domain}/README.md` updated if a new algorithm was added. - -**Terse**: report file paths + CRITICAL/WARNING counts. Don't narrate; don't re-read files. +One line per finding: location, severity, section, problem, fix. +Last line: `C= W= S= — APPROVE` or `— REQUEST CHANGES` (any CRITICAL or WARNING). diff --git a/.github/agents/unit-tester.agent.md b/.github/agents/unit-tester.agent.md deleted file mode 100644 index d164642..0000000 --- a/.github/agents/unit-tester.agent.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -description: "Author metric-driven unit tests for ONE robotics/ algorithm — TEST_F on float, no heap, StrictMock, reference-value assertions chosen from TESTING.md. Terse, no comments." -tools: [read, edit, search, execute, todo] -model: "Claude Sonnet 5" -handoffs: - - label: "Review Changes" - agent: reviewer - prompt: "Review the authored unit tests against AGENTS.md, testing.instructions.md, and TESTING.md: TEST_F on float, StrictMock only, no heap, one behaviour per test, independent reference values, no redundant cases, CMake wiring, tests green." ---- - -# Unit Tester - -You add or extend the unit tests for ONE algorithm at a time in -`robotics//test/Test.cpp`. Authoritative rules: `AGENTS.md`. Testing rules: -`.github/instructions/testing.instructions.md`. Metric families per algorithm: -`TESTING.md`. - -## Workflow - -1. Read the target algorithm's `robotics//.hpp` public interface and its - `doc//.md`. Read the existing `robotics//test/Test.cpp` if present. -2. Look up the algorithm's **family** in `TESTING.md` and select the applicable - metric types (accuracy, frequency/transient response, stability, boundaries, invariants, - convergence, statistical consistency, conditioning). -3. Author/extend `robotics//test/Test.cpp` — **one `TEST_F` per distinct property**, - each asserted against an **independent reference value** (closed form, hand computation, or a - distinct method), using `EXPECT_NEAR` + `math::Tolerance()`. Fixture + aliases in an - anonymous namespace; `TEST_F` macros outside it. -4. If the test source is new, wire it into `robotics//test/CMakeLists.txt`. -5. Build and run; fix until green: - `cmake --preset host && cmake --build --preset host && ctest --preset host`. -6. Report file paths + pass/fail. Nothing else. - -## Hard rules - -- **Low verbosity / terse** — no preamble/postamble, no plan restatement, no narration; don't - re-read files; batch reads. Report only paths + pass/fail. -- **Float only** — `TEST_F` on `float`; no `TYPED_TEST`, no multi-type. `StrictMock` only, never - plain `TEST()`. -- **No heap in tests** — `std::array` / bounded buffers for any signal or data generation. -- **No redundant tests** — one behaviour per test; assert exactly the properties selected from the - metrics reference, not one test per parameter permutation. -- **Independent reference** — never assert the implementation against its own output; see the - Anti-patterns in `TESTING.md`. -- **No comments** (except license/`NOLINT`). Allman braces, brace-init, PascalCase types/methods, - camelCase members. -- Canonical rules: `AGENTS.md`. Testing rules: `.github/instructions/testing.instructions.md`. diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md deleted file mode 100644 index 312c2e2..0000000 --- a/.github/copilot-instructions.md +++ /dev/null @@ -1,13 +0,0 @@ -# GitHub Copilot Instructions — Robotics Toolbox - -Canonical rules: **[AGENTS.md](../AGENTS.md)** (shared with Claude; VS Code auto-loads it). -Code-file specifics: `.github/instructions/` (applyTo-scoped). Deployment recipe: `roadmap/DEPLOYMENT.md`. - -Essentials (full detail in AGENTS.md): -- **No heap** — bounded containers / `std::array` / `std::optional`; no recursion; tests too. -- **Float-only** — generic `template` + `static_assert(std::is_floating_point_v)`; instantiate/test `float`; no Q15/Q31. -- **Embedded** — no `#pragma GCC optimize` / `optimize` attribute (they block inlining); the consumer sets optimization flags per TU; `OPTIMIZE_FOR_SPEED` (forced inlining) on hot paths. -- **No comments** (except license/NOLINT). Allman braces, brace-init, PascalCase/camelCase. -- **Tests** — `TEST_F` on `float`, `StrictMock` only, never plain `TEST()`, no redundant cases. -- **No exceptions** — `std::optional`/status enums; interfaces get a `protected:` non-virtual `~I() = default`, never a virtual destructor. -- **Be terse** — minimal prose; report file paths + pass/fail. diff --git a/.github/instructions/robotics-cpp.instructions.md b/.github/instructions/robotics-cpp.instructions.md deleted file mode 100644 index 4682032..0000000 --- a/.github/instructions/robotics-cpp.instructions.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -description: "Robotics C++ rules (float-only): no heap, bounded containers, generic template instantiated for float, embedded pragmas, Allman/brace-init, SOLID, const-correct. Canonical: AGENTS.md." -applyTo: "**/*.{hpp,cpp,h}" ---- - -# Robotics Toolbox C++ Rules - -This project is a robotics algorithms library (manipulator kinematics, dynamics, trajectories and control today; mobile, aerial, legged and marine families planned) targeting resource-constrained embedded systems. It consumes the shared numerical primitives (`math`, `solvers`, …) from numerical-toolbox-cpp via FetchContent. Follow these rules strictly. - -## Memory — No Heap Allocation - -Never use `new`, `delete`, `malloc`, `free`, `std::make_unique`, or `std::make_shared`. - -Replace standard containers: -- `std::vector` → `infra::BoundedVector::WithMaxSize` -- `std::string` → `infra::BoundedString::WithStorage` -- `std::deque` → `infra::BoundedDeque::WithMaxSize` -- `std::list` → `infra::BoundedList::WithMaxSize` -- Use `std::array` for fixed-size arrays -- Use `std::optional` for optional values -- No recursion — stack usage must be predictable - -## Numeric Types — Float-Only - -Write generic `template` with -`static_assert(std::is_floating_point_v, "...")`, and **instantiate/test `float` only**. -Do not implement `Q15`/`Q31` — the generic `T` keeps that a cheap future add. -Use `std::numbers::pi_v` — never hardcode `3.14159265f`. - -## Embedded Optimizations - -Never use `#pragma GCC optimize` or the `optimize` attribute. GCC does not inline a callee whose optimization options differ from its caller's, so options set per header or per function turn every small helper on a hot path into an out-of-line call. Optimization level and floating-point flags are the consumer's, applied to whole translation units (embedded: `-O2`/`-O3` with `-ffast-math -fno-finite-math-only`). - -Apply `OPTIMIZE_FOR_SPEED` (from `numerical/math/CompilerOptimizations.hpp`) on hot-path methods: `Compute()`, `Filter()`, `Calculate()`, `Solve()`, `Update()`, `Step()`. It forces inlining when `NumericalToolbox_ENABLE_OPTIMIZATIONS` is defined and expands to nothing otherwise. - -Use `math::IsFinite` for finiteness checks: a consumer may still build with `-ffinite-math-only`. - -## Naming - -- Classes/Methods: `PascalCase` (e.g., `ForwardKinematics`, `Compute()`) -- Member variables: `camelCase` (e.g., `sampleRate`, `coefficients`) -- Namespaces: lowercase (`kinematics`, `dynamics`, `trajectory`, `math`) -- Template parameters: descriptive (`typename T`, `std::size_t Order`) - -## Style - -- Allman braces (opening brace on new line), 4-space indent -- Functions ~30 lines max (hard limit ~50) -- Self-documenting code — avoid unnecessary comments -- `const` on all non-mutating methods, `constexpr` where possible -- Fixed-size types: `uint8_t`, `int32_t`, etc. -- **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. - -## Design - -- SOLID principles — constructor injection, depend on abstractions -- DRY — extract shared logic into helpers or templates -- RAII for resource management -- **Protected, non-virtual interface destructors**: declare `~Interface() = default` in a `protected:` section, - never `virtual ~Interface()` (defaulted or `= 0`). A virtual destructor puts a deleting destructor in every - implementation's vtable, which links `operator delete` (and with it `malloc`/`free`) into heap-free firmware, and - under multiple inheritance adds a thunk per base. The protected destructor makes deletion through an interface - pointer a compile error. Concrete classes declare no destructor unless they need one, and callers hold the - concrete type rather than a `std::unique_ptr` to the interface. -- No virtual calls in ISR-callable or real-time critical paths - -## Documentation — MANDATORY - -For every algorithm added or modified, update the corresponding `doc/{domain}/{AlgorithmName}.md` file. Follow `doc/TEMPLATE.md` exactly. -Documentation is **design-first**: cover mathematical background, algorithm behaviour, complexity, pitfalls, and connections. -Do **not** include implementation details, class names, template parameters, or usage code examples — docs describe the algorithm design; code follows from it. - -Canonical rules: [AGENTS.md](../../AGENTS.md). diff --git a/.github/instructions/testing.instructions.md b/.github/instructions/testing.instructions.md deleted file mode 100644 index c69313d..0000000 --- a/.github/instructions/testing.instructions.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -description: "Robotics Toolbox testing (float-only): TEST_F on float, StrictMock only, anonymous-namespace fixtures, no plain TEST(), no redundant cases, Arrange-Act-Assert. Canonical: AGENTS.md." -applyTo: "**/test/**" ---- - -# Robotics Toolbox Testing Guidelines - -## File Structure - -- Test files: `robotics/{domain}/test/Test{ComponentName}.cpp` -- CMake: tests added via `add_subdirectory(test)` with standard test target patterns - -## Framework - -- GoogleTest for assertions — **`TEST_F` on `float`** (no `TYPED_TEST`, no multi-type) -- GoogleMock (`testing::StrictMock<>`) only when needed -- No heap allocation in tests — same rules as production code -- **NEVER use plain `TEST()` macro** — cppcheck reports `syntaxError` - -## Fixture Test Pattern (float) - -```cpp -#include "robotics/kinematics/ForwardKinematics.hpp" -#include "numerical/math/Tolerance.hpp" -#include - -namespace -{ - class TestForwardKinematics - : public ::testing::Test - { - protected: - kinematics::ForwardKinematics fk{ math::Vector{ 0.8f, 0.0f, 0.0f } }; - }; -} - -TEST_F(TestForwardKinematics, elbow_at_ninety_degrees_places_tool_above_elbow) -{ - // Arrange, Act, Assert — EXPECT_NEAR(actual, expected, math::Tolerance()) -} -``` - -## Rules - -- Fixture class and type aliases go inside anonymous `namespace {}` -- `TEST_F` macros go **outside** the anonymous namespace -- Include `` (not ``) unless gmock matchers are needed -- Use `testing::StrictMock` for strict mock expectations -- **ONLY `StrictMock`**: Never use `testing::NiceMock<>` or bare mock instantiation — `NiceMock` silences unexpected-call warnings, masking test gaps; `StrictMock` enforces all interactions explicitly -- Test `float` only (single type) — no multi-type tests -- **No redundant tests** — implement exactly the spec's enumerated cases; no overlapping/extra cases -- Test numerical accuracy against known reference values (not just "doesn't crash") -- Pick the properties to assert from [`TESTING.md`](../../TESTING.md) — the per-family metric reference (accuracy, frequency/transient response, stability, boundaries, convergence, statistical consistency, conditioning) -- Test genuine edge cases (zero input, extreme values) without duplicating coverage -- One behavior per test — keep tests focused -- Use descriptive test names that explain the scenario -- Allman brace style and PascalCase naming apply to test code too - -## TDD Approach - -- **Clarify requirements first**: Before writing any code, define and document all use cases, inputs, outputs, and edge cases as test cases -- **Write tests before implementation**: Tests define the expected behavior; implementation exists only to satisfy the tests -- **Red-Green-Refactor cycle**: Write a failing test, make it pass with minimal code, then refactor while keeping tests green - -## Coverage for Template Code - -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): - -```cpp -#ifdef ROBOTICS_TOOLBOX_COVERAGE_BUILD -extern template class ForwardKinematics; -#endif -``` - -And in the matching `.cpp` file: - -```cpp -#include "robotics/kinematics/ForwardKinematics.hpp" - -namespace kinematics -{ - template class ForwardKinematics; -} -``` diff --git a/.github/prompts/orchestrate.prompt.md b/.github/prompts/orchestrate.prompt.md deleted file mode 100644 index 0e9555d..0000000 --- a/.github/prompts/orchestrate.prompt.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -description: "Start an orchestrated plan-execute-review workflow for a robotics-toolbox development task. Routes through planning (Claude Opus 4.6), implementation, and code review stages with handoff buttons between each step." -agent: "orchestrator" -argument-hint: "Describe the algorithm, feature, bug fix, or change you want to implement" -model: "Claude Sonnet 4.6" ---- - -# Orchestrate - -Analyze the following task for the **robotics-toolbox** project — a robotics algorithms library (manipulator kinematics, dynamics, trajectories and control today; mobile, aerial, legged and marine families planned) targeting resource-constrained embedded systems, consuming shared numerical primitives from numerical-toolbox-cpp via FetchContent. -Gather relevant context from the codebase — identify affected modules, existing patterns, the float-only numeric policy, and documentation requirements. -Then provide a brief scope summary and use the handoff buttons to route to the appropriate specialist: - -- **Plan Implementation**: For complex tasks needing detailed upfront design (new algorithms, architectural changes, multi-file modifications) -- **Execute Directly**: For straightforward changes with a clear path (bug fixes, small improvements) -- **Review Code**: For reviewing existing or recently changed code against project standards - -Task to orchestrate: diff --git a/.github/prompts/unit-test.prompt.md b/.github/prompts/unit-test.prompt.md deleted file mode 100644 index dc46e33..0000000 --- a/.github/prompts/unit-test.prompt.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -description: "Author metric-driven unit tests for one robotics/ algorithm — TEST_F on float, no heap, StrictMock, reference-value assertions selected per family from TESTING.md." -agent: "unit-tester" -argument-hint: "Name the robotics/ algorithm to author unit tests for (e.g. Biquad, KalmanFilter, RungeKuttaIntegrators)" -model: "Claude Sonnet 5" ---- - -# Unit Test - -Author (or extend) the unit tests for the named **robotics-toolbox** algorithm in -`robotics//test/Test.cpp`. Follow the `unit-tester` workflow: read the algorithm's -public interface and doc; look up its family in `TESTING.md` and select the metric -types to assert (accuracy, frequency/transient response, stability, boundaries, invariants, -convergence, statistical consistency, conditioning); write one `TEST_F` on `float` per distinct -property against an independent reference value (`EXPECT_NEAR` + `math::Tolerance()`); wire -CMake; build, run, and report paths + pass/fail. Rules: `AGENTS.md` + -`.github/instructions/testing.instructions.md` (float-only, no heap, StrictMock, no redundant cases). - -Algorithm to cover: diff --git a/.github/workflows/agents.yml b/.github/workflows/agents.yml new file mode 100644 index 0000000..cbaabc0 --- /dev/null +++ b/.github/workflows/agents.yml @@ -0,0 +1,5 @@ +name: Agent Rules +on: [pull_request] +jobs: + agents: + uses: embedded-pro/embedded-agent-kit/.github/workflows/verify-consumer.yml@main diff --git a/AGENTS.md b/AGENTS.md index ffee2f3..a6ebbb8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,103 +1,122 @@ -# Robotics Toolbox — Agent Rules (canonical) +# robotics-toolbox-cpp — Agent Rules -Single source of truth for **Claude and Copilot**. `CLAUDE.md` and -`.github/copilot-instructions.md` point here. Code-file specifics load on demand from -`.github/instructions/`. Deployment recipe: `roadmap/DEPLOYMENT.md`. + +Canonical rules for Claude, Copilot and sub-agents. Sections marked *(shared)* come from embedded-pro/embedded-agent-kit: +edit them there, not here. *(repo)* sections belong to this repository. *Exceptions* overrides a shared rule. -Robotics algorithms library for resource-constrained embedded systems: robot manipulators today -(kinematics, dynamics, trajectories, manipulator control); mobile, aerial, legged and marine families -are planned in `ROADMAP.md`. Real-time, deterministic, no heap. The shared numerical -primitives (`math`, `solvers`, …) are consumed from -[numerical-toolbox-cpp](https://github.com/embedded-pro/numerical-toolbox-cpp) via `FetchContent` -and included as `numerical//…`. +## Behaviour *(shared)* -## Numeric policy — FLOAT-ONLY (current) +- **Be as terse as possible.** No preamble, summary or narration. Report file paths and pass/fail. +- Everything you write — code, docs, agent files, PR text — uses the fewest words that stay unambiguous. +- Prose (docs, comments, agent files, commit and PR text) follows ASD-STE100 Simplified Technical English: + one word, one meaning; active voice; one instruction per sentence; sentences ≤ 20 words (procedures) or ≤ 25 (descriptions). +- Ambiguous request: ask. Clear request: act. +- Do only what was asked. No unrelated refactors, no extra features. +- Batch reads, don't re-read, prefer targeted edits. +- Never change a shared section. Add a deviation to *Exceptions* only when the user approves it. -- New algorithms are **float-only**. Write generic `template`, add - `static_assert(std::is_floating_point_v, "...")`, and **instantiate/test `float` only**. -- Do **NOT** implement `Q15`/`Q31` now. The generic `T` keeps a fixed-point specialisation cheap later. -- `std::numbers::pi_v` — never hardcode constants. +## Workflow *(shared)* -## Memory — no heap +1. Multi-file or architectural change: update the design document first. Get approval before you write code. +2. Read *Domain* and *Build*. Read each `.github/instructions/*.instructions.md` whose `applyTo` matches a file you change. +3. Find the nearest existing pattern. Follow it. +4. Per behaviour: write a failing test, write the minimum code that passes it, refactor with all tests green. +5. Add each new file to its `CMakeLists.txt`. +6. Update the documentation for each behavioural change. +7. Run the *Build* commands until build and tests pass. Never disable, skip or weaken a test to get green. +8. Non-trivial change: run the `reviewer` agent, or ask the user to run it. Fix each CRITICAL and WARNING finding. +9. Report changed files, build pass/fail, test pass/fail. + +## Memory *(shared)* + +Scope: production code. Tests and host tools may use the heap. - Forbidden: `new`/`delete`/`malloc`/`free`, `make_unique`/`make_shared`, - `std::vector`/`string`/`deque`/`list`/`map`/`set`. + `std::vector`/`string`/`deque`/`list`/`map`/`set`, recursion. - Use: `infra::BoundedVector::WithMaxSize`, `infra::BoundedString::WithStorage`, - `infra::BoundedDeque::WithMaxSize`, `infra::BoundedList::WithMaxSize`, - `std::array`, `std::optional`. Stack/static only. No recursion. **Tests too.** - -## Embedded optimizations - -- **No `#pragma GCC optimize` and no `optimize` attribute**, in headers or sources. GCC does not - inline a callee whose optimization options differ from its caller's, so options set per header or - per function turn every small helper on a hot path into an out-of-line call; an unscoped pragma in - a header also leaks fast-math into every including translation unit. -- The optimization level and floating-point model belong to the consumer and apply to whole - translation units. For embedded targets: `-O2` or `-O3` with `-ffast-math -fno-finite-math-only`. -- `OPTIMIZE_FOR_SPEED` (from `numerical/math/CompilerOptimizations.hpp`) on hot paths - (`Filter/Compute/Update/Solve/Step`). Pure interfaces exempt. With - `NumericalToolbox_ENABLE_OPTIMIZATIONS` it forces inlining (`always_inline`, `hot`, `inline`); - without it, it expands to nothing. -- Use `math::IsFinite` for finiteness checks: a consumer may still build with `-ffinite-math-only`. - -## Style - -- Allman braces, 4-space indent, `.clang-format` authoritative. -- Brace-init `{}` everywhere. PascalCase types/methods, camelCase members, lowercase namespaces. -- Functions ≤ ~30 lines. `const`/`constexpr`-correct. Fixed-width ints. Full descriptive names. -- **No comments** except license headers, `NOLINT`, and a brief note on genuinely non-obvious math. - -## Interfaces & errors - -- Interfaces = pure virtual classes with a `protected:`, non-virtual `~I() = default` — **never** a `virtual` or `= 0` destructor. A virtual one puts a deleting destructor in every vtable, which links `operator delete`/`free` into heap-free firmware. -- Concrete classes declare no destructor unless they need one. Never own or delete through an interface pointer (no `std::unique_ptr`): hold the concrete type, pass `I&`. -- No exceptions. Use `std::optional` or status enums. `assert`/`really_assert` for preconditions. -- SOLID + DIP: constructor injection; depend on abstractions. RAII. No virtual calls in real-time paths. - -## Namespaces - -`dynamics`, `kinematics`, and new: `trajectory`, `controllers` (manipulator control). Planned by the -roadmap families: `mobile`, `aerial`, `legged`, `marine`, `grasping`, `planning`, `localization`, -`calibration`, `safety`. Shared primitives keep their upstream namespaces (`math`, `solvers`, …) from -numerical-toolbox; generic algorithms belong there, not here. - -## Kinematics & dynamics conventions - -- 6-vectors are ordered **linear part first**: twists `(v; ω)`, wrenches `(f; n)`; the geometric - Jacobian has linear rows first (upstream `math::SE3Transform`, roadmap NT53/M8). Featherstone `(ω; v)` ordering stays internal to the - recursive dynamics algorithms. -- Orientation errors use the SE(3) logarithm (`PoseError`), never angle subtraction. -- The tool frame and the base mounting offset are explicit kinematic parameters — never derived from a - center of mass. -- Controllers receive dynamics and Jacobians through small interfaces (`EulerLagrangeDynamics`, - `InverseDynamicsModel`, `JacobianProvider`); hard real-time code may bind the concrete types instead. -- Spatial fixtures in tests must exercise non-parallel axes and gravity across the joint axes. - -## Testing - -- GoogleTest. **`TEST_F` on `float`** — no `TYPED_TEST`, no multi-type. **Never plain `TEST()`**. -- **`StrictMock` only** (no `NiceMock`/bare). Fixture + aliases in an anonymous namespace; macros outside it. -- **No redundant tests** — implement exactly the spec's enumerated cases, one behavior per test, - Arrange/Act/Assert, `EXPECT_NEAR` + `math::Tolerance()`. No heap. -- **Coverage ≥ 90 %** — measured by SonarQube. Every new algorithm must reach this threshold - before merge; CI fails below it. - -## CMake (robotics/ targets) - -- `robotics_add_header_library()`, `robotics_add_coverage_sources( .cpp)`, - `${ROBOTICS_VISIBILITY}`. -- Coverage `.cpp`: `template class ;`. `extern template` guarded by - `#ifdef ROBOTICS_TOOLBOX_COVERAGE_BUILD`. - -## Docs - -Design-first `doc//.md` per `doc/TEMPLATE.md`. Math/theory/complexity/pitfalls — -no code, no class names, no usage examples. Update `doc//README.md` when adding a new algorithm. - -## Assistant behavior — be terse - -- Minimal prose. No preamble/postamble, no restating the plan, no summaries unless asked. -- Report results as file paths + pass/fail. Don't narrate routine tool calls. -- Don't re-read files already read; batch reads; prefer targeted edits. -- Build: `cmake --preset host && cmake --build --preset host` · Test: `ctest --preset host` - (the `host` preset builds the Qt simulator; without Qt6 use the `host-single-Debug` presets). + `infra::BoundedDeque`, `infra::BoundedList`/`IntrusiveList`, `std::array`, `std::optional`, `std::variant`. + +## Interfaces & errors *(shared)* + +- No virtual destructors: each adds a deleting destructor and thunks to flash. + Interface = pure virtual methods + `protected: ~I() = default;` (non-virtual). +- Public `virtual ~Base() = default;` only on a base destroyed through a base pointer: + `delete`/`std::unique_ptr`, `infra::PolymorphicVariant`, `infra::OptionalForPolymorphicObjects`. + Put it on that base, not on every interface. +- Not needed for `std::variant`, `std::optional`, `infra::SharedPtr`: they destroy the concrete type. +- No exceptions. `std::optional`, `bool` or status enum; `really_assert` for preconditions. Never swallow an error. +- Constructor injection; no global state. + +## Optimisation *(shared)* + +- No `#pragma GCC optimize`, no `optimize` attribute: GCC won't inline across differing options. + The consumer sets flags per translation unit. +- `OPTIMIZE_FOR_SPEED` only on hot functions defined in a header. +- Hot paths: no heap, no virtual dispatch, no blocking. + +## Style *(shared)* + +- `.clang-format` is authoritative. Allman, 4 spaces, `{}` init. +- PascalCase types/methods; camelCase members and enum values; lowercase namespaces. + No `I` prefix; implementations end in `Impl`. +- `#pragma once` only. +- Fixed-width integers. `const`/`constexpr`-correct. Functions ≤ 30 lines (hard limit 50). +- Comments: non-obvious *why* only, one line. No `TODO`/`FIXME`, commented-out code, or restating the code. + Fix or delete a comment the change makes stale. + +## Testing *(shared)* + +- `TEST_F` for fixtures, `TYPED_TEST` for types, plain `TEST()` for stateless checks. +- `StrictMock` only. `EXPECT_NEAR` with explicit tolerance. Fixture in an anonymous namespace, macros outside. +- Heap allowed in tests. + +## Documentation *(shared)* + +- Update docs before or with any behavioural change. +- One fact, one place: link, never restate. +- Visuals: Mermaid or ASCII. + + +## Domain *(repo)* + +- Robotics algorithms for embedded targets: manipulator kinematics, dynamics, trajectories and control. + `ROADMAP.md` lists the planned families (mobile, aerial, legged, marine). +- Source root: `robotics/`. Namespaces: `kinematics`, `dynamics`, `trajectory`, `controllers`. + Planned: `mobile`, `aerial`, `legged`, `marine`, `grasping`, `planning`, `localization`, `calibration`, `safety`. +- `math`, `solvers` and other shared primitives come from numerical-toolbox-cpp through `FetchContent`, included as + `numerical//…`. A generic algorithm goes there, not here. +- `simulator/` is a host-only Qt tool. *Memory* does not apply to it. +- Float only: `template` with `static_assert(std::is_floating_point_v)`. Instantiate and test `float`. + No `Q15`/`Q31`. Use `std::numbers::pi_v`, never a literal. +- `OPTIMIZE_FOR_SPEED` on `Compute`, `Filter`, `Calculate`, `Solve`, `Update` and `Step`. Embedded consumers build + with `-O2`/`-O3 -ffast-math -fno-finite-math-only`; check finiteness with `math::IsFinite`. +- Hold the concrete type and pass `I&`. Never own an object through an interface pointer. +- 6-vectors put the linear part first: twists `(v; ω)`, wrenches `(f; n)`, Jacobian linear rows first. + Featherstone `(ω; v)` order stays inside the recursive dynamics algorithms. +- Orientation error: SE(3) logarithm (`PoseError`), never angle subtraction. +- Tool frame and base mounting offset are explicit kinematic parameters, never derived from a center of mass. +- Controllers get dynamics and Jacobians through small interfaces (`EulerLagrangeDynamics`, `InverseDynamicsModel`, + `JacobianProvider`). Hard real-time code may bind the concrete types. +- Tests: `TEST_F` on `float`, no `TYPED_TEST`. `EXPECT_NEAR` with `math::Tolerance()`. Exactly the cases of + the spec. Spatial fixtures use non-parallel axes and gravity across the joint axes. Properties to assert: + `TESTING.md`. Coverage ≥ 90 % (SonarQube gate). +- CMake: `robotics_add_header_library()`, `robotics_add_coverage_sources( .cpp)`, + `${ROBOTICS_VISIBILITY}`. Coverage `.cpp`: `template class ;`; header bottom: + `extern template` inside `#ifdef ROBOTICS_TOOLBOX_COVERAGE_BUILD`. +- Docs: design-first `doc//.md` per `doc/TEMPLATE.md`: math, behaviour, complexity, pitfalls. + No code, class names or usage. Add new algorithms to `doc//README.md`. +- Deploy a roadmap spec: `roadmap/DEPLOYMENT.md` (`algo-implementer` skill). Write tests: `unit-tester` skill. + Bring an old algorithm up to date: `modernizer` agent. + +## Build *(repo)* + +```bash +cmake --preset host && cmake --build --preset host +ctest --preset host +``` + +`host` builds the Qt simulator. Without Qt6, use the `host-single-Debug` configure, build and test presets. + +## Exceptions *(repo)* + +- No plain `TEST()`: MegaLinter's cppcheck reports a syntax error on it. Use `TEST_F`. diff --git a/CLAUDE.md b/CLAUDE.md index e5c68c4..43c994c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,14 +1 @@ -# Robotics Toolbox — Claude Instructions - -Canonical rules: **[AGENTS.md](AGENTS.md)** (shared with Copilot). -Code-file specifics: `.github/instructions/`. Deployment recipe: `roadmap/DEPLOYMENT.md`. -Shared numerical primitives come from numerical-toolbox-cpp via FetchContent (`numerical/…` includes). - -Essentials (full detail in AGENTS.md): -- **No heap** — bounded containers / `std::array` / `std::optional`; no recursion; tests too. -- **Float-only** — generic `template` + `static_assert(std::is_floating_point_v)`; instantiate/test `float`; no Q15/Q31. -- **Embedded** — no `#pragma GCC optimize` / `optimize` attribute (they block inlining); the consumer sets optimization flags per TU; `OPTIMIZE_FOR_SPEED` (forced inlining) on hot paths. -- **No comments** (except license/NOLINT). Allman braces, brace-init, PascalCase/camelCase. -- **Tests** — `TEST_F` on `float`, `StrictMock` only, never plain `TEST()`, no redundant cases. -- **No exceptions** — `std::optional`/status enums; interfaces get a `protected:` non-virtual `~I() = default`, never a virtual destructor. -- **Be terse** — minimal prose; report file paths + pass/fail. +@AGENTS.md diff --git a/README.md b/README.md index 3133544..39ecb75 100644 --- a/README.md +++ b/README.md @@ -89,10 +89,9 @@ under [roadmap/](roadmap/README.md); generic algorithms go to numerical-toolbox- ## Testing Every algorithm is validated against the **mathematical invariants of its family** — not golden -output. Tests are `TEST_F` on `float`, no heap, one behaviour per test, asserted against independent +output. Tests are `TEST_F` on `float`, one behaviour per test, asserted against independent reference values. The per-family metric strategy is documented in **[TESTING.md](TESTING.md)**; -framework rules live in -[.github/instructions/testing.instructions.md](.github/instructions/testing.instructions.md). +framework rules live in [AGENTS.md](AGENTS.md). Build & test locally: diff --git a/TESTING.md b/TESTING.md index 9d491f2..c18ca4e 100644 --- a/TESTING.md +++ b/TESTING.md @@ -1,7 +1,7 @@ # Testing Strategy — Algorithm Metrics The library's test strategy: every algorithm is validated against the **mathematical invariants of -its family**, not golden output. This is the reference for the `unit-tester` agent (and humans) when +its family**, not golden output. This is the reference for the `unit-tester` skill (and humans) when writing **unit tests** for `robotics/`. It answers one question per algorithm: *which mathematical properties must a correct implementation satisfy, and how do we assert them?* @@ -18,8 +18,8 @@ kinematics needs geometric/round-trip metrics, dynamics needs cross-method and c trajectories need boundary/limit metrics, controllers need closed-loop metrics. Without this, tests drift toward shallow "golden output" snapshots that pass while the math is wrong. -Canonical rules still apply ([AGENTS.md](AGENTS.md), [testing.instructions.md](.github/instructions/testing.instructions.md)): -`TEST_F` on `float`, one behaviour per test, no redundant cases, **no heap in tests**, assert with +Canonical rules still apply ([AGENTS.md](AGENTS.md)): +`TEST_F` on `float`, one behaviour per test, no redundant cases, assert with `EXPECT_NEAR` + `math::Tolerance()` against reference values. ## How the agent uses this