fix(dsh): handle Scope failures at tool and command boundaries - #1452
Open
knqiufan wants to merge 1 commit into
Open
fix(dsh): handle Scope failures at tool and command boundaries#1452knqiufan wants to merge 1 commit into
knqiufan wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue or RFC does this PR close?
Closes #1451.
Refs #1450 (work package A).
Rationale for this change
Scope resolution currently runs outside the error boundary used for DSH HTTP operations. A failed resolver request can therefore escape as a host exception from a named tool or block
/pc doctorbefore its health checks run. Operation-level 404 results also discard the public reason, making a missing Scope or Memory difficult to distinguish from an unavailable required route.What changes are included in this PR?
not_foundfor business 404s and add optionalerror_codefor recognized public reasons. A 404 becomesversion_mismatchonly when the original business code is absent and the endpoint is required, including Scope resolution. Keep the existing authentication, availability, conflict, and validation codes, and map detected invalid responses explicitly.scope=unresolved, controlled error details, a recovery hint, and a redacted Server origin.The implementation builds on #1401, #1360, and #1371. It leaves the transport/encoding work in #1438 and Scope onboarding in #1449 to their existing owners. Automatic-hook diagnostics, broader Doctor probes, and guidance/status work remain in #1450 B–F.
Are there any user-facing changes?
Yes. Scope failures return controlled failures instead of escaping to DSH. Doctor and capabilities work independently of Scope availability; usage help is local. Bare
/pcreports an unresolved Scope honestly and displays only the Server origin.Failure results retain available
statusandrequest_id; business 404s can additionally expose a safeerror_code. Existing success results and specific public 409/422 codes remain compatible. Failed Scope resolution does not write Memory, create bindings, or select another Scope. No HTTP API contract or persisted-format change is required.How was this change tested?
The initial registered-entry regression suite reproduced the defect on the base revision: 24 failures and 3 passes. The completed suite passes.
GNU make is unavailable on the local Windows host, so the Makefile recipes were executed directly in PowerShell:
make js-testrecipe: frozen pnpm installation, unit tests, build, generated-operation/bundlegit diff --exit-code, unit tests again, and live-Server e2e — 117 unit tests and 9 e2e tests passed, with no generated-output drift.make checkrecipe: generated integration-manifest documentation check, 26 integration-manifest tests,uv lock --locked,uv run prek run -a,uv run ty check, and the Pydantic AI integration type check — passed.make docs-testrecipe: strict clean Zensical build with the canonical OpenAPI copy, API-page existence check, and published-contract byte equivalence — passed.git diff --cached --check— passed.Regression coverage includes resolver and operation failures, required-route versus business 404s, authentication, timeout, cancellation, unresolved Scope, safe error output, diagnostic writer failures and cooldown, Scope-independent commands, and exact-Scope stats. The live-Server case verifies that a nonexistent explicit Scope fails direct operations while doctor/capabilities remain usable.
Upstream CI also passed
dsh-package(make js-test),quality(make checkandmake contract-test),check-docs(make docs-test), and the license-header check on commitc776cddf.AI usage statement
OpenAI Codex assisted with investigation, implementation, regression tests, documentation, and validation.