caching2

@startuml
title Cache Miss → Hydrate → AI Tables → Consumer Query (Minimal)


skinparam sequence {
  ArrowColor black
  ArrowThickness 1
  ParticipantBorderColor black
  ParticipantBackgroundColor #FFFFFF
  LifeLineBorderColor black
  LifeLineBackgroundColor #FFFFFF
}


actor Consumer as C
participant "Kafka Brokers" as K
participant "Fast Cache (NVMe/SSD)" as FC
participant "Cold Tier (Object Store)" as CT
participant "AI Pipelines\n(Chunk/Embed, Feature Compute)" as AIP
database "Lakehouse\n(AI Tables: Features, Embeddings, Labels)" as LH


== Operational read ==
C -> K : Subscribe / poll for records
K -> FC : Read segment/key
FC --> K : MISS
FC -> CT : Hydrate segment/key (fetch)
CT --> FC : Segment bytes
FC --> K : Segment pointer / data (PROMOTE)
K --> C : Deliver records (ms SLO)


note over FC,CT
  Hydrate under SLO (e.g., p95 < 250 ms).
  Segment promoted to cache on success.
end note


== Stream → AI tables (parallel/continuous) ==
K -> AIP : Stream events/docs
AIP -> LH : Write/merge to AI Tables
LH --> AIP : Ack / checkpoint


note over AIP,LH
  Features, embeddings, labels
  materialized for training & RAG.
end note


== Analytics / AI batch reads ==
C -> LH : BI/ML/RAG query on AI Tables
LH --> C : Result set
@enduml