Skip to content
📦 ARCHIVED SNAPSHOT (v1.0) You are viewing historical business logic and documentation for Converters (IoT & Cloud) v1.0 (frozen on 2026-11-23, commit 71e82be). Switch to Latest →

Open Questions [TEAM_WHY_NEEDED] & Tech Debt

Use this board during engineering/product reviews to record the historical “Why?” behind non-obvious rules and track cleanup priorities.

A. Open [TEAM_WHY_NEEDED] Questions for the Team

  1. Unlocked OTP in online manufacturing CLI: tools/provision_device.py:263 unconditionally passes --allow-unlocked-otp (marked LAB ONLY in provision_otp.py) and never passes --permissions-file. Is OTP locking deferred for current production batches?
  2. Legacy magic numbers in active OTP/signing tools: tools/provision_otp.py:32-33 burns 0x41534C44 (ASLD) instead of 0x504C4E56 (PLNV), and sign_firmware.py emits 0x41534C46 (ASLF). When should new hardware batches switch to PLNV?
  3. Ephemeral signing fallback in Docker builder & dev default in provisioning CLI: tools/build_firmware_docker.sh:21-61 silently generates temporary CA/signing keys in /tmp/ if production files are missing; tools/provision_device.py:28 defaults to https://dev-cloud.planovi.app/api/v1. Should release builds fail closed?
  4. Unauthenticated FastAPI management API & dead Flutter AuthService: All 35 management routes (converters.py including Device CA signing, settings.py, activity_logs.py, firmware.py) have zero FastAPI auth, and admin/lib/services/auth_service.dart is an unused mock with Supabase Auth TODOs. Is Nginx IP allowlisting / Cloudflare Access the intended sole boundary, or is JWT auth planned?
  5. ORM vs SQL migration drift (edge_system_settings & telemetry_ingest_receipts): Were edge_system_settings and the 4 UUID/audit columns on telemetry_ingest_receipts created manually in Supabase outside cloud/migrations/000..019? Should a reconciliation migration 020 be added?
  6. Supabase Edge pass-through vs migration 019 RPC: supabase/functions/ingest-telemetry/index.ts proxies raw telemetry to FastAPI /edge-record without touching PostgreSQL, while migration 019 maintains public.ingest_telemetry_record() in Supabase. Which ingestion path is canonical in production?
  7. Unexposed VirtualMeterService recovery APIs: register_point_zero() and handle_meter_replacement() exist with full validation in virtual_meter_service.py but have zero API endpoints. How do operators currently handle physical meter replacements when counter rollbacks are rejected?
  8. Serial floor 130, synthetic USB slot metadata & divergent offline thresholds: Why does converters.py:316,918 enforce max_num = 130, why does prepare-usb-provisioning return hardcoded synthetic Slot B block/size metadata, and should the three offline thresholds (180 s UI / 300 s alert / 900 s recovery log) be unified?
  9. Firmware RS-485 & measurement edge cases: Confirm (a) fixed 8N1 parity (uart_rs485.c:32), (b) bus_scanner.c mapping baudrate=0 -> 9600 instead of multi-baud sweep, (c) LEM-60 reading 36 regs while decoding 18 (meter_lem60.c:43), (d) unbounded per-phase P/Q and asymmetric current cap (1M A scanner vs 100k A manager), (e) device_event.c min timestamp 2000 vs 2020 in time_sync.c.
  10. Firmware NVS/Button/OTA/Storage edge cases: Confirm (a) 168 KiB unused NVS gap (flash_layout.h), (b) 3–10 s button dead zone (button.c), (c) factory reset leaving prior encrypted NVS slot unerased (config_store.c:937-950), (d) unlimited backward jump on local time_sync_set_utc() causing RAM monotonic hold, (e) quarantine_allowance = 64 cap (sd_journal.c:1292), (f) ota_update command returning "APPLIED" stub instead of "FAILED", (g) vestigial HTTPS->MQTT fallback removal, (h) src/ux/index.html omitting Wi-Fi SSID scan and replay action.
  11. Admin UI hardcoded placeholders: ConverterDetailScreen:2087 displays static "Bus Channel 0 · Baud 9600 · 0 CRC Errors" and :1202 hardcodes 'HTTPS Standalone mTLS (:443)'; DashboardScreen ignores AdminSettings.refreshRateSec. Should these be wired to real API fields?
  12. Infrastructure & tooling quirks: Confirm (a) hardcoded extra_hosts -> 191.218.165.149 and conflicting PLANOVI_TRUSTED_PROXY_CIDRS vs ASLANDI_TRUSTED_PROXY_CIDRS defaults in deploy/docker-compose.public-ingress.yml, (b) pinning FreeRTOS-Kernel in deploy/Dockerfile.firmware-builder instead of -b main, (c) making Windows Norton CA export optional in tools/setup_local_staging.py, (d) archiving/removing mockups/planovi-converters/.

B. Confirmed Runtime Bugs & Security Vulnerabilities

  • BUG (500 Crash): PATCH /api/v1/converter-orders/{order_id} (cloud/api/converters.py:126-130, 635-648) reads nonexistent payload.converter_serial and payload.notes on ConverterOrderUpdateRequest.
  • BUG (Silent Feature Disable): AlertDispatcher (cloud/services/alert_dispatcher.py:203) ignores PLANOVI_GOOGLE_CHAT_WEBHOOK_URL (reads only ASLANDI_GOOGLE_CHAT_WEBHOOK_URL), silently disabling both Google Chat alerts and reconcile_converter_availability offline detection.
  • BUG (Env Var Ignored): cloud/mqtt_ingress.py:107 reads only ASLANDI_MQTT_INGRESS_CLIENT_ID, ignoring PLANOVI_MQTT_INGRESS_CLIENT_ID.
  • BUG (Migration vs ORM Breakage): SystemSetting (edge_system_settings) vs 016 (system_settings); TelemetryIngestReceipt maps 4 columns (id, created_at, updated_at, created_by) missing from 000–019; telemetry_data.source_sequence lost NOT NULL in 008; alert_notifications retries indefinitely past DB check attempt_count <= 100.
  • BUG (Scratch Register Overwrite): src/main.c:414-417 writes PLANOVI_FAULT_OTA_TRIAL_TIMEOUT to watchdog_hw->scratch[0], then watchdog_mgr_reboot(false) (src/hal/watchdog.c:88) overwrites scratch[0] = RESET_REASON_SOFTWARE.
  • BUG (Chunked HTTP Broken on sync/storage): https_telemetry_transport.c:92-105 copies raw undecoded body into response_body, breaking JSON parsing if upstream uses Transfer-Encoding: chunked.
  • BUG (Synchronous PBKDF2 in tcpip_thread): POST /api/auth/account (api_endpoints.c:557-578, auth.c:953-992) executes 100k PBKDF2 iterations synchronously inside lwIP callback.
  • BUG (49.7-Day Tick Wraparound): cloud_client.c:1960, 1965 use unsigned now >= deadline comparisons instead of signed wrap-safe subtraction.
  • BUG (Dashboard Cloud Transport Mismatch): GET /api/status (api_endpoints.c:1869-1878) omits cloud.transport, and src/ux/index.html:1886 tests transport === 1 for HTTPS (actually 2).
  • BUG (Status & Diagnostics): cloud/api/status.py:133-140 never resets supabase-db back to "online"; cloud/app.py:150-154 /status bypasses DI; converters.py:2046 queries nonexistent receipt outcome 'DUPLICATE'; telemetry_ingress.py:246-254 _check_sync_required omits desired_cloud_port; retention_service.py:31-32 ignores year multiplier; converters.py:1598 hardcodes UTC+2 instead of Europe/Warsaw; converters.py:1301 signs cert with unstripped serial_number; staging/verify_schema.py:10-12 skips +asyncpg strip for PLANOVI_DATABASE_URL.
  • BUG (Flutter I18n & UX): 5 missing keys (chart_legend_pv, chart_legend_cons, th_time, modal_close, no_components_found) render raw in UI; ActivityLogScreen has no search debounce; event_ingestion.py overwrites original details["message"] upon RS-485 resolution.
  • SECURITY: Path traversal risk in POST /api/v1/firmware/upload (firmware.py:268-271); verify_forwarded_client_certificate (telemetry_ingress.py:49-85) skips cert expiration check; POST /api/auth/password-status (auth.c:910-932) lacks IP binding & TTL; hardcoded secret fallbacks in mtls_gateway.py:40, status.py:15, deploy/check-health.sh:13, deploy/cron-setup.md:34; status.py uses non-constant-time !=; Flutter ApiService logs full response bodies (including provisioned aes_key_hex/private keys) in browser console via LogInterceptor(responseBody: true); deploy/nginx.admin.planovi.conf:30 has placeholder allow 1.2.3.4;; FastAPI CORS defaults to ["*"] with allow_credentials=True.

C. Dead / Legacy Code & Discrepancies Checklist

  • Legacy ASLANDI_* Artifacts: Magic bytes (ASLF, ASBT, ASLD, ASLC, 0xA51A0000), CMake aliases (aslandi_release, etc.), env var aliases (ASLANDI_*), Docker output aslandi_full_factory.uf2, advisory lock 0x41534C414E4449, MQTT client ID "aslandi-cloud-ingress".
  • Unwired / Dead Modules & Functions:
    • Firmware: ota_update.c (ota_start/write_chunk/finish_and_verify/apply_and_reboot/abort/get_progress), bootloader_mark_slot_valid(), BOOT_VERIFY_ERR_SIZE/NOT_VALIDATED, BUTTON_EVENT_SHORT_CLICK handler, meter_manager_process(), energy_counter_delta(), lem60_context_t/chint666_context_t, modbus_rtu_write_*_register(s), sd_card_erase_sector(), FIFO_WRITER_SAVE_METADATA, cloud_retry_fallback_allowed(), g_sta_consecutive_failures, active_netif, PLANOVI_COLOR_* RGB LED constants.
    • Cloud & Supabase: cloud/services/device_provisioning.py (entire file), email-templates/*.html (all 4 files), supabase/functions/ingest-telemetry/schema3_adapter.ts:mapSchema3ToRawTelemetry, virtual_meter_service.py:{register_point_zero,handle_meter_replacement,get_accumulated_virtual_energy}, ConverterUpdateRequest.{clear_company,clear_building}, status._check_tcp_port.
    • Flutter Admin: AuthService, sampleConverters, ApiService.{fetchFacilities,createConverter,uploadFirmwareRelease}, window.requestPicoUsbDevice (admin/web/index.html), google_fonts dependency, 76 unused i18n keys.
    • Tests & Mockups: tests/test_fifo_buffer.c (excluded from tests/CMakeLists.txt), mockups/planovi-converters/ (legacy static mockup + unused Next.js/Vinext scaffold).
  • Outdated Comments / Docs: image_header.h:78 ("RP2350-PICO2W" vs "PICO2W-RP2350"), crypto_aes.h (“Hardware-Accelerated AES-256” vs software mbedTLS), modbus_rtu.h:9,158 (FC 0x16 vs 0x10), schema3_adapter.ts:19-20 (mt/mr meanings contradict migration 019), mqtt_broker_config.conf:72 (“1MB” vs 4096), cloud/migrations/README.md (stops at 014), admin/README.md & admin/pubspec.yaml (still call app a static mockup), src/ux/index.html:962,1190 (mentions “testów T04” and says factory reset wipes telemetry queue).