From 5f517ae82b95c1988d6c07e888194dcc28e02ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20SAILLANT?= <108685187+electron-rare@users.noreply.github.com> Date: Sat, 21 Feb 2026 19:24:09 +0100 Subject: [PATCH 1/4] fix(ai): guard chip mismatch env fallback on unstable USB (#12) --- tools/ai/zeroclaw_hw_firmware_loop.sh | 81 +++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/tools/ai/zeroclaw_hw_firmware_loop.sh b/tools/ai/zeroclaw_hw_firmware_loop.sh index e5751a6..03f46fb 100755 --- a/tools/ai/zeroclaw_hw_firmware_loop.sh +++ b/tools/ai/zeroclaw_hw_firmware_loop.sh @@ -11,6 +11,9 @@ RTC_ENV_DEFAULT="${ZEROCLAW_RTC_PIO_ENV:-esp32dev}" ZACUS_ENV_DEFAULT="${ZEROCLAW_ZACUS_PIO_ENV:-esp32dev}" MONITOR_SECS_DEFAULT="${ZEROCLAW_MONITOR_SECS:-60}" BAUD_DEFAULT="${ZEROCLAW_SERIAL_BAUD:-115200}" +ZEROCLAW_CHIP_MISMATCH_FALLBACK="${ZEROCLAW_CHIP_MISMATCH_FALLBACK:-1}" +ZEROCLAW_USB_STABILITY_SAMPLES="${ZEROCLAW_USB_STABILITY_SAMPLES:-2}" +ZEROCLAW_USB_STABILITY_DELAY="${ZEROCLAW_USB_STABILITY_DELAY:-1}" usage() { cat </dev/null || true)"; then + return 1 + fi + if [[ "$i" -eq 0 ]]; then + last_sig="$sig" + elif [[ "$sig" != "$last_sig" ]]; then + return 1 + fi + ((i++)) + if (( i < samples )); then + sleep "$delay_secs" + fi + done + return 0 +} + if ! env_exists "$ENV_NAME"; then echo "[fail] invalid PlatformIO env '${ENV_NAME}' for $target." >&2 echo "[info] valid envs:" >&2 @@ -219,6 +278,24 @@ resolve_env_fallback() { return 1 } +can_use_fallback_on_mismatch() { + local failed_env="$1" + local fallback_env="$2" + + if [[ "${ZEROCLAW_CHIP_MISMATCH_FALLBACK}" != "1" ]]; then + echo "[warn] chip mismatch detected for $failed_env -> $fallback_env, but ZEROCLAW_CHIP_MISMATCH_FALLBACK=${ZEROCLAW_CHIP_MISMATCH_FALLBACK} (auto-fallback disabled)." + return 1 + fi + + if ! is_usb_port_stable "$PORT" "$ZEROCLAW_USB_STABILITY_SAMPLES" "$ZEROCLAW_USB_STABILITY_DELAY"; then + echo "[warn] chip mismatch detected for $failed_env but serial port is unstable (flapping signature on $PORT)." + echo "[hint] Retry with a stable USB link or set ZEROCLAW_USB_STABILITY_SAMPLES=1 after manual validation." + return 1 + fi + + return 0 +} + UPLOAD_ARGS=() MONITOR_ARGS=() if [[ -n "$PORT" ]]; then @@ -240,6 +317,10 @@ UPLOAD_LAST_OUTPUT="" if ! upload_once "$ACTIVE_ENV"; then fallback_env="$(resolve_env_fallback "$ACTIVE_ENV" "$UPLOAD_LAST_OUTPUT" || true)" if [[ -n "$fallback_env" ]]; then + if ! can_use_fallback_on_mismatch "$ACTIVE_ENV" "$fallback_env"; then + echo "[fail] upload skipped fallback for retry due to unstable link or disabled policy." + exit 3 + fi echo "[warn] detected chip/env mismatch for $ACTIVE_ENV; retrying with '$fallback_env'." ACTIVE_ENV="$fallback_env" echo "[step] rebuild (fallback env)" -- 2.52.0 From d0d67307c294fde05bd95ac5dac8f43ce3e05c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20SAILLANT?= <108685187+electron-rare@users.noreply.github.com> Date: Sat, 21 Feb 2026 19:44:07 +0100 Subject: [PATCH 2/4] chore(specs): sync ai-agentic embedded specs with current Kill_LIFE task state --- ai-agentic-embedded-base/specs/04_tasks.md | 170 +++++++++++++++--- .../specs/zeroclaw_dual_hw_todo.md | 82 ++++++--- 2 files changed, 206 insertions(+), 46 deletions(-) diff --git a/ai-agentic-embedded-base/specs/04_tasks.md b/ai-agentic-embedded-base/specs/04_tasks.md index 6e18fa1..6d4eb29 100644 --- a/ai-agentic-embedded-base/specs/04_tasks.md +++ b/ai-agentic-embedded-base/specs/04_tasks.md @@ -1,28 +1,154 @@ -# Axe d’amélioration : badge & conformité +# Tasks autonomie locale (execution) -- Automatiser la génération, vérification et publication des badges (sécurité, SBOM, doc, qualité, communauté, coverage) -- Centraliser guides badge dans docs/badges/ -- Vérifier la fraîcheur des badges à chaque commit (timestamp ≥ commit) -- Inclure badges et rapports dans l’evidence pack -- Ajouter checklist badge en tête du README -- Documenter la politique badge & conformité (docs/COMPLIANCE.md) -- Planifier un audit badge à chaque release majeure +Last updated: 2026-02-21 -## Planification audit badge +Format: -- À chaque release majeure, exécuter un audit badge : - - Vérifier la couleur et l’actualisation de chaque badge - - Vérifier la présence des rapports JSON - - Vérifier l’inclusion dans l’evidence pack - - Documenter les résultats dans docs/badges/audit_.md -# Easter Egg musique concrète +- `[ ]` non fait +- `[x]` fait +- `AC` = acceptance criteria +- `Evidence` = fichier/commande de preuve -_« Les tâches sont des sons trouvés : chaque action, chaque gate, est une pièce du puzzle acousmatique. »_ — Pierre Schaeffer -# Tasks (Backlog exécutable) +## Sprint actuel -Format conseillé (copiable en GitHub Issues) : +- [x] T-001 - Merger la PR autonomie ZeroClaw + - AC: PR mergee sur `main`. + - Evidence: `https://github.com/electron-rare/Kill_LIFE/pull/5` -- [ ] T1 — ... - - AC: ... - - Evidence: ... -- [ ] T2 — ... +- [x] T-002 - Fermer ou merger la PR miroir restante + - AC: plus de PR redondante ouverte pour le meme scope. + - Evidence: `gh pr list --state open` + +- [x] T-003 - Configurer secret fallback OpenRouter local + - AC: `~/.zeroclaw/env` present avec `OPENROUTER_API_KEY` et mode `600`. + - Evidence: `ls -l ~/.zeroclaw/env` + +- [x] T-004 - Installer backend Prometheus local + - AC: commande `prometheus --version` disponible. + - Evidence: sortie shell `prometheus, version ...` + +- [x] T-005 - Stabiliser pairing bearer auto + - AC: `artifacts/zeroclaw/pair_token.txt` utilisable pour webhook sans override manuel. + - Evidence: `tools/ai/zeroclaw_webhook_send.sh --repo-hint rtc "pairing check"` + - Status: `2026-02-21` done (401 resolved + webhook HTTP 200 after provider/model auto-fix in stack bootstrap). + +- [x] T-006 - Activer fallback IA locale (macOS) + - AC: `ollama` installe, service actif, modele local disponible, stack capable de le preferer. + - Evidence: `tools/ai/ollama_local_setup.sh --no-pull --no-warmup` + config `default_provider = "ollama"`. + - Status: `2026-02-21` done (`llama3.2:1b` local); mode local est optionnel via `ZEROCLAW_PREFER_LOCAL_AI=1` pour garder la fiabilite webhook par defaut. + +- [x] T-007 - Renforcer mode local-only agentic (ZeroClaw + OpenClaw) + - AC: `tools/ai/zeroclaw_dual_chat.sh --local-only --provider-check` choisit un provider local (`ollama` ou `lmstudio`) sinon exit explicite. + - Evidence: sortie provider-check + `openclaw models status --plain`. + - Status: `2026-02-21` done (`openclaw` default model force sur `ollama/llama3.2:1b`, fallbacks `openai-codex` puis `openrouter`). + +- [x] T-008 - Scanner les options provider/agentic disponibles + - AC: rapport local avec statut runtime `openclaw/ollama/lmstudio/litellm` et matrice providers ZeroClaw. + - Evidence: `tools/ai/zeroclaw_provider_scan.sh --no-refresh` -> `artifacts/zeroclaw/provider_options.md`. + - Status: `2026-02-21` done. + +- [x] T-009 - Verrouiller le mapping matériel par cible + - AC: la détection automatique affecte `zacus` aux ports `usbmodem`/S3 et `rtc` à l’Audio Kit (pas d’interversion habituelle). + - Evidence: + - `ZEROCLAW_ZACUS_UPLOAD_PORT_HINT="1a86,usbmodem,ch340,freenove" tools/ai/zeroclaw_hw_firmware_loop.sh zacus --port '' --monitor-secs 5` + - `ZEROCLAW_RTC_UPLOAD_PORT_HINT="cp2102,10c4,esp32audiokit,audio" tools/ai/zeroclaw_hw_firmware_loop.sh rtc --port '' --monitor-secs 5` + - Status: `2026-02-21` done (`usbmodem` prioritaire pour zacus, `usbmodem` pénalisé pour rtc). + +## Boucle hardware RTC + +- [x] T-101 - Discover hardware RTC + - AC: au moins un port detecte pour carte RTC. + - Evidence: `tools/ai/zeroclaw_dual_chat.sh rtc --hardware` + +- [x] T-102 - Build firmware RTC + - AC: `pio run -e esp32dev` termine sans erreur bloquante. + - Evidence: logs build RTC. + - Status: `2026-02-21` done. + +- [x] T-103 - Upload + monitor RTC (forced default) + - AC: `pio run -e esp32dev -t upload` puis monitor 60s executes. + - Evidence: logs upload/monitor RTC. + - Status: `2026-02-21` done (`ESP32-D0WD-V3` flash + serial monitor output captured). + +- [x] T-104 - Trace webhook RTC + - AC: une ligne JSONL avec `repo_hint=rtc` apparait. + - Evidence: `artifacts/zeroclaw/conversations.jsonl` + - Status: `2026-02-21` done (`http_status=200`, `ok=true`). + +## Boucle hardware Zacus + +- [x] T-201 - Discover hardware Zacus + - AC: au moins un port detecte pour carte Zacus. + - Evidence: `tools/ai/zeroclaw_dual_chat.sh zacus --hardware` + +- [x] T-202 - Build firmware Zacus + - AC: `pio run -e esp32dev` (dans `hardware/firmware`) termine sans erreur bloquante. + - Evidence: logs build Zacus. + - Status: `2026-02-21` done. + +- [x] T-203 - Upload + monitor Zacus (forced default) + - AC: `pio run -e -t upload` puis monitor executes. + - Evidence: logs upload/monitor Zacus. + - Status: `2026-02-21` done (`ESP32-S3` detecte, env fallback `freenove_esp32s3`, flash + monitor OK). + +- [x] T-204 - Trace webhook Zacus + - AC: une ligne JSONL avec `repo_hint=zacus` apparait. + - Evidence: `artifacts/zeroclaw/conversations.jsonl` + - Status: `2026-02-21` done (`http_status=200`, `ok=true`). + +## Observabilite et cout + +- [x] T-301 - Stack endpoints smoke + - AC: `3000/health`, `8788`, `9090/-/ready` tous OK. + - Evidence: captures `curl`. + +- [x] T-302 - Dry-run webhook budget + - AC: `--dry-run` passe sans ecriture execution JSONL. + - Evidence: sortie script + diff JSONL. + - Status: `2026-02-21` done. + +- [x] T-303 - Quota call limiter + - AC: depassement quota bloque avec code non-zero. + - Evidence: message `[budget] hourly call limit reached`. + - Status: `2026-02-21` done (test sandbox local `max_calls=1`, second call blocked with exit 12). + +- [x] T-304 - Quota chars limiter + - AC: message trop long bloque avec code non-zero. + - Evidence: message `[budget] message length ... exceeds ...`. + - Status: `2026-02-21` done (`ZEROCLAW_WEBHOOK_MAX_CHARS=5`, exit 11). + +## Integrations Open WebUI + n8n + +- [x] T-401 - Ajouter API alerts + autotriage backend + - AC: endpoints `/api/alerts`, `/api/alerts/ack`, `/api/pr/autotriage` disponibles. + - Evidence: `tools/ai/zeroclaw_orchestrator_server.py`. + +- [x] T-402 - Etendre WebUI orchestrateur + - AC: panneau Alerts + Integrations status + action `PR autotriage now`. + - Evidence: `tools/ai/zeroclaw_stack_up.sh`. + +- [x] T-403 - Refactor Pipe Open WebUI en mapping mixte + - AC: pipe expose `zc.router` + modeles dedies et parsing `/run`/`/pr`. + - Evidence: `tools/ai/integrations/openwebui/zeroclaw_orchestrator_pipe.py`. + +- [x] T-404 - Ajouter workflow n8n PR autotriage + - AC: workflow avec Webhook + Cron fallback + alert/question outputs. + - Evidence: `tools/ai/integrations/n8n/zeroclaw_pr_autotriage_workflow.json`. + +- [x] T-405 - Ajouter provisioning local Docker integrations + - AC: compose + scripts `up/down/status` + import n8n + assist Open WebUI. + - Evidence: + - `tools/ai/integrations/docker/docker-compose.openwebui-n8n.yml` + - `tools/ai/zeroclaw_integrations_up.sh` + - `tools/ai/zeroclaw_integrations_down.sh` + - `tools/ai/zeroclaw_integrations_status.sh` + - `tools/ai/zeroclaw_integrations_import_n8n.sh` + - `tools/ai/zeroclaw_integrations_openwebui_assist.sh` + +## Definition of done + +- [x] Au moins une boucle complete RTC + Zacus executee en local. +- [x] Dashboard live exploitable pour suivi continu. +- [x] Prometheus disponible avec target gateway scrapee. +- [x] Logs et preuves archives dans `artifacts/zeroclaw/`. +- [x] Aucune commande documentee n'utilise `-e native` ou `-e test`. diff --git a/ai-agentic-embedded-base/specs/zeroclaw_dual_hw_todo.md b/ai-agentic-embedded-base/specs/zeroclaw_dual_hw_todo.md index 95aed68..d65e220 100644 --- a/ai-agentic-embedded-base/specs/zeroclaw_dual_hw_todo.md +++ b/ai-agentic-embedded-base/specs/zeroclaw_dual_hw_todo.md @@ -1,36 +1,70 @@ -# TODO: Dual Hardware Autonomy (RTC + Zacus) +# TODO: Dual hardware autonomy runbook (RTC + Zacus) Last updated: 2026-02-21 -## Phase A: Local Baseline +## Immediate now -- [ ] Run `tools/ai/zeroclaw_dual_bootstrap.sh` and capture hardware snapshot. -- [ ] Validate `tools/ai/zeroclaw_dual_chat.sh rtc -m ""`. -- [ ] Validate `tools/ai/zeroclaw_dual_chat.sh zacus -m ""`. -- [ ] Record detected ports and map preferred role per board. +- [x] I-001 - Merge autonomie stack into `main` (`PR #5`). +- [x] I-002 - Configure local secret file `~/.zeroclaw/env` (`OPENROUTER_API_KEY` placeholder + mode `600`). +- [x] I-003 - Ensure local Prometheus backend exists (`prometheus` binary installed). +- [x] I-004 - Resolve open mirror PR redundancy (`PR #7` merge/close decision). +- [x] I-005 - Enable local AI fallback (`ollama` + local model) for credit savings. +- [x] I-006 - Enforce local-only chat mode option (`--local-only`) with `ollama/lmstudio` detection. +- [x] I-007 - Align OpenClaw default model to local `ollama/llama3.2:1b` + cloud fallbacks for continuity. +- [x] I-008 - Add provider/agentic scanner (`tools/ai/zeroclaw_provider_scan.sh`) for live capability matrix. -## Phase B: Repo Specs and PR Cadence +## Daily autonomous sequence -- [ ] Create/refresh one issue in `RTC_BL_PHONE` for ZeroClaw-assisted hardware loop. -- [ ] Create/refresh one issue in `le-mystere-professeur-zacus` for ZeroClaw-assisted hardware loop. -- [ ] Open one small PR per repo focused on one gate (build, tests, hardware smoke, docs). -- [ ] Require code review pass before merge (`gh pr review --approve` only after checks). +- [x] D-001 - `tools/ai/zeroclaw_stack_down.sh` then `ZEROCLAW_PROM_MODE=auto tools/ai/zeroclaw_stack_up.sh`. +- [x] D-002 - Smoke endpoints: + - `curl -fsS http://127.0.0.1:3000/health` + - `curl -fsS http://127.0.0.1:8788/` + - `curl -fsS http://127.0.0.1:9090/-/ready` +- [x] D-003 - RTC loop: + - `tools/ai/zeroclaw_dual_chat.sh rtc --provider-check` + - `tools/ai/zeroclaw_dual_chat.sh rtc --hardware` + - `tools/ai/zeroclaw_hw_firmware_loop.sh rtc` (build+upload+monitor forced default) + - webhook trace with `--repo-hint rtc` + - status: `2026-02-21` done (flash + monitor + webhook HTTP 200). +- [x] D-004 - Zacus loop: + - `tools/ai/zeroclaw_dual_chat.sh zacus --provider-check` + - `tools/ai/zeroclaw_dual_chat.sh zacus --hardware` + - `tools/ai/zeroclaw_hw_firmware_loop.sh zacus` (build+upload+monitor forced default) + - webhook trace with `--repo-hint zacus` + - status: `2026-02-21` done (ESP32-S3 mismatch auto-corrected to `freenove_esp32s3`). +- [x] D-005 - Review `artifacts/zeroclaw/gateway.log` + `conversations.jsonl`. -## Phase C: Autonomy + Cost Optimization +- [x] D-006 - Corriger l'association cible↔port + - `RTC_UPLOAD_PORT_HINT` cible Audio Kit (`cp2102`, `esp32audiokit`, `audio`). + - `ZACUS_UPLOAD_PORT_HINT` cible Freenove/S3 (`usbmodem`, `1a86`, `ch340`, `freenove`). + - status: `2026-02-21` done. -- [ ] Keep prompts short, target one repo at a time. -- [ ] Use provider auto-fallback (`copilot` -> `openai-codex` -> `openrouter`) to avoid dead sessions. -- [ ] Add repo-level path filters in workflows to avoid expensive irrelevant runs. -- [ ] Use `workflow_dispatch` for hardware-required jobs to avoid noisy CI failures. +## Hardware safety gates -## Phase D: Hardware Robustness +- [x] H-001 - Flash/upload/monitor are forced by default when a board is detected. +- [x] H-002 - Resolve stable serial target before upload. +- [x] H-003 - Keep per-run logs under `artifacts/zeroclaw/`. -- [ ] Add serial-port resolver step before every upload/flash action. -- [ ] Fail fast if no expected USB device is detected. -- [ ] Archive logs per run for replayability (`artifacts//...`). +## Cost/control gates -## Exit Criteria +- [x] C-001 - Validate `tools/ai/zeroclaw_webhook_send.sh --dry-run`. +- [x] C-002 - Validate hourly quota guard (`ZEROCLAW_WEBHOOK_MAX_CALLS_PER_HOUR`). +- [x] C-003 - Validate message length guard (`ZEROCLAW_WEBHOOK_MAX_CHARS`). -- [ ] Both repos can be targeted with one command (`rtc` or `zacus`) without workspace leakage. -- [ ] Hardware discovery passes before action on connected boards. -- [ ] At least one successful PR cycle completed per repo with this orchestration path. +## Exit criteria + +- [x] E-001 - One successful complete loop RTC in local hardware. +- [x] E-002 - One successful complete loop Zacus in local hardware. +- [x] E-003 - Dashboard live usable for continuous supervision. +- [x] E-004 - Prometheus target scrape confirmed on gateway metrics. + +## Integrations (Open WebUI + n8n) + +- [x] I-201 - Add mixed Open WebUI Pipe mapping (`zc.router` + dedicated models). +- [x] I-202 - Add n8n PR autotriage workflow (webhook + cron fallback). +- [x] I-203 - Add local docker compose stack for Open WebUI (`3001`) and n8n (`5678`). +- [x] I-204 - Add runtime scripts (`integrations_up/down/status`, `import_n8n`, `openwebui_assist`). +- [ ] I-205 - Validate end-to-end import + activation on local Docker runtime. + - command: `tools/ai/zeroclaw_integrations_up.sh` + - command: `tools/ai/zeroclaw_integrations_status.sh` + - command: `tools/ai/zeroclaw_integrations_import_n8n.sh` -- 2.52.0 From 7e459a1012b44ea8088d4c3542341834b110a020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20SAILLANT?= <108685187+electron-rare@users.noreply.github.com> Date: Sat, 21 Feb 2026 19:44:56 +0100 Subject: [PATCH 3/4] chore(specs): sync ai-agentic embedded specs with current Kill_LIFE task state (#13) --- ai-agentic-embedded-base/specs/04_tasks.md | 170 +++++++++++++++--- .../specs/zeroclaw_dual_hw_todo.md | 82 ++++++--- 2 files changed, 206 insertions(+), 46 deletions(-) diff --git a/ai-agentic-embedded-base/specs/04_tasks.md b/ai-agentic-embedded-base/specs/04_tasks.md index 6e18fa1..6d4eb29 100644 --- a/ai-agentic-embedded-base/specs/04_tasks.md +++ b/ai-agentic-embedded-base/specs/04_tasks.md @@ -1,28 +1,154 @@ -# Axe d’amélioration : badge & conformité +# Tasks autonomie locale (execution) -- Automatiser la génération, vérification et publication des badges (sécurité, SBOM, doc, qualité, communauté, coverage) -- Centraliser guides badge dans docs/badges/ -- Vérifier la fraîcheur des badges à chaque commit (timestamp ≥ commit) -- Inclure badges et rapports dans l’evidence pack -- Ajouter checklist badge en tête du README -- Documenter la politique badge & conformité (docs/COMPLIANCE.md) -- Planifier un audit badge à chaque release majeure +Last updated: 2026-02-21 -## Planification audit badge +Format: -- À chaque release majeure, exécuter un audit badge : - - Vérifier la couleur et l’actualisation de chaque badge - - Vérifier la présence des rapports JSON - - Vérifier l’inclusion dans l’evidence pack - - Documenter les résultats dans docs/badges/audit_.md -# Easter Egg musique concrète +- `[ ]` non fait +- `[x]` fait +- `AC` = acceptance criteria +- `Evidence` = fichier/commande de preuve -_« Les tâches sont des sons trouvés : chaque action, chaque gate, est une pièce du puzzle acousmatique. »_ — Pierre Schaeffer -# Tasks (Backlog exécutable) +## Sprint actuel -Format conseillé (copiable en GitHub Issues) : +- [x] T-001 - Merger la PR autonomie ZeroClaw + - AC: PR mergee sur `main`. + - Evidence: `https://github.com/electron-rare/Kill_LIFE/pull/5` -- [ ] T1 — ... - - AC: ... - - Evidence: ... -- [ ] T2 — ... +- [x] T-002 - Fermer ou merger la PR miroir restante + - AC: plus de PR redondante ouverte pour le meme scope. + - Evidence: `gh pr list --state open` + +- [x] T-003 - Configurer secret fallback OpenRouter local + - AC: `~/.zeroclaw/env` present avec `OPENROUTER_API_KEY` et mode `600`. + - Evidence: `ls -l ~/.zeroclaw/env` + +- [x] T-004 - Installer backend Prometheus local + - AC: commande `prometheus --version` disponible. + - Evidence: sortie shell `prometheus, version ...` + +- [x] T-005 - Stabiliser pairing bearer auto + - AC: `artifacts/zeroclaw/pair_token.txt` utilisable pour webhook sans override manuel. + - Evidence: `tools/ai/zeroclaw_webhook_send.sh --repo-hint rtc "pairing check"` + - Status: `2026-02-21` done (401 resolved + webhook HTTP 200 after provider/model auto-fix in stack bootstrap). + +- [x] T-006 - Activer fallback IA locale (macOS) + - AC: `ollama` installe, service actif, modele local disponible, stack capable de le preferer. + - Evidence: `tools/ai/ollama_local_setup.sh --no-pull --no-warmup` + config `default_provider = "ollama"`. + - Status: `2026-02-21` done (`llama3.2:1b` local); mode local est optionnel via `ZEROCLAW_PREFER_LOCAL_AI=1` pour garder la fiabilite webhook par defaut. + +- [x] T-007 - Renforcer mode local-only agentic (ZeroClaw + OpenClaw) + - AC: `tools/ai/zeroclaw_dual_chat.sh --local-only --provider-check` choisit un provider local (`ollama` ou `lmstudio`) sinon exit explicite. + - Evidence: sortie provider-check + `openclaw models status --plain`. + - Status: `2026-02-21` done (`openclaw` default model force sur `ollama/llama3.2:1b`, fallbacks `openai-codex` puis `openrouter`). + +- [x] T-008 - Scanner les options provider/agentic disponibles + - AC: rapport local avec statut runtime `openclaw/ollama/lmstudio/litellm` et matrice providers ZeroClaw. + - Evidence: `tools/ai/zeroclaw_provider_scan.sh --no-refresh` -> `artifacts/zeroclaw/provider_options.md`. + - Status: `2026-02-21` done. + +- [x] T-009 - Verrouiller le mapping matériel par cible + - AC: la détection automatique affecte `zacus` aux ports `usbmodem`/S3 et `rtc` à l’Audio Kit (pas d’interversion habituelle). + - Evidence: + - `ZEROCLAW_ZACUS_UPLOAD_PORT_HINT="1a86,usbmodem,ch340,freenove" tools/ai/zeroclaw_hw_firmware_loop.sh zacus --port '' --monitor-secs 5` + - `ZEROCLAW_RTC_UPLOAD_PORT_HINT="cp2102,10c4,esp32audiokit,audio" tools/ai/zeroclaw_hw_firmware_loop.sh rtc --port '' --monitor-secs 5` + - Status: `2026-02-21` done (`usbmodem` prioritaire pour zacus, `usbmodem` pénalisé pour rtc). + +## Boucle hardware RTC + +- [x] T-101 - Discover hardware RTC + - AC: au moins un port detecte pour carte RTC. + - Evidence: `tools/ai/zeroclaw_dual_chat.sh rtc --hardware` + +- [x] T-102 - Build firmware RTC + - AC: `pio run -e esp32dev` termine sans erreur bloquante. + - Evidence: logs build RTC. + - Status: `2026-02-21` done. + +- [x] T-103 - Upload + monitor RTC (forced default) + - AC: `pio run -e esp32dev -t upload` puis monitor 60s executes. + - Evidence: logs upload/monitor RTC. + - Status: `2026-02-21` done (`ESP32-D0WD-V3` flash + serial monitor output captured). + +- [x] T-104 - Trace webhook RTC + - AC: une ligne JSONL avec `repo_hint=rtc` apparait. + - Evidence: `artifacts/zeroclaw/conversations.jsonl` + - Status: `2026-02-21` done (`http_status=200`, `ok=true`). + +## Boucle hardware Zacus + +- [x] T-201 - Discover hardware Zacus + - AC: au moins un port detecte pour carte Zacus. + - Evidence: `tools/ai/zeroclaw_dual_chat.sh zacus --hardware` + +- [x] T-202 - Build firmware Zacus + - AC: `pio run -e esp32dev` (dans `hardware/firmware`) termine sans erreur bloquante. + - Evidence: logs build Zacus. + - Status: `2026-02-21` done. + +- [x] T-203 - Upload + monitor Zacus (forced default) + - AC: `pio run -e -t upload` puis monitor executes. + - Evidence: logs upload/monitor Zacus. + - Status: `2026-02-21` done (`ESP32-S3` detecte, env fallback `freenove_esp32s3`, flash + monitor OK). + +- [x] T-204 - Trace webhook Zacus + - AC: une ligne JSONL avec `repo_hint=zacus` apparait. + - Evidence: `artifacts/zeroclaw/conversations.jsonl` + - Status: `2026-02-21` done (`http_status=200`, `ok=true`). + +## Observabilite et cout + +- [x] T-301 - Stack endpoints smoke + - AC: `3000/health`, `8788`, `9090/-/ready` tous OK. + - Evidence: captures `curl`. + +- [x] T-302 - Dry-run webhook budget + - AC: `--dry-run` passe sans ecriture execution JSONL. + - Evidence: sortie script + diff JSONL. + - Status: `2026-02-21` done. + +- [x] T-303 - Quota call limiter + - AC: depassement quota bloque avec code non-zero. + - Evidence: message `[budget] hourly call limit reached`. + - Status: `2026-02-21` done (test sandbox local `max_calls=1`, second call blocked with exit 12). + +- [x] T-304 - Quota chars limiter + - AC: message trop long bloque avec code non-zero. + - Evidence: message `[budget] message length ... exceeds ...`. + - Status: `2026-02-21` done (`ZEROCLAW_WEBHOOK_MAX_CHARS=5`, exit 11). + +## Integrations Open WebUI + n8n + +- [x] T-401 - Ajouter API alerts + autotriage backend + - AC: endpoints `/api/alerts`, `/api/alerts/ack`, `/api/pr/autotriage` disponibles. + - Evidence: `tools/ai/zeroclaw_orchestrator_server.py`. + +- [x] T-402 - Etendre WebUI orchestrateur + - AC: panneau Alerts + Integrations status + action `PR autotriage now`. + - Evidence: `tools/ai/zeroclaw_stack_up.sh`. + +- [x] T-403 - Refactor Pipe Open WebUI en mapping mixte + - AC: pipe expose `zc.router` + modeles dedies et parsing `/run`/`/pr`. + - Evidence: `tools/ai/integrations/openwebui/zeroclaw_orchestrator_pipe.py`. + +- [x] T-404 - Ajouter workflow n8n PR autotriage + - AC: workflow avec Webhook + Cron fallback + alert/question outputs. + - Evidence: `tools/ai/integrations/n8n/zeroclaw_pr_autotriage_workflow.json`. + +- [x] T-405 - Ajouter provisioning local Docker integrations + - AC: compose + scripts `up/down/status` + import n8n + assist Open WebUI. + - Evidence: + - `tools/ai/integrations/docker/docker-compose.openwebui-n8n.yml` + - `tools/ai/zeroclaw_integrations_up.sh` + - `tools/ai/zeroclaw_integrations_down.sh` + - `tools/ai/zeroclaw_integrations_status.sh` + - `tools/ai/zeroclaw_integrations_import_n8n.sh` + - `tools/ai/zeroclaw_integrations_openwebui_assist.sh` + +## Definition of done + +- [x] Au moins une boucle complete RTC + Zacus executee en local. +- [x] Dashboard live exploitable pour suivi continu. +- [x] Prometheus disponible avec target gateway scrapee. +- [x] Logs et preuves archives dans `artifacts/zeroclaw/`. +- [x] Aucune commande documentee n'utilise `-e native` ou `-e test`. diff --git a/ai-agentic-embedded-base/specs/zeroclaw_dual_hw_todo.md b/ai-agentic-embedded-base/specs/zeroclaw_dual_hw_todo.md index 95aed68..d65e220 100644 --- a/ai-agentic-embedded-base/specs/zeroclaw_dual_hw_todo.md +++ b/ai-agentic-embedded-base/specs/zeroclaw_dual_hw_todo.md @@ -1,36 +1,70 @@ -# TODO: Dual Hardware Autonomy (RTC + Zacus) +# TODO: Dual hardware autonomy runbook (RTC + Zacus) Last updated: 2026-02-21 -## Phase A: Local Baseline +## Immediate now -- [ ] Run `tools/ai/zeroclaw_dual_bootstrap.sh` and capture hardware snapshot. -- [ ] Validate `tools/ai/zeroclaw_dual_chat.sh rtc -m ""`. -- [ ] Validate `tools/ai/zeroclaw_dual_chat.sh zacus -m ""`. -- [ ] Record detected ports and map preferred role per board. +- [x] I-001 - Merge autonomie stack into `main` (`PR #5`). +- [x] I-002 - Configure local secret file `~/.zeroclaw/env` (`OPENROUTER_API_KEY` placeholder + mode `600`). +- [x] I-003 - Ensure local Prometheus backend exists (`prometheus` binary installed). +- [x] I-004 - Resolve open mirror PR redundancy (`PR #7` merge/close decision). +- [x] I-005 - Enable local AI fallback (`ollama` + local model) for credit savings. +- [x] I-006 - Enforce local-only chat mode option (`--local-only`) with `ollama/lmstudio` detection. +- [x] I-007 - Align OpenClaw default model to local `ollama/llama3.2:1b` + cloud fallbacks for continuity. +- [x] I-008 - Add provider/agentic scanner (`tools/ai/zeroclaw_provider_scan.sh`) for live capability matrix. -## Phase B: Repo Specs and PR Cadence +## Daily autonomous sequence -- [ ] Create/refresh one issue in `RTC_BL_PHONE` for ZeroClaw-assisted hardware loop. -- [ ] Create/refresh one issue in `le-mystere-professeur-zacus` for ZeroClaw-assisted hardware loop. -- [ ] Open one small PR per repo focused on one gate (build, tests, hardware smoke, docs). -- [ ] Require code review pass before merge (`gh pr review --approve` only after checks). +- [x] D-001 - `tools/ai/zeroclaw_stack_down.sh` then `ZEROCLAW_PROM_MODE=auto tools/ai/zeroclaw_stack_up.sh`. +- [x] D-002 - Smoke endpoints: + - `curl -fsS http://127.0.0.1:3000/health` + - `curl -fsS http://127.0.0.1:8788/` + - `curl -fsS http://127.0.0.1:9090/-/ready` +- [x] D-003 - RTC loop: + - `tools/ai/zeroclaw_dual_chat.sh rtc --provider-check` + - `tools/ai/zeroclaw_dual_chat.sh rtc --hardware` + - `tools/ai/zeroclaw_hw_firmware_loop.sh rtc` (build+upload+monitor forced default) + - webhook trace with `--repo-hint rtc` + - status: `2026-02-21` done (flash + monitor + webhook HTTP 200). +- [x] D-004 - Zacus loop: + - `tools/ai/zeroclaw_dual_chat.sh zacus --provider-check` + - `tools/ai/zeroclaw_dual_chat.sh zacus --hardware` + - `tools/ai/zeroclaw_hw_firmware_loop.sh zacus` (build+upload+monitor forced default) + - webhook trace with `--repo-hint zacus` + - status: `2026-02-21` done (ESP32-S3 mismatch auto-corrected to `freenove_esp32s3`). +- [x] D-005 - Review `artifacts/zeroclaw/gateway.log` + `conversations.jsonl`. -## Phase C: Autonomy + Cost Optimization +- [x] D-006 - Corriger l'association cible↔port + - `RTC_UPLOAD_PORT_HINT` cible Audio Kit (`cp2102`, `esp32audiokit`, `audio`). + - `ZACUS_UPLOAD_PORT_HINT` cible Freenove/S3 (`usbmodem`, `1a86`, `ch340`, `freenove`). + - status: `2026-02-21` done. -- [ ] Keep prompts short, target one repo at a time. -- [ ] Use provider auto-fallback (`copilot` -> `openai-codex` -> `openrouter`) to avoid dead sessions. -- [ ] Add repo-level path filters in workflows to avoid expensive irrelevant runs. -- [ ] Use `workflow_dispatch` for hardware-required jobs to avoid noisy CI failures. +## Hardware safety gates -## Phase D: Hardware Robustness +- [x] H-001 - Flash/upload/monitor are forced by default when a board is detected. +- [x] H-002 - Resolve stable serial target before upload. +- [x] H-003 - Keep per-run logs under `artifacts/zeroclaw/`. -- [ ] Add serial-port resolver step before every upload/flash action. -- [ ] Fail fast if no expected USB device is detected. -- [ ] Archive logs per run for replayability (`artifacts//...`). +## Cost/control gates -## Exit Criteria +- [x] C-001 - Validate `tools/ai/zeroclaw_webhook_send.sh --dry-run`. +- [x] C-002 - Validate hourly quota guard (`ZEROCLAW_WEBHOOK_MAX_CALLS_PER_HOUR`). +- [x] C-003 - Validate message length guard (`ZEROCLAW_WEBHOOK_MAX_CHARS`). -- [ ] Both repos can be targeted with one command (`rtc` or `zacus`) without workspace leakage. -- [ ] Hardware discovery passes before action on connected boards. -- [ ] At least one successful PR cycle completed per repo with this orchestration path. +## Exit criteria + +- [x] E-001 - One successful complete loop RTC in local hardware. +- [x] E-002 - One successful complete loop Zacus in local hardware. +- [x] E-003 - Dashboard live usable for continuous supervision. +- [x] E-004 - Prometheus target scrape confirmed on gateway metrics. + +## Integrations (Open WebUI + n8n) + +- [x] I-201 - Add mixed Open WebUI Pipe mapping (`zc.router` + dedicated models). +- [x] I-202 - Add n8n PR autotriage workflow (webhook + cron fallback). +- [x] I-203 - Add local docker compose stack for Open WebUI (`3001`) and n8n (`5678`). +- [x] I-204 - Add runtime scripts (`integrations_up/down/status`, `import_n8n`, `openwebui_assist`). +- [ ] I-205 - Validate end-to-end import + activation on local Docker runtime. + - command: `tools/ai/zeroclaw_integrations_up.sh` + - command: `tools/ai/zeroclaw_integrations_status.sh` + - command: `tools/ai/zeroclaw_integrations_import_n8n.sh` -- 2.52.0 From 7bdcbf6be9edd0e57d7f2b56f7a641c19f14fe5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20SAILLANT?= <108685187+electron-rare@users.noreply.github.com> Date: Sat, 21 Feb 2026 20:25:04 +0100 Subject: [PATCH 4/4] chore(kill_life): sync spec_kit state and runtime stack doc wiring --- specs/04_tasks.md | 28 ++ specs/zeroclaw_dual_hw_todo.md | 11 + tools/ai/zeroclaw_stack_up.sh | 741 ++++++++++++++++++++++++++++++++- 3 files changed, 779 insertions(+), 1 deletion(-) diff --git a/specs/04_tasks.md b/specs/04_tasks.md index afd3331..6d4eb29 100644 --- a/specs/04_tasks.md +++ b/specs/04_tasks.md @@ -117,6 +117,34 @@ Format: - Evidence: message `[budget] message length ... exceeds ...`. - Status: `2026-02-21` done (`ZEROCLAW_WEBHOOK_MAX_CHARS=5`, exit 11). +## Integrations Open WebUI + n8n + +- [x] T-401 - Ajouter API alerts + autotriage backend + - AC: endpoints `/api/alerts`, `/api/alerts/ack`, `/api/pr/autotriage` disponibles. + - Evidence: `tools/ai/zeroclaw_orchestrator_server.py`. + +- [x] T-402 - Etendre WebUI orchestrateur + - AC: panneau Alerts + Integrations status + action `PR autotriage now`. + - Evidence: `tools/ai/zeroclaw_stack_up.sh`. + +- [x] T-403 - Refactor Pipe Open WebUI en mapping mixte + - AC: pipe expose `zc.router` + modeles dedies et parsing `/run`/`/pr`. + - Evidence: `tools/ai/integrations/openwebui/zeroclaw_orchestrator_pipe.py`. + +- [x] T-404 - Ajouter workflow n8n PR autotriage + - AC: workflow avec Webhook + Cron fallback + alert/question outputs. + - Evidence: `tools/ai/integrations/n8n/zeroclaw_pr_autotriage_workflow.json`. + +- [x] T-405 - Ajouter provisioning local Docker integrations + - AC: compose + scripts `up/down/status` + import n8n + assist Open WebUI. + - Evidence: + - `tools/ai/integrations/docker/docker-compose.openwebui-n8n.yml` + - `tools/ai/zeroclaw_integrations_up.sh` + - `tools/ai/zeroclaw_integrations_down.sh` + - `tools/ai/zeroclaw_integrations_status.sh` + - `tools/ai/zeroclaw_integrations_import_n8n.sh` + - `tools/ai/zeroclaw_integrations_openwebui_assist.sh` + ## Definition of done - [x] Au moins une boucle complete RTC + Zacus executee en local. diff --git a/specs/zeroclaw_dual_hw_todo.md b/specs/zeroclaw_dual_hw_todo.md index 750f684..d65e220 100644 --- a/specs/zeroclaw_dual_hw_todo.md +++ b/specs/zeroclaw_dual_hw_todo.md @@ -57,3 +57,14 @@ Last updated: 2026-02-21 - [x] E-002 - One successful complete loop Zacus in local hardware. - [x] E-003 - Dashboard live usable for continuous supervision. - [x] E-004 - Prometheus target scrape confirmed on gateway metrics. + +## Integrations (Open WebUI + n8n) + +- [x] I-201 - Add mixed Open WebUI Pipe mapping (`zc.router` + dedicated models). +- [x] I-202 - Add n8n PR autotriage workflow (webhook + cron fallback). +- [x] I-203 - Add local docker compose stack for Open WebUI (`3001`) and n8n (`5678`). +- [x] I-204 - Add runtime scripts (`integrations_up/down/status`, `import_n8n`, `openwebui_assist`). +- [ ] I-205 - Validate end-to-end import + activation on local Docker runtime. + - command: `tools/ai/zeroclaw_integrations_up.sh` + - command: `tools/ai/zeroclaw_integrations_status.sh` + - command: `tools/ai/zeroclaw_integrations_import_n8n.sh` diff --git a/tools/ai/zeroclaw_stack_up.sh b/tools/ai/zeroclaw_stack_up.sh index abbd11b..e6b75a2 100755 --- a/tools/ai/zeroclaw_stack_up.sh +++ b/tools/ai/zeroclaw_stack_up.sh @@ -57,12 +57,22 @@ PROM_MANAGED_FILE="$ART_DIR/prometheus.managed" WATCHER_SCRIPT="$ROOT_DIR/tools/ai/zeroclaw_watch_1min.sh" ORCHESTRATOR_SERVER="$ROOT_DIR/tools/ai/zeroclaw_orchestrator_server.py" RT_LOG="$ART_DIR/realtime_1min.log" +INTEGRATIONS_DIR="$ROOT_DIR/tools/ai/integrations" mkdir -p "$ART_DIR" touch "$CONVO_FILE" touch "$GW_LOG" touch "$RT_LOG" +sync_integrations() { + if [[ ! -d "$INTEGRATIONS_DIR" ]]; then + return 0 + fi + rm -rf "$ART_DIR/integrations" + mkdir -p "$ART_DIR/integrations" + cp -R "$INTEGRATIONS_DIR"/. "$ART_DIR/integrations/" +} + if [[ -f "$HOME/.zeroclaw/config.toml" ]]; then chmod 600 "$HOME/.zeroclaw/config.toml" >/dev/null 2>&1 || true fi @@ -713,6 +723,8 @@ case "$PROM_MODE" in ;; esac +sync_integrations + cat >"$INDEX_FILE" < @@ -878,6 +890,56 @@ cat >"$INDEX_FILE" <"$INDEX_FILE" <"$INDEX_FILE" <1s | Display cap: 500 lines/panel | Prometheus: $PROM_STATUS | - API: /api/status /api/run + API: /api/status /api/run /api/pr/scan /api/pr/autotriage /api/alerts
+
+
+

Agent Workbench

+
+

Agents specializes: orchestrator, WebUI/UX, firmware RTC, firmware Zacus, QA/PR.

+ + +
+ + + + +
+
(agent status)
+
+
+
+

PR Cockpit (gh)

+
+
+ + +
+
+ + +
+ +
+ + + + + + + + + +
+
(PR summary)
+
(PR action result)
+
+
+
+
+
+

Alerts

+
+
+ + +
+
(alerts summary)
+
(no active alerts)
+
+
+
+

Integrations Status

+
+
(integrations status)
+
+ + +
+
+
+
+
+
+

Workflow & Agents

+
+
+ + + + +
+
+
(loading agents)
+
+
+
(loading workflows)
+
+
+
(loading recap)
+
+
+
+
+

Quick Start

+
+

Point d'entrée recommandé.

+
1) tools/ai/zeroclaw_stack_up.sh
+2) tools/ai/zeroclaw_integrations_up.sh
+3) Ouvrir http://127.0.0.1:8788/ (monitoring)
+4) Ouvrir http://127.0.0.1:3001/ (Open WebUI)
+5) Ouvrir http://127.0.0.1:5678/ (n8n)
+
+
+

Questions / Decisions

@@ -1069,6 +1247,17 @@ cat >"$INDEX_FILE" <
+ -- 2.52.0