Skip to content

feat(fullstack): R1 STA/LTA cross-validation via SIL pipeline - #365

Merged
GiZano merged 4 commits into
mainfrom
research/r1
Aug 6, 2026
Merged

feat(fullstack): R1 STA/LTA cross-validation via SIL pipeline#365
GiZano merged 4 commits into
mainfrom
research/r1

Conversation

@GiZano

@GiZano GiZano commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Summary

Implements ROADMAP R1 (Scientific Validation / SIL): Software-in-the-Loop cross-validation of the STA/LTA detection core using the exact same C++ code as the ESP32 firmware.

What's included

  • Pure-C++ STA/LTA core isolated in firmware/src/DetectionCore.h — no Arduino/FreeRTOS/I2C calls, shared 100% between firmware and host
  • Firmware refactor: main.cpp sensorTask now uses the shared core; dead ALPHA_STA/ALPHA_LTA constants removed
  • Host CLI firmware/tools/detect_cli.cpp for native SIL replay (subprocess bridge)
  • research/ Python orchestrator:
    • orchestrator.py — compiles & drives the C++ CLI (sole Python↔C++ bridge)
    • metrics.py — Sensitivity/Recall, False-Alarm Rate, latency, ROC
    • calibrate.py — sweep TRIGGER_RATIO × NOISE_FLOOR, maximize F1
    • fetch_itaca.py — graceful degradation: real ITACA/ESM path (token-gated) or realistic synthetic fallback
    • synthetic.py, plot_roc.py, calibrate_io.py, README, requirements
  • CI (iot-ci.yml): native core + CLI build, synthetic smoke test
  • Docs: R1 marked implemented; added v2.2.0 and Future Horizon (Kubernetes + Terraform IaC)

Verification

  • Native C++ unit tests: PASSED
  • pio run: Flash 78.8% / RAM 12.7% SUCCESS
  • End-to-end calibration on synthetic fallback: sensitivity 1.000, FAR 0.000

Notes

  • Real ITACA waveform download is token-gated (registration portal currently unavailable); the real path is an explicit failing stub, synthetic fallback is default.
  • ITACA is CC-BY-NC-ND 4.0: only aggregate results will be published; the Zenodo dataset will be the QuakeGuard MEMS Dataset (own IP).

- Extract pure-C++ STA/LTA core into DetectionCore.h (shared firmware/host)
- Refactor main.cpp sensorTask onto the shared core
- Add native host CLI (detect_cli) for SIL replay
- Add research/ Python orchestrator: metrics, calibration sweep, ROC plot,
  graceful-degradation ITACA fetcher (real token path + realistic synthetic)
- Extend iot-ci with native core + CLI build and synthetic smoke test
- Mark R1 implemented in ROADMAP/README; add v2.2.0 and Future Horizon (K8s/Terraform)
@GiZano
GiZano requested a review from riccardo0731 as a code owner August 6, 2026 14:45
@GiZano GiZano changed the title feat(research): R1 STA/LTA cross-validation via SIL pipeline feat(fullstack): R1 STA/LTA cross-validation via SIL pipeline Aug 6, 2026
GiZano added 3 commits August 6, 2026 17:00
- DetectionCore.h: explicit constructor + member init list (S1709/S3230)
- detect_cli.cpp: std::string/std::getline, dedicated declarations, auto (S5945/S1659/S5827)
- calibrate.py: math.isclose for float equality (S1244)
- calibrate_io.py/fetch_itaca.py/calibrate.py/plot_roc.py: path-injection guard resolve_within_root (S8707)
- fetch_itaca.py: drop unused param, int-typed main (S1172/S5886/S3699/S1135)
- ci: run SIL smoke test inside gitignored research/out (respects path guard)
- DetectionCore.h: drop redundant ctor init list (members use in-class initializers) (S3230)
- detect_cli.cpp: use auto for derived type (S5827)
@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

@GiZano
GiZano merged commit 55e5671 into main Aug 6, 2026
8 of 9 checks passed
@GiZano
GiZano deleted the research/r1 branch August 6, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant