Namespace Qavren.Edge.Chat
Classes
- ChatBackendReport
What the shipped native build and this model actually turned out to be.
- ChatClientStatistics
What one client has done since it was resolved.
- ChatHistoryOptions
What history reduction preserves and what it may evict.
- ChatMemoryBudget
Pure, static, no ORT, no GenAI, no I/O - so the entire gate is a tier-1 unit test over a hand-written EdgeResourceSnapshot with no natives at all.
- ChatMemoryBudgetOptions
Everything the memory gate reads, and the one hook that replaces it.
- ChatMemoryDecision
The gate's answer, with every term it read.
- ChatModelInfo
Everything the host knows about the model it is holding.
- ChatModelLease
A borrowed model. Exclusive for the duration of one turn - there is no shared-reader mode, because the GenAI C API is not thread safe and a second generator is a second full KV cache. Disposing releases the lease; the Model and Tokenizer are disposed only when the last lease returns after a drop. This is sub-project 2's
OnnxSessionLeasecontract and it exists for the same reason: every ORT GenAI wrapper type is IDisposable with a finalizer, so a dropped-but-undisposed model pins the whole native graph until GC - jetsam bait - while disposing one under a liveGenerateNextTokenis a native access violation.
- ChatModelPlan
What a consent screen needs, and nothing it does not. No network I/O beyond a stat.
- ChatModelShape
The decoder geometry the memory budget is computed from. A preset declares it - the budget has to refuse before 1.24 GB is mapped, and reading the shape at load time is too late - and the loader cross-checks the declaration against the provisioned
genai_config.jsonfield by field, so a republished model folder is ChatModelShapeMismatch rather than a wrong budget.
- ChatOnnxEdgeBuilderExtensions
Registers on-device chat on the Qavren.Edge builder.
- ChatPreset
One ready-made ORT GenAI model folder: its manifest, its geometry, its defaults.
- ChatPresets
The shipped catalogue, generated by
chat/tools/model-hashes/fetch_chat_model_hashes.pyintoChatPresets.g.cswith literal SHA-256s and a pinned commit revision, exactly as sub-project 2'sEmbeddingPresets.g.csis. The script reads each repo's owngenai_config.jsonand emits the ChatModelShape from it, so no geometry value in this catalogue is hand-typed.There is deliberately no default preset. The two entries carry different licences, and a silently-chosen 1.24 GB download under the Llama 3.2 Community Licence is not a default anyone should inherit.
AddOnnxChattakes a preset as a required argument.Each preset's sampling defaults are the model's own shipped
searchvalues, not this type's defaults (plan adjustment 15): Llama ships 0.6 / 0.9 / 50 and Qwen ships 0.6 / 0.95 / 20, and a preset that silently sampled differently from the publisher's owngenai_config.jsonwould be a quality regression nobody would attribute. ChatPreset's own defaults stay as declared, for a preset somebody writes by hand.
- ChatProvisioningOptions
What provisioning checks before it moves a gigabyte.
- ChatThermalOptions
How thermal pressure paces or stops a turn.
- ChatTurnStatus
One turn's honest record, carried on the final
ChatResponseUpdateand on theChatResponseunder TurnStatus. One strongly-typed record under one key, rather than seven loose string keys.
- EdgeChat
Reads sub-project 4's turn record off an MEAI response without typing a string literal.
- EdgeChatClient
MEAI IChatClient over ORT GenAI.
- EdgeChatEventIds
900-959 is sub-project 4's chat range. Sub-project 1's
EdgeEventIdsis a non-partial static class and sub-project 2'sEdgeAiEventIdsowns 600-899, so sub-project 4 publishes its own and continues the numbering.
- EdgeChatException
Every chat failure that is not a provisioning failure: the environment task, the model host, the memory budget, the shape reader and the decode loop all raise this one type.
- EdgeChatOptions
Everything one registered chat client reads.
- EdgeChatProperties
The
AdditionalPropertieskeys sub-project 4 writes. Public so a consumer never types a string literal and an OpenTelemetry exporter can allow-list them.
- EdgeChatStartupOrder
400-999 is free between sub-project 2's
VectorSchema(300) and sub-project 1'sConsumerDefault(1000). Sub-project 4 does not squat in sub-project 2's band.
- EdgeChatTokenBudgetReducer
Implements MEAI's stable
IChatReducer. System messages are preserved, pinned messages are preserved, then whole groups are evicted oldest-first until the token budget or MaxTurns binds, with MinimumPreservedMessages as the floor. Counts with the model's own tokenizer, not an estimate. Never throws.
- EdgeGenAiOptions
The three switches on the process-wide ORT GenAI runtime. Read once, by the order-400
ChatEnvironmentStartupTask, and by nothing else.
Structs
- ChatBudgetRequest
One question for the memory gate.
- EdgeChatDeviceProfile
Static facts about the device, read once at startup and cached for the life of the process. Everything here is constant, which is what stops this and
IEdgeResourceMonitordrifting apart: per-turn readings come from the monitor and nowhere else.
Interfaces
- IChatModelHost
The ref-counted chat-model host. One per
AddOnnxChatregistration.
- IChatModelProvisioner
The only way a chat model's bytes arrive. Nothing downloads implicitly:
IChatModelHost.AcquireAsyncon an unprovisioned model throws ChatModelNotProvisioned rather than starting a 1.24 GB transfer. The Plan() - consent - ProvisionAsync(IProgress<ModelProvisioningProgress>?, CancellationToken) sequence is what App Store Review 4.2.3(ii) requires ("disclose the size of the download and prompt users before doing so"), expressed in the API rather than left to a README.
- IChatPromptContext
What a formatter may reach. Deliberately not the raw
Tokenizer: the GenAI C API is documented as not thread safe and the decode loop owns the gate.
- IEdgeChatDeviceProfileProvider
Reads EdgeChatDeviceProfile. Three implementations, one per compilation, chosen by
AddGenAiRuntime()behind#if ANDROID/#if IOS || MACCATALYST/#elseexactly as sub-project 2 splitsIEdgeResourceMonitor.
Enums
- ChatMemoryVerdict
What the memory gate decided.
- EdgeChatStopReason
Why a turn ended.
- EdgeGuidancePolicy
How constrained decoding is treated.
- EdgeGuidanceProbeResult
The guidance probe's outcome.
- EdgeMemoryBudgetKind
What
EdgeResourceSnapshot.AvailableMemoryBytesactually measures.
- EdgeTotalMemorySource
Where TotalMemoryBytes came from, because the three sources are not the same measurement and the floor in MinTotalMemoryBytes is a constant compared against all of them.
Delegates
- ChatPromptFormatter
Builds the prompt string handed to the tokenizer.