wifi-densepose/v2/crates/wifi-densepose-bfld/examples
ruv 519e0044b1 feat(adr-118/p6.13): examples/bfld_handle.rs worker-thread pattern (319/319 GREEN)
Iter 48. Ships the production-recommended operator example: full
lifecycle through the worker-thread handle. Companion to iter-47's
minimal example which uses BfldPipeline::process directly. The
handle example demonstrates the multi-thread pattern operators
actually deploy with HA + MQTT.

Lifecycle demonstrated in the example:
  1. publish_availability_online (retained → HA marks device online)
  2. publish_discovery (retained → HA auto-creates 6 BFLD entities)
  3. BfldPipelineHandle::spawn (worker owns gate + ring + hasher)
  4. handle.send(input) per BFI frame (worker process + publish)
  5. handle.shutdown() (clean worker join)
  6. publish_availability_offline (explicit graceful disconnect)

Example output (verified pre-commit):
  bootstrap: 1 availability + 6 discovery payloads
  total messages published: 33
  first three topics:
    ruview/seed-handle-demo/bfld/availability
    homeassistant/binary_sensor/seed-handle-demo_bfld_presence/config
    homeassistant/sensor/seed-handle-demo_bfld_motion/config
  last three topics:
    ruview/seed-handle-demo/bfld/confidence/state
    ruview/seed-handle-demo/bfld/identity_risk/state
    ruview/seed-handle-demo/bfld/availability

Added:
- v2/crates/wifi-densepose-bfld/examples/bfld_handle.rs (~110 LOC):
    * Documents the 6-phase lifecycle with inline comments
    * Pointer to RumqttPublisher::connect_with_lwt for prod use
    * 5 sensing frames × 5 state topics = 25 per-frame messages
- v2/crates/wifi-densepose-bfld/tests/example_handle.rs (4 named tests):
    handle_example_documents_full_lifecycle_phases
      (doc drift guard: 8 operator-facing symbols must appear)
    handle_example_carries_run_instructions_and_prod_pointer
      (cargo run line + RumqttPublisher pointer present)
    handle_example_lifecycle_produces_expected_message_counts
      *** Re-executes full lifecycle inline; asserts total == 33,
          first message payload == "online", last == "offline" ***
    handle_example_returns_box_dyn_error_for_main_signature
- v2/crates/wifi-densepose-bfld/Cargo.toml:
    [[example]] name = "bfld_handle", required-features = ["std"]

ADR-124 status (iter step 0 sibling check):
- docs/adr/ADR-124-rvagent-mcp-ruvector-npm-integration.md unchanged
  at 431 lines. SENSE-BRIDGE scope remains orthogonal.

ACs progressed:
- ADR-118 §2.1 documentation surface — two runnable operator examples
  now shipped (iter 47 minimal, iter 48 worker-thread). Together
  they cover the two operator patterns: simple in-process consumer
  (process + to_json) and the full HA-integration deployment
  (handle + bootstrap + lifecycle).
- ADR-122 §2.1 + §2.2 + §2.6 — the worker example exercises every
  layer of the HA-DISCO publish chain in one runnable file:
  availability, discovery, state, graceful shutdown.

Test config:
- cargo test --no-default-features → 101 passed (example_handle cfg-out)
- cargo test                       → 319 passed (315 + 4)

Out of scope (next iter target):
- PR-readiness pivot still pending. External-resource-gated work
  (KIT BFId, Pi5/Nexmon) still skipped.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-24 19:52:59 -04:00
..
bfld_handle.rs feat(adr-118/p6.13): examples/bfld_handle.rs worker-thread pattern (319/319 GREEN) 2026-05-24 19:52:59 -04:00
bfld_minimal.rs feat(adr-118/p6.12): examples/bfld_minimal.rs operator quickstart (315/315 GREEN) 2026-05-24 19:49:16 -04:00