refactor: merge cycle policy into semantic validation layer
Wire SemanticValidator into the production validator pipeline and consolidate cycle-policy types under core:validation. - Add SemanticValidator(CycleExitRule(requirePolicyForCycles=false)) to the prod ValidationPipeline (no-op default, preserves behavior) - Move CyclePolicy/Binding/Signature/Factory from core:transitions.policy to core:validation.policy (validation already owns ValidationContext) - Rename CyclePolicyBindingRule -> CycleExitRule (issue code unchanged) - Delete dead CyclePolicyResolver + PolicyValidation
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
package com.correx.core.transitions.policy
|
||||
|
||||
sealed interface CyclePolicy {
|
||||
data class Retry(
|
||||
val maxAttempts: Int
|
||||
) : CyclePolicy
|
||||
|
||||
data class Refinement(
|
||||
val maxIterations: Int
|
||||
) : CyclePolicy
|
||||
|
||||
data class Approval(
|
||||
val timeoutMs: Long
|
||||
) : CyclePolicy
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
package com.correx.core.transitions.policy
|
||||
|
||||
data class CyclePolicyBinding(
|
||||
val cycle: CycleSignature,
|
||||
val policy: CyclePolicy
|
||||
)
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
package com.correx.core.transitions.policy
|
||||
|
||||
class CyclePolicyResolver(
|
||||
private val bindings: Set<CyclePolicyBinding>
|
||||
) {
|
||||
|
||||
fun resolve(signature: CycleSignature): CyclePolicy? {
|
||||
return bindings
|
||||
.firstOrNull { it.cycle == signature }
|
||||
?.policy
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.correx.core.transitions.policy
|
||||
|
||||
import com.correx.core.events.types.StageId
|
||||
import java.util.*
|
||||
|
||||
data class CycleSignature(
|
||||
val nodes: SortedSet<StageId>,
|
||||
val edges: SortedSet<Pair<StageId, StageId>>,
|
||||
)
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
package com.correx.core.transitions.policy
|
||||
|
||||
import com.correx.core.events.types.StageId
|
||||
import com.correx.core.transitions.graph.TransitionEdge
|
||||
import java.util.*
|
||||
|
||||
object CycleSignatureFactory {
|
||||
fun from(nodes: List<StageId>, edges: List<TransitionEdge>): CycleSignature {
|
||||
val nodeSet = TreeSet<StageId>(compareBy { it.value })
|
||||
nodeSet.addAll(nodes)
|
||||
|
||||
val edgeSet = TreeSet<Pair<StageId, StageId>>(
|
||||
compareBy({ it.first.value }, { it.second.value })
|
||||
)
|
||||
edges.forEach { edgeSet.add(it.from to it.to) }
|
||||
|
||||
return CycleSignature(nodes = nodeSet, edges = edgeSet)
|
||||
}
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
package com.correx.core.transitions.policy
|
||||
|
||||
class PolicyValidation {
|
||||
fun validate(
|
||||
bindings: Set<CyclePolicyBinding>,
|
||||
knownCycles: Set<CycleSignature>
|
||||
): List<String> {
|
||||
|
||||
val errors = mutableListOf<String>()
|
||||
|
||||
val bound = bindings.map { it.cycle }.toSet()
|
||||
|
||||
val unbound = knownCycles - bound
|
||||
|
||||
if (unbound.isNotEmpty()) {
|
||||
errors += unbound.map {
|
||||
"Cycle $it has no policy binding"
|
||||
}
|
||||
}
|
||||
|
||||
return errors
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user