Skip to content

#19 add contract public api and compatibility policy fix - #181

Open
onakijames-droid wants to merge 2 commits into
Axionvera:mainfrom
onakijames-droid:#19--Add-contract-public-API-and-compatibility-policy-FIX
Open

#19 add contract public api and compatibility policy fix#181
onakijames-droid wants to merge 2 commits into
Axionvera:mainfrom
onakijames-droid:#19--Add-contract-public-API-and-compatibility-policy-FIX

Conversation

@onakijames-droid

Copy link
Copy Markdown

CLOSED #19 add contract public api and compatibility policy
Description
Adds a canonical public API and compatibility policy for Aegis contracts so
contract, SDK, dashboard, and indexer consumers have one stable integration
reference.

The change:

  • Adds docs/public-api.md, documenting all five contract entry points:
    initialize, whitelist_user, mint_asset, transfer, and
    distribute_yield.
  • Documents ordered inputs, Soroban types, () outputs, authorization,
    preconditions, success effects, failure conditions, events, and storage
    implications for each entry point.
  • Classifies supported surfaces as Stable, Experimental, or Internal.
    distribute_yield/YieldDistributed are explicitly experimental because the
    current implementation emits an indexing signal but does not distribute or
    escrow assets.
  • Defines function, error, event, storage, state-migration, and deployment
    breaking-change categories.
  • Defines pre-1.0 and post-1.0 versioning, deprecation, review, migration, and
    downstream-approval requirements.
  • Defines SDK and dashboard/indexer expectations, including exact i128
    handling, auth responsibilities, unknown-event handling, idempotent replay,
    and the prohibition on depending on raw storage or panic strings.
  • Updates README.md, CONTRIBUTING.md, and docs/contract-spec.md to link to
    the canonical policy.
  • Adds tests/public_api_policy.rs with documentation-contract tests that fail
    when an exported entry point/event or required policy area is not represented
    in the reference.
  • Relocates the pre-existing monitoring project from .github/monitoring/ to
    the monitoring/ path already expected by the README and Makefile. It also
    normalizes analytics/index.js casing and renames store.tests.js to
    store.test.js, fixing case-sensitive imports and ensuring the existing store
    tests are discovered.
  • Adds generated test_snapshots/ to .gitignore.

No contract entry-point signature, authorization rule, storage value, accounting
behavior, or event wire format is changed by this PR.

Key files

File Change
docs/public-api.md New normative public API and compatibility policy.
tests/public_api_policy.rs New API/documentation drift guards.
README.md Adds the public API and compatibility entry point.
CONTRIBUTING.md Adds API-affecting change review requirements.
docs/contract-spec.md Becomes a concise index into the canonical policy.
.gitignore Ignores generated test_snapshots/.
monitoring/** Relocated from .github/monitoring/**; filename casing/test-discovery corrections only.

Related Issues

Fixes “Create a public API and compatibility policy for Aegis contracts.”

The source request did not include a GitHub issue number or issue URL. Replace
this text with Fixes #<issue-number> before opening the PR if one is
available.

Completion Table

Acceptance Criterion Status Implementation Evidence Test Evidence Documentation Impact
AC 1: Public API reference is added. Complete docs/public-api.md is the normative reference for every current #[contractimpl] entry point and contract event. docs/contract-spec.md provides a concise index. every_contract_entrypoint_has_a_public_reference; every_contract_event_has_a_wire_format_reference in tests/public_api_policy.rs. Added docs/public-api.md; updated docs/contract-spec.md.
AC 2: Inputs and outputs are documented. Complete Each function section records its SDK signature, ordered input names/types/rules, auth requirements, () output, and success effects. Calling conventions explain that Rust Env is host-supplied and not an SDK input. every_contract_entrypoint_has_a_public_reference verifies all five exported methods have canonical sections; existing contract tests validate their runtime behavior. Added the Calling Conventions and Public Function Reference sections in docs/public-api.md.
AC 3: Errors and events are referenced. Complete The policy documents the untyped assertion/host-error model, every current explicit failure, exact diagnostic references, and all five event topic/data layouts and statuses. current_explicit_failures_are_referenced; every_contract_event_has_a_wire_format_reference; existing event-XDR/topic/data tests in src/test.rs; monitoring on-chain compatibility tests. Added Error Model and Failure Reference and Event Reference sections in docs/public-api.md.
AC 4: Breaking-change categories are defined. Complete Defines stable/experimental/internal surfaces and breaking categories for function ABI, authorization, errors, events, accounting, storage/state migrations, and deployments. Includes SemVer and deprecation rules. policy_covers_required_compatibility_areas requires stability, breaking-change, versioning, and review sections. Added Stability Classification, Breaking-Change Categories, Versioning and Deprecation, and Change Review Requirements sections.
AC 5: SDK and dashboard expectations are documented. Complete Defines binding generation/pinning, exact i128 handling, auth construction, error handling, event dispatch, unknown-event tolerance, finality, replay/idempotency, and experimental-yield presentation requirements. policy_covers_required_compatibility_areas requires both consumer sections; 106 monitoring tests validate event decoding and dashboard/indexer compatibility. Added SDK Expectations and Dashboard and Indexer Expectations sections in docs/public-api.md.
AC 6: README links to the API policy. Complete README.md contains a dedicated Public API and Compatibility section linking to docs/public-api.md and docs/contract-spec.md. repository_guidance_links_to_the_canonical_policy checks README, contributor guidance, and contract-spec links. Local Markdown link validation also passed. Updated README.md and CONTRIBUTING.md.

All acceptance criteria are complete; no follow-up acceptance work is required.

Detailed Traceability Mapping

Acceptance Criteria Implementation Storage & State Changes Events Emitted Test Coverage Security/Safety Controls
AC 1: Public API reference Canonical reference plus contract-spec index for five functions and five events. No state change. Existing instance/persistent layout and migration implications are documented. No new events. Existing event surface is referenced. Entrypoint and event documentation drift tests. Makes auth, uninitialized-state, and upgrade assumptions reviewable.
AC 2: Inputs and outputs Per-function SDK signatures, ordered arguments, types, validation, auth, void output, and effects. No state change. Per-function write/read matrix documents existing behavior. No new events. Existing per-call event cardinality is documented. Entrypoint coverage test plus existing lifecycle/failure tests. Explicitly documents unauthenticated initialize, required signer addresses, positive amounts, whitelist checks, and exact integer handling.
AC 3: Errors and events Failure table distinguishes assertion diagnostics from Soroban host errors; event sections define exact topics and positional data. No state change. Archived/missing storage behavior is documented as a host/trap risk. No new events or wire-format changes. Init, WhitelistAdd, Mint, Transfer, and YieldDistributed are documented. Explicit-failure reference test, event-reference test, Rust event tests, and monitoring XDR compatibility tests. Prohibits machine parsing of panic strings and requires successful finalized transactions before processing events.
AC 4: Breaking changes Stable/experimental/internal policy; function, error, event, state, and deployment categories; SemVer/deprecation/review process. No state change. Storage encoding/class changes require tested migration and rollback plans. No new events. Event topic/data/cardinality changes are explicitly breaking for stable events. Required-policy-section drift test; formatting, lint, build, and full-suite validation. Requires contract, SDK, and dashboard/indexer review for stable/event changes and explicit rollout/rollback planning.
AC 5: Consumer expectations SDK and dashboard/indexer integration rules, release pinning, precision, auth, error, event, replay, and migration requirements. No state change. Raw storage reads are unsupported; projections must come from finalized events or future public getters. No new events. Consumers must validate known layouts and ignore unknown actions safely. Required-policy-section test and 106 monitoring tests covering decoders, replay, analytics, alerts, and dashboard paths. Requires exact i128 math, contract-ID filtering, finality, duplicate handling, and non-settlement labeling for experimental yield events.
AC 6: README link Dedicated README section and contributor/spec links to the canonical policy. N/A — navigation/documentation-only change. N/A — no event effect. Repository policy-link test and local Markdown link validation. Prevents contributors and consumers from relying on undocumented assumptions.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Chore (refactoring, build tools, etc.)

PR Evidence Checklist

Before opening this PR, complete every applicable item in the evidence
checklist below.

1. Issue Reference

  • The PR description links to the issue being addressed (e.g. Fixes #123).

The issue title is recorded above, but the source request did not provide an
issue number or issue URL. Add it before opening the PR.

2. Implementation Summary

  • A concise summary of what was implemented, changed, or fixed is provided
    above in the Description section.
  • Key files modified are listed with brief descriptions of each change.
  • New public functions, events, error codes, or roles are documented.

No new function/event/error/role was introduced; all existing public functions,
events, and failure behavior are now documented.

3. Tests Added or Justification

  • New or updated tests cover the change (happy path + failure paths).
  • Test names and locations are listed (e.g. test_mint_ok in
    src/test.rs:L45-60).
  • OR a No-Test Justification is provided and explicitly approved.

New tests in tests/public_api_policy.rs:

  • every_contract_entrypoint_has_a_public_reference
  • every_contract_event_has_a_wire_format_reference
  • policy_covers_required_compatibility_areas
  • current_explicit_failures_are_referenced
  • repository_guidance_links_to_the_canonical_policy

Existing happy-path, failure-path, state, and exact event encoding tests remain
unchanged and pass in src/test.rs.

4. Commands Run

  • make verify passes locally.
  • Relevant command output is included in Additional Context below.

make verify is not defined by the repository's current Makefile. Equivalent
and stricter available checks were run individually: formatting, Clippy with
warnings denied, all Rust/monitoring tests, and the release WASM build.

5. CI Status

  • All GitHub Actions checks pass (green) on the PR branch.
  • If CI is failing, a clear explanation and link to the follow-up issue is
    provided.

CI cannot be observed until the branch is pushed and a PR is opened. Local
checks are green.

6. Acceptance Criteria Coverage

  • Every acceptance criterion from the issue is addressed in the Completion
    Table above.
  • Documentation impact is recorded for every criterion, including an
    explicit N/A with a reason when no documentation changes are needed.
  • Incomplete criteria include a rationale and, where applicable, a link to a
    follow-up issue.

There are no incomplete acceptance criteria.

Policy & Standards

  • I have read the Contributor Evaluation Policy and understand that merge
    does not guarantee payment
    .
  • I have read the CONTRIBUTING.md guidelines.
  • My code follows the Rust and Soroban formatting standards (ran cargo fmt).
  • My changes generate no new warnings (ran cargo clippy).
  • I have added/updated tests for the new logic, and all tests pass (ran
    cargo test).
  • Traceability Mapping: I have filled out the detailed mapping table for
    any storage, event, or security changes.
  • Reviewer Guidance: I have reviewed my own changes against the Reviewer
    Checklist.
  • Compliance & Legal Check: I have verified that any new documentation
    or features do not imply regulatory completeness beyond smart contract
    enforcement, as per the Legal Boundary Disclaimer.

The referenced Contributor Evaluation Policy, Reviewer Checklist, and Legal
Boundary Disclaimer files are not present in this checkout, so those attestations
are intentionally left unchecked for the PR author to complete after reviewing
the canonical repository documents. The new policy itself does not claim legal
or regulatory completeness.

Additional Context

Validation results

$ make test-all
Rust contract tests:        9 passed, 0 failed, 1 intentionally ignored
Public API policy tests:    5 passed, 0 failed
Monitoring/dashboard tests: 106 passed, 0 failed
Total executed:             120 passed, 0 failed

$ cargo fmt --all -- --check
PASS

$ cargo clippy --all-targets -- -D warnings
PASS (0 warnings)

$ make build
Build successful. WASM located at:
target/wasm32v1-none/release/aegis_contracts.wasm

WASM SHA-256:
c1ae3186984a151e2853d5da3f7510767e466350e19c1b009ad0369c86537666

Local Markdown file-link validation: PASS
git diff --check:                  PASS

The ignored Rust test is dump_event_xdr, an intentional fixture-generation
utility that is only run manually with --ignored --nocapture.

Compatibility statement

This PR changes documentation, documentation validation, and repository layout
for the already-existing monitoring service. It does not change deployed
contract behavior, public function signatures, auth requirements, ledger state,
or event encoding.

@El-swaggerito

Copy link
Copy Markdown
Contributor
\nThis PR is currently blocked by merge conflicts.\n\nPlease update the branch with the latest main branch and resolve the conflicts before it can be merged.

@El-swaggerito

Copy link
Copy Markdown
Contributor
\nGitHub has not finished calculating whether this PR can be merged cleanly.\n\nThe auto-merge automation will skip this PR for now. Re-run the automation later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add contract public API and compatibility policy

2 participants