Skip to content

docs: update RecurringAgreementManager doc and refocus on consumer perspective#1348

Draft
RembrandtK wants to merge 3 commits into
mainfrom
rk/ram-doc-fix
Draft

docs: update RecurringAgreementManager doc and refocus on consumer perspective#1348
RembrandtK wants to merge 3 commits into
mainfrom
rk/ram-doc-fix

Conversation

@RembrandtK

Copy link
Copy Markdown
Contributor

The doc had drifted from the contract implementation and talked in terms implementation detail.

This brings it current and reorients it toward integrators/devs (overview + concepts; NatSpec carries the depth).

Doc-only; no code changes.

  • correct interface count (eight) and add IEmergencyRoleControl
  • document minResidualEscrowFactor, residual-drop cleanup, and emergencyRevokeRole
  • fix IAgreementOwner role (collection callbacks; ERC-165 contract-payer), and describe signatureless acceptance via the stored on-chain offer
  • note RAM (Recurring Agreement Manager) is collector-agnostic (Recurring Collector, RC, is the example), and that the fully-funded relation is the Full-basis target, not an invariant
  • add funding-not-guaranteed caveat and AGREEMENT_MANAGER_ROLE over-commit responsibility
  • reframe cleanup table around the single maxNextClaim==0 trigger
  • restructure: lead with public surface, move deep mechanics into Key Concepts

…rspective

- correct interface count (eight) and add IEmergencyRoleControl
- document minResidualEscrowFactor, residual-drop cleanup, and emergencyRevokeRole
- fix IAgreementOwner role (collection callbacks; ERC-165 contract-payer), and
  describe signatureless acceptance via the stored on-chain offer
- note RAM is collector-agnostic (RC is the example), and that the fully-funded
  relation is the Full-basis target, not an invariant
- add funding-not-guaranteed caveat and AGREEMENT_MANAGER_ROLE over-commit responsibility
- reframe cleanup table around the single maxNextClaim==0 trigger
- restructure: lead with public surface, move deep mechanics into Key Concepts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the RecurringAgreementManager (RAM) documentation to better reflect the current contract behavior and present it from an integrator/consumer perspective (with deeper mechanics deferred to NatSpec).

Changes:

  • Reframes RAM as a collector-agnostic contract payer and documents key lifecycle flows (offer/accept/collect/reconcile/cleanup).
  • Expands and clarifies roles, interfaces, and operational caveats (e.g., funding not guaranteed; emergency role revocation; residual escrow cleanup).
  • Reorganizes escrow behavior explanations (configured vs effective basis; degradation thresholds) and adds monitoring/configuration guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/issuance/contracts/agreement/RecurringAgreementManager.md Outdated
If RAM is paused, these callbacks revert (low-level calls, so the collection itself still succeeds) and escrow accounting drifts until RAM is unpaused and reconciled. To fully halt collections, pause `RecurringCollector` too.

Collection flows through `SubgraphService → RecurringCollector → PaymentsEscrow`. RecurringCollector then calls `IAgreementOwner.afterCollection` on the payer, which triggers automatic reconciliation and escrow top-up in the same transaction. Manual reconcile is still available as a fallback.
Reconciliation can also be triggered manually at any time (permissionless):
### Reconciliation
| Agreement State | maxNextClaim |
| --------------------------- | -------------------------------------------------------------------- |
| NotAccepted (pre-offered) | Stored estimate from `offerAgreement` |

- **`cancelAgreement`** — routes cancellation through the collector's `cancel` function (passing the terms hash), then reconciles locally. Cancels un-accepted offers, accepted agreements, or pending updates depending on the `versionHash` provided. Requires AGREEMENT_MANAGER_ROLE.
- **`forceRemoveAgreement`** — operator escape hatch for agreements whose collector is unresponsive (broken upgrade, permanent pause). Zeroes the agreement's maxNextClaim, removes it from pair tracking, and triggers pair reconciliation. Requires OPERATOR_ROLE.
- **`cancelAgreement(collector, agreementId, versionHash, options)`** — routes cancellation through the collector, then reconciles. Depending on `versionHash`, cancels an un-accepted offer, an accepted agreement, or a pending update. Requires `AGREEMENT_MANAGER_ROLE`.
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.16%. Comparing base (21f59f9) to head (d21c3ad).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1348   +/-   ##
=======================================
  Coverage   91.16%   91.16%           
=======================================
  Files          81       81           
  Lines        5319     5319           
  Branches     1128     1128           
=======================================
  Hits         4849     4849           
  Misses        448      448           
  Partials       22       22           
Flag Coverage Δ
unittests 91.16% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Full-basis target sums maxNextClaim over all tracked agreements (not just active)
- note reconcile is blocked while RAM is paused (whenNotPaused)
- maxNextClaim always read from collector getMaxNextClaim (active+pending);
  NotAccepted value is the collector's time-dependent conservative max, not RAM-stored
- cancelAgreement scope is driven by the options bitmask; versionHash matches terms

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread packages/issuance/contracts/agreement/RecurringAgreementManager.md Outdated
Comment thread packages/issuance/contracts/agreement/RecurringAgreementManager.md Outdated
- underfunding: a collection reverts (escrow never partially drawn); a shortfall
  beyond one maxSecondsPerCollection window forfeits uncollected time, under-paying
- pause: collection succeeds only while escrow already covers it; no JIT while paused,
  so an over-escrow collection reverts
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.

2 participants