Add `authority` and `path_authority` to the sandbox and `SSHWorkspace` capabilities

Merged
DO
18d ago
+520-15

Reading guide: read with_authority in pydantic_ai_harness/_workspace.py and one capability, such as docker_container/_capability.py. The other capabilities get the same two fields and the same three-line get_workspace wrapper, so you can skim them. The key decision is the API shape: authority and path_authority copy LocalWorkspace exactly. The one difference is that paths are sandbox or host paths, so ~ isn't expanded, the same rule AuthorityWorkspace uses. BubblewrapSandbox is left out on purpose: it wraps another workspace capability, which already takes authority.

DockerContainer, E2BSandbox, KubernetesSandbox, ModalSandbox, DaytonaSandbox, BoxdSandbox, BoxLiteSandbox, OpenSandbox, RenderSandbox, SmolSandbox, SpritesSandbox and SSHWorkspace take authority and path_authority, like LocalWorkspace. When either is set below 'operator', the run's workspace is wrapped in an AuthorityWorkspace, for new and attached sandboxes alike. Before this, someone running an agent on an untrusted checkout in a sandbox or over SSH had to wrap the backend by hand.

  • get_workspace builds the backend as before (now _run_backend) and passes it through the shared with_authority helper. The defaults change nothing.
  • Tests: DockerSandbox and SSHWorkspace (with read_only=True too) check authority_of from a tool and that the workspace ref is still the backend's.
  • Docs: docs/workspace.md and the harness CODING-AND-WORKSPACES reference. Each field's docstring appears on its capability's API page.

Takeover notes

  • Merged the latest main (conflicts were adjacent field additions: boxd secrets, E2B network, the harness skill's working_dir row; both sides kept).
  • KubernetesSandbox landed on main after this PR opened, so it gets the same two fields, from_spec arguments, docs rows and tests (authority_of from a tool, and the run still closes its connection through the AuthorityWorkspace). Decision: include it here rather than a follow-up, since the issue asks for every sandbox capability.
  • Harness-only change; no core code outside pydantic_ai_harness.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.

šŸ¤– Generated with Claude Code