feat(settlement): add a cross-service agent settlement summary view - #322
Merged
mikewheeleer merged 1 commit intoJul 28, 2026
Merged
Conversation
get_last_settlement (per (agent, service_id)) and get_billing_summary
already exist as read views. Adds AgentSettlementSummary { total_settled,
outstanding_services, last_settlement } and
get_agent_settlement_summary(agent), combining the agent's lifetime
settled total with one bounded pass over their active-service index
(capped at MAX_AGENT_SERVICE_INDEX) to count outstanding services and
find the most recent settlement stamp among currently-indexed services.
Pure read; defaults to zero/None for an unseen agent, never panics.
Caveat documented on the struct: settle() deindexes a service once
drained, so last_settlement only reflects settle_all() sweeps (which do
not deindex) or services still carrying nonzero usage; use
get_last_settlement for the authoritative per-pair timestamp regardless
of index membership.
Adds 4 tests covering: defaults for an unseen agent, outstanding-count
tracking through an individual settle() (which deindexes and drops out
of last_settlement), and last_settlement correctly reflecting a
settle_all() timestamp.
Contributor
|
well done @thlpkee20-wq, this reads well. merging in 🌟 |
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 #298
`get_last_settlement` (per `(agent, service_id)`) and
`get_billing_summary` already exist as read views. Adds
`AgentSettlementSummary { total_settled, outstanding_services,
last_settlement }` and `get_agent_settlement_summary(agent)`, combining
the agent's lifetime settled total with one bounded pass over their
active-service index (capped at `MAX_AGENT_SERVICE_INDEX`) to count
outstanding services and find the most recent settlement stamp among
currently-indexed services. Pure read; defaults to zero/`None` for an
unseen agent, never panics.
Caveat documented on the struct: `settle()` deindexes a service once
drained, so `last_settlement` only reflects `settle_all()` sweeps
(which do not deindex) or services still carrying nonzero usage; use
`get_last_settlement` for the authoritative per-pair timestamp
regardless of index membership. (I initially assumed `last_settlement`
would reflect any settle call and had to correct both the doc comment
and the tests once I hit this — see the test names below.)
Adds 4 tests: defaults for an unseen agent, outstanding-count tracking
through an individual `settle()` (which deindexes and drops out of
`last_settlement`), and `last_settlement` correctly reflecting a
`settle_all()` timestamp.
Test plan
pre-existing, unrelated test covered by fix(test): correct cross-call event-count assumption in ownership-transfer test #315.