Skip to content

DO NOT MERGE: Hue instrumented capture - #3212

Open
varzac wants to merge 4 commits into
mainfrom
hue-instrumented-capture
Open

DO NOT MERGE: Hue instrumented capture#3212
varzac wants to merge 4 commits into
mainfrom
hue-instrumented-capture

Conversation

@varzac

@varzac varzac commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

varzac and others added 4 commits August 20, 2026 12:19
dkjson.decode returns (value, next_position, error_message), but
process_rest_response propagated all of pcall's captured return values
after decoding, not just the decoded value its own doc comment
promises. That means the parse position (e.g. 74 for a 73-byte body)
gets returned in the position every caller treats as `err`, so every
successful REST call with a JSON body logs a spurious
"Error performing <action>: <parse position>". Found via the first
integration test to exercise a real, successful JSON-decoded REST
response through this path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

philips-hue: fix onmessage misreading json.decode's position as an error

table.pack(pcall(json.decode, msg.data)) followed by table.remove(...,1) to
strip the pcall success flag left `events, err = table.unpack(...)`
capturing dkjson's second return value (the position it stopped scanning
at, a non-nil number even on success) into `err` instead of its real third
return value. Every SSE message was therefore logged as a JSON parse
error and dropped without ever reaching the update/add/delete handling
below -- there was no prior test coverage of this path to catch it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Add capture_logger.lua: Structured JSON logging for all network & IPC
- Add capture_device_wrapper.lua: Automatic device event capture
- Instrument REST client (lunchbox/rest.lua) with request/response logging
- Instrument SSE client (eventsource.lua) with event/connection logging
- Instrument command handlers with IPC logging
- Instrument lifecycle handlers with event logging
- Add CAPTURE_TEST_PLAN.md: 16 comprehensive test scenarios
- Add INSTRUMENTATION_README.md: Documentation and usage guide

This instrumented driver captures:
- All REST API requests/responses with timing
- All SSE events and connection lifecycle
- All commands from hub
- All capability events to hub
- All device lifecycle events (added, init, removed)
- All state changes (fields, datastore)
- Correlation IDs for request->response tracking

Purpose: Capture real-world behavior for refactoring baseline
@varzac varzac added do not merge CGAI Contains code that was generated by AI labels Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

philips-hue_coverage.xml

File Coverage
All files NaN%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against e28e54b

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Results

   73 files  ± 0    552 suites  +11   0s ⏱️ ±0s
3 275 tests +11  3 264 ✅ ± 0  0 💤 ±0  0 ❌ ±0  11 🔥 +11 
5 264 runs  +11  5 253 ✅ ± 0  0 💤 ±0  0 ❌ ±0  11 🔥 +11 

For more details on these errors, see this check.

Results for commit e28e54b. ± Comparison against base commit f46b647.

♻️ This comment has been updated with latest results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CGAI Contains code that was generated by AI do not merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant