Sign in

    moonbit-notary

    Reusable MoonBit library and CLI for electronic evidence manifests, integrity verification, audit trails, and compliance reporting

    notary
    manifest
    evidence
    verification
    digest
    audit
    pipeline
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    2 months ago
    Downloads
    26

    No dependencies

    #MoonBit Notary

    moonbit-notary is a reusable MoonBit library and CLI for assembling, verifying, reviewing, and reporting electronic evidence manifests. It is designed for evidence hand-off, archive intake, integrity checks, and compliance-oriented workflows where deterministic outputs and auditability matter.

    #What it provides

    • Manifest and evidence data models with a fluent builder and query helpers.
    • Deterministic FNV-1a, CRC32, Murmur3, Merkle-root, and digest utilities.
    • Directory-style scanning and category classification for common evidence formats.
    • Rule-based validation for paths, digests, sources, categories, sealing, and duplicate material.
    • A pipeline layer for batch policies, canonical snapshots, risk summaries, quality assessment, retention decisions, review queues, reconciliation, and operational diagnostics.
    • Hash-chained audit records, version diffs, and Markdown/JSON/CSV/HTML reports.
    • A command-line entrypoint and a reproducible benchmark runner.

    The digest helpers in the current release are deterministic integrity fingerprints implemented in MoonBit. They are not a claim of production cryptographic security or a replacement for a reviewed cryptography library.

    #Package layout

    moonbit-notary/ ├── moon.mod ├── LICENSE ├── README.md ├── .github/workflows/test.yml ├── cmd/main/ # CLI executable ├── cmd/benchmark/ # measured pipeline benchmark ├── examples/ # runnable evidence scenarios └── src/ ├── core/ # manifests, items, digests, and builders ├── digest/ # deterministic hashes and Merkle roots ├── scanner/ # path scanning and classification ├── validator/ # compliance rules and reports ├── pipeline/ # batch processing and operational decisions ├── audit/ # hash-chained audit trail ├── report/ # manifest reconciliation and diffs ├── formatter/ # Markdown, JSON, CSV, and HTML output ├── crypto/ # signature and timestamp data structures ├── config/ # policy presets └── cli/ # command parsing and dispatch

    #Requirements

    Install the current stable MoonBit toolchain. Verify the local environment:

    moon version --all moon check --deny-warn moon test --deny-warn

    The repository uses moon.mod and moon.pkg files, so the commands above are run from the repository root.

    #CLI quick start

    moon run cmd/main -- help moon run cmd/main -- version moon run cmd/main -- init MAN-2026-001 moon run cmd/main -- scan ./evidence moon run cmd/main -- verify manifest.json moon run cmd/main -- export manifest.json markdown moon run cmd/main -- seal manifest.json moon run cmd/main -- audit MAN-2026-001

    The CLI examples use deterministic sample inputs for demonstration. Integrate the library APIs below when an application supplies its own file metadata or storage layer.

    #Library example

    The example assumes these imports in the consuming package's moon.pkg:

    import { "hcjbat/moonbit-notary/src/core", "hcjbat/moonbit-notary/src/digest", "hcjbat/moonbit-notary/src/pipeline", }

    let manifest = @core.ManifestBuilder::new()
    .set_id("MAN-2026-001")
    .set_title("Evidence package")
    .set_org("Example archive")
    .set_applicant("Operator")
    .add_evidence_simple(
    1,
    "Contract scan",
    "evidence/contract.pdf",
    @core.Category::PdfDocument,
    "sha256-fingerprint",
    "md5-fingerprint",
    520000L,
    "operator-1",
    )
    .build()

    @digest.seal_manifest(manifest)
    let batch = @pipeline.EvidenceBatch::from_manifest(manifest)
    let assessment = @pipeline.assess_batch(
    batch,
    @pipeline.BatchPolicy::strict(),
    )
    let report = assessment.to_markdown()

    src/pipeline is additive to the existing packages. Applications can start with EvidenceBatch::from_manifest, call verify_batch or assess_batch, and then pass the structured result to their own UI, storage, or reporting layer.

    #Benchmarks

    Run the real benchmark locally:

    moon run cmd/benchmark --

    The runner measures 100, 1,000, and 5,000 deterministic evidence records and prints elapsed milliseconds, throughput, canonical snapshot size, archive readiness, and digest prefixes. The recorded observation and reproduction details are in docs/benchmarks.md. Timings are machine- dependent; digest and readiness invariants are the stable checks.

    #Development and verification

    moon fmt moon fmt --check moon info moon check --deny-warn moon check --target all moon test --deny-warn moon test --target all

    moon info regenerates the package interface summaries. Review generated .mbti changes as public API changes. The GitHub Actions workflow runs strict check/test and formatting gates on Linux, macOS, and Windows.

    The test suite covers core data models, digest behavior, scanning, validation, formatting, audit trails, reconciliation, the pipeline's policy and boundary behavior, and the benchmark report format.

    #License

    Licensed under the Apache License 2.0.

    #Contributing

    Please include focused tests for behavior changes, run the verification commands above, keep public APIs small, and document any third-party source, generated code, fixture, or redistribution constraint introduced by a change.