Skip to content

Bounty #427: Add ledger row limit controls#490

Open
akmhatey-ai wants to merge 3 commits into
ramimbo:mainfrom
akmhatey-ai:codex/ledger-limit-controls-427
Open

Bounty #427: Add ledger row limit controls#490
akmhatey-ai wants to merge 3 commits into
ramimbo:mainfrom
akmhatey-ai:codex/ledger-limit-controls-427

Conversation

@akmhatey-ai
Copy link
Copy Markdown
Contributor

@akmhatey-ai akmhatey-ai commented May 27, 2026

Bounty #427

Summary

  • Add row-count controls to the public /ledger page so contributors can choose how many recent ledger entries to inspect.
  • Reuse the existing /api/v1/ledger limit bounds and link the rendered page to the matching JSON response.
  • Preserve non-standard valid limits by adding the current limit to the selector when needed.

Before / After

  • Before: /ledger rendered the default recent ledger window with no page-level way to inspect a smaller or larger recent set.
  • After: /ledger?limit=N shows the number of rendered entries, offers common row limits, rejects out-of-range limits through the existing FastAPI 1..200 validation, and links to /api/v1/ledger?limit=N.
  • Screenshot evidence was captured locally from /ledger?limit=25 in the Money workspace receipt; I did not commit the binary screenshot into this repository.

Duplicate / Scope Notes

Validation

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_api_mcp.py::test_ledger_api_rejects_out_of_range_limits tests/test_api_mcp.py::test_ledger_page_exposes_limit_controls tests/test_api_mcp.py::test_ledger_page_highlights_bounty_payment_and_release tests/test_api_mcp.py::test_ledger_page_uses_wrapping_entry_cards -q -> 6 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 415 passed
  • uv run --extra dev ruff check app tests -> passed
  • uv run --extra dev ruff format --check app tests -> 67 files already formatted
  • uv run --extra dev python -m mypy app -> success
  • uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check -> exit 0; Git only printed Windows LF-to-CRLF working-copy warnings
  • git diff | gitleaks stdin --redact --no-banner --no-color -> no leaks found

Limitations

  • This PR does not change ledger ordering or the API response schema.
  • The local screenshot was kept out of the repo to avoid adding a binary proof artifact to source control.
  • No wallet material, private keys, cookies, OAuth state, access tokens, signatures, private vulnerability details, deployment credentials, price claims, liquidity claims, exchange claims, or fabricated payout claims are included.

Summary by CodeRabbit

  • New Features

    • Ledger page now includes pagination controls with a dropdown to set how many entries are shown and accepts a limit via query parameter.
  • Style

    • Added styling for a ledger toolbar and its controls.
  • Tests

    • Added tests verifying limit controls, selection behavior, pagination links, JSON link presence, and validation of allowed limits.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 48b729cc-e779-4ff1-9bac-41fc0b7a2537

📥 Commits

Reviewing files that changed from the base of the PR and between 82f18c3 and 4a64000.

📒 Files selected for processing (4)
  • app/public_routes.py
  • app/static/style.css
  • app/templates/ledger.html
  • tests/test_api_mcp.py

📝 Walkthrough

Walkthrough

The PR adds ledger page pagination via a validated limit query parameter. LEDGER_LIMIT_OPTIONS and ledger_page_context() compute and expose selectable limits. The /ledger endpoint now accepts limit, calls api_ledger(limit), and renders the template. A toolbar UI and CSS were added, and tests verify valid/invalid limits.

Changes

Ledger pagination feature

Layer / File(s) Summary
Limit options and context helper
app/public_routes.py
LEDGER_LIMIT_OPTIONS constant and ledger_page_context() package entries with the current limit and compute the sorted set of limit options for the dropdown; Annotated imported for query typing.
Ledger endpoint with limit parameter
app/public_routes.py
api_ledger dependency signature changes to accept int limit; /ledger validates limit (ge=1, le=200), calls api_ledger(limit), and renders via ledger_page_context().
Ledger toolbar UI and CSS
app/templates/ledger.html, app/static/style.css
Template adds a toolbar showing entry count, a limit dropdown, Update button, and JSON link. CSS adds .ledger-toolbar rules and styles nested form controls.
Test coverage for limit controls
tests/test_api_mcp.py
Imports add_ledger_entry and adds test_ledger_page_exposes_limit_controls() which seeds entries and asserts dropdown selection, pagination links, JSON link, and HTTP 422 for out-of-range limits.

Possibly related PRs

  • ramimbo/mergework#366: Adds limit-aware ledger fetching via recent_ledger_entries used by ledger endpoints.
  • ramimbo/mergework#394: Refactors /ledger wiring and the api_ledger callable signature that this change builds on.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed Title is specific and directly names the surface changed: ledger row limit controls, aligning with the primary change.
Description check ✅ Passed Description covers summary, before/after, duplicate scope notes, validation results, and limitations; template structure mostly followed with test evidence checkboxes present.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Mergework Public Artifact Hygiene ✅ Passed PR contains only UX/UI code and tests for ledger pagination. No investment claims, price claims, cash-out claims, payout fabrications, or private security details found in added content.
Bounty Pr Focus ✅ Passed PR references Bounty #427; diff matches stated files with limit controls, validation, and focused test coverage without unrelated scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@Thanhdn1984
Copy link
Copy Markdown

Reviewed PR #490 against bounty #427. Evidence: inspected app/public_routes.py, app/templates/ledger.html, app/static/style.css, and existing/new ledger tests in tests/test_api_mcp.py around /ledger?limit=. Diff adds bounded FastAPI Query(ge=1, le=200), propagates the selected limit into api_ledger(limit), exposes stable 25/50/100/200 options plus custom valid limits, and links the matching JSON endpoint. This is a useful focused UX improvement for scanning the ledger/explorer.

Local verification note: I attempted focused pytest runs, but the local checkout currently reports found no collectors for direct node ids even though the test functions are present; broad run also showed a mistaken local path for tests/test_public_pages.py from my first command. So I treated this as static review + test inspection, not passing local test proof.

Minor non-blocking suggestion: consider adding an aria-live/status copy only if future updates become async. For current full-page form submit, the implementation looks coherent.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: da651210-f202-4275-bd93-af61a942e2bc

📥 Commits

Reviewing files that changed from the base of the PR and between d8532d4 and 307cb15.

📒 Files selected for processing (4)
  • app/public_routes.py
  • app/static/style.css
  • app/templates/ledger.html
  • tests/test_api_mcp.py

Comment thread app/static/style.css
Comment thread tests/test_api_mcp.py
Copy link
Copy Markdown
Contributor

@GHX5T-SOL GHX5T-SOL left a comment

Choose a reason for hiding this comment

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

I reviewed current head 307cb1582c9b9388caa8ef34256f3152be05badf and I think this needs two small fixes before merge.

  1. app/static/style.css: the new .ledger-toolbar button rule does not override the later global input, textarea, button { width: 100%; }, so the toolbar submit button inherits full width instead of staying inline with the select and JSON link. Add an explicit toolbar override such as width: auto or scope the global form-button rule away from the toolbar.

  2. tests/test_api_mcp.py: the page route is capped at limit <= 200, but the new regression only asserts the lower rejection case (limit=0). Please add an upper-bound assertion for /ledger?limit=201 so the UI/page contract is pinned on both sides of the accepted range.

Validation I ran on this head:

  • MERGEWORK_DATABASE_URL=sqlite:////tmp/mergework-pr490-test.sqlite3 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_api_mcp.py::test_ledger_page_exposes_limit_controls tests/test_api_mcp.py::test_ledger_api_rejects_out_of_range_limits -q -> 4 passed
  • MERGEWORK_DATABASE_URL=sqlite:////tmp/mergework-pr490-test2.sqlite3 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_api_mcp.py -q -> 77 passed
  • MERGEWORK_DATABASE_URL=sqlite:////tmp/mergework-pr490-full.sqlite3 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 415 passed
  • uv run --extra dev ruff check app/public_routes.py tests/test_api_mcp.py -> passed
  • uv run --extra dev ruff format --check app/public_routes.py tests/test_api_mcp.py -> already formatted
  • uv run --extra dev python -m mypy app -> success
  • uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check origin/main...HEAD -> clean
  • gitleaks detect --no-banner --redact --source . --log-opts origin/main..HEAD --exit-code 1 -> no leaks found

No secrets or private data were used.

@akmhatey-ai
Copy link
Copy Markdown
Contributor Author

Pushed follow-up 82f18c324206d62008495bc52ba2f30326b48006 for the current review notes.

Changes:

  • keep the ledger toolbar submit button inline by overriding the inherited full-width button rule
  • add /ledger?limit=201 page-route rejection coverage next to the lower-bound check

Validation:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_api_mcp.py -q -> 77 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 415 passed
  • uv run --extra dev ruff check . -> passed
  • uv run --extra dev ruff format --check . -> 79 files already formatted
  • uv run --extra dev python -m mypy app -> success
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check origin/main...HEAD -> clean
  • staged diff gitleaks scan -> no leaks

Post-push GitHub CI and CodeRabbit are still pending at readback.

@tinyopsstudio
Copy link
Copy Markdown

Current-head review for PR #490 at 82f18c324206d62008495bc52ba2f30326b48006.

I reviewed the ledger limit controls after the follow-up commit. The two issues called out in the earlier stale-head review appear addressed: .ledger-toolbar button { width: auto; } prevents the toolbar submit button from inheriting the later full-width global button rule, and the regression test now covers both lower and upper FastAPI bounds with /ledger?limit=0 and /ledger?limit=201.

Files inspected: app/public_routes.py, app/templates/ledger.html, app/static/style.css, and tests/test_api_mcp.py. The public page route now delegates to the existing validated /api/v1/ledger limit path, carries non-standard valid values like 10 into the selector, and links the rendered view to the matching JSON endpoint.

Validation I ran locally:

  • .venv/bin/python -m pytest tests/test_api_mcp.py::test_ledger_page_exposes_limit_controls tests/test_api_mcp.py::test_ledger_page_highlights_bounty_payment_and_release tests/test_api_mcp.py::test_ledger_page_uses_wrapping_entry_cards -q -> 3 passed
  • .venv/bin/python -m pytest tests/test_api_mcp.py tests/test_docs_public_urls.py -q -> 100 passed
  • .venv/bin/python -m ruff check app/public_routes.py tests/test_api_mcp.py -> passed
  • .venv/bin/python -m ruff format --check app/public_routes.py tests/test_api_mcp.py -> 2 files already formatted
  • .venv/bin/python -m mypy app -> success
  • .venv/bin/python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check d8532d4d909f47c689d3b88eb21461243097673f...HEAD -> clean

Assessment: this is a useful #427 site/workflow improvement. It is small, test-backed, reuses the existing API limit contract, and makes the public ledger easier to inspect without widening the API surface or adding MRWK price/liquidity claims.

Copy link
Copy Markdown
Contributor

@jtc268 jtc268 left a comment

Choose a reason for hiding this comment

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

Reviewed current head 82f18c324206d62008495bc52ba2f30326b48006.

The earlier change-request items are addressed: .ledger-toolbar button { width: auto; } overrides the global full-width button rule, and the regression now checks /ledger?limit=201 as well as the lower bound. I also checked that /ledger passes the bounded limit through to api_ledger(limit) and that the JSON link preserves the selected limit.

Validation:

  • ../mergework/.venv/bin/python -m pytest tests/test_api_mcp.py::test_ledger_page_exposes_limit_controls tests/test_api_mcp.py::test_ledger_page_highlights_bounty_payment_and_release tests/test_api_mcp.py::test_ledger_page_uses_wrapping_entry_cards -q -> 3 passed
  • ../mergework/.venv/bin/python -m pytest tests/test_api_mcp.py -q -> 77 passed
  • ../mergework/.venv/bin/python -m ruff check app/public_routes.py tests/test_api_mcp.py -> passed
  • ../mergework/.venv/bin/python -m ruff format --check app/public_routes.py tests/test_api_mcp.py -> 2 files already formatted
  • ../mergework/.venv/bin/python -m mypy app/public_routes.py -> success
  • ../mergework/.venv/bin/python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check -> clean

Approving.

Copy link
Copy Markdown

@eliasx45 eliasx45 left a comment

Choose a reason for hiding this comment

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

Reviewed current head 82f18c3 against refreshed origin/main.

Verdict: request changes.

The ledger limit implementation itself still validates locally: the page exposes bounded row controls, preserves custom valid limits, links to the matching JSON endpoint, and the prior toolbar width / upper-bound test follow-up is present. However, the branch is no longer merge-ready against current main because merge-tree reports a content conflict in app/public_routes.py.

Validation on this head:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ..venv\Scripts\python.exe -m pytest tests\test_api_mcp.py::test_ledger_page_exposes_limit_controls tests\test_api_mcp.py::test_ledger_api_rejects_out_of_range_limits tests\test_api_mcp.py::test_ledger_page_highlights_bounty_payment_and_release tests\test_api_mcp.py::test_ledger_page_uses_wrapping_entry_cards -q -> 6 passed
  • ..venv\Scripts\python.exe -m ruff check app\public_routes.py tests\test_api_mcp.py -> passed
  • ..venv\Scripts\python.exe -m ruff format --check app\public_routes.py tests\test_api_mcp.py -> 2 files already formatted
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ..venv\Scripts\python.exe scripts\docs_smoke.py -> docs smoke ok
  • git diff --check origin/main...HEAD -> clean
  • git merge-tree --write-tree origin/main HEAD -> conflict in app/public_routes.py

Required follow-up: rebase/merge current main and resolve app/public_routes.py, then rerun the focused ledger tests. I do not see a feature-level blocker beyond the stale/conflicting base.

Copy link
Copy Markdown

@eliasx45 eliasx45 left a comment

Choose a reason for hiding this comment

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

Re-reviewed current head 4a64000f86432740a7e35aeeade9adbb5959395f after the upstream merge.

Verdict: approve.

The prior merge-readiness blocker is resolved: git merge-tree --write-tree origin/main HEAD now succeeds. The ledger row-limit feature still looks focused and useful: /ledger accepts the bounded limit query, passes it through to the existing ledger API path, exposes common row-count options plus custom valid limits, keeps the JSON link in sync, and includes the toolbar width / upper-bound regression follow-up.

Validation:

  • git diff --check origin/main...HEAD -> clean.
  • git merge-tree --write-tree origin/main HEAD -> 82102aec3f1d189d0eede233df45b4407c64bc69.
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ..\mergework\.venv\Scripts\python.exe -m pytest tests\test_api_mcp.py::test_ledger_page_exposes_limit_controls tests\test_api_mcp.py::test_ledger_api_rejects_out_of_range_limits tests\test_api_mcp.py::test_ledger_page_highlights_bounty_payment_and_release tests\test_api_mcp.py::test_ledger_page_uses_wrapping_entry_cards -q --tb=short -> 6 passed.
  • ..\mergework\.venv\Scripts\python.exe -m ruff check app\public_routes.py tests\test_api_mcp.py -> passed.
  • ..\mergework\.venv\Scripts\python.exe -m ruff format --check app\public_routes.py tests\test_api_mcp.py -> 2 files already formatted.
  • ..\mergework\.venv\Scripts\python.exe -m mypy app\public_routes.py -> success.
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ..\mergework\.venv\Scripts\python.exe scripts\docs_smoke.py -> docs smoke ok.
  • GitHub CI Quality, readiness, docs, and image checks is green at readback.

I do not see a remaining blocker.

@akmhatey-ai
Copy link
Copy Markdown
Contributor Author

Pushed 4a64000 to refresh the branch against current origin/main.

Addressed:

  • merged upstream main and resolved the app/public_routes.py conflict
  • kept the ledger limit controls while preserving the newer wallet/bounty route changes from main

Validation:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_api_mcp.py::test_ledger_page_exposes_limit_controls tests/test_api_mcp.py::test_ledger_api_rejects_out_of_range_limits tests/test_api_mcp.py::test_ledger_page_highlights_bounty_payment_and_release tests/test_api_mcp.py::test_ledger_page_uses_wrapping_entry_cards -q -> 6 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_api_mcp.py tests/test_public_routes.py tests/test_docs_public_urls.py -q -> 110 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 483 passed
  • uv run --extra dev ruff check app/public_routes.py tests/test_api_mcp.py -> passed
  • uv run --extra dev ruff format --check app/public_routes.py tests/test_api_mcp.py -> 2 files already formatted
  • uv run --extra dev python -m mypy app/public_routes.py -> success
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check origin/main...HEAD -> clean
  • git merge-tree --write-tree origin/main HEAD -> 82102aec3f1d189d0eede233df45b4407c64bc69
  • git diff origin/main...HEAD | gitleaks stdin --no-banner --redact --exit-code 1 -> no leaks found
  • gitleaks git --no-banner --redact --log-opts origin/main..HEAD --exit-code 1 . -> no leaks found
  • GitHub CI -> passed
  • CodeRabbit -> passed / no actionable comments

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.

6 participants