Add treasury reserve capacity status#625
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR computes treasury reserve metrics from recent ledger entries and pending create-bounty proposals via ChangesTreasury Status Reporting
Possibly related PRs
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
Maintainer note: this PR is intended as the first operational step after the treasury proposal changes, not as a cap-policy change. The path I suggest is:
This PR is a maintainer PR and has no bounty request. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 0119e1b1-abc8-4742-8672-693d512816b0
📒 Files selected for processing (9)
app/admin.pyapp/templates/admin.htmlapp/treasury.pyapp/treasury_routes.pydocs/admin-runbook.mddocs/agent-guide.mddocs/api-examples.mdtests/test_security.pytests/test_treasury_proposals.py
…apacity-visibility # Conflicts: # tests/test_treasury_proposals.py
Thanhdn1984
left a comment
There was a problem hiding this comment.
Review of PR #625: Add treasury reserve capacity status
Head commit: checked against current HEAD
CI: all checks pass (Quality/readiness/docs/image checks ✅, CodeRabbit review skipped)
Merge state: clean
Files inspected (9 files, +279/-4)
-
app/treasury.py(+66): New_recent_bounty_reserve_entries()andtreasury_status()functions._recent_bounty_reserve_entriescorrectly filters bybounty_reserveentry type, treasury account, and 24h window with proper ordering.treasury_status()aggregates executed reserves, pending create-bounty proposals, available capacity, and next capacity release time.max(... , 0)correctly floors available capacity at zero.min(release_times)returns the soonest upcoming release — correct.- Edge case:
replace(tzinfo=None)in tests suggests DB stores naive UTC; the code handles this consistently.
-
app/treasury_routes.py(+6): NewGET /api/v1/treasury/statusendpoint — clean, usessession_scopeproperly, returns dict directly (FastAPI JSON serialization). -
app/admin.py(+1/-1): Addstreasury_statusto admin page context — minimal, clean import. -
app/templates/admin.html(+51): Treasury reserve capacity section with semantic HTML,aria-label, conditional rendering for pending proposals table. Proper use of{% if %}guards. -
tests/test_treasury_proposals.py(+131): Two thorough tests:test_treasury_status_includes_recent_reserves_and_pending_proposals: verifies cap, executed, pending, available, next release, and pending bounty list.test_treasury_status_includes_reserve_at_exact_24h_boundary: boundary condition — entry at exactly 24h ago is included butnext_capacity_release_atisNone(correct, since it expires atnow).
-
tests/test_security.py(+6/-1): Updated admin page assertions to verify treasury section renders, and tightened regex for webhook summaryaria-labeldisambiguation. -
docs/(+13/-1): Updated agent-guide, api-examples, and admin-runbook with new endpoint documentation.
Findings
- No security issues: endpoint is read-only, no auth required (consistent with other public treasury endpoints).
- No conflicts with active maintainer branches observed.
- Code quality: consistent with existing patterns, proper type annotations, clean separation of concerns.
- Minor observation:
_pending_action_payloadsis reused — good code reuse rather than duplicating query logic.
LGTM. Clean, well-tested feature addition.
|
Reviewed for #578 at current head
So the operator can be told that nothing is limiting create capacity even though pending proposals are the limiter. This needs either a distinct pending-proposal blocking message in |
|
Addressed the pending-create capacity wording finding in The admin page now explicitly says pending create-bounty proposals are using current create-bounty capacity when Validation:
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: b6811479-8733-4a25-8cd4-40c98da0d6c4
📒 Files selected for processing (2)
app/templates/admin.htmltests/test_security.py
|
Addressed CodeRabbit's test nit in Validation:
|
yui-stingray
left a comment
There was a problem hiding this comment.
Reviewed current head ac3ada26072bb41b5d6ec932103d42ade7f78df2.
I approve this after checking the latest follow-up commits. The current implementation keeps treasury reserve capacity visibility read-only and consistent across the API and admin UI:
treasury_status()reports the 24-hour cap, executed reserves, pending create-bounty reserves, remaining create capacity, next release time, and pending create proposals without changing the reserve policy.- The latest admin wording fix correctly avoids saying there are no recent reserve entries when pending create-bounty proposals are what consume the remaining create capacity.
- The final test adjustment scopes the
0 MRWKassertion to theAvailable create reservecard, which avoids a brittle page-wide match.
Evidence checked: app/treasury.py, app/treasury_routes.py, app/templates/admin.html, tests/test_treasury_proposals.py, tests/test_security.py, the docs updates, current head SHA above, mergeable metadata, and hosted Quality, readiness, docs, and image checks reporting success. An independent read-only reviewer also ran targeted tests for the touched treasury/admin paths and reported 93 passed.
chinook1001
left a comment
There was a problem hiding this comment.
Reviewed current head ac3ada26072bb41b5d6ec932103d42ade7f78df2.
Evidence checked:
- Inspected
app/treasury.py,app/treasury_routes.py,app/admin.py,app/templates/admin.html,tests/test_treasury_proposals.py,tests/test_security.py, and the docs touched by this PR. - Verified
treasury_status()uses the same recentbounty_reservewindow as the cap enforcement path, includes pendingcreate_bountyproposal reserves, floors available capacity at zero, and reports the next release only for reserve entries that still constrain the current 24h window. - Verified the admin UI now distinguishes the pending-create-capacity case from the no-recent-reserve case, so operators are not told that nothing is limiting capacity when pending create proposals consume the remaining cap.
- Checked PR metadata: current head matches the commit above, PR is mergeable/clean, and hosted
Quality, readiness, docs, and image checksis green.
Local validation run from a fresh checkout of the PR head:
./.venv/bin/python -m pytest tests/test_treasury_proposals.py tests/test_security.py -q-> 88 passed, 1 Starlette/httpx deprecation warning./.venv/bin/python -m ruff check app/treasury.py app/treasury_routes.py app/admin.py tests/test_treasury_proposals.py tests/test_security.py-> passed./.venv/bin/python -m ruff format --check app/treasury.py app/treasury_routes.py app/admin.py tests/test_treasury_proposals.py tests/test_security.py-> already formattedgit diff --check origin/main...HEAD-> clean
Verdict: APPROVE. The change is read-only/status-focused, tested at the treasury/API/admin surfaces, and the latest wording fix addresses the pending-create capacity ambiguity without changing cap policy.
Summary
Adds read-only treasury reserve capacity visibility for maintainers and agents:
GET /api/v1/treasury/status/admintreasury reserve capacity panel with pending create-bounty proposalsThis is a maintainer PR. I am not claiming or requesting a bounty for it.
Why
Fresh bounty rounds are now proposal-gated and reserve-capped. Maintainers need to see the rolling 24h reserve cap, executed reserves, pending create-bounty reserve, remaining create capacity, and next release time before deciding whether to open or wait on new rounds.
Validation
./.venv/bin/python -m pytest(483 passed)./.venv/bin/python -m ruff format --check ../.venv/bin/python -m ruff check ../.venv/bin/python -m mypy app./.venv/bin/python scripts/docs_smoke.pySummary by CodeRabbit
New Features
Documentation
Tests