发布

  • feat(wizard): validate the LLM credential during onboarding, with failure recovery (#4055)

    frostbyte_neo 发布于 2026-07-27 19:36:41 +00:00 | 946 次提交 在此版本后已推送到 main

    • feat(wizard): validate LLM API keys during onboarding

    Wire validate_provider_credentials into run_wizard's two credential
    collection sites via _collect_validated_llm_credential, with a bounded
    failure menu (re-enter / save anyway / repick) and a keyring-persist
    recovery menu replacing the hard exit. Fixes #3591.

    • fix(wizard): reinstate #3591 validation implementation and tests

    The working tree was reverted by a concurrent session between the
    original restore and commit; this reinstates the verified state
    (flow.py wiring, 67-test contract, amended onboarding smoke tests)
    from the tagged recovery point wave-3591-true-state.

    • test(wizard): add network guard and RED tests for the MiniMax base-URL gap

    Socket-level autouse guard for the wizard package: no wizard test may open a
    real outbound connection. This is load-bearing for #3591 — validation.py caches
    the provider SDK classes in module globals, tests/conftest.py loads .env with
    override=True, and dev machines routinely export ANTHROPIC_API_KEY, so a test
    that patches the wrong name would quietly call api.anthropic.com with a live key
    and still go green. The guard derives from BaseException so the SDKs' own
    except Exception (which re-raises transport faults as APIConnectionError)
    cannot swallow it.

    It immediately caught a pre-existing impure test: run_wizard's model-change test
    reaches _configure_grafana_local -> seed_logs -> wait_for_loki -> requests.get
    against a local Loki. The connection error is swallowed today, so it passes —
    but on a machine with Loki running, that unit test seeds a live Loki. Fixed in
    the follow-up commit.

    Also adds the RED tests for the MiniMax gap: minimax is a live api_key
    provider that reaches the wizard's key prompt, but _get_provider_base_url has no
    branch for it, so a valid key is sent to api.openai.com and rejected.
    MINIMAX_BASE_URL has been in config all along, never wired in. Latent today;
    a hard block once onboarding gates on validation.

    Refs #3591.

    • test(wizard): RED for #3591 deltas

    Deltas 3-6 + X2. Every new test fails on missing behaviour (AssertionError)
    or on a helper the approved design contract obliges GREEN to create.

    • feat(wizard): validate the LLM credential against the chosen model, and recover from failures

    • fix(wizard): keep the session-only API key across the env-sync handoff (#3591)

    • test(wizard): RED for #3591 azure-endpoint recovery + ollama summary

    • fix(wizard): re-prompt a failed Azure endpoint; name .env in the Ollama host summary (#3591)

    • test(wizard): fix CLI-repick smoke test for the model-before-key order (#3591)

    Greptile P1: the parametrized codex/opencode repick smoke test was missed when
    the smoke tests were reordered for #3591. It still expected the pre-hoist order
    (key prompt, then model) and the stale string 'failed validation. What next?'.
    Post-hoist the real flow is model -> key -> 'could not be verified. What next?',
    matching test_onboard_interactive_smoke. The test is skipped without codex or
    opencode on PATH, so the staleness never failed locally; it would hang until
    timeout once either CLI is installed.

    • test(wizard): RED for host .env-write recovery gap (#3591)

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • refactor(wizard): extract LLM-credential helpers to a module; constants; host .env recovery (#4055 review)

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com


    Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com

    下载附件