// Excerpt published for audit — source of truth lives in
// PredictiveOverlayApp/CaptureRouter/CaptureRouterController.swift
//
// This is the trigger matcher only: how Doubleslash decides that a
// keystroke stream completed `//command` + space/return.
// Surrounding strip / overlay / Pro-gate code omitted for clarity.

/*
 Space (49) or Return (36) -> Check for trigger matching
 if keyCode == 49 || keyCode == 36 {
     let spaceChar = keyCode == 49 ? " " : "\n"
     normalBuffer.append(spaceChar)

     for target in registeredTargets {
         let triggerBody = "//\(target.commandName)"
         let triggerCmd = triggerBody + spaceChar
         if let lastChar = normalBuffer.last,
            (lastChar == " " || lastChar == "\n") {
             let withoutDelimiter = String(normalBuffer.dropLast())
             // Case-insensitive command match
             guard withoutDelimiter.lowercased().hasSuffix(triggerBody) else { continue }

             // Word boundary: first '/' preceded by whitespace or start
             let prefixLength = normalBuffer.count - triggerCmd.count
             let isBoundary: Bool
             if prefixLength == 0 {
                 isBoundary = true
             } else {
                 let prevCharIndex = normalBuffer.index(normalBuffer.startIndex, offsetBy: prefixLength - 1)
                 let prevChar = normalBuffer[prevCharIndex]
                 isBoundary = prevChar.isWhitespace || prevChar == "\n"
             }

             if isBoundary {
                 // Free targets never gated. Pro targets may nudge upgrade.
                 // Delimiter is swallowed; strip length = triggerCmd.count - 1
                 // Then: async strip host (OFF the CGEvent tap thread) → show HUD.
                 ...
             }
         }
     }
 }
*/

// Invariants auditors care about:
// 1. No AXUIElement / usleep / disk / network on the CGEvent tap callback thread.
// 2. Only a short sliding buffer is kept for // matching — not a keystroke log.
// 3. Secure Input / password fields are rejected before buffering (PrivacyFirewall).
