Skip to content

test(install): cover install flow; add probe cache + ban-risk guardrails - #602

Open
rakeshbishtn wants to merge 1 commit into
Panniantong:mainfrom
rakeshbishtn:fix/install-flow-tests-and-guardrails
Open

test(install): cover install flow; add probe cache + ban-risk guardrails#602
rakeshbishtn wants to merge 1 commit into
Panniantong:mainfrom
rakeshbishtn:fix/install-flow-tests-and-guardrails

Conversation

@rakeshbishtn

Copy link
Copy Markdown

Summary

Addresses three weaknesses identified in the install/doctor path:

1. Install flow had no direct test coverage

New tests/test_install_flow.py (25 tests):

  • _detect_environment() local/server classification (SSH, container markers, headless+virt, clean local)
  • Safe/dry-run side-effect isolation: dry-run never creates ~/.agent-reach/tools, safe mode never writes config or persists a proxy, dep-check helpers never execute installers
  • --channels=all expands to exactly the supported set (cookie/manual-only channels excluded); channel names normalize case/whitespace; unknown channels exit 2 before any side effect
  • facebook/instagram/opencli installer dedup runs once

2. Doctor accuracy / probe churn

  • probe_command() now has a TTL cache (10s default, keyed by binary+args+env) so repeated doctor runs reuse fresh results instead of re-executing every upstream CLI
  • New agent-reach doctor --refresh flag forces a full re-probe
  • clear_probe_cache() exported for programmatic invalidation
  • tests/conftest.py autouse fixture clears the cache per test so a real host probe can never poison a mocked test

3. Cookie account-ban risk was README-only

  • configure twitter-cookies / xhs-cookies now print a targeted ban-risk warning (throwaway-account advice) at the moment credentials are saved
  • doctor report adds a ban-risk line when cookie-based channels (twitter/xiaohongshu/reddit/xueqiu) are active

Verification

  • Full suite: 611 passed, 16 subtests passed (586 pre-existing + 25 new, zero regressions)
  • ruff clean
  • doctor --refresh --json and the configure warning verified live

Notes

  • probe_command signature is backward compatible (use_cache=True default; existing callers unchanged)
  • Cached results are short-lived (10s) and keyed per binary/args/env, so a stale backend cannot survive inside a single process

- tests/test_install_flow.py: 25 tests for _detect_environment, safe/dry-run
  side-effect isolation, --channels=all expansion, channel normalization,
  probe cache TTL semantics, doctor --refresh, cookie ban-risk warning
- probe.py: TTL cache for probe_command (10s default) so repeated doctor
  runs reuse fresh results; clear_probe_cache() forces a full re-probe
- cli.py: doctor --refresh flag; _warn_cookie_ban_risk printed when saving
  Twitter/X or Xiaohongshu cookies (account-ban risk, throwaway-account advice)
- doctor.py: ban-risk line in the report when cookie-based channels active
- conftest.py: autouse fixture clears the probe cache per test
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