Files
Heimdall/skills/mdns-camera-discovery/SKILL.md
T
arnaud.dartois 636154572b
Heimdall Gitea / Detect CI scope (push) Successful in 6s
Heimdall Gitea / Build and tests (push) Successful in 19m19s
Heimdall Gitea / Publish versioned release (push) Skipped
Heimdall Gitea / Build and scan server image (push) Successful in 6m13s
Heimdall Gitea / Build and scan agent image (push) Successful in 14m44s
Heimdall Gitea / Publish Docker Hub latest tags (push) Successful in 1m48s
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Successful in 19m9s
Heimdall Gitea / CI policy (push) Successful in 10s
Complete remaining Heimdall features and acceptance
Merge pull request #138

Co-authored-by: Arnaud Dartois <admin@tordais.cc>
2026-11-06 11:14:49 +01:00

4.1 KiB

name, description
name description
mdns-camera-discovery Implement and validate HomeKit camera discovery from DNS-SD mDNS announcements in Heimdall Agent.

Heimdall mDNS camera discovery

Read AGENTS.md, the mDNS #81 entry in todo.md, skills/heimdall-dotnet/SKILL.md, and skills/compose-disposable-recipe/SKILL.md before changing discovery behavior.

Ownership and data flow

  • Heimdall.Mdns/MdnsClient owns UDP multicast and DNS-SD PTR/SRV/TXT/A parsing. Keep network operations cancellable and dispose sockets per operation.
  • HomeKitMdnsProbe maps only categories 17 (camera) and 18 (doorbell) into Agent discovery records.
  • NetworkCameraScanner is the Agent-side source of LAN probes. Preserve HomeKit metadata when its TCP scan has already found the same IP. Central persists and returns metadata; it must not probe the camera LAN.
  • Resolve an accessory address from an A record attached to the instance or from the exact SRV target hostname. Never use another advertisement's arbitrary A record as a fallback.
  • At Central confirmation, persist only capabilities proven by the discovery result and selected stream. Derive RTSP port from the selected RTSP URL (554 default for RTSP, 322 for RTSPS when omitted) or a probed RTSP port, HTTP port from the HTTP probe, and ONVIF service port from the device-service URL. Do not confuse UDP WS-Discovery port 3702 with the camera's HTTP ONVIF service port. Do not claim PTZ, audio, snapshot, or native motion support unless the probe actually verifies it.

Synthetic acceptance

  • Build synthetic DNS response packets with PTR _hap._tcp.local → instance, SRV instance → hostname/port, TXT ci, sf, id, md, and A hostname → address. Include an unrelated A record to verify strict SRV association.
  • Verify camera and doorbell categories are kept, unrelated categories are filtered, sf=0 maps to paired, and missing SRV-target A does not invent an address.
  • Verify HomeKitMdnsProbe maps address/name/id/model/category/pairing/port into its Agent contract, and cancellation yields an empty result.
  • Run the focused Agent tests and the full Agent test project after changes.
  • The synthetic packet path validates DNS assembly and mapping only. A disposable Compose test can exercise the Agent source in isolation; only a real camera on a representative LAN validates multicast routing and hardware behavior. Keep that item open until such a run exists.
  • The PostgreSQL integration scenario ConfirmDiscovery_PersistsOnlyVerifiedPortsAndCapabilities exercises confirmation from discovery metadata through persisted camera fields, including an ONVIF service port distinct from UDP 3702. Preserve that relational coverage when changing confirmation mapping.

Disposable Compose

Run a one-shot isolated Compose test from the changed source with the SDK pinned by global.json (currently mcr.microsoft.com/dotnet/sdk:10.0.100). Copy only the Agent test project and its referenced source projects into a temporary directory outside the repository. Restore with --locked-mode, then run only HomeKitMdnsProbeTests; these tests synthesize DNS-SD response packets and exercise the parser plus Agent mapping without multicast privileges or access to the LAN. Use a unique Compose project, project-scoped NuGet volume, and isolated bridge; publish no ports and never use host networking. Install an EXIT cleanup trap before starting. This recipe builds no local images: remove only the named project with down --volumes --remove-orphans, verify its containers, volumes, and network are gone, then delete the source copy, retaining the shared SDK image. Record local image tags: none in the acceptance result. If a future variant builds an app/helper image, tag it uniquely and remove/verify that exact tag in the same cleanup trap. This proves source/test behavior in a container, not multicast delivery or camera discovery on a real LAN.

This SDK-only recipe creates no local Heimdall image. Retain the shared SDK base image; if future changes add a local build, use a project-unique tag and remove/verify that exact tag after teardown under skills/compose-disposable-recipe/SKILL.md.