MoonBit cross-target scenario reproduction matrix and evidence toolkit
Can another maintainer repeat the same example on the declared targets and verify the same output within a bounded time?
moon add ZBZ-ai-nb/cakecheck@0.3.0matrix name=demo version=0.3.0
scenario id=hello title=hello-world command="moon run examples/basic" targets=native,js,wasm expected=success output="hello world" timeout_ms=30000 required=true tags=smoke,portable
scenario id=fmt title=format command="moon fmt --check" targets=native expected=success output="format ok" timeout_ms=30000 required=true tags=qualitylet digest = @audit.scenario_evidence_digest("hello world", "")
let observations = [@audit.ScenarioObservation::{
id: "hello",
target: @audit.Native,
status: @audit.Passed,
stdout: "hello world",
stderr: "",
duration_ms: 14,
evidence_digest: digest,
}]let manifest = @audit.parse_scenario_manifest(source)
let matrix = @audit.build_scenario_matrix(
manifest,
observations,
[@audit.Native, @audit.Js, @audit.Wasm],
)
let policy = @audit.default_matrix_policy()
let checked = @audit.apply_policy(matrix, policy)
println(checked.to_markdown())
println(checked.to_json())moon run examples/basic
moon run cmd/mainmoon fmt --check
moon check --deny-warn
moon build
moon test --deny-warn
moon run examples/basic
moon run cmd/main
moon infopub(all) struct MatrixPolicy {
required_targets : Array[ScenarioTarget]
max_timeout_ms : Int
require_evidence : Bool
require_output_for_success : Bool
allow_failure_scenarios : Bool
} derive(Eq, Debug)pub(all) struct MatrixTimeline {
snapshots : Array[MatrixSnapshot]
improved : Int
regressed : Int
stable : Int
} derive(Eq, Debug)pub(all) struct ObservationParseResult {
observations : Array[ScenarioObservation]
issues : Array[ScenarioIssue]
} derive(Eq, Debug)pub(all) struct ParsedObservation {
observation : ScenarioObservation?
issues : Array[ScenarioIssue]
} derive(Eq, Debug)pub(all) struct ParsedScenario {
spec : ScenarioSpec?
issues : Array[ScenarioIssue]
} derive(Eq, Debug)pub(all) struct ReplayEnvelope {
case_id : String
target : ScenarioTarget
command : String
expected : ExpectedStatus
stdout : String
stderr : String
duration_ms : Int
evidence_digest : String
replay_key : String
} derive(Eq, Debug)pub(all) struct ReproductionContract {
matrix_name : String
matrix_version : String
matrix_digest : String
policy_digest : String
invariants : Array[ContractInvariant]
replay_count : Int
schedule_batch_count : Int
passes : Bool
} derive(Eq, Debug)pub(all) struct RunPlanStep {
index : Int
scenario_id : String
target : ScenarioTarget
command : String
expected : ExpectedStatus
timeout_ms : Int
required : Bool
} derive(Eq, Debug)pub(all) struct ScenarioIssue {
code : String
severity : IssueSeverity
scenario_id : String
target : String
message : String
hint : String
} derive(Eq, Debug)pub(all) struct ScenarioManifest {
name : String
version : String
specs : Array[ScenarioSpec]
issues : Array[ScenarioIssue]
} derive(Eq, Debug)pub(all) struct ScenarioMatrix {
name : String
version : String
specs : Array[ScenarioSpec]
observations : Array[ScenarioObservation]
coverage : Array[TargetCoverage]
issues : Array[ScenarioIssue]
required_count : Int
completed_count : Int
passed_count : Int
failed_count : Int
skipped_count : Int
} derive(Eq, Debug)pub(all) struct ScenarioMetrics {
scenario_count : Int
target_case_count : Int
observed_case_count : Int
covered_target_count : Int
required_target_count : Int
passed_count : Int
failed_count : Int
skipped_count : Int
total_duration_ms : Int
min_duration_ms : Int
max_duration_ms : Int
coverage_percent : Int
pass_percent : Int
balance_score : Int
} derive(Eq, Debug)pub(all) struct ScenarioObservation {
id : String
target : ScenarioTarget
status : ObservationStatus
stdout : String
stderr : String
duration_ms : Int
evidence_digest : String
} derive(Eq, Debug)pub(all) struct ScenarioQuery {
tag : String
target : ScenarioTarget?
status : ObservationStatus?
required_only : Bool
} derive(Eq, Debug)pub(all) struct ScenarioRiskFinding {
scenario_id : String
target : ScenarioTarget
level : ScenarioRiskLevel
code : String
message : String
hint : String
} derive(Eq, Debug)pub(all) struct ScenarioRiskReport {
findings : Array[ScenarioRiskFinding]
low_count : Int
medium_count : Int
high_count : Int
passes : Bool
} derive(Eq, Debug)pub(all) struct ScenarioSpec {
id : String
title : String
command : String
targets : Array[ScenarioTarget]
expected : ExpectedStatus
expected_output : String
timeout_ms : Int
required : Bool
tags : Array[String]
} derive(Eq, Debug)pub(all) struct ScheduleBatch {
index : Int
target : ScenarioTarget
lane : ScheduleLane
steps : Array[ScheduleStep]
parallel_safe : Bool
} derive(Eq, Debug)pub(all) struct ScheduleStep {
index : Int
case_id : String
target : ScenarioTarget
lane : ScheduleLane
command : String
estimated_ms : Int
} derive(Eq, Debug)pub(all) struct TargetCoverage {
target : ScenarioTarget
required_cases : Int
observed_cases : Int
passed_cases : Int
complete : Bool
} derive(Eq, Debug)pub(all) struct TargetProfile {
target : ScenarioTarget
label : String
supports_files : Bool
supports_network : Bool
supports_process : Bool
notes : String
} derive(Eq, Debug)fn build_reproduction_contract(matrix : ScenarioMatrix, policy : MatrixPolicy) -> ReproductionContractfn build_scenario_matrix(manifest : ScenarioManifest, observations : Array[ScenarioObservation], required_targets : Array[ScenarioTarget]) -> ScenarioMatrixfn observation_for(observations : Array[ScenarioObservation], id : String, target : ScenarioTarget) -> ScenarioObservation?fn risk_findings_for(report : ScenarioRiskReport, level : ScenarioRiskLevel) -> Array[ScenarioRiskFinding]fn scenario_evidence_digest(stdout : String, stderr : String) -> Stringfn validate_observation(spec : ScenarioSpec, observation : ScenarioObservation) -> Array[ScenarioIssue]Install
Download zipMoonBit cross-target scenario reproduction matrix and evidence toolkit