Skip to content

Allow OpenClaw automation create commands - #173

Open
sauagarwa wants to merge 47 commits into
validatedpatterns-sandbox:mainfrom
sauagarwa:fix/openclaw-automation-create
Open

sauagarwa wants to merge 47 commits into
validatedpatterns-sandbox:mainfrom
sauagarwa:fix/openclaw-automation-create

Conversation

@sauagarwa

Copy link
Copy Markdown
Collaborator

Allow openclaw cron create and openclaw automations create through the tool gate with approval, matching the existing add behavior. Update the governance documentation and cover both aliases.

Validation: node --test charts/openshell-saw/files/installer/tool-gate.test.mjs (28 passed).

@sauagarwa
sauagarwa force-pushed the fix/openclaw-automation-create branch 2 times, most recently from 5050f76 to d73503e Compare November 19, 2026 04:18
A container user now needs only name, ownerSubject, profiles, vaultPrefix
and values.deployment.mode, like a VM entry.

saw-users:
- Derive registration (sha256 of name:generation), installationID (the
  portal's uuid5), the owner-scoped vaultPrefix, pruneOnRemove and
  intentGeneration; explicit values still win.
- Build each container site from a cluster-wide containerDefaults, overlaid
  by containerSites.<name>; subject defaults to the user's ownerSubject.
- Default every component revision to global.targetRevision so container
  workspaces follow the pattern branch like VM users.

saw-portal-container / projector:
- Accept a Git branch as well as a full SHA for stack, relay and enrollment
  revisions.
- Add automaticEnrollment.autoApprove for dev/demo clusters: enrollment
  still runs its health, admission and network checks, then publishes the
  observed boundary instead of comparing it with a reviewed reference.

Pattern and tooling:
- overrides/saw-container-defaults.yaml holds projection and
  containerDefaults; Alice's entry is reduced to the essentials.
- values-prod installs the Agent Sandbox controller.
- make container-topology also discovers the ApplicationSet controller
  labels, storage classes and containerDefaults egress.
- make keycloak-user-info KC_USER=<name> prints a user's subject.

Tests cover the derived fields, minimal entries, mixed VM and container
users, autoApprove and the topology discovery.

Assisted-By: Claude
Keep main's wording and add the create alias from the automation
commands change.

Assisted-By: Claude
make saw-init (scripts/saw-init.sh) prepares a cluster before
./pattern.sh make install or make saw-create. pattern-install and
saw-create for container/kata run it first. With container or kata users
it checks OVN-Kubernetes, AdminNetworkPolicy, ValidatingAdmissionPolicy and
an anonymous pull of the runtime image from inside the cluster, and
ensures a ReadWriteMany StorageClass for the audit exchange volume
(scripts/shared-storage.sh): without one it creates a small in-cluster NFS
server and provisioner (StorageClass saw-nfs, dev/demo) and verifies a
read/write mount; SAW_SHARED_STORAGE=efs offers EFS on AWS, none reports.

saw-users: a container user without ownerSubject on an installation
configured for containers waits (ConfigMap saw-users-awaiting-owner)
instead of failing the whole render. make saw-create accepts the minimal
entry with the chart's defaults and resolves an omitted subject from
Keycloak.

make container-topology finds the ApplicationSet controller by its
app.kubernetes.io/name label, fills missing storage classes and writes
plain YAML. Add the generated overrides/container-network.yaml for this
cluster to the saw-users value files.

README (both install options) and docs/container-installation.md describe
the flow.

Assisted-By: Claude
The stock OpenClaw image's /sandbox (0770, 1000:0) is not searchable by
OpenShift namespace UIDs, so the projector preflight refused alice
(WorkloadImageNotNamespaceAccessible). Point the data-science and
custom-inference notebooks at the in-cluster rebuild from
make container-notebook-image and grant pull access to its ImageStream.

Assisted-By: Claude
The custom-inference workspace chart needs the endpoint URL itself
(site.customInferenceURL), which comes from a site's profileBoundaries.
Declare it in containerDefaults and let a static entry take the
site-approved endpoint unless it names one; an autoApprove site needs no
reviewed boundary reference.

Assisted-By: Claude
Restore the audit writer's identity.subject ('@subject@'), lost when the
site became containerDefaults; the audit Application failed to render.

A dedicated-endpoint profile such as custom-inference gets no web-search
credential unless the entry asks for one, as the portal does at
registration; alice's web-search ExternalSecret had no Vault data.

Assisted-By: Claude
The runtime compiles a sandbox's model from public model inputs, never
from the credential Secret. Without one, alice's enrollment looped on
ContractError (invalid sandbox inference inputs). Set
modelInputs.inference.model on alice, and have the projector refuse a
static entry whose profile requires a model it does not name, instead of
an enrollment that never finishes.

Assisted-By: Claude
Its enrollment recorded the alice-gateway Service while it still carried
the VM workspace's selector, so the reconciler rejects the boundary
(BoundaryRejected) and cannot be repaired in place. Remove the
registration; alice comes back as generation 2.

Assisted-By: Claude
A fresh container registration (d2565216ccf6a6c0) on the fixed defaults:
rebuilt OpenClaw image, approved custom inference endpoint, model input,
no web search, restored audit identity.

Assisted-By: Claude
The published interceptor image predates mTLS operator access (118b4cf),
so it denies the container reconciler's CreateSandbox driver config.

Assisted-By: Claude
Remove the generated network overlay (this cluster's API, DNS and Keycloak
addresses), alice's entry, and images built in this cluster's registry or a
fork. Each site generates and lists its own overlay, as
docs/container-installation.md describes; image digests are placeholders.

Assisted-By: Claude
The portal layers containerDefaults under each user's site, looks up the
owner's Keycloak subject, follows the branch revision and honours
autoApprove, so the create form offers container mode without per-user
containerSites. Preflight accepts branch revisions as well as commit SHAs.

Assisted-By: Claude
Reviewed sites keep the full commit SHA pin on every chart; development sites
with automaticEnrollment.autoApprove may follow a branch, as saw-users and the
portal defaults do through global.targetRevision.

Assisted-By: Claude
A chart change starts a new enrollment Job. Under autoApprove it observed the
boundary again, now including the running workspace, and failed against the
immutable first publication. If this registration already published, report
it and exit; reviewed sites keep the strict comparison.

Assisted-By: Claude

@Hadar301 Hadar301 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three high-urgency issues block the merge:

  1. Production values enable dev-only auto-approval (overrides/saw-container-defaults.yaml:42-47). values-prod.yaml loads this file for saw-users and the self-service portal. The default enables autoApprove, which lets the portal offer every catalog profile and lets enrollment publish the first observed boundary and BOM without a reviewed reference or profile digest. Please keep this off in production values. Require the reviewed reference and approvedProfiles, and put auto-approval in a demo-only values file.

  2. A per-user false cannot disable default auto-approval (charts/saw-users/templates/_helpers.tpl:520-524). mergeOverwrite skips empty values, so containerSites.<name>.automaticEnrollment.autoApprove: false does not override a shared true. The chart projector then keeps auto-approval enabled, while the portal's Python merge accepts false. Please merge by explicit key presence and test that both paths honor the same per-user override.

  3. Install defaults to a privileged demo NFS stack (scripts/shared-storage.sh:115-124,229-230). saw-init runs this during pattern-install and make saw-create. If no recognized RWX class exists, the unset default creates a single-pod NFS server, grants it privileged SCC access, and adds a cluster-scoped provisioner role without an opt-in prompt. Please fail with guidance by default and require an explicit SAW_SHARED_STORAGE=nfs choice for the demo server.

GitHub also reports this PR as non-mergeable (dirty) and shows no check runs. Please resolve the merge state and run the required checks after these fixes.

Container workspaces now hand credentials to OpenShell providers and drop
SAW's credential proxy, its hard-coded provider list, and the boundary
checks that mirrored the proxy policy. The runtime controller reads each
site-approved Secret just in time and submits it with CreateProvider or
UpdateProvider. OpenShell's provider profiles decide which endpoints the
supervisor may substitute the credential for. Providers with
oauth2_refresh_token (Gmail) are configured through
ConfigureProviderRefresh and RotateProviderCredential.

- credentialBindings replaces proxyBindings throughout the site config
- saw-kubernetes-proxy chart removed; identity owns bootstrapEgress
- saw-runtime-policies: optional publicHTTPS lets supervisors reach
  public 443 while private ranges stay denied
- VM mode is unchanged

Assisted-By: Claude
…le catalog

The gateway adapter refused ListProviderProfiles, UpdateProvider and the
refresh RPCs, which test fakes accepted. A test now checks every RPC the
runtime calls against the allowlist. The controller fetched the provider
profile catalog in a second gateway session per cycle; each session waits
for the gateway to trust a fresh admin CA, so the catalog now comes from
the reconcile session.

Assisted-By: Claude
COPY keeps the builder's file modes, so a checkout with a private umask
produced an image UID 1001 could not import. Normalize the modes and run
the import check as the runtime user so the build fails instead.

Assisted-By: Claude
harness.yaml lists tools per MCP server with allow or approval. The rules
follow the base tool-actions.yaml in the gate policy, so the pinned policy
hash and gate digest cover them and a base rule for the same tool still
decides. A bundle can only name its own servers' tools. Container
workspaces apply them; VM workspaces keep the base policy.

Assisted-By: Claude
Native providers made preflight require site.credentialBindings, which
saw-users renders into the site from the profile's secrets. The portal runs
preflight before anything renders, so every container request failed with
ProviderEgressRejected. Derive the same list from the catalog entry.

Assisted-By: Claude
@sauagarwa
sauagarwa force-pushed the fix/openclaw-automation-create branch from a440492 to 64770a8 Compare November 23, 2026 14:57
Sprig's mergeOverwrite skips empty values, so containerSites.<name> could not
set automaticEnrollment.autoApprove (or any key) to false over a shared true,
while the portal's Python merge could. saw-users.deepMerge merges maps by key
presence and replaces every other value, matching the portal. Tests cover the
same override on the static, projected and portal paths.

Assisted-By: Claude
values-prod.yaml loads saw-container-defaults.yaml for saw-users and the
portal, and it enabled autoApprove. Production defaults now keep enrollment
off until an operator reviews the boundary and sets the reference,
approvedProfiles and pinned revisions per user. Auto-approval moves to
overrides/saw-container-demo.yaml, which demo clusters list explicitly.

Assisted-By: Claude
saw-init runs shared-storage.sh during pattern-install and make saw-create.
With no shared-filesystem class and SAW_SHARED_STORAGE unset, it created a
privileged NFS server and a cluster-scoped provisioner role without asking.
It now fails with the options; SAW_SHARED_STORAGE=nfs creates the demo
server. Tests drive the script with a fake oc.

Assisted-By: Claude
helm lint reports a missing required value as a warning and returns "",
so ranging over required ... credentialBindings failed the chart with
"range can't iterate over". Default the result to an empty list; real
installs still fail when the bindings are missing.

Assisted-By: Claude
values-prod.yaml now lists saw-container-defaults.yaml before saw-users.yaml.
The test also checks that no application lists the demo-only file and that
the defaults keep enrollment and auto-approval off.

Assisted-By: Claude
make saw-create now runs scripts/saw-init.sh before the container apply, so
the test's scripts directory needs it. The stub also checks that only
saw-create runs it.

Assisted-By: Claude

@Hadar301 Hadar301 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One high-urgency issue remains in charts/openshell-saw/files/installer/saw_core.py:1327-1328. The harness tool-rule builder inserts an MCP server name into policy text without validating or escaping it. A name containing newlines can inject an unconditional allow rule for exec, which can bypass the tool gate's default-deny behavior. Please reject names that do not match MCP_SERVER_NAME_RE before building rules, serialize policy fields safely, and add a regression check for invalid names.

Optional:
The PR title and body describe only the OpenClaw command aliases, but the diff spans 94 files and includes container/Kata provisioning, provider credentials, network policy, and shared storage. Please update the PR description or split the unrelated changes. The latest available check snapshot still had the Python 3.12 and 3.14 test jobs in progress; wait for required checks to finish before merge.

Preflight demanded commit SHAs for reviewed sites, but the saw-users chart and
the portal filled every unset revision with global.targetRevision, and the
workspace chart accepted any branch. Only autoApprove sites now follow the
branch; a reviewed site keeps its revisions unset until the operator pins
them, and the workspace chart fails on a branch or a missing revision, as
preflight does. Production values no longer advertise Container in the
portal; the demo file does.

Assisted-By: Claude
The portal writes only Gmail's client_id, client_secret and refresh_token to
Vault, but the ExternalSecret also synced access_token and the reconciler read
it to create the provider, so Gmail never started. The ExternalSecret now
syncs only the refresh material, and the reconciler creates the provider
without a credential value (the profile's oauth2_refresh_token strategy lets
OpenShell mint it), sends only OpenShell Provider fields (the gateway rejects
the plan's refresh field), and accepts the version bumps each minted token
causes. Tests check that every synced Vault property is one the profile
collects, and that refresh converges after OpenShell rewrites the provider.

Assisted-By: Claude
OpenShell attaches a provider's credential to its profile's endpoints, and
container supervisors may open public TCP/443, but nothing checked those
endpoints once the credential proxy was removed. Before creating a provider,
the reconciler now requires the live profile's endpoints to be exactly the
approved set, all enforced and without raw IP allowances: the governed
profile shipped with the runtime image, or for custom-inference only the
site URL's host on 443. Anything else stops with ProviderProfileMismatch.

Assisted-By: Claude
A rotated Secret's UpdateProvider recorded the new source only when the
reply had a body. After a lost reply, or a replay answering ALREADY_EXISTS,
the provider's version no longer matched and the update never converged.
The reconciler now persists the update intent before the RPC, as creates
do. On the next pass, if the provider moved on from the version it updated
and still holds exactly its credential slot, it records that; if not
applied, it resends the same request ID; if the provider changed shape, it
fails closed.

Assisted-By: Claude
The reconciler recorded a refresh as configured right after sending the
material, even when both RPC replies were lost, so a lost configure was
never retried; and an empty refresh status failed the workspace. Sent and
confirmed are now separate: a revision counts as configured only once the
gateway's status shows the credential without an error, an empty status is
pending, and a configure without an acknowledged reply is sent again with
the same request ID. A refresh that disappears after working is reported.
ProviderRefreshFailed is now an allowed status reason, so it is published.

Assisted-By: Claude
Workspaces enrolled by the credential-proxy controller failed after upgrade
with a generic BoundaryRejected or ProviderRejected. An approval that still
lists the removed proxy objects now fails with ReenrollRequired, and
controller state holding proxy-era provider records stops with the same
reason before any gateway call, so old providers are never adopted. The
reason is published to the portal; the docs describe re-enrolling with a new
generation.

Assisted-By: Claude
The stock OpenClaw image's /sandbox (0770, 1000:0) cannot be searched by
OpenShift namespace UIDs, and OpenShell cannot fix it either: its own
workspace seeding reads that directory as the same UID. Clusters built the
one-line fix in-cluster (make container-notebook-image). A workflow now
builds images/saw-openclaw/Containerfile from the notebook BOM's pinned image
on main and publishes ghcr.io/<repository owner>/saw-openclaw for
linux/amd64 and linux/arm64, tagged src-<source digest prefix>.

Assisted-By: Claude
The defaults pinned an image each cluster had to build into its internal
registry, plus imagePull access to it. They now name the public image the
build-openclaw-image workflow publishes; the digest is filled in after its
first build. In-cluster builds remain for disconnected clusters.

Assisted-By: Claude
ghcr.io/sauagarwa/saw-openclaw@sha256:05f17f38… is the amd64 build of the
notebook BOM's source image (tag 896d1526ee29-amd64). Switch to the
workflow's multi-arch src-896d1526ee29 digest once it publishes.

Assisted-By: Claude
…nce profile

The URL lived in four places: the owner's Vault entry, a site-level
profileBoundaries.custom-inference (inferenceBaseURL and allowHosts), the
site copy compiled into the agent, and the custom-inference governance
profile's host. The site-level copies only restated the other two. A
workspace now uses its owner's own URL (the portal form, or
customInferenceURL in a saw-users entry), checked for an HTTPS /v1 DNS
URL; the governance profile remains the approval, enforced by the runtime
controller before the key is handed to OpenShell. profileBoundaries keeps
its per-profile reviewed reference.

Assisted-By: Claude
overrides/saw-container-defaults.yaml repeated wiring that is the same on
every cluster: namespaces, service accounts, SANs, the workspace egress
policy, the governance endpoint and its egress, the enrollment build
namespace, resources and relay Keycloak settings. These now live in
saw-portal-container's siteDefaults, and a site sets only what differs.
The defaults file keeps the image pins and the runtime image.

- The gateway's default sandbox image is the first target's image, and
  its interceptor endpoint and egress follow governanceNamespace.
- Workspaces share one AdminNetworkPolicy priority: each policy selects
  only its own namespace, and enrollment already refuses an earlier
  overlapping policy.
- Enrollment runs only when a site sets automaticEnrollment.enabled: true.
- autoApprove sites get a revision for every stack component, even one
  the site does not list.
- make container-topology no longer needs gateway and relay blocks in the
  base file.

Assisted-By: Claude
An amd64 build of this branch (fe412b2), published to
ghcr.io/sauagarwa until the build-kubernetes-runtime workflow publishes
the image from main.

Assisted-By: Claude
A harness bundle's MCP server name went into tool-actions.yaml unchecked.
A name with newlines could add an unconditional allow rule for exec and
get past the tool gate's default deny.

- Reject a server name that is not 1-64 letters, digits, '_' or '-'
  before building its tool rules.
- Check every rule again when writing the policy: exactly id, tool and
  action; a <server>__<tool> name, never a bare tool such as exec; an
  allow or approval action; and only characters the policy reads
  verbatim.
- Add regression tests for the newline injection and each invalid rule
  shape.

Assisted-By: Claude
Every automation change (create, edit, rm, enable, disable, run) asked for
approval, which is tiring when an agent reworks a schedule. Its approval
card now also offers "Allow always". Later automation changes then run
without asking until the gateway restarts or the policy changes.

- A rule opts in with allowAlways: true, which is valid only on an
  approval rule. Only exec-openclaw-automation-change sets it; git push,
  rm, set-identity and every other approval rule still ask each time.
- The approval is remembered only once its resolution is in the audit
  trail. Each later call is still audited, with approval.mode
  "remembered".
- Commands that match no rule are still denied.

Assisted-By: Claude
The gate log showed agents losing time on blocked calls: `openclaw
automations list --all 2>&1`, two `show` calls chained with `;`, and
`--help` piped to `head`. Each got only "exec-opaque", so the agent
guessed at variants until one passed.

- Ignore a trailing 2>&1, which only merges stderr into stdout. Any
  other redirect, chain or wrapper is still opaque.
- Allow `openclaw cron --help` and `openclaw automations --help` as
  read-only inspection.
- Say how to retry: an opaque call gets "run one command per exec
  call...", and an unlisted command gets "not on the allowed list, so
  do not retry it in another form".

Assisted-By: Claude
Agents reach for `openclaw automations remove` and `--help` on change
commands. remove was denied with no way forward, and `edit --help`
asked for approval like a real edit.

- rm, remove and delete all ask for approval, with Allow always as for
  the other automation changes.
- `<command> --help` for every automation command runs directly.
- An unlisted command lists the accepted commands that share its first
  two words, split into those that run directly and those that ask for
  approval, so the agent can use a working spelling.

Assisted-By: Claude
Hadar301
Hadar301 previously approved these changes Nov 23, 2026

@Hadar301 Hadar301 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

OpenClaw offers only "default" and "off" thinking for a custom provider's
model, so `/think medium` was refused for the custom-inference model.

- A sandbox's `inference.thinking` (off, minimal, low, medium or high)
  becomes that model's default thinking level
  (agents.defaults.models["<model>"].params.thinking). A chat's /think
  still overrides it.
- Any level other than off also marks the model's entry reasoning: true,
  with compat.supportedReasoningEfforts [low, medium, high]. OpenClaw then
  offers those levels and sends reasoning_effort.
- Removing the setting removes the default it set.
- VM workspaces only for now; the container runtime builds the OpenClaw
  config separately.

Assisted-By: Claude
`inference.thinking: off` set only the default level. The model entry kept
whatever reasoning flag it had, including one an earlier level set. Off
now also sets reasoning: false and drops the effort list, matching
MODEL_REASONING=false, so OpenClaw sends no reasoning_effort.

Assisted-By: Claude
YAML 1.1 reads `off` as false, so a profile with `thinking: off` failed
validation with "thinking must be one of ...". Treat false as off.

Assisted-By: Claude

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants