///|
/// A parsed RFC 9309 Allow or Disallow record.
pub(all) struct RobotsRule {
  allow : Bool
  pattern : String
  line : Int
} derive(Debug, Eq)

///|
/// One robots group with normalized product tokens and ordered rules.
pub(all) struct RobotsGroup {
  user_agents : Array[String]
  rules : Array[RobotsRule]
} derive(Debug, Eq)

///|
/// Parsed robots policy plus non-core records kept for reporting.
pub(all) struct RobotsDocument {
  groups : Array[RobotsGroup]
  sitemap_locations : Array[String]
  other_records : Array[(String, String)]
} derive(Debug, Eq)

///|
/// Observable robots decision and winning rule provenance.
pub(all) struct RobotsDecision {
  allowed : Bool
  matched_rule : RobotsRule?
  matched_user_agent : String?
} derive(Debug, Eq)

///|
/// Sitemap URL entry from the protocol namespace.
pub(all) struct SitemapUrl {
  loc : String
  lastmod : String?
  changefreq : String?
  priority : Double?
} derive(Debug, Eq)

///|
/// Entry in a Sitemap index.
pub(all) struct SitemapRef {
  loc : String
  lastmod : String?
} derive(Debug, Eq)

///|
/// Parsed Sitemap or Sitemap index.
pub(all) enum SitemapDocument {
  UrlSet(Array[SitemapUrl])
  Index(Array[SitemapRef])
} derive(Debug, Eq)

///|
/// Incremental Sitemap parser events.
pub(all) enum SitemapEvent {
  Url(SitemapUrl)
  Reference(SitemapRef)
} derive(Debug, Eq)

///|
/// Audit severity.
pub(all) enum FindingSeverity {
  Error
  Warning
  Information
} derive(Debug, Eq)

///|
/// Stable offline consistency finding.
pub(all) struct AuditFinding {
  code : String
  severity : FindingSeverity
  subject : String
  message : String
} derive(Debug, Eq)

///|
/// Public parse, match, XML, validation, and audit failures.
pub(all) suberror DiscoveryError {
  InvalidUtf8(component~ : String)
  InvalidRobots(line~ : Int, reason~ : String)
  InvalidUri(uri~ : String, reason~ : String)
  InvalidXml(offset~ : Int, reason~ : String)
  InvalidSitemap(reason~ : String)
  LimitExceeded(kind~ : String, limit~ : Int)
  InvalidArgument(reason~ : String)
} derive(Debug, Eq)