feat: P1-1 handle resource value push via OPCode_notify

Add OPCode_notify handler in go_push_handler top-level switch
(not inside handlePush) to receive resource value updates from
the controller via xce_notify_data_t/schedUpdateResvals.

- Add 8 CGO union accessors for xce_val_t (which, i32, i64,
  u32, u64, fval, str, bool) since CGO cannot access union fields
- Add handleNotifyData() dispatching NotifyData_data_schedUpdateResvals
  events, iterating xce_resval_list_t and calling cResvalToDistribution
- Add cResvalToDistribution in convert.go with 7 separate switch
  cases for Value_u_* union discriminants (no combining i32/i64)
- Add rawResvalData + rawResvalToDistribution pure-Go version
  in convert_pure.go for testability without CGO
- Add 10 TDD tests covering all 7 value types, nil val guard,
  unknown discriminant, and boolean false
- All 42 backend tests passing
This commit is contained in:
Rongsong Shen 2026-04-17 13:54:03 +00:00
parent dc029a6d14
commit bc3103a6d5
5 changed files with 365 additions and 23 deletions

View file

@ -85,11 +85,14 @@
## P1-1: Handle Resource Value Push
- [ ] **#10 P1-1: Handle resource value push (OPCode_notify)**
- `backend/clib.go` — Add CGO val helpers to preamble (`xce_val_which`, `xce_val_i32`, etc.)
- `backend/clib.go` — Add `OPCode_notify` case at top-level switch in `go_push_handler()` (NOT inside `handlePush()`)
- `backend/clib.go` — Add `handleNotifyData()` for `NotifyData_data_schedUpdateResvals`
- `backend/convert.go` — Add `cResvalToDistribution()` — switch on `Value_u_*` constants, all 7 cases separate
- [x] **#10 P1-1: Handle resource value push (OPCode_notify)**
- `backend/clib.go` — Added 8 CGO val union helpers (`xce_val_which`, `xce_val_i32`, `i64`, `u32`, `u64`, `fval`, `str`, `bool`)
- `backend/clib.go` — Added `OPCode_notify` case at top-level switch in `go_push_handler()` (NOT inside `handlePush()`)
- `backend/clib.go` — Added `handleNotifyData()` for `NotifyData_data_schedUpdateResvals`
- `backend/convert.go` — Added `cResvalToDistribution()` — switches on `Value_u_*` constants, all 7 cases separate
- `backend/convert_pure.go` — Added `rawResvalData` struct + `rawResvalToDistribution()` pure-Go version
- `backend/convert_test.go` — 10 TDD tests covering all 7 value types, nil val, unknown discriminant, boolean false
- All 42 backend tests passing (`CGO_ENABLED=0 go test ./backend/ -v`)
---