feat(v2): compose realtime monitor pipeline

This commit is contained in:
ila
2026-07-22 21:20:13 +08:00
parent d183170554
commit 8e093acb9b
4 changed files with 300 additions and 5 deletions
@@ -208,7 +208,7 @@ git commit -m "feat(v2): add annotated evidence and alert dispatch"
- Create: `v2/internal/monitor/monitor_test.go`
- Modify: `v2/internal/spike/ort.go` only if an interface adapter is needed
- [ ] **Step 1: Write failing orchestration tests using fakes**
- [x] **Step 1: Write failing orchestration tests using fakes**
```go
func TestMonitorPublishesLatestCompletedFrameAndOneAlert(t *testing.T) {
@@ -227,12 +227,12 @@ func TestMonitorDoesNotCreateFallEvidenceOnSourceFailure(t *testing.T) {
}
```
- [ ] **Step 2: Verify the monitor tests fail**
- [x] **Step 2: Verify the monitor tests fail**
Run: `Set-Location v2; go test ./internal/monitor -v`
Expected: FAIL because `internal/monitor` does not exist.
- [ ] **Step 3: Implement the composition boundary**
- [x] **Step 3: Implement the composition boundary**
```go
type PoseRuntime interface { Run([]float32) ([]float32, error); Close() }
@@ -244,12 +244,12 @@ func (m *Monitor) Run(ctx context.Context) { /* source frame -> pose -> fall ->
Create/open one ONNX Runtime instance before consuming frames and close it only when monitoring stops. Treat Pose/preprocess errors as non-fall status updates and continue/reconnect according to source state; do not terminate the Walk message loop. Only completed rendered frames enter the one-slot `Updates` channel, so a slow UI never queues stale video frames.
- [ ] **Step 4: Run monitor, fall and full Go tests**
- [x] **Step 4: Run monitor, fall and full Go tests**
Run: `Set-Location v2; $env:CGO_ENABLED='1'; go test ./internal/monitor ./internal/fall ./...`
Expected: PASS.
- [ ] **Step 5: Commit the monitor slice**
- [x] **Step 5: Commit the monitor slice**
```powershell
git add v2/internal/monitor v2/internal/spike/ort.go