Offline transactional history analysis with independently verifiable dependency-cycle witnesses
node dist/moontxnwitness.mjs --version
node dist/demo.mjsnode dist/moontxnwitness.mjs check examples/write-skew.json --profile balanced
node dist/moontxnwitness.mjs check examples/fractured-observation.json --profile balanced --format json
node dist/moontxnwitness.mjs shrink examples/noisy-write-skew.json --profile balanced --output reduction.json --history mini.json
node dist/moontxnwitness.mjs check mini.json --profile balanced --format markdown --output report.md --capsule case.capsule.json
node dist/moontxnwitness.mjs replay case.capsule.json
node dist/moontxnwitness.mjs compare-models examples/strict-realtime.json| 状态 | 退出码 | 含义 |
|---|---|---|
| consistent | 0 | 当前模型与约束内有可行串行执行,无未解决缺失 |
| violation | 1 | 有直接读写异常、依赖环或完整搜索无解 |
| invalid | 2 | 输入或约束不合法 |
| inconclusive | 3 | 缺少观察或计算预算不足 |
node dist/postgres-demo.mjs{
"schemaVersion": 1,
"model": "serializable",
"initial": {"x": "x0", "y": "y0"},
"transactions": [
{"id": "A", "status": "committed", "ops": [
{"type": "read", "key": "x", "version": "x0"},
{"type": "write", "key": "y", "version": "y1"}
]},
{"id": "B", "status": "committed", "ops": [
{"type": "read", "key": "y", "version": "y0"},
{"type": "write", "key": "x", "version": "x1"}
]}
]
}import {analyzeWithOptions, shrinkWithOptions, replayReport} from './dist/sdk.mjs';
const report = analyzeWithOptions(history, {
maxAttempts: 100000, maxOperationChecks: 1000000, maxCachedStates: 50000
});
console.log(report.status, report.search, report.metrics);
const reduced = shrinkWithOptions(history, {maxChecks: 256});
console.log(reduced.oneMinimal, replayReport(reduced.reducedHistory, reduced.report));moon add HhWw96/moontxnwitness@0.1.0| 范围 | 默认兼容入口 | balanced 入口 |
|---|---|---|
| 图分析 | 512 事务 / 10,000 操作 / 50,000 依赖 | 相同 |
| 完整串行补全 | 8 个已提交事务 | 12 个已提交事务 |
| 补全操作 / 初始键 | 512 / 128 | 相同 |
| 候选前缀 / 操作检查 | 100,000 / 1,000,000 | 相同,可调低 |
| 失败状态缓存 | 无 | 最多 50,000 项,可关闭 |
| 缩减 | 64 事务 / 2,048 操作 / 128 次检查 | 512 事务 / 10,000 操作 / 256 次检查 |
npm run build
npm test
npm run benchmark
npm run postgres:verify
npm run packagepub(all) struct AnalysisOptions {
max_attempts : Int
max_operation_checks : Int
max_cached_states : Int
} derive(Eq)pub(all) struct AnalysisResult {
report : Report
options : AnalysisOptions
cache_hits : Int
cached_states : Int
} derive(Eq)pub(all) struct Edge {
from : String
to : String
kind : Dependency
key : String?
from_op : Int?
to_op : Int?
from_version : String?
to_version : String?
reason : String
} derive(Eq, Hash)pub(all) struct GraphInfo {
analyzed : Bool
components : Int
cyclic_components : Int
cyclic_transactions : Int
bfs_roots : Int
edge_budget_exceeded : Bool
} derive(Eq)pub(all) struct KeyCoverage {
key : String
committed_reads : Int
committed_final_writes : Int
unresolved_reads : Int
} derive(Eq)pub(all) struct ReductionResult {
reduction : Reduction
analysis : AnalysisResult
cached_checks : Int
max_checks : Int
} derive(Eq)pub(all) struct Report {
outcome : Outcome
model : Model
findings : Array[Finding]
edges : Array[Edge]
witness : Array[Edge]
serial_order : Array[String]
transaction_count : Int
committed_count : Int
operation_count : Int
inferred_orders : Map[String, Array[String]]
order_sources : Map[String, String]
search : SearchInfo
graph : GraphInfo
coverage : Array[KeyCoverage]
} derive(Eq)fn analysis_options(max_attempts? : Int, max_operation_checks? : Int, max_cached_states? : Int) -> AnalysisOptionsfn analyze_json(text : String) -> Stringfn capsule_content_json(text : String) -> Stringfn replay_report_json(history_text : String, report_text : String) -> Stringfn run_json(text : String, format : String) -> Stringfn verify_certificate_json(history_text : String, certificate_text : String) -> StringInstall
Download zipOffline transactional history analysis with independently verifiable dependency-cycle witnesses