From d7179364a19905a70475fb423844b6dfa7692a1c Mon Sep 17 00:00:00 2001 From: slhafzjw Date: Tue, 24 Mar 2026 10:29:15 +0800 Subject: [PATCH] refactor(context): forces the context of the first domain hit to be fully expanded to adapt to the context focus needs within the module --- .../partner/core/cognition/ContextWorkspace.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Partner-Core/src/main/java/work/slhaf/partner/core/cognition/ContextWorkspace.kt b/Partner-Core/src/main/java/work/slhaf/partner/core/cognition/ContextWorkspace.kt index dc6c0f83..1e559e7f 100644 --- a/Partner-Core/src/main/java/work/slhaf/partner/core/cognition/ContextWorkspace.kt +++ b/Partner-Core/src/main/java/work/slhaf/partner/core/cognition/ContextWorkspace.kt @@ -28,6 +28,7 @@ class ContextWorkspace { if (domains.isEmpty()) { return@write emptyList() } + val primaryDomain = domains.first() val domainWeights = domains .distinct() @@ -52,7 +53,8 @@ class ContextWorkspace { activeBlocks += ResolvedContextBlock( block = block, domainWeight = matchedDomains.sumOf { domainWeights.getValue(it) }, - activationScore = activationScore + activationScore = activationScore, + forceFullRender = primaryDomain in matchedDomains ) } @@ -64,7 +66,13 @@ class ContextWorkspace { .thenBy { it.activationScore } .thenBy { it.block.blockContent.encodeToXmlString() } ) - .map { it.block.render() } + .map { resolved -> + if (resolved.forceFullRender) { + resolved.block.blockContent + } else { + resolved.block.render() + } + } } @@ -101,7 +109,8 @@ class ContextWorkspace { private data class ResolvedContextBlock( val block: ContextBlock, val domainWeight: Int, - val activationScore: Double + val activationScore: Double, + val forceFullRender: Boolean ) data class ContextBlock @JvmOverloads constructor(