๐ ๏ธ Self-Healing & Repair
Algorithmic trading environments must be resilient and self-healing. If you experience deployment failures, database routing discrepancies, expired authentication tokens, or missing git submodules, the Hoox CLI features a dedicated hoox repair command group designed to diagnose issues, check infrastructure status, and recover your workspace automatically.
๐ 1. Running the 5-Step System Diagnostics
If your trading gateway throws errors or the dashboard reports connection issues, run a comprehensive diagnostic sweep:
# Execute the automated 5-step repair check
hoox repair check
The diagnostics engine runs a strict, sequential analysis of your entire monorepo environment:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ hoox Repair Diagnostic Checklist โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ [Step 1] Submodule Integrity ......... โ
COMPLETED โ
โ [Step 2] Dependency Resolutions ....... โ
COMPLETED โ
โ [Step 3] TypeScript Type Safety ...... โ
COMPLETED โ
โ [Step 4] Cloudflare Edge Bindings .... โ
COMPLETED โ
โ [Step 5] Hardware Secrets Validation . โ
COMPLETED โ
โ โ
โ Diagnostic Result: 0 errors detected โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Submodule Check: Verifies that all 9 worker folders under
workers/are fully populated and registered in Git. - Dependency Check: Audits
node_modulesacross Bun workspaces for missing or duplicate libraries. - Type Safety Check: Compiles the CLI and shared packages to catch syntax or interface errors.
- Edge Bindings Check: Connects to Cloudflareโs APIs to verify that your D1, KV, and Queue namespaces physically exist on your account.
- Secrets Check: Audits your Workers Secrets to ensure exchange keys and Telegram tokens are securely bound.
๐ฉน 2. Targeted Component Repairs
If a diagnostic check fails, you do not need to redeploy the entire stack. You can run highly targeted repairs:
# A. Re-verify, provision, and repair missing Cloudflare bindings
hoox repair infra
# B. Re-audit and sync encrypted Workers Secrets to Cloudflare
hoox repair secrets
# C. Reset the CONFIG_KV configuration namespace to default variables
hoox repair kv
# D. Re-apply drizzle DQL schemas and run pending D1 database migrations
hoox repair db
# E. Rebuild and redeploy a single, degraded worker
hoox repair worker trade-worker
โก 3. Full System Interactive Rebuild
In the event of a catastrophic system failure (e.g. lost Cloudflare credentials, corrupted SQLite files, or major monorepo drift), you can execute a full, interactive self-healing rebuild:
# Execute an interactive, guided workspace rebuild
hoox repair rebuild
The Rebuild Sequence
When triggered, the CLI walks you through a structured recovery protocol:
- D1 Database Backup: Automatically exports your current D1 ledger as a secure
.sqlfile inbackups/recovery-pre-rebuild.sql. - Infrastructure Tear-Down: Deletes corrupted D1, KV, and Queue instances.
- Fresh Provisioning: Recreates all database tables and config buckets on Cloudflare.
- Sequenced Redeployment: Re-compiles and deploys all 9 edge workers in correct dependency sequence.
- Database Seeding: Restores your backup SQL data and re-applies schema migrations.
- KV Sync: Applies the 16-key configuration manifest defaults.
Danger: The
hoox repair rebuildcommand performs destructive resets on D1 and KV instances. Ensure you carefully read the interactive prompts and confirm database backup completion before letting the script proceed!
๐ 4. Common Troubleshooting Scenarios
| Symptom / Failure | Primary Root Cause | CLI Healing Action |
|---|---|---|
bun install or build crashes | Git submodules are empty or out of sync. | git submodule update --init --recursive |
D1_ERROR: no such table | SQLite D1 tables were not initialized. | hoox db apply --remote |
500 Internal Server Error | Missing or rotated exchange API secrets. | hoox secrets set BYBIT_API_KEY "key" followed by hoox deploy update-internal-urls. |
| Telegram Bot is mute | BotFather token is wrong, or webhook is unregistered. | hoox secrets set TELEGRAM_BOT_TOKEN "token" followed by hoox deploy telegram-webhook. |
๐ Next Steps
- Monitoring Operations Guide โ Audit system status, tail console logs, and verify fills.
- CLI Reference Manual โ Review all CLI commands, options, and JSON flags.