Add missing fields (event_code, camera_ip, started_at, ended_at, dwell_seconds, is_discarded, alerted_at, etc.) to both batch_event and case_event payloads. Introduce source_id config for payload injection and infer_camera_ip to extract IP from RTSP stream URL. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
67 lines
4.3 KiB
Markdown
67 lines
4.3 KiB
Markdown
# Task Todo
|
|
|
|
- [x] Review the current project instructions and check for task-relevant lessons.
|
|
- [x] Inspect the OTA upload API document and current runtime/webhook capture path.
|
|
- [x] Create an isolated worktree for alarm snapshot upload implementation.
|
|
- [x] Write the detailed implementation plan to `docs/superpowers/plans/2026-06-09-alarm-snapshot-upload.md`.
|
|
- [x] Execute alarm snapshot upload client TDD cycle.
|
|
- [x] Execute runtime and webhook payload integration TDD cycle.
|
|
- [x] Update config surface, docs, and verification notes.
|
|
- [x] Run targeted verification and final full verification.
|
|
|
|
## Notes
|
|
|
|
- `tasks/lessons.md` is absent in this repository/worktree, so there were no prior session lessons to review.
|
|
- Upload API reference: `/Users/glo/code/go/wenma/ai_manager/zd-ai-manager/chunk-upload-oss-service/UPLOAD_API.md`
|
|
- User-provided upload target: `https://ota.zhengxinshipin.com`
|
|
- User-provided token secret: `change-me-in-production`
|
|
|
|
## Review
|
|
|
|
- Plan saved to `docs/superpowers/plans/2026-06-09-alarm-snapshot-upload.md`.
|
|
- Chosen implementation keeps snapshot upload entirely outside `BatchEngine` and enriches webhook payloads from the runtime side using the already captured frame.
|
|
- Implemented `src/cold_display_guard/alarm_snapshots.py` for JPEG encoding plus OTA chunk-upload orchestration, runtime integration in `src/cold_display_guard/main.py`, webhook payload enrichment in `src/cold_display_guard/webhooks.py`, config exposure/secret stripping in `src/cold_display_guard/config.py` and `src/cold_display_guard/manage_api.py`, and config/doc updates in `config/example.toml` and `README_zh.md`.
|
|
- Targeted verification passed:
|
|
- `eval "$(/opt/homebrew/bin/pyenv init -)" && PYTHONPATH=src python -m unittest tests/test_alarm_snapshots.py -v`
|
|
- `eval "$(/opt/homebrew/bin/pyenv init -)" && PYTHONPATH=src python -m unittest tests/test_main.py -v`
|
|
- `eval "$(/opt/homebrew/bin/pyenv init -)" && PYTHONPATH=src python -m unittest tests/test_webhooks.py tests/test_config.py tests/test_manage_api.py -v`
|
|
- Final verification passed:
|
|
- `eval "$(/opt/homebrew/bin/pyenv init -)" && PYTHONPATH=src python -m unittest discover -s tests -v`
|
|
- `cd web && pnpm install --frozen-lockfile && pnpm build`
|
|
|
|
## Current Task: Webhook Payload Field Gap Check
|
|
|
|
- [x] Pull the actual payload currently received by `video-recognition` and compare it against the required event list fields.
|
|
- [x] Patch webhook payload builders to include the missing non-store fields required by the downstream table.
|
|
- [x] Add or update focused webhook tests for the enriched payload shape.
|
|
- [x] Run targeted verification and record the result here.
|
|
|
|
### Current Findings
|
|
|
|
- Current received payload only includes `batch_id`, `camera_id`, `event`, `kind`, `severity`, `source_id`, `state`, `ts`, `zone_id`, and `zone_label`.
|
|
- Missing or not explicitly populated for the downstream event table: event code, camera IP, batch start time, removal time, dwell duration, discard flag, discard time, create time, alarm time, and update time.
|
|
|
|
### Field Gap Verification
|
|
|
|
- Actual receiver payload before the fix, from `video-recognition` result JSONL on `10.8.0.11`, confirmed only the base fields above and did not include the downstream table time/discard/IP fields.
|
|
- Updated `src/cold_display_guard/webhooks.py` so both `batch_event` and `case_event` now include:
|
|
- `event_code`
|
|
- `camera_ip`
|
|
- `started_at`
|
|
- `ended_at`
|
|
- `removed_at`
|
|
- `dwell_seconds`
|
|
- `is_discarded`
|
|
- `discarded_at`
|
|
- `created_at`
|
|
- `alerted_at`
|
|
- `alarm_at`
|
|
- `updated_at`
|
|
- `case_event` also now carries the missing contextual fields `camera_id`, `zone_id`, and `zone_label`.
|
|
- Verification passed:
|
|
- `PYTHONPATH=src python3 -m unittest tests/test_webhooks.py -v`
|
|
- `PYTHONPATH=src python3 -m unittest tests/test_main.py -v`
|
|
- `PYTHONPATH=src python3 -m unittest discover -s tests -v`
|
|
- Deployed updated code to `xiaozheng@10.8.0.11` without overwriting the remote `config/example.toml`, rebuilt `cold-display-guard:dev`, and restarted only `cold-display-guard-api` plus `cold-display-guard-runtime`.
|
|
- Natural post-deploy traffic did not arrive during the 2-minute observation window, so final runtime verification used the deployed container to build representative batch/case webhook payloads with the live remote config and confirmed `camera_ip = 192.168.3.4` plus all new downstream fields were present.
|