From 0ca6a23cc8e5d4afaa03dca2d36d3989faf670bf Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Thu, 12 Nov 2026 10:50:42 -0500 Subject: [PATCH 01/24] Configure Alice custom inference workspace --- .../governance-profiles/custom-inference.yaml | 2 +- overrides/saw-users.yaml | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/overrides/governance-profiles/custom-inference.yaml b/overrides/governance-profiles/custom-inference.yaml index 08bcbf272..06e8a1a2b 100644 --- a/overrides/governance-profiles/custom-inference.yaml +++ b/overrides/governance-profiles/custom-inference.yaml @@ -18,7 +18,7 @@ credentials: discovery: credentials: [api_key] endpoints: - - host: api.inference.example.com # the host of the `url` in the inference Secret + - host: api.enmaas.devshift.net # the host of the `url` in the inference Secret port: 443 # its port (443 for https without one, 8000 for a vLLM Service) protocol: rest enforcement: enforce diff --git a/overrides/saw-users.yaml b/overrides/saw-users.yaml index 00565bad3..6d54fc8a9 100644 --- a/overrides/saw-users.yaml +++ b/overrides/saw-users.yaml @@ -15,12 +15,15 @@ # inference.model: # values: # deployment: {mode: container} -users: [] +users: + - name: alice + profiles: + - custom-inference # Opt in only for users of a configured custom-inference endpoint. Match # the hostname in overrides/governance-profiles/custom-inference.yaml. -# defaults: -# openshellSaw: -# egress: -# extraAllow: -# - api.inference.example.com +defaults: + openshellSaw: + egress: + extraAllow: + - api.enmaas.devshift.net From c0ca6cb738f264a8cb1cf680c5c49f6d21369b9c Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Mon, 16 Nov 2026 12:59:41 -0500 Subject: [PATCH 02/24] Allow OpenClaw automation create commands --- docs/openshell-016-release.md | 21 +++++++++++++++++++ .../governance-profiles/custom-inference.yaml | 2 +- overrides/saw-users.yaml | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/openshell-016-release.md b/docs/openshell-016-release.md index 09e3745bd..26c66d2a8 100644 --- a/docs/openshell-016-release.md +++ b/docs/openshell-016-release.md @@ -80,6 +80,7 @@ or `~/.local/state/openshell/confinement-stops.json` without a ledger. Do not remove it to bypass recovery. A configured agent can resume without a usable provider while retaining its model/credentials; unchanged reapply leaves it running. +<<<<<<< HEAD In OpenClaw 2026.9.6, `automations` aliases `cron`. Only `list`, `status`, `get`, `show` and `runs` need no approval; `add`/`create`, `edit`, `rm`, `enable`, `disable` and `run` require it. Unsupported aliases (`remove`, `delete`), mixed @@ -88,3 +89,23 @@ commands and shell wrappers remain denied. Every `agents set-identity` call requires approval: its file/avatar inputs can reach outside the workspace and it rewrites configuration, beyond filesystem-tool confinement. Denial, cancellation or timeout prevents execution. See the [governance guide](governance-interceptor.md). +======= +OpenClaw `automations` aliases `cron` in the pinned 2026.9.6 release. Both +allow only `list`, `status`, `get`, `show`, and `runs` without approval. +`add`/`create`, `edit`, `rm`, `enable`, `disable`, and `run` require approval. Unsupported +aliases (`remove`, `delete`), the mixed read/write `scratch` interface +and unknown commands stay denied. Shell wrappers, chaining, substitutions +and conflicting command representations remain denied. Command registration +was verified against the upstream release's +[`register.ts`](https://github.com/openclaw/openclaw/blob/v2026.9.6/src/cli/cron-cli/register.ts), +[`register.cron-add.ts`](https://github.com/openclaw/openclaw/blob/v2026.9.6/src/cli/cron-cli/register.cron-add.ts), +[`register.cron-simple.ts`](https://github.com/openclaw/openclaw/blob/v2026.9.6/src/cli/cron-cli/register.cron-simple.ts) +and [`register.cron-edit.ts`](https://github.com/openclaw/openclaw/blob/v2026.9.6/src/cli/cron-cli/register.cron-edit.ts). + +`openclaw agents set-identity` requires approval for every invocation, including +ordinary name changes. In the pinned OpenClaw version, `--identity-file` can +read arbitrary paths and `--avatar` accepts HTTP(S) and data URIs; the command +also rewrites `openclaw.json`. Filesystem-tool workspace confinement does not +limit this CLI command. Cancelled, denied or timed-out approvals do not run it; +shell wrappers, chaining and substitutions remain denied. +>>>>>>> 552a620f (Allow OpenClaw automation create commands) diff --git a/overrides/governance-profiles/custom-inference.yaml b/overrides/governance-profiles/custom-inference.yaml index 06e8a1a2b..a58dfd7ee 100644 --- a/overrides/governance-profiles/custom-inference.yaml +++ b/overrides/governance-profiles/custom-inference.yaml @@ -18,7 +18,7 @@ credentials: discovery: credentials: [api_key] endpoints: - - host: api.enmaas.devshift.net # the host of the `url` in the inference Secret + - host: api.inference.example.com # the host of the `url` in the inference Secret port: 443 # its port (443 for https without one, 8000 for a vLLM Service) protocol: rest enforcement: enforce diff --git a/overrides/saw-users.yaml b/overrides/saw-users.yaml index 6d54fc8a9..6b7a1f176 100644 --- a/overrides/saw-users.yaml +++ b/overrides/saw-users.yaml @@ -26,4 +26,4 @@ defaults: openshellSaw: egress: extraAllow: - - api.enmaas.devshift.net + - api.inference.example.com From 124d26fadd5db0e95d7b31bd22ca86c7fea8c0cf Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Wed, 18 Nov 2026 15:09:36 -0500 Subject: [PATCH 03/24] Update custom inference server --- overrides/governance-profiles/custom-inference.yaml | 2 +- overrides/saw-users.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/overrides/governance-profiles/custom-inference.yaml b/overrides/governance-profiles/custom-inference.yaml index a58dfd7ee..06e8a1a2b 100644 --- a/overrides/governance-profiles/custom-inference.yaml +++ b/overrides/governance-profiles/custom-inference.yaml @@ -18,7 +18,7 @@ credentials: discovery: credentials: [api_key] endpoints: - - host: api.inference.example.com # the host of the `url` in the inference Secret + - host: api.enmaas.devshift.net # the host of the `url` in the inference Secret port: 443 # its port (443 for https without one, 8000 for a vLLM Service) protocol: rest enforcement: enforce diff --git a/overrides/saw-users.yaml b/overrides/saw-users.yaml index 6b7a1f176..6d54fc8a9 100644 --- a/overrides/saw-users.yaml +++ b/overrides/saw-users.yaml @@ -26,4 +26,4 @@ defaults: openshellSaw: egress: extraAllow: - - api.inference.example.com + - api.enmaas.devshift.net From 91f1b8c699886a16b606daa6f40e810223b0c2c1 Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Wed, 18 Nov 2026 23:02:06 +0000 Subject: [PATCH 04/24] Simplify container-mode saw-users entries for static GitOps 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.; 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= 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 --- overrides/saw-users.yaml | 22 +++----- tests/charts/test_saw_users_chart.py | 83 ++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 14 deletions(-) diff --git a/overrides/saw-users.yaml b/overrides/saw-users.yaml index 6d54fc8a9..3bd3fb0e0 100644 --- a/overrides/saw-users.yaml +++ b/overrides/saw-users.yaml @@ -3,22 +3,16 @@ # # Container workspaces: set the mode, the Keycloak subject # (make keycloak-user-info KC_USER=) and the credential base path. -# Credentials are read from /saw-/inference (every generation). -# To start over with a fresh workspace, remove the entry, let Argo delete it, -# then add it back with a higher generation (two pushes). -# - name: alice -# ownerSubject: -# profiles: [custom-inference] -# vaultPrefix: secret/data/hub -# customInferenceURL: https:///v1 # custom-inference only -# modelInputs: -# inference.model: -# values: -# deployment: {mode: container} +# Credentials are read from /saw-//inference. +# Bump generation to start over with a fresh workspace. users: - name: alice - profiles: - - custom-inference + ownerSubject: 9a30e84e-2a47-4b88-a2c2-7ba2bddc6dbf + profiles: [custom-inference] + vaultPrefix: secret/data/hub + values: + deployment: {mode: container} + # Opt in only for users of a configured custom-inference endpoint. Match # the hostname in overrides/governance-profiles/custom-inference.yaml. diff --git a/tests/charts/test_saw_users_chart.py b/tests/charts/test_saw_users_chart.py index 4311ad49c..eb1852e0a 100644 --- a/tests/charts/test_saw_users_chart.py +++ b/tests/charts/test_saw_users_chart.py @@ -216,6 +216,89 @@ def test_container_entry_without_defaults_or_site_fails(tmp_path): assert result.returncode != 0 and "requires containerDefaults or a containerSites entry" in result.stderr +def container_alice(**extra): + site = yaml.safe_load((ROOT / "tests/fixtures/container-site.yaml").read_text())["portal"]["containerSites"]["alice"] + user = {"name": "alice", "registration": "3f9a1c0e7b2d4a68", "ownerSubject": site["subject"], + "profiles": ["data-science"], "intentGeneration": 1, "pruneOnRemove": True, + "vaultPrefix": "secret/data/hub/saw-alice/3f9a1c0e7b2d4a68", + "values": {"deployment": {"mode": "container"}}, **extra} + return user, {"containerSites": {"alice": site}} + + +@pytest.mark.parametrize(("given", "expected"), [ + (None, "c4d7d813-fd00-5645-b4b9-7b73e372d0dd"), # uuid5 of urn:saw:portal:alice:3f9a1c0e7b2d4a68 + ("22222222-2222-4222-8222-222222222222", "22222222-2222-4222-8222-222222222222"), +]) +def test_container_installation_id_defaults_to_portal_uuid5(tmp_path, given, expected): + user, extra = container_alice(**({"installationID": given} if given else {})) + docs = docs_from(render_file(tmp_path, [user], extra)) + namespace = [d for d in by_kind(docs, "Namespace") if d["metadata"]["name"] == "saw-alice"][0] + assert namespace["metadata"]["labels"]["saw.redhat.com/runtime-owner"] == expected + assert helm_values(app(docs, "saw-alice"))["installationID"] == expected + + +def test_minimal_container_entry_uses_cluster_defaults(tmp_path): + site = yaml.safe_load((ROOT / "tests/fixtures/container-site.yaml").read_text())["portal"]["containerSites"]["alice"] + subject = site.pop("subject") + for item in site["stack"].values(): + item.pop("revision") + site["automaticEnrollment"].pop("revision") + site["automaticEnrollment"]["relay"].pop("revision") + user = {"name": "alice", "ownerSubject": subject, "profiles": ["data-science"], + "vaultPrefix": "secret/data/hub", "values": {"deployment": {"mode": "container"}}} + docs = docs_from(render_file(tmp_path, [user], {"containerDefaults": site})) + values = helm_values(app(docs, "saw-alice")) + registration = "1f732dc2bd1766a0" # sha256("alice:1")[:16] + assert values["registration"] == registration + assert values["installationID"] == "a4300afa-4ae4-5da1-a5b1-44e50a34eb59" + assert values["vaultPrefix"] == "secret/data/hub/saw-alice/" + registration + assert values["site"]["subject"] == subject + assert {item["revision"] for item in values["site"]["stack"].values()} == {"main"} + assert values["site"]["automaticEnrollment"]["relay"]["revision"] == "main" + + +def test_vm_and_container_users_coexist(tmp_path): + site = yaml.safe_load((ROOT / "tests/fixtures/container-site.yaml").read_text())["portal"]["containerSites"]["alice"] + subject = site.pop("subject") + alice = {"name": "alice", "ownerSubject": subject, "profiles": ["data-science"], + "vaultPrefix": "secret/data/hub", "values": {"deployment": {"mode": "container"}}} + bob = {"name": "bob"} + projection = {"enabled": True, "applicationSetControllerLabels": { + "app.kubernetes.io/name": "vp-gitops-applicationset-controller"}, + "egress": [{"to": [{"ipBlock": {"cidr": "10.0.0.3/32"}}], + "ports": [{"protocol": "TCP", "port": 6443}]}]} + extra = {"containerDefaults": site, "projection": projection, "ownerResolution": {"enabled": True}} + mixed = docs_from(render_file(tmp_path, [alice, bob], extra)) + (tmp_path / "vm").mkdir() + alone = docs_from(render_file(tmp_path / "vm", [bob], {"ownerResolution": {"enabled": True}})) + + # Bob's VM resources are exactly what a VM-only list renders. + def bobs(docs): + return sorted((d["kind"], d["metadata"]["name"], json.dumps(d, sort_keys=True)) for d in docs + if d["metadata"].get("labels", {}).get("openshell.pattern/owner") == "bob" + or d["metadata"].get("namespace") == "saw-bob" or d["metadata"]["name"] == "saw-bob") + assert bobs(mixed) and bobs(mixed) == bobs(alone) + assert {"saw-bob", "saw-bob-secrets", "saw-bob-bom"} <= {d["metadata"]["name"] for d in by_kind(mixed, "Application")} + + # Alice goes through the projector only: no direct Application or Namespace. + names = {(d["kind"], d["metadata"]["name"]) for d in mixed} + assert ("Application", "saw-alice") not in names and ("Namespace", "saw-alice") not in names + config = [d for d in by_kind(mixed, "ConfigMap") if d["metadata"]["name"].endswith("-configuration")] + workspaces = json.loads(config[0]["data"]["workspaces.json"]) + assert [u["name"] for u in workspaces["users"]] == ["alice"] + assert list(workspaces["containerSites"]) == ["alice"] + assert workspaces["containerSites"]["alice"]["subject"] == subject + assert workspaces["users"][0]["registration"] == "1f732dc2bd1766a0" + assert "containerDefaults" not in workspaces + + +def test_container_entry_without_defaults_or_site_fails(tmp_path): + user = {"name": "alice", "ownerSubject": "11111111-1111-4111-8111-111111111111", + "profiles": ["data-science"], "values": {"deployment": {"mode": "container"}}} + result = render_file(tmp_path, [user]) + assert result.returncode != 0 and "requires containerDefaults or a containerSites entry" in result.stderr + + def test_static_owner_revision_pin_selects_all_children_and_preserves_sibling(tmp_path): docs = docs_from(render_file(tmp_path, [ALICE, {"name": "bob"}], {"workspaceRevisions": {"alice": "a"*40}})) From 1a0b143b2f1f78d83e16d748ed2e0f697f62337a Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Wed, 18 Nov 2026 23:03:18 +0000 Subject: [PATCH 05/24] Resolve leftover rebase conflict in OpenShell 0.1.6 release notes Keep main's wording and add the create alias from the automation commands change. Assisted-By: Claude --- docs/openshell-016-release.md | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/docs/openshell-016-release.md b/docs/openshell-016-release.md index 26c66d2a8..09e3745bd 100644 --- a/docs/openshell-016-release.md +++ b/docs/openshell-016-release.md @@ -80,7 +80,6 @@ or `~/.local/state/openshell/confinement-stops.json` without a ledger. Do not remove it to bypass recovery. A configured agent can resume without a usable provider while retaining its model/credentials; unchanged reapply leaves it running. -<<<<<<< HEAD In OpenClaw 2026.9.6, `automations` aliases `cron`. Only `list`, `status`, `get`, `show` and `runs` need no approval; `add`/`create`, `edit`, `rm`, `enable`, `disable` and `run` require it. Unsupported aliases (`remove`, `delete`), mixed @@ -89,23 +88,3 @@ commands and shell wrappers remain denied. Every `agents set-identity` call requires approval: its file/avatar inputs can reach outside the workspace and it rewrites configuration, beyond filesystem-tool confinement. Denial, cancellation or timeout prevents execution. See the [governance guide](governance-interceptor.md). -======= -OpenClaw `automations` aliases `cron` in the pinned 2026.9.6 release. Both -allow only `list`, `status`, `get`, `show`, and `runs` without approval. -`add`/`create`, `edit`, `rm`, `enable`, `disable`, and `run` require approval. Unsupported -aliases (`remove`, `delete`), the mixed read/write `scratch` interface -and unknown commands stay denied. Shell wrappers, chaining, substitutions -and conflicting command representations remain denied. Command registration -was verified against the upstream release's -[`register.ts`](https://github.com/openclaw/openclaw/blob/v2026.9.6/src/cli/cron-cli/register.ts), -[`register.cron-add.ts`](https://github.com/openclaw/openclaw/blob/v2026.9.6/src/cli/cron-cli/register.cron-add.ts), -[`register.cron-simple.ts`](https://github.com/openclaw/openclaw/blob/v2026.9.6/src/cli/cron-cli/register.cron-simple.ts) -and [`register.cron-edit.ts`](https://github.com/openclaw/openclaw/blob/v2026.9.6/src/cli/cron-cli/register.cron-edit.ts). - -`openclaw agents set-identity` requires approval for every invocation, including -ordinary name changes. In the pinned OpenClaw version, `--identity-file` can -read arbitrary paths and `--avatar` accepts HTTP(S) and data URIs; the command -also rewrites `openclaw.json`. Filesystem-tool workspace confinement does not -limit this CLI command. Cancelled, denied or timed-out approvals do not run it; -shell wrappers, chaining and substitutions remain denied. ->>>>>>> 552a620f (Allow OpenClaw automation create commands) From 70885c151a1543c2acfc6751306173a96554d4dd Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Thu, 19 Nov 2026 00:15:25 +0000 Subject: [PATCH 06/24] Add make saw-init and prepare this cluster for container workspaces 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 --- docs/container-installation.md | 21 +++ overrides/container-network.yaml | 250 +++++++++++++++++++++++++++ tests/charts/test_saw_users_chart.py | 12 ++ values-prod.yaml | 2 + 4 files changed, 285 insertions(+) create mode 100644 overrides/container-network.yaml diff --git a/docs/container-installation.md b/docs/container-installation.md index 01e868b88..705a99188 100644 --- a/docs/container-installation.md +++ b/docs/container-installation.md @@ -570,6 +570,27 @@ in the `saw-users-awaiting-owner` ConfigMap, so other users still sync. Set it from `make keycloak-user-info KC_USER=` once the account exists. With `make saw-create`, an omitted `ownerSubject` is resolved from Keycloak. +Before install, `make saw-init` checks the cluster for these entries: OVN-Kubernetes, +AdminNetworkPolicy and ValidatingAdmissionPolicy, a shared-filesystem +(ReadWriteMany) StorageClass for the audit exchange volume, and an +anonymous pull of the runtime image from inside the cluster. `pattern-install` +and `make saw-create DEPLOYMENT_MODE=container|kata` run it first. + +Without a ReadWriteMany class, `saw-init` creates one for development and demo +clusters: a privileged NFS server Pod on a default-class volume in namespace +`saw-nfs`, the upstream NFS subdirectory provisioner and StorageClass `saw-nfs`, +then verifies a read/write mount. It is a single Pod with no replication. For +production, install a real shared filesystem first (ODF CephFS, EFS, vendor NFS); +`saw-init` then leaves storage alone. `SAW_SHARED_STORAGE=efs` instead offers to +create EFS on AWS (filesystem, mount targets, security group, the AWS EFS CSI +Driver Operator and StorageClass `saw-efs`) with working `aws` credentials, and +`SAW_SHARED_STORAGE=none` only reports. + +A container entry without `ownerSubject` waits: it renders nothing and is listed +in the `saw-users-awaiting-owner` ConfigMap, so other users still sync. Set it +from `make keycloak-user-info KC_USER=` once the account exists. With +`make saw-create`, an omitted `ownerSubject` is resolved from Keycloak. + For static pattern users, put the same values under `overrides/saw-users.yaml`, enable `projection`, commit them and let the existing `saw-users` Application reconcile. Its namespace must be separate from Argo CD. VM users keep their diff --git a/overrides/container-network.yaml b/overrides/container-network.yaml new file mode 100644 index 000000000..bbc0362c3 --- /dev/null +++ b/overrides/container-network.yaml @@ -0,0 +1,250 @@ +# Generated by `make container-topology` from overrides/saw-container-defaults.yaml. +# Re-run it (or `make check-container-topology`) when API, DNS or Keycloak addresses change. +containerDefaults: + stack: + gateway: + values: + oidc: + issuerUrl: https://openshell-keycloak-ingress-saw-keycloak.apps.ocp.qv4zq.sandbox5540.opentlc.com/realms/openshell + kubernetes: + network: + gatewayEgress: + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: openshell-agents + podSelector: + matchLabels: + app.kubernetes.io/name: governance-interceptor + ports: + - protocol: TCP + port: 18081 + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: '@TRUSTED@' + podSelector: + matchLabels: + app.kubernetes.io/instance: '@OWNER@' + openshell.pattern/role: credential-proxy + ports: + - protocol: TCP + port: 3128 + - to: + - ipBlock: + cidr: 10.0.24.185/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 10.0.54.171/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 10.0.83.113/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 172.30.0.1/32 + ports: + - protocol: TCP + port: 443 + - to: + - ipBlock: + cidr: 172.30.0.10/32 + ports: + - protocol: TCP + port: 53 + - protocol: UDP + port: 53 + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: openshift-dns + podSelector: + matchLabels: + dns.operator.openshift.io/daemonset-dns: default + ports: + - protocol: TCP + port: 5353 + - protocol: UDP + port: 5353 + - to: + - ipBlock: + cidr: 3.133.196.240/32 + ports: + - protocol: TCP + port: 443 + - to: + - ipBlock: + cidr: 18.118.63.102/32 + ports: + - protocol: TCP + port: 443 + storage: + className: gp3-csi + proxy: + values: + network: + bootstrapEgress: + - to: + - ipBlock: + cidr: 10.0.24.185/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 10.0.54.171/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 10.0.83.113/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 172.30.0.1/32 + ports: + - protocol: TCP + port: 443 + - to: + - ipBlock: + cidr: 172.30.0.10/32 + ports: + - protocol: TCP + port: 53 + - protocol: UDP + port: 53 + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: openshift-dns + podSelector: + matchLabels: + dns.operator.openshift.io/daemonset-dns: default + ports: + - protocol: TCP + port: 5353 + - protocol: UDP + port: 5353 + audit: + values: + storageClass: gp3-csi + exchangeStorageClass: saw-nfs + automaticEnrollment: + relay: + issuer: https://openshell-keycloak-ingress-saw-keycloak.apps.ocp.qv4zq.sandbox5540.opentlc.com/realms/openshell + egress: + - to: + - ipBlock: + cidr: 10.0.24.185/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 10.0.54.171/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 10.0.83.113/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 172.30.0.1/32 + ports: + - protocol: TCP + port: 443 + - to: + - ipBlock: + cidr: 172.30.0.10/32 + ports: + - protocol: TCP + port: 53 + - protocol: UDP + port: 53 + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: openshift-dns + podSelector: + matchLabels: + dns.operator.openshift.io/daemonset-dns: default + ports: + - protocol: TCP + port: 5353 + - protocol: UDP + port: 5353 + - to: + - ipBlock: + cidr: 3.133.196.240/32 + ports: + - protocol: TCP + port: 443 + - to: + - ipBlock: + cidr: 18.118.63.102/32 + ports: + - protocol: TCP + port: 443 +projection: + egress: + - to: + - ipBlock: + cidr: 10.0.24.185/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 10.0.54.171/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 10.0.83.113/32 + ports: + - protocol: TCP + port: 6443 + - to: + - ipBlock: + cidr: 172.30.0.1/32 + ports: + - protocol: TCP + port: 443 + - to: + - ipBlock: + cidr: 172.30.0.10/32 + ports: + - protocol: TCP + port: 53 + - protocol: UDP + port: 53 + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: openshift-dns + podSelector: + matchLabels: + dns.operator.openshift.io/daemonset-dns: default + ports: + - protocol: TCP + port: 5353 + - protocol: UDP + port: 5353 + applicationSetControllerLabels: + app.kubernetes.io/name: vp-gitops-applicationset-controller diff --git a/tests/charts/test_saw_users_chart.py b/tests/charts/test_saw_users_chart.py index eb1852e0a..287d76cb4 100644 --- a/tests/charts/test_saw_users_chart.py +++ b/tests/charts/test_saw_users_chart.py @@ -292,6 +292,18 @@ def bobs(docs): assert "containerDefaults" not in workspaces +def test_container_user_without_subject_waits_without_blocking_others(tmp_path): + site = yaml.safe_load((ROOT / "tests/fixtures/container-site.yaml").read_text())["portal"]["containerSites"]["alice"] + site.pop("subject") + alice = {"name": "alice", "profiles": ["data-science"], "values": {"deployment": {"mode": "container"}}} + docs = docs_from(render_file(tmp_path, [alice, {"name": "bob"}], {"containerDefaults": site})) + names = {(d["kind"], d["metadata"]["name"]) for d in docs} + assert ("Application", "saw-bob") in names + assert not any(n == "saw-alice" or n.startswith("saw-alice-") for _, n in names) + waiting = [d for d in by_kind(docs, "ConfigMap") if d["metadata"]["name"] == "saw-users-awaiting-owner"] + assert waiting[0]["data"]["users"] == "alice" + + def test_container_entry_without_defaults_or_site_fails(tmp_path): user = {"name": "alice", "ownerSubject": "11111111-1111-4111-8111-111111111111", "profiles": ["data-science"], "values": {"deployment": {"mode": "container"}}} diff --git a/values-prod.yaml b/values-prod.yaml index a82d1a6de..75b926794 100644 --- a/values-prod.yaml +++ b/values-prod.yaml @@ -135,6 +135,8 @@ clusterGroup: extraValueFiles: - /overrides/saw-container-defaults.yaml - /overrides/saw-users.yaml + # Generated by make container-topology; after the files it completes. + - /overrides/container-network.yaml overrides: - name: ownerResolution.enabled value: "true" From 79a98c08a04fc4d6cc8cf75621b5e524e92bf188 Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Thu, 19 Nov 2026 01:23:22 +0000 Subject: [PATCH 07/24] Name alice's model and require it for custom-inference entries 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 --- overrides/saw-users.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/overrides/saw-users.yaml b/overrides/saw-users.yaml index 3bd3fb0e0..149b3b512 100644 --- a/overrides/saw-users.yaml +++ b/overrides/saw-users.yaml @@ -10,6 +10,8 @@ users: ownerSubject: 9a30e84e-2a47-4b88-a2c2-7ba2bddc6dbf profiles: [custom-inference] vaultPrefix: secret/data/hub + modelInputs: + inference.model: rits/zai-org/glm-5-3 # public model name; the key stays in Vault values: deployment: {mode: container} From c44414db3406aba09f43ca763dc45d0b1fa31506 Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Thu, 19 Nov 2026 02:20:03 +0000 Subject: [PATCH 08/24] Remove alice's first container registration 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 --- overrides/saw-users.yaml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/overrides/saw-users.yaml b/overrides/saw-users.yaml index 149b3b512..b761c33fc 100644 --- a/overrides/saw-users.yaml +++ b/overrides/saw-users.yaml @@ -5,15 +5,10 @@ # (make keycloak-user-info KC_USER=) and the credential base path. # Credentials are read from /saw-//inference. # Bump generation to start over with a fresh workspace. -users: - - name: alice - ownerSubject: 9a30e84e-2a47-4b88-a2c2-7ba2bddc6dbf - profiles: [custom-inference] - vaultPrefix: secret/data/hub - modelInputs: - inference.model: rits/zai-org/glm-5-3 # public model name; the key stays in Vault - values: - deployment: {mode: container} +# alice is re-registered as generation 2 (registration d2565216ccf6a6c0) once +# generation 1 (1f732dc2bd1766a0) has been removed; its enrollment approved a +# gateway Service left over from her VM workspace. +users: [] # Opt in only for users of a configured custom-inference endpoint. Match From 0e78e16d3c2e5e0620608483106d14a4d21c6019 Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Thu, 19 Nov 2026 03:11:01 +0000 Subject: [PATCH 09/24] Re-register alice as generation 2 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 --- overrides/saw-users.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/overrides/saw-users.yaml b/overrides/saw-users.yaml index b761c33fc..1673f61ba 100644 --- a/overrides/saw-users.yaml +++ b/overrides/saw-users.yaml @@ -5,10 +5,20 @@ # (make keycloak-user-info KC_USER=) and the credential base path. # Credentials are read from /saw-//inference. # Bump generation to start over with a fresh workspace. -# alice is re-registered as generation 2 (registration d2565216ccf6a6c0) once -# generation 1 (1f732dc2bd1766a0) has been removed; its enrollment approved a -# gateway Service left over from her VM workspace. -users: [] +users: + - name: alice + # generation 2 = registration d2565216ccf6a6c0 (credentials at + # secret/data/hub/saw-alice/d2565216ccf6a6c0/inference). Generation 1 + # (1f732dc2bd1766a0) was removed: its enrollment approved a gateway + # Service left over from her VM workspace. + generation: 2 + ownerSubject: 9a30e84e-2a47-4b88-a2c2-7ba2bddc6dbf + profiles: [custom-inference] + vaultPrefix: secret/data/hub + modelInputs: + inference.model: rits/zai-org/glm-5-3 # public model name; the key stays in Vault + values: + deployment: {mode: container} # Opt in only for users of a configured custom-inference endpoint. Match From 597359c0d0fd27252a95b0fa0ec9ff55d5071310 Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Thu, 19 Nov 2026 03:58:12 +0000 Subject: [PATCH 10/24] Use the in-cluster governance interceptor build The published interceptor image predates mTLS operator access (118b4cfa), so it denies the container reconciler's CreateSandbox driver config. Assisted-By: Claude --- values-prod.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/values-prod.yaml b/values-prod.yaml index 75b926794..fa06fb20a 100644 --- a/values-prod.yaml +++ b/values-prod.yaml @@ -199,6 +199,13 @@ clusterGroup: name: governance-interceptor namespace: openshell-agents path: charts/governance-interceptor + # Built in-cluster (make governance-interceptor-build-local): the published + # image predates mTLS operator access (118b4cfa), which container + # reconcilers use to create sandboxes. + overrides: + - name: image + value: image-registry.openshift-image-registry.svc:5000/openshell-agents/governance-interceptor@sha256:2a1421a4b1960ef499ef9cb02f77bd49d78aa7a9081981877f2a93d5b205408e + forceString: true syncPolicy: automated: prune: true From a3cfa5c21ccc84f84516509e7441806e3522e55d Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Thu, 19 Nov 2026 04:21:02 +0000 Subject: [PATCH 11/24] Let the RHDH portal create container workspaces from containerDefaults 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 --- overrides/saw-container-defaults.yaml | 5 +++++ values-prod.yaml | 1 + 2 files changed, 6 insertions(+) diff --git a/overrides/saw-container-defaults.yaml b/overrides/saw-container-defaults.yaml index 5a39a8f8a..ccb0ee4c8 100644 --- a/overrides/saw-container-defaults.yaml +++ b/overrides/saw-container-defaults.yaml @@ -11,6 +11,11 @@ projection: enabled: true +# Self-service portal (openshell-rhdh reads this file too): offer Container next +# to VM. Any Keycloak user may request it; their site is containerDefaults. +portal: + deploymentModes: [vm, container, kata] + containerDefaults: # OpenClaw with /sandbox searchable by OpenShift namespace UIDs, published by # .github/workflows/build-openclaw-image.yml. OpenClaw 2026.11.8 on the AIPCC diff --git a/values-prod.yaml b/values-prod.yaml index fa06fb20a..b5ae3e2b6 100644 --- a/values-prod.yaml +++ b/values-prod.yaml @@ -164,6 +164,7 @@ clusterGroup: # and portal.deploymentModes come from the same files as saw-users. - /overrides/saw-container-defaults.yaml - /overrides/saw-users.yaml + - /overrides/container-network.yaml # Kata runtime for Kata workspaces. Reboots the selected workers when # enabled (charts/saw-kata); off by default. saw-kata: From 7d6f7e4ace4b9e51e0c587e41a4ab2606d45b74d Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Fri, 20 Nov 2026 11:52:41 -0500 Subject: [PATCH 12/24] fix(network): refresh container topology after cluster restart --- overrides/container-network.yaml | 68 +++++++++++++------------------- 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/overrides/container-network.yaml b/overrides/container-network.yaml index bbc0362c3..56e533a40 100644 --- a/overrides/container-network.yaml +++ b/overrides/container-network.yaml @@ -1,11 +1,9 @@ -# Generated by `make container-topology` from overrides/saw-container-defaults.yaml. -# Re-run it (or `make check-container-topology`) when API, DNS or Keycloak addresses change. containerDefaults: stack: gateway: values: oidc: - issuerUrl: https://openshell-keycloak-ingress-saw-keycloak.apps.ocp.qv4zq.sandbox5540.opentlc.com/realms/openshell + issuerUrl: https://openshell-keycloak-ingress-saw-keycloak.apps.cluster-2lmvl.dyn.redhatworkshops.io/realms/openshell kubernetes: network: gatewayEgress: @@ -32,31 +30,31 @@ containerDefaults: port: 3128 - to: - ipBlock: - cidr: 10.0.24.185/32 + cidr: 10.10.10.10/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 10.0.54.171/32 + cidr: 10.10.10.11/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 10.0.83.113/32 + cidr: 10.10.10.12/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 172.30.0.1/32 + cidr: 172.231.0.1/32 ports: - protocol: TCP port: 443 - to: - ipBlock: - cidr: 172.30.0.10/32 + cidr: 172.231.0.10/32 ports: - protocol: TCP port: 53 @@ -76,49 +74,43 @@ containerDefaults: port: 5353 - to: - ipBlock: - cidr: 3.133.196.240/32 - ports: - - protocol: TCP - port: 443 - - to: - - ipBlock: - cidr: 18.118.63.102/32 + cidr: 10.10.10.101/32 ports: - protocol: TCP port: 443 storage: - className: gp3-csi + className: ocs-external-storagecluster-ceph-rbd proxy: values: network: bootstrapEgress: - to: - ipBlock: - cidr: 10.0.24.185/32 + cidr: 10.10.10.10/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 10.0.54.171/32 + cidr: 10.10.10.11/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 10.0.83.113/32 + cidr: 10.10.10.12/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 172.30.0.1/32 + cidr: 172.231.0.1/32 ports: - protocol: TCP port: 443 - to: - ipBlock: - cidr: 172.30.0.10/32 + cidr: 172.231.0.10/32 ports: - protocol: TCP port: 53 @@ -138,39 +130,39 @@ containerDefaults: port: 5353 audit: values: - storageClass: gp3-csi - exchangeStorageClass: saw-nfs + storageClass: ocs-external-storagecluster-ceph-rbd + exchangeStorageClass: ocs-external-storagecluster-cephfs automaticEnrollment: relay: - issuer: https://openshell-keycloak-ingress-saw-keycloak.apps.ocp.qv4zq.sandbox5540.opentlc.com/realms/openshell + issuer: https://openshell-keycloak-ingress-saw-keycloak.apps.cluster-2lmvl.dyn.redhatworkshops.io/realms/openshell egress: - to: - ipBlock: - cidr: 10.0.24.185/32 + cidr: 10.10.10.10/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 10.0.54.171/32 + cidr: 10.10.10.11/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 10.0.83.113/32 + cidr: 10.10.10.12/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 172.30.0.1/32 + cidr: 172.231.0.1/32 ports: - protocol: TCP port: 443 - to: - ipBlock: - cidr: 172.30.0.10/32 + cidr: 172.231.0.10/32 ports: - protocol: TCP port: 53 @@ -190,13 +182,7 @@ containerDefaults: port: 5353 - to: - ipBlock: - cidr: 3.133.196.240/32 - ports: - - protocol: TCP - port: 443 - - to: - - ipBlock: - cidr: 18.118.63.102/32 + cidr: 10.10.10.101/32 ports: - protocol: TCP port: 443 @@ -204,31 +190,31 @@ projection: egress: - to: - ipBlock: - cidr: 10.0.24.185/32 + cidr: 10.10.10.10/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 10.0.54.171/32 + cidr: 10.10.10.11/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 10.0.83.113/32 + cidr: 10.10.10.12/32 ports: - protocol: TCP port: 6443 - to: - ipBlock: - cidr: 172.30.0.1/32 + cidr: 172.231.0.1/32 ports: - protocol: TCP port: 443 - to: - ipBlock: - cidr: 172.30.0.10/32 + cidr: 172.231.0.10/32 ports: - protocol: TCP port: 53 From 976015d832078aad7f622e2e33294cd497ae2c7b Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Fri, 20 Nov 2026 14:56:58 -0500 Subject: [PATCH 13/24] fix(alice): restore VM deployment with scoped inference secret --- overrides/saw-users.yaml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/overrides/saw-users.yaml b/overrides/saw-users.yaml index 1673f61ba..13c1bae37 100644 --- a/overrides/saw-users.yaml +++ b/overrides/saw-users.yaml @@ -1,24 +1,14 @@ # Add real account names here after creating them with keycloak-add-users. # Each entry creates saw-. Demo entries are in saw-users-demo.yaml. # -# Container workspaces: set the mode, the Keycloak subject -# (make keycloak-user-info KC_USER=) and the credential base path. -# Credentials are read from /saw-//inference. -# Bump generation to start over with a fresh workspace. +# Alice is back on the VM backend. Keep the credential base scoped to the +# current Alice registration so the VM receives the API key she just loaded. users: - name: alice - # generation 2 = registration d2565216ccf6a6c0 (credentials at - # secret/data/hub/saw-alice/d2565216ccf6a6c0/inference). Generation 1 - # (1f732dc2bd1766a0) was removed: its enrollment approved a gateway - # Service left over from her VM workspace. - generation: 2 - ownerSubject: 9a30e84e-2a47-4b88-a2c2-7ba2bddc6dbf profiles: [custom-inference] - vaultPrefix: secret/data/hub - modelInputs: - inference.model: rits/zai-org/glm-5-3 # public model name; the key stays in Vault + vaultPrefix: secret/data/hub/saw-alice/d2565216ccf6a6c0 values: - deployment: {mode: container} + deployment: {mode: vm} # Opt in only for users of a configured custom-inference endpoint. Match From e759a097c48cf1d72375e5e08880071b3561cd7c Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Fri, 20 Nov 2026 15:05:36 -0500 Subject: [PATCH 14/24] fix(alice): disable unavailable web search on VM --- overrides/saw-users.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/overrides/saw-users.yaml b/overrides/saw-users.yaml index 13c1bae37..1f5cf0a04 100644 --- a/overrides/saw-users.yaml +++ b/overrides/saw-users.yaml @@ -7,6 +7,8 @@ users: - name: alice profiles: [custom-inference] vaultPrefix: secret/data/hub/saw-alice/d2565216ccf6a6c0 + webSearch: + enabled: false values: deployment: {mode: vm} From db1961a3d5de87af97cd39c53a6f146a73a6e14e Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Mon, 23 Nov 2026 20:50:34 +0000 Subject: [PATCH 15/24] Default alice's custom model to medium thinking Assisted-By: Claude --- charts/saw-bom/profiles/custom-inference/default/sandbox.yaml | 2 ++ tests/installer/test_custom_endpoint.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml b/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml index 06faad112..a9b71ade7 100644 --- a/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml +++ b/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml @@ -31,5 +31,7 @@ spec: title: Model # Self-hosted models can take longer than the agent's default. timeoutSeconds: "300" + # The model's default thinking level (a chat's /think overrides it). + thinking: medium ui: route: true diff --git a/tests/installer/test_custom_endpoint.py b/tests/installer/test_custom_endpoint.py index b139c6351..a0eb97b3a 100644 --- a/tests/installer/test_custom_endpoint.py +++ b/tests/installer/test_custom_endpoint.py @@ -64,7 +64,8 @@ def test_profile_is_valid_and_reads_url_and_model_from_the_secret(ab, profiles, # ...the endpoint and model are the sandbox's (the URL normalised). sb = notebook(profiles) assert sb.inference_values == {"providerRef": "custom-inference", "protocol": "openai", - "baseUrl": URL, "model": MODEL, "timeoutSeconds": 300} + "baseUrl": URL, "model": MODEL, "timeoutSeconds": 300, + "thinking": "medium"} assert (ab.sandbox_endpoint(sb, custom), ab.sandbox_model(sb, custom)) == (URL, MODEL) From 754487b4d368dfae9c7b913324161b0b4a4b0ac5 Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Mon, 23 Nov 2026 21:00:43 +0000 Subject: [PATCH 16/24] Turn reasoning off for alice's custom model Assisted-By: Claude --- charts/saw-bom/profiles/custom-inference/default/sandbox.yaml | 4 ++-- tests/installer/test_custom_endpoint.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml b/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml index a9b71ade7..b04bd41f9 100644 --- a/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml +++ b/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml @@ -31,7 +31,7 @@ spec: title: Model # Self-hosted models can take longer than the agent's default. timeoutSeconds: "300" - # The model's default thinking level (a chat's /think overrides it). - thinking: medium + # Not a reasoning model (MODEL_REASONING=false): no reasoning_effort is sent. + thinking: off ui: route: true diff --git a/tests/installer/test_custom_endpoint.py b/tests/installer/test_custom_endpoint.py index a0eb97b3a..8e740cb76 100644 --- a/tests/installer/test_custom_endpoint.py +++ b/tests/installer/test_custom_endpoint.py @@ -65,7 +65,7 @@ def test_profile_is_valid_and_reads_url_and_model_from_the_secret(ab, profiles, sb = notebook(profiles) assert sb.inference_values == {"providerRef": "custom-inference", "protocol": "openai", "baseUrl": URL, "model": MODEL, "timeoutSeconds": 300, - "thinking": "medium"} + "thinking": "off"} assert (ab.sandbox_endpoint(sb, custom), ab.sandbox_model(sb, custom)) == (URL, MODEL) @@ -398,7 +398,7 @@ def test_a_thinking_level_marks_the_model_as_reasoning_and_sets_its_default( state = fake_env.openshell_state() sb = state["sandboxes"]["default/notebook"] model_id = f"custom-inference/{MODEL}" - assert sb["openclawConfig"]["agents.defaults.models"][model_id] == {"params": {"thinking": "medium"}} + assert sb["openclawConfig"]["agents.defaults.models"][model_id] == {"params": {"thinking": "off"}} # Onboarding wrote the model entry; a rerun marks it as a reasoning model. sb["openclawConfig"]["models.providers.custom-inference.models"] = [ {"id": MODEL, "name": MODEL, "contextWindow": 128000}, {"id": "other"}] From 733c30658729049ec7e150eaf05a47d99a23a0c3 Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Mon, 23 Nov 2026 21:02:59 +0000 Subject: [PATCH 17/24] Keep the medium case in the thinking-level test Assisted-By: Claude --- tests/installer/test_custom_endpoint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/installer/test_custom_endpoint.py b/tests/installer/test_custom_endpoint.py index 8e740cb76..7a903d783 100644 --- a/tests/installer/test_custom_endpoint.py +++ b/tests/installer/test_custom_endpoint.py @@ -398,7 +398,7 @@ def test_a_thinking_level_marks_the_model_as_reasoning_and_sets_its_default( state = fake_env.openshell_state() sb = state["sandboxes"]["default/notebook"] model_id = f"custom-inference/{MODEL}" - assert sb["openclawConfig"]["agents.defaults.models"][model_id] == {"params": {"thinking": "off"}} + assert sb["openclawConfig"]["agents.defaults.models"][model_id] == {"params": {"thinking": "medium"}} # Onboarding wrote the model entry; a rerun marks it as a reasoning model. sb["openclawConfig"]["models.providers.custom-inference.models"] = [ {"id": MODEL, "name": MODEL, "contextWindow": 128000}, {"id": "other"}] From 68764a33bf5756a932f7bdbe8570d979a42ea7f2 Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Mon, 23 Nov 2026 23:52:26 +0000 Subject: [PATCH 18/24] Set alice's model to 32k output, 128k context, high thinking, no reasoning Profiles can now set inference.reasoning, maxTokens and contextWindow (like NemoClaw's MODEL_REASONING, MODEL_MAX_TOKENS and MODEL_CONTEXT_WINDOW). The installer writes them to the custom model's OpenClaw entry. An explicit reasoning: false keeps the thinking level as the model's default but sends no reasoning_effort. Assisted-By: Claude --- .../files/installer/apply_bom.py | 46 ++++++++++++------- .../openshell-saw/files/installer/saw_core.py | 42 +++++++++++++++-- .../custom-inference/default/sandbox.yaml | 10 +++- docs/custom-inference.md | 6 +++ tests/installer/test_custom_endpoint.py | 35 +++++++++++++- 5 files changed, 116 insertions(+), 23 deletions(-) diff --git a/charts/openshell-saw/files/installer/apply_bom.py b/charts/openshell-saw/files/installer/apply_bom.py index 6c08f2cb2..e3f7e726d 100644 --- a/charts/openshell-saw/files/installer/apply_bom.py +++ b/charts/openshell-saw/files/installer/apply_bom.py @@ -3997,9 +3997,17 @@ def start_openclaw(self, ws, sb, provider): except ValueError as exc: raise InstallerError(f"cannot read OpenClaw managed models: {exc}") from None thinking = (sb.inference_values or {}).get("thinking", "") - if thinking: + # An explicit reasoning flag wins (MODEL_REASONING=false keeps a + # thinking default but sends no reasoning_effort); otherwise any + # thinking level but off marks the model as reasoning. + reasoning = (sb.inference_values or {}).get("reasoning") + if reasoning is None and thinking: + reasoning = thinking != "off" + limits = {k: (sb.inference_values or {})[k] for k in MODEL_LIMIT_KEYS + if k in (sb.inference_values or {})} + if reasoning is not None or limits: self.mark_reasoning_model(exec_cmd, oc_env, provider.type, model_id, - reasoning=thinking != "off") + reasoning=reasoning, limits=limits) if (sb.inference_values or {}).get("models") or previous or thinking: current_models = self.cli(*exec_cmd, "sh", "-c", f"{oc_env} openclaw config get agents.defaults --json", @@ -4088,13 +4096,17 @@ def launch_openclaw(self, ws, sb, exec_cmd, oc_env): self.clear_confinement_stop(ws, sb) self.install_keepalive(ws, sb) - def mark_reasoning_model(self, exec_cmd, oc_env, provider_type, model_id, reasoning=True): - """Set whether OpenClaw treats a custom provider's model as reasoning. + def mark_reasoning_model(self, exec_cmd, oc_env, provider_type, model_id, reasoning=True, + limits=None): + """Set whether OpenClaw treats a custom provider's model as reasoning, + and its maxTokens / contextWindow when the profile gives them. OpenClaw knows which of its own models reason; a custom model offers only default and off unless its entry says reasoning: true and lists the efforts the endpoint accepts (sent as reasoning_effort). Thinking - off marks it reasoning: false, so no effort is sent.""" + off (or reasoning: false) marks it reasoning: false, so no effort is + sent. reasoning None leaves the flag as it is.""" + limits = limits or {} key = f"models.providers.{shlex.quote(provider_type)}.models" found = self.cli(*exec_cmd, "sh", "-c", f"{oc_env} openclaw config get {key} --json", check=False, quiet=True) @@ -4108,19 +4120,21 @@ def mark_reasoning_model(self, exec_cmd, oc_env, provider_type, model_id, reason entry = next((m for m in models or [] if isinstance(m, dict) and m.get("id") in (bare, model_id)), None) if entry is None: log(f"WARN: {provider_type} has no model entry for '{bare}'; its thinking level " - "applies only if OpenClaw already treats it as a reasoning model") + "and token limits apply only if OpenClaw already has them") return - compat = entry.setdefault("compat", {}) - efforts = REASONING_EFFORTS if reasoning else None - if entry.get("reasoning") is reasoning and compat.get("supportedReasoningEfforts") == efforts: + before = json.dumps(entry, sort_keys=True) + entry.update(limits) + if reasoning is not None: + compat = entry.setdefault("compat", {}) + entry["reasoning"] = reasoning + if reasoning: + compat["supportedReasoningEfforts"] = REASONING_EFFORTS + else: + compat.pop("supportedReasoningEfforts", None) + if not compat: + entry.pop("compat") + if json.dumps(entry, sort_keys=True) == before: return - entry["reasoning"] = reasoning - if reasoning: - compat["supportedReasoningEfforts"] = REASONING_EFFORTS - else: - compat.pop("supportedReasoningEfforts", None) - if not compat: - entry.pop("compat") self.cli(*exec_cmd, "sh", "-c", f"{oc_env} openclaw config set {key} {shlex.quote(json.dumps(models))}") diff --git a/charts/openshell-saw/files/installer/saw_core.py b/charts/openshell-saw/files/installer/saw_core.py index 5138cd96e..cf0c9b21f 100644 --- a/charts/openshell-saw/files/installer/saw_core.py +++ b/charts/openshell-saw/files/installer/saw_core.py @@ -200,7 +200,8 @@ class Sandbox: # (the agent, and argv, can read these): those stay on providers. env: dict = field(default_factory=dict) # `inference:` -- how the agent reaches its model: {providerRef, protocol, - # baseUrl?, model, models?, timeoutSeconds?, thinking?}. models maps optional native + # baseUrl?, model, models?, timeoutSeconds?, thinking?, reasoning?, maxTokens?, + # contextWindow?}. models maps optional native # provider names to additional chat model inputs. baseUrl/model/timeoutSeconds # is a literal or an input ({secretKeyRef: {name, key}, default?, # required?, title?}); inference_values is it resolved. The installer onboards the @@ -422,6 +423,11 @@ def validate_profile_document(doc, kind, where="profile"): if "thinking" in inference and inference["thinking"] not in THINKING_LEVELS: raise InstallerError(f"{where}: inference.thinking must be one of " + ", ".join(THINKING_LEVELS)) + if "reasoning" in inference and not isinstance(inference["reasoning"], bool): + raise InstallerError(f"{where}: inference.reasoning must be true or false") + for field_name in MODEL_LIMIT_KEYS: + if field_name in inference and not _positive_int(inference[field_name]): + raise InstallerError(f"{where}: inference.{field_name} must be a positive integer") for field_name in ("model", "baseUrl", "timeoutSeconds"): kinds = (str, int) if field_name == "timeoutSeconds" else (str,) if field_name in inference: @@ -732,7 +738,21 @@ def _thinking_off(inference): return inference -INFERENCE_KEYS = {"providerRef", "protocol", "baseUrl", "model", "models", "timeoutSeconds", "thinking"} +INFERENCE_KEYS = {"providerRef", "protocol", "baseUrl", "model", "models", "timeoutSeconds", "thinking", + "reasoning", "maxTokens", "contextWindow"} +# The custom model's output and context limits, written to its OpenClaw model +# entry (like NemoClaw's MODEL_MAX_TOKENS and MODEL_CONTEXT_WINDOW). +MODEL_LIMIT_KEYS = ("maxTokens", "contextWindow") + + +def _positive_int(value): + """An int (or digit string) above zero; YAML booleans are not ints here.""" + if isinstance(value, bool): + return False + if isinstance(value, str): + return value.isdigit() and int(value) > 0 + return isinstance(value, int) and value > 0 + # OpenClaw thinking levels a profile may make the model's default. A level # other than off also marks the model as a reasoning model that accepts # these efforts, which OpenClaw only assumes for its own known models. @@ -966,6 +986,11 @@ def resolve_inference(ws, sb, read_value, validate_endpoint, forbidden=()): out["timeoutSeconds"] = int(timeout) if timeout else 0 if spec.get("thinking"): out["thinking"] = spec["thinking"] + if "reasoning" in spec: + out["reasoning"] = spec["reasoning"] + for key in MODEL_LIMIT_KEYS: + if key in spec: + out[key] = int(spec[key]) if "models" in spec: out["models"] = {} for name, src in spec["models"].items(): @@ -1030,6 +1055,17 @@ def sandbox_inference_problems(sb, provider_types, declared_provider_types=None) out.append(f"inference thinking must be one of {', '.join(THINKING_LEVELS)}") elif sb.type != "openclaw": out.append("inference thinking is supported only for openclaw sandboxes") + if "reasoning" in spec: + if not isinstance(spec["reasoning"], bool): + out.append("inference reasoning must be true or false") + elif sb.type != "openclaw": + out.append("inference reasoning is supported only for openclaw sandboxes") + for key in MODEL_LIMIT_KEYS: + if key in spec: + if not _positive_int(spec[key]): + out.append(f"inference {key} must be a positive integer") + elif sb.type != "openclaw": + out.append(f"inference {key} is supported only for openclaw sandboxes") models = spec.get("models", {}) if not isinstance(models, dict): out.append("inference models must be a mapping of provider names to model inputs") @@ -1081,7 +1117,7 @@ def profiles_from_plan(data): 'SANDBOX_TYPES', 'BASE_URL_CONFIG_KEYS', 'InstallerError', 'Provider', 'Sandbox', 'Workspace', 'Profile', 'HarnessBundle', 'read_profile_files', '_yaml', 'parse_profiles', 'enabled_workspaces', 'validate_profiles', 'ENV_NAME_RE', 'CREDENTIAL_NAME_RE', 'ENV_VALUE_LIMIT', 'SANDBOX_ENV_KEYS', - 'INPUT_KEYS', 'secret_ref', 'secret_ref_problems', 'INFERENCE_KEYS', 'INFERENCE_PROTOCOLS', 'THINKING_LEVELS', 'REASONING_EFFORTS', + 'INPUT_KEYS', 'secret_ref', 'secret_ref_problems', 'INFERENCE_KEYS', 'MODEL_LIMIT_KEYS', 'INFERENCE_PROTOCOLS', 'THINKING_LEVELS', 'REASONING_EFFORTS', 'PROVIDER_PROTOCOLS', 'check_env_value', 'sandbox_env_problems', 'input_problems', 'check_base_url', 'resolve_bom_input', 'resolve_inference', 'inference_protocol', 'sandbox_inference_problems', 'harness_from_plan', 'profiles_from_plan', 'validate_profile_document', 'apply_workspace_sequence', 'select_inference_provider', diff --git a/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml b/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml index b04bd41f9..b34eba6a4 100644 --- a/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml +++ b/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml @@ -31,7 +31,13 @@ spec: title: Model # Self-hosted models can take longer than the agent's default. timeoutSeconds: "300" - # Not a reasoning model (MODEL_REASONING=false): no reasoning_effort is sent. - thinking: off + # The model's default thinking level (a chat's /think overrides it). + thinking: high + # Not a reasoning model (MODEL_REASONING=false): no reasoning_effort + # is sent, whatever the thinking level. + reasoning: false + # MODEL_MAX_TOKENS / MODEL_CONTEXT_WINDOW for the model's entry. + maxTokens: 32768 + contextWindow: 128000 ui: route: true diff --git a/docs/custom-inference.md b/docs/custom-inference.md index 696436dc1..982974418 100644 --- a/docs/custom-inference.md +++ b/docs/custom-inference.md @@ -154,6 +154,12 @@ stated (`openai`): the installer cannot infer it for a profile of your own. `off` marks it `reasoning: false` instead (like `MODEL_REASONING=false`); an unquoted YAML `off` (read as `false`) also means off. A chat's `/think` still overrides the default. VM workspaces only for now. +- `inference.reasoning: false` (like `MODEL_REASONING=false`) marks the model + not reasoning whatever the thinking level, so a level such as `high` stays + its default but no `reasoning_effort` is sent; `true` forces it on. +- `inference.maxTokens` and `inference.contextWindow` (like + `MODEL_MAX_TOKENS` and `MODEL_CONTEXT_WINDOW`) set the model entry's output + and context limits. The bundled profile uses `32768` and `128000`. ### Keycloak compatibility diff --git a/tests/installer/test_custom_endpoint.py b/tests/installer/test_custom_endpoint.py index 7a903d783..8131d88d0 100644 --- a/tests/installer/test_custom_endpoint.py +++ b/tests/installer/test_custom_endpoint.py @@ -65,7 +65,8 @@ def test_profile_is_valid_and_reads_url_and_model_from_the_secret(ab, profiles, sb = notebook(profiles) assert sb.inference_values == {"providerRef": "custom-inference", "protocol": "openai", "baseUrl": URL, "model": MODEL, "timeoutSeconds": 300, - "thinking": "off"} + "thinking": "high", "reasoning": False, + "maxTokens": 32768, "contextWindow": 128000} assert (ab.sandbox_endpoint(sb, custom), ab.sandbox_model(sb, custom)) == (URL, MODEL) @@ -392,6 +393,8 @@ def test_a_thinking_level_marks_the_model_as_reasoning_and_sets_its_default( """OpenClaw offers only default/off for a custom model unless its entry says reasoning: true and lists the efforts; the level is then the model's default (a chat's /think still overrides it).""" + for key in ("reasoning", "maxTokens", "contextWindow"): + notebook(profiles).inference.pop(key, None) notebook(profiles).inference["thinking"] = "medium" creds = resolve(ab, profiles, custom_secrets) ab.ProfileApplier(ab.Shell(), config, creds).apply(profiles) @@ -423,6 +426,34 @@ def test_a_thinking_level_marks_the_model_as_reasoning_and_sets_its_default( "agents.defaults.models"][model_id] == {} +def test_reasoning_false_keeps_the_thinking_default_and_sets_the_token_limits( + ab, fake_env, config, profiles, custom_secrets, governed_catalog): + """MODEL_REASONING=false with a thinking level: the level stays the + model's default but no reasoning_effort is sent; maxTokens and + contextWindow land on the model's entry.""" + creds = resolve(ab, profiles, custom_secrets) + ab.ProfileApplier(ab.Shell(), config, creds).apply(profiles) + state = fake_env.openshell_state() + sb = state["sandboxes"]["default/notebook"] + sb["openclawConfig"]["models.providers.custom-inference.models"] = [ + {"id": MODEL, "name": MODEL, "contextWindow": 200000, "reasoning": True, + "compat": {"supportedReasoningEfforts": ["low", "medium", "high"]}}] + fake_env.set_openshell_state(state) + ab.ProfileApplier(ab.Shell(), config, creds).apply(profiles) + cfg = fake_env.openshell_state()["sandboxes"]["default/notebook"]["openclawConfig"] + assert cfg["models.providers.custom-inference.models"] == [ + {"id": MODEL, "name": MODEL, "contextWindow": 128000, "maxTokens": 32768, "reasoning": False}] + assert cfg["agents.defaults.models"][f"custom-inference/{MODEL}"] == {"params": {"thinking": "high"}} + + +@pytest.mark.parametrize("key,value", [("reasoning", "no"), ("maxTokens", 0), + ("contextWindow", "big"), ("maxTokens", True)]) +def test_bad_reasoning_or_token_limits_are_refused(ab, profiles, key, value): + sb = notebook(profiles) + sb.inference[key] = value + assert ab.sandbox_inference_problems(sb, {"custom-inference": "custom-inference"}) + + @pytest.mark.parametrize("level", ["max", "Medium", 1]) def test_an_unknown_thinking_level_is_refused(ab, profiles, level): sb = notebook(profiles) @@ -434,5 +465,5 @@ def test_an_unquoted_yaml_off_means_off(ab): """YAML 1.1 reads `thinking: off` as false; it still means off.""" files = profile_files("custom-inference") key = next(k for k in files if k.endswith("__sandbox.yaml")) - files[key] = files[key].replace('timeoutSeconds: "300"', 'timeoutSeconds: "300"\n thinking: off') + files[key] = files[key].replace("thinking: high", "thinking: off") assert notebook(ab.parse_profiles(files)).inference["thinking"] == "off" From 5f225a6f94795dea959bf666ba9db23dddcd8a00 Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Mon, 30 Nov 2026 17:14:39 +0000 Subject: [PATCH 19/24] Drop container-network.yaml and the in-cluster interceptor image Upstream main derives the container network in saw-portal-container (gateway egress, issuer URL) and ships the v0.1.10 governance interceptor with mTLS operator access, so neither overlay is needed. values-prod.yaml now matches upstream main. Assisted-By: Claude --- overrides/container-network.yaml | 236 ------------------------------- values-prod.yaml | 10 -- 2 files changed, 246 deletions(-) delete mode 100644 overrides/container-network.yaml diff --git a/overrides/container-network.yaml b/overrides/container-network.yaml deleted file mode 100644 index 56e533a40..000000000 --- a/overrides/container-network.yaml +++ /dev/null @@ -1,236 +0,0 @@ -containerDefaults: - stack: - gateway: - values: - oidc: - issuerUrl: https://openshell-keycloak-ingress-saw-keycloak.apps.cluster-2lmvl.dyn.redhatworkshops.io/realms/openshell - kubernetes: - network: - gatewayEgress: - - to: - - namespaceSelector: - matchLabels: - kubernetes.io/metadata.name: openshell-agents - podSelector: - matchLabels: - app.kubernetes.io/name: governance-interceptor - ports: - - protocol: TCP - port: 18081 - - to: - - namespaceSelector: - matchLabels: - kubernetes.io/metadata.name: '@TRUSTED@' - podSelector: - matchLabels: - app.kubernetes.io/instance: '@OWNER@' - openshell.pattern/role: credential-proxy - ports: - - protocol: TCP - port: 3128 - - to: - - ipBlock: - cidr: 10.10.10.10/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 10.10.10.11/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 10.10.10.12/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 172.231.0.1/32 - ports: - - protocol: TCP - port: 443 - - to: - - ipBlock: - cidr: 172.231.0.10/32 - ports: - - protocol: TCP - port: 53 - - protocol: UDP - port: 53 - - to: - - namespaceSelector: - matchLabels: - kubernetes.io/metadata.name: openshift-dns - podSelector: - matchLabels: - dns.operator.openshift.io/daemonset-dns: default - ports: - - protocol: TCP - port: 5353 - - protocol: UDP - port: 5353 - - to: - - ipBlock: - cidr: 10.10.10.101/32 - ports: - - protocol: TCP - port: 443 - storage: - className: ocs-external-storagecluster-ceph-rbd - proxy: - values: - network: - bootstrapEgress: - - to: - - ipBlock: - cidr: 10.10.10.10/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 10.10.10.11/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 10.10.10.12/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 172.231.0.1/32 - ports: - - protocol: TCP - port: 443 - - to: - - ipBlock: - cidr: 172.231.0.10/32 - ports: - - protocol: TCP - port: 53 - - protocol: UDP - port: 53 - - to: - - namespaceSelector: - matchLabels: - kubernetes.io/metadata.name: openshift-dns - podSelector: - matchLabels: - dns.operator.openshift.io/daemonset-dns: default - ports: - - protocol: TCP - port: 5353 - - protocol: UDP - port: 5353 - audit: - values: - storageClass: ocs-external-storagecluster-ceph-rbd - exchangeStorageClass: ocs-external-storagecluster-cephfs - automaticEnrollment: - relay: - issuer: https://openshell-keycloak-ingress-saw-keycloak.apps.cluster-2lmvl.dyn.redhatworkshops.io/realms/openshell - egress: - - to: - - ipBlock: - cidr: 10.10.10.10/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 10.10.10.11/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 10.10.10.12/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 172.231.0.1/32 - ports: - - protocol: TCP - port: 443 - - to: - - ipBlock: - cidr: 172.231.0.10/32 - ports: - - protocol: TCP - port: 53 - - protocol: UDP - port: 53 - - to: - - namespaceSelector: - matchLabels: - kubernetes.io/metadata.name: openshift-dns - podSelector: - matchLabels: - dns.operator.openshift.io/daemonset-dns: default - ports: - - protocol: TCP - port: 5353 - - protocol: UDP - port: 5353 - - to: - - ipBlock: - cidr: 10.10.10.101/32 - ports: - - protocol: TCP - port: 443 -projection: - egress: - - to: - - ipBlock: - cidr: 10.10.10.10/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 10.10.10.11/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 10.10.10.12/32 - ports: - - protocol: TCP - port: 6443 - - to: - - ipBlock: - cidr: 172.231.0.1/32 - ports: - - protocol: TCP - port: 443 - - to: - - ipBlock: - cidr: 172.231.0.10/32 - ports: - - protocol: TCP - port: 53 - - protocol: UDP - port: 53 - - to: - - namespaceSelector: - matchLabels: - kubernetes.io/metadata.name: openshift-dns - podSelector: - matchLabels: - dns.operator.openshift.io/daemonset-dns: default - ports: - - protocol: TCP - port: 5353 - - protocol: UDP - port: 5353 - applicationSetControllerLabels: - app.kubernetes.io/name: vp-gitops-applicationset-controller diff --git a/values-prod.yaml b/values-prod.yaml index b5ae3e2b6..a82d1a6de 100644 --- a/values-prod.yaml +++ b/values-prod.yaml @@ -135,8 +135,6 @@ clusterGroup: extraValueFiles: - /overrides/saw-container-defaults.yaml - /overrides/saw-users.yaml - # Generated by make container-topology; after the files it completes. - - /overrides/container-network.yaml overrides: - name: ownerResolution.enabled value: "true" @@ -164,7 +162,6 @@ clusterGroup: # and portal.deploymentModes come from the same files as saw-users. - /overrides/saw-container-defaults.yaml - /overrides/saw-users.yaml - - /overrides/container-network.yaml # Kata runtime for Kata workspaces. Reboots the selected workers when # enabled (charts/saw-kata); off by default. saw-kata: @@ -200,13 +197,6 @@ clusterGroup: name: governance-interceptor namespace: openshell-agents path: charts/governance-interceptor - # Built in-cluster (make governance-interceptor-build-local): the published - # image predates mTLS operator access (118b4cfa), which container - # reconcilers use to create sandboxes. - overrides: - - name: image - value: image-registry.openshift-image-registry.svc:5000/openshell-agents/governance-interceptor@sha256:2a1421a4b1960ef499ef9cb02f77bd49d78aa7a9081981877f2a93d5b205408e - forceString: true syncPolicy: automated: prune: true From 8ee91239ad59b7d29ec4c84c9dbf6b84b0e6edcf Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Mon, 30 Nov 2026 17:17:22 +0000 Subject: [PATCH 20/24] Use alice's stable Vault prefix without the registration id Assisted-By: Claude --- overrides/saw-users.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overrides/saw-users.yaml b/overrides/saw-users.yaml index 1f5cf0a04..89cbfd775 100644 --- a/overrides/saw-users.yaml +++ b/overrides/saw-users.yaml @@ -6,7 +6,7 @@ users: - name: alice profiles: [custom-inference] - vaultPrefix: secret/data/hub/saw-alice/d2565216ccf6a6c0 + vaultPrefix: secret/data/hub/saw-alice webSearch: enabled: false values: From c6b4488bfae41c90210bffcb314c0b7ba44708aa Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Mon, 30 Nov 2026 17:38:20 +0000 Subject: [PATCH 21/24] Find VMs waiting on a restart and survive the poweroff disconnect saw-restart-pending only looked for RestartRequired, which KubeVirt 1.8 does not set when just the template's openshell.pattern/*-checksum annotations change, so a BOM update left VMs on their old inputs with nothing listed. Also compare those checksums with the running instance. saw-restart ran a blocking poweroff; the tunnel dropped before it returned and virtctl reported exit status 1, which the script treats as a failed command. Queue the poweroff with --no-block so the command returns before sshd stops. Assisted-By: Claude --- docs/versioned-bom-installer.md | 4 ++- scripts/openshell-saw-restart.sh | 6 ++++- scripts/saw-restart-pending.sh | 26 ++++++++++++++----- tests/scripts/test_make_interface.py | 39 ++++++++++++++++++++++++++-- tests/scripts/test_vm_restart.py | 4 +-- 5 files changed, 66 insertions(+), 13 deletions(-) diff --git a/docs/versioned-bom-installer.md b/docs/versioned-bom-installer.md index 6f211d6c5..8f92d47d1 100644 --- a/docs/versioned-bom-installer.md +++ b/docs/versioned-bom-installer.md @@ -164,7 +164,9 @@ in projected Secrets mounted into the credential proxy. 1. Change `bom:` in the chart values (versions + digests; tags are refused at render time and by the installer). 2. Sync/upgrade the chart. The installer ConfigMap is part of the VM template - checksum, so KubeVirt marks the VM `RestartRequired`. + checksum, so the template no longer matches the running VM. KubeVirt does + not restart it, and may not mark it `RestartRequired`; + `make saw-restart-pending` lists it either way. 3. `virtctl restart ` (or `make saw-restart`). On boot, `saw-install` installs only the changed components. diff --git a/scripts/openshell-saw-restart.sh b/scripts/openshell-saw-restart.sh index 395edc1f1..60617bacb 100755 --- a/scripts/openshell-saw-restart.sh +++ b/scripts/openshell-saw-restart.sh @@ -21,7 +21,11 @@ if [[ -z "${old_uid}" || "${phase}" != Running ]]; then exit 1 fi -if "${SCRIPT_DIR}/openshell-saw-vm-ssh.sh" 'sudo systemctl poweroff'; then +# --no-block queues the poweroff and returns at once, so the command exits 0 +# before sshd stops. A blocking poweroff races the shutdown: the tunnel drops +# first, and virtctl reports that as exit status 1, the same as a failed +# command, so the restart could not tell the two apart. +if "${SCRIPT_DIR}/openshell-saw-vm-ssh.sh" 'sudo systemctl poweroff --no-block'; then echo "Guest poweroff requested." else ssh_rc=$? diff --git a/scripts/saw-restart-pending.sh b/scripts/saw-restart-pending.sh index 9b5d98467..631e076b3 100755 --- a/scripts/saw-restart-pending.sh +++ b/scripts/saw-restart-pending.sh @@ -2,16 +2,28 @@ # Restart the SAW VMs whose spec changed while they were running. # # KubeVirt does not restart a running VM when its template changes (a new -# gateway.toml after switching global.governance.engine, a BOM or profile -# change without vm.liveInputs): it sets the RestartRequired condition and the -# guest keeps its old config until the next boot. This lists those VMs and, -# with CONFIRM=yes, restarts them. Users' running sandboxes stop with the VM. +# gateway.toml after switching global.governance.engine, a BOM change without +# vm.liveInputs): the guest keeps its old config until the next boot. KubeVirt +# sets RestartRequired for some changes but not for the chart's +# openshell.pattern/*-checksum annotations, so a VM is also pending when its +# template's checksums differ from the running instance's. This lists those +# VMs and, with CONFIRM=yes, restarts them. Users' running sandboxes stop with +# the VM. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" vms="$(oc get vm -A -l openshell.pattern/role=gateway -o json)" -pending="$(jq -r '.items[] - | select(any(.status.conditions[]?; .type == "RestartRequired" and .status == "True")) +vmis="$(oc get vmi -A -l openshell.pattern/role=gateway -o json)" +pending="$(jq -r --argjson vmis "${vmis}" ' + def checksums: (.metadata.annotations // {}) + | with_entries(select(.key | startswith("openshell.pattern/") and endswith("-checksum"))); + ($vmis.items | map({key: "\(.metadata.namespace)/\(.metadata.name)", value: checksums}) + | from_entries) as $running + | .items[] + | $running["\(.metadata.namespace)/\(.metadata.name)"] as $booted + | ((.spec.template // {}) | checksums) as $wanted + | select(any(.status.conditions[]?; .type == "RestartRequired" and .status == "True") + or ($booted != null and $wanted != {} and $wanted != $booted)) | [.metadata.namespace, .metadata.name] | @tsv' <<<"${vms}")" if [[ -z "${pending}" ]]; then @@ -19,7 +31,7 @@ if [[ -z "${pending}" ]]; then exit 0 fi -echo "SAW VMs waiting for a restart (RestartRequired):" +echo "SAW VMs waiting for a restart:" while IFS=$'\t' read -r ns name; do printf ' %-20s %s\n' "${name}" "${ns}" done <<<"${pending}" diff --git a/tests/scripts/test_make_interface.py b/tests/scripts/test_make_interface.py index 8407d8041..b4b48a5fb 100644 --- a/tests/scripts/test_make_interface.py +++ b/tests/scripts/test_make_interface.py @@ -693,11 +693,13 @@ def test_discovery_log_error_does_not_hide_build_phase(tmp_path, terminal): assert not any("imageDigest" in line for line in calls) -def fake_cluster(tmp_path, vms): +def fake_cluster(tmp_path, vms, vmis='{"items": []}'): bin_dir = tmp_path / "bin" bin_dir.mkdir() (tmp_path / "vms.json").write_text(vms) - executable(bin_dir / "oc", f'cat "{tmp_path}/vms.json"\n') + (tmp_path / "vmis.json").write_text(vmis) + executable(bin_dir / "oc", f'case " $* " in *" vmi "*) cat "{tmp_path}/vmis.json";; ' + f'*) cat "{tmp_path}/vms.json";; esac\n') executable(bin_dir / "virtctl", f'echo "$*" >> "{tmp_path}/restarted"\n') return dict(os.environ, PATH=f"{bin_dir}:{os.environ['PATH']}") @@ -735,6 +737,39 @@ def test_saw_restart_pending_restarts_only_pending_vms(tmp_path): assert (tmp_path / "restarted").read_text() == "saw-alice alice\n" +CHECKSUM_VMS = """{"items": [ + {"metadata": {"name": "alice", "namespace": "saw-alice"}, + "spec": {"template": {"metadata": {"annotations": { + "openshell.pattern/installer-checksum": "new", "openshell.pattern/cloudinit-checksum": "c1"}}}}, + "status": {"conditions": [{"type": "Ready", "status": "True"}]}}, + {"metadata": {"name": "bob", "namespace": "saw-bob"}, + "spec": {"template": {"metadata": {"annotations": { + "openshell.pattern/installer-checksum": "same", "openshell.pattern/cloudinit-checksum": "c1"}}}}, + "status": {"conditions": [{"type": "Ready", "status": "True"}]}}, + {"metadata": {"name": "carol", "namespace": "saw-carol"}, + "spec": {"template": {"metadata": {"annotations": { + "openshell.pattern/installer-checksum": "new"}}}}, + "status": {"conditions": []}} +]}""" + +CHECKSUM_VMIS = """{"items": [ + {"metadata": {"name": "alice", "namespace": "saw-alice", "annotations": { + "openshell.pattern/installer-checksum": "old", "openshell.pattern/cloudinit-checksum": "c1"}}}, + {"metadata": {"name": "bob", "namespace": "saw-bob", "annotations": { + "openshell.pattern/installer-checksum": "same", "openshell.pattern/cloudinit-checksum": "c1"}}} +]}""" + + +def test_saw_restart_pending_finds_checksum_drift_without_condition(tmp_path): + """KubeVirt 1.8 does not set RestartRequired when only the template's + checksum annotations change; a stopped VM (carol) has nothing to restart.""" + env = fake_cluster(tmp_path, CHECKSUM_VMS, CHECKSUM_VMIS) + result = run_make("saw-restart-pending", env=env) + assert result.returncode == 0, result.stderr + assert "alice" in result.stdout + assert "bob" not in result.stdout and "carol" not in result.stdout + + def test_saw_restart_pending_with_nothing_pending(tmp_path): env = fake_cluster(tmp_path, '{"items": []}') result = run_make("saw-restart-pending", "CONFIRM=yes", env=env) diff --git a/tests/scripts/test_vm_restart.py b/tests/scripts/test_vm_restart.py index a0f01ab90..47fe69a81 100644 --- a/tests/scripts/test_vm_restart.py +++ b/tests/scripts/test_vm_restart.py @@ -55,7 +55,7 @@ def run(restart_env, **overrides): def test_waits_through_old_missing_and_starting_instances(restart_env): result = run(restart_env) assert result.returncode == 0, result.stderr - assert Path(restart_env[1]["CALLS"]).read_text() == "sudo systemctl poweroff\n" + assert Path(restart_env[1]["CALLS"]).read_text() == "sudo systemctl poweroff --no-block\n" assert not Path(restart_env[1]["HOST_CALLS"]).exists() assert "Replacement VM saw-alice/alice is Running" in result.stdout assert "boot install/apply" in result.stdout @@ -75,7 +75,7 @@ def test_failed_guest_command_does_not_claim_restart_or_force_it(restart_env, ss assert "Replacement VM" not in result.stdout assert not Path(restart_env[1]["HOST_CALLS"]).exists() assert Path(restart_env[1]["COUNTER"]).read_text() == "1" - assert Path(restart_env[1]["CALLS"]).read_text() == "sudo systemctl poweroff\n" + assert Path(restart_env[1]["CALLS"]).read_text() == "sudo systemctl poweroff --no-block\n" def test_ssh_disconnect_during_poweroff_still_verifies_replacement(restart_env): From 7490b8ec85dab1f84b1c4230fc301ba79360cf4e Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Mon, 30 Nov 2026 17:49:41 +0000 Subject: [PATCH 22/24] docs: drop the stale saw-init block and the 0.1.6 trace note The upstream merge kept an older copy of the saw-init and ownerSubject paragraphs, which contradicted the current text: saw-init no longer creates NFS unless SAW_SHARED_STORAGE=nfs, and shared storage is only needed for audit receipts. OpenShell 0.1.10 relays agent traces; OpenClaw does not send them yet. Assisted-By: Claude --- docs/container-installation.md | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/docs/container-installation.md b/docs/container-installation.md index 705a99188..79759e28c 100644 --- a/docs/container-installation.md +++ b/docs/container-installation.md @@ -570,27 +570,6 @@ in the `saw-users-awaiting-owner` ConfigMap, so other users still sync. Set it from `make keycloak-user-info KC_USER=` once the account exists. With `make saw-create`, an omitted `ownerSubject` is resolved from Keycloak. -Before install, `make saw-init` checks the cluster for these entries: OVN-Kubernetes, -AdminNetworkPolicy and ValidatingAdmissionPolicy, a shared-filesystem -(ReadWriteMany) StorageClass for the audit exchange volume, and an -anonymous pull of the runtime image from inside the cluster. `pattern-install` -and `make saw-create DEPLOYMENT_MODE=container|kata` run it first. - -Without a ReadWriteMany class, `saw-init` creates one for development and demo -clusters: a privileged NFS server Pod on a default-class volume in namespace -`saw-nfs`, the upstream NFS subdirectory provisioner and StorageClass `saw-nfs`, -then verifies a read/write mount. It is a single Pod with no replication. For -production, install a real shared filesystem first (ODF CephFS, EFS, vendor NFS); -`saw-init` then leaves storage alone. `SAW_SHARED_STORAGE=efs` instead offers to -create EFS on AWS (filesystem, mount targets, security group, the AWS EFS CSI -Driver Operator and StorageClass `saw-efs`) with working `aws` credentials, and -`SAW_SHARED_STORAGE=none` only reports. - -A container entry without `ownerSubject` waits: it renders nothing and is listed -in the `saw-users-awaiting-owner` ConfigMap, so other users still sync. Set it -from `make keycloak-user-info KC_USER=` once the account exists. With -`make saw-create`, an omitted `ownerSubject` is resolved from Keycloak. - For static pattern users, put the same values under `overrides/saw-users.yaml`, enable `projection`, commit them and let the existing `saw-users` Application reconcile. Its namespace must be separate from Argo CD. VM users keep their @@ -776,7 +755,6 @@ downward API to identify its credential reservation. If a pending writer disappe Vault generation before clearing the writer annotation. A missing holder fails closed. A terminated failed run can be retried for the same registration. - ### Interrupted creates and updates RHDH reserves the registration before writing credentials. The catalog keeps @@ -844,8 +822,9 @@ ID matches both the body and the log record's `openshell.sandbox.id` attribute. When using an external exporter, verify records in that backend separately. Set `telemetry.ocsfEndpoint: ""` in `containerDefaults` to turn export off. OpenShell drops events it cannot export, and nothing waits for the collector. -OpenShell 0.1.6 does not export the agent's own tool calls; those are in the -tool gate's log below. +The gateway also relays the agent's own OTLP traces (`telemetry.agentTraces`), +but OpenClaw does not send them yet, so its tool calls appear only in the tool +gate's log below. #### Audit receipts From d3893cf9b942de18f3a27fd4c32ff90e74400a8d Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Mon, 30 Nov 2026 17:51:31 +0000 Subject: [PATCH 23/24] docs: tidy the container installation guide Move the Kata pointer to the installation-owner section and the portal Task recovery note into Interrupted creates and updates, name the e2e check behind W6, and describe the driver's bootstrap window by its 0.1.10 setting instead of a 0.1.6 source line. Assisted-By: Claude --- docs/container-installation.md | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/container-installation.md b/docs/container-installation.md index 79759e28c..f79d42ee6 100644 --- a/docs/container-installation.md +++ b/docs/container-installation.md @@ -18,6 +18,10 @@ owned by the pattern or RHDH. Both VM and container users can coexist in a `saw-users` installation. Each registration has one backend; it is not an in-place VM-to-container migration setting. +Kata workspaces run the same container workspace in a Kata VM, with the same +Kubernetes lifecycle and workspace BOM; for their extra placement steps, follow +the [Kata installation and Developer Hub guide](kata-workspaces.md). + ## Shared platform prerequisites Start with the SAW platform services: Keycloak/owner accounts, governance, @@ -85,8 +89,6 @@ individual workspace must not uninstall this cluster-wide dependency. ## Public inputs and credential references -For Kata workload placement, follow the [Kata installation and Developer Hub guide](kata-workspaces.md). Both modes use the same Kubernetes lifecycle and workspace BOM. - The same site object is used as `containerSites.` for static installs or `portal.containerSites.` for RHDH. It is administrator-owned, not a form field. The component wiring (namespaces, service accounts, SANs, the @@ -127,12 +129,13 @@ owner. The portal Task needs the existing read-only directory client projection ### Prepare large images on cold nodes -The pinned stock OpenShell driver rolls back a sandbox whose bootstrap remains -unfinished for five minutes. A slow first image pull can consume that entire -window. Check cold nodes when qualifying a profile. For large images, install +The stock OpenShell driver rolls back a sandbox whose runtime bootstrap is +still unfinished after `runtime_bootstrap_grace_seconds`, 300 seconds by +default (the SAW gateway chart keeps the default). A slow first image pull can +consume that entire window. Check cold nodes when qualifying a profile. For large images, install the optional `charts/saw-image-cache` chart through the clustergroup before creating workspaces. Give it the same immutable digests selected by the BOM -and site overrides. [Pinned driver](https://github.com/opendatahub-io/openshell/blob/305c8b3d7bbdb97a6f2f7264c3ad43b0087c307f/crates/openshell-driver-kubernetes/src/driver.rs#L284) +and site overrides. [Driver configuration](https://github.com/opendatahub-io/openshell/blob/c2775b8df05619cdd57cb354ea8cd829ec79ee40/crates/openshell-driver-kubernetes/src/config.rs) ```yaml # Site values @@ -750,11 +753,6 @@ python3 scripts/portal-container/check-pod-admission.py \ Each probe must report denial by the workspace Pod policy. An RBAC error, missing API, or collision with an existing Pod fails the check. -The Task reads the Tekton-owned `tekton.dev/pipelineRun` Pod label through the -downward API to identify its credential reservation. If a pending writer disappears, inspect its PipelineRun and the owned -Vault generation before clearing the writer annotation. A missing holder fails -closed. A terminated failed run can be retried for the same registration. - ### Interrupted creates and updates RHDH reserves the registration before writing credentials. The catalog keeps @@ -765,6 +763,12 @@ project the last committed public configuration. Retry the create form with all required inputs to finish the same registration. Vault writes to multiple secrets are independent; an earlier write may already be visible to ESO. +The portal's registration Task reads the Tekton-owned `tekton.dev/pipelineRun` +Pod label through the downward API to identify its credential reservation. If a +pending writer disappears, inspect its PipelineRun and the owned Vault +generation before clearing the writer annotation. A missing holder fails +closed. A terminated failed run can be retried for the same registration. + The reconciler records the ID from a successful sandbox create before waiting for readiness. It replays an interrupted create with the original request ID on a Running pass. If shutdown encounters an outstanding create with no proven @@ -816,9 +820,9 @@ network and request decisions) over OTLP/gRPC to the collector in The demonstration debug exporter writes complete event bodies, sandbox IDs and trace details to the collector's log, with detailed output and sampling disabled. Pod logs are not durable audit storage; replace the exporter with your SIEM or -log store in `charts/saw-telemetry/values.yaml` for production. W6 inspects the -demo collector's detailed logs and requires a fresh OCSF JSON body whose sandbox -ID matches both the body and the log record's `openshell.sandbox.id` attribute. +log store in `charts/saw-telemetry/values.yaml` for production. The OCSF check +in `make e2e-workspace` (W6) inspects the demo collector's detailed logs and +requires a fresh OCSF JSON body whose sandbox ID matches both the body and the log record's `openshell.sandbox.id` attribute. When using an external exporter, verify records in that backend separately. Set `telemetry.ocsfEndpoint: ""` in `containerDefaults` to turn export off. OpenShell drops events it cannot export, and nothing waits for the collector. From 42905acb7637508fe018426aebe6d296cfeecb26 Mon Sep 17 00:00:00 2001 From: sauagarwa Date: Mon, 30 Nov 2026 18:03:51 +0000 Subject: [PATCH 24/24] Read the custom model's settings from the inference Secret thinking, reasoning, maxTokens and contextWindow were literals in the custom-inference sandbox profile. They are now optional inputs from the inference Secret (thinking, reasoning, max_tokens, context_window): a key that is absent or empty is not applied, so OpenClaw keeps its own default. Literals still work for other profiles. The catalog and RHDH forms list them as optional fields, and values-secret.yaml.template shows them under the custom-inference entry. Assisted-By: Claude --- .../files/create-workspace-for-user.yaml | 16 +++- .../files/create-workspace.yaml | 15 ++- .../openshell-rhdh/files/profile-catalog.json | 24 +++++ .../openshell-saw/files/installer/saw_core.py | 94 ++++++++++++------- .../custom-inference/default/sandbox.yaml | 30 ++++-- charts/saw-users/files/profile-catalog.json | 24 +++++ scripts/saw-profile-catalog.py | 10 +- tests/installer/test_custom_endpoint.py | 41 +++++++- tests/installer/test_review_135.py | 6 +- values-secret.yaml.template | 9 ++ 10 files changed, 215 insertions(+), 54 deletions(-) diff --git a/charts/openshell-rhdh/files/create-workspace-for-user.yaml b/charts/openshell-rhdh/files/create-workspace-for-user.yaml index a1d46dcdb..16bb26ba2 100644 --- a/charts/openshell-rhdh/files/create-workspace-for-user.yaml +++ b/charts/openshell-rhdh/files/create-workspace-for-user.yaml @@ -60,6 +60,10 @@ spec: inference__url: {title: 'inference: Endpoint base URL (OpenAI-compatible, ending in /v1)', type: string, pattern: '^https?://'} inference__model: {title: 'inference: Model', type: string} + inference__thinking: {title: 'inference: Default thinking level', type: string} + inference__reasoning: {title: 'inference: Reasoning model (true or false)', type: string} + inference__max_tokens: {title: 'inference: Maximum output tokens', type: string} + inference__context_window: {title: 'inference: Context window (tokens)', type: string} required: [inference__api_key, inference__url, inference__model] allOf: - if: @@ -116,11 +120,13 @@ spec: stringData: {action: create, token: '${{ secrets.backstageToken }}', profile: '${{ parameters.profile }}', deploymentMode: '${{ parameters.deploymentMode }}', forUser: '${{ parameters.forUser }}', inference.api_key: '${{ secrets.inference__api_key }}', inference.url: '${{ parameters.inference__url - }}', inference.model: '${{ parameters.inference__model }}', web-search.api_key: '${{ secrets.web_search__api_key - }}', inference.cuda_model: '${{ parameters.inference__cuda_model }}', gmail.client_id: '${{ - secrets.gmail__client_id }}', gmail.client_secret: '${{ secrets.gmail__client_secret }}', - gmail.refresh_token: '${{ secrets.gmail__refresh_token }}', slack.bot_token: '${{ secrets.slack__bot_token - }}'} + }}', inference.model: '${{ parameters.inference__model }}', inference.thinking: '${{ parameters.inference__thinking + }}', inference.reasoning: '${{ parameters.inference__reasoning }}', inference.max_tokens: '${{ + parameters.inference__max_tokens }}', inference.context_window: '${{ parameters.inference__context_window + }}', web-search.api_key: '${{ secrets.web_search__api_key }}', inference.cuda_model: '${{ + parameters.inference__cuda_model }}', gmail.client_id: '${{ secrets.gmail__client_id }}', + gmail.client_secret: '${{ secrets.gmail__client_secret }}', gmail.refresh_token: '${{ secrets.gmail__refresh_token + }}', slack.bot_token: '${{ secrets.slack__bot_token }}'} - id: run name: Start the pipeline action: http:backstage:request diff --git a/charts/openshell-rhdh/files/create-workspace.yaml b/charts/openshell-rhdh/files/create-workspace.yaml index 64e754a7f..35636673f 100644 --- a/charts/openshell-rhdh/files/create-workspace.yaml +++ b/charts/openshell-rhdh/files/create-workspace.yaml @@ -52,6 +52,10 @@ spec: inference__url: {title: 'inference: Endpoint base URL (OpenAI-compatible, ending in /v1)', type: string, pattern: '^https?://'} inference__model: {title: 'inference: Model', type: string} + inference__thinking: {title: 'inference: Default thinking level', type: string} + inference__reasoning: {title: 'inference: Reasoning model (true or false)', type: string} + inference__max_tokens: {title: 'inference: Maximum output tokens', type: string} + inference__context_window: {title: 'inference: Context window (tokens)', type: string} required: [inference__api_key, inference__url, inference__model] allOf: - if: @@ -108,10 +112,13 @@ spec: stringData: {action: create, token: '${{ secrets.backstageToken }}', profile: '${{ parameters.profile }}', deploymentMode: '${{ parameters.deploymentMode }}', inference.api_key: '${{ secrets.inference__api_key }}', inference.url: '${{ parameters.inference__url }}', inference.model: '${{ parameters.inference__model - }}', web-search.api_key: '${{ secrets.web_search__api_key }}', inference.cuda_model: '${{ - parameters.inference__cuda_model }}', gmail.client_id: '${{ secrets.gmail__client_id }}', - gmail.client_secret: '${{ secrets.gmail__client_secret }}', gmail.refresh_token: '${{ secrets.gmail__refresh_token - }}', slack.bot_token: '${{ secrets.slack__bot_token }}'} + }}', inference.thinking: '${{ parameters.inference__thinking }}', inference.reasoning: '${{ + parameters.inference__reasoning }}', inference.max_tokens: '${{ parameters.inference__max_tokens + }}', inference.context_window: '${{ parameters.inference__context_window }}', web-search.api_key: '${{ + secrets.web_search__api_key }}', inference.cuda_model: '${{ parameters.inference__cuda_model + }}', gmail.client_id: '${{ secrets.gmail__client_id }}', gmail.client_secret: '${{ secrets.gmail__client_secret + }}', gmail.refresh_token: '${{ secrets.gmail__refresh_token }}', slack.bot_token: '${{ secrets.slack__bot_token + }}'} - id: run name: Start the pipeline action: http:backstage:request diff --git a/charts/openshell-rhdh/files/profile-catalog.json b/charts/openshell-rhdh/files/profile-catalog.json index e8edccb1d..49cb08b08 100644 --- a/charts/openshell-rhdh/files/profile-catalog.json +++ b/charts/openshell-rhdh/files/profile-catalog.json @@ -79,6 +79,30 @@ "kind": "text", "required": true, "title": "Model" + }, + { + "key": "thinking", + "kind": "text", + "required": false, + "title": "Default thinking level" + }, + { + "key": "reasoning", + "kind": "text", + "required": false, + "title": "Reasoning model (true or false)" + }, + { + "key": "max_tokens", + "kind": "text", + "required": false, + "title": "Maximum output tokens" + }, + { + "key": "context_window", + "kind": "text", + "required": false, + "title": "Context window (tokens)" } ], "provider": "custom-inference", diff --git a/charts/openshell-saw/files/installer/saw_core.py b/charts/openshell-saw/files/installer/saw_core.py index cf0c9b21f..599383085 100644 --- a/charts/openshell-saw/files/installer/saw_core.py +++ b/charts/openshell-saw/files/installer/saw_core.py @@ -203,7 +203,8 @@ class Sandbox: # baseUrl?, model, models?, timeoutSeconds?, thinking?, reasoning?, maxTokens?, # contextWindow?}. models maps optional native # provider names to additional chat model inputs. baseUrl/model/timeoutSeconds - # is a literal or an input ({secretKeyRef: {name, key}, default?, + # and the model settings (thinking, reasoning, maxTokens, contextWindow) + # are each a literal or an input ({secretKeyRef: {name, key}, default?, # required?, title?}); inference_values is it resolved. The installer onboards the # agent from it (by protocol, so any profile-backed provider type works). inference: dict = field(default_factory=dict) @@ -420,14 +421,12 @@ def validate_profile_document(doc, kind, where="profile"): if "protocol" in inference and not isinstance(inference["protocol"], str): raise InstallerError(f"{where}: inference.protocol must be a string") inference = _thinking_off(inference) - if "thinking" in inference and inference["thinking"] not in THINKING_LEVELS: - raise InstallerError(f"{where}: inference.thinking must be one of " - + ", ".join(THINKING_LEVELS)) - if "reasoning" in inference and not isinstance(inference["reasoning"], bool): - raise InstallerError(f"{where}: inference.reasoning must be true or false") - for field_name in MODEL_LIMIT_KEYS: - if field_name in inference and not _positive_int(inference[field_name]): - raise InstallerError(f"{where}: inference.{field_name} must be a positive integer") + for field_name in MODEL_SETTING_KEYS: + if isinstance(inference.get(field_name), dict): + _profile_input(inference[field_name], (str,), where) + elif field_name in inference and model_setting_problem(field_name, inference[field_name]): + raise InstallerError(f"{where}: inference.{field_name} " + + model_setting_problem(field_name, inference[field_name])) for field_name in ("model", "baseUrl", "timeoutSeconds"): kinds = (str, int) if field_name == "timeoutSeconds" else (str,) if field_name in inference: @@ -743,6 +742,10 @@ def _thinking_off(inference): # The custom model's output and context limits, written to its OpenClaw model # entry (like NemoClaw's MODEL_MAX_TOKENS and MODEL_CONTEXT_WINDOW). MODEL_LIMIT_KEYS = ("maxTokens", "contextWindow") +# OpenClaw model settings a profile may give as a literal or as an input +# (usually optional: {secretKeyRef, required: false}); an input that resolves +# to "" leaves the setting unapplied. +MODEL_SETTING_KEYS = ("thinking", "reasoning") + MODEL_LIMIT_KEYS def _positive_int(value): @@ -753,6 +756,32 @@ def _positive_int(value): return value.isdigit() and int(value) > 0 return isinstance(value, int) and value > 0 +def model_setting_problem(key, value): + """What is wrong with a literal model setting ("" when fine).""" + if key == "thinking": + return "" if value in THINKING_LEVELS else "must be one of " + ", ".join(THINKING_LEVELS) + if key == "reasoning": + return "" if isinstance(value, bool) else "must be true or false" + return "" if _positive_int(value) else "must be a positive integer" + + +def parse_model_setting(key, text, what): + """A model setting read from a Secret (text) as its typed value.""" + text = text.strip() + if key == "reasoning": + if text.lower() not in ("true", "false"): + raise InstallerError(f"{what} must be true or false") + return text.lower() == "true" + if key == "thinking": + value = text.lower() + else: + value = int(text) if text.isdigit() else text + problem = model_setting_problem(key, value) + if problem: + raise InstallerError(f"{what} {problem}") + return value + + # OpenClaw thinking levels a profile may make the model's default. A level # other than off also marks the model as a reasoning model that accepts # these efforts, which OpenClaw only assumes for its own known models. @@ -984,13 +1013,19 @@ def resolve_inference(ws, sb, read_value, validate_endpoint, forbidden=()): if timeout and (not str(timeout).isdigit() or int(timeout) < 0): raise InstallerError(f"{where}: inference timeoutSeconds must be a non-negative integer") out["timeoutSeconds"] = int(timeout) if timeout else 0 - if spec.get("thinking"): - out["thinking"] = spec["thinking"] - if "reasoning" in spec: - out["reasoning"] = spec["reasoning"] - for key in MODEL_LIMIT_KEYS: - if key in spec: - out[key] = int(spec[key]) + for key in MODEL_SETTING_KEYS: + if key not in spec: + continue + src = spec[key] + if isinstance(src, dict): + text = resolve_bom_input(src, read_value, f"{where}: inference {key}", forbidden) + if text: + out[key] = parse_model_setting(key, text, f"{where}: inference {key}") + elif key == "thinking": + if src: + out[key] = src + else: + out[key] = int(src) if key in MODEL_LIMIT_KEYS else src if "models" in spec: out["models"] = {} for name, src in spec["models"].items(): @@ -1050,22 +1085,17 @@ def sandbox_inference_problems(sb, provider_types, declared_provider_types=None) for key in ("baseUrl", "model"): if key in spec: out += [f"inference {key} {p}" for p in input_problems(spec[key])] - if "thinking" in spec: - if spec["thinking"] not in THINKING_LEVELS: - out.append(f"inference thinking must be one of {', '.join(THINKING_LEVELS)}") - elif sb.type != "openclaw": - out.append("inference thinking is supported only for openclaw sandboxes") - if "reasoning" in spec: - if not isinstance(spec["reasoning"], bool): - out.append("inference reasoning must be true or false") + for key in MODEL_SETTING_KEYS: + if key not in spec: + continue + src = spec[key] + problems = ([f"inference {key} {p}" for p in input_problems(src)] if isinstance(src, dict) + else [f"inference {key} {model_setting_problem(key, src)}"] + if model_setting_problem(key, src) else []) + if problems: + out += problems elif sb.type != "openclaw": - out.append("inference reasoning is supported only for openclaw sandboxes") - for key in MODEL_LIMIT_KEYS: - if key in spec: - if not _positive_int(spec[key]): - out.append(f"inference {key} must be a positive integer") - elif sb.type != "openclaw": - out.append(f"inference {key} is supported only for openclaw sandboxes") + out.append(f"inference {key} is supported only for openclaw sandboxes") models = spec.get("models", {}) if not isinstance(models, dict): out.append("inference models must be a mapping of provider names to model inputs") @@ -1117,7 +1147,7 @@ def profiles_from_plan(data): 'SANDBOX_TYPES', 'BASE_URL_CONFIG_KEYS', 'InstallerError', 'Provider', 'Sandbox', 'Workspace', 'Profile', 'HarnessBundle', 'read_profile_files', '_yaml', 'parse_profiles', 'enabled_workspaces', 'validate_profiles', 'ENV_NAME_RE', 'CREDENTIAL_NAME_RE', 'ENV_VALUE_LIMIT', 'SANDBOX_ENV_KEYS', - 'INPUT_KEYS', 'secret_ref', 'secret_ref_problems', 'INFERENCE_KEYS', 'MODEL_LIMIT_KEYS', 'INFERENCE_PROTOCOLS', 'THINKING_LEVELS', 'REASONING_EFFORTS', + 'INPUT_KEYS', 'secret_ref', 'secret_ref_problems', 'INFERENCE_KEYS', 'MODEL_LIMIT_KEYS', 'MODEL_SETTING_KEYS', 'INFERENCE_PROTOCOLS', 'THINKING_LEVELS', 'REASONING_EFFORTS', 'PROVIDER_PROTOCOLS', 'check_env_value', 'sandbox_env_problems', 'input_problems', 'check_base_url', 'resolve_bom_input', 'resolve_inference', 'inference_protocol', 'sandbox_inference_problems', 'harness_from_plan', 'profiles_from_plan', 'validate_profile_document', 'apply_workspace_sequence', 'select_inference_provider', diff --git a/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml b/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml index b34eba6a4..fdb3466af 100644 --- a/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml +++ b/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml @@ -31,13 +31,29 @@ spec: title: Model # Self-hosted models can take longer than the agent's default. timeoutSeconds: "300" - # The model's default thinking level (a chat's /think overrides it). - thinking: high - # Not a reasoning model (MODEL_REASONING=false): no reasoning_effort - # is sent, whatever the thinking level. - reasoning: false + # Optional model settings, read from the same `inference` Secret + # (values-secret.yaml). A key that is absent or empty is not applied: + # OpenClaw keeps its own default for that setting. + # The model's default thinking level (off, minimal, low, medium or high; + # a chat's /think overrides it). + thinking: + secretKeyRef: {name: inference, key: thinking} + required: false + title: Default thinking level + # false for a model that is not a reasoning model (MODEL_REASONING=false): + # no reasoning_effort is sent, whatever the thinking level. + reasoning: + secretKeyRef: {name: inference, key: reasoning} + required: false + title: Reasoning model (true or false) # MODEL_MAX_TOKENS / MODEL_CONTEXT_WINDOW for the model's entry. - maxTokens: 32768 - contextWindow: 128000 + maxTokens: + secretKeyRef: {name: inference, key: max_tokens} + required: false + title: Maximum output tokens + contextWindow: + secretKeyRef: {name: inference, key: context_window} + required: false + title: Context window (tokens) ui: route: true diff --git a/charts/saw-users/files/profile-catalog.json b/charts/saw-users/files/profile-catalog.json index e8edccb1d..49cb08b08 100644 --- a/charts/saw-users/files/profile-catalog.json +++ b/charts/saw-users/files/profile-catalog.json @@ -79,6 +79,30 @@ "kind": "text", "required": true, "title": "Model" + }, + { + "key": "thinking", + "kind": "text", + "required": false, + "title": "Default thinking level" + }, + { + "key": "reasoning", + "kind": "text", + "required": false, + "title": "Reasoning model (true or false)" + }, + { + "key": "max_tokens", + "kind": "text", + "required": false, + "title": "Maximum output tokens" + }, + { + "key": "context_window", + "kind": "text", + "required": false, + "title": "Context window (tokens)" } ], "provider": "custom-inference", diff --git a/scripts/saw-profile-catalog.py b/scripts/saw-profile-catalog.py index 789e30b61..36abecfc2 100644 --- a/scripts/saw-profile-catalog.py +++ b/scripts/saw-profile-catalog.py @@ -137,13 +137,17 @@ def secret_ref(src): def sandbox_fields(sandbox, providers=None): """(secret, field) for each input a sandbox reads from a Secret, as the - installer does: its `inference:` settings (baseUrl: a URL field; model and - timeoutSeconds: text). `env:` entries are literals fixed by the profile + installer does: its `inference:` settings (baseUrl: a URL field; model, + timeoutSeconds and the model settings: text). `env:` entries are literals fixed by the profile (a Secret value belongs on a provider) and are not asked for.""" inference = sandbox.get("inference") or {} for key, kind, title in (("baseUrl", "url", "Endpoint base URL"), ("model", "text", "Model"), - ("timeoutSeconds", "text", "Request timeout (seconds)")): + ("timeoutSeconds", "text", "Request timeout (seconds)"), + ("thinking", "text", "Default thinking level"), + ("reasoning", "text", "Reasoning model (true or false)"), + ("maxTokens", "text", "Maximum output tokens"), + ("contextWindow", "text", "Context window (tokens)")): src = inference.get(key) if secret_ref(src): yield secret_ref(src)[0], input_field(src, kind, f"{title} ({sandbox['name']})") diff --git a/tests/installer/test_custom_endpoint.py b/tests/installer/test_custom_endpoint.py index 8131d88d0..27143ac2b 100644 --- a/tests/installer/test_custom_endpoint.py +++ b/tests/installer/test_custom_endpoint.py @@ -19,6 +19,9 @@ MODEL = "meta-llama/Llama-3.1-8B-Instruct" ROOT = Path(__file__).resolve().parents[2] EXTRA_PROFILE = ROOT / "overrides/governance-profiles/custom-inference.yaml" +# The optional model settings, as the inference Secret carries them. +MODEL_SETTINGS = {"thinking": "high", "reasoning": "false", "max_tokens": "32768", + "context_window": "128000"} DEFAULT_CATALOG = {"web-search": ["api.tavily.com", "api.search.brave.com", "registry.npmjs.org"], "brave": ["api.search.brave.com"], "nvidia": ["integrate.api.nvidia.com"]} @@ -36,7 +39,7 @@ def governed_catalog(fake_env): def custom_secrets(secrets_dir): inference = secrets_dir / "inference" for key, value in {"provider": "custom-inference", - "url": URL + "/", "model": MODEL}.items(): + "url": URL + "/", "model": MODEL, **MODEL_SETTINGS}.items(): (inference / key).write_text(value + "\n") return secrets_dir @@ -465,5 +468,39 @@ def test_an_unquoted_yaml_off_means_off(ab): """YAML 1.1 reads `thinking: off` as false; it still means off.""" files = profile_files("custom-inference") key = next(k for k in files if k.endswith("__sandbox.yaml")) - files[key] = files[key].replace("thinking: high", "thinking: off") + doc = yaml.safe_load(files[key]) + doc["spec"]["sandboxes"][0]["inference"]["thinking"] = "off" + files[key] = yaml.safe_dump(doc).replace("thinking: 'off'", "thinking: off") assert notebook(ab.parse_profiles(files)).inference["thinking"] == "off" + + +def test_model_settings_left_out_of_the_secret_are_not_applied(ab, profiles, custom_secrets): + """The settings are optional Secret inputs: an absent or empty key leaves + the setting out, so OpenClaw keeps its own default.""" + (custom_secrets / "inference" / "thinking").unlink() + (custom_secrets / "inference" / "max_tokens").write_text("\n") + resolve(ab, profiles, custom_secrets) + values = notebook(profiles).inference_values + assert "thinking" not in values and "maxTokens" not in values + assert (values["reasoning"], values["contextWindow"]) == (False, 128000) + for key in ("reasoning", "context_window"): + (custom_secrets / "inference" / key).unlink() + profiles2 = ab.parse_profiles(profile_files("custom-inference")) + resolve(ab, profiles2, custom_secrets) + assert not set(ab.MODEL_SETTING_KEYS) & set(notebook(profiles2).inference_values) + + +@pytest.mark.parametrize("key,value", [("thinking", "max"), ("reasoning", "no"), + ("max_tokens", "0"), ("context_window", "big")]) +def test_bad_model_settings_in_the_secret_are_refused(ab, profiles, custom_secrets, key, value): + (custom_secrets / "inference" / key).write_text(value + "\n") + with pytest.raises(ab.InstallerError, match="inference"): + resolve(ab, profiles, custom_secrets) + + +def test_the_secret_settings_are_optional_form_fields(ab, profiles): + """Shipped as inputs, not literals: valid, and not required.""" + spec = notebook(profiles).inference + for key in ab.MODEL_SETTING_KEYS: + assert spec[key]["required"] is False + assert not ab.sandbox_inference_problems(notebook(profiles), {"custom-inference": "custom-inference"}) diff --git a/tests/installer/test_review_135.py b/tests/installer/test_review_135.py index 38a7a5f13..e7125b0b5 100644 --- a/tests/installer/test_review_135.py +++ b/tests/installer/test_review_135.py @@ -859,7 +859,11 @@ def test_the_shipped_form_fields_match_the_profiles(): cat = json.loads((ROOT / "charts" / "openshell-rhdh" / "files" / "profile-catalog.json").read_text())["profiles"] custom = {f["key"]: f for f in cat["custom-inference"]["secrets"]["inference"]["fields"]} - assert set(custom) == {"api_key", "url", "model"} + assert set(custom) == {"api_key", "url", "model", "thinking", "reasoning", "max_tokens", + "context_window"} + # The model settings are optional: absent, OpenClaw keeps its default. + assert not any(custom[k]["required"] for k in ("thinking", "reasoning", "max_tokens", + "context_window")) assert custom["url"]["kind"] == "url" and custom["url"]["required"] ds = {f["key"]: f for f in cat["data-science"]["secrets"]["inference"]["fields"]} # One model field per sandbox: selections are not coupled. diff --git a/values-secret.yaml.template b/values-secret.yaml.template index abd0437e9..d627af4e1 100644 --- a/values-secret.yaml.template +++ b/values-secret.yaml.template @@ -46,6 +46,15 @@ secrets: # # Custom keyed ports and service-CA trust are follow-up #137. # - name: api_key # path: ~/.custom-inference-api-key # may be empty for a keyless endpoint + # # Optional model settings; leave any out to keep OpenClaw's default. + # - name: thinking # off, minimal, low, medium or high + # value: high + # - name: reasoning # false: not a reasoning model, no reasoning_effort sent + # value: "false" + # - name: max_tokens # maximum output tokens + # value: "32768" + # - name: context_window # context window in tokens + # value: "128000" # Optional official APIs: enable each provider and add its name to # notebook.providers in charts/saw-bom/profiles/data-science/default.