wifi-densepose/tools
ruv f9c98809c2 feat(adr-124/phase4): BFLD tool family — bfld.last_scan + bfld.subscribe (ADR-124 §4.1)
Advances SPARC Phase 4 (Refinement): implements the first two ADR-124 §4.1
sensing tools, which also serve as integration tests for the schema-validation
gate wired in Phase 3 (iter 3).

New files:
  src/tools/bfld-last-scan.ts
    - bfldLastScanSchema: z.object with optional node_id (min 1) + optional
      sensing_server_url — enforces the ADR-124 §4.1 input contract
    - bfldLastScan(): proxies GET /api/v1/bfld/<node_id>/last_scan from the
      sensing-server; returns BfldLastScanResult{ok,node_id,identity_risk_score,
      privacy_class,n_frames,timestamp_ms} on success
    - Converts BfldEvent.timestamp_ns (ns) → timestamp_ms (ms)
    - Uses person_count as n_frames proxy per ADR-118 BfldEvent shape
    - Returns {ok:false,warn:true} when server unreachable (soft-failure convention)

  src/tools/bfld-subscribe.ts
    - bfldSubscribeSchema: z.object with required duration_s (positive, max 3600)
    - bfldSubscribe(): POST /api/v1/bfld/<node_id>/subscribe?duration_s=<n>
    - Synthetic envelope fallback: when server unreachable, synthesises a valid
      {subscription_id (UUID v4), expires_at, topic} locally so the schema gate
      is always exercised and the caller can track the intent
    - topic format: ruview/<node_id>/bfld/* (ADR-122 §2.2 wildcard)

src/index.ts:
    - Import bfldLastScan + bfldSubscribe
    - Two new TOOLS entries: ruview.bfld.last_scan + ruview.bfld.subscribe
    - Both go through the TOOL_INPUT_SCHEMAS schema-validation gate (iter 3)

New test: tests/bfld-tools.test.ts (14 assertions):
    - bfldLastScan: unreachable → ok:false+warn:true, malformed path,
      ns→ms arithmetic, null identity_risk_score coalescing
    - BfldLastScanInputSchema: empty object accepted, empty node_id rejected
    - bfldSubscribe: subscription_id defined + future expires_at, UUID v4 format,
      expires_at timing accuracy (±50ms), topic pattern match
    - BfldSubscribeInputSchema: duration_s > 3600 rejected, duration_s=0 rejected

Test results: 75/75 PASS (+14). Build: tsc clean.

ACs touched: ADR-124 §4.1 ruview.bfld.last_scan + ruview.bfld.subscribe.
  SPARC Phase 4 gate: acceptance criteria have passing tests; code review
  against spec complete; no critical issues.

Next iter target: Phase 4 continued — ruview.presence.now + ruview.vitals.*
  tool handlers (4 tools), following the same pattern; then Phase 5 (Completion)
  with package metadata, CHANGELOG, and witness-bundle extension.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-24 22:16:02 -04:00
..
ruview-cli feat(tools/ruview-mcp): M2 — wire real inference via cog health (#706) 2026-05-21 23:43:32 -04:00
ruview-mcp feat(adr-124/phase4): BFLD tool family — bfld.last_scan + bfld.subscribe (ADR-124 §4.1) 2026-05-24 22:16:02 -04:00