Skip to content

byterover: implement health_check() to verify brv login state (#42 step 2c)#46

Merged
PowerCreek merged 1 commit into
mainfrom
byterover-health-check-override
May 23, 2026
Merged

byterover: implement health_check() to verify brv login state (#42 step 2c)#46
PowerCreek merged 1 commit into
mainfrom
byterover-health-check-override

Conversation

@PowerCreek

Copy link
Copy Markdown

Summary

Step 2c of the RFC #42 migration plan. ByteRover's is_available() only verified the brv CLI was on PATH — an operator with the CLI installed but not logged in saw a false-positive green check from doctor.

health_check() now runs brv status (3-second timeout) and classifies the outcome with RFC #42 reason prefixes:

Tuple When
(True, "") brv status exits 0
(False, "sdk_missing") brv not on PATH
(False, "auth: ...") Non-zero exit + stderr mentions auth / login / unauthorized / not signed in / 401 / 403
(False, "unreachable: timeout") Probe timed out
(False, "unreachable: ...") Anything else (config issue, malformed install, etc.)

The "never raises" contract is enforced — even when _run_brv propagates (defense in depth; _run_brv already has its own try/except), the override catches and returns (False, "unreachable: <msg>").

Test plan

  • 8 new tests in tests/plugins/memory/test_byterover_health_check.py:
    • success returns (True, "")
    • sdk_missing when brv absent
    • 5 auth-classification cases (not signed in, Unauthorized, auth required, 401, login required)
    • timed outunreachable: timeout
    • Generic non-zero exit → unreachable: <msg>
    • "Never raises": even when _run_brv throws, returns tuple
    • Long error messages truncated under 220 chars
  • No regression across the active sweep: pytest tests/plugins/memory/test_byterover_health_check.py tests/honcho_plugin/test_health_check.py tests/plugins/memory/test_mem0_health_check.py tests/agent/test_memory_provider.py → 99 passed.

Continues #42 step 2. Three providers now migrated: mem0 (#44), honcho (#45), byterover (this PR). Six remain (holographic, supermemory, hindsight, retaindb, openviking, plus any future) before the doctor-branch collapse in step 3.

Filed by hermes-maintainer (PowerCreek).

…ep 2c)

Step 2c of the RFC #42 migration plan. ByteRover's is_available()
only checked whether the brv CLI was on PATH — an operator with
brv installed but not logged in saw a false-positive green check
from doctor. health_check() now runs `brv status` to verify both:

  (True, "")                     — `brv status` exits 0.
  (False, "sdk_missing")         — brv CLI not on PATH.
  (False, "auth: ...")           — non-zero exit + stderr mentions
                                    auth / login / unauthorized /
                                    "not signed in" / 401 / 403.
  (False, "unreachable: timeout")— probe timed out.
  (False, "unreachable: ...")    — anything else (config issue,
                                    malformed install, etc.).

The probe has a 3-second timeout — `brv status` is local-cache
backed, so anything longer indicates a stuck CLI.

The "never raises" contract from the ABC default is preserved —
even if _run_brv itself propagates (it shouldn't; it has its own
try/except), the override catches the exception and returns
(False, "unreachable: <msg>").

Tests:
  - success returns (True, "")
  - sdk_missing when brv absent
  - 5 auth-classification cases (not-signed-in, Unauthorized,
    auth-required, 401, login required)
  - "timed out" → unreachable: timeout
  - generic non-zero exit → unreachable: <msg>
  - never-raises: even when _run_brv throws, returns tuple
  - long error messages truncated under 220 chars

Continues #42; does not close it. Three providers migrated:
mem0 (#44), honcho (#45), byterover (this PR). Six remain
before the doctor-branch collapse in step 3.
@PowerCreek PowerCreek merged commit af498a9 into main May 23, 2026
@PowerCreek PowerCreek deleted the byterover-health-check-override branch May 23, 2026 02:12
PowerCreek added a commit that referenced this pull request May 23, 2026
…s 2h + 3) (#52)

Closes #42. Final two steps of the RFC migration.

Step 2h — holographic health_check:
  Holographic is local-only (SQLite); no remote service. But a
  read-only HERMES_HOME (RO mount, wrong perms) would still
  break it at runtime. Override verifies db_path's parent
  directory is writable.

    (True, "")                     — parent mkdir + W_OK pass.
    (False, "unreachable: <msg>")  — mkdir failed or W_OK denied.
    (False, "config_error: <msg>") — get_hermes_home raised.

Step 3 — doctor branch collapse:
  Every shipped provider now implements health_check() with the
  RFC #42 reason-prefix taxonomy. The provider-specific Honcho +
  Mem0 elif blocks (~120 lines combined) are gone. The unified
  dispatch is one ~80-line block in doctor.py keyed on the prefix:

    healthy → check_ok("<name> reachable")
    no_api_key / no_credentials → _fail_and_issue (setup hint)
    no_url / no_endpoint        → _fail_and_issue (URL hint)
    no_config                   → check_warn (run setup)
    disabled                    → check_info
    sdk_missing                 → _fail_and_issue (plugin docs)
    auth:                       → _fail_and_issue (rotate key)
    not_found:                  → _fail_and_issue (verify base URL)
    http:                       → check_warn (unexpected status)
    unreachable:                → check_warn (transient hint)
    config_error:               → check_warn (config raised)
    health_check_raised:        → check_warn (provider bug; RFC
                                   #42 says health_check MUST NOT
                                   raise, so this is a contract
                                   violation worth flagging)
    other                       → check_warn (unknown verbatim)

Doctor's Memory Provider section is now ~80 lines instead of
~200, and adding the 9th provider requires zero doctor changes.

Migration table (8 providers total):
  mem0       — PR #44  GET /v1/memory profile
  honcho     — PR #45  get_honcho_client handshake
  byterover  — PR #46  brv status (CLI + login)
  supermemory — PR #48  client.profile probe
  openviking — PR #49  /health endpoint probe
  retaindb   — PR #50  /v1/memory/profile GET
  hindsight  — PR #51  mode-dependent (local import / cloud /version)
  holographic — this PR  db_path parent writability

Tests:
  - 6 new tests for holographic health_check
  - Updated 3 doctor tests to assert the new unified dispatch
    (auth → _fail_and_issue; unreachable → check_warn; healthy
    → "<name> reachable") instead of the now-removed elif-block
    output strings.
  - 228 health_check + doctor tests pass total.

The #42 RFC is now fully implemented across all shipped memory
providers. Closing the issue with this PR.
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