Skip to content

feat(remote): support admin tokens - #651

Merged
delete-cloud merged 3 commits into
mainfrom
feat/remote-admin-token-pr2
Jun 29, 2026
Merged

delete-cloud merged 3 commits into
mainfrom
feat/remote-admin-token-pr2

Conversation

@delete-cloud

@delete-cloud delete-cloud commented Jun 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add remote admin token and admin token env config fields
  • route remote semantic memory maintenance calls through admin auth while keeping user-token fallback
  • reject blank admin credentials before persisting remotes and keep normal remote endpoints on user auth

Verification

  • uv run pytest tests/cli/test_remote_client.py -q
  • uv run pytest tests/cli/test_remote_client.py -q -k "remote_memory or admin_token or semantic_memory"
  • uv run ruff check src/coding_agent/remote/client.py src/coding_agent/cli/remote_commands.py tests/cli/test_remote_client.py
  • uv run ruff format --check src/coding_agent/remote/client.py src/coding_agent/cli/remote_commands.py tests/cli/test_remote_client.py
  • git diff --check

Review

Summary by CodeRabbit

  • New Features

    • remote add now supports separate credentials for admin-only actions, including environment-variable-based tokens.
    • remote list now shows distinct user-auth and admin-auth status columns.
  • Bug Fixes

    • Admin-only remote operations now use the correct admin credentials when available.
    • Blank or invalid admin token settings are rejected early with clear errors.
    • Saved remote settings now validate admin credential fields more strictly.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@delete-cloud, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 25 minutes and 36 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4161cb16-8611-4c16-870f-d3180c97cd38

📥 Commits

Reviewing files that changed from the base of the PR and between 69fbacb and cf11ed9.

📒 Files selected for processing (2)
  • coding-agent/src/coding_agent/remote/client.py
  • coding-agent/tests/cli/test_remote_client.py
📝 Walkthrough

Walkthrough

Adds admin_token and admin_token_env optional fields to RemoteEndpoint, with matching support in load_remotes() and add_remote() for parsing, mutual-exclusion validation, and persistence. A new admin_auth_headers() function resolves the effective admin bearer token and is applied to the semantic memory status and rebuild endpoints. The CLI remote add gains --admin-token/--admin-token-env options and remote list output splits into user-auth and admin-auth columns.

Changes

Admin Credential Support for Remote Endpoints

Layer / File(s) Summary
RemoteEndpoint admin fields and persistence
coding-agent/src/coding_agent/remote/client.py
RemoteEndpoint gains admin_token and admin_token_env fields; load_remotes() parses and type-validates them from JSON with mutual-exclusion enforcement; add_remote() accepts and persists them; _remote_payload() includes them in the remote config payload.
admin_auth_headers() and HTTP helper overrides
coding-agent/src/coding_agent/remote/client.py
New admin_auth_headers() resolves the effective admin bearer token from admin_token or admin_token_env with blank/missing checks, falling back to auth_headers(); _get_remote_json() and _post_remote_json() gain an optional headers override; semantic memory status and rebuild endpoints now use admin_auth_headers().
CLI remote add options and remote list output
coding-agent/src/coding_agent/cli/remote_commands.py
remote_add gains --admin-token/--admin-token-env click options with whitespace normalization and blank validation; remote_list replaces the single auth= column with tab-separated user-auth= and admin-auth= via new _remote_admin_auth_label() helper.
Tests for admin auth and CLI options
coding-agent/tests/cli/test_remote_client.py
New tests cover admin token selection (direct, env-var, failure-fast on missing/blank), user-token fallback when admin token present, remote add persistence and conflict rejection, remote list label output, and invalid JSON field type errors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐇 Two tokens are better than one, said the rabbit with glee,
An admin key for the vaults, a user key to roam free!
With --admin-token-env I hop through the door,
No blank credentials allowed — that's the law of the warren floor.
user-auth and admin-auth side by side on the list,
Now the secrets stay secret — none shall be missed! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.26% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding admin token support for remote authentication.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/remote-admin-token-pr2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
coding-agent/tests/cli/test_remote_client.py (1)

1663-1668: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert remote list auth labels per remote row.

These checks only prove the four substrings appear somewhere in listed.output. If remote list accidentally swaps the user-auth / admin-auth combinations between direct and env, this test still passes. Tie the expected labels to each remote's line instead of asserting them independently.

Suggested tightening
     assert listed.exit_code == 0
-    assert "direct" in listed.output
-    assert "env" in listed.output
-    assert "user-auth=token" in listed.output
-    assert "user-auth=no-token" in listed.output
-    assert "admin-auth=admin-token" in listed.output
-    assert "admin-auth=admin-token-env" in listed.output
+    lines = listed.output.splitlines()
+    assert any(
+        "direct" in line
+        and "user-auth=token" in line
+        and "admin-auth=admin-token" in line
+        for line in lines
+    )
+    assert any(
+        "env" in line
+        and "user-auth=no-token" in line
+        and "admin-auth=admin-token-env" in line
+        for line in lines
+    )
     assert "user-token" not in listed.output
     assert "admin-secret" not in listed.output
     assert "REMOTE_ADMIN_TOKEN" not in listed.output
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@coding-agent/tests/cli/test_remote_client.py` around lines 1663 - 1668, The
remote list assertions are too loose because they only check for auth labels
anywhere in listed.output, so swapped labels between rows would still pass.
Tighten test_remote_client.py by asserting each remote row’s line contains the
expected label combination, using the existing remote names like direct, env,
user-auth=token, and admin-auth=admin-token to locate the correct row output.
Update the checks around the remote list output to bind each expected auth label
to its specific remote entry instead of independent substring assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@coding-agent/src/coding_agent/remote/client.py`:
- Around line 138-146: The add_remote() flow currently validates the admin
credential choice but still allows blank admin_token and admin_token_env values
to be persisted through RemoteEndpoint and _remote_payload(). Update
add_remote() to normalize these inputs by trimming whitespace and rejecting
empty results before constructing RemoteEndpoint, using the existing
_validate_admin_credential_choice and nearby validation helpers as the right
place to enforce this for direct callers.
- Around line 183-198: The admin token normalization in the token-resolution
logic is incomplete: `endpoint.admin_token` and the value read from
`endpoint.admin_token_env` are only checked with `strip()` but the untrimmed
string is still returned. Update the token-return path in the admin token helper
in `client.py` so both direct and env-sourced values are stripped once,
validated for emptiness, and the normalized token is what gets returned for
later `Authorization` use.

---

Nitpick comments:
In `@coding-agent/tests/cli/test_remote_client.py`:
- Around line 1663-1668: The remote list assertions are too loose because they
only check for auth labels anywhere in listed.output, so swapped labels between
rows would still pass. Tighten test_remote_client.py by asserting each remote
row’s line contains the expected label combination, using the existing remote
names like direct, env, user-auth=token, and admin-auth=admin-token to locate
the correct row output. Update the checks around the remote list output to bind
each expected auth label to its specific remote entry instead of independent
substring assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7af5867a-e63f-4cc5-8c0c-85e913f8ee97

📥 Commits

Reviewing files that changed from the base of the PR and between 94bedc8 and 69fbacb.

📒 Files selected for processing (3)
  • coding-agent/src/coding_agent/cli/remote_commands.py
  • coding-agent/src/coding_agent/remote/client.py
  • coding-agent/tests/cli/test_remote_client.py

Comment thread coding-agent/src/coding_agent/remote/client.py Outdated
Comment thread coding-agent/src/coding_agent/remote/client.py Outdated
@delete-cloud
delete-cloud merged commit 5d825d6 into main Jun 29, 2026
2 checks passed
@delete-cloud
delete-cloud deleted the feat/remote-admin-token-pr2 branch June 29, 2026 01:16
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.

1 participant