Process discovery, trace conformance and performance diagnostics for MoonBit
Dependencies
| 能力 | 可复用价值 |
|---|---|
| 日志重建与 JSON 互操作 | 将乱序业务区间按实例重建,验证身份、时间与容量,便于应用或现有协议库接入。 |
| 流程关系和变体发现 | 区分活动次数与实例覆盖,识别直接相邻关系、自循环、起止节点和完整处理路径。 |
| 最优加权轨迹对齐 | 对有限参考路径解释额外活动和缺失步骤,输出活动身份与逐步证据,支持不同偏差成本。 |
| 区间性能和资源诊断 | 区分服务工作量、并发区间覆盖和真正空闲,分析分位数、环节间隔及资源并发峰值。 |
import { "xingsiyi/processlens" @lens }fn main raise {
let log = @lens.EventLog::new([
@lens.LogEvent::new("o1", "order/7", "create", 0L, 1L),
@lens.LogEvent::new("o2", "order/7", "ship", 5L, 6L),
])
let model = @lens.ReferencePath::new("approved-order", ["create", "approve", "ship"])
let result = log.align([model])
assert_eq(result[0].cost, 1)
println(@lens.alignment_to_json(result[0]).stringify())
println(@lens.process_map_to_json(log.discover()).stringify())
println(@lens.performance_to_json(log.performance()).stringify())
}| 示例 | 输入、分析和可核验结果 |
|---|---|
| procurement | 两笔乱序订单,发现正常和跳过审批两种路径;对齐明确指出缺失审批,并报告处理空闲。 |
| support | 工单反复调查形成自循环;对齐给出多余活动证据,并输出客服环节服务耗时分布。 |
| pipeline | 构建与测试并行;区间并集避免把并发工作量误算成总耗时,计算资源并发峰值。 |
| repairs | 正常维修和复检返工走不同参考路径;识别变体,比较工位服务时间和跨工单并发。 |
moon run --target native examples/procurement
moon run --target native examples/support
moon run --target native examples/pipeline
moon run --target native examples/repairs
moon run --target native --release examples/process_scalemoon run --target native cmd/processlens -- analyze examples/files/process-log.json
moon run --target native cmd/processlens -- align examples/files/process-log.json examples/files/reference-paths.jsonmoon check --target all --deny-warn
moon build --target all --deny-warn
moon test --target all --deny-warn
moon fmt --check
moon info
git diff --exit-code
python scripts/verify_repository.pypub(all) suberror ProcessError {
InvalidLog(path~ : String, reason~ : String)
Capacity(resource~ : String, limit~ : Int)
} derive(Debug)pub struct AlignmentCosts {
unexpected : Int
missing : Int
}pub(all) struct CasePerformance {
case_id : String
events : Int
cycle_time : Int64
busy_union : Int64
idle_time : Int64
service_work : Double
overlapping_starts : Int
}fn CaseTrace::align(self : CaseTrace, references : Array[ReferencePath], costs? : AlignmentCosts, max_cells? : Int) -> TraceAlignment raise ProcessErrorpub(all) struct DurationDistribution {
count : Int
minimum : Int64?
maximum : Int64?
median : Int64?
p95 : Int64?
mean : Double?
}fn EventLog::align(self : EventLog, references : Array[ReferencePath], costs? : AlignmentCosts, max_cells? : Int) -> Array[TraceAlignment] raise ProcessErrorfn EventLog::new(events : Array[LogEvent], max_events? : Int, max_cases? : Int, max_trace? : Int) -> EventLog raise ProcessErrorpub(all) struct HandoffPerformance {
source : String
target : String
positive_gap : DurationDistribution
overlapping_pairs : Int
}fn LogEvent::new(id : String, case_id : String, activity : String, started : Int64, completed : Int64, resource? : String?) -> LogEvent raise ProcessErrorpub(all) struct PerformanceReport {
cases : Array[CasePerformance]
activities : Array[ActivityPerformance]
handoffs : Array[HandoffPerformance]
resources : Array[ResourcePerformance]
cycle_times : DurationDistribution
}pub(all) struct ProcessMap {
nodes : Array[ActivityNode]
edges : Array[FlowEdge]
variants : Array[ProcessVariant]
cases : Int
events : Int
}fn ProcessMap::frequent_edges(self : ProcessMap, minimum : Int) -> Array[FlowEdge] raise ProcessErrorfn ReferencePath::new(name : String, activities : Array[String]) -> ReferencePath raise ProcessErrorpub(all) struct ResourcePerformance {
resource : String
occurrences : Int
service : DurationDistribution
maximum_concurrency : Int
}pub(all) struct TraceAlignment {
case_id : String
reference : String
cost : Int
fitness : Double
moves : Array[AlignmentMove]
evaluated_cells : Int
}Install
Download zipProcess discovery, trace conformance and performance diagnostics for MoonBit
Dependencies