Skip to content

fix(miner): add offline GITHUB_TOKEN and coding-agent-credential checks to doctor (#5170) - #5514

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
carlh7777:fix/doctor-credential-presence-checks
Jul 13, 2026
Merged

fix(miner): add offline GITHUB_TOKEN and coding-agent-credential checks to doctor (#5170)#5514
JSONbored merged 1 commit into
JSONbored:mainfrom
carlh7777:fix/doctor-credential-presence-checks

Conversation

@carlh7777

Copy link
Copy Markdown
Contributor

Summary

gittensory-miner doctor is a no-network readiness check, but it never verified two credentials every real attempt needs, so an operator could pass doctor cleanly and then have their first attempt fail mid-run purely on a missing credential:

  • GITHUB_TOKEN (needed the moment an attempt pushes a branch or opens a PR), and
  • the credential required by the configured MINER_CODING_AGENT_PROVIDER.

This adds both as offline checks in runDoctorChecks() (packages/gittensory-miner/lib/status.js):

  • checkGitHubTokenPresent — string presence/length check; fails doctor when GITHUB_TOKEN is unset or empty. No API call.
  • checkCodingAgentCredential — resolves the configured provider via the existing resolveFirstConfiguredCodingAgentDriverName and checks the credential that provider actually requires:
    • claude-cli / agent-sdk → a Claude credential env var (CLAUDE_CODE_OAUTH_TOKEN, the same token the rest of the tree reads via createClaudeCodeAi; the Agent SDK also accepts a raw ANTHROPIC_API_KEY, so either satisfies it),
    • codex-cliauth.json readability, reusing laptop-init.js's resolveCodexAuthPath (now exported) so the path never drifts from the existing codex auth probe,
    • noop / no provider configured → a clean skip.

Both preserve doctor's documented zero-network invariant, and neither ever prints a credential value — only presence booleans and env-var / file-path names.

Distinct from the existing checkClaudeCliPresent/checkCodexCliPresent, which by design keep ok: true when only the credential is missing (#5165) — this new check is what actually fails doctor on a missing credential.

Closes #5170

Scope

Validation

  • git diff --check
  • npm run typecheck (clean, incl. the updated .d.ts declarations)
  • node --check on both changed lib files (the miner package's build gate)
  • Tests: 14 new cases in miner-cli-doctor-checks.test.ts (every provider × present/absent, both || sides, fallback-chain resolution, the no-secret-value invariant, and the missing-credential regression) plus the updated miner-status.test.ts healthy-setup fixtures — all pass. packages/gittensory-miner/** sits outside Codecov's src/** include glob, so codecov/patch cannot measure it, but every new line and branch is covered to the 100% house standard regardless.
  • npm run test:workers · build:mcp · ui:* — N/A (miner-package + test change only; no worker/MCP/UI/OpenAPI surface touched).

If any required check was skipped, explain why:

Change is confined to the packages/gittensory-miner lib (authored JS, validated by node --check) + its .d.ts + unit tests. It touches no worker src/**, workflow, MCP, OpenAPI, or UI surface.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed. An explicit invariant test asserts doctor's output never contains a credential VALUE, only presence + env-var/file names.
  • Public GitHub text stays sanitized and low-noise.
  • Auth/CORS/session negative-path tests — N/A (offline local CLI check; no auth/session surface).
  • API/OpenAPI/MCP behavior updated/tested where needed — N/A.
  • UI changes use real states — N/A (no UI).
  • Visible UI changes include UI Evidence — N/A.
  • Public docs/changelogs updated where needed — N/A.

UI Evidence

N/A — no UI/frontend/docs changes.

Notes

  • agent-sdk's credential: the repo has no ANTHROPIC_API_KEY reference anywhere and authenticates Claude via CLAUDE_CODE_OAUTH_TOKEN; since agent-sdk is the in-process form of the same Claude backend as claude-cli, the check accepts either token (both are valid Agent-SDK auth), documented inline.
  • The two existing "healthy setup" doctor tests were updated to include GITHUB_TOKEN in their fixture (a healthy setup now genuinely requires it) and the new check names — not weakened.

…octor functionality

This update introduces two new checks in the doctor functionality: `checkGitHubTokenPresent` and `checkCodingAgentCredential`. The former verifies the presence of the `GITHUB_TOKEN` environment variable, while the latter checks for the configured coding agent's credentials, enhancing the overall robustness of the setup validation process. Additionally, the `runDoctorChecks` function has been updated to include these new checks, ensuring users are informed of any missing credentials before attempting operations that require them.
@carlh7777
carlh7777 requested a review from JSONbored as a code owner July 13, 2026 00:18
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 13, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.75%. Comparing base (f6e5d07) to head (6c806e0).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5514   +/-   ##
=======================================
  Coverage   94.75%   94.75%           
=======================================
  Files         565      565           
  Lines       44920    44935   +15     
  Branches    14675    14675           
=======================================
+ Hits        42565    42580   +15     
  Misses       1621     1621           
  Partials      734      734           
Flag Coverage Δ
shard-1 43.78% <0.00%> (-0.52%) ⬇️
shard-2 35.38% <0.00%> (+0.03%) ⬆️
shard-3 32.07% <0.00%> (+0.14%) ⬆️
shard-4 31.40% <100.00%> (-0.56%) ⬇️
shard-5 33.32% <40.00%> (+0.39%) ⬆️
shard-6 43.80% <0.00%> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/gittensory-miner/lib/laptop-init.js 98.27% <ø> (ø)
packages/gittensory-miner/lib/status.js 94.53% <100.00%> (+0.72%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 13, 2026
@loopover-orb

loopover-orb Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-13 00:23:27 UTC

6 files · 2 AI reviewers · no blockers · readiness 100/100 · CI green · unstable

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds two offline doctor checks — GITHUB_TOKEN presence and coding-agent-provider-credential presence — closing the gap where checkClaudeCliPresent/checkCodexCliPresent intentionally stay ok:true on a missing credential (#5165). The new checkCodingAgentCredential correctly resolves the configured provider via resolveFirstConfiguredCodingAgentDriverName and checks the right credential per provider (env var for claude-cli/agent-sdk, auth.json readability for codex-cli via the now-exported resolveCodexAuthPath), and never leaks credential values, only presence/paths. Tests cover both branches of each check plus a secrets-never-printed invariant and existing snapshot tests were updated for the new check names in the doctor sequence.

Nits — 5 non-blocking
  • packages/gittensory-miner/lib/status.js: checkCodingAgentCredential silently treats any provider string that isn't null/noop/claude-cli/agent-sdk as codex-cli by falling through — worth an explicit check or comment noting this is intentional since resolveFirstConfiguredCodingAgentDriverName is trusted to only return one of the known provider names.
  • packages/gittensory-miner/lib/status.js grew to ~428 lines per the size-smell note; consider splitting the new credential-check functions into a small helper module if the file keeps growing.
  • The `Gate doctor's claude/codex CLI-presence checks by the configured MINER_CODING_AGENT_PROVIDER #5165` reference in the comment at status.js:352 is just an issue number, not a magic number needing a named constant — the flagged 'magic number' concern is a false positive.
  • Consider a short comment noting that checkCodingAgentCredential's final branch is reached for any provider that isn't null/noop/claude-cli/agent-sdk, relying on the driver resolver to only ever return codex-cli in that case.
  • If the file size keeps growing, extract the credential-check functions (checkGitHubTokenPresent, checkCodingAgentCredential) into a dedicated module.
Flagged checks (non-blocking)
  • Contributor trust — Contributor flagged for review
Signal Result Evidence
Code review ✅ No blockers 2 reviewers, synthesized
Linked issue ✅ Linked #5170
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 181 registered-repo PR(s), 117 merged, 17 issue(s).
Contributor context ✅ Confirmed Gittensor contributor carlh7777; Gittensor profile; 181 PR(s), 17 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence. LLM value judgment: moderate — The change closes a real, previously-acknowledged gap (#5165) where doctor could pass cleanly and then fail mid-attempt on a missing credential, and does so with narrow, well-tested, offline-only checks that directly serve the linked issue #5170.
Linked issue satisfaction

Addressed
The PR adds checkGitHubTokenPresent and checkCodingAgentCredential to runDoctorChecks(), covering GITHUB_TOKEN presence and provider-specific credential checks (env var for claude-cli/agent-sdk, auth.json readability for codex-cli) with zero network calls and no secret values ever printed, matching the issue's requirements almost point-for-point.

Review context
  • Author: carlh7777
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 181 PR(s), 17 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
[BETA] Chat with Gittensory

Ask Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @gittensory ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @gittensory mention with a real question is routed to the closest matching read-only command automatically -- no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 13, 2026
@JSONbored
JSONbored merged commit d25c60d into JSONbored:main Jul 13, 2026
15 of 16 checks passed
@carlh7777
carlh7777 deleted the fix/doctor-credential-presence-checks branch July 13, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add offline GitHub-token and coding-agent-credential presence checks to gittensory-miner doctor

2 participants