Skip to content

Add unit tests asserting doctor distinguishes unconfigured-vs-broken coding-agent CLI states #5195

Description

@JSONbored

Context

test/unit/miner-cli-doctor-checks.test.ts covers checkClaudeCliPresent/checkCodexCliPresent in packages/gittensory-miner/lib/laptop-init.js today, but a separate candidate in this same batch ('Gate doctor's claude/codex CLI-presence checks by the configured MINER_CODING_AGENT_PROVIDER') will make those checks read MINER_CODING_AGENT_PROVIDER and only flip ok to false when a specific provider is configured but its CLI is missing/broken. Once that lands, there is no dedicated test locking in the resulting four-state behavior, and it is kept as its own PR specifically to keep the gating implementation PR small.

Dependencies

Depends on the provider-gating candidate in this same batch ('Gate doctor's claude/codex CLI-presence checks by the configured MINER_CODING_AGENT_PROVIDER') landing first - do not start until MINER_CODING_AGENT_PROVIDER-aware gating actually exists in packages/gittensory-miner/lib/laptop-init.js. These tests assert behavior that change introduces; against today's unconditional checks they would simply fail or be meaningless.

Requirements

  1. Add test cases to test/unit/miner-cli-doctor-checks.test.ts covering all four states, for BOTH claude-cli and codex-cli (8 cases total):
    a. no provider configured + CLI missing => ok:true, advisory-only message
    b. no provider configured + CLI present but unauthenticated => ok:true, advisory-only message
    c. matching provider configured + CLI missing => ok:false
    d. matching provider configured + CLI present but unauthenticated => ok:false, with the specific remediation string
  2. Set MINER_CODING_AGENT_PROVIDER per case via the existing options.env injection pattern already used in this test file - do not mutate global process.env directly.
  3. Assert both the boolean ok field and the exact message/remediation string content for each case, not just truthiness.
  4. Do not modify checkClaudeCliPresent/checkCodexCliPresent's production logic in this PR - this is a test-only change layered on top of the already-merged gating behavior.
  5. If the merged gating PR's actual remediation-string wording differs from what is described here, assert against the real shipped strings rather than an assumed wording.

Deliverables / Acceptance Criteria

  • 8 new/updated test cases added to test/unit/miner-cli-doctor-checks.test.ts (4 states x 2 providers)
  • Each case asserts both ok and the message/remediation string
  • Tests use options.env injection, not global process.env mutation
  • No production code in packages/gittensory-miner/lib/laptop-init.js changed by this PR
  • Full suite passes against the merged provider-gating change

Test Coverage Requirements

This PR must ship with full test coverage for every changed line and branch - the repo's Codecov patch gate requires 99%+ coverage and the house standard is to aim for 100%, including both sides of every conditional/nullish-coalescing branch introduced. Since this PR is itself a test addition, apply that standard to the test code: (1) cover every branch of the gating logic under test (all 4 states x 2 providers, 8 cases), (2) an invariant test asserting 'doctor's ok field is never true when a configured provider's CLI is missing or broken, and never false for a CLI that no configured provider depends on', and (3) this batch of cases doubles as the regression test locking in the parent gating fix - no separate regression test is needed beyond these 8 cases.

Codecov visibility note: packages/gittensory-miner/**, apps/gittensory-miner-ui/**, and apps/gittensory-miner-extension/** currently sit entirely outside vitest's coverage.include glob, so codecov/patch cannot measure changes there yet — closing that gap is exactly what #4864 and #4865 (in this same milestone) do. Any part of this change under packages/gittensory-engine/src/** or the repo's own src/** remains fully Codecov-instrumented as usual. Either way, this does not lower the bar: treat the 100%-including-invariants-and-regression target above as the enforced house standard regardless of what Codecov can currently see, and it becomes gate-enforced for real once #4864/#4865 ship.

Expected Outcome

A contributor or reviewer can trust that gittensory-miner doctor reliably distinguishes 'not installed, nobody cares' from 'configured but broken, every attempt will fail' for both supported CLI providers, backed by a locked-in regression suite.

Links & Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    Status
    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions