ข้ามไปยังเนื้อหา

Hybrid Context and Scope Resolution

ระบบใช้ทั้งสองทางพร้อมกัน:

  1. Push context: BFF ส่ง scope/context ไปกับ payload ตอนเรียก AI
  2. Pull context: internal routes ให้ระบบภายในดึง context เพิ่มเติมตาม scope claims
flowchart LR
  UI["Client request"] --> BFF["AI API boundary"]
  BFF --> P1["Push canvas context"]
  BFF --> P2["Push dashboard context"]
  BFF --> ENG["AI engine"]
  ENG --> INT["Internal context API"]
  INT --> DB["Scoped data store"]
  DB --> INT
  INT --> ENG
flowchart TB
  A["Incoming route"] --> B["Resolve thread context"]
  B --> C["Derive effective scope"]
  C --> D{"URL is canonical?"}
  D -- no --> E["Replace with canonical path"]
  D -- yes --> F["Continue runtime"]
  E --> F
  • maps mode ต้องถือ mapId เป็น canonical เสมอ
  • analytics mode ต้องถือ dashboardId เป็น canonical เสมอ
  • board semantics ใช้กับ idea/strategy เป็นหลัก
  • share flows ต้องตรวจ role/scope ก่อนเปิด read/write operations
  • new chat path ควรผ่าน session start และส่งกลับ scopeKind/scopeId/sv เพื่อให้ URL canonical ตั้งแต่ต้น
  1. route มี thread แต่ขาด scope key -> ต้องเติมจาก metadata
  2. scope ใน URL ไม่ตรงกับ thread mapping -> ต้อง deny หรือ recover
  3. claim-scope mismatch ใน internal routes -> hard error
  4. legacy fallback hit บ่อยผิดปกติ -> สัญญาณว่าต้อง deprecate branch นั้น