Offline transactional history analysis with independently verifiable dependency-cycle witnesses
moon run --target wasm-gc src/demonode examples/mlflow-http-roundtrip.mjsnode dist/moontxnwitness.mjs --version
node dist/demo.mjsnode dist/moontxnwitness.mjs check examples/write-skew.json --profile balanced
node dist/moontxnwitness.mjs shrink examples/noisy-write-skew.json --profile balanced --history mini.json
node dist/moontxnwitness.mjs check mini.json --profile balanced --format markdown --output report.md --capsule case.json
node dist/moontxnwitness.mjs replay case.json
node dist/moontxnwitness.mjs compare-models examples/strict-realtime.json| 状态 | 退出码 | 含义 |
|---|---|---|
| consistent | 0 | 在提供的模型、观察及约束内有可行串行执行 |
| violation | 1 | 发现直接异常、依赖环或完整搜索无解 |
| invalid | 2 | 输入或约束不合法 |
| inconclusive | 3 | 观察不足或预算耗尽 |
moon add HhWw96/moontxnwitness@0.4.0import {analyzeWithOptions, shrinkWithOptions, replayReport} from './dist/sdk.mjs';
const report = analyzeWithOptions(history);
const reduced = shrinkWithOptions(history, {maxChecks: 256});
console.log(report.status, reduced.oneMinimal);
console.log(replayReport(reduced.reducedHistory, reduced.report));| 范围 | 默认入口 | balanced 入口 |
|---|---|---|
| 图分析 | 512 事务 / 10,000 操作 / 50,000 依赖 | 相同 |
| 精确串行补全 | 8 个提交事务 | 12 个提交事务 |
| 补全操作 / 初始键 | 512 / 128 | 相同 |
| 搜索前缀 / 操作检查 | 100,000 / 1,000,000 | 相同,可调低 |
| 缩减 | 64 事务 / 2,048 操作 / 128 次检查 | 512 事务 / 10,000 操作 / 256 次检查 |
node dist/moontxnwitness.mjs ingest capture-trace.json --history history.json
node dist/moontxnwitness.mjs check history.json --profile balanced --capsule case.json
node dist/postgres-demo.mjsnode examples/list-roundtrip.mjsnode examples/relation-roundtrip.mjsnpm run build
npm test
npm run packagepub(all) struct AnalysisOptions {
max_attempts : Int
max_operation_checks : Int
max_cached_states : Int
} derive(Eq)pub(all) struct AnalysisOptionsV4 {
max_attempts : Int
max_states : 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 struct AnalysisV4 {
// private fields
}pub struct CaptureAnomaliesV4 {
// private fields
}pub struct ClassificationV4 {
// private fields
}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) enum ElleModelV4 {
ElleReadUncommitted
ElleReadCommitted
ElleRepeatableRead
ElleSerializable
ElleStrictSerializable
ElleSnapshotIsolation
ElleConsistentView
ElleSessionReadUncommitted
ElleStrongReadUncommitted
ElleSessionReadCommitted
ElleStrongReadCommitted
ElleSessionSerializable
ElleSessionSnapshotIsolation
ElleStrongSnapshotIsolation
} derive(Eq)pub(all) struct GraphInfo {
analyzed : Bool
components : Int
cyclic_components : Int
cyclic_transactions : Int
bfs_roots : Int
edge_budget_exceeded : Bool
} derive(Eq)pub struct HistoryV4 {
// private fields
}pub struct InternalConsistencyV4 {
// private fields
}pub(all) struct KeyCoverage {
key : String
committed_reads : Int
committed_final_writes : Int
unresolved_reads : Int
} derive(Eq)pub struct ListPrefixProjectionV4 {
// private fields
}pub(all) enum ModelCompletionPolicyV4 {
ModelObservationOnlyCompletion
ModelGivenSnapshotsUnsupported
} derive(Eq)fn ModelCompletionPolicyV4::not_equal(x : ModelCompletionPolicyV4, y : ModelCompletionPolicyV4) -> Boolpub(all) enum ModelListProfileV4 {
ModelListNative
ModelListPrefixStates
ModelListOriginalSerial
} derive(Eq)pub(all) enum ModelRelationProfileV4 {
ModelRelationPoint
ModelRelationPredicateKeySlots
ModelRelationAtomicRows
} derive(Eq)fn ModelRelationProfileV4::not_equal(x : ModelRelationProfileV4, y : ModelRelationProfileV4) -> Boolpub(all) struct ReductionResult {
reduction : Reduction
analysis : AnalysisResult
cached_checks : Int
max_checks : Int
} derive(Eq)pub struct ReductionV4 {
// private fields
}pub struct RelationCategoryReductionV4 {
// private fields
}pub struct RelationClassificationV4 {
// private fields
}pub struct RelationPointGraphV4 {
// private fields
}pub struct RelationPredicateClassificationV4 {
// private fields
}pub struct RelationPredicateGraphV4 {
// private fields
}pub(all) enum RelationProgramReplayModeV4 {
RelationSnapshotPrefixes
RelationSerialOrder
} derive(Eq)fn RelationProgramReplayModeV4::equal(RelationProgramReplayModeV4, RelationProgramReplayModeV4) -> Boolfn RelationProgramReplayModeV4::not_equal(x : RelationProgramReplayModeV4, y : RelationProgramReplayModeV4) -> Boolpub struct RelationProgramReplayV4 {
// private fields
}pub struct RelationRowProjectionV4 {
// private fields
}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)pub(all) enum ScopedCategoryV4 {
ScopedG0
ScopedG1c
ScopedG2Item
ScopedG2
ScopedGSingleItem
ScopedGSingle
ScopedGNonadjacent
} derive(Eq)pub(all) struct ScopedDataEdgeInputV4 {
id : String
from : String
to : String
kind : ScopedDataKindV4
sources : Array[Json]
}pub(all) enum ScopedDataKindV4 {
ScopedWWItem
ScopedWWPredicate
ScopedWRItem
ScopedWRPredicate
ScopedRWItem
ScopedRWPredicate
} derive(Eq)pub struct ScopedDependencyGraphV4 {
// private fields
}pub(all) enum ScopedOrderContextV4 {
ScopedDataOnly
ScopedWithProcess
ScopedWithRealtime
} derive(Eq)pub(all) struct ScopedOrderEdgeInputV4 {
id : String
from : String
to : String
kind : ScopedOrderKindV4
context_id : String
from_source : ScopedOriginalRefV4
to_source : ScopedOriginalRefV4
}pub struct ScopedSearchResultV4 {
// private fields
}fn analysis_options(max_attempts? : Int, max_operation_checks? : Int, max_cached_states? : Int) -> AnalysisOptionsfn analysis_options_v4(max_attempts? : Int, max_states? : Int, max_operation_checks? : Int, max_cached_states? : Int) -> AnalysisOptionsV4fn analyze_json(text : String) -> Stringfn build_list_graph_effective_v4(history : HistoryV4, max_checks? : Int) -> Result[EffectiveListGraphV4, String]fn build_relation_point_graph_v4(history : HistoryV4, max_checks? : Int) -> Result[RelationPointGraphV4, String]fn build_relation_predicate_graph_v4(history : HistoryV4, max_graph_checks? : Int, max_predicate_checks? : Int, max_candidate_visits? : Int) -> Result[RelationPredicateGraphV4, String]fn capsule_content_json(text : String) -> Stringfn capsule_v3_content_json(text : String) -> Stringfn capsule_v4_content_json(text : String) -> Stringfn classify_models_v4_json(text : String, options_text : String) -> Stringfn classify_relation_point_v4(history : HistoryV4, categories? : Array[String], max_states? : Int, max_edge_checks? : Int, max_graph_checks? : Int) -> RelationClassificationV4fn classify_relation_predicate_v4(history : HistoryV4, category : ScopedCategoryV4, rule_set~ : ScopedRuleSetV4, max_graph_checks? : Int, max_predicate_checks? : Int, max_candidate_visits? : Int, max_states? : Int, max_edge_checks? : Int) -> Result[RelationPredicateClassificationV4, String]fn classify_relation_predicate_v4_json(text : String, options_text : String) -> Stringfn classify_relation_v4_json(text : String, options_text : String) -> Stringfn classify_v4(history : HistoryV4, categories? : Array[String], max_states? : Int, max_edge_checks? : Int, list_graph? : String, max_list_graph_checks? : Int) -> ClassificationV4fn compare_configured_c_text_v1(a : String, b : String) -> Intfn configured_session_bundle_v4_json(text : String) -> Stringfn configured_session_options_v4(max_journal_checks? : Int, max_results? : Int, max_installation_checks? : Int, max_fetch_checks? : Int, max_result_checks? : Int, max_source_checks? : Int) -> Result[ConfiguredSessionOptionsV4, String]fn configured_session_options_v4_json(text : String) -> Stringfn diagnose_configured_session_v4(config : SQLConfigV1, lifecycle_text : String, diagnostic_trace_text : String, source_input : Json, options? : ConfiguredSessionOptionsV4) -> ConfiguredSessionDiagnosticV4fn diagnose_configured_session_v4_json(config_text : String, lifecycle_text : String, diagnostic_trace_text : String, source_inputs_text : String, options_text : String) -> Stringfn dislock_sql_v3_proof_json(text : String) -> Stringfn inspect_anomalies_v4_json(text : String, options_text : String) -> Stringfn inspect_capture_anomalies_v4_json(text : String, options_text : String) -> Stringfn inspect_execution_failures_v3_json(text : String) -> Stringfn inspect_internal_consistency_v4_json(text : String, options_text : String) -> Stringfn inspect_lost_updates_v4_json(text : String, options_text : String) -> Stringfn model_capsule_v4_content_json(text : String) -> Stringfn model_facts_v4(history : HistoryV4, clients? : Array[ModelClientV4], clients_complete? : Bool) -> Result[ModelFactsV4, String]fn model_options_v4(models? : Array[ElleModelV4], max_source_checks? : Int, max_states? : Int, max_edge_checks? : Int, relation_profile? : ModelRelationProfileV4, list_profile? : ModelListProfileV4, completion_policy? : ModelCompletionPolicyV4) -> Result[ModelOptionsV4, String]fn model_profile_source_v3_json(text : String, options_text : String) -> Stringfn normalize_capture_json(text : String) -> Stringfn normalize_capture_v3_options_json(text : String, options_text : String) -> Stringfn normalize_configured_sql_v1_json(config_text : String, source : String, parameters_text : String, options_text : String) -> Stringfn normalize_presence_capture_json(text : String) -> Stringfn normalize_relation_capture_v3_json(text : String) -> Stringfn normalize_sql_candidate_v1(config : SQLConfigV1, source : String, parameters : Json, options? : SQLVerificationOptionsV1) -> SQLCandidateCheckV1fn options_v4_content_json(text : String) -> Stringfn orm_profile_source_v3_json(text : String, options_text : String) -> Stringfn project_list_prefix_v4(history : HistoryV4, max_checks? : Int) -> Result[ListPrefixProjectionV4, String]fn project_relation_rows_v4(history : HistoryV4, max_checks? : Int) -> Result[RelationRowProjectionV4, String]fn reduce_classification_v3_json(text : String, options_text : String) -> Stringfn reduce_relation_category_v4(history : HistoryV4, category~ : String, max_checks? : Int, max_states? : Int, max_edge_checks? : Int, max_graph_checks? : Int) -> RelationCategoryReductionV4fn reduce_relation_category_v4_json(text : String, options : String) -> Stringfn reduce_v3_json(text : String, options_text : String) -> Stringfn reduce_v4(history : HistoryV4, preserve~ : Model, max_checks? : Int, options? : AnalysisOptionsV4) -> ReductionV4fn relation_reduction_capsule_v4_content_json(text : String) -> Stringfn relation_reduction_report_v4_content_json(text : String) -> Stringfn replay_relation_program_v4(history : HistoryV4, certificate : Json, mode~ : RelationProgramReplayModeV4, max_checks? : Int) -> Result[RelationProgramReplayV4, String]fn replay_report_json(history_text : String, report_text : String) -> Stringfn run_json(text : String, format : String) -> Stringfn scoped_dependency_graph_v4(nodes : Array[String], data_edges : Array[ScopedDataEdgeInputV4], order_edges? : Array[ScopedOrderEdgeInputV4], data_complete? : Bool, process_complete? : Bool, realtime_complete? : Bool, gaps? : Array[Json]) -> Result[ScopedDependencyGraphV4, String]fn search_scoped_category_v4(graph : ScopedDependencyGraphV4, category : ScopedCategoryV4, rule_set~ : ScopedRuleSetV4, order_context? : ScopedOrderContextV4, max_states? : Int, max_edge_checks? : Int) -> ScopedSearchResultV4fn search_si_extension_v4(graph : ScopedDependencyGraphV4, rule_set~ : ScopedRuleSetV4, order_context? : ScopedOrderContextV4, max_states? : Int, max_edge_checks? : Int) -> ScopedSearchResultV4fn source_rules_capsule_v4_content_json(text : String) -> Stringfn source_rules_report_v4_content_json(text : String) -> Stringfn sql_verification_options_v1(max_checks? : Int, max_tokens? : Int, max_sql_bytes? : Int) -> SQLVerificationOptionsV1fn verify_anomalies_v4_json(text : String, report_text : String, options_text : String) -> Stringfn verify_capture_anomalies_v4_json(text : String, report_text : String, options_text : String) -> Stringfn verify_certificate_json(history_text : String, certificate_text : String) -> Stringfn verify_classification_v3_json(text : String, report_text : String) -> Stringfn verify_classification_v4_json(text : String, report_text : String, options_text : String) -> Stringfn verify_configured_fetch_v1(config : SQLConfigV1, execution : Json, native : Json, deliveries : Json, max_checks? : Int, grammar_options? : SQLVerificationOptionsV1) -> ConfiguredFetchCheckV1fn verify_configured_fetch_v1_json(config_text : String, execution_text : String, native_text : String, deliveries_text : String, options_text : String) -> Stringfn verify_configured_session_diagnostic_v4(config : SQLConfigV1, lifecycle_text : String, diagnostic_trace_text : String, source_input : Json, report : Json, expected_options? : ConfiguredSessionOptionsV4) -> Boolfn verify_configured_session_diagnostic_v4_json(config_text : String, lifecycle_text : String, diagnostic_trace_text : String, source_inputs_text : String, report_text : String, expected_options_text : String) -> Boolfn verify_configured_sql_v1_json(config_text : String, source : String, parameters_text : String, candidate_text : String, options_text : String) -> Stringfn verify_internal_consistency_v4_json(text : String, report_text : String, options_text : String) -> Stringfn verify_lost_updates_v4_json(text : String, report_text : String, options_text : String) -> Stringfn verify_model_classification_v4_json(text : String, report_text : String, expected_options_text : String) -> Stringfn verify_reduction_v4(history : HistoryV4, supplied : Json, preserve~ : Model, max_checks? : Int, options? : AnalysisOptionsV4) -> Boolfn verify_reduction_v4_json(text : String, report_text : String, options_text : String) -> Stringfn verify_relation_category_reduction_v4_json(text : String, report : String, options : String) -> Stringfn verify_relation_classification_v4_json(text : String, report_text : String, options_text : String) -> Stringfn verify_relation_predicate_classification_v4(history : HistoryV4, supplied : Json, category : ScopedCategoryV4, rule_set~ : ScopedRuleSetV4, max_graph_checks? : Int, max_predicate_checks? : Int, max_candidate_visits? : Int, max_states? : Int, max_edge_checks? : Int) -> Boolfn verify_relation_predicate_classification_v4_json(text : String, report_text : String, options_text : String) -> Stringfn verify_relation_program_replay_v4(history : HistoryV4, report : Json, certificate : Json, mode~ : RelationProgramReplayModeV4, max_checks? : Int) -> Boolfn verify_scoped_category_v4(graph : ScopedDependencyGraphV4, supplied : Json, category : ScopedCategoryV4, rule_set~ : ScopedRuleSetV4, order_context? : ScopedOrderContextV4, max_states? : Int, max_edge_checks? : Int) -> Boolfn verify_si_extension_v4(graph : ScopedDependencyGraphV4, supplied : Json, rule_set~ : ScopedRuleSetV4, order_context? : ScopedOrderContextV4, max_states? : Int, max_edge_checks? : Int) -> Boolfn verify_source_fetch_mapping_report_v4_json(config_text : String, policy_text : String, log_text : String, receipt_text : String, execution_text : String, native_text : String, deliveries_text : String, context_text : String, report_text : String, expected_options_text : String) -> Boolfn verify_source_fetch_mapping_v4(installation : SourceInstallationCheckV4, execution : Json, native : Json, deliveries : Json, source_context : Json, max_checks? : Int, max_fetch_checks? : Int, grammar_options? : SQLVerificationOptionsV1) -> SourceFetchMappingV4fn verify_source_fetch_mapping_v4_json(config_text : String, policy_text : String, log_text : String, receipt_text : String, execution_text : String, native_text : String, deliveries_text : String, context_text : String, options_text : String) -> Stringfn verify_source_installation_report_v4_json(config_text : String, policy_text : String, log_text : String, receipt_text : String, report_text : String, expected_options_text : String) -> Boolfn verify_source_installation_v4(config : SQLConfigV1, policy_value : Json, original_log : String, receipt : Json, max_checks? : Int) -> SourceInstallationCheckV4fn verify_source_installation_v4_json(config_text : String, policy_text : String, log_text : String, receipt_text : String, options_text : String) -> Stringfn verify_sql_candidate_v1(config : SQLConfigV1, source : String, parameters : Json, candidate : Json, options? : SQLVerificationOptionsV1) -> SQLCandidateCheckV1fn verify_v4_json(text : String, report_text : String, options_text : String) -> StringInstall
Download zipOffline transactional history analysis with independently verifiable dependency-cycle witnesses