moonbit-returnplay

A deterministic and auditable return-to-sport decision framework for MoonBit.

moonbit
return-to-sport
decision-framework
audit
moon add qxjhhrr/moonbit-returnplay@0.1.0
Download zip
Author
Version
0.1.0
License
Apache-2.0
Last updated
2 hours ago
Downloads
2
README

#moonbit-returnplay

moonbit-returnplay is a deterministic MoonBit library for evaluating staged return-to-sport protocols. It turns configured test observations into transparent stage results, prerequisite-aware progression summaries, batch statistics, and reviewable audit artifacts.

The library organizes protocol inputs and explains their workflow state. It does not diagnose injuries, predict medical outcomes, prescribe treatment, or automatically authorize participation.

#Features

  • Weighted integer scoring with explicit range and missing-data policies.
  • Required tests, minimum-score gates, maximum-missing gates, and stable reason ordering.
  • Multi-stage protocols with prerequisite blocking and deterministic current-stage selection.
  • Batch assessment, score distribution, status counts, evidence ledgers, review packets, and timelines.
  • Stable line-oriented reports suitable for logs, CI artifacts, and human review.
  • Reproducible fixtures, quality checks, and a benchmark example with fixed sample counts.
  • Pure MoonBit implementation with no network, database, or runtime service dependency.

#Quick start

Requires the current stable MoonBit CLI.

moon fmt moon check --deny-warn moon test --deny-warn moon run ./examples/returnplay_demo moon run ./examples/returnplay_benchmark

The demo prints a deterministic baseline summary. The benchmark example runs eight fixed fixtures and prints the measured sample counts and quality result; it is not a cross-machine performance claim.

#API example

let definitions = [
@returnplay.test_definition(
id="strength",
stage=@returnplay.return_stage_baseline(),
name="Strength",
weight=2,
required=true,
threshold=70,
note="Example protocol input",
),
]
let observations = [
@returnplay.observation_entry(
id="strength",
value=@returnplay.observation_score(86),
),
]
let result = @returnplay.evaluate_stage(
definitions=definitions,
observations=observations,
policy=@returnplay.stage_policy_with_gates(
missing=@returnplay.missing_policy_block_required(),
gates=[@returnplay.gate_minimum_score(70)],
),
)

Observations can be Pass, Fail, a bounded integer score, or Missing. Scores and weighted totals use integer arithmetic, so the same input produces the same result across supported targets.

#Architecture

The package is organized around small, composable domain modules:

  • model, validation, evaluation, and audit define the stable assessment contract.
  • protocol and progression validate ordered stages and resolve prerequisites.
  • scoring, policy, batch, and operations provide reusable aggregation and query behavior.
  • evidence, review, timeline, bundle, and governance keep provenance and human-review metadata separate from score calculation.
  • report, export, fixtures, benchmark, and quality produce deterministic artifacts and regression evidence.

#Benchmark and source scale

Run the reproducible local workload with:

moon run ./examples/returnplay_benchmark powershell -NoProfile -ExecutionPolicy Bypass -File scripts/source-scale.ps1

The benchmark uses eight fixed fixtures and three configured repetitions. The source-scale script reports production MoonBit lines separately from test lines and fails below the repository's 6000-line total threshold. Current measured values are documented in docs/benchmark.md.

#Quality assurance

The local and GitHub checks cover formatting, generated interface drift, moon check --deny-warn, tests, native/all targets where the runner provides the required toolchain, example smoke tests, source scale, and the fixed benchmark. The workflow installs Moon through the official stable installer on Ubuntu, macOS, and Windows; Windows also installs the UCRT native toolchain for native-target tests.

powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\cli-check.ps1

#Safety boundary

This is a protocol and audit library, not a medical device or clinical decision system. Example stages, names, observations, and thresholds are synthetic fixtures. Real protocols must be defined, reviewed, and operated by appropriately qualified organizations.

#License

Apache-2.0. See LICENSE.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io