Skip to content

Validation

Structural validation and the deterministic confidence heuristic.

Confidence is not a probability and it is not a model score. It is a fixed function of the type, the validation result, and noise tags. The same indicator always receives the same score.

Functions:

  • ipv4_class –

    Classify an IPv4 address the way the sieve tags noise.

  • ipv6_tags –

    Return a single noise tag for an IPv6 address, or an empty tuple.

  • validation_notes –

    Return reason codes for a normalized value. Empty means structurally valid.

  • domain_notes –

    Validate a host name against label rules and the bundled TLD list.

  • confidence_for –

    Score an indicator from its validation result and noise tags.

ipv4_class

ipv4_class(ip: str) -> str | None

Classify an IPv4 address the way the sieve tags noise.

Parameters:

  • ip (str) –

    Dotted IPv4 address. Octets are not re-validated here.

Returns:

  • str | None –

    private, loopback, link-local, cgnat, multicast,

  • str | None –

    reserved, or None for an ordinary public address.

ipv6_tags

ipv6_tags(address: IPv6Address) -> tuple[str, ...]

Return a single noise tag for an IPv6 address, or an empty tuple.

Tags come from :mod:ipaddress: loopback, link-local, multicast, private (unique-local), then reserved or unspecified.

validation_notes

validation_notes(kind: str, normalized: str) -> tuple[str, ...]

Return reason codes for a normalized value. Empty means structurally valid.

Parameters:

  • kind (str) –

    Type key.

  • normalized (str) –

    Canonical value.

Returns:

  • tuple[str, ...] –

    A tuple of stable codes such as tld-not-recognized.

domain_notes

domain_notes(domain: str) -> tuple[str, ...]

Validate a host name against label rules and the bundled TLD list.

Parameters:

  • domain (str) –

    Normalized host name.

Returns:

  • str –

    Reason codes. tld-not-recognized means the last label is neither in

  • ... –

    the bundled root-zone list nor in the small special-use set.

confidence_for

confidence_for(*, kind: str, valid: bool | None, tags: tuple[str, ...]) -> float

Score an indicator from its validation result and noise tags.

The result is rounded to two decimals and clamped to 0.01-0.99.

  • Invalid: 0.25
  • Validation skipped: 0.55
  • Valid: 0.80
  • Tagged IP, IPv6, or CIDR: subtract 0.15
  • Valid untagged IP or IPv6: add 0.10
  • Valid hash, JA3, JA3S, or JARM: add 0.10

Parameters:

  • kind (str) –

    Type key.

  • valid (bool | None) –

    Validation result, or None when validation did not run.

  • tags (tuple[str, ...]) –

    Noise tags.

Returns:

  • float –

    A heuristic score. It is not a probability.