FP-Devicer - v2.0.2
    Preparing search index...

    Class IdentityGraph

    In-memory identity graph that tracks weighted relationships between distinct device identifiers.

    Edges are un-directed but stored with a canonical ordering (deviceIdA < deviceIdB lexicographically) so each pair is represented by exactly one entry.

    This implementation is suitable for single-process deployments. For horizontally-scaled environments, edges should be persisted via a shared store and loaded on startup.

    Index

    Constructors

    Methods

    • Add or reinforce a relationship edge between two devices.

      If an edge already exists for this pair the weight is blended upward (new = max(0.97, old + increment)) and the occurrence count is bumped. New reasons are merged into the existing set without duplication.

      Parameters

      • deviceIdA: string

        First device identifier.

      • deviceIdB: string

        Second device identifier (must differ from A).

      • reason: string

        Human-readable signal that produced this observation.

      • weight: number = 0.3

        Strength of this individual observation in [0, 1]. Defaults to 0.3.

      Returns void

    • Return the raw edge between two specific devices, or undefined if none exists.

      Parameters

      • deviceIdA: string
      • deviceIdB: string

      Returns IdentityEdge | undefined

    • Return all devices that share an identity edge with the given device, sorted by descending edge weight.

      Parameters

      • deviceId: string

        The device to look up.

      Returns RelatedDevice[]

      An array of RelatedDevice, or an empty array if no edges are known for this device.

    • Remove edges whose lastSeen is older than maxAgeMs milliseconds.

      An edge is considered stale when edge.lastSeen + maxAgeMs <= Date.now(), so prune(0) removes all edges regardless of age.

      Parameters

      • maxAgeMs: number

        Maximum allowed edge staleness in milliseconds.

      Returns number

      The number of edges pruned.