Skip to content

ADR 0045: Reject duplicate YAML mapping keys

  • Status: Accepted
  • Date: 2026-11-29

Marshal only deserializes YAML, but its previous parser depended on the unmaintained unsafe-libyaml crate. A replacement must preserve the meaning of policy values, including untyped values used in MCP argument constraints.

Use the deserialization-only build of serde-saphyr through a shared marshal-config entry point, including the early env_file read. Use compatibility settings for scalar inference and leave << literal. Reject duplicate mapping keys rather than silently keeping one value in an arbitrary map. Report parse locations without retaining input text in errors.

noyalib-serde-yaml matched the old duplicate-key behavior in the comparison corpus. yaml_serde did too, but retains a backend transpiled from C with unsafe Rust. Preserving last-value-wins would make migration easier for some files but leaves ambiguous policy input.

Existing files that use duplicate mapping keys must be corrected. Parse diagnostics omit rejected values and may be less specific, but cannot echo configuration values through the underlying parser error. Compatibility tests cover policy-sensitive scalars, not every YAML construct.