BasicMethod.Map 设计框架:8 个并行基础模块的数学根基与实现

BasicMethod.Map --- 映射与编排基础框架

定位 :BasicMethod 层的"映射/编排/执行"基础体系

设计哲学 :万物皆函数,一切皆可映射

数学根基:函数、态射、自动机、图论、关系代数、分段函数


1. 概述

BasicMethod.Map 是 WorkFlowPrj 基础方法库(BasicMethod)的核心子体系,提供了 8 个并行的通用基础模块,覆盖了软件开发中最基本的抽象模式:

模块 核心抽象 数学基础
Transformers 函数变换 f: A → B 函数论(Modules.Transformers
SortMent 编排态射 范畴论态射(BasicMethod.SortMent
Block 分块执行 分段函数(BasicMethod.Block
StateMachine 状态转换 有限状态自动机(Modules.StateMachine
DecisionEngine 决策推理 决策规则引擎(BasicMethod.DecisionEngine
GraphFoundation 图数据结构 图论 G = (V, E)BasicMethod.GraphFoundation
Container 弹性执行容器 命令模式 + 请求/响应(Container.Abstractions
Declarative 声明式描述 关系代数 + 谓词逻辑(BasicMethod.Declarative

这些模块彼此独立、互不依赖,每个都是纯技术抽象,可被上层任意模块独立复用。


2. 模块全景图

#mermaid-svg-hKslB70cdw5dm9zA{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-hKslB70cdw5dm9zA .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-hKslB70cdw5dm9zA .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-hKslB70cdw5dm9zA .error-icon{fill:#552222;}#mermaid-svg-hKslB70cdw5dm9zA .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-hKslB70cdw5dm9zA .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-hKslB70cdw5dm9zA .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-hKslB70cdw5dm9zA .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-hKslB70cdw5dm9zA .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-hKslB70cdw5dm9zA .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-hKslB70cdw5dm9zA .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-hKslB70cdw5dm9zA .marker{fill:#333333;stroke:#333333;}#mermaid-svg-hKslB70cdw5dm9zA .marker.cross{stroke:#333333;}#mermaid-svg-hKslB70cdw5dm9zA svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-hKslB70cdw5dm9zA p{margin:0;}#mermaid-svg-hKslB70cdw5dm9zA .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-hKslB70cdw5dm9zA .cluster-label text{fill:#333;}#mermaid-svg-hKslB70cdw5dm9zA .cluster-label span{color:#333;}#mermaid-svg-hKslB70cdw5dm9zA .cluster-label span p{background-color:transparent;}#mermaid-svg-hKslB70cdw5dm9zA .label text,#mermaid-svg-hKslB70cdw5dm9zA span{fill:#333;color:#333;}#mermaid-svg-hKslB70cdw5dm9zA .node rect,#mermaid-svg-hKslB70cdw5dm9zA .node circle,#mermaid-svg-hKslB70cdw5dm9zA .node ellipse,#mermaid-svg-hKslB70cdw5dm9zA .node polygon,#mermaid-svg-hKslB70cdw5dm9zA .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-hKslB70cdw5dm9zA .rough-node .label text,#mermaid-svg-hKslB70cdw5dm9zA .node .label text,#mermaid-svg-hKslB70cdw5dm9zA .image-shape .label,#mermaid-svg-hKslB70cdw5dm9zA .icon-shape .label{text-anchor:middle;}#mermaid-svg-hKslB70cdw5dm9zA .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-hKslB70cdw5dm9zA .rough-node .label,#mermaid-svg-hKslB70cdw5dm9zA .node .label,#mermaid-svg-hKslB70cdw5dm9zA .image-shape .label,#mermaid-svg-hKslB70cdw5dm9zA .icon-shape .label{text-align:center;}#mermaid-svg-hKslB70cdw5dm9zA .node.clickable{cursor:pointer;}#mermaid-svg-hKslB70cdw5dm9zA .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-hKslB70cdw5dm9zA .arrowheadPath{fill:#333333;}#mermaid-svg-hKslB70cdw5dm9zA .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-hKslB70cdw5dm9zA .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-hKslB70cdw5dm9zA .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-hKslB70cdw5dm9zA .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-hKslB70cdw5dm9zA .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-hKslB70cdw5dm9zA .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-hKslB70cdw5dm9zA .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-hKslB70cdw5dm9zA .cluster text{fill:#333;}#mermaid-svg-hKslB70cdw5dm9zA .cluster span{color:#333;}#mermaid-svg-hKslB70cdw5dm9zA div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-hKslB70cdw5dm9zA .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-hKslB70cdw5dm9zA rect.text{fill:none;stroke-width:0;}#mermaid-svg-hKslB70cdw5dm9zA .icon-shape,#mermaid-svg-hKslB70cdw5dm9zA .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-hKslB70cdw5dm9zA .icon-shape p,#mermaid-svg-hKslB70cdw5dm9zA .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-hKslB70cdw5dm9zA .icon-shape .label rect,#mermaid-svg-hKslB70cdw5dm9zA .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-hKslB70cdw5dm9zA .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-hKslB70cdw5dm9zA .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-hKslB70cdw5dm9zA :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} BasicMethod.Map --- 8 个并行基础模块
Transformers

函数变换
SortMent

编排态射
Block

分块执行
StateMachine

状态转换
DecisionEngine

决策推理
GraphFoundation

图结构
Container

执行容器
Declarative

声明式描述

所有模块并行独立,无依赖关系,可单独使用或任意组合。


3. 数学基础体系

每个模块都建立在明确的数学概念之上:
#mermaid-svg-ojl0oeSOYo2Nh6bb{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-ojl0oeSOYo2Nh6bb .error-icon{fill:#552222;}#mermaid-svg-ojl0oeSOYo2Nh6bb .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-ojl0oeSOYo2Nh6bb .marker{fill:#333333;stroke:#333333;}#mermaid-svg-ojl0oeSOYo2Nh6bb .marker.cross{stroke:#333333;}#mermaid-svg-ojl0oeSOYo2Nh6bb svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-ojl0oeSOYo2Nh6bb p{margin:0;}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge{stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section--1 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section--1 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section--1 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section--1 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section--1 path{fill:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section--1 text{fill:#ffffff;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon--1{font-size:40px;color:#ffffff;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge--1{stroke:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth--1{stroke-width:17;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section--1 line{stroke:hsl(60, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-0 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-0 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-0 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-0 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-0 path{fill:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-0 text{fill:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon-0{font-size:40px;color:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge-0{stroke:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth-0{stroke-width:14;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-0 line{stroke:hsl(240, 100%, 83.5294117647%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-1 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-1 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-1 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-1 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-1 path{fill:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-1 text{fill:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon-1{font-size:40px;color:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge-1{stroke:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth-1{stroke-width:11;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-1 line{stroke:hsl(260, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-2 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-2 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-2 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-2 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-2 path{fill:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-2 text{fill:#ffffff;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon-2{font-size:40px;color:#ffffff;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge-2{stroke:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth-2{stroke-width:8;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-2 line{stroke:hsl(90, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-3 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-3 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-3 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-3 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-3 path{fill:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-3 text{fill:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon-3{font-size:40px;color:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge-3{stroke:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth-3{stroke-width:5;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-3 line{stroke:hsl(120, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-4 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-4 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-4 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-4 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-4 path{fill:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-4 text{fill:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon-4{font-size:40px;color:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge-4{stroke:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth-4{stroke-width:2;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-4 line{stroke:hsl(150, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-5 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-5 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-5 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-5 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-5 path{fill:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-5 text{fill:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon-5{font-size:40px;color:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge-5{stroke:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth-5{stroke-width:-1;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-5 line{stroke:hsl(180, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-6 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-6 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-6 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-6 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-6 path{fill:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-6 text{fill:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon-6{font-size:40px;color:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge-6{stroke:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth-6{stroke-width:-4;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-6 line{stroke:hsl(210, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-7 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-7 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-7 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-7 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-7 path{fill:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-7 text{fill:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon-7{font-size:40px;color:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge-7{stroke:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth-7{stroke-width:-7;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-7 line{stroke:hsl(270, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-8 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-8 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-8 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-8 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-8 path{fill:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-8 text{fill:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon-8{font-size:40px;color:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge-8{stroke:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth-8{stroke-width:-10;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-8 line{stroke:hsl(330, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-9 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-9 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-9 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-9 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-9 path{fill:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-9 text{fill:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon-9{font-size:40px;color:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge-9{stroke:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth-9{stroke-width:-13;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-9 line{stroke:hsl(0, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-10 rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-10 path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-10 circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-10 polygon,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-10 path{fill:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-10 text{fill:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .node-icon-10{font-size:40px;color:black;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-edge-10{stroke:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge-depth-10{stroke-width:-16;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-10 line{stroke:hsl(30, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:lightgray;}#mermaid-svg-ojl0oeSOYo2Nh6bb .disabled text{fill:#efefef;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-root rect,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-root path,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-root circle,#mermaid-svg-ojl0oeSOYo2Nh6bb .section-root polygon{fill:hsl(240, 100%, 46.2745098039%);}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-root text{fill:#ffffff;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-root span{color:#ffffff;}#mermaid-svg-ojl0oeSOYo2Nh6bb .section-2 span{color:#ffffff;}#mermaid-svg-ojl0oeSOYo2Nh6bb .icon-container{height:100%;display:flex;justify-content:center;align-items:center;}#mermaid-svg-ojl0oeSOYo2Nh6bb .edge{fill:none;}#mermaid-svg-ojl0oeSOYo2Nh6bb .mindmap-node-label{dy:1em;alignment-baseline:middle;text-anchor:middle;dominant-baseline:middle;text-align:center;}#mermaid-svg-ojl0oeSOYo2Nh6bb :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 数学基础
函数论
Transformers :: 函数 f: A → B
SortMent :: 范畴论态射
Block :: 分段函数
自动机理论
StateMachine :: 有限状态自动机
DecisionEngine :: 决策规则引擎
图论
V, E
关系代数
Declarative :: 关系 / 选择 / 投影 / 连接
谓词逻辑
Declarative :: 约束满足问题 CSP
DecisionEngine :: 条件谓词评估


4. 核心模块详解

4.1 Transformers --- 函数变换框架

数学基础 :函数 f: A → B

将一切"从 A 到 B 的操作"统一抽象为 ITransformer<TInput, TOutput> 接口。
#mermaid-svg-STrc6uOxrevFxVih{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-STrc6uOxrevFxVih .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-STrc6uOxrevFxVih .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-STrc6uOxrevFxVih .error-icon{fill:#552222;}#mermaid-svg-STrc6uOxrevFxVih .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-STrc6uOxrevFxVih .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-STrc6uOxrevFxVih .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-STrc6uOxrevFxVih .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-STrc6uOxrevFxVih .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-STrc6uOxrevFxVih .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-STrc6uOxrevFxVih .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-STrc6uOxrevFxVih .marker{fill:#333333;stroke:#333333;}#mermaid-svg-STrc6uOxrevFxVih .marker.cross{stroke:#333333;}#mermaid-svg-STrc6uOxrevFxVih svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-STrc6uOxrevFxVih p{margin:0;}#mermaid-svg-STrc6uOxrevFxVih .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-STrc6uOxrevFxVih .cluster-label text{fill:#333;}#mermaid-svg-STrc6uOxrevFxVih .cluster-label span{color:#333;}#mermaid-svg-STrc6uOxrevFxVih .cluster-label span p{background-color:transparent;}#mermaid-svg-STrc6uOxrevFxVih .label text,#mermaid-svg-STrc6uOxrevFxVih span{fill:#333;color:#333;}#mermaid-svg-STrc6uOxrevFxVih .node rect,#mermaid-svg-STrc6uOxrevFxVih .node circle,#mermaid-svg-STrc6uOxrevFxVih .node ellipse,#mermaid-svg-STrc6uOxrevFxVih .node polygon,#mermaid-svg-STrc6uOxrevFxVih .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-STrc6uOxrevFxVih .rough-node .label text,#mermaid-svg-STrc6uOxrevFxVih .node .label text,#mermaid-svg-STrc6uOxrevFxVih .image-shape .label,#mermaid-svg-STrc6uOxrevFxVih .icon-shape .label{text-anchor:middle;}#mermaid-svg-STrc6uOxrevFxVih .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-STrc6uOxrevFxVih .rough-node .label,#mermaid-svg-STrc6uOxrevFxVih .node .label,#mermaid-svg-STrc6uOxrevFxVih .image-shape .label,#mermaid-svg-STrc6uOxrevFxVih .icon-shape .label{text-align:center;}#mermaid-svg-STrc6uOxrevFxVih .node.clickable{cursor:pointer;}#mermaid-svg-STrc6uOxrevFxVih .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-STrc6uOxrevFxVih .arrowheadPath{fill:#333333;}#mermaid-svg-STrc6uOxrevFxVih .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-STrc6uOxrevFxVih .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-STrc6uOxrevFxVih .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-STrc6uOxrevFxVih .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-STrc6uOxrevFxVih .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-STrc6uOxrevFxVih .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-STrc6uOxrevFxVih .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-STrc6uOxrevFxVih .cluster text{fill:#333;}#mermaid-svg-STrc6uOxrevFxVih .cluster span{color:#333;}#mermaid-svg-STrc6uOxrevFxVih div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-STrc6uOxrevFxVih .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-STrc6uOxrevFxVih rect.text{fill:none;stroke-width:0;}#mermaid-svg-STrc6uOxrevFxVih .icon-shape,#mermaid-svg-STrc6uOxrevFxVih .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-STrc6uOxrevFxVih .icon-shape p,#mermaid-svg-STrc6uOxrevFxVih .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-STrc6uOxrevFxVih .icon-shape .label rect,#mermaid-svg-STrc6uOxrevFxVih .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-STrc6uOxrevFxVih .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-STrc6uOxrevFxVih .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-STrc6uOxrevFxVih :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 装饰器
输入
装饰器链

日志 → 重试 → 超时
原始转换器
输出
管线编排
输入
步骤 1
步骤 2
步骤 3
管线结果
函数复合
输入 A
f₁: A → B
f₂: B → C
输出 C

核心能力

  • 函数复合g ∘ f --- 两个转换器组合为新转换器
  • 管线编排:多步骤顺序执行,支持失败策略
  • 装饰器模式:日志、重试、超时、缓存等横切关注点
  • 上下文传播TransformContext 通过 AsyncLocal 隐式传递

关键类型

类型 说明
ITransformer<TInput, TOutput> 同步转换器接口
IAsyncTransformer<TInput, TOutput> 异步转换器接口
CacheTransformer<TInput, TOutput> 缓存包装(where TInput : notnull
ConditionalTransformer<TInput, TOutput> 条件分支(条件为 false 且无 falseBranch 时抛出异常)
TryTransformer<TInput, TOutput> 容错包装(输出 Result<TOutput>
GroupReducer<T> 分组归约(IEnumerable<T> → IEnumerable<T>
DelegateAdapter<TInput, TOutput> 委托适配器(函数/委托 → 转换器)
AsyncComposition<TInput, TOutput> 异步组合器
TransformContext AsyncLocal 上下文
TransformerExtensions 扩展方法(复合/管线/装饰器)

4.2 SortMent --- 编排态射框架

数学基础 :范畴论态射 f: (A, ≤, ∼) → (B, ≤, ∼)

在"纯函数变换"基础上,增加了排序、分类、分组等编排语义。
#mermaid-svg-so03b9EsYfYRaO6B{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-so03b9EsYfYRaO6B .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-so03b9EsYfYRaO6B .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-so03b9EsYfYRaO6B .error-icon{fill:#552222;}#mermaid-svg-so03b9EsYfYRaO6B .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-so03b9EsYfYRaO6B .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-so03b9EsYfYRaO6B .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-so03b9EsYfYRaO6B .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-so03b9EsYfYRaO6B .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-so03b9EsYfYRaO6B .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-so03b9EsYfYRaO6B .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-so03b9EsYfYRaO6B .marker{fill:#333333;stroke:#333333;}#mermaid-svg-so03b9EsYfYRaO6B .marker.cross{stroke:#333333;}#mermaid-svg-so03b9EsYfYRaO6B svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-so03b9EsYfYRaO6B p{margin:0;}#mermaid-svg-so03b9EsYfYRaO6B g.classGroup text{fill:#9370DB;stroke:none;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:10px;}#mermaid-svg-so03b9EsYfYRaO6B g.classGroup text .title{font-weight:bolder;}#mermaid-svg-so03b9EsYfYRaO6B .cluster-label text{fill:#333;}#mermaid-svg-so03b9EsYfYRaO6B .cluster-label span{color:#333;}#mermaid-svg-so03b9EsYfYRaO6B .cluster-label span p{background-color:transparent;}#mermaid-svg-so03b9EsYfYRaO6B .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-so03b9EsYfYRaO6B .cluster text{fill:#333;}#mermaid-svg-so03b9EsYfYRaO6B .cluster span{color:#333;}#mermaid-svg-so03b9EsYfYRaO6B .nodeLabel,#mermaid-svg-so03b9EsYfYRaO6B .edgeLabel{color:#131300;}#mermaid-svg-so03b9EsYfYRaO6B .edgeLabel .label rect{fill:#ECECFF;}#mermaid-svg-so03b9EsYfYRaO6B .label text{fill:#131300;}#mermaid-svg-so03b9EsYfYRaO6B .labelBkg{background:#ECECFF;}#mermaid-svg-so03b9EsYfYRaO6B .edgeLabel .label span{background:#ECECFF;}#mermaid-svg-so03b9EsYfYRaO6B .classTitle{font-weight:bolder;}#mermaid-svg-so03b9EsYfYRaO6B .node rect,#mermaid-svg-so03b9EsYfYRaO6B .node circle,#mermaid-svg-so03b9EsYfYRaO6B .node ellipse,#mermaid-svg-so03b9EsYfYRaO6B .node polygon,#mermaid-svg-so03b9EsYfYRaO6B .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-so03b9EsYfYRaO6B .divider{stroke:#9370DB;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B g.clickable{cursor:pointer;}#mermaid-svg-so03b9EsYfYRaO6B g.classGroup rect{fill:#ECECFF;stroke:#9370DB;}#mermaid-svg-so03b9EsYfYRaO6B g.classGroup line{stroke:#9370DB;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5;}#mermaid-svg-so03b9EsYfYRaO6B .classLabel .label{fill:#9370DB;font-size:10px;}#mermaid-svg-so03b9EsYfYRaO6B .relation{stroke:#333333;stroke-width:1;fill:none;}#mermaid-svg-so03b9EsYfYRaO6B .dashed-line{stroke-dasharray:3;}#mermaid-svg-so03b9EsYfYRaO6B .dotted-line{stroke-dasharray:1 2;}#mermaid-svg-so03b9EsYfYRaO6B #compositionStart,#mermaid-svg-so03b9EsYfYRaO6B .composition{fill:#333333!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B #compositionEnd,#mermaid-svg-so03b9EsYfYRaO6B .composition{fill:#333333!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B #dependencyStart,#mermaid-svg-so03b9EsYfYRaO6B .dependency{fill:#333333!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B #dependencyStart,#mermaid-svg-so03b9EsYfYRaO6B .dependency{fill:#333333!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B #extensionStart,#mermaid-svg-so03b9EsYfYRaO6B .extension{fill:transparent!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B #extensionEnd,#mermaid-svg-so03b9EsYfYRaO6B .extension{fill:transparent!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B #aggregationStart,#mermaid-svg-so03b9EsYfYRaO6B .aggregation{fill:transparent!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B #aggregationEnd,#mermaid-svg-so03b9EsYfYRaO6B .aggregation{fill:transparent!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B #lollipopStart,#mermaid-svg-so03b9EsYfYRaO6B .lollipop{fill:#ECECFF!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B #lollipopEnd,#mermaid-svg-so03b9EsYfYRaO6B .lollipop{fill:#ECECFF!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-so03b9EsYfYRaO6B .edgeTerminals{font-size:11px;line-height:initial;}#mermaid-svg-so03b9EsYfYRaO6B .classTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-so03b9EsYfYRaO6B .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-so03b9EsYfYRaO6B .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-so03b9EsYfYRaO6B :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} <<interface>>
ISortMent
+Morph(TSource) : TTarget
<<interface>>
IClassifyMent
+Classify(TSource) : TCategory
<<interface>>
ISortableMent
+Order int
<<interface>>
IGroupMent
+KeySelector Func
<<interface>>
ISortMentPipeline
+Execute(TContext) : TContext
<<interface>>
ISortMentRegistry
+Register(key, sortMent)
+Execute(key, source) : TTarget
IOrderedMent
ISortMentCollection

核心能力

  • 态射复合g ∘ f --- 编排态射的组合
  • 管线编排:按 Order 排序后依次执行
  • 分类处理:按等价关系 ∼ 将输入划分到不同类别
  • 分组处理:按等价关系 ∼ 将集合划分为等价类
  • 注册表模式:按键注册和查找编排态射,支持策略模式

关键类型

类型 说明
ISortMent<TSource, TTarget> 编排态射接口
IAsyncSortMent<TSource, TTarget> 异步编排态射
IClassifyMent<TSource, TCategory, TTarget> 分类态射
IGroupMent<TSource, TKey, TTarget> 分组态射
ISortMentPipeline<TContext> 编排管线
ISortMentRegistry<TKey, TSource, TTarget> 编排注册表

4.3 Block --- 分块执行框架

数学基础 :分段函数 f(x) = { f₁(x), ..., fₙ(x) }

将执行逻辑划分为多个独立块,每个块有独立的定义域和值域,通过 BlockContext 传递数据,每个块独立 try/catch 隔离。
块 3 块 2 块 1 BlockContext 执行管线 块 3 块 2 块 1 BlockContext 执行管线 #mermaid-svg-9w6hBvjoyRtaHZxr{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-9w6hBvjoyRtaHZxr .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-9w6hBvjoyRtaHZxr .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-9w6hBvjoyRtaHZxr .error-icon{fill:#552222;}#mermaid-svg-9w6hBvjoyRtaHZxr .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-9w6hBvjoyRtaHZxr .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-9w6hBvjoyRtaHZxr .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-9w6hBvjoyRtaHZxr .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-9w6hBvjoyRtaHZxr .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-9w6hBvjoyRtaHZxr .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-9w6hBvjoyRtaHZxr .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-9w6hBvjoyRtaHZxr .marker{fill:#333333;stroke:#333333;}#mermaid-svg-9w6hBvjoyRtaHZxr .marker.cross{stroke:#333333;}#mermaid-svg-9w6hBvjoyRtaHZxr svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-9w6hBvjoyRtaHZxr p{margin:0;}#mermaid-svg-9w6hBvjoyRtaHZxr .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-9w6hBvjoyRtaHZxr text.actor>tspan{fill:black;stroke:none;}#mermaid-svg-9w6hBvjoyRtaHZxr .actor-line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-9w6hBvjoyRtaHZxr .innerArc{stroke-width:1.5;stroke-dasharray:none;}#mermaid-svg-9w6hBvjoyRtaHZxr .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg-9w6hBvjoyRtaHZxr .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg-9w6hBvjoyRtaHZxr #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg-9w6hBvjoyRtaHZxr .sequenceNumber{fill:white;}#mermaid-svg-9w6hBvjoyRtaHZxr #sequencenumber{fill:#333;}#mermaid-svg-9w6hBvjoyRtaHZxr #crosshead path{fill:#333;stroke:#333;}#mermaid-svg-9w6hBvjoyRtaHZxr .messageText{fill:#333;stroke:none;}#mermaid-svg-9w6hBvjoyRtaHZxr .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-9w6hBvjoyRtaHZxr .labelText,#mermaid-svg-9w6hBvjoyRtaHZxr .labelText>tspan{fill:black;stroke:none;}#mermaid-svg-9w6hBvjoyRtaHZxr .loopText,#mermaid-svg-9w6hBvjoyRtaHZxr .loopText>tspan{fill:black;stroke:none;}#mermaid-svg-9w6hBvjoyRtaHZxr .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-9w6hBvjoyRtaHZxr .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-9w6hBvjoyRtaHZxr .noteText,#mermaid-svg-9w6hBvjoyRtaHZxr .noteText>tspan{fill:black;stroke:none;}#mermaid-svg-9w6hBvjoyRtaHZxr .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg-9w6hBvjoyRtaHZxr .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg-9w6hBvjoyRtaHZxr .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg-9w6hBvjoyRtaHZxr .actorPopupMenu{position:absolute;}#mermaid-svg-9w6hBvjoyRtaHZxr .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg-9w6hBvjoyRtaHZxr .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-9w6hBvjoyRtaHZxr .actor-man circle,#mermaid-svg-9w6hBvjoyRtaHZxr line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg-9w6hBvjoyRtaHZxr :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 条件不满足 创建上下文ExecuteAsync(ctx)Set("data", value)BlockResult.Success()ExecuteAsync(ctx)Get("data")BlockResult.Success()ExecuteAsync(ctx)BlockResult.Skipped()生成诊断报告

内置块类型

块类型 功能
DiagnosticBlock 执行前诊断检查
ConditionalBlock 条件分支(if-then-else)
TimeoutBlock 超时控制
LogBlock 日志记录
SequenceBlock 子序列嵌套
DelayBlock 延迟执行

关键类型

类型 说明
IBlock 执行块接口
BlockContext 块上下文(数据传递 + 诊断)
ExecutionPipeline 执行管线
BlockResult 块执行结果
PipelineResult 管线执行报告

4.4 StateMachine --- 状态机框架

数学基础 :有限状态自动机 (S, Σ, δ, s₀, F)

提供四种状态转换型状态机模式,关注"状态如何合法变化"。
#mermaid-svg-YVjydrvU8jGSdsG2{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-YVjydrvU8jGSdsG2 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-YVjydrvU8jGSdsG2 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-YVjydrvU8jGSdsG2 .error-icon{fill:#552222;}#mermaid-svg-YVjydrvU8jGSdsG2 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-YVjydrvU8jGSdsG2 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-YVjydrvU8jGSdsG2 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-YVjydrvU8jGSdsG2 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-YVjydrvU8jGSdsG2 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-YVjydrvU8jGSdsG2 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-YVjydrvU8jGSdsG2 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-YVjydrvU8jGSdsG2 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-YVjydrvU8jGSdsG2 .marker.cross{stroke:#333333;}#mermaid-svg-YVjydrvU8jGSdsG2 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-YVjydrvU8jGSdsG2 p{margin:0;}#mermaid-svg-YVjydrvU8jGSdsG2 defs #statediagram-barbEnd{fill:#333333;stroke:#333333;}#mermaid-svg-YVjydrvU8jGSdsG2 g.stateGroup text{fill:#9370DB;stroke:none;font-size:10px;}#mermaid-svg-YVjydrvU8jGSdsG2 g.stateGroup text{fill:#333;stroke:none;font-size:10px;}#mermaid-svg-YVjydrvU8jGSdsG2 g.stateGroup .state-title{font-weight:bolder;fill:#131300;}#mermaid-svg-YVjydrvU8jGSdsG2 g.stateGroup rect{fill:#ECECFF;stroke:#9370DB;}#mermaid-svg-YVjydrvU8jGSdsG2 g.stateGroup line{stroke:#333333;stroke-width:1;}#mermaid-svg-YVjydrvU8jGSdsG2 .transition{stroke:#333333;stroke-width:1;fill:none;}#mermaid-svg-YVjydrvU8jGSdsG2 .stateGroup .composit{fill:white;border-bottom:1px;}#mermaid-svg-YVjydrvU8jGSdsG2 .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px;}#mermaid-svg-YVjydrvU8jGSdsG2 .state-note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-YVjydrvU8jGSdsG2 .state-note text{fill:black;stroke:none;font-size:10px;}#mermaid-svg-YVjydrvU8jGSdsG2 .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5;}#mermaid-svg-YVjydrvU8jGSdsG2 .edgeLabel .label rect{fill:#ECECFF;opacity:0.5;}#mermaid-svg-YVjydrvU8jGSdsG2 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-YVjydrvU8jGSdsG2 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-YVjydrvU8jGSdsG2 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-YVjydrvU8jGSdsG2 .edgeLabel .label text{fill:#333;}#mermaid-svg-YVjydrvU8jGSdsG2 .label div .edgeLabel{color:#333;}#mermaid-svg-YVjydrvU8jGSdsG2 .stateLabel text{fill:#131300;font-size:10px;font-weight:bold;}#mermaid-svg-YVjydrvU8jGSdsG2 .node circle.state-start{fill:#333333;stroke:#333333;}#mermaid-svg-YVjydrvU8jGSdsG2 .node .fork-join{fill:#333333;stroke:#333333;}#mermaid-svg-YVjydrvU8jGSdsG2 .node circle.state-end{fill:#9370DB;stroke:white;stroke-width:1.5;}#mermaid-svg-YVjydrvU8jGSdsG2 .end-state-inner{fill:white;stroke-width:1.5;}#mermaid-svg-YVjydrvU8jGSdsG2 .node rect{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-YVjydrvU8jGSdsG2 .node polygon{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-YVjydrvU8jGSdsG2 #statediagram-barbEnd{fill:#333333;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-cluster rect{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-YVjydrvU8jGSdsG2 .cluster-label,#mermaid-svg-YVjydrvU8jGSdsG2 .nodeLabel{color:#131300;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-cluster rect.outer{rx:5px;ry:5px;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-state .divider{stroke:#9370DB;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-state .title-state{rx:5px;ry:5px;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-cluster.statediagram-cluster .inner{fill:white;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-cluster.statediagram-cluster-alt .inner{fill:#f0f0f0;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-cluster .inner{rx:0;ry:0;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-state rect.basic{rx:5px;ry:5px;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#f0f0f0;}#mermaid-svg-YVjydrvU8jGSdsG2 .note-edge{stroke-dasharray:5;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-note rect{fill:#fff5ad;stroke:#aaaa33;stroke-width:1px;rx:0;ry:0;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-note rect{fill:#fff5ad;stroke:#aaaa33;stroke-width:1px;rx:0;ry:0;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-note text{fill:black;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram-note .nodeLabel{color:black;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagram .edgeLabel{color:red;}#mermaid-svg-YVjydrvU8jGSdsG2 #dependencyStart,#mermaid-svg-YVjydrvU8jGSdsG2 #dependencyEnd{fill:#333333;stroke:#333333;stroke-width:1;}#mermaid-svg-YVjydrvU8jGSdsG2 .statediagramTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-YVjydrvU8jGSdsG2 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Initial
顺序状态机
步骤完成
步骤完成
全部完成
S1
S2
S3
生命周期状态机
Initialize()
Start()
Pause()
Resume()
Complete()
Error
Created
Initialized
Running
Paused
Completed
Faulted
条件状态机
条件满足
条件不满足
Pending
Approved
Rejected

四种模式

模式 说明 适用场景
Sequential 顺序执行,按步骤推进 工作流、安装向导
Lifecycle 生命周期管理,支持暂停/恢复 服务管理、会话管理
AsyncEvent 异步事件驱动 消息处理、事件驱动架构
Conditional 条件转换,带验证 审批流程、规则引擎

配套组件

  • StateMachineStore --- 状态机存储,支持 TTL 自动清理
  • PauseManager --- 全局/局部暂停管理
  • ScopeStateManager --- 嵌套作用域状态管理

4.5 DecisionEngine --- 决策引擎

数学基础:决策规则引擎

关注"下一步该做什么"------根据当前状态和上下文,通过规则评估做出决策。
#mermaid-svg-0SjNfhA2B0CYNraM{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-0SjNfhA2B0CYNraM .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-0SjNfhA2B0CYNraM .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-0SjNfhA2B0CYNraM .error-icon{fill:#552222;}#mermaid-svg-0SjNfhA2B0CYNraM .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-0SjNfhA2B0CYNraM .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-0SjNfhA2B0CYNraM .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-0SjNfhA2B0CYNraM .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-0SjNfhA2B0CYNraM .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-0SjNfhA2B0CYNraM .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-0SjNfhA2B0CYNraM .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-0SjNfhA2B0CYNraM .marker{fill:#333333;stroke:#333333;}#mermaid-svg-0SjNfhA2B0CYNraM .marker.cross{stroke:#333333;}#mermaid-svg-0SjNfhA2B0CYNraM svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-0SjNfhA2B0CYNraM p{margin:0;}#mermaid-svg-0SjNfhA2B0CYNraM .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-0SjNfhA2B0CYNraM .cluster-label text{fill:#333;}#mermaid-svg-0SjNfhA2B0CYNraM .cluster-label span{color:#333;}#mermaid-svg-0SjNfhA2B0CYNraM .cluster-label span p{background-color:transparent;}#mermaid-svg-0SjNfhA2B0CYNraM .label text,#mermaid-svg-0SjNfhA2B0CYNraM span{fill:#333;color:#333;}#mermaid-svg-0SjNfhA2B0CYNraM .node rect,#mermaid-svg-0SjNfhA2B0CYNraM .node circle,#mermaid-svg-0SjNfhA2B0CYNraM .node ellipse,#mermaid-svg-0SjNfhA2B0CYNraM .node polygon,#mermaid-svg-0SjNfhA2B0CYNraM .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-0SjNfhA2B0CYNraM .rough-node .label text,#mermaid-svg-0SjNfhA2B0CYNraM .node .label text,#mermaid-svg-0SjNfhA2B0CYNraM .image-shape .label,#mermaid-svg-0SjNfhA2B0CYNraM .icon-shape .label{text-anchor:middle;}#mermaid-svg-0SjNfhA2B0CYNraM .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-0SjNfhA2B0CYNraM .rough-node .label,#mermaid-svg-0SjNfhA2B0CYNraM .node .label,#mermaid-svg-0SjNfhA2B0CYNraM .image-shape .label,#mermaid-svg-0SjNfhA2B0CYNraM .icon-shape .label{text-align:center;}#mermaid-svg-0SjNfhA2B0CYNraM .node.clickable{cursor:pointer;}#mermaid-svg-0SjNfhA2B0CYNraM .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-0SjNfhA2B0CYNraM .arrowheadPath{fill:#333333;}#mermaid-svg-0SjNfhA2B0CYNraM .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-0SjNfhA2B0CYNraM .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-0SjNfhA2B0CYNraM .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-0SjNfhA2B0CYNraM .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-0SjNfhA2B0CYNraM .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-0SjNfhA2B0CYNraM .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-0SjNfhA2B0CYNraM .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-0SjNfhA2B0CYNraM .cluster text{fill:#333;}#mermaid-svg-0SjNfhA2B0CYNraM .cluster span{color:#333;}#mermaid-svg-0SjNfhA2B0CYNraM div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-0SjNfhA2B0CYNraM .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-0SjNfhA2B0CYNraM rect.text{fill:none;stroke-width:0;}#mermaid-svg-0SjNfhA2B0CYNraM .icon-shape,#mermaid-svg-0SjNfhA2B0CYNraM .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-0SjNfhA2B0CYNraM .icon-shape p,#mermaid-svg-0SjNfhA2B0CYNraM .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-0SjNfhA2B0CYNraM .icon-shape .label rect,#mermaid-svg-0SjNfhA2B0CYNraM .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-0SjNfhA2B0CYNraM .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-0SjNfhA2B0CYNraM .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-0SjNfhA2B0CYNraM :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 决策流程




当前状态 + 上下文
规则评估
匹配规则?
执行动作
回退策略
下一个状态
流程完成?
完成

核心接口

csharp 复制代码
public interface IDecisionEngine<TState, TContext>
{
    Task<DecisionResult<TState>> DecideAsync(TContext context, ...);
    void SetCurrentState(TState state);
    void Reset();
}

实现

  • RuleBasedDecisionEngine --- 基于规则的确定性决策
  • CompositeDecisionEngine --- 组合多个决策引擎
  • ConditionEvaluator --- 条件表达式评估器

4.6 GraphFoundation --- 图基础框架

数学基础 :图 G = (V, E)

提供通用的图数据结构和算法基础能力,存储与业务逻辑分离。
#mermaid-svg-HZwFhtslw5qKTVec{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-HZwFhtslw5qKTVec .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-HZwFhtslw5qKTVec .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-HZwFhtslw5qKTVec .error-icon{fill:#552222;}#mermaid-svg-HZwFhtslw5qKTVec .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-HZwFhtslw5qKTVec .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-HZwFhtslw5qKTVec .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-HZwFhtslw5qKTVec .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-HZwFhtslw5qKTVec .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-HZwFhtslw5qKTVec .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-HZwFhtslw5qKTVec .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-HZwFhtslw5qKTVec .marker{fill:#333333;stroke:#333333;}#mermaid-svg-HZwFhtslw5qKTVec .marker.cross{stroke:#333333;}#mermaid-svg-HZwFhtslw5qKTVec svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-HZwFhtslw5qKTVec p{margin:0;}#mermaid-svg-HZwFhtslw5qKTVec .entityBox{fill:#ECECFF;stroke:#9370DB;}#mermaid-svg-HZwFhtslw5qKTVec .relationshipLabelBox{fill:hsl(80, 100%, 96.2745098039%);opacity:0.7;background-color:hsl(80, 100%, 96.2745098039%);}#mermaid-svg-HZwFhtslw5qKTVec .relationshipLabelBox rect{opacity:0.5;}#mermaid-svg-HZwFhtslw5qKTVec .labelBkg{background-color:rgba(248.6666666666, 255, 235.9999999999, 0.5);}#mermaid-svg-HZwFhtslw5qKTVec .edgeLabel .label{fill:#9370DB;font-size:14px;}#mermaid-svg-HZwFhtslw5qKTVec .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-HZwFhtslw5qKTVec .edge-pattern-dashed{stroke-dasharray:8,8;}#mermaid-svg-HZwFhtslw5qKTVec .node rect,#mermaid-svg-HZwFhtslw5qKTVec .node circle,#mermaid-svg-HZwFhtslw5qKTVec .node ellipse,#mermaid-svg-HZwFhtslw5qKTVec .node polygon{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-HZwFhtslw5qKTVec .relationshipLine{stroke:#333333;stroke-width:1;fill:none;}#mermaid-svg-HZwFhtslw5qKTVec .marker{fill:none!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-HZwFhtslw5qKTVec .edgeLabel{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-HZwFhtslw5qKTVec .edgeLabel .label rect{fill:rgba(232,232,232, 0.8);}#mermaid-svg-HZwFhtslw5qKTVec .edgeLabel .label text{fill:#333;}#mermaid-svg-HZwFhtslw5qKTVec :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} contains
contains
uses
implements
implements
CoreGraph
Node
TKey
key
PK
TNodeData
data
string
symbol
Edge
string
edgeId
PK
TKey
source
FK
TKey
target
FK
bool
isDirected
double
weight
TEdgeData
data
IGraphStorage
InMemoryGraphStorage
CustomStorage

核心能力

组件 功能
IGraph<TKey, TNodeData, TEdgeData> 图核心接口,定义图的基本操作
CoreGraph<TKey, TNodeData, TEdgeData> 图核心实现,事务 + 事件 + 编排
GraphFrame<TKey, TNodeData, TEdgeData> 图框架层,提供高级编排能力
IGraphStorage 存储抽象,支持内存/自定义存储
Chain 链式处理与编排系统
Topology 拓扑排序与关键路径
GraphSnapshot 图快照与差异比较
GraphNavigationExtensions 图遍历扩展方法
Commands.cs 图操作命令集

4.7 Container --- 通用执行容器框架

数学基础:命令模式 + 请求/响应

提供原子执行单元和引擎容器,支持弹性策略(重试、熔断、超时、日志)。
#mermaid-svg-9UMYLunm7MwBL4NR{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-9UMYLunm7MwBL4NR .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-9UMYLunm7MwBL4NR .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-9UMYLunm7MwBL4NR .error-icon{fill:#552222;}#mermaid-svg-9UMYLunm7MwBL4NR .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-9UMYLunm7MwBL4NR .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-9UMYLunm7MwBL4NR .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-9UMYLunm7MwBL4NR .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-9UMYLunm7MwBL4NR .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-9UMYLunm7MwBL4NR .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-9UMYLunm7MwBL4NR .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-9UMYLunm7MwBL4NR .marker{fill:#333333;stroke:#333333;}#mermaid-svg-9UMYLunm7MwBL4NR .marker.cross{stroke:#333333;}#mermaid-svg-9UMYLunm7MwBL4NR svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-9UMYLunm7MwBL4NR p{margin:0;}#mermaid-svg-9UMYLunm7MwBL4NR .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-9UMYLunm7MwBL4NR .cluster-label text{fill:#333;}#mermaid-svg-9UMYLunm7MwBL4NR .cluster-label span{color:#333;}#mermaid-svg-9UMYLunm7MwBL4NR .cluster-label span p{background-color:transparent;}#mermaid-svg-9UMYLunm7MwBL4NR .label text,#mermaid-svg-9UMYLunm7MwBL4NR span{fill:#333;color:#333;}#mermaid-svg-9UMYLunm7MwBL4NR .node rect,#mermaid-svg-9UMYLunm7MwBL4NR .node circle,#mermaid-svg-9UMYLunm7MwBL4NR .node ellipse,#mermaid-svg-9UMYLunm7MwBL4NR .node polygon,#mermaid-svg-9UMYLunm7MwBL4NR .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-9UMYLunm7MwBL4NR .rough-node .label text,#mermaid-svg-9UMYLunm7MwBL4NR .node .label text,#mermaid-svg-9UMYLunm7MwBL4NR .image-shape .label,#mermaid-svg-9UMYLunm7MwBL4NR .icon-shape .label{text-anchor:middle;}#mermaid-svg-9UMYLunm7MwBL4NR .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-9UMYLunm7MwBL4NR .rough-node .label,#mermaid-svg-9UMYLunm7MwBL4NR .node .label,#mermaid-svg-9UMYLunm7MwBL4NR .image-shape .label,#mermaid-svg-9UMYLunm7MwBL4NR .icon-shape .label{text-align:center;}#mermaid-svg-9UMYLunm7MwBL4NR .node.clickable{cursor:pointer;}#mermaid-svg-9UMYLunm7MwBL4NR .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-9UMYLunm7MwBL4NR .arrowheadPath{fill:#333333;}#mermaid-svg-9UMYLunm7MwBL4NR .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-9UMYLunm7MwBL4NR .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-9UMYLunm7MwBL4NR .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-9UMYLunm7MwBL4NR .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-9UMYLunm7MwBL4NR .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-9UMYLunm7MwBL4NR .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-9UMYLunm7MwBL4NR .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-9UMYLunm7MwBL4NR .cluster text{fill:#333;}#mermaid-svg-9UMYLunm7MwBL4NR .cluster span{color:#333;}#mermaid-svg-9UMYLunm7MwBL4NR div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-9UMYLunm7MwBL4NR .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-9UMYLunm7MwBL4NR rect.text{fill:none;stroke-width:0;}#mermaid-svg-9UMYLunm7MwBL4NR .icon-shape,#mermaid-svg-9UMYLunm7MwBL4NR .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-9UMYLunm7MwBL4NR .icon-shape p,#mermaid-svg-9UMYLunm7MwBL4NR .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-9UMYLunm7MwBL4NR .icon-shape .label rect,#mermaid-svg-9UMYLunm7MwBL4NR .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-9UMYLunm7MwBL4NR .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-9UMYLunm7MwBL4NR .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-9UMYLunm7MwBL4NR :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 装饰器
弹性策略
执行容器体系
IExecutionCell

原子执行单元
IExecutionEngine

引擎容器
行为管道
重试策略
熔断策略
超时策略
日志策略
RetryDecorator
CircuitBreakerDecorator
TimeoutDecorator
LoggingDecorator

设计原则

  • 所有输入输出通过不可变 record 传递,无 SharedData
  • 运行时依赖通过构造函数注入,无隐式依赖
  • 不依赖任何业务逻辑

4.8 Declarative --- 声明式框架

数学基础:关系代数 + 谓词逻辑 + 约束满足问题

提供声明式编程的核心抽象------描述"是什么"(What),而非"怎么做"(How)。
#mermaid-svg-gvC49mUrlKYNyHvL{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-gvC49mUrlKYNyHvL .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-gvC49mUrlKYNyHvL .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-gvC49mUrlKYNyHvL .error-icon{fill:#552222;}#mermaid-svg-gvC49mUrlKYNyHvL .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-gvC49mUrlKYNyHvL .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-gvC49mUrlKYNyHvL .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-gvC49mUrlKYNyHvL .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-gvC49mUrlKYNyHvL .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-gvC49mUrlKYNyHvL .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-gvC49mUrlKYNyHvL .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-gvC49mUrlKYNyHvL .marker{fill:#333333;stroke:#333333;}#mermaid-svg-gvC49mUrlKYNyHvL .marker.cross{stroke:#333333;}#mermaid-svg-gvC49mUrlKYNyHvL svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-gvC49mUrlKYNyHvL p{margin:0;}#mermaid-svg-gvC49mUrlKYNyHvL .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-gvC49mUrlKYNyHvL .cluster-label text{fill:#333;}#mermaid-svg-gvC49mUrlKYNyHvL .cluster-label span{color:#333;}#mermaid-svg-gvC49mUrlKYNyHvL .cluster-label span p{background-color:transparent;}#mermaid-svg-gvC49mUrlKYNyHvL .label text,#mermaid-svg-gvC49mUrlKYNyHvL span{fill:#333;color:#333;}#mermaid-svg-gvC49mUrlKYNyHvL .node rect,#mermaid-svg-gvC49mUrlKYNyHvL .node circle,#mermaid-svg-gvC49mUrlKYNyHvL .node ellipse,#mermaid-svg-gvC49mUrlKYNyHvL .node polygon,#mermaid-svg-gvC49mUrlKYNyHvL .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-gvC49mUrlKYNyHvL .rough-node .label text,#mermaid-svg-gvC49mUrlKYNyHvL .node .label text,#mermaid-svg-gvC49mUrlKYNyHvL .image-shape .label,#mermaid-svg-gvC49mUrlKYNyHvL .icon-shape .label{text-anchor:middle;}#mermaid-svg-gvC49mUrlKYNyHvL .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-gvC49mUrlKYNyHvL .rough-node .label,#mermaid-svg-gvC49mUrlKYNyHvL .node .label,#mermaid-svg-gvC49mUrlKYNyHvL .image-shape .label,#mermaid-svg-gvC49mUrlKYNyHvL .icon-shape .label{text-align:center;}#mermaid-svg-gvC49mUrlKYNyHvL .node.clickable{cursor:pointer;}#mermaid-svg-gvC49mUrlKYNyHvL .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-gvC49mUrlKYNyHvL .arrowheadPath{fill:#333333;}#mermaid-svg-gvC49mUrlKYNyHvL .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-gvC49mUrlKYNyHvL .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-gvC49mUrlKYNyHvL .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-gvC49mUrlKYNyHvL .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-gvC49mUrlKYNyHvL .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-gvC49mUrlKYNyHvL .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-gvC49mUrlKYNyHvL .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-gvC49mUrlKYNyHvL .cluster text{fill:#333;}#mermaid-svg-gvC49mUrlKYNyHvL .cluster span{color:#333;}#mermaid-svg-gvC49mUrlKYNyHvL div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-gvC49mUrlKYNyHvL .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-gvC49mUrlKYNyHvL rect.text{fill:none;stroke-width:0;}#mermaid-svg-gvC49mUrlKYNyHvL .icon-shape,#mermaid-svg-gvC49mUrlKYNyHvL .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-gvC49mUrlKYNyHvL .icon-shape p,#mermaid-svg-gvC49mUrlKYNyHvL .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-gvC49mUrlKYNyHvL .icon-shape .label rect,#mermaid-svg-gvC49mUrlKYNyHvL .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-gvC49mUrlKYNyHvL .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-gvC49mUrlKYNyHvL .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-gvC49mUrlKYNyHvL :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 关系操作
约束类型
声明式体系
IDeclaration

声明基接口
IConstraint

约束验证
IRelation

关系代数
IDeclarativeMapper

声明→运行时映射
PredicateConstraint

谓词约束
RangeConstraint

范围约束
TypeConstraint

类型约束
RequiredConstraint

必填约束
CompositeConstraint

复合约束 AND/OR/NOT
Select σ

选择
Project π

投影
Join ⋈

连接
Rename ρ

重命名

关键类型

类型 说明
IDeclaration 声明基接口
IDeclarationCollection 声明集合管理
IDeclarationResolver 声明解析器
IConstraint<T> 约束接口(谓词/范围/类型/必填/复合)
IRelation 关系接口(选择/投影/连接/重命名)
IDeclarativeMapper<TDeclaration, TRuntime> 声明→运行时映射器
DeclarationValidator<T> 声明验证器
DeclarationResult 声明执行结果

5. 使用场景指南

各模块可独立使用,也可按需自由组合:

场景 推荐模块 说明
数据清洗/ETL Transformers 管线化数据转换
工作流引擎 StateMachine 状态驱动流程
策略模式 SortMent Registry 按键选择处理策略
声明式配置 Declarative 声明描述业务规则
弹性执行 Container 原子执行 + 重试/熔断/超时
图数据处理 GraphFoundation 图存储、拓扑排序、关键路径
分步隔离执行 Block 分段执行 + 诊断报告
规则验证 Declarative Constraints 约束满足问题求解
决策推理 DecisionEngine 规则驱动的下一步决策

6. 文件结构

text 复制代码
CsharpPrj/BasicMethod/Map/
├── Transformers/          # 函数变换框架(17 文件)
│   ├── Interfaces.cs      # 核心接口体系
│   ├── TransformContext.cs # AsyncLocal 上下文传播
│   ├── Decorator.cs       # 装饰器模式(日志/重试/超时)
│   ├── CacheTransformer.cs # 缓存包装
│   ├── ConditionalTransformer.cs # 条件分支
│   ├── TryTransformer.cs  # 容错包装
│   ├── GroupReducer.cs    # 分组归约
│   ├── DelegateAdapter.cs # 委托适配器
│   ├── AsyncComposition.cs # 异步组合器
│   ├── TransformerExtensions.cs # 扩展方法
│   └── ...
├── SortMent/              # 编排态射框架(5 文件)
│   ├── Interfaces.cs      # 10 个核心接口
│   ├── SortMentBase.cs    # 抽象基类体系
│   ├── SortMentCollection.cs # 集合与管线
│   ├── SortMentRegistry.cs   # 注册表模式
│   └── SortMentExtensions.cs # 扩展方法
├── Block/                 # 分块执行框架(6 文件)
│   ├── Interfaces.cs      # 核心接口
│   ├── BlockContext.cs    # 块上下文与结果类型
│   ├── ExecutionPipeline.cs # 执行管线
│   ├── BuiltInBlocks.cs   # 6 种内置块
│   ├── BlockBase.cs       # 抽象基类
│   └── BlockExtensions.cs # 扩展方法
├── StateMachine/          # 状态机框架(15 文件)
│   ├── StateMachine.Abstractions.cs # 核心接口
│   ├── SequentialStateMachine.cs    # 顺序状态机
│   ├── LifecycleStateMachine.cs     # 生命周期状态机
│   ├── ConditionalStateMachine.cs   # 条件状态机
│   ├── AsyncEventStateMachine.cs    # 异步事件状态机
│   ├── StateMachineStore.cs         # 状态机存储
│   ├── PauseManager.cs   # 暂停管理
│   ├── ScopeStateManager.cs # 作用域状态管理
│   └── ...
├── DecisionEngine/        # 决策引擎(4 文件)
│   ├── IDecisionEngine.cs # 核心接口 + 决策结果 + 规则定义
│   ├── RuleBasedDecisionEngine.cs   # 规则驱动实现
│   ├── CompositeDecisionEngine.cs   # 组合引擎
│   └── ConditionEvaluator.cs        # 条件评估器
├── GraphFoundation/       # 图基础框架(25 文件)
│   ├── Graph/             # 图核心(IGraph / CoreGraph / GraphFrame)
│   ├── Storage/           # 存储抽象(内存/自定义)
│   ├── Topology/          # 拓扑排序与关键路径
│   ├── Chain/             # 链式处理
│   ├── Navigation/        # 图遍历扩展
│   └── Snapshots/         # 图快照与差异比较
├── Container/             # 执行容器(24 文件)
│   ├── Abstractions/      # 核心接口
│   ├── Core/              # 执行单元与引擎
│   ├── Behaviors/         # 弹性策略行为
│   ├── Decorators/        # 装饰器实现
│   └── Extensions/        # 扩展方法
└── Declarative/           # 声明式框架(21 文件)
    ├── Interfaces.cs      # 核心接口
    ├── Abstractions/      # 抽象基类
    ├── Constraints/       # 5 种约束类型
    ├── Relations/         # 4 种关系操作
    ├── Mappers/           # 声明→运行时映射
    └── Resolvers/         # 声明解析器

代码仓库地址:https://gitee.com/Ljy_111/ZhiLianStorage.git

总结BasicMethod.Map 以明确的数学概念为根基,提供 8 个并行独立的通用基础模块。每个模块职责清晰、零外部依赖(Container 除外)、零业务耦合,可单独使用或按需自由组合,为上层应用提供从"声明式描述"到"函数式转换"到"编排执行"到"状态管理"的完整基础能力。

相关推荐
青山木1 小时前
Hot 100 --- 二叉树与递归
java·数据结构·算法·leetcode·深度优先
珠海西格电力2 小时前
数据采集与治理:零碳园区管理系统的 “生命线”
大数据·人工智能·算法·架构·能源
Byron Loong2 小时前
【c#】Bitmap释放之 大象与蚊子
开发语言·c#
●VON2 小时前
HarmonyKit | 鸿蒙新特性:router 导航 API 从 pushUrl 到 UIContext 的演进
算法·华为·交互·harmonyos
星释2 小时前
鸿蒙智能体开发实战:31.鸿蒙壁纸大师 - 环境搭建与基础配置
算法·华为·ai·harmonyos·鸿蒙
ysa0510302 小时前
【板子】树上启发式合并
数据结构·c++·笔记·算法
学究天人3 小时前
数学公理体系大全:第一章 命题逻辑:真值之舞
人工智能·算法·机器学习·数学建模·动态规划·图论·抽象代数
小O的算法实验室3 小时前
2025年Neurocomputing,基于LLM的进化优化器:结合精英策略推理
算法
临风细雨3 小时前
从 Bun 的 Rust 重写,看 C# 如何重建 AI 基础设施层
人工智能·rust·c#