Repository navigation
feat(sdk): client.plan(...) gives the request a call would send, and with_options sets a call's options - #577
Merged
Merged
Conversation
…d `with_options` sets a call's options `tracker.plan(lambda tracker: tracker.issues.update(...))` returns the first write the call would send, not sent: its method, URL and body with secrets masked, and whether it would grant access (#556, question 2). What the call reads before that write is read for real; nothing after it runs. A call that sends no write is an error: there is nothing to plan. It is the SDK's side of one mechanism: the core stops the first write under `dry_run` and raises `RequestPlanned` (#557); the CLI's command wrapper and the MCP server's layer catch it, and here `plan` does, so a caller gets a value and catches nothing. `client.with_options(timeout_seconds=..., retries=..., dry_run=...)` is the client for the calls made through what it returns: a view over the same connections and credentials, with nothing of its own to close. The options are validated like the configuration they stand in for. A session has the same method, the asynchronous one too. A plan that is only shown now says whether its request grants access, as one that is asked about did: the same lines as in the `dry_run` change of the MCP server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was previously deployed
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.
The SDK's way to ask "what would this send":
client.plan(...)returns the request as a value. Decision: #556 (question 2, B). With it,client.with_options(...), which the plan is built on.plan(call)PlannedRequest: the method, the URL and the body of the FIRST writecallwould send, secrets masked by the function the CLI's--dry-runusescallYandexInvalidRequestError: "the call sends no write: nothing to plan"planned.grants_accessisTruecallis given a view of it underdry_runThe docstring says so with an
input -> outputexample that runs as a doctest (a delete planned, and the error for a read).It is one mechanism on three surfaces: the core stops the first write under
dry_runand raisesRequestPlanned(#557); the CLI's command wrapper catches it, the MCP server's layer catches it (#576), and hereplandoes.with_options(timeout_seconds=, retries=, dry_run=)Not in the ten lines of #556, which called it: it did not exist. It is the per-call options of the SDK (the accepted idea, taken whole as #556 said: timeout, retries, dry run).
withon it does not close the client it came from.retries=-1,timeout_seconds=0are refused).SyncSession.with_optionsandAsyncSession.with_optionsare the same thing one level down.The asynchronous side
There is no asynchronous domain client in ycli (the asynchronous how-to works with
connect_asyncand endpoints), so there is no asynchronousplan. The asynchronous session haswith_options, tested: underdry_run=Truea write raisesRequestPlannedand a read goes out.Shared with #576
core/guard.py: a plan that is only shown now says whether its request grants access. The lines are the same as in #576, word for word, so whichever lands second merges without a conflict (checked:git merge-treeof the two heads has none).Can
plansend?with_optionscopies the client and wires its resources over the view's session.planis safe only if nothing reachable from the view still holds the session of the client.self.boards = getattr(self, "boards", None) or …): the walk namesclient.boards._session, and two plan tests fail with ittests/contract/test_sdk_plan.py: every contract case that writes, called throughclient.plan(...)--dry-run -o jsonprintsdry_run=Falsemade from a dry-run view sendscallraises before any write (a 404 on a read inside it, or an error of the caller's own)Coverage of the drive: 406 write cases of 264 operations, all of them through
client.plan; 396 have a command and are compared with its plan, 10 have none and are held to "no write sent" only.Tests
grants_accessdry_runon and off for a view; the asynchronous sessionVerified
On this head, over main
6b6c1787(0.140.0; the commit's parent, by hash): ruff, ty, lint-imports, ast-grep (each by exit code, 0), the commit hooks over the commit (exit 0), rulesync and the generated reference without drift; the full suite: 7467 passed, 5 skipped, coverage 100 %.Seen once and not again, not traced: in one partial run a snapshot test (
mcp_output_schemas,wiki_grids_create) failed with another hash; regenerating the snapshot changed nothing and three later runs, the full suite among them, passed.NOT RUN: any live run.
🤖 Generated with Claude Code