fix: protect sophia governor recent events#6514
Conversation
eliasx45
left a comment
There was a problem hiding this comment.
Reviewed the focused Sophia governor auth change at e0d3c4f510123c530ba5747307e3d868ff56dbea.
I did not find a blocker in the changed files. The new guard in node/sophia_governor.py runs before limit parsing, so unauthenticated callers get the same 401 for both normal and malformed limit requests, which matches the issue's goal of not exposing recent-event behavior. The new tests cover missing key, wrong key, valid admin key, and the auth-before-limit ordering.
Verification performed locally:
.\.venv\Scripts\python.exe -m pytest tests/test_sophia_governor_recent_auth.py -q-> 3 passed.\.venv\Scripts\python.exe -m py_compile node/sophia_governor.py tests/test_sophia_governor_recent_auth.py-> passedgit diff --check origin/main...HEAD-> clean- Read
Scottcjn/Rustchain#6513and confirmed this PR gates/sophia/governor/recentwith the existingRC_ADMIN_KEY/X-Admin-Key/X-API-Keyhelper used by the review/retry routes.
One merge note: GitHub's full pytest job is currently red during collection on node/gpu_render_endpoints.py:240 (SyntaxError: expected 'except' or 'finally' block). I confirmed the same syntax error exists when compiling that file from both origin/main and this PR head, so it is outside this two-file PR's diff. The focused regression for this PR is green locally.
|
Disclosure update for my review above: I am claiming RustChain ONBOARD review bounty #2782 for this review. RTC wallet: |
Fixes #6513.
Summary
/sophia/governor/recentTesting
./.venv/bin/python -m pytest -q tests/test_sophia_governor_recent_auth.pyPYTHONPYCACHEPREFIX=/private/tmp/rustchain-pycache python3 -m py_compile node/sophia_governor.py tests/test_sophia_governor_recent_auth.pygit diff --check