No description
  • Rust 82.5%
  • Python 7.6%
  • JavaScript 4.9%
  • Astro 3.5%
  • Shell 1.1%
  • Other 0.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Alex Samartsau 6e6770bc02
Some checks are pending
ci / quality (1.88.0) (push) Waiting to run
ci / quality (stable) (push) Waiting to run
ci / YAML Test Suite (push) Waiting to run
ci / allocation budgets (push) Waiting to run
ci / cross (aarch64-apple-darwin) (push) Waiting to run
ci / cross (x86_64-apple-darwin) (push) Waiting to run
ci / cross (x86_64-pc-windows-gnu) (push) Waiting to run
ci / cross (x86_64-pc-windows-msvc) (push) Waiting to run
ci / macos-latest (push) Waiting to run
ci / windows-latest (push) Waiting to run
ci / dependency policy (push) Waiting to run
ci / instruction counts (push) Waiting to run
ci / plan check (push) Waiting to run
ci / repository lint (push) Waiting to run
ci / documentation lint (push) Waiting to run
ci / package and downstream smoke (push) Waiting to run
ci / semver checks (push) Waiting to run
ci / public API diff (push) Waiting to run
ci / minimal versions (push) Waiting to run
ci / secret scan (push) Waiting to run
leak gate / leak scan (push) Waiting to run
fix(ci,tests): kill final 10 ayaml mutation survivors and sync ci-local miri mirrors (#338)
## Summary

Closes the final 10 surviving mutants from the 56-shard hosted `mutants`
qualification run on `e7bab6e2` (49/56 shards already passed including
8/8 `ayaml-edit` shards) and updates `tools/ci-local.sh` to mirror the
split `ayaml-edit` Miri commands.

### Changes
- **`tools/ci-local.sh`**: Mirror the two split `ayaml-edit` Miri
commands from `.github/workflows/miri.yml` so `./tools/ci-local.sh sync`
passes cleanly.
- **`crates/ayaml/src/spanned.rs`**: Remove the equivalent
`!data.ambiguous` guard on `Kind::TaggedMapping` inside
`SpannedNode::resolved_value` (`resolve_entries` already rejects every
ambiguous case).
- **`crates/ayaml/src/tape/builder.rs`**: Deduplicate
`TAPE_SEEN_SMALL_LIMIT * 2` table allocation in `promote_seen_keys`.
- **`crates/ayaml/src/tape/de.rs`**: Remove the redundant string arm in
`deserialize_scalar_as_text` (handled identically by `_ =>
inner.deserialize_any_at(span, visitor)`).
- **`crates/ayaml/src/tape/tests.rs` &
`crates/ayaml/src/tape/tests_mutants.rs`**: Strengthen assertions for
`borrowed_slice_span`, `scalar_eq` (distinct bool indices), `mapping_eq`
(trailing sibling leak), `unexpected_tape` (`boolean \`true\`` via
`deserialize_struct`), `TapeRef::deserialize_struct`, and
`NothingDeserializer::deserialize_struct`.

## Verification
- `./tools/ci-local.sh sync` (PASS)
- `cargo +1.100.0 fmt --all -- --check`
- `cargo +1.100.0 clippy --workspace --all-targets --all-features
--locked -- -D warnings` (and Rust 1.88 MSRV)
- Bounded `cargo test --workspace --all-features --locked`
- `python3 tools/check_alloc_baseline.py --strict-slack` (118/118 OK)
- `python3 tools/check_instructions.py main` (116/116 Callgrind cells
OK)
- Targeted local `cargo-mutants` across all touched functions (0 missed)
- `python3 tools/leak-scan/gate.py` (commits and PR metadata clean)
2026-12-03 20:10:47 -05:00
.cargo AY-171: close fuzzing, adversarial, Miri, Kani, and mutation blind spots (#276) 2026-11-27 19:28:35 -05:00
.github fix(ci,tests): resolve Miri and mutation-testing gaps for v1.1.0 qualification (#337) 2026-12-03 17:20:20 -05:00
aplan/tasks Harden Wave 3 core, perf gates, Miri memcount, docs, and site checks (#336) 2026-12-03 13:12:55 -05:00
crates fix(ci,tests): kill final 10 ayaml mutation survivors and sync ci-local miri mirrors (#338) 2026-12-03 20:10:47 -05:00
docs Harden Wave 3 core, perf gates, Miri memcount, docs, and site checks (#336) 2026-12-03 13:12:55 -05:00
fuzz Harden Wave 3 core, perf gates, Miri memcount, docs, and site checks (#336) 2026-12-03 13:12:55 -05:00
site Harden Wave 3 core, perf gates, Miri memcount, docs, and site checks (#336) 2026-12-03 13:12:55 -05:00
tests Migrate ayaml to ZeroPier, @zeropier/site-kit, and Cloudflare Workers (#330) 2026-12-03 00:22:43 -05:00
tools fix(ci,tests): kill final 10 ayaml mutation survivors and sync ci-local miri mirrors (#338) 2026-12-03 20:10:47 -05:00
.alint.yml Upgrade alint pin to v0.23.0, land Dependabot actions updates, and bump astro to 7.4.13 (AY-165) (#261) 2026-11-25 17:03:49 -05:00
.aplan.yml Make aplan version read the workspace version (#80) 2026-11-10 16:55:40 -05:00
.editorconfig Gate repository shape with alint 0.22.0 (#82) 2026-11-10 20:25:36 -05:00
.gitattributes Fix CI secret scanning, unsafe census, and Windows fixture line endings 2026-11-04 11:31:56 -05:00
.gitignore Migrate ayaml to ZeroPier, @zeropier/site-kit, and Cloudflare Workers (#330) 2026-12-03 00:22:43 -05:00
.gitleaks.toml Add a leak gate for public pushes 2026-11-05 12:39:29 -05:00
.markdownlint-cli2.yaml Enforce documentation lint and plan evidence verification (#76) 2026-11-10 15:53:12 -05:00
AGENTS.md docs: sync v1.1 docs, website, changelogs, and aplan titles (AY-214) (#335) 2026-12-03 04:02:09 -05:00
Cargo.lock test: expand v1.1 fuzz, unit, property, adversarial, conformance, Kani, Miri, and mutation coverage (AY-207) (#328) 2026-12-02 21:31:54 -05:00
Cargo.toml Migrate ayaml to ZeroPier, @zeropier/site-kit, and Cloudflare Workers (#330) 2026-12-03 00:22:43 -05:00
CHANGELOG.md Harden Wave 3 core, perf gates, Miri memcount, docs, and site checks (#336) 2026-12-03 13:12:55 -05:00
clippy.toml Enforce a strict MSRV-compatible Rust lint policy (#103) 2026-11-12 13:19:17 -05:00
CONTRIBUTING.md docs: sync v1.1 docs, website, changelogs, and aplan titles (AY-214) (#335) 2026-12-03 04:02:09 -05:00
deny.toml ayaml 0.1.0 2026-11-04 10:59:07 -05:00
LICENSE-APACHE ayaml 0.1.0 2026-11-04 10:59:07 -05:00
LICENSE-MIT ayaml 0.1.0 2026-11-04 10:59:07 -05:00
NOTICE ayaml 0.1.0 2026-11-04 10:59:07 -05:00
README.md docs: sync v1.1 docs, website, changelogs, and aplan titles (AY-214) (#335) 2026-12-03 04:02:09 -05:00
RELEASING.md docs: sync v1.1 docs, website, changelogs, and aplan titles (AY-214) (#335) 2026-12-03 04:02:09 -05:00
rustfmt.toml Enforce a strict MSRV-compatible Rust lint policy (#103) 2026-11-12 13:19:17 -05:00
SECURITY.md Migrate ayaml to ZeroPier, @zeropier/site-kit, and Cloudflare Workers (#330) 2026-12-03 00:22:43 -05:00
wrangler.jsonc Harden Wave 3 core, perf gates, Miri memcount, docs, and site checks (#336) 2026-12-03 13:12:55 -05:00

ayaml

CI crates.io ayaml-edit docs.rs MSRV 1.88 License: MIT OR Apache-2.0

Documentation · Benchmarks · Parsing Modes · Migration Guides · API Docs

A safe, fast, pure-Rust YAML 1.2.2 parser, zero-copy tape, value model, Serde codec, emitter, and source-preserving editor.

One scanner and grammar back every surface (pull events, flat-array Tape, owned Value, SpannedTree, typed Serde decoding, and emission), so every API enforces the same YAML 1.2.2 semantics, byte-accurate spans, and DoS limits.

The current release is 1.0.0 (this branch also documents strictly additive 1.1 APIs listed under [Unreleased] in CHANGELOG.md ahead of the 1.1.0 release). Both ayaml and ayaml-edit enforce #![forbid(unsafe_code)], are UTF-8 only, target MSRV Rust 1.88, and are dual-licensed under MIT or Apache-2.0.

Highlights

  • Pure safe Rust, minimal dependencies: #![forbid(unsafe_code)], zero C/C++ FFI, no default features, and only 2 runtime dependencies (serde, indexmap).
  • Complete YAML 1.2.2 conformance: 100% pass rate on the YAML Test Suite, verified with Miri, Kani proofs, fuzzing, property tests, and mutation testing.
  • Flat-array zero-copy Tape, 'static OwnedTape, & reusable ParserBuf: compact 16-byte nodes borrowing unmodified &str slices directly from input (or from an Arc<str> via OwnedTape / OwnedTapeDocuments), Tape::source / TapeDocuments::source, streaming merge_keys, and reusable ParserBuf scratch (*_in, ParserBuf::deserializer*, Tape::recycle_into, EventStream::recycle_into, Deserializer::recycle_into) for high-throughput bulk parsing.
  • Direct streaming Serde & owned Value: borrowed (from_str_borrowed) and owned typed decoding streamed directly from events at every input size, ayaml::with::singleton_map for single-entry mapping enum serialization, ayaml::Tagged<T> for explicit typed tags (composable with Spanned<T>), multi-document Deserializer, DocumentDeserializer middleware, DeserializeSeed, and insertion-ordered Value with exact wide integers.
  • Byte-accurate spans, opt-in comment capture, & source-preserving editing: SpannedTree (with opt-in parse*_with_comments / comments() and standalone scan_comments*), Spanned<T>, and LineIndex (UTF-8, scalar, and UTF-16 columns) for linters and LSPs, plus companion crate ayaml-edit for verified, comment-preserving edits, read-only plan_batch* / Editable::plan, and transactional Editable<T>.
  • Deterministic emitter: values, Serde types, event streams, and document streams with per-node style overrides, YAML 1.1-safe leading-zero numeral quoting, and output limits.
  • Built-in DoS limits & safe diagnostics: native resource budgets on every parse, decode, and emit path, stable ErrorCode (yaml.<kebab-name>), and Error::masked() (MaskedError) for logging errors from untrusted or sensitive YAML.
  • Smooth migrations: opt-in YAML 1.1 << merge-key expansion (ParseOptions::with_merge_keys(true)), Markdown frontmatter helpers (parse_frontmatter*), and additive libyaml-compat mode (ayaml::compat, including compat::from_slice*, compat::parse_tape*, compat::parse_owned_tape*, and compat::scan_comments*).

Performance

Geometric means across the pinned 26-fixture suite (v1.0.0, 3 rounds, x86_64, semantic oracle verified):

Workload ayaml result
Generic Value DOM vs Rust & C++ DOMs 2.12x to 2.44x faster than yaml-rust2 / saphyr, 3.08x faster than yaml-serde (4.57x lower peak heap, 5.1x fewer allocs), 4.98x faster than serde-saphyr (serde_json::Value), 1.87x faster than C++ fkYAML, matches astral-yaml Value CPU (0.99x) at 3.85x lower peak heap
Flat-array zero-copy Tape DOM 1.43x faster than ayaml::Value (1.51x lower peak heap, 140x fewer allocs); 4.41x faster and 6.99x lower peak heap than yaml-serde; 1.42x faster and 5.89x lower peak heap than astral-yaml Value
Streaming pull events (parse_events) 1.72x faster than C libyaml (1.97x lower peak heap), 2.78x faster than C libfyaml; O(1) ~42 KiB streaming heap up to 1 MiB (up to 2,456 MiB/s on 1 MiB plain scalars)
Deterministic YAML emission (to_string) 133 to 242 MiB/s across 7 fixtures (4.96x geomean faster than yaml-serde, 2.01x faster than C++ fkYAML)

Across five migrated open-source Rust projects (syntect, ast-grep, zizmor, prek, and rattler-build, totaling 3,380 upstream tests), ayaml delivered 1.52x to 4.76x faster parsing and 2.29x to 41.1x fewer heap allocations with zero correctness bugs. See Benchmarks & Performance, Parsing modes explained, and Real-world migration validation.

Install

[dependencies]
ayaml = "1.0.0"

For typed Serde decoding, enable Serde's derive feature in your own crate:

[dependencies]
ayaml = "1.0.0"
serde = { version = "1", features = ["derive"] }

For verified, comment-preserving source edits, add the companion crate:

[dependencies]
ayaml-edit = "1.0.0"

Quick start

Parse a document into the generic value model and emit YAML:

use ayaml::{parse_value, to_string};

fn main() -> Result<(), ayaml::Error> {
    let value = parse_value("name: example\nitems:\n  - one\n  - two\n")?;
    assert_eq!(value["name"].as_str(), Some("example"));

    let output = to_string(&value)?;
    assert!(output.contains("name: example"));
    Ok(())
}

Decode into a typed Rust struct:

use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Config {
    name: String,
    retries: u32,
}

fn main() -> Result<(), ayaml::Error> {
    let config: Config = ayaml::from_str("name: example\nretries: 3\n")?;
    assert_eq!(config.retries, 3);
    Ok(())
}

Inspect read-only YAML with zero-copy Tape (flat-array DOM):

use ayaml::parse_tape;

fn main() -> Result<(), ayaml::Error> {
    let tape = parse_tape("name: example\nports: [80, 443]\n")?;
    let root = tape.root();
    assert_eq!(root.get("name").and_then(|n| n.as_str()), Some("example"));
    assert_eq!(
        root.get("ports").and_then(|n| n.get(1)).and_then(|n| n.as_u64()),
        Some(443),
    );
    Ok(())
}

Walk the pull event stream when streaming or source spans matter:

fn main() -> Result<(), ayaml::Error> {
    for event in ayaml::parse_events("a: 1\n")? {
        let event = event?;
        println!("{event:?} at {:?}", event.span());
    }
    Ok(())
}

A span is a byte range. Use LineIndex::new(input) to convert offsets to zero-based Position values in UTF-8, scalar, or UTF-16 columns (and back); Location::from(position) provides one-based line and column numbers.

Configure resource limits or emit options with ParseOptions and EmitOptions:

use ayaml::{EmitOptions, Limits, ParseOptions, parse_value_with, to_string_value_with};

const PARSE: ParseOptions =
    ParseOptions::new().with_limits(Limits::new().with_max_depth(64));

fn main() -> Result<(), ayaml::Error> {
    let value = parse_value_with("a: [1, 2, 3]\n", &PARSE)?;
    assert_eq!(value["a"][1].as_u64(), Some(2));

    let flow = to_string_value_with(&value, &EmitOptions::flow())?;
    assert_eq!(flow, "{a: [1, 2, 3]}\n");
    Ok(())
}

API overview

Need Entry points
Flat-array zero-copy DOM parse_tape*, parse_tape_documents*, parse_owned_tape*, parse_owned_tape_documents*, Tape (Tape::source), TapeDocuments (TapeDocuments::source), OwnedTape, OwnedTapeDocuments, TapeRef, Tape::deserialize, Tape::deserialize_seed
Reusable scratch buffers ParserBuf (ParserBuf::deserializer*, from_slice*, scan_comments*, parse_frontmatter*, parse_spanned*), parse_events*_in, EventStream::recycle_into, Deserializer::from_str*_in, Deserializer::recycle_into, from_slice*_in, compat::from_slice*_in, scan_comments*_in, compat::scan_comments*_in, parse_frontmatter*_in, SpannedTree::parse*_in, parse_tape*_in, parse_owned_tape*_in, parse_value*_in, from_str*_in, Tape::recycle_into, OwnedTape::recycle_into
Owned value model parse_value, parse_value_with (with opt-in ParseOptions::with_merge_keys), parse_documents, parse_documents_with
Spanned pull events parse_events, parse_events_with, parse_events_in, parse_events_with_in, EventStream
Spanned tree, comments, & typed spans SpannedTree::parse*, SpannedTree::parse*_with_comments*, SpannedTree::comments, scan_comments*, SpannedNode, Spanned<T>, LineIndex
Typed decoding, tags, & middleware from_str*, from_str_borrowed, from_slice*, from_slice_borrowed, from_reader*, from_str_seed*, ayaml::with::singleton_map, ayaml::Tagged<T>, Deserializer, DocumentDeserializer
Markdown frontmatter split_frontmatter, split_frontmatter_with, parse_frontmatter*, parse_frontmatter_value* (including *_in variants)
Value/Serde conversion from_value, from_value_seed, to_value
Deterministic emission to_string, to_string_with, to_writer, to_writer_with, to_string_value_with, to_string_documents_with, to_string_events_with, Emitter
Source-preserving editing Companion crate ayaml-edit: replace_scalar, remove_entry, insert_mapping_entry, upsert_mapping_entry, insert_sequence_item, insert_comment, plan_batch, apply_batch, apply_batch_validated, apply_batch_checked, Editable<T> (Editable::plan), apply_edits (plus opt-in libyaml-compat)
Libyaml compatibility ayaml::compat (compat::from_str*, compat::from_slice*, compat::parse_events*, compat::parse_tape*, compat::parse_owned_tape*, compat::scan_comments*, compat::deserialize_any*, compat::ParseOptions with GlobalTags and with_allow_duplicates) behind libyaml-compat

ParseOptions, compat::ParseOptions, EmitOptions, and Limits are #[non_exhaustive] structs with const presets (new(), for_max_input(), EmitOptions::flow()) and with_* builders. EmitOptions combines resource limits, layout and indentation settings, and optional per-node EmitterStyles in one value; Emitter reuses borrowed Limits and EmitterOptions across calls.

Compatibility profile

The default parser follows YAML 1.2.2. In particular:

  • yes, no, and date-like text remain strings;
  • 0123 remains a string; 0b11, 0o755, and 0x1f are integers;
  • 1e3 is a floating-point number;
  • merge keys remain literal << entries by default (opt-in YAML 1.1 expansion is available via ParseOptions::with_merge_keys(true) or Value::apply_merge_keys*);
  • duplicate mapping pairs are retained at the event layer and rejected deterministically during composition and typed decoding;
  • custom tags are preserved.

The additive libyaml-compat feature exposes ayaml::compat for callers that need libyaml-compatible behavior without changing the default root functions. compat::ParseOptions supports dropping non-core global tags (GlobalTags::Drop) and toggling duplicate-key rejection (with_allow_duplicates(false)). Deliberate compatibility deviations are listed in tests/data/yaml-test-suite-deviations.txt.

See the Compatibility profile guide for details.

Limits

Every parse, decode, and emit entry point accepts explicit Limits via its _with form taking &ParseOptions, &compat::ParseOptions, or &EmitOptions (Value::apply_merge_keys_with_limits also takes &Limits; in-memory from_value, from_value_seed, and to_value conversions do not take limits, and from_reader* bounds reads to at most max_input_bytes + 1 bytes).

Key defaults:

  • Input & output: max_input_bytes = 32 MiB, max_scalar_bytes = 32 MiB, max_output_bytes = 64 MiB, max_tag_expansion_bytes = 64 MiB
  • Depth: max_depth = 128 (also the accepted maximum, MAX_DEPTH_CAP, to keep recursive paths safe on default 2 MiB stacks)
  • Stream & collection counts: max_documents = 10,000 (single-document APIs still reject a second document), max_events = 1,000,000, max_collection_entries = 1,000,000, max_anchors = 100,000, max_alias_dereferences = 100,000
  • Alias expansion: 256 MiB + 16 B per input byte (input term capped at max_input_bytes)

The default count limits are intentionally lower than the 32 MiB input limit to bound memory on untrusted input; use ParseOptions::for_max_input() (or Limits::for_max_input()) for trusted dense documents within max_input_bytes. Exceeding a limit returns ErrorKind::Limit, Error::limit() exposes the exhausted LimitKind, ceiling, and observed value, and Error::masked() redacts document content when logging untrusted input errors.

See Resource limits and the sizing guide for full details and the alias budget formula.

Feature flags

ayaml has no default features (only serde and indexmap runtime dependencies).

Feature Default Purpose
libyaml-compat no Adds the additive ayaml::compat module (compat::from_str*, compat::from_slice*, compat::parse_events*, compat::parse_tape*, compat::parse_owned_tape*, compat::scan_comments*, compat::deserialize_any*), DocumentDeserializer::from_str_compat*, and SpannedTree::parse_compat* (including _with_comments* and *_in; companion crate ayaml-edit also exposes an additive libyaml-compat feature).
bench-internals no Unstable hooks for ayaml's benchmark and conformance harnesses; outside SemVer.

Documentation

Minimum supported Rust version

Rust 1.88. The MSRV is checked in CI against the locked dependency graph. In 1.x, raising the MSRV requires a minor version bump and an explicit release note.

License

Licensed under either of

at your option. See NOTICE for the project notice.