-- Optional manual mapping for rank profile selection.
-- Used by rank.h: SELECT profile, confidence FROM host_intent WHERE host_id=?

CREATE TABLE IF NOT EXISTS host_intent (
  host_id INT(10) UNSIGNED NOT NULL,
  profile VARCHAR(32) NOT NULL,
  confidence DOUBLE NOT NULL DEFAULT 1.0,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (host_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Example mappings
-- REPLACE INTO host_intent(host_id, profile, confidence) VALUES (123, 'ecommerce', 0.95);
-- REPLACE INTO host_intent(host_id, profile, confidence) VALUES (456, 'docs', 0.90);

-- Optional heuristic cache (filled by runtime when no manual mapping is present).
CREATE TABLE IF NOT EXISTS host_intent_cache (
  host_id INT(10) UNSIGNED NOT NULL,
  profile VARCHAR(32) NOT NULL,
  confidence DOUBLE NOT NULL DEFAULT 0,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (host_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
