技能 2026-10-07 12:38 UTC
ouroboros
由提交人 lee3Q 提交,主要更新类型为:新增功能与能力扩展。提交说明:feat(mcp): add opt-in local stdio doctor probe (#2406)。带来了新的能力与可配置项,扩展了使用场景。
Commit提交信息原文
feat(mcp): add opt-in local stdio doctor probe (#2406) Refs #2405 ## Problem and behavior When an MCP host cannot discover Ouroboros, `ouroboros mcp doctor --probe-local-stdio` checks this installation's own server through three stable stages: local stdio transport, protocol discovery, and recognition of the production tool surface. The default doctor command does not launch a server. The probe lists tools without invoking them. Probe or owned cleanup failure produces the existing failure exit status; external cancellation is preserved after cleanup is attempted. The three stages describe what was actually observed. Cleanup failure adds a failing `local_stdio_cleanup` result without rewriting successful startup, discovery, or recognition as failures in a different stage. A primary discovery/body exception retains its identity and diagnostic while simultaneous teardown failures remain secondary evidence. ## Implementation The child uses the current Python interpreter in isolated mode with bytecode writes disabled, imports the trusted installation, and runs the ordinary production server composition in a temporary home and working directory. It bypasses normal CLI dotenv, shell-profile, update-check and PID-registry startup; the child denies network and command execution. Configured MCP launch commands are not used. A public SDK transport wrapper records stream entry before protocol discovery. The adapter owns one cleanup envelope that attempts acquired resources, records secondary teardown failures, and preserves primary discovery errors or cancellation. Doctor owns temporary-state removal and staged visible results. Adapter context exit preserves an existing body exception or cancellation even when teardown or warning emission also fails. A side-effect-free immutable manifest is checked against real production composition and requires all 36 built-in tools. The CLI test helper now declares an explicit command group and consistently invokes `doctor`. This prevents Typer's single-command promotion from changing fixture behavior when another Doctor command is registered. The fixture correction does not alter the product implementation. ## Implementation boundary and review contract Owner: existing MCP diagnostics/CLI, MCP client adapter/SDK lifecycle, and production tool-registration owners. This change stays within those owners, focused tests, and CLI documentation. The supported input is the explicit opt-in flag under the declared local MCP runtime. No new subsystem or dependency is introduced. The isolated offline bootstrap is retained deliberately. It differs from the later review's normal-serve reset directive: the first review reproduced cwd package shadow execution, network update refresh, and state/TLS side effects on ordinary startup. Restoring that path would conflict with the original own-installation, offline, and user-state-isolation requirements. This implementation uses the existing MCP configuration/client boundary and production composition without duplicating wire framing. Literal compliance with that conflicting reset directive is not claimed. ## Verification Exact HEAD: `7a47c624b37a4e6fa5a60be5e9bf419d35f59f1f`; incorporated main: `fef3e21840d1d147642da9d6353bf1542de337a3`; binary diff SHA-256: `e60c3dc4850a42d4e5457b7dde3553261df847f1e069931ee61c6b88c9b624c4`. - Rebased after #2420 merged. The overlapping Doctor test imports and invocation fixtures were reconciled, preserving both PRs' tests. - On this rebased HEAD, combined Doctor/runtime tests: 199 passed. - Ruff lint and format passed; whole-source MyPy: no issues in 696 source files; module-size ratchet passed against current main; `git diff --check` passed. - GitHub CI for this exact HEAD is running; results are pending. Historical pre-rebase evidence below was collected on HEAD `4583510d2585357d7128c5483e34014940399a57` against main `0df5b9893897dc28f1597235e586df60b15f319d`. The full project suite has not been rerun after #2420 merged. - Focused contract regressions on the pre-rebase candidate: 109 passed. - Bridge TypeScript/152-test evidence is reused from the identical Bridge tree `520e2cb914f221724c05d5e3a070ce9fc36f35d2`; no fresh whole-diff Bridge execution is claimed. - Historical pre-rebase local whole-project Python 3.12/macOS result: **29 failed, 25863 passed, 188 skipped, 1 xfailed, 7 warnings in 4393.83s (1:13:13)**. Latest unchanged main reproduced **12 failed, 3 passed** on the prior failure selectors. 13 full-run failed selectors also failed on unchanged main; 16 additional full-run failures did not reproduce in the candidate serial rerun; no candidate-only serial failure remains. All original failures are preserved. Local pre-review is not represented as passing when the whole suite is nonpassing. Remote CI, current-HEAD reviewer approval, native Windows execution and merge are not claimed. Please review the published exact HEAD; no merge is requested. Local profile: macOS Intel, CPython 3.12.15, two xdist workers, `not performance`. CI uses its own declared runner/profile. <details> <summary>Preserved pre-rebase whole-suite failed selectors</summary> | Selector | Comparison | | --- | --- | | `tests/integration/mcp/test_detached_job_worker.py::test_detached_job_survives_accepting_process_exit[forced]` | Also failed on unchanged main | | `tests/integration/mcp/test_detached_job_worker.py::test_detached_job_survives_accepting_process_exit[normal]` | Also failed on unchanged main | | `tests/integration/mcp/test_detached_job_worker.py::test_external_controller_cancels_detached_owner` | Also failed on unchanged main | | `tests/integration/mcp/test_detached_job_worker.py::test_nested_handoff_gets_independent_durable_owner` | Also failed on unchanged main | | `tests/integration/mcp/test_detached_probe_process.py::test_cleanup_error_preserves_body_failure_without_hiding_cleanup_failure[False]` | Also failed on unchanged main | | `tests/integration/mcp/test_detached_probe_process.py::test_cleanup_error_preserves_body_failure_without_hiding_cleanup_failure[True]` | Also failed on unchanged main | | `tests/integration/plugin/test_wheel_packaging.py::test_built_wheel_preserves_packaging_contracts` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/boundary/test_oracle_run.py::test_binding_admission_timeout_is_indeterminate_and_not_retried` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/cli/test_run_successors.py::test_ctrl_c_during_wait_stops_waiting_without_cancelling_jobs` | Also failed on unchanged main | | `tests/unit/cli/test_setup.py::TestCodexSetup::test_register_codex_mcp_server_refreshes_legacy_direct_dev_entry` | Also failed on unchanged main | | `tests/unit/cli/test_setup.py::TestCodexSetup::test_register_codex_mcp_server_refreshes_stale_dev_module_entry` | Also failed on unchanged main | | `tests/unit/cli/test_setup.py::TestCodexSetup::test_register_codex_mcp_server_uses_current_python_for_source_tree` | Also failed on unchanged main | | `tests/unit/cli/test_setup.py::TestCodexSetup::test_register_codex_mcp_server_uses_direct_executable_for_dev_build` | Also failed on unchanged main | | `tests/unit/orchestrator/test_codex_cli_runtime.py::TestCodexCliRuntime::test_execute_task_marks_resume_bootstrap_failures_recoverable` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_atomic_aba_during_version_probe_is_not_authorized` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_changed_symlink_target_is_rejected_before_version_execution` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_check_time_execution_failure_is_not_reported_as_drift` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_check_time_timeout_is_fail_closed_but_retryable_for_codex_family[CodexCliRuntime-Codex CLI]` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_check_time_timeout_is_fail_closed_but_retryable_for_codex_family[CopilotCliRuntime-Copilot CLI]` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_execution_identity_tracks_launch_symlink_target` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_in_place_aba_during_version_probe_is_not_authorized` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_in_place_mutation_during_version_probe_is_not_authorized` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_initialization_execution_failure_has_distinct_fail_closed_error` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_probe_window_aba_takes_precedence_over_probe_failure[empty]` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_probe_window_aba_takes_precedence_over_probe_failure[nonzero]` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_probe_window_aba_takes_precedence_over_probe_failure[os_error]` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_codex_cli_runtime.py::test_probe_window_aba_takes_precedence_over_probe_failure[timeout]` | Passed serially on main and candidate; whole run remains failed | | `tests/unit/orchestrator/test_n_version_tournament.py::TestNonAsciiAndQuotedFilenames::test_undecodable_filename_exports_and_applies` | Also failed on unchanged main | | `tests/unit/persistence/test_event_store.py::TestEventStoreInitialization::test_durable_append_interrupts_lock_and_returns_after_rollback` | Also failed on unchanged main | </details> <!-- contribution-flow:20260914-203047-doctor-successor-case-after-the--f83e3b -->