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>
4.3 KiB
4.3 KiB
Task Todo
- Review the current project instructions and check for task-relevant lessons.
- Inspect the OTA upload API document and current runtime/webhook capture path.
- Create an isolated worktree for alarm snapshot upload implementation.
- Write the detailed implementation plan to
docs/superpowers/plans/2026-06-09-alarm-snapshot-upload.md. - Execute alarm snapshot upload client TDD cycle.
- Execute runtime and webhook payload integration TDD cycle.
- Update config surface, docs, and verification notes.
- Run targeted verification and final full verification.
Notes
tasks/lessons.mdis 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
BatchEngineand enriches webhook payloads from the runtime side using the already captured frame. - Implemented
src/cold_display_guard/alarm_snapshots.pyfor JPEG encoding plus OTA chunk-upload orchestration, runtime integration insrc/cold_display_guard/main.py, webhook payload enrichment insrc/cold_display_guard/webhooks.py, config exposure/secret stripping insrc/cold_display_guard/config.pyandsrc/cold_display_guard/manage_api.py, and config/doc updates inconfig/example.tomlandREADME_zh.md. - Targeted verification passed:
eval "$(/opt/homebrew/bin/pyenv init -)" && PYTHONPATH=src python -m unittest tests/test_alarm_snapshots.py -veval "$(/opt/homebrew/bin/pyenv init -)" && PYTHONPATH=src python -m unittest tests/test_main.py -veval "$(/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 -vcd web && pnpm install --frozen-lockfile && pnpm build
Current Task: Webhook Payload Field Gap Check
- Pull the actual payload currently received by
video-recognitionand compare it against the required event list fields. - Patch webhook payload builders to include the missing non-store fields required by the downstream table.
- Add or update focused webhook tests for the enriched payload shape.
- 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, andzone_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-recognitionresult JSONL on10.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.pyso bothbatch_eventandcase_eventnow include:event_codecamera_ipstarted_atended_atremoved_atdwell_secondsis_discardeddiscarded_atcreated_atalerted_atalarm_atupdated_at
case_eventalso now carries the missing contextual fieldscamera_id,zone_id, andzone_label.- Verification passed:
PYTHONPATH=src python3 -m unittest tests/test_webhooks.py -vPYTHONPATH=src python3 -m unittest tests/test_main.py -vPYTHONPATH=src python3 -m unittest discover -s tests -v
- Deployed updated code to
xiaozheng@10.8.0.11without overwriting the remoteconfig/example.toml, rebuiltcold-display-guard:dev, and restarted onlycold-display-guard-apipluscold-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.4plus all new downstream fields were present.