fix/Add public interface compatibility checks (closes #37) - #173
Merged
El-swaggerito merged 1 commit intoJul 29, 2026
Merged
Conversation
Add check_interface_compatibility, a pure-read entrypoint that lets an SDK/dashboard client verify its required capability keys and schema version against a specific Aegis deployment before integrating, instead of discovering a gap mid-transaction. - src/capabilities.rs: SchemaVersionRelation enum, InterfaceCompatibilityReport struct, check_interface_compatibility() free fn, and the AegisContract::check_interface_compatibility contract entrypoint. Re-derives every answer from the existing supports_capability helper so it can never disagree with get_capabilities / the key registry. No storage writes, no events, no auth required, callable pre-init and while paused. - src/test.rs: 7 tests covering matching/older/newer client schema, aggregation of multiple unsupported required keys, agreement with supports_capability, the empty-requirements case, and the no-mutation / pre-initialize guarantee. - docs/interface-compatibility.md: new contributor doc covering the API, the schema_relation table, and SDK/dashboard usage guidance. - docs/capabilities.md, docs/contract-spec.md, README.md: cross-link the new doc and entrypoint from the existing capability-flag references. No new storage keys, error codes, or auth changes. Purely additive; Cargo.lock/Cargo.toml untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #37
Summary
capabilities.rsalready exposes a versioned capability-flag registry(
get_capabilities,supports_capability,get_capability_keys), but therewas no single call an SDK/dashboard client could make to answer "can I
safely integrate with this deployment?" — clients had to hand-roll the
comparison themselves, or skip it and discover a gap only when a transaction
they assumed would succeed reverts.
This PR adds
check_interface_compatibility: a pure-read entrypoint thattakes a client's schema version and its list of required capability keys,
and returns a precise, actionable report.
This is diagnostic tooling only — it does not gate authorization, and per
the issue's note, protocol-level compatibility is not legal or financial
advice. That caveat is stated explicitly in the new doc.
What changed
src/capabilities.rs(+107 lines, inserted afterget_capability_keys, starting at line 577)SchemaVersionRelationenum:Matching/ClientOlder/ClientNewer, derived from comparingclient_schema_versiontoCAPABILITY_SCHEMA_VERSION.InterfaceCompatibilityReportstruct:contract_schema_version,client_schema_version,schema_relation,unsupported_required: Vec<Symbol>,compatible: bool.check_interface_compatibility()free function. Re-derives every answer by calling the existingsupports_capability()per requested key, so it can never disagree withget_capabilities/ the key registry — no duplicated logic, no second source of truth.AegisContract::check_interface_compatibility(env, client_schema_version, required_capabilities)public contract entrypoint, added to the existingimpl AegisContractblock alongsideget_capabilities,supports_capability,get_capability_keys.Characteristics (matching the existing capability-flag functions): no storage
writes, no events, no authorization required, never panics, callable before
initializeand while paused.src/test.rs(+137 lines: import update + 7 new tests, L4282–L4412)All under the new
// ─── Public interface compatibility checks (#37) ───section:test_interface_compatibility_matching_schema_and_supported_keys_is_compatibleMatching,compatible == truetest_interface_compatibility_older_client_schema_is_still_compatibletest_interface_compatibility_newer_client_schema_flags_gap_when_relevanttest_interface_compatibility_reports_every_unsupported_required_keyUnsupported+Planned) are all aggregated, not just the firsttest_interface_compatibility_empty_requirements_always_compatibletest_interface_compatibility_agrees_with_supports_capabilitysupports_capabilitycall — the two can't silently divergetest_interface_compatibility_never_mutates_and_works_before_initializeinitialize, with no auth, and never mutates statedocs/interface-compatibility.md(new, 122 lines)Full field reference, the
schema_relationdecision table, and SDK/dashboardusage guidance (when to call it, how to build
required_capabilities, how tobranch on
compatiblevs.schema_relation). Explicitly states this is nota permission/compliance check and not legal or financial advice.
docs/capabilities.md(+8 lines)Added a
check_interface_compatibilityentry to the API reference,cross-linking the new doc.
docs/contract-spec.md(+1 line)Added
check_interface_compatibilityto the Read Functions list (line 116),matching the existing entries for
get_capabilities/supports_capability/
get_capability_keys.README.md(+3 lines)Linked the new
docs/interface-compatibility.md, and also linked theexisting (previously unlinked)
docs/capabilities.mdfrom the docs index.No changes to
Cargo.toml/Cargo.lock— purely additive, no newdependencies, no new error codes, no new storage keys.
Traceability mapping
check_interface_compatibilityinsrc/capabilities.rs(L577–714)src/test.rsL4282–4412docs/interface-compatibility.mdsrc/test.rs, cross-checked againstsupports_capabilityREADME.mddocs index,docs/capabilities.md,docs/contract-spec.mdCAPABILITY_SCHEMA_VERSIONandsupports_capabilityas its only data source; no new storage/error surfaceVerification
Ran locally against the full suite on the standard Rust/soroban-sdk 26 toolchain:
cargo test --lib: 187 passed, 0 failed (180 pre-existing + 7 newinterface_compatibilitytests). Baseline before this change: 180 passed, 0 failed.cargo test interface_compatibility -- --nocapture: all 7 new tests pass individually.unused import: AssetStatusChangedEventwarning pre-dates this change and is unrelated.git diff main...HEAD --statconfirms exactly the six files listed above changed — no stray edits.Suggested commands for reviewers