Refuse a `CapabilityCreation` run when `directory` is below `'operator'` authority
- Part of #12484
CapabilityCreation imports and runs the Python in its directory as the operator's. The check before a run only asked for a writable local workspace, so a directory in a cloned repository or a user's upload passed it. A run now also refuses to start unless Workspace.authority_of(directory) is 'operator'.
[!WARNING]
Compatibility impact: A directory outside the workspace's working directory, such as LocalWorkspace('./project') with CapabilityCreation(Path('.authored')), now raises UserError at the start of a run, because authority_of gives a path outside the workspace 'none'.
Why this can ship in a minor release: It's a security hardening of an opt-in capability, and it fails closed with an error that says what to do. The docs did allow this placement (directory is "not a workspace path"), and they now state the requirement.
Migration: Name the directory: LocalWorkspace('./project', path_authority={'/abs/path/.authored': 'operator'}).
| Store directory | Before | Now |
|---|---|---|
| In an operator workspace | runs | runs |
In a workspace at 'user' or 'none' | runs | refused |
Under path_authority={'vendor': 'none'} in an operator workspace, or a link to such a path | runs | refused |
Named 'operator' in a workspace at 'none' | runs | runs |
| Outside the working directory, not named | runs | refused |
Outside the working directory, named 'operator' | runs | runs |
Notes for review:
- Deferred loading. A capability loaded mid-run with
load_capabilityskipsbefore_run, so without another checkauthor_capabilityran its code in any workspace, and the writable local workspace check was skipped the same way. The checks now also run before each authoring tool, which fails the run. Under Temporal, a deferredCapabilityCreationis already refused when it loads, because its toolset can't be added at runtime. - The directory is read against the process's directory.
directoryis not a workspace path, so a relative one is made absolute first; passed as is,authority_ofwould ask about the wrong location. Reading it blocks and can't happen in workflow code, so it's a durable operation.tests/harness/capability_creation/test_temporal.pyruns the check on a real sandboxed worker. store.load_active()isn't covered. It's called before the run and has no workspace to ask, so it runs what it finds. The docs say so, along with thatdirectorymust hold only operator-written or authored code. #12484 stays open for aworkspaceargument on it.- A wrapper overriding the
authorityproperty isn't seen.authority_ofreads the wrapper layers, as its docstring says, so such a wrapper passes this check. Setting authority goes throughAuthorityWorkspace, and this PR doesn't change that. - Under durable execution, the check adds units at the start of each run and before each authoring tool call (the directory read, plus
realpathcalls), which changes the event history of a workflow in flight during an upgrade.
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