Skip to content

fix: register explorer dependency routes#6733

Merged
Scottcjn merged 1 commit into
Scottcjn:mainfrom
keon0711:codex/register-agent-economy-routes-6693
Jun 1, 2026
Merged

fix: register explorer dependency routes#6733
Scottcjn merged 1 commit into
Scottcjn:mainfrom
keon0711:codex/register-agent-economy-routes-6693

Conversation

@keon0711
Copy link
Copy Markdown
Contributor

@keon0711 keon0711 commented Jun 1, 2026

BCOS Checklist (Required For Non-Doc PRs)

  • Add a tier label: BCOS-L1
  • If adding new code files, include SPDX header near the top (no new code files)
  • Provide test evidence (commands + output below)

Summary

  • Register the existing RIP-302 Agent Economy routes from the integrated node app so /agent/stats and /agent/jobs no longer 404 for the explorer dashboard.
  • Register/read through Ergo anchor routes when available, and provide a read-only /anchor/list fallback plus /anchors redirect so navigation does not land on 404.
  • Ensure anchor listing creates the ergo_anchors table on empty DBs and returns an empty list instead of failing.

Fixes the application-route 404s reported in #6693. The raw-IP certificate mismatch is deployment/certificate configuration, not something this repo patch can correct by itself.

RTC wallet for any merged-PR reward: RTC1410e82d545ce0b3ffd21ca83e2465a8f2c3a64e

Testing

git diff --check
uv run --no-project --with pytest --with flask --with requests --with cryptography --with pynacl --with psutil python -m pytest node/tests/test_ergo_anchor_routes.py node/tests/test_explorer_api_routes.py tests/test_agent_jobs_query_validation.py -q

Result: 34 passed in 0.24s.

Manual route probe after the fix:

/agent/stats -> 200
/agent/jobs?status=open&limit=1 -> 200
/anchors -> 302 /anchor/list
/anchor/list -> 200

@keon0711 keon0711 requested a review from Scottcjn as a code owner June 1, 2026 14:32
@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related tests Test suite changes size/M PR: 51-200 lines labels Jun 1, 2026
@keon0711
Copy link
Copy Markdown
Contributor Author

keon0711 commented Jun 1, 2026

CI note: the broad test workflow is failing on pre-existing/broader baseline tests outside this PR scope (bridge/governance/beacon/monitor/docs/etc.). The focused route coverage for this PR passed locally:

git diff --check
uv run --no-project --with pytest --with flask --with requests --with cryptography --with pynacl --with psutil python -m pytest node/tests/test_ergo_anchor_routes.py node/tests/test_explorer_api_routes.py tests/test_agent_jobs_query_validation.py -q

Result: 34 passed in 0.24s.

Manual route probe on the integrated app after the patch:

  • /agent/stats -> 200
  • /agent/jobs?status=open&limit=1 -> 200
  • /anchors -> 302 /anchor/list
  • /anchor/list -> 200

Copy link
Copy Markdown
Contributor

@Asti1982 Asti1982 left a comment

Choose a reason for hiding this comment

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

Reviewed the route-registration fix for #6693. The main happy path looks reasonable: the Agent Economy routes are registered on the integrated app, /anchors gives the explorer a stable navigation target, and /anchor/list now handles an empty anchor DB instead of 404/failing.

One non-blocking test gap below: the fallback branch is part of the behavior this PR is relying on for deployments where the optional anchor module cannot import, but the current integrated-app test does not force that branch. Adding a small import-failure/monkeypatch test would make this safer to merge.

Routing this as a substantive line-level review for rustchain-bounties #73; no RTC has been received for this review yet.

print(f"[ANCHOR] Failed to register Ergo anchor endpoints: {e}")


if not _ANCHOR_ROUTES_REGISTERED:
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.

This fallback branch is now part of the explorer's availability guarantee, but the added integrated-app test only exercises it if rustchain_ergo_anchor happens not to import in the test environment. Since the module normally imports, the fallback query parsing/table-creation path can regress without failing CI. Consider adding a focused test that forces the optional anchor import/registration to fail and then asserts /anchor/list still returns 200 with the empty payload plus the expected 400 responses for invalid limit/offset.

try:
conn.row_factory = sqlite3.Row
cursor = conn.cursor()
_ensure_anchor_table(cursor)
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.

Good extraction here: using _ensure_anchor_table(cursor) before the list query keeps /anchor/list aligned with get_last_anchor() on empty deployments. That matters for the explorer fix because a fresh DB should render an empty anchor list instead of surfacing a route-level error to first-time users.

@Scottcjn Scottcjn merged commit 2e99762 into Scottcjn:main Jun 1, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/M PR: 51-200 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants