feat: add webhook case management

This commit is contained in:
2026-06-09 11:13:56 +08:00
parent 490b3089d2
commit 9d791be174
17 changed files with 1982 additions and 12 deletions

View File

@@ -1,10 +1,51 @@
# Task Todo
- [x] Review the current `AGENTS.md` structure and check for existing `tasks/` tracking files.
- [x] Check in on the plan before implementation and keep this change scoped to the requested documentation update.
- [x] Merge the requested workflow orchestration, task management, and execution principles into `AGENTS.md`.
- [x] Verify the updated `AGENTS.md` content against the requested rules and record the review result here.
- [x] Review the current project instructions and check for task-relevant lessons.
- [x] Check repository status before writing the implementation plan.
- [x] Inspect existing engine, CLI, docs, and frontend event handling for disposal-tracking impact.
- [x] Write the design spec for webhook case management in an isolated worktree.
- [x] Confirm the design with the user before implementation.
## Review
## Design Review
- Verified by re-reading `AGENTS.md` and checking the inserted sections for plan-first workflow, `tasks/todo.md` tracking, `tasks/lessons.md` review/update rules, subagent guidance, verification requirements, and simplicity/minimal-impact principles.
- Spec path: `docs/superpowers/specs/2026-06-09-webhook-case-management-design.md`
- Scope fixed to local case management plus outbound and inbound webhook integration.
- Confirmed behaviors:
- manual handling and external callback handling are both supported
- cases are created from `time_alarm`, `batch_pending_disposal`, and `warning_escalated`
- both batch-event webhooks and case-state webhooks are required
- callback `status` is exactly `handled`
- callback-applied case handling must emit a `case_event` webhook
## 2026-06-09 Implementation Plan
- [x] Create isolated worktree for implementation on branch `feat/webhook-case-management`.
- [x] Re-check runtime baseline in the worktree and note the local Python environment requirement.
- [x] Write the detailed implementation plan to `docs/superpowers/plans/2026-06-09-webhook-case-management-implementation.md`.
- [x] Execute backend case-state TDD cycle.
- [x] Execute webhook integration TDD cycle.
- [x] Execute management API TDD cycle.
- [x] Execute frontend case-management TDD cycle.
- [x] Run full verification and record outcomes.
## 2026-06-09 Implementation Review
- Worktree path: `/Users/glo/.config/superpowers/worktrees/cold_display_guard/webhook-case-management`
- Baseline note: the default `python3` in this shell resolves to macOS system Python 3.9 and cannot import the repo's `dataclass(..., slots=True)` code. Python verification in this worktree must run through `eval "$(/opt/homebrew/bin/pyenv init -)" && python ...`, which resolves to Python 3.12.11.
- Frontend baseline check in the worktree passed with `node --test web/test/zone-state.test.js`.
- Implemented:
- `src/cold_display_guard/cases.py` for case lifecycle and JSONL persistence
- `src/cold_display_guard/webhooks.py` for outbound event/case webhook delivery and audit logging
- runtime integration in `src/cold_display_guard/main.py`
- case listing/summary/manual-handle/callback routes in `src/cold_display_guard/manage_api.py`
- frontend case summary and manual-handle flow in `web/src/main.js` and `web/src/zone-state.js`
- Targeted verification passed during implementation:
- `eval "$(/opt/homebrew/bin/pyenv init -)" && PYTHONPATH=src python -m unittest tests/test_cases.py -v`
- `eval "$(/opt/homebrew/bin/pyenv init -)" && PYTHONPATH=src python -m unittest tests/test_webhooks.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_manage_api.py -v`
- `node --test web/test/zone-state.test.js`
- Final verification passed:
- `eval "$(/opt/homebrew/bin/pyenv init -)" && PYTHONPATH=src python -m unittest discover -s tests -v`
- `cd web && pnpm build`
- Frontend build note: the isolated worktree needed `cd web && pnpm install --frozen-lockfile` before `pnpm build` because `node_modules` are not shared into new worktrees.