Generate a structured implementation contract before making any code changes to FastLED. Defines scope, affected files, API changes, platform impact, risk assessment, and test plan. Use before implementing any feature, bug fix, driver addition, or refactoring.
Generate an implementation contract for a FastLED change. The contract must be reviewed before any code is written.
$ARGUMENTS
FastLED runs on 100+ microcontroller platforms. A change that seems simple can break:
The contract documents what changes, what risks exist, and how to prove it works — before a line of code is written.
Determine:
Document:
For each affected area, evaluate impact:
| Platform Area | Impact | Notes |
|---|---|---|
| AVR (Arduino Uno/Mega/Nano) | [None/Low/Med/High] | RAM-constrained, no FPU |
| ESP32 (all variants) | [None/Low/Med/High] | RMT/I2S/SPI/PARLIO drivers |
| Teensy (3.x, 4.x) | [None/Low/Med/High] | ARM Cortex-M, bitbang & DMA |
| RP2040 (Raspberry Pi Pico) | [None/Low/Med/High] | PIO-based drivers |
| STM32 | [None/Low/Med/High] | HAL dependencies |
| WASM (web browser target) | [None/Low/Med/High] | Emulation only |
| nRF52 | [None/Low/Med/High] | BLE coexistence |
Evaluate each risk category:
Timing Risks (critical for LED protocols):
API Compatibility Risks:
Memory Risks:
Concurrency Risks (ESP32 / RTOS platforms):
Build System Risks:
Specify the test layers that apply:
| Layer | Applies | Tests |
|---|---|---|
Host unit tests (bash test) | Always | Logic, math, data structures |
WASM compile check (bash compile wasm) | Always | Catches most compile errors |
Platform compile (bash compile <platform>) | If driver code | Catches platform-specific errors |
Hardware validation (bash autoresearch) | If driver or timing change | Only definitive proof for LED output |
List specific test cases:
Document:
# Implementation Contract: [Title]
## Change Summary
[One-paragraph description of what changes and why]
## Non-Goals
- [What this explicitly does NOT include]
## Affected Files
| File | Action | Description |
|------|--------|-------------|
| src/platforms/esp/32/foo.h | MODIFY | [What changes] |
| src/fl/bar.h | CREATE | [Purpose] |
## APIs Touched
- `FastLED.addLeds<...>()` — [How it changes, if at all]
- `CRGB` — [Impact]
## Platform Impact
| Platform | Impact | Rationale |
|---------|--------|-----------|
| AVR | None | No new code on AVR path |
| ESP32 | High | New RMT encoder implementation |
| ... | ... | ... |
## Risk Assessment
### Timing: [LOW / MED / HIGH]
[Details — will LED protocols still work?]
### API Compatibility: [LOW / MED / HIGH]
[Details — will existing user code still compile and run?]
### Memory: [LOW / MED / HIGH]
[Details — RAM/flash impact, especially for AVR]
### Concurrency: [LOW / MED / HIGH]
[Details — ISR safety, DMA lifetime, task interaction]
### Build System: [LOW / MED / HIGH]
[Details — meson.build, guards, new dependencies]
## Test Plan
- [ ] Host unit test: [test name / description]
- [ ] WASM compile: `bash compile wasm --examples Blink`
- [ ] Platform compile: `bash compile <platform>`
- [ ] Hardware validation: [specific test on which board]
- [ ] Regression: `bash test --cpp` — all existing tests pass
## Rollback Strategy
[Steps to safely revert this change]
## Acceptance Criteria
- [ ] [Specific, measurable criterion]
- [ ] All platform compiles pass
- [ ] No regressions in host test suite
- [ ] [Hardware test evidence if applicable]
Good: "WS2812 output on ESP32 shows correct colors at 1000 LEDs without flicker, confirmed by hardware observation" Bad: "It works"
Good: "All existing host tests pass with bash test --cpp"
Bad: "Tests pass"
Good: "Sketch compiles on Arduino IDE 2.x with no warnings" Bad: "Compiles somewhere"