Model compatibility differences
Compare assembled models without filesystem or network access:
///|
pub fn compare_models(
old_model : @smithy.Model,
new_model : @smithy.Model,
) -> Bool {
let result = @diff.compare(old_model, new_model)
for event in result.events {
println(event.id + ": " + event.message)
}
result.is_breaking()
}Differences::detect exposes added and removed shapes, changed shapes with their trait changes, and metadata changes. Source locations and assembly provenance do not cause differences. Container changes include changes to their member shapes.
compare evaluates the built-in compatibility rules from the pinned Smithy reference, including member targets, constraints, nullability, defaults, entity bindings, trait breaking-change definitions and legacy diff tags. It applies the new model's suppressions and severity overrides, then preview-feature downgrades. The reference's authentication-scheme evaluator currently emits no events.
Events use the shared smithy.ValidationEvent type. events includes suppressed events and has deterministic order by event ID, shape ID, severity and message. is_breaking() is true when an event has ERROR or DANGER severity.
The constraint evaluators preserve two quirks of the pinned reference. They compare @length and @range bounds only when the trait exists in both models; adding either trait uses the generic NOTE event. Both evaluators substitute zero for an absent minimum, including @range. Introducing a nonpositive range minimum therefore produces no constraint ERROR, while removing a negative minimum can produce one. The local constraint-boundary reference cases record these behaviors. is_breaking() follows the reference's event severities.
smithy diff --old old-model.smithy --new new-model.smithy
smithy diff --old old-models/ --new new-models/ --output changes.txtThe CLI assembles each file or directory independently using local resource discovery, including JAR manifests. It prints each unsuppressed difference on one line, escaping message newlines as \n. Breaking changes or invalid models exit with status 1; invalid arguments exit with status 2. Unchanged or compatible models exit with status 0. Git and project comparison modes are not implemented.
The committed reference event manifest is generated by mise run tck:reference:diff. Regeneration requires the pinned upstream source snapshot and a JDK. --check verifies it without rewriting. Normal tests read the committed expectations and require neither Java nor network access.