[fidl] Add ordinals to API summaries and reject ABI-breaking changes

This CL adds ordinals to FIDL API summaries for protocol methods and for
table/union/struct members. For structs, the ordinal is the one-based
index of the member, and changing it is API-breaking because C++
bindings allow positional construction. For the rest, changing ordinals
breaks ABI, so fidl_api_diff will report APICompatibleButABIBreaking.

Some context: Before this CL, the summary/diff tooling only detected API
breakages. Ideally we'd analyze both API and ABI separately, but this is
harder to do. Instead, we're taking the simpler approach of ensuring we
also reject the class of changes that break ABI without affecting API.
The logic is conservative, i.e. some safe changes might be rejected but
no breaking change will ever be accepted.

Here is how fidl_api_diff's behavior is changing:

1. API compatible, ABI compatible: Accept
2. API breaking,   ABI breaking:   Reject
3. API compatible, ABI breaking:   Reject (NEW)
4. API breaking,   ABI compatible: Reject

We still lack the ability to distinguish (2) from (4), which means if
someone submits a breaking API change at a future API level (which is
allowed within reason), reviewers must manually check ABI compatibility.

I ran this to confirm .api_summary.json changes were as expected:

    remove_ordinals() { jq --sort-keys --indent 4 'map(del(.ordinal))'; }
    check() { diff <(git show @~:"$1") <(git show @:"$1" | remove_ordinals); }
    export -f remove_ordinals check
    # `sudo apt-get install parallel` to ensure GNU parallel, not moreutils
    git show --pretty="format:" --name-only -- '*.api_summary.json' | parallel check

Test: fx test tools/fidl/lib/apidiff
Fixed: 102427 (encode ABI in summaries)
Bug: 105046 (rename summaries)
Change-Id: I4aef7eed2ba3fceedf1d60053260ab849254f8fa
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/721565
Reviewed-by: Kendal Harland <kjharland@google.com>
API-Review: Adam Barth <abarth@google.com>
Commit-Queue: Mitchell Kember <mkember@google.com>
Reviewed-by: Adam Barth <abarth@google.com>
572 files changed
tree: b3176b25983aa73370cc02e4aea0a5c116ac5bbb
  1. boards/
  2. build/
  3. bundles/
  4. docs/
  5. examples/
  6. products/
  7. scripts/
  8. sdk/
  9. src/
  10. third_party/
  11. tools/
  12. zircon/
  13. .clang-format
  14. .clang-tidy
  15. .editorconfig
  16. .git-blame-ignore-revs
  17. .gitattributes
  18. .gitignore
  19. .gn
  20. .style.yapf
  21. analysis_options.yaml
  22. AUTHORS
  23. BUILD.gn
  24. CODE_OF_CONDUCT.md
  25. CONTRIBUTING.md
  26. LICENSE
  27. OWNERS
  28. PATENTS
  29. pyrightconfig.json
  30. README.md
  31. rustfmt.toml
README.md

Fuchsia

What is Fuchsia?

Fuchsia is an open source, general purpose operating system supporting modern 64-bit Intel and ARM processors.

We expect everyone interacting with our project to respect our code of conduct.

Read more about Fuchsia's principles.

How can I build and run Fuchsia?

See Getting Started.

Where can I learn more about Fuchsia?

See fuchsia.dev.