Knowledge of the GuardState KB containment hierarchy in the selena-chat edge function. Use this whenever touching guardState.ts, modifying the system prompt hierarchy, or any task that could affect how Selena responds to sensitive topics, competitive questions, or out-of-scope requests.
supabase/functions/selena-chat/guardState.ts (549 lines) is a containment overlay system that enforces a strict knowledge base (KB) hierarchy on every Selena response. It acts as a constitutional layer on top of the AI model's outputs.
Never bypass, reorder, or weaken the GuardState hierarchy. This system protects Kasandra's brand, prevents competitive disclosure, and keeps Selena legally compliant as a real estate AI concierge.
KB-0 → Absolute prohibitions (never say, never do — non-negotiable)
Brokerage Truth → Kasandra-specific facts (brokerage, licensing, territory)
Conversational → Doctrine of how Selena speaks and behaves
STATE GUARD → The guardState.ts enforcement layer (this file)
Mode Instructions → Mode-specific behavior (Orientation/Clarity/Confidence/Handoff)
KB-0 always wins. If any instruction conflicts with KB-0, KB-0 takes precedence.
Modes (psychological progression — 4 states, one-directional per session):
modeContext.tsJourney States (TOFU/MOFU/BOFU — lead funnel classifier):
Mode 1 — ORIENTATION → First contact. Educational, non-pushy. NEVER mention booking.
Mode 2 — CLARITY → Intent declared or engaged. Suggest tools/guides. Still no booking.
Mode 3 — CONFIDENCE → Deep engagement. Reflect on progress. No hard booking CTA.
Mode 4 — HANDOFF → Ready to convert. allowBookingCTA: true. No persuasion needed.
Mode transitions are one-directional within a session — never regress a user backward without an explicit session reset.
guardState.ts injects its containment logic into the system prompt assembly in index.ts. The STATE GUARD section appears after Conversational Doctrine and before Mode Instructions in the assembled prompt. Do not move this injection point.
supabase/functions/selena-chat/index.ts — imports and applies guardStatesupabase/functions/selena-chat/modeContext.ts — operates within the mode layer below STATE GUARD