Skip to content

docs(storage): document the model and invariants - #428

Merged
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
Jagadeeshftw:docs/storage-01-model
Jul 28, 2026
Merged

docs(storage): document the model and invariants#428
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
Jagadeeshftw:docs/storage-01-model

Conversation

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

Summary

docs/escrow/storage.md describes itself as "the authoritative map of every DataKey variant" but seven variants were missing, and one existing note was inaccurate. This closes those gaps:

  • Documents the previously-missing UsageAlertThreshold, MinServicePrice, MaxServicePrice, PriceTiers, AgentCredit, AgentServiceIndex, AgentServices, and Dispute keys in the reference tables, plus a prose "details" section for each.
  • Invariant gap found and documented: settle never checks the Dispute flag — an open dispute does not actually block settlement, contradicting the source doc-comment on open_dispute which claimed "settle is blocked". Corrected the misleading comment in lib.rs (comment-only, no behavior change) and called this out explicitly in the new Security notes bullets.
  • Dead key found and documented: AgentServices(Address) is declared but never read or written anywhere in lib.rs, despite a comment describing it as the key settle_all uses — settle_all actually reads AgentServiceIndex. Documented as unused/dead storage.
  • Unreachable feature found and documented: UsageAlertThreshold has no setter, so the usage_hi alert path in record_usage can never fire on the current contract.

No contract behavior changes — this is a docs-and-comment-only PR (the one lib.rs change corrects a comment to match actual settle behavior).

Closes #286

Validation

  • cargo fmt --all -- --check
  • cargo build -p escrow
  • cargo test -p escrow — 352 passed, 1 pre-existing failure unrelated to this change (test_transfer_service_ownership_genuine_transfer_emits_event, fails identically on main)

env.events().all() reflects only the most recent contract invocation, not
a running total across separate calls (consistent with every other event
test in this file). The test compared post-transfer event count against a
pre-transfer count captured after a *different* call (set_service_metadata),
expecting accumulation that never happens, so it failed on every run
regardless of contract behavior. Fixed to assert directly on this call's
own event count.
@Jagadeeshftw
Jagadeeshftw force-pushed the docs/storage-01-model branch from 877f9d6 to 3a20d4e Compare July 28, 2026 21:18
@mikewheeleer
mikewheeleer merged commit c177d7d into Agentpay-Org:main Jul 28, 2026
1 check passed
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.

Document the storage model and its invariants

2 participants