# Release Notes

All notable changes to the Weknow system will be documented in this file.

## [0.3.2] - 2026-07-17

### Module Versions
- **host-agent**: v0.3.1
- **cloud-agent**: v0.3.1
- **apiserver**: v0.3.2
- **media**: v0.1.8

### Changes

#### Bug Fixes & Stability
- **Fixed** bug #8, #34
- **Fixed** (media v0.1.8): Resolved `ffmpeg` `libblas` absolute symlink issue by adjusting runtime library linking.
- **Fixed** (media v0.1.8): Made `LD_LIBRARY_PATH` injection conditional on Docker volume mount to prevent host path conflicts.
- **Testing**: Robustified E2E test suite (`test_00`, `test_03`, `test_05`, `test_06`) against startup timing issues, EdgeX initialization delays after factory resets, and cron scheduler flaky boundaries.

#### Architecture & Performance
- **Feature** (apiserver): Unified data API semantics (`getOb`, `getSt`, `getImg`) by introducing dynamic sampling `interval` support and making `startTime`/`endTime` parameters optional (defaulting to the current trailing interval window).

## [0.3.1] - 2026-07-04

### Module Versions
- **host-agent**: v0.3.1
- **cloud-agent**: v0.3.1
- **apiserver**: v0.3.1
- **media**: v0.1.7

### Changes

#### Bug Fixes & Stability
- **Fixed** (media v0.1.7): Restored container isolation by removing the host `/usr/lib/aarch64-linux-gnu` override. `media-server` now safely imports its native GObject RTSP libraries while executing the host `ffmpeg` dynamically via `LD_LIBRARY_PATH`.
- **Fixed**: bug #32, #33
- **Fixed**: Resolved a telemetry alignment bug in `cloud-agent` where MQTT payload timestamps were hardcoded to 10-minute offsets, causing missing data issues during dynamic polling.
- **Fixed**: Corrected `data_aggregator` to evaluate exact time windows when querying single points (`startTime == endTime`) instead of forcing a 10-minute modulus alignment.
- **Fixed**: Piped `stderr` in `media` `LiveStreamTask` to properly capture and diagnose subprocess crashes instead of discarding them to `DEVNULL`.
- **Chore**: Renamed `upgrade_cli.py` to `upgrade-cli.py`.

#### Architecture & Performance
- **Perf**: Stripped `ffmpeg` from the `media` container image, mounting the host's native `ffmpeg` and hardware acceleration libraries directly. This significantly slims down the image size and natively integrates host dependencies.
- **Refactor**: Completely decoupled monitoring data persistence from the `cloud-agent` HTTP request flow. `host-agent` now autonomously collects and persists system telemetry to SQLite using a standalone `APScheduler` cron job.
- **Removed**: Removed the legacy `POST /v1/monitor` persistence endpoint from `host-agent`.
- **Feature**: Added new `GET /v1/system/monitor` endpoint in `apiserver` to proxy system telemetry queries (with optional `start_time` and `end_time` parameters) directly to `host-agent`.
- **Feature**: Implemented memory caching (`_latest_raw_stats`) in `host-agent` monitor persistence to prevent 35-second Uvicorn blocking during system info API calls.
- **Feature**: Increased APIServer proxy timeout to 45s in `system.py` to better accommodate potential network or processing delays.
- **Perf**: Optimized sensor status aggregation (`data_aggregator`) to O(1) network requests.

#### CI/CD & Testing
- **Refactor**: Restructured `run_e2e_pipeline.sh` into strictly ordered execution phases (Build -> Prepare -> Deploy -> Test) to ensure atomic and safe deployments.
- **Feature**: Upgraded E2E full upgrade test (`test_07`) to dynamically parse the target version from the remote `release-manifest.json` instead of relying on hardcoded versions, preventing 404 blockages during active development.
- **Feature**: Added new E2E test `test_01b_unactive_monitoring.py` to assert telemetry collection works properly while unactivated without initiating MQTT uploads.
- **Testing**: Added `stdata` performance benchmark script.

#### System Maintenance & Host Agent
- **Feature**: Introduced `setup_system.sh` script for automating system installations on fresh Ubuntu deployments.
- **Feature**: Added `WIFI_AP_ALLOW_FORWARDING` configuration and forwarding rules for Wi-Fi AP mode.
- **Fixed**: Resolved a multi-byte serial decoding bug during UART communication.
- **Refactor**: Prioritized license file path `/etc/weknow/erase_license.txt` during the `erase-factory-info` procedure.
- **Chore**: Changed `journald` `SystemMaxFiles` limit to 6 in the setup script.
- **Chore**: Updated kernel option to support `iptables-nft`.
- **Chore**: Removed legacy/unused `app` folder.

## [0.3.0] - 2026-06-23

### Module Versions
- **host-agent**: v0.3.0
- **cloud-agent**: v0.3.0
- **apiserver**: v0.3.0

### Changes

#### System Upgrade & Maintenance
- **Feature**: Added SQLite-backed upgrade history tracking to `host-agent`, logging upgrade outcomes (`SUCCESS` / `FAILED`) upon completion.
- **Feature**: Implemented `GET /v1/system/upgrade/history` to query upgrade records.
- **Feature**: Created command line helper tool `tools/upgrade-cli.py` to check system updates, inspect progress, view upgrade history, and trigger upgrades.
- **Feature**: Restricted standalone release notes to the `full` package only, uploading `RELEASE_NOTES.md` under `full/{version}/` and completely removing `version.json` from the release system.
- **Fixed**: Fixed `upgrade.sh` routing logic where specifying `--module full` fell through to incremental comparison instead of downloading the unified full package.
- **Fixed**: Enforced a thread-safe immediate state update lock inside `trigger_upgrade` to block concurrent duplicate upgrade requests.

#### Architecture Decoupling
- **Feature**: Decoupled the legacy monolithic `agent` into two separate microservices: `host-agent` (running as a systemd service) and `cloud-agent` (running containerized under Docker).
- **Feature**: Configured explicit image tag versioning (e.g. `0.3.0`) for both `apiserver` and `cloud-agent` to replace mutable `latest` tags.

#### Host Agent & Edge Gateway
- **Feature**: Built a single-file compiled binary for `host-agent` using PyInstaller to speed up deployment and reduce dependency footprint.
- **Feature**: Updated packaging script (`build_upgrade_package.sh`) to support full system microservice packaging.

#### Testing (E2E)
- **Feature**: Refactored `test_02_device_active.py` to read `wn_num` from the `E2E_WN_NUM` environment variable to prevent MQTT Client ID conflicts during multi-board testing.
- **Feature**: Added onboarding automation workflow and rules integration.

## [0.2.7] - 2026-06-19

### Module Versions
- **Agent**: v0.2.0
- **Apiserver**: v0.2.0

### Changes

#### Agent (v0.2.0)
- **Feature**: Migrated factory configuration fields (`sn`, `productName`, `productModel`, `wifi_ssid`, `wifi_password`) from SQLite database to Rockchip Vendor Storage (ID 16).
- **Feature**: Enforced a strict write-once constraint on Vendor Storage ID 16.
- **Feature**: Required atomic submission of all 5 factory fields via serial UART `WRITE` command.
- **Removed**: Removed serial UART command configuration and storage support for `api_url`.
- **Refactor**: White-listed factory configuration HTTP routes in DB recovery middleware, bypassing 503 errors during factory reset.

#### Apiserver (v0.2.0)
- **Feature**: Added read-only `GET /v1/system/factoryInfo` endpoint, proxying to the agent identity endpoint with 503 error handling (wifi_password is now exposed for local services).
- **Removed**: Removed redundant `wn_sn` field from `WNMetaData` model, DB schema, and API requests/responses.
- **Refactor**: Refactored `updateMetaData` API to support partial updates (skipping null fields instead of applying default empty strings).

#### Documentation
- **Feature**: Added `integration_guide_factory_info.md` to document Vendor Storage behavior, serial commands, and migration strategies.
- **Refactor**: Merged `doc` directory into `docs` directory to unify documentation structure.

#### Testing (E2E)
- **Feature**: Added Vendor Storage backup and restoration in E2E tests to prevent overwriting physical board SNs.
- **Feature**: Added adversarial testing for missing parameters during serial UART writes.
- **Refactor**: Replaced hardcoded `time.sleep()` waiting with robust HTTP polling to eliminate flaky test failures.
- **Fixed**: Fixed a false positive vulnerability in `test_01_factory_reset.py` where tests silently passed if pre-reset state could not be fetched.

## [0.2.6] - 2026-06-08

### Module Versions
- **Agent**: v0.1.3
- **Apiserver**: v0.1.0
- **Media**: v0.1.5
- **Device (edgex)**: v3.1.1
- **Support**: v0.1.2

### Changes

#### Agent (v0.1.3)
- **Fixed**: Wi-Fi AP configuration failure (`failed to configure Wi-Fi AP`) after factory reset. Stale inactive NetworkManager profiles (device listed as `--`) are now queried and cleaned up by their UUIDs prior to creating the new profile to prevent duplicate connection conflicts.
