feat: implement CreateGrant handler and grant-aware approval engine
- GlobalStreamHandler.handleCreateGrant validates scope (SESSION/STAGE) and sends ProtocolError to client on validation failure instead of silent log.warn + drop. - Derive event stageId directly from GrantScope type, removing redundant stageIdForEvent tuple. - SessionOrchestrator integrates ApprovalEngine to check active grants before requesting user approval for T2+ tool calls. - ContextEntry gains EntryRole (SYSTEM/USER/ASSISTANT/TOOL) field for proper chat message role mapping. - RouterContextBuilder.build is now suspend; uses Tokenizer for accurate token estimation with fallback to character-based estimate. - LlamaCppInferenceProvider maps EntryRole to ChatMessage role instead of heuristic layer-based inference.
This commit is contained in:
@@ -3,6 +3,8 @@ package com.correx.core.context.model
|
||||
import com.correx.core.events.types.ContextEntryId
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
enum class EntryRole { SYSTEM, USER, ASSISTANT, TOOL }
|
||||
|
||||
@Serializable
|
||||
data class ContextEntry(
|
||||
val id: ContextEntryId,
|
||||
@@ -10,5 +12,6 @@ data class ContextEntry(
|
||||
val content: String,
|
||||
val sourceType: String,
|
||||
val sourceId: String,
|
||||
val tokenEstimate: Int
|
||||
val tokenEstimate: Int,
|
||||
val role: EntryRole = EntryRole.USER,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user