Presence tracking creates a discovered device for every new hardware address it sees #145

Open
opened 2026-10-31 12:42:14 -04:00 by claude · 0 comments
Owner
  • Draft: PN-3
  • Priority: high (this is the feature itself)
  • Agent: coder
  • Depends on: #144
  • Decisions: Q-PN-1

Why

ClientPresenceFlushService.FlushAsync (src/dotnet/src/Ninlil.Dns.Server.ClientIdentity/Presence/ClientPresenceFlushService.cs:163-278) updates only stored address rows. Sightings with no match are dropped (lines 244-245).

What changes

  • ClientPresenceFlushService.FlushAsync: after the matching loop, take every identity or hardware sighting that matched no stored address and carries a MAC. Create one DnsClientEntity (Origin = Discovered, IsAcknowledged = false, DisplayName empty) plus one DnsClientAddressEntity (IPv4 identity keyed by the colon-separated MAC, FirstSeenUtc/LastSeenUtc = sighting time, Address = sighted address).
    • Technical call: source-address sightings that do not resolve to an identity are never stored. An IP address alone is not a persistent identity (DnsClientEntity.cs:8-12), and these sightings can be spoofed (ClientPresenceTracker.cs:19-24).
    • Technical call: cap new devices per flush with a constant (for example 256) and log one warning when the cap is hit, the same pattern as MaxSourceAddressesPerFlush.
    • Dual-stack linking reuses DhcpClientIdentifierLinkKeys, as DhcpClientRegistryAutoPopulationService does (src/dotnet/src/Ninlil.Dhcp.Server.DnsIntegration/DhcpClientRegistryAutoPopulationService.cs:29-39).
    • New rows must raise the entity-change signal, unlike sighting updates (lines 268-275), so DnsClientDirectory reloads.
  • ClientPresenceOptions.cs: add bool EnableDeviceDiscovery, default true. Update ENVIRONMENT.md (row, default, totals counted from OptionsEnvironmentVariableMap.BuildMappings). Rewrite the "presence never registers devices" sentences in the class summaries.
  • README.md presence section: discovery is on by default and how to turn it off.

Acceptance

  • This test fails first: in src/dotnet/tests/Ninlil.Dns.Server.ClientIdentity.Tests, FlushAsync_ForAnUnknownHardwareSighting_CreatesADiscoveredClient asserts one client with Origin == Discovered and one address with the MAC.
  • Tests: discovery off creates nothing; a sighting of a MAC embedded in a known DUID links and does not create; the per-flush cap; a source-address-only sighting creates nothing; the option defaults to true.
  • ENVIRONMENT.md and README.md updated.
  • Gate: dotnet test src/dotnet/tests/Ninlil.Dns.Server.ClientIdentity.Tests, dotnet test src/dotnet/tests/Ninlil.Web.Tests.

Source

audit-feature-parity.md §2A #10; ClientPresenceFlushService.cs:31-33.
Owner decision 2026-10-31: "discovery on by default" (Q-PN-1).

- **Draft:** PN-3 - **Priority:** high (this is the feature itself) - **Agent:** coder - **Depends on:** #144 - **Decisions:** Q-PN-1 ### Why `ClientPresenceFlushService.FlushAsync` (`src/dotnet/src/Ninlil.Dns.Server.ClientIdentity/Presence/ClientPresenceFlushService.cs:163-278`) updates only stored address rows. Sightings with no match are dropped (lines 244-245). ### What changes - `ClientPresenceFlushService.FlushAsync`: after the matching loop, take every identity or hardware sighting that matched no stored address and carries a MAC. Create one `DnsClientEntity` (`Origin = Discovered`, `IsAcknowledged = false`, `DisplayName` empty) plus one `DnsClientAddressEntity` (IPv4 identity keyed by the colon-separated MAC, `FirstSeenUtc`/`LastSeenUtc` = sighting time, `Address` = sighted address). - Technical call: source-address sightings that do not resolve to an identity are never stored. An IP address alone is not a persistent identity (`DnsClientEntity.cs:8-12`), and these sightings can be spoofed (`ClientPresenceTracker.cs:19-24`). - Technical call: cap new devices per flush with a constant (for example 256) and log one warning when the cap is hit, the same pattern as `MaxSourceAddressesPerFlush`. - Dual-stack linking reuses `DhcpClientIdentifierLinkKeys`, as `DhcpClientRegistryAutoPopulationService` does (`src/dotnet/src/Ninlil.Dhcp.Server.DnsIntegration/DhcpClientRegistryAutoPopulationService.cs:29-39`). - New rows must raise the entity-change signal, unlike sighting updates (lines 268-275), so `DnsClientDirectory` reloads. - `ClientPresenceOptions.cs`: add `bool EnableDeviceDiscovery`, default `true`. Update ENVIRONMENT.md (row, default, totals counted from `OptionsEnvironmentVariableMap.BuildMappings`). Rewrite the "presence never registers devices" sentences in the class summaries. - README.md presence section: discovery is on by default and how to turn it off. ### Acceptance - [ ] This test fails first: in `src/dotnet/tests/Ninlil.Dns.Server.ClientIdentity.Tests`, `FlushAsync_ForAnUnknownHardwareSighting_CreatesADiscoveredClient` asserts one client with `Origin == Discovered` and one address with the MAC. - [ ] Tests: discovery off creates nothing; a sighting of a MAC embedded in a known DUID links and does not create; the per-flush cap; a source-address-only sighting creates nothing; the option defaults to `true`. - [ ] ENVIRONMENT.md and README.md updated. - [ ] Gate: `dotnet test src/dotnet/tests/Ninlil.Dns.Server.ClientIdentity.Tests`, `dotnet test src/dotnet/tests/Ninlil.Web.Tests`. ### Source `audit-feature-parity.md` §2A #10; `ClientPresenceFlushService.cs:31-33`. Owner decision 2026-10-31: "discovery on by default" (Q-PN-1).
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#145
No description provided.