diff --git a/Makefile.custom.mk b/Makefile.custom.mk index 5c4446c2..64cdea89 100644 --- a/Makefile.custom.mk +++ b/Makefile.custom.mk @@ -1478,6 +1478,17 @@ verify-mcp-kubernetes-registration: ## Assert the bundled mcp-kubernetes registr @python3 tests/verify-mcp-kubernetes-registration.py $(CHART_DIR) $(CONNECTIVITY_DIR) @echo "mcp-kubernetes registration shapes verified." +.PHONY: verify-agent-chart-line +verify-agent-chart-line: ## Assert that agent-manager.agentChart.semver moves to agent chart 3.x only together with agent-manager at agent-platform.agentManager.agentChartV3Floor (its migrate rewrites muster.requireApproval to default: Ask), muster at agent-platform.muster.agentApprovalFloor (enforces it), agent-manager's tool approval on and the default agent's range on the same major; a range is read as agent-manager's migrate reads it (spanning majors or only pre-releases fails, ~3.2 and bounded forms count as 3.x); the placeholder floors are unset (every 3.x line refused) or above the last release without the feature, and the gated paths run on a chart copy with test floors; the 3.x line reaches agent-manager, the migrate run's connectivity release and the default agent's source; the migrate run may list namespaces and, with organizations on, read releases, sources and Agents cluster-wide, and only on the 3.x line itself (not a preflight) update HelmReleases and write its report ConfigMap, held by agent-platform-organization-migrate-scope; every alternative of a || range and every version a range names count (3.0.1 || 2.6.0 spans two majors). Stdlib only. HELM selects the binary. + @echo "====> $@ ($(CHART_DIR), $(CONNECTIVITY_DIR))" + @HELM="$(HELM)" HELM_LEGACY="$(if $(filter-out $(HELM_PINNED_VERSION)+%,$(HELM_VERSION)),$(wildcard $(HELM_PINNED)))" python3 tests/verify-agent-chart-line.py $(CHART_DIR) $(CONNECTIVITY_DIR) + +.PHONY: verify-tool-approval +verify-tool-approval: ## Assert the platform side of Governing tool calls: the top-level governance and governedServers values render muster's governance configuration into the muster release (muster.governance: mode, governedServers {server, role, safe} per shipped MCPServer, keyed namespace/name outside muster's namespace, an own entry standing) from the muster floor agent-platform.muster.governanceFloor, none below it, governed below it, the earlier servers shape, unknown keys and conflicting or unknown modes failing; coverage: every shipped MCPServer source (meta releases carrying muster.mcpServer, the connectivity chart's MCPServers, agent-platform-mcps' families, and the component charts beside this checkout, COMPONENT_CHECKOUTS) is governed or in governanceExempt, no floor is safe, every safe entry names a tool of its server, the two kubernetes maps agree; the redirect allowlist (portal /sessions with backstage.publicPort, klaus-gateway's return with its port, invalid ports and URLs failing); the connector-admin role binds the Giant Swarm admin groups plus tenants.platformTeam; muster-approval-binder's subjects are agent-manager's ServiceAccount only (muster.rbac.approvalBinder.subjects), none from the connectivity chart; agent-manager's muster.toolApproval.enabled on from its floor and muster's agent approval floor, off below muster's, absent below its own, an own value standing; the connectivity MCPServers carry explicit approval settings (a Block rule renders, overrides reach spec.approval also from the meta chart, null renders none, invalid values fail naming the key). Stdlib only. HELM selects the binary. + @echo "====> $@ ($(CHART_DIR), $(CONNECTIVITY_DIR))" + @HELM="$(HELM)" python3 tests/verify-tool-approval.py $(CHART_DIR) $(CONNECTIVITY_DIR) + @echo "tool approval verified." + .PHONY: verify-self verify-self: ## Assert self-management's shapes: engine off renders nothing of it; engine on renders the self OCIRepository + suspended HelmRelease, the -6/-5/0 hooks, the identity and the admission policy (CLI day-0 only); engine on with self off (lab, hand-back) renders the -6/-5 hooks at pre-upgrade too and nothing else; the guards and knobs. HELM selects the binary. @echo "====> $@ ($(CHART_DIR))" diff --git a/README.md b/README.md index 49b95497..170bba73 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ Then point any MCP client at `https://muster./mcp`. Its traffic cro | [Operator reference](docs/reference.md) | Every component and value: GitOps engine, self-management, serving and runtime slices, network policies, observability, CRD lifecycle | | [Authentication](docs/authentication.md) | The request path, OAuth discovery, token forwarding and exchange, edge JWT validation | | [Toolset presets](docs/toolset-presets.md) | Choosing which tools an agent gets | +| [Tool approval](docs/tool-approval.md) | Allow, Ask or Block per connector and tool, the governance mode and who sets what ([chart values](helm/agent-platform/README.md#tool-approval-and-the-governance-mode)) | | [Serving presets](docs/serving-presets.md) | Adding and benchmarking a model recipe | | [ChatGPT login](docs/chatgpt-login.md) | Running codex on each person's own ChatGPT subscription | | [Agent Substrate security](docs/substrate-security.md) | What the agent runtime changes on the cluster, and what protects it | diff --git a/UPGRADE.md b/UPGRADE.md index 2b4a814e..b1f68b90 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -30,6 +30,61 @@ Every component ships its own CRDs and upgrades them with its release; there is A CRD version change that needs more than an apply (a stored version dropped, as with kagent's `v1alpha2`) has its own entry below, with the hook that does it. +## \ → \ (agent chart 3.0: `muster.requireApproval` becomes `default: Ask`) + +Agent chart 3.0 removes `muster.requireApproval` and the default of `modelConfig.name`. `default: Ask` replaces `requireApproval: true`: muster asks a person before every tool call the agent makes through it, from every client. `agent-manager.agentChart.semver` moves the agents of the whole installation: agent-manager composes new agents on it, its migrate run (the connectivity release's start hook) rewrites the existing releases, and the agent-platform-operator moves each organization's chart source once migrate marks that organization ready. + +The render allows the 3.x line only together with `make verify-agent-chart-line`'s conditions: agent-manager at `agent-platform.agentManager.agentChartV3Floor`, muster at `agent-platform.muster.agentApprovalFloor`, agent-manager's tool approval on, and the default agent's range on the same major. **Both floors are unset in this chart** until the releases carrying tool approval exist, so every 3.x range is refused for now; the platform release that pins those versions sets them. The other tool approval floors (`agentManager.toolApprovalFloor`, `muster.governanceFloor`, `muster.sessionBindingsPortFloor`) behave the same: unset, what they gate stays off and `governance: governed` fails. A range admitting two majors or only pre-releases fails. + +What migrate does: + +| Case | Result | +|------|--------| +| Release owned by agent-manager | Rewritten: `requireApproval: true` becomes `default: Ask`, the key is dropped, an unset `modelConfig.name` becomes `default-model-config` | +| Release with `spec.valuesFrom` | `failed`: move the settings into `spec.values` | +| Pinned, git-owned or platform release | `pending` with a diff to apply | +| Organization namespace | Same rules; GitOps-owned releases get a diff. Annotates the namespace `agent-platform.giantswarm.io/agent-chart-ready-major: "3"` once every release is on 3.x values | + +Any `failed` or `pending` release keeps the namespace in the expand phase. The operator moves an organization's source only on that annotation; until then the organization is `Ready=False` (`ChartSourceHeld`) and its releases stay on 2.x, still asking. A release created on the 2.x source after the run is not covered: the operator holds the source and names it until migrate runs again. + +### Operator action + +- **Before the upgrade (mandatory), with the line still on 2.x:** set `agentManager.migration.preflightSemver: ">=3.0.0 <4.0.0"`, run `kubectl -n create job --from=cronjob/-agent-manager-migrate-preflight preflight-1` and read `kubectl -n logs job/preflight-1` (a dry run writes nothing). Fix every release it lists that the run will not write (`failed`, and `diff` ones you own in git), organization namespaces included, then unset `preflightSemver`. Also list releases with `valuesFrom` or without the 3.x settings: `kubectl get helmreleases -A -o json | jq -r '.items[] | select(.spec.values.muster.requireApproval != null or .spec.values.modelConfig.name == null or (.spec.valuesFrom // [] | length > 0)) | "\(.metadata.namespace)/\(.metadata.name)"'`. +- **The repair is always `muster.requireApproval: true` to `default: Ask`**, never just deleting the key (that turns asks off); drop `false` and `null`; set `modelConfig.name` where unset. In git, apply it together with moving that release's chart source to 3.x. +- Once the floors are set, move `agent-manager.agentChart.semver` and `components.default-agent.versionRange` to `>=3.0.0 <4.0.0` together with `components.agent-manager.versionRange` and `components.muster.versionRange` at or above the floors. With organizations on, set `agentManager.migration.cutover: true` in the same change (a boolean; without it the organizations' sources stay held). +- Tool approval's prerequisites must hold (muster's OAuth server with Dex sign-in, Valkey; see the next entry): without them muster refuses every call that asks, so a migrated agent cannot call its tools. It never runs them unasked. +- Running Sessions: with agent-manager at `agentManager.toolApprovalFloor`, it binds `default: Ask` for a Session of an agent still on `requireApproval: true` already on 2.x. That agent needs the prerequisites from then on and is asked twice (kagent and muster) until migrated. Sessions from an older agent-manager carry no settings and muster applies the agent's `X-Muster-Tool-Approval: default=Ask`. +- Read the report: `kubectl -n get configmap agent-manager-migrate-report -o jsonpath='{.data.report\.yaml}'`. A release with `requireApproval: true` beside tool approval settings is `failed`: set its settings by hand. The run needs list on namespaces and, in organization namespaces, read access and update on HelmReleases and its report ConfigMap (granted only on the 3.x line with `cutover`, scoped by the ValidatingAdmissionPolicy `agent-platform-organization-migrate-scope`); without them it fails before writing. +- **Per organization:** `kubectl get agentplatformorganizations -A -o json | jq -r '.items[] | select(any(.status.conditions[]?; .reason == "ChartSourceHeld")) | "\(.metadata.namespace)/\(.metadata.name)"'` lists those still on 2.x; the report in the organization's namespace names the releases that hold it. Apply each diff in the organization's repository, then run migrate again: `kubectl -n create job --from=cronjob/-agent-manager-migrate migrate-2` (also after a failed write, and when the condition names releases created after the run). Once none is held, unset `cutover`. + +## \ → \ (tool approval and the governance mode) + +muster decides Allow, Ask or Block for every tool call; the chart renders its governance configuration, the approval page's installation name, the redirect allowlist and the approval binder ([chart README](helm/agent-platform/README.md#tool-approval-and-the-governance-mode)). None of it reaches a muster below `agent-platform.muster.governanceFloor`. + +### Operator action + +- Move `components.muster.versionRange` to the muster release carrying tool approval. `governance.mode: governed` below it fails the render. +- The floors are muster `5.67.0-rc.61` and agent-manager `4.1.0-rc.1`. A pinned BOM moves muster, agent-manager and the MCPServer components to the pins in `examples/customer-bom.yaml`. +- After muster's CRD upgrade, force a reconcile of the releases that render MCPServers (connectivity, agent-platform-mcps, the managers) if any was applied while the old CRD was served (its `spec.approval` was pruned): `flux reconcile helmrelease -n --force`. Until then muster refuses every server tool. Check with `kubectl get mcpservers -A -o custom-columns=NAME:.metadata.name,RULE:.spec.approval.rule`. +- **Editor defaults changed.** `muster.rbac.mcpServerEditor.subjects` (connector admins) and `muster.rbac.workflowEditor.subjects` default to a ServiceAccount nobody can authenticate as (`kube-system/agent-platform-unset-connector-admins`, `...-workflow-editors`); before, they named two fixed admin groups. Set both to your admin groups (with the OIDC groups prefix); `tenants.platformTeam` is still appended. Until then only cluster admins register servers, author workflows or change tool approval. Keep the lists non-empty: muster's chart fails the upgrade with an empty list while its old `system:authenticated` binding exists (`muster.rbac.mcpServerEditor.allowRemovingBinding: true` drops it). `tenants.platform.editors` keeps its earlier default groups: replace them too. +- **`governance` is a map.** Write `governance.mode: governed` where you wrote `governance: governed`; a string fails the render. +- **No server outside the platform's components is governed by default.** Own servers go in `governedServers` with `governance.roleFloors` (set below the muster governance floor, the render fails): + + ```yaml + governance: + roleFloors: + exampleManager: [approve_change, merge_change] + governedServers: + example-manager: + role: exampleManager + safe: [get_info, list_changes] + ``` +- Replace an own `muster.muster.governance.servers.` with `governedServers` entries (the earlier shape fails the render). +- An edge not on 443: set `backstage.publicPort` and remove a hand-written portal entry from `muster.muster.oauth.mcpClient.postLoginRedirectAllowlist`. The allowlist reaches muster only with `muster.muster.oauth.mcpClient.enabled`. +- An agent-manager ServiceAccount the chart does not create (`agent-manager.serviceAccount.create: false`) needs `agent-manager.serviceAccount.name`. +- The connectivity release no longer renders `agent-platform:muster-approval-binder`; the muster release binds `muster-approval-binder` in muster's namespace instead. +- Clients (portal, klaus-gateway, kagent) retry an approved call as the same client of the same person; another client asks anew. + ## \ → \ (vm-manager 0.29: guests run only signed code, pods only from signed layers) `components.vm-manager.versionRange` selects `>=0.29.0 <0.30.0` (the component is off by default). The chart's values are unchanged since 0.27. From 0.28.0 the guest image runs only code from its own signed dm-verity root and sysexts under IPE (giantswarm/vm-manager#266); vm-manager writes the image certificate the guest image artifact carries into each VM's UEFI db, so nothing is configured for it. From 0.29.0 a Kubernetes node runs pods only from container layers whose dm-verity root hash is signed with a trusted key (giantswarm/vm-manager#286). `create_vm` takes two optional arguments: `layer_certificates`, the installation's PEM certificates that layers may be signed with, and `cni_version`, the CNI sysext (default: the newest Cilium the image offers). Release guest images enroll no Giant Swarm layer certificate yet (giantswarm/architect-orb#1084), so a release node trusts only the certificates passed in `layer_certificates`. diff --git a/docs/authentication.md b/docs/authentication.md index f36de28b..322d5bf1 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -44,6 +44,23 @@ muster aggregates many MCP servers behind `/mcp`. Each server entry in `agent-pl muster signs no tokens of its own: every downstream server validates against Dex. A kagent agent acts as the person who started its Session: agent-manager binds the Session's Actor to that person at muster, and the egress gateway puts the Actor's JWT on every call to muster, which serves it as the bound person. The runtime never holds or forwards the person's token: the Harness sets no `KAGENT_PROPAGATE_TOKEN`, so no MCP server receives it, and muster refuses a Session nobody bound. model-manager, agent-manager, cluster-manager and mcp-kubernetes receive the person's token with the audience `dex-k8s-authenticator` and act on the cluster with that person's RBAC (install.md, [The identity provider](install.md#the-identity-provider)). +### The portal's own client and sign-in handoff + +By default the portal signs in with the platform's shared client (`global.identity.clientId`). `backstage.oidcClientId` gives it a client of its own at the same issuer: + +- The identity provider registers it with the portal's redirect URI only (`https:///api/auth/oidc-agent-platform/handler/frame`); its secret goes into `global.identity.existingSecret` under `portal-dex-client-secret`. +- The portal also requests the platform client's audience (`audience:server:client_id:`, added to `backstage.extraScopes`), so every component that trusts the platform client accepts its tokens unchanged; `azp` names the portal's client. On Dex, the platform client and `dex-k8s-authenticator` list the portal's client under `trustedPeers`. +- muster keys a forwarded token's session by its client too: a person's connector sign-ins through the shared client are not the portal's, except subject-scoped ones (`spec.auth.grantScope: subject`). + +With a dedicated client and `backstage.signInHandoff` on (default), the chart lists that client, and only it, in muster's `approval.trustedClients` (from `agent-platform.muster.trustedClientsFloor`; below it none). The portal then shows a tool approval inline and posts the decision to muster (`POST /approvals/{id}/decision`) with the person's token and the digest of what was shown, and *Open* on a connector sign-in prompt gets a one-time ticket from `POST /handoff-tickets`. A person's portal token is not held by the portal backend alone (the browser, `forwardToken` servers and runtimes hold it too), so muster takes it on these two endpoints only together with the backend's own workload identity: its projected ServiceAccount token (audience `muster`, in `X-Muster-Approval-Client`, checked by `TokenReview` and a `LocalSubjectAccessReview` for `decide` on `toolapprovals.muster.giantswarm.io`). The chart binds muster's Role `muster-approval-decider` to the portal's ServiceAccount (`muster.rbac.approvalDecider.subjects`; an own list stands) and projects the token at `/var/run/secrets/muster.giantswarm.io/serviceaccount/token`. Either token alone decides nothing and mints no ticket. A portal deployed as its own release (`components.backstage` off) gets neither: name its ServiceAccount in `muster.rbac.approvalDecider.subjects` (ServiceAccounts only, any other kind fails the render) and its client in `muster.muster.approval.trustedClients`, and project the token into its pod yourself. + +- Trade-off: the portal backend can approve a person's pending requests without muster's browser sign-in, on the person's click only. +- muster refuses tokens naming an acting party, an agent's credential, another client, another workload or another person. A ticketed connector sign-in still asks the browser on muster's page first. +- Only the portal's dedicated client may be listed: the render fails when `muster.muster.approval.trustedClients` or `handoffClients` names any other id (the shared client, `dex-k8s-authenticator`, the kagent UI's, klaus-gateway's or a CLI's). +- `backstage.signInHandoff: false` keeps every decision and sign-in on muster's own pages. + +`agentlab portal dev` has no projected token: agentlab mints a lab-only one for the lab portal's ServiceAccount (audience `muster`) on every start and points `muster.workloadTokenFile` at it. Never copy an installation's portal token to a laptop. + ## 4. Edge JWT validation and JWKS agentgateway verifies the JWT itself (`Strict`, against `global.identity.issuerUrl`) on three routes: the kagent controller route ([5](#5-the-kagent-controller-route)), the agent-manager route (`agentManager.route` with its `jwtAuthentication.enabled`, both off by default) and the models Gateway ([6](#6-the-models-gateway)). Each takes its key set from its own `jwtAuthentication.jwks` (`host`, `port`, `path`, `tls`). The agentgateway controller fetches it and pushes the keys to the data plane. A failed fetch refuses every caller with `401 token uses the unknown key`. diff --git a/docs/tool-approval.md b/docs/tool-approval.md new file mode 100644 index 00000000..c2a375aa --- /dev/null +++ b/docs/tool-approval.md @@ -0,0 +1,45 @@ +# Tool approval + +Every tool behind muster, the platform's tool gateway, is **Allow** (runs), **Ask** (a person confirms the exact call first) or **Block** (hidden, refused). muster enforces it on every call, so it holds in the Dev Portal, Slack, Claude Code and an agent's sandbox alike. The chart values, floors and prerequisites are in the chart README ("Tool approval and the governance mode"); upgrade steps are in [UPGRADE.md](../UPGRADE.md). + +## Who sets what + +| Who | Sets | Where | +|---|---|---| +| Connector admin (`muster.rbac.mcpServerEditor.subjects`, `tenants.platformTeam`) | A `rule` for tools without an entry (new ones included) and a setting per tool | The connector's `MCPServer` `spec.approval`, or the Dev Portal's *Connectors* page | +| Agent builder | The agent's tool list, each entry optionally Allow, Ask or Block, plus a `default` | The agent chart's `tools` and `default` | +| Connector admin only | An exception: Allow for one agent on a tool its connector asks for | agent-manager's `set_agent_approval` | + +The stricter of the connector's and the agent's setting holds. A person calling a tool directly gets the connector's setting only. A connector without settings runs every tool and shows as *not reviewed*. + +## Trusted and governed + +`governance.mode` (`trusted`, the default, or `governed`) adds asking for agent callers; it never asks a person using a tool directly. + +- **trusted**: an agent runs what the connector allows. It still asks before it adds or repoints a connector, changes approval settings, grants access or exceptions, authors workflows, or changes muster's configuration (the floors). +- **governed**: besides the floors, an agent asks before any tool of a governed server that is not on its `safe` list in `governedServers`, so a new or renamed tool asks until someone lists it. + +Floors for your own servers go under `governance.roleFloors`; they add to the built-in ones and never narrow them. + +```yaml +governance: + mode: governed + roleFloors: + exampleManager: [approve_change, merge_change] +governedServers: + example-manager: + role: exampleManager + safe: [get_info, list_changes] +``` + +Whoever can change these values can switch the mode or shorten a safe list, and nobody else approves it: protect the values repository with required reviews. + +## What fails closed + +- Asking needs muster's OAuth server with Dex sign-in, Valkey and `muster.muster.oauth.mcpClient.publicUrl`; without them every call that would ask is refused (`approval.unavailable`), never run. +- An agent with nobody to open the approval link runs only what is Allow; the rest expires. +- `governed` fails the render below the release floors (`agent-platform.muster.governanceFloor` and the others in `values.yaml`); a safe list naming a floor, or a `role` declared nowhere, fails muster's start. +- The editor groups default to a ServiceAccount nobody can authenticate as, so until you name your admin groups only cluster admins change approval. +- muster refuses every connector's tools while the `MCPServer` CRD lacks `spec.approval`. + +A selection of tools (the agent's [toolset](toolset-presets.md)) is separate from whether a selected tool runs, asks or is hidden. diff --git a/docs/toolset-presets.md b/docs/toolset-presets.md index e794176c..8e3ac1c6 100644 --- a/docs/toolset-presets.md +++ b/docs/toolset-presets.md @@ -2,6 +2,8 @@ A **toolset** is the selector list an agent declares to say which of the gateway's tools it is composed with: the agent chart's `toolset` value (rendered as the `X-Muster-Toolset` header on the agent's muster tool entry), agent-manager's `toolset` argument, or the `toolset` argument of muster's `filter_tools`. muster evaluates it on every request as one more filter on the caller's own catalogue — it never widens access; the invoking human's identity and the backends' own authorization remain the boundary. The grammar, the built-in presets and the error texts are muster's: [docs/reference/toolsets.md](https://github.com/giantswarm/muster/blob/main/docs/reference/toolsets.md). +A toolset only selects tools; whether a selected tool runs, asks a person or is hidden is its connector's tool approval (`Allow`, `Ask`, `Block`; the agent-platform chart README, "Tool approval and the governance mode"; [Tool approval](tool-approval.md)). Once agent-manager ships per-agent tool lists (`tools` in `create_agent`), the toolset becomes that list: the same selectors, each optionally `Allow`, `Ask` or `Block`, plus a `default`. + A **preset** is a named selection an agent refers to as `preset:`. Presets are muster configuration — `toolsetPresets` in muster's `config.yaml`, which the muster chart renders from its `muster.toolsetPresets` value. This meta-package forwards its `muster:` block to the muster release, so the presets an installation ships live under **`muster.muster.toolsetPresets`** in these values (the first `muster` is the component block, the second is the muster chart's own `muster:` key). ## The presets muster builds in diff --git a/helm/agent-platform-connectivity/README.md b/helm/agent-platform-connectivity/README.md index bad9c1a8..8696a341 100644 --- a/helm/agent-platform-connectivity/README.md +++ b/helm/agent-platform-connectivity/README.md @@ -1282,6 +1282,8 @@ The kagent block is open in the schema, so the template refuses a key under `kag | networkPolicy.substrate.egressGateway.privateCIDRs | list | `[]` | | | networkPolicy.musterInClusterMcpPorts[0] | int | `8080` | | | networkPolicy.musterInClusterMcpPorts[1] | int | `8443` | | +| networkPolicy.musterSessionBindingsPort | int | `0` | | +| networkPolicy.musterSessionBindingsNamespace | string | `""` | | | networkPolicy.mcpBackends | object | `{}` | | | networkPolicy.mcpBackendScrapers[0].namespace | string | `"kube-system"` | | | networkPolicy.mcpBackendScrapers[0].matchLabels."app.kubernetes.io/instance" | string | `"alloy-metrics"` | | @@ -1534,6 +1536,25 @@ The kagent block is open in the schema, so the template refuses a key under `kag | kagent.controllerRoute.mcp.timeout | int | `300` | | | kagent.controllerRoute.mcp.displayName | string | `"Kagent"` | | | kagent.controllerRoute.mcp.description | string | `"Your agent sessions on this installation, as the signed-in person: list them, send one a message, and checkpoint or fork them"` | | +| kagent.controllerRoute.mcp.approval.rule | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.list_sessions | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.invoke_session | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.create_session_checkpoint | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.list_session_checkpoints | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.fork_session | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.list_sandbox_templates | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.create_sandbox | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.list_sandboxes | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.get_sandbox | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.suspend_sandbox | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.resume_sandbox | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.delete_sandbox | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.start_sandbox_process | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.get_sandbox_process | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.kill_sandbox_process | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.read_sandbox_outputs | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.read_sandbox_file | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.write_sandbox_file | string | `"Allow"` | | | kagent.controllerRoute.jwtAuthentication.enabled | bool | `true` | | | kagent.controllerRoute.jwtAuthentication.mode | string | `"Strict"` | | | kagent.controllerRoute.jwtAuthentication.issuer | string | `""` | | @@ -1812,6 +1833,8 @@ The kagent block is open in the schema, so the template refuses a key under `kag | agentManager.migration.image.repository | string | `"giantswarm/agent-manager"` | | | agentManager.migration.image.tag | string | `"3.5.11"` | | | agentManager.migration.dryRun | bool | `false` | dry-run: the report and the diffs, nothing written — a rehearsal of one installation's cut-over before the real run. | +| agentManager.migration.preflightSemver | string | `""` | | +| agentManager.migration.cutover | bool | `false` | | | agentManager.migration.gitopsNamespaces | list | `[]` | | | cluster-manager.fullnameOverride | string | `"cluster-manager"` | | | cluster-manager.installation.name | string | `""` | | @@ -1940,6 +1963,7 @@ The kagent block is open in the schema, so the template refuses a key under `kag | backstage.installationName | string | `"agent-platform"` | | | backstage.extraScopes[0] | string | `"federated:id"` | | | backstage.extraScopes[1] | string | `"audience:server:client_id:dex-k8s-authenticator"` | | +| backstage.oidcClientId | string | `""` | | | backstage.startUrlSearchParams | object | `{}` | | | backstage.enabledExtensions | list | `[]` | | | backstage.disabledExtensions[0] | string | `"page:gs/clusters"` | | @@ -1968,6 +1992,31 @@ The kagent block is open in the schema, so the template refuses a key under `kag | mcp-kubernetes.mcpServer.managementCluster | string | `""` | | | mcp-kubernetes.mcpServer.displayName | string | `"Kubernetes"` | | | mcp-kubernetes.mcpServer.description | string | `"Resources, events and pod logs of this installation's cluster, and the health of its workload clusters"` | | +| mcp-kubernetes.mcpServer.approval.rule | string | `"Ask"` | | +| mcp-kubernetes.mcpServer.approval.tools.get | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.list | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.describe | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.logs | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.api_resources | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.cluster_health | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.can_i | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.context_list | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.context_get_current | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.list_port_forward_sessions | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.capi_list_clusters | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.capi_get_cluster | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.capi_resolve_cluster | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.capi_cluster_health | string | `"Allow"` | | +| mcp-kubernetes.mcpServer.approval.tools.context_use | string | `"Ask"` | | +| mcp-kubernetes.mcpServer.approval.tools.create | string | `"Ask"` | | +| mcp-kubernetes.mcpServer.approval.tools.apply | string | `"Ask"` | | +| mcp-kubernetes.mcpServer.approval.tools.delete | string | `"Ask"` | | +| mcp-kubernetes.mcpServer.approval.tools.patch | string | `"Ask"` | | +| mcp-kubernetes.mcpServer.approval.tools.scale | string | `"Ask"` | | +| mcp-kubernetes.mcpServer.approval.tools.exec | string | `"Ask"` | | +| mcp-kubernetes.mcpServer.approval.tools.port_forward | string | `"Ask"` | | +| mcp-kubernetes.mcpServer.approval.tools.stop_port_forward_session | string | `"Ask"` | | +| mcp-kubernetes.mcpServer.approval.tools.stop_all_port_forward_sessions | string | `"Ask"` | | | cloudnative-pg | object | `{}` | | | kagent-crds | object | `{}` | | | substrate.createNamespace | bool | `false` | | diff --git a/helm/agent-platform-connectivity/templates/_helpers.tpl b/helm/agent-platform-connectivity/templates/_helpers.tpl index 9d84d0eb..a3ec7059 100644 --- a/helm/agent-platform-connectivity/templates/_helpers.tpl +++ b/helm/agent-platform-connectivity/templates/_helpers.tpl @@ -2583,3 +2583,46 @@ string, so `with` gates a caller's comment). Include with nindent under {{- include "agent-platform.otlpEgressRule" (dict "target" $t "who" "kagent's exporters send to") -}} {{- end }} {{- end -}} + +{{/* +An MCPServer's spec.approval from a values block (Governing tool calls), +validated the way the CRD's CEL rules check it so +a wrong value fails the render naming the key: `rule` Allow, Ask or Block (a +Block rule hides and refuses every tool without its own entry), `tools` a +map of at most 512 tool names to Allow, Ask or Block, nothing else. Renders the +`approval:` block at two spaces of indentation, nothing for an empty or null +block. +Usage: include "agent-platform.mcpServerApproval" (dict "approval" $block "key" "") +*/}} +{{- define "agent-platform.mcpServerApproval" -}} +{{- $a := .approval | default dict -}} +{{- if $a -}} +{{- if not (kindIs "map" $a) -}} +{{- fail (printf "%s: want a map with rule and tools" .key) -}} +{{- end -}} +{{- range $k, $_ := $a -}} +{{- if not (has $k (list "rule" "tools")) -}} +{{- fail (printf "%s.%s: unknown key, want rule or tools" $.key $k) -}} +{{- end -}} +{{- end -}} +{{- if hasKey $a "rule" -}} +{{- if not (has (toString $a.rule) (list "Allow" "Ask" "Block")) -}} +{{- fail (printf "%s.rule %q: want Allow, Ask or Block" .key (toString $a.rule)) -}} +{{- end -}} +{{- end -}} +{{- $tools := $a.tools | default dict -}} +{{- if not (kindIs "map" $tools) -}} +{{- fail (printf "%s.tools: want a map of tool name to Allow, Ask or Block" .key) -}} +{{- end -}} +{{- if gt (len $tools) 512 -}} +{{- fail (printf "%s.tools: %d tools, want at most 512 (the MCPServer CRD's maxProperties)" .key (len $tools)) -}} +{{- end -}} +{{- range $tool, $v := $tools -}} +{{- if not (has (toString $v) (list "Allow" "Ask" "Block")) -}} +{{- fail (printf "%s.tools.%s %q: want Allow, Ask or Block" $.key $tool (toString $v)) -}} +{{- end -}} +{{- end }} +approval: + {{- toYaml $a | nindent 2 }} +{{- end -}} +{{- end -}} diff --git a/helm/agent-platform-connectivity/templates/agent-manager/netpol.yaml b/helm/agent-platform-connectivity/templates/agent-manager/netpol.yaml index d52c8d54..7a11e6fd 100644 --- a/helm/agent-platform-connectivity/templates/agent-manager/netpol.yaml +++ b/helm/agent-platform-connectivity/templates/agent-manager/netpol.yaml @@ -183,6 +183,18 @@ spec: - port: {{ $musterPort | quote }} protocol: TCP {{- end }} + {{- with .Values.networkPolicy.musterSessionBindingsPort }} + # muster's session bindings API on its own port (start_session's binds, + # grant drops), which muster admits from agent-manager alone. + - toEndpoints: + - matchLabels: + app.kubernetes.io/name: muster + io.kubernetes.pod.namespace: {{ $.Values.networkPolicy.musterSessionBindingsNamespace | default $.Release.Namespace }} + toPorts: + - ports: + - port: {{ . | quote }} + protocol: TCP + {{- end }} {{- if $oauthOn }} {{- include "agent-platform.idpEgress.cilium" (dict "ctx" $ "provider" (include "agent-platform.agentManager.oauthProvider" .) "issuerUrl" (include "agent-platform.agentManager.issuerUrl" .)) | trim | nindent 4 }} {{- include "agent-platform.oauth.trustedIssuerEgress" (dict "ctx" . "flavor" "cilium" "component" "agent-manager" "provider" (include "agent-platform.agentManager.oauthProvider" .) "issuerUrl" (include "agent-platform.agentManager.issuerUrl" .)) | nindent 4 }} @@ -404,6 +416,20 @@ spec: - port: {{ $musterPort | int }} protocol: TCP {{- end }} + {{- with .Values.networkPolicy.musterSessionBindingsPort }} + # muster's session bindings API on its own port (start_session's binds, + # grant drops), which muster admits from agent-manager alone. + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: {{ $.Values.networkPolicy.musterSessionBindingsNamespace | default $.Release.Namespace }} + podSelector: + matchLabels: + app.kubernetes.io/name: muster + ports: + - port: {{ . | int }} + protocol: TCP + {{- end }} {{- include "agent-platform.agentManager.chartSourcesEgress.kubernetes" . | nindent 4 }} {{- with $broker }} # Native NetworkPolicy cannot select a DNS origin. Private DNS origins diff --git a/helm/agent-platform-connectivity/templates/backstage/app-config.yaml b/helm/agent-platform-connectivity/templates/backstage/app-config.yaml index 391670c6..f46b57eb 100644 --- a/helm/agent-platform-connectivity/templates/backstage/app-config.yaml +++ b/helm/agent-platform-connectivity/templates/backstage/app-config.yaml @@ -8,6 +8,21 @@ route hostname. */}} {{- $issuer := include "agent-platform.issuerUrl" (dict "ctx" . "for" "the Backstage login provider") }} {{- $installation := include "agent-platform.backstage.installationName" . }} {{- $provider := "oidc-agent-platform" }} +{{- /* The portal's own OAuth client (backstage.oidcClientId), else the +platform's shared one. A dedicated client reads its secret from its own env +var (the meta chart's backstage values mount portal-dex-client-secret) and +also requests the platform client's audience, so every component that trusts +that audience accepts the portal's tokens as before. */}} +{{- $platformClient := toString (.Values.global.identity.clientId | default "") }} +{{- $portalClient := toString ($backstage.oidcClientId | default "") }} +{{- $dedicated := and $portalClient (ne $portalClient $platformClient) }} +{{- $extraScopes := $backstage.extraScopes | default list }} +{{- if and $dedicated $platformClient $extraScopes }} +{{- $platformScope := printf "audience:server:client_id:%s" $platformClient }} +{{- if not (has $platformScope $extraScopes) }} +{{- $extraScopes = append $extraScopes $platformScope }} +{{- end }} +{{- end }} {{- $musterHostname := "" }} {{- if .Values.ingress.hostnames }} {{- $musterHostname = index .Values.ingress.hostnames 0 }} @@ -103,8 +118,13 @@ data: {{ $provider }}: production: metadataUrl: {{ $issuer }}/.well-known/openid-configuration + {{- if $dedicated }} + clientId: {{ $portalClient }} + clientSecret: ${AGENT_PLATFORM_PORTAL_OIDC_CLIENT_SECRET} + {{- else }} clientId: {{ .Values.global.identity.clientId }} clientSecret: ${AGENT_PLATFORM_OIDC_CLIENT_SECRET} + {{- end }} {{- /* Unset, the Backstage oidc authenticator sends prompt=none on every authorize request. Dex ignores it, but a spec-strict IdP (Google) answers a fresh login with error=interaction_required @@ -124,7 +144,7 @@ data: {{- end }} gs: authProvider: {{ $provider }} - {{- with $backstage.extraScopes }} + {{- with $extraScopes }} auth: extraScopes: {{- toYaml . | nindent 10 }} diff --git a/helm/agent-platform-connectivity/templates/kagent/_migrate.tpl b/helm/agent-platform-connectivity/templates/kagent/_migrate.tpl index 9e8f714b..2793a5e6 100644 --- a/helm/agent-platform-connectivity/templates/kagent/_migrate.tpl +++ b/helm/agent-platform-connectivity/templates/kagent/_migrate.tpl @@ -127,3 +127,59 @@ fi kubectl -n {{ .namespace }} create job {{ .job }} --from=cronjob/{{ .cronJob }} echo "{{ .job }} started; its outcome: kubectl -n {{ .namespace }} get job {{ .job }}, the ConfigMap agent-manager-migrate-report" {{- end -}} + +{{/* +Truthy when a range (the argument) admits a 3.x release, probed as +agent-manager's migrate probes it (agent-platform.agentChart.majors in the +meta chart): every version the range names with its next patch and minor, so +each alternative of a `||` range counts, and 3.0.0, a late 3.x and the first +and a late patch of every minor below 200. +*/}} +{{- define "agent-platform.kagent.migration.isV3" -}} +{{- $range := toString . -}} +{{- if and (regexMatch "[0-9]" $range) (not (regexMatch "(^|[\\s|,<>=~^])[A-Za-uwyzA-WYZ]" $range)) -}} +{{- $hit := or (semverCompare $range "3.0.0") (semverCompare $range "3.999999.999999") -}} +{{- range $lit := regexFindAll "[0-9]+(\\.[0-9]+)?(\\.[0-9]+)?" $range -1 -}} +{{- $p := splitList "." $lit -}} +{{- if eq (index $p 0) "3" -}} +{{- $min := 0 -}}{{- if gt (len $p) 1 -}}{{- $min = atoi (index $p 1) -}}{{- end -}} +{{- $pat := 0 -}}{{- if gt (len $p) 2 -}}{{- $pat = atoi (index $p 2) -}}{{- end -}} +{{- range $v := list (printf "3.%d.%d" $min $pat) (printf "3.%d.%d" $min (add1 $pat)) (printf "3.%d.0" (add1 $min)) -}} +{{- if and (not $hit) (semverCompare $range $v) -}}{{- $hit = true -}}{{- end -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- range $n := until 200 -}} +{{- if and (not $hit) (or (semverCompare $range (printf "3.%d.0" $n)) (semverCompare $range (printf "3.%d.999999" $n))) -}}{{- $hit = true -}}{{- end -}} +{{- end -}} +{{- if $hit -}}true{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Truthy when a run of the migration takes the 2.x -> 3.x path and reads the +organization namespaces (migrate-rbac.yaml): agent-manager.agentChart.semver +(as the run takes it) is a 3.x line, or agentManager.migration.preflightSemver +is, for the dry run before the line moves. +*/}} +{{- define "agent-platform.kagent.migration.v3Line" -}} +{{- $am := include "agent-platform.agentManager.chartValues" . | fromJson -}} +{{- if or (include "agent-platform.kagent.migration.isV3" (dig "agentChart" "semver" "2.x" $am)) (include "agent-platform.kagent.migration.isV3" (dig "migration" "preflightSemver" "" (.Values.agentManager | default dict))) -}}true{{- end -}} +{{- end -}} + +{{/* +Truthy while the organizations' cut-over runs: agentManager.migration.cutover +true (a boolean: a string such as "false" fails the render, it would read as +set), agent-manager.agentChart.semver a 3.x line (not the preflight dry run) +and organizations on. Only then the run writes organization releases and its +report there (migrate-rbac.yaml, organizations/migrate-scope.yaml); unset +afterwards, the identity keeps its reads on the 3.x line and no write there. +*/}} +{{- define "agent-platform.kagent.migration.v3Writes" -}} +{{- $am := include "agent-platform.agentManager.chartValues" . | fromJson -}} +{{- $cutover := dig "migration" "cutover" false (.Values.agentManager | default dict) -}} +{{- if not (or (kindIs "bool" $cutover) (kindIs "invalid" $cutover)) -}} +{{- fail (printf "agentManager.migration.cutover must be the boolean true or false, got the %s %q: only a boolean true grants the migration its organization writes" (kindOf $cutover) (toString $cutover)) -}} +{{- end -}} +{{- if and (eq (toString $cutover) "true") (include "agent-platform.organizations.enabled" .) (include "agent-platform.kagent.migration" .) (include "agent-platform.kagent.migration.isV3" (dig "agentChart" "semver" "2.x" $am)) -}}true{{- end -}} +{{- end -}} diff --git a/helm/agent-platform-connectivity/templates/kagent/mcpserver.yaml b/helm/agent-platform-connectivity/templates/kagent/mcpserver.yaml index 3a062bd7..14f1f406 100644 --- a/helm/agent-platform-connectivity/templates/kagent/mcpserver.yaml +++ b/helm/agent-platform-connectivity/templates/kagent/mcpserver.yaml @@ -8,7 +8,8 @@ and the checkpoint and fork tools. Registered, every session whose toolset inclu preset lists and messages the person's other sessions as x_kagent_, and the Dev Portal's MCP servers page lists it in the Agent Platform group, by mcp.displayName (the ui.giantswarm.io/display-name annotation) when set, with -mcp.description (spec.description) under the name when set. +mcp.description (spec.description) under the name when set. mcp.approval is +its tool approval (spec.approval, agent-platform.mcpServerApproval). The path is the data plane's, never the controller's directly: an HTTPRoute at pathPrefix, rewritten to /mcp, on the kagent AgentgatewayBackend @@ -95,4 +96,7 @@ spec: auth: type: oauth forwardToken: true + {{- with include "agent-platform.mcpServerApproval" (dict "approval" $mcp.approval "key" "kagent.controllerRoute.mcp.approval") }} + {{- . | trim | nindent 2 }} + {{- end }} {{- end }} diff --git a/helm/agent-platform-connectivity/templates/kagent/migrate-cronjob.yaml b/helm/agent-platform-connectivity/templates/kagent/migrate-cronjob.yaml index 5dabbdd3..e2490722 100644 --- a/helm/agent-platform-connectivity/templates/kagent/migrate-cronjob.yaml +++ b/helm/agent-platform-connectivity/templates/kagent/migrate-cronjob.yaml @@ -3,8 +3,13 @@ The cut-over of one installation's agents to the api.kagent.dev line (giantswarm/agent-platform#346 for the shape; bumblebee-plans#51 D11, expand–contract): `agent-manager migrate`, run once per pod template, in the kagent namespace, as the ServiceAccount of the migration's own name -(migrate-rbac.yaml), never the agents' Flux identity. The 2.x range of -agent-manager.agentChart.semver picks the 1.x -> 2.x +(migrate-rbac.yaml), never the agents' Flux identity. The major of +agent-manager.agentChart.semver picks the path. A 3.x range picks 2.x -> 3.x +(agent chart 3.0): the command rewrites +muster.requireApproval: true to default: Ask and spells out the 2.x +modelConfig.name default, before it moves a namespace's OCIRepository to 3.x, +and emits the same as a diff for a GitOps-owned release; both lines render +the same Agent, so nothing is deleted. A 2.x range picks the 1.x -> 2.x path: the command validates every Generic-chart release against the chart 2.x schema, rewrites the portal-created ones (sub-agent bindings `agent` -> `subAgent`, the 1.x Harness admission label -> agent.harness) and moves the @@ -159,6 +164,40 @@ spec: ttlSecondsAfterFinished: 86400 template: {{- $template | nindent 8 }} +{{- with $m.preflightSemver }} +{{- /* The preflight: the same run, dry, against preflightSemver, +never started by the hook: `kubectl create job --from=cronjob/` before +the agent chart line moves, as UPGRADE.md says. */ -}} +{{- $pre := list }} +{{- range $env }} +{{- if eq .name "AGENT_CHART_SEMVER" }}{{- $pre = append $pre (dict "name" "AGENT_CHART_SEMVER" "value" (toString $.Values.agentManager.migration.preflightSemver)) }}{{- else if ne .name "AGENT_CHART_SEMVER_FILTER" }}{{- $pre = append $pre . }}{{- end }} +{{- end }} +{{- $preTemplate := include "agent-platform.kagent.migration.podTemplate" (dict "root" $ "serviceAccountName" $sa "image" $image "args" (list "migrate" "--dry-run") "env" $pre) }} +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "agent-platform.kagent.migration.name" $ }}-preflight + namespace: {{ $kagentNs }} + labels: + {{- include "agent-platform.kagent.migration.labels" $ | nindent 4 }} + annotations: + agent-platform.giantswarm.io/about: {{ printf "agent-manager migrate --dry-run against %s (agentManager.migration.preflightSemver): run it with kubectl create job --from=cronjob/ and read the report in its log; it writes nothing (UPGRADE.md)" (toString .) | quote }} +spec: + suspend: true + schedule: "0 0 31 2 *" + concurrencyPolicy: Forbid + jobTemplate: + metadata: + labels: + {{- include "agent-platform.kagent.migration.labels" $ | nindent 8 }} + spec: + backoffLimit: 0 + activeDeadlineSeconds: 900 + ttlSecondsAfterFinished: 86400 + template: + {{- $preTemplate | nindent 8 }} +{{- end }} --- {{ include "agent-platform.hooks.job" (dict "root" . diff --git a/helm/agent-platform-connectivity/templates/kagent/migrate-rbac.yaml b/helm/agent-platform-connectivity/templates/kagent/migrate-rbac.yaml index b600b11b..c70ced67 100644 --- a/helm/agent-platform-connectivity/templates/kagent/migrate-rbac.yaml +++ b/helm/agent-platform-connectivity/templates/kagent/migrate-rbac.yaml @@ -17,7 +17,27 @@ ClusterRoleBinding to this ServiceAccount, holds exactly that: get and delete on customresourcedefinitions confined by resourceNames to those nine CRDs, and a cluster-wide list on their kagent.dev resources, which proves a CRD empty before it goes. verify-flux-identity asserts these rights and no other -cluster-scoped binding of the identity. +cluster-scoped binding of the identity on the 2.x line. + +Only while agent-manager.agentChart.semver is a 3.x line (the 2.x -> 3.x path) +the same ClusterRole also lets the run +list namespaces (it finds the organization namespaces by label and fails when +it may not) and, with agentPlatformOrganizations.enabled, list and get the +HelmReleases and OCIRepositories and list the Agents it reads there +(agent-platform.kagent.migration.v3Line; a 3.x preflight range on the 2.x +line too, for its dry run). Only while the line itself is 3.x and +agentManager.migration.cutover is set (agent-platform.kagent.migration.v3Writes; +UPGRADE.md says to unset it once every organization moved) the run also +updates the +organization releases agent-manager owns (their values to 3.x) and writes its +report ConfigMap agent-manager-migrate-report there, which the +agent-platform-operator reads before it moves the organization's chart source +to 3.x; it never writes an organization's OCIRepository. The operator mirrors +no binding of this identity into organization namespaces, so these rights are +cluster-wide; they exist only for the cut-over run, and +agent-platform-organization-migrate-scope (organizations/migrate-scope.yaml) +holds the writes to organization namespaces (and the kagent namespace), to +spec.values of a HelmRelease and to the report's name. Per namespace in agentManager.migration.gitopsNamespaces (the fleet: flux-giantswarm, where the GitOps-owned agents' HelmReleases and @@ -106,6 +126,41 @@ rules: - apiGroups: ["kagent.dev"] resources: {{ $legacyCRDs | toJson }} verbs: ["list"] + # Organization namespaces: on the + # agent chart 2.x -> 3.x path the run lists the namespaces labelled as an + # organization's and fails when it may not; it reads their releases, chart + # sources and Agents, rewrites the releases agent-manager owns and marks + # each namespace in its report once every release there is on 3.x values; + # the agent-platform-operator moves an organization's source only then. + {{- if include "agent-platform.kagent.migration.v3Line" . }} + - apiGroups: [""] + resources: ["namespaces"] + verbs: ["list"] + {{- if include "agent-platform.organizations.enabled" . }} + - apiGroups: ["helm.toolkit.fluxcd.io"] + resources: ["helmreleases"] + verbs: ["get", "list"] + - apiGroups: ["source.toolkit.fluxcd.io"] + resources: ["ocirepositories"] + verbs: ["get", "list"] + - apiGroups: ["api.kagent.dev"] + resources: ["agents"] + verbs: ["list"] + {{- end }} + {{- if include "agent-platform.kagent.migration.v3Writes" . }} + - apiGroups: ["helm.toolkit.fluxcd.io"] + resources: ["helmreleases"] + verbs: ["update"] + # RBAC cannot name the object of a create. + - apiGroups: [""] + resources: ["configmaps"] + verbs: ["create"] + - apiGroups: [""] + resources: ["configmaps"] + resourceNames: ["agent-manager-migrate-report"] + verbs: ["get", "update"] + {{- end }} + {{- end }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding diff --git a/helm/agent-platform-connectivity/templates/mcp-kubernetes/mcpserver.yaml b/helm/agent-platform-connectivity/templates/mcp-kubernetes/mcpserver.yaml index 1a35d518..9ab1848a 100644 --- a/helm/agent-platform-connectivity/templates/mcp-kubernetes/mcpserver.yaml +++ b/helm/agent-platform-connectivity/templates/mcp-kubernetes/mcpserver.yaml @@ -21,7 +21,9 @@ agent-platform, stamped by their charts) and the servers an installation registers (no label). The portal's MCP servers page, the toolset presets and the docs group servers by it; it names the server by mcpServer.displayName (the ui.giantswarm.io/display-name annotation) when set, and shows -mcpServer.description (spec.description) under the name when set. +mcpServer.description (spec.description) under the name when set, and its +tool approval mcpServer.approval as spec.approval (the Recommended preset by +default, as agent-platform-mcps' kubernetes family). mcp-kubernetes.mcpServer picks one of three shapes: - enabled: false renders no CR; the registration is agent-platform-mcps' @@ -83,4 +85,7 @@ spec: name: kubernetes instanceArg: management_cluster {{- end }} + {{- with include "agent-platform.mcpServerApproval" (dict "approval" (dig "approval" dict $reg) "key" "mcp-kubernetes.mcpServer.approval") }} + {{- . | trim | nindent 2 }} + {{- end }} {{- end }} diff --git a/helm/agent-platform-connectivity/templates/organizations/migrate-scope.yaml b/helm/agent-platform-connectivity/templates/organizations/migrate-scope.yaml new file mode 100644 index 00000000..ebcdc042 --- /dev/null +++ b/helm/agent-platform-connectivity/templates/organizations/migrate-scope.yaml @@ -0,0 +1,85 @@ +{{- /* +agent-platform-organization-migrate-scope: what agent-manager's migrate run +(the ServiceAccount of agent-platform.kagent.migration.name in the kagent +namespace) writes with the cluster-wide rights it holds during the 2.x -> 3.x +cut-over (kagent/migrate-rbac.yaml, agent-platform.kagent.migration.v3Writes): +RBAC cannot select namespaces by label, so this policy holds them to + + * organization namespaces (labelled agent-platform.giantswarm.io/organization) + and the kagent namespace, where its Role writes anyway; + * in an organization namespace, a HelmRelease update that changes + spec.values only (migrate rewrites muster.requireApproval to + default: Ask and spells out modelConfig.name; it never changes the chart, + the identity a release runs as or anything else of it), its labels, + annotations, ownerReferences and finalizers as they were (no owner the + garbage collector would delete it for, no GitOps label that changes who + owns it, no Flux reconcile request); + * a ConfigMap of the report's name, agent-manager-migrate-report. + +A bug or a leaked token of the run then cannot rewrite the platform's own +HelmReleases or another namespace's ConfigMaps. Rendered with those rights +only: while agentManager.migration.cutover is set +(agent-platform.kagent.migration.v3Writes). +*/ -}} +{{- if include "agent-platform.kagent.migration.v3Writes" . }} +{{- $label := include "agent-platform.organizations.label" . }} +{{- $kagentNs := .Values.kagent.namespaceOverride | default .Release.Namespace }} +{{- $user := printf "system:serviceaccount:%s:%s" $kagentNs (include "agent-platform.kagent.migration.name" .) }} +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingAdmissionPolicy +metadata: + name: agent-platform-organization-migrate-scope + labels: + {{- include "labels.common" . | nindent 4 }} +spec: + failurePolicy: Fail + matchConstraints: + resourceRules: + - apiGroups: ["helm.toolkit.fluxcd.io"] + apiVersions: ["*"] + operations: ["CREATE", "UPDATE", "DELETE"] + resources: ["helmreleases"] + - apiGroups: [""] + apiVersions: ["v1"] + operations: ["CREATE", "UPDATE", "DELETE"] + resources: ["configmaps"] + matchConditions: + - name: migrate + expression: {{ printf "request.userInfo.username == '%s'" $user | quote }} + variables: + - name: sameMetadata + expression: >- + request.operation != 'UPDATE' || + (object.metadata.?labels.orValue({}) == oldObject.metadata.?labels.orValue({}) && + object.metadata.?annotations.orValue({}) == oldObject.metadata.?annotations.orValue({}) && + object.metadata.?ownerReferences.orValue([]) == oldObject.metadata.?ownerReferences.orValue([]) && + object.metadata.?finalizers.orValue([]) == oldObject.metadata.?finalizers.orValue([])) + - name: organizationNamespace + expression: {{ printf "has(namespaceObject.metadata.labels) && '%s' in namespaceObject.metadata.labels" $label | quote }} + validations: + - expression: {{ printf "request.namespace == '%s' || variables.organizationNamespace" $kagentNs | quote }} + reason: Forbidden + messageExpression: "'agent-manager migrate writes ' + request.resource.resource + ' only in organization namespaces and its own; refused in ' + request.namespace" + - expression: "request.resource.resource != 'configmaps' || request.name == 'agent-manager-migrate-report'" + reason: Forbidden + messageExpression: "'agent-manager migrate writes no ConfigMap but its report agent-manager-migrate-report; refused: ' + request.name" + - expression: >- + request.resource.resource != 'helmreleases' || !variables.organizationNamespace || + (request.operation == 'UPDATE' && + object.spec.all(k, k == 'values' || (k in oldObject.spec && oldObject.spec[k] == object.spec[k])) && + oldObject.spec.all(k, k == 'values' || k in object.spec) && + variables.sameMetadata) + reason: Forbidden + messageExpression: "'agent-manager migrate changes only spec.values of a HelmRelease in an organization namespace, never its spec otherwise, labels, annotations, ownerReferences or finalizers; refused for ' + request.namespace + '/' + request.name" +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingAdmissionPolicyBinding +metadata: + name: agent-platform-organization-migrate-scope + labels: + {{- include "labels.common" . | nindent 4 }} +spec: + policyName: agent-platform-organization-migrate-scope + validationActions: [Deny] +{{- end }} diff --git a/helm/agent-platform-connectivity/values.schema.json b/helm/agent-platform-connectivity/values.schema.json index 55998bfa..452f86b7 100644 --- a/helm/agent-platform-connectivity/values.schema.json +++ b/helm/agent-platform-connectivity/values.schema.json @@ -1740,6 +1740,12 @@ "type": "integer" } }, + "musterSessionBindingsNamespace": { + "type": "string" + }, + "musterSessionBindingsPort": { + "type": "integer" + }, "substrate": { "type": "object", "additionalProperties": false, diff --git a/helm/agent-platform-connectivity/values.yaml b/helm/agent-platform-connectivity/values.yaml index 63457113..7cee873d 100644 --- a/helm/agent-platform-connectivity/values.yaml +++ b/helm/agent-platform-connectivity/values.yaml @@ -831,6 +831,14 @@ networkPolicy: musterInClusterMcpPorts: - 8080 - 8443 + # Port of muster's session bindings API (agent-manager only); set by the meta + # chart from muster's floor. 0 opens no egress for it: agent-manager binds on + # muster's aggregator port. + musterSessionBindingsPort: 0 + # Namespace muster runs in, for that egress rule; set by the meta chart from + # muster's namespace (components.muster.targetNamespace). Empty selects the + # release's own namespace. + musterSessionBindingsNamespace: "" # In-cluster MCP backends an installation registers with muster (its own # MCPServer entries, e.g. through agent-platform-mcps). A ClusterIP Service # without a policy admits every pod on the cluster, and a direct call skips @@ -1818,6 +1826,38 @@ kagent: # @schema skipProperties: true; additionalProperties: true # The line the Dev Portal shows under the server's name (the MCPServer's # spec.description, at most 500 characters); empty renders none. description: "Your agent sessions on this installation, as the signed-in person: list them, send one a message, and checkpoint or fork them" + # The connector's tool approval (spec.approval; see + # https://github.com/giantswarm/agent-platform/blob/main/docs/tool-approval.md): + # `rule` (Allow | Ask | Block) for a tool without its own entry, new ones + # included, and `tools`, the server's own tool names -> Allow | Ask | Block + # (at most 512). Written out for every tool as the Allow all preset: these + # session tools run as the person who ran the turn and carry no MCP + # annotations. On a governed platform muster also asks agents before every + # tool not on the meta chart's governedServers.kagent safe list, whatever + # these say. null renders none (the connector runs every tool, not + # reviewed). Without spec.approval in muster's CRD, muster refuses the + # server's tools until the CRD is upgraded. + approval: + rule: Allow + tools: + list_sessions: Allow + invoke_session: Allow + create_session_checkpoint: Allow + list_session_checkpoints: Allow + fork_session: Allow + list_sandbox_templates: Allow + create_sandbox: Allow + list_sandboxes: Allow + get_sandbox: Allow + suspend_sandbox: Allow + resume_sandbox: Allow + delete_sandbox: Allow + start_sandbox_process: Allow + get_sandbox_process: Allow + kill_sandbox_process: Allow + read_sandbox_outputs: Allow + read_sandbox_file: Allow + write_sandbox_file: Allow # The first of the controller's two authentication layers, on by default # (docs/authentication.md, "The kagent controller route"). Renders an # AgentgatewayPolicy on the GRPCRoute (plus a static AgentgatewayBackend for @@ -3015,6 +3055,19 @@ agentManager: # @schema skipProperties: true; additionalProperties: true # --dry-run: the report and the diffs, nothing written — a rehearsal of # one installation's cut-over before the real run. dryRun: false + # A never-started CronJob -preflight that runs `migrate --dry-run` + # against this range instead of the line's, e.g. ">=3.0.0 <4.0.0" before the + # agent chart line moves to 3.x (the mandatory check of UPGRADE.md; a dry + # run writes nothing). A 3.x range also grants the migration's identity the + # read-only access the 3.x path needs. Empty renders neither. + preflightSemver: "" + # true only while the organizations' 2.x -> 3.x cut-over runs, with + # agent-manager.agentChart.semver on 3.x and agentPlatformOrganizations + # enabled: the migration's identity may then update the organizations' + # HelmReleases (spec.values only) and write its report there, held by the + # ValidatingAdmissionPolicy agent-platform-organization-migrate-scope. + # Unset it once no organization is Ready=False with reason ChartSourceHeld. + cutover: false # Namespaces the GitOps-owned agents' HelmReleases and OCIRepositories live # in (a HelmRelease with targetNamespace: kagent applied from elsewhere — # the fleet's flux-giantswarm): the Job reads them there (get, list; a Role @@ -3615,6 +3668,14 @@ backstage: # @schema skipProperties: true; additionalProperties: true extraScopes: - federated:id - audience:server:client_id:dex-k8s-authenticator + # The portal's own OAuth client. Empty (default) signs in with + # global.identity.clientId and AGENT_PLATFORM_OIDC_CLIENT_SECRET. Set, the + # login provider takes this id and AGENT_PLATFORM_PORTAL_OIDC_CLIENT_SECRET + # (the meta chart mounts the key portal-dex-client-secret), and + # audience:server:client_id: is added to + # extraScopes (unless they are empty). The meta chart's values.yaml lists + # what the identity provider needs. + oidcClientId: "" # Extra query parameters on the login provider's authorize request (the # oidc authenticator's startUrlSearchParams). Dex needs none. Google models # offline access as authorize parameters, not as the offline_access scope @@ -3737,6 +3798,45 @@ mcp-kubernetes: # @schema skipProperties: true; additionalProperties: true # What the Dev Portal shows under the name (the MCPServer's # spec.description), at most 500 characters. Empty renders none. description: "Resources, events and pod logs of this installation's cluster, and the health of its workload clusters" + # The connector's tool approval (spec.approval; see + # https://github.com/giantswarm/agent-platform/blob/main/docs/tool-approval.md): + # `rule` (Allow | Ask | Block) for a tool without its own entry, new ones + # included, and `tools`, the server's own tool names -> Allow | Ask | Block + # (at most 512). Written out as the Recommended preset, equal to + # agent-platform-mcps' kubernetes family (make verify-tool-approval compares + # them): read-only tools run, every other one asks, new tools ask until + # listed. The deprecated kubernetes_* aliases follow the rule. On a governed + # platform muster also asks agents before every tool not on the meta chart's + # governedServers.mcp-kubernetes safe list. null renders none (not + # reviewed). Without spec.approval in muster's CRD, muster refuses the + # server's tools until the CRD is upgraded. + approval: + rule: Ask + tools: + get: Allow + list: Allow + describe: Allow + logs: Allow + api_resources: Allow + cluster_health: Allow + can_i: Allow + context_list: Allow + context_get_current: Allow + list_port_forward_sessions: Allow + capi_list_clusters: Allow + capi_get_cluster: Allow + capi_resolve_cluster: Allow + capi_cluster_health: Allow + context_use: Ask + create: Ask + apply: Ask + delete: Ask + patch: Ask + scale: Ask + exec: Ask + port_forward: Ask + stop_port_forward_session: Ask + stop_all_port_forward_sessions: Ask cloudnative-pg: {} # @schema skipProperties: true; additionalProperties: true # The kagent-crds component's values (kagent main ships its CRDs as their own diff --git a/helm/agent-platform/README.md b/helm/agent-platform/README.md index 27c03ce1..0e9e67c5 100644 --- a/helm/agent-platform/README.md +++ b/helm/agent-platform/README.md @@ -376,6 +376,60 @@ Karpenter relaxes a preferred term and launches the node. An installation's own `podAffinity` stands instead of the derived one (keep the atelet term in it, never required); below `1.3.0` the key is refused. +## Tool approval and the governance mode + +Every tool behind muster is **Allow**, **Ask** (a person confirms the call first) or **Block** +(hidden and refused). A connector's `rule` applies to tools without their own entry, new ones +included. Concepts and prompts: [Governing tool calls](https://github.com/giantswarm/agent-platform/blob/main/docs/tool-approval.md). + +| Value | What it does | +|-------|--------------| +| `governance.mode` | `trusted` (default) or `governed`; anything else fails the render. `governed` asks a person before an agent runs any tool of a governed server that is not on its safe list (new tools too) and any muster tool but its reads; it fails the render below `agent-platform.muster.governanceFloor`. | +| `governedServers` | Per source `{role, safe}`: `safe` is the read tools agents call unasked. Sources: the manager components, `kagent`, `mcp-kubernetes`, or any other key as a muster server key (`namespace/name` outside muster's namespace). `null` drops a source; `governanceExempt` lists shipped sources left ungoverned. The earlier `muster.muster.governance.servers.` shape fails the render. | +| `governance.roleFloors` | Role to tool names that ask agents in both modes, added to muster's built-in floors. A role declared here is valid in `governedServers`. | + +Persons get the connectors' settings only; no agent tool changes the mode. `governance` is a map +(`{mode, roleFloors}`); a string fails the render. Registering a server of your own: + +```yaml +governance: + roleFloors: + exampleManager: [approve_change, merge_change] +governedServers: + example-manager: + role: exampleManager + safe: [get_info, list_changes] +``` + +- **Prerequisites.** Asking calls are refused (reported as `approval.unavailable`) unless muster + runs on Valkey (default), has its OAuth server with Dex sign-in (`oauth.server.baseUrl`, + `dex.issuerUrl`, `dex.clientId`, `existingSecret`) and a public URL on that server's origin + (`muster.muster.oauth.mcpClient.enabled` with `publicUrl`). The chart does not fail a render + without them. +- **Rendered for muster.** `approval.installation` (`backstage.installationName`) and + `oauth.mcpClient.postLoginRedirectAllowlist`: the portal's `/sessions` (`backstage.publicPort` + when not 443) and `/auth/slack/return`; an own list's entries + stay. Without an entry the person answers in the portal or Slack by hand. +- **Retry as the same client.** An approval binds to the person and the calling client, not the MCP + session; another client of the person asks anew. At most 3 pending per client, 10 per person. +- **`connector-admin`** is muster's `mcpserver-editor` Role, bound to + `muster.rbac.mcpServerEditor.subjects` plus `tenants.platformTeam`. Its holders edit connectors, + set tool approval and may let an agent skip an `Ask`. The default subject is a ServiceAccount + nobody can authenticate as (fail closed; `workflowEditor` likewise): set your admin groups, + with the OIDC groups prefix. Binding `system:authenticated` makes everyone an admin. +- **`muster-approval-binder`** lets agent-manager's ServiceAccount (and only it) bind an agent's + tool settings to a Session (`muster.rbac.approvalBinder.subjects`; an own list stands; name an + agent-manager ServiceAccount the chart does not create). +- **Shipped connectors carry `spec.approval`.** `mcp-kubernetes.mcpServer.approval` is + *Recommended* (read-only Allow, rest Ask), `kagent.controllerRoute.mcp.approval` and the managers' + `.muster.mcpServer.approval` are *Allow all*, agent-platform-mcps families + `muster.families..approval` *Recommended*. Tighten a tool or the rule there; `null` + renders none (the connector runs everything, shown as *not reviewed*). + +Operator steps: [UPGRADE.md](../../UPGRADE.md). `make verify-tool-approval` asserts the governance configuration, its coverage (every shipped +MCPServer governed or exempt, no floor safe), the allowlist, the admins, the binder and the +connectors' settings. + ## Voluntary disruption The platform's core runs as single replicas — the agentgateway data plane, muster, the kagent controller, klaus-gateway, agent-manager — and each carries long-lived streams (MCP sessions, A2A and portal SSE turns, the LLM listener). A voluntary eviction (Karpenter consolidation, a node drain) cuts them mid-turn (giantswarm/agent-platform#431). Two guards, both on by default: @@ -457,7 +511,7 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.flux.enabled | bool | `true` | | | components.muster.chart | string | `"muster"` | | | components.muster.repository | string | `"oci://gsoci.azurecr.io/charts/giantswarm"` | | -| components.muster.versionRange | string | `">=5.67.0-rc.19 <6.0.0-0"` | | +| components.muster.versionRange | string | `">=5.67.0-rc.61 <6.0.0-0"` | | | components.muster.valuesFrom | string | `"muster"` | | | components.muster.crds | string | `"CreateReplace"` | | | components.muster.dependsOn[0] | string | `"valkey"` | | @@ -480,7 +534,7 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.valkey.omitKeys[0] | string | `"podDisruptionBudget"` | | | components.agent-platform-mcps.chart | string | `"agent-platform-mcps"` | | | components.agent-platform-mcps.repository | string | `"oci://gsoci.azurecr.io/charts/giantswarm"` | | -| components.agent-platform-mcps.versionRange | string | `"0.12.x"` | | +| components.agent-platform-mcps.versionRange | string | `">=0.13.0-rc.1 <0.14.0-0"` | | | components.agent-platform-mcps.valuesFrom | string | `"agent-platform-mcps"` | | | components.agent-platform-mcps.injectGlobal | bool | `false` | | | components.agent-platform-mcps.dependsOn[0] | string | `"muster"` | | @@ -545,7 +599,7 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.google-access-token-credential-provider.dependsOn[0] | string | `"substrate"` | | | components.klaus-gateway.chart | string | `"klaus-gateway"` | | | components.klaus-gateway.repository | string | `"oci://gsoci.azurecr.io/charts/giantswarm"` | | -| components.klaus-gateway.versionRange | string | `">=4.18.10 <5.0.0"` | | +| components.klaus-gateway.versionRange | string | `">=4.20.0-rc.8 <5.0.0-0"` | | | components.klaus-gateway.valuesFrom | string | `"klausGateway"` | | | components.klaus-gateway.omitKeys[0] | string | `"observability.enabled"` | | | components.klaus-gateway.omitKeys[1] | string | `"refusals"` | | @@ -561,7 +615,7 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.agent-sandbox.dependsOn[0] | string | `"agent-platform-connectivity"` | | | components.model-manager.chart | string | `"model-manager"` | | | components.model-manager.repository | string | `"oci://gsoci.azurecr.io/charts/giantswarm"` | | -| components.model-manager.versionRange | string | `">=1.25.0 <2.0.0-0"` | | +| components.model-manager.versionRange | string | `">=1.26.0-rc.1 <2.0.0-0"` | | | components.model-manager.valuesFrom | string | `"model-manager"` | | | components.model-manager.enabled | bool | `true` | | | components.model-manager.dependsOn[0] | string | `"muster"` | | @@ -579,7 +633,7 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.credential-api.dependsOn[0] | string | `"valkey"` | | | components.agent-manager.chart | string | `"agent-manager"` | | | components.agent-manager.repository | string | `"oci://gsoci.azurecr.io/charts/giantswarm"` | | -| components.agent-manager.versionRange | string | `">=4.0.0 <5.0.0"` | | +| components.agent-manager.versionRange | string | `">=4.1.0-rc.1 <5.0.0-0"` | | | components.agent-manager.valuesFrom | string | `"agent-manager"` | | | components.agent-manager.omitEmptyKeys[0] | string | `"harness.egress"` | | | components.agent-manager.enabled | bool | `false` | | @@ -587,7 +641,7 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.agent-manager.dependsOn[1] | string | `"kagent"` | | | components.skill-manager.chart | string | `"skill-manager"` | | | components.skill-manager.repository | string | `"oci://gsoci.azurecr.io/charts/giantswarm"` | | -| components.skill-manager.versionRange | string | `">=0.4.0-rc.1 <0.5.0-0"` | | +| components.skill-manager.versionRange | string | `">=0.5.0-rc.1 <0.6.0-0"` | | | components.skill-manager.valuesFrom | string | `"skill-manager"` | | | components.skill-manager.dependsOn[0] | string | `"muster"` | | | components.skill-manager.gatedRoster | bool | `true` | | @@ -605,7 +659,7 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.default-agent.dependsOn[0] | string | `"kagent"` | | | components.vm-manager.chart | string | `"vm-manager"` | | | components.vm-manager.repository | string | `"oci://gsoci.azurecr.io/charts/giantswarm"` | | -| components.vm-manager.versionRange | string | `">=0.29.0 <0.30.0"` | | +| components.vm-manager.versionRange | string | `">=0.30.0-rc.2 <0.31.0-0"` | | | components.vm-manager.valuesFrom | string | `"vm-manager"` | | | components.vm-manager.enabled | bool | `false` | | | components.vm-manager.dependsOn[0] | string | `"muster"` | | @@ -614,7 +668,7 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.vm-manager.gatedValues[1] | string | `"vmManager"` | | | components.cluster-manager.chart | string | `"cluster-manager"` | | | components.cluster-manager.repository | string | `"oci://gsoci.azurecr.io/charts/giantswarm"` | | -| components.cluster-manager.versionRange | string | `">=0.40.0-rc.1"` | | +| components.cluster-manager.versionRange | string | `">=0.40.0-rc.3"` | | | components.cluster-manager.valuesFrom | string | `"cluster-manager"` | | | components.cluster-manager.enabled | bool | `false` | | | components.cluster-manager.dependsOn[0] | string | `"muster"` | | @@ -622,7 +676,7 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.cluster-manager.gatedValues[1] | string | `"clusterManager"` | | | components.workspace-manager.chart | string | `"workspace-manager"` | | | components.workspace-manager.repository | string | `"oci://gsoci.azurecr.io/charts/giantswarm"` | | -| components.workspace-manager.versionRange | string | `">=0.16.0-rc.1 <0.17.0-0"` | | +| components.workspace-manager.versionRange | string | `">=0.17.0-rc.1 <0.18.0-0"` | | | components.workspace-manager.valuesFrom | string | `"workspace-manager"` | | | components.workspace-manager.dependsOn[0] | string | `"muster"` | | | components.workspace-manager.dependsOn[1] | string | `"agent-platform-connectivity"` | | @@ -642,7 +696,7 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.workspace-manager.omitEmptyKeys[9] | string | `"storage.sizing.maxSize"` | | | components.toolchain-manager.chart | string | `"toolchain-manager"` | | | components.toolchain-manager.repository | string | `"oci://gsoci.azurecr.io/charts/giantswarm"` | | -| components.toolchain-manager.versionRange | string | `">=0.5.0 <0.6.0"` | | +| components.toolchain-manager.versionRange | string | `">=0.6.0-rc.16 <0.7.0-0"` | | | components.toolchain-manager.valuesFrom | string | `"toolchain-manager"` | | | components.toolchain-manager.enabled | bool | `false` | | | components.toolchain-manager.dependsOn[0] | string | `"muster"` | | @@ -651,7 +705,7 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.toolchain-manager.gatedRoster | bool | `true` | | | components.agent-platform-operator.chart | string | `"agent-platform-operator"` | | | components.agent-platform-operator.repository | string | `"oci://gsoci.azurecr.io/charts/giantswarm"` | | -| components.agent-platform-operator.versionRange | string | `">=0.5.0 <0.6.0"` | | +| components.agent-platform-operator.versionRange | string | `">=0.6.0-rc.1 <0.7.0-0"` | | | components.agent-platform-operator.valuesFrom | string | `"agent-platform-operator"` | | | components.agent-platform-operator.dependsOn[0] | string | `"agent-platform-connectivity"` | | | components.agent-platform-operator.gatedRoster | bool | `true` | | @@ -660,16 +714,19 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.backstage.versionRange | string | `">=2.68.0 <4.0.0"` | | | components.backstage.valuesFrom | string | `"backstage"` | | | components.backstage.omitKeys[0] | string | `"hostname"` | | -| components.backstage.omitKeys[1] | string | `"parentRefs"` | | -| components.backstage.omitKeys[2] | string | `"installationName"` | | -| components.backstage.omitKeys[3] | string | `"extraScopes"` | | -| components.backstage.omitKeys[4] | string | `"startUrlSearchParams"` | | -| components.backstage.omitKeys[5] | string | `"enabledExtensions"` | | -| components.backstage.omitKeys[6] | string | `"disabledExtensions"` | | -| components.backstage.omitKeys[7] | string | `"skillsRepositories"` | | -| components.backstage.omitKeys[8] | string | `"skillPullRequests"` | | -| components.backstage.omitKeys[9] | string | `"metaAgents"` | | -| components.backstage.omitKeys[10] | string | `"configReload"` | | +| components.backstage.omitKeys[1] | string | `"publicPort"` | | +| components.backstage.omitKeys[2] | string | `"parentRefs"` | | +| components.backstage.omitKeys[3] | string | `"installationName"` | | +| components.backstage.omitKeys[4] | string | `"extraScopes"` | | +| components.backstage.omitKeys[5] | string | `"startUrlSearchParams"` | | +| components.backstage.omitKeys[6] | string | `"enabledExtensions"` | | +| components.backstage.omitKeys[7] | string | `"disabledExtensions"` | | +| components.backstage.omitKeys[8] | string | `"skillsRepositories"` | | +| components.backstage.omitKeys[9] | string | `"skillPullRequests"` | | +| components.backstage.omitKeys[10] | string | `"metaAgents"` | | +| components.backstage.omitKeys[11] | string | `"configReload"` | | +| components.backstage.omitKeys[12] | string | `"oidcClientId"` | | +| components.backstage.omitKeys[13] | string | `"signInHandoff"` | | | components.backstage.enabled | bool | `false` | | | components.backstage.dependsOn[0] | string | `"cloudnative-pg"` | | | components.backstage.dependsOn[1] | string | `"agent-platform-connectivity"` | | @@ -739,18 +796,21 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | components.agent-platform-connectivity.forwardAllValues | bool | `true` | | | components.agent-platform-connectivity.disableWaitForJobs | bool | `true` | | | components.agent-platform-connectivity.omitKeys[0] | string | `"flux-engine"` | | -| components.agent-platform-connectivity.omitKeys[1] | string | `"credential-api"` | | -| components.agent-platform-connectivity.omitKeys[2] | string | `"scheduling"` | | -| components.agent-platform-connectivity.omitKeys[3] | string | `"gpu-operator"` | | -| components.agent-platform-connectivity.omitKeys[4] | string | `"toolchain-manager"` | | -| components.agent-platform-connectivity.omitKeys[5] | string | `"kserve-runtime-configs"` | | -| components.agent-platform-connectivity.omitKeys[6] | string | `"skills"` | | -| components.agent-platform-connectivity.omitKeys[7] | string | `"skillManager"` | | -| components.agent-platform-connectivity.omitKeys[8] | string | `"skill-manager"` | | -| components.agent-platform-connectivity.omitKeys[9] | string | `"defaultAgent"` | | -| components.agent-platform-connectivity.omitKeys[10] | string | `"agent-platform-operator"` | | -| components.agent-platform-connectivity.omitKeys[11] | string | `"agentPlatformOrganizations.operator"` | | -| components.agent-platform-connectivity.omitKeys[12] | string | `"agentPlatformOrganizations.organizationCRD"` | | +| components.agent-platform-connectivity.omitKeys[1] | string | `"governance"` | | +| components.agent-platform-connectivity.omitKeys[2] | string | `"governedServers"` | | +| components.agent-platform-connectivity.omitKeys[3] | string | `"governanceExempt"` | | +| components.agent-platform-connectivity.omitKeys[4] | string | `"credential-api"` | | +| components.agent-platform-connectivity.omitKeys[5] | string | `"scheduling"` | | +| components.agent-platform-connectivity.omitKeys[6] | string | `"gpu-operator"` | | +| components.agent-platform-connectivity.omitKeys[7] | string | `"toolchain-manager"` | | +| components.agent-platform-connectivity.omitKeys[8] | string | `"kserve-runtime-configs"` | | +| components.agent-platform-connectivity.omitKeys[9] | string | `"skills"` | | +| components.agent-platform-connectivity.omitKeys[10] | string | `"skillManager"` | | +| components.agent-platform-connectivity.omitKeys[11] | string | `"skill-manager"` | | +| components.agent-platform-connectivity.omitKeys[12] | string | `"defaultAgent"` | | +| components.agent-platform-connectivity.omitKeys[13] | string | `"agent-platform-operator"` | | +| components.agent-platform-connectivity.omitKeys[14] | string | `"agentPlatformOrganizations.operator"` | | +| components.agent-platform-connectivity.omitKeys[15] | string | `"agentPlatformOrganizations.organizationCRD"` | | | components.agent-platform-connectivity.dependsOn[0] | string | `"muster"` | | | components.agent-platform-connectivity.dependsOn[1] | string | `"agentgateway"` | | | components.agent-platform-connectivity.dependsOn[2] | string | `"substrate-crds"` | | @@ -866,6 +926,8 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | networkPolicy.substrate.egressGateway.privateCIDRs | list | `[]` | | | networkPolicy.musterInClusterMcpPorts[0] | int | `8080` | | | networkPolicy.musterInClusterMcpPorts[1] | int | `8443` | | +| networkPolicy.musterSessionBindingsPort | int | `0` | | +| networkPolicy.musterSessionBindingsNamespace | string | `""` | | | networkPolicy.mcpBackends | object | `{}` | | | networkPolicy.mcpBackendScrapers[0].namespace | string | `"kube-system"` | | | networkPolicy.mcpBackendScrapers[0].matchLabels."app.kubernetes.io/instance" | string | `"alloy-metrics"` | | @@ -899,18 +961,12 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | muster.image.registry | string | `"gsoci.azurecr.io"` | | | muster.fullnameOverride | string | `"muster"` | | | muster.crds.install | bool | `false` | | -| muster.rbac.mcpServerEditor.subjects[0].apiGroup | string | `"rbac.authorization.k8s.io"` | | -| muster.rbac.mcpServerEditor.subjects[0].kind | string | `"Group"` | | -| muster.rbac.mcpServerEditor.subjects[0].name | string | `"giantswarm-ad:giantswarm-admins"` | | -| muster.rbac.mcpServerEditor.subjects[1].apiGroup | string | `"rbac.authorization.k8s.io"` | | -| muster.rbac.mcpServerEditor.subjects[1].kind | string | `"Group"` | | -| muster.rbac.mcpServerEditor.subjects[1].name | string | `"giantswarm-github:giantswarm:giantswarm-admins"` | | -| muster.rbac.workflowEditor.subjects[0].apiGroup | string | `"rbac.authorization.k8s.io"` | | -| muster.rbac.workflowEditor.subjects[0].kind | string | `"Group"` | | -| muster.rbac.workflowEditor.subjects[0].name | string | `"giantswarm-ad:giantswarm-admins"` | | -| muster.rbac.workflowEditor.subjects[1].apiGroup | string | `"rbac.authorization.k8s.io"` | | -| muster.rbac.workflowEditor.subjects[1].kind | string | `"Group"` | | -| muster.rbac.workflowEditor.subjects[1].name | string | `"giantswarm-github:giantswarm:giantswarm-admins"` | | +| muster.rbac.mcpServerEditor.subjects[0].kind | string | `"ServiceAccount"` | | +| muster.rbac.mcpServerEditor.subjects[0].name | string | `"agent-platform-unset-connector-admins"` | | +| muster.rbac.mcpServerEditor.subjects[0].namespace | string | `"kube-system"` | | +| muster.rbac.workflowEditor.subjects[0].kind | string | `"ServiceAccount"` | | +| muster.rbac.workflowEditor.subjects[0].name | string | `"agent-platform-unset-workflow-editors"` | | +| muster.rbac.workflowEditor.subjects[0].namespace | string | `"kube-system"` | | | muster.networkPolicy.enabled | bool | `true` | | | muster.networkPolicy.flavor | string | `"auto"` | | | muster.networkPolicy.cilium.allowClusterIngress | bool | `true` | | @@ -1173,6 +1229,25 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | kagent.controllerRoute.mcp.timeout | int | `300` | | | kagent.controllerRoute.mcp.displayName | string | `"Kagent"` | | | kagent.controllerRoute.mcp.description | string | `"Your agent sessions on this installation, as the signed-in person: list them, send one a message, and checkpoint or fork them"` | | +| kagent.controllerRoute.mcp.approval.rule | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.list_sessions | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.invoke_session | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.create_session_checkpoint | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.list_session_checkpoints | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.fork_session | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.list_sandbox_templates | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.create_sandbox | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.list_sandboxes | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.get_sandbox | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.suspend_sandbox | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.resume_sandbox | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.delete_sandbox | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.start_sandbox_process | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.get_sandbox_process | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.kill_sandbox_process | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.read_sandbox_outputs | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.read_sandbox_file | string | `"Allow"` | | +| kagent.controllerRoute.mcp.approval.tools.write_sandbox_file | string | `"Allow"` | | | kagent.controllerRoute.jwtAuthentication.enabled | bool | `true` | | | kagent.controllerRoute.jwtAuthentication.mode | string | `"Strict"` | | | kagent.controllerRoute.jwtAuthentication.issuer | string | `""` | | @@ -1555,8 +1630,13 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | clusterManager.networkPolicy.workloadClusters.ports[1] | int | `6443` | | | clusterManager.networkPolicy.egress.fqdns | list | `[]` | | | clusterManager.networkPolicy.egress.cidrs | list | `[]` | | +| governance | object | `{"mode":"trusted","roleFloors":{}}` | The platform's governance (mode and role floors). `trusted` (default) lets agents run what the connectors' settings allow; `governed` also asks a person before an agent runs any tool of a governed server (governedServers) that is not on its safe list, and any muster tool but its reads. In both modes muster's built-in floors ask before an agent adds or repoints a connector, changes approval settings, grants access, adds a model, egress origin, credential or backend, approves an action or toolchain source, or changes muster's configuration. Rendered as muster.governance from agent-platform.muster.governanceFloor; below it `governed` fails the render. Approval needs muster's OAuth server with Dex sign-in, Valkey storage and muster.muster.oauth.mcpClient.publicUrl (with mcpClient.enabled for the redirect allowlist); without them muster refuses asking calls with the reason. No agent tool changes the mode. A string here (the earlier scalar) fails the render. See https://github.com/giantswarm/agent-platform/blob/main/docs/tool-approval.md | +| governance.mode | string | `"trusted"` | trusted (the default) or governed; anything else fails the render. | +| governance.roleFloors | object | `{}` | Floors per governance role (muster.governance.roleFloors): role -> tool names that ask agents in both modes on the governed servers of that role, added to muster's built-in floors. A role named here is valid in governedServers. Example for a server the installation registers: governance: roleFloors: exampleManager: [approve_change, merge_change] governedServers: example-manager: role: exampleManager safe: [get_info, list_changes] | +| governedServers | object | `{"agent-manager":{"role":"agentManager","safe":["get_info","list_agents","get_agent","get_agent_status","validate_agent","list_model_configs","list_egress_policies","list_skills","list_sessions","get_session","get_session_turn","toolchain_users","list_organizations","get_organization","list_organization_members","list_organization_connectors"]},"cluster-manager":{"role":"clusterManager","safe":["get_info","list_clusters","list_releases","list_node_pools"]},"kagent":{"role":"sessionManager","safe":["list_sessions","list_session_checkpoints","list_sandbox_templates","list_sandboxes","get_sandbox","get_sandbox_process","read_sandbox_outputs","read_sandbox_file"]},"mcp-kubernetes":{"role":"infrastructure","safe":["logs","list_port_forward_sessions","context_list","context_get_current","can_i","api_resources","cluster_health","capi_list_clusters","capi_get_cluster","capi_resolve_cluster","capi_cluster_health","get","list","describe"]},"model-manager":{"role":"modelManager","safe":["get_info","get_backend","list_backends","list_models","get_model","list_loaded_models","list_presets","search_models","check_fit","list_nodes","list_jobs","get_job"]},"skill-manager":{"role":"skillManager","safe":["list_skill_sources","list_skills","resolve_skills","get_skill","get_skill_file"]},"toolchain-manager":{"role":"toolchainManager","safe":["list_sources","list_toolchains","describe_toolchain","toolchain_build_status","search_packages"]},"vm-manager":{"role":"vmManager","safe":["get_info","get_host","list_images","get_image","list_networks","get_network","list_vms","get_vm","get_vm_metrics","get_vm_attestation"]},"workspace-manager":{"role":"workspaceManager","safe":["list_providers","list_owners","list_workspaces","get_workspace","list_repositories","preview_workspace"]}}` | The servers muster governs (muster.governance.governedServers), per source: `role` (agentManager, connectorManager, sessionManager, modelManager, clusterManager, vmManager, workspaceManager, toolchainManager, skillManager, infrastructure, or a role governance.roleFloors declares) and `safe`, the server's own read tools that agents call unasked on governed (never a floor). Every other tool asks agents on governed. A source renders one entry per MCPServer it ships: a manager component's .muster.mcpServer.name; kagent; mcp-kubernetes (the connectivity chart's and every agent-platform-mcps kubernetes entry); any other key is a muster server key itself. null drops a source (list it in governanceExempt). make verify-tool-approval fails on a shipped MCPServer in neither place, and on a safe entry that names a floor, no tool of its server, or starts with a write verb unless a `# safe-write: : ` comment above `safe:` says why. | +| governanceExempt | object | `{"capi":"agent-platform-mcps' capi family (mcp-kubernetes' CAPI tools): every tool reads","prometheus":"agent-platform-mcps' prometheus family (mcp-prometheus): every tool reads"}` | Shipped MCPServer sources muster deliberately does not govern, each with its reason. Read by the meta chart's tests only. | | tenants.platform.users | list | `[{"apiGroup":"rbac.authorization.k8s.io","kind":"Group","name":"system:authenticated"}]` | Every signed-in person: bound to agent-platform:platform-user in the kagent namespace, and, while musterMcpServerViewers is unset, to `list` (with get and watch) on muster's MCPServers in muster's namespace (the servers for everyone). RBAC subjects. The default, system:authenticated, gives this to every user. It also gives it to every ServiceAccount, so every pod in the cluster can read the platform tenant's Agents, RemoteMCPServer URLs and muster's MCPServer specs. To give it to people only, replace the default with an OIDC group that every user belongs to, written as the API server sees it (with the installation's OIDC groups prefix). | -| tenants.platform.editors | list | `[{"apiGroup":"rbac.authorization.k8s.io","kind":"Group","name":"giantswarm-ad:giantswarm-admins"},{"apiGroup":"rbac.authorization.k8s.io","kind":"Group","name":"giantswarm-github:giantswarm:giantswarm-admins"}]` | The platform's operators: bound to agent-platform:editor in the kagent namespace. RBAC subjects. The Giant Swarm admin groups, as in muster.rbac.*.subjects. | +| tenants.platform.editors | list | `[{"apiGroup":"rbac.authorization.k8s.io","kind":"Group","name":"giantswarm-ad:giantswarm-admins"},{"apiGroup":"rbac.authorization.k8s.io","kind":"Group","name":"giantswarm-github:giantswarm:giantswarm-admins"}]` | The platform's operators: bound to agent-platform:editor in the kagent namespace. RBAC subjects. The default names two admin groups kept from before tool approval: replace them with the installation's own. | | tenants.platform.kagentRelease.name | string | `""` | The name of kagent's HelmRelease in the kagent namespace. Empty, the default, admits none. | | tenants.platform.kagentRelease.writers | list | `[]` | The identities that write it: RBAC-style subjects of kind User, Group or ServiceAccount (with its namespace), as the API server sees them (a kubeconfig's user or group, a Flux ServiceAccount). | | tenants.platformTeam | list | `[]` | The customer's platform team, per installation: RBAC subjects bound to agent-platform:editor in the kagent namespace beside `platform.editors`, and added to muster's mcpserver-editor and workflow-editor subjects beside muster.rbac.*.subjects (the meta chart appends them to the muster release's values). Empty by default. A group is written as the API server sees it (with the OIDC groups prefix of the installation). | @@ -1687,6 +1767,8 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | backstage.installationName | string | `"agent-platform"` | | | backstage.extraScopes[0] | string | `"federated:id"` | | | backstage.extraScopes[1] | string | `"audience:server:client_id:dex-k8s-authenticator"` | | +| backstage.oidcClientId | string | `""` | | +| backstage.signInHandoff | bool | `true` | | | backstage.startUrlSearchParams | object | `{}` | | | backstage.enabledExtensions | list | `[]` | | | backstage.disabledExtensions[0] | string | `"page:gs/clusters"` | | @@ -1721,8 +1803,12 @@ The map is merged into each component's own `nodeSelector` (`muster.nodeSelector | backstage.backstage.extraEnvVars[1].name | string | `"AGENT_PLATFORM_OIDC_CLIENT_SECRET"` | | | backstage.backstage.extraEnvVars[1].valueFrom.secretKeyRef.name | string | `"{{ .Values.global.identity.existingSecret }}"` | | | backstage.backstage.extraEnvVars[1].valueFrom.secretKeyRef.key | string | `"dex-client-secret"` | | -| backstage.backstage.extraEnvVars[2].name | string | `"NODE_EXTRA_CA_CERTS"` | | -| backstage.backstage.extraEnvVars[2].value | string | `"{{ with (dig \"identity\" \"ca\" \"secretName\" \"\" .Values.global) }}/etc/agent-platform/idp-ca/{{ dig \"identity\" \"ca\" \"key\" \"ca.crt\" $.Values.global }}{{ end }}"` | | +| backstage.backstage.extraEnvVars[2].name | string | `"AGENT_PLATFORM_PORTAL_OIDC_CLIENT_SECRET"` | | +| backstage.backstage.extraEnvVars[2].valueFrom.secretKeyRef.name | string | `"{{ .Values.global.identity.existingSecret }}"` | | +| backstage.backstage.extraEnvVars[2].valueFrom.secretKeyRef.key | string | `"portal-dex-client-secret"` | | +| backstage.backstage.extraEnvVars[2].valueFrom.secretKeyRef.optional | bool | `true` | | +| backstage.backstage.extraEnvVars[3].name | string | `"NODE_EXTRA_CA_CERTS"` | | +| backstage.backstage.extraEnvVars[3].value | string | `"{{ with (dig \"identity\" \"ca\" \"secretName\" \"\" .Values.global) }}/etc/agent-platform/idp-ca/{{ dig \"identity\" \"ca\" \"key\" \"ca.crt\" $.Values.global }}{{ end }}"` | | | backstage.backstage.extraVolumes[0].name | string | `"idp-ca"` | | | backstage.backstage.extraVolumes[0].secret.secretName | string | `"{{ dig \"identity\" \"ca\" \"secretName\" \"\" .Values.global | default \"agent-platform-idp-ca\" }}"` | | | backstage.backstage.extraVolumes[0].secret.optional | bool | `true` | | diff --git a/helm/agent-platform/README.md.gotmpl b/helm/agent-platform/README.md.gotmpl index f648e50f..2e85a4a9 100644 --- a/helm/agent-platform/README.md.gotmpl +++ b/helm/agent-platform/README.md.gotmpl @@ -362,6 +362,60 @@ Karpenter relaxes a preferred term and launches the node. An installation's own `podAffinity` stands instead of the derived one (keep the atelet term in it, never required); below `1.3.0` the key is refused. +## Tool approval and the governance mode + +Every tool behind muster is **Allow**, **Ask** (a person confirms the call first) or **Block** +(hidden and refused). A connector's `rule` applies to tools without their own entry, new ones +included. Concepts and prompts: [Governing tool calls](https://github.com/giantswarm/agent-platform/blob/main/docs/tool-approval.md). + +| Value | What it does | +|-------|--------------| +| `governance.mode` | `trusted` (default) or `governed`; anything else fails the render. `governed` asks a person before an agent runs any tool of a governed server that is not on its safe list (new tools too) and any muster tool but its reads; it fails the render below `agent-platform.muster.governanceFloor`. | +| `governedServers` | Per source `{role, safe}`: `safe` is the read tools agents call unasked. Sources: the manager components, `kagent`, `mcp-kubernetes`, or any other key as a muster server key (`namespace/name` outside muster's namespace). `null` drops a source; `governanceExempt` lists shipped sources left ungoverned. The earlier `muster.muster.governance.servers.` shape fails the render. | +| `governance.roleFloors` | Role to tool names that ask agents in both modes, added to muster's built-in floors. A role declared here is valid in `governedServers`. | + +Persons get the connectors' settings only; no agent tool changes the mode. `governance` is a map +(`{mode, roleFloors}`); a string fails the render. Registering a server of your own: + +```yaml +governance: + roleFloors: + exampleManager: [approve_change, merge_change] +governedServers: + example-manager: + role: exampleManager + safe: [get_info, list_changes] +``` + +- **Prerequisites.** Asking calls are refused (reported as `approval.unavailable`) unless muster + runs on Valkey (default), has its OAuth server with Dex sign-in (`oauth.server.baseUrl`, + `dex.issuerUrl`, `dex.clientId`, `existingSecret`) and a public URL on that server's origin + (`muster.muster.oauth.mcpClient.enabled` with `publicUrl`). The chart does not fail a render + without them. +- **Rendered for muster.** `approval.installation` (`backstage.installationName`) and + `oauth.mcpClient.postLoginRedirectAllowlist`: the portal's `/sessions` (`backstage.publicPort` + when not 443) and `/auth/slack/return`; an own list's entries + stay. Without an entry the person answers in the portal or Slack by hand. +- **Retry as the same client.** An approval binds to the person and the calling client, not the MCP + session; another client of the person asks anew. At most 3 pending per client, 10 per person. +- **`connector-admin`** is muster's `mcpserver-editor` Role, bound to + `muster.rbac.mcpServerEditor.subjects` plus `tenants.platformTeam`. Its holders edit connectors, + set tool approval and may let an agent skip an `Ask`. The default subject is a ServiceAccount + nobody can authenticate as (fail closed; `workflowEditor` likewise): set your admin groups, + with the OIDC groups prefix. Binding `system:authenticated` makes everyone an admin. +- **`muster-approval-binder`** lets agent-manager's ServiceAccount (and only it) bind an agent's + tool settings to a Session (`muster.rbac.approvalBinder.subjects`; an own list stands; name an + agent-manager ServiceAccount the chart does not create). +- **Shipped connectors carry `spec.approval`.** `mcp-kubernetes.mcpServer.approval` is + *Recommended* (read-only Allow, rest Ask), `kagent.controllerRoute.mcp.approval` and the managers' + `.muster.mcpServer.approval` are *Allow all*, agent-platform-mcps families + `muster.families..approval` *Recommended*. Tighten a tool or the rule there; `null` + renders none (the connector runs everything, shown as *not reviewed*). + +Operator steps: [UPGRADE.md](../../UPGRADE.md). `make verify-tool-approval` asserts the governance configuration, its coverage (every shipped +MCPServer governed or exempt, no floor safe), the allowlist, the admins, the binder and the +connectors' settings. + ## Voluntary disruption The platform's core runs as single replicas — the agentgateway data plane, muster, the kagent controller, klaus-gateway, agent-manager — and each carries long-lived streams (MCP sessions, A2A and portal SSE turns, the LLM listener). A voluntary eviction (Karpenter consolidation, a node drain) cuts them mid-turn (giantswarm/agent-platform#431). Two guards, both on by default: diff --git a/helm/agent-platform/examples/customer-bom.yaml b/helm/agent-platform/examples/customer-bom.yaml index 3e70e4cd..f74c2c0f 100644 --- a/helm/agent-platform/examples/customer-bom.yaml +++ b/helm/agent-platform/examples/customer-bom.yaml @@ -37,36 +37,36 @@ gitops: interval: 30m components: - muster: { versionRange: "5.67.0-rc.19" } + muster: { versionRange: "5.67.0-rc.61" } agentgateway: { versionRange: "2.8.0" } valkey: { versionRange: "0.1.4" } - agent-platform-mcps: { versionRange: "0.9.0" } + agent-platform-mcps: { versionRange: "0.13.0-rc.1" } kagent: { versionRange: "1.34.0-rc.4" } kagent-crds: { versionRange: "1.34.0-rc.4" } substrate: { versionRange: "1.18.0" } substrate-crds: { versionRange: "1.18.0" } google-access-token-credential-provider: { versionRange: "0.3.0" } - klaus-gateway: { versionRange: "4.18.10" } + klaus-gateway: { versionRange: "4.20.0-rc.8" } agent-sandbox: { versionRange: "0.2.31" } dicebear: { versionRange: "0.3.10" } - model-manager: { versionRange: "1.25.0" } + model-manager: { versionRange: "1.26.0-rc.1" } credential-api: { versionRange: "0.1.0" } - agent-manager: { versionRange: "4.0.0" } + agent-manager: { versionRange: "4.1.0-rc.1" } # The default agent (components.default-agent): the agent chart. default-agent: { versionRange: "2.6.0" } - vm-manager: { versionRange: "0.29.0" } + vm-manager: { versionRange: "0.30.0-rc.2" } # The cluster write surface (components.cluster-manager, off by default). - cluster-manager: { versionRange: "0.40.0-rc.1" } + cluster-manager: { versionRange: "0.40.0-rc.3" } # The workspace surface (components.workspace-manager, follows # workspaces.enabled, off by default). - workspace-manager: { versionRange: "0.16.0-rc.1" } + workspace-manager: { versionRange: "0.17.0-rc.1" } # The toolchain surface (components.toolchain-manager, off by default). - toolchain-manager: { versionRange: "0.5.0" } + toolchain-manager: { versionRange: "0.6.0-rc.16" } # The skill sources (components.skill-manager, follows agent-manager). - skill-manager: { versionRange: "0.4.0-rc.1" } + skill-manager: { versionRange: "0.5.0-rc.1" } # The organizations' operator (components.agent-platform-operator, follows # agentPlatformOrganizations.enabled, off by default). - agent-platform-operator: { versionRange: "0.5.0" } + agent-platform-operator: { versionRange: "0.6.0-rc.1" } # The standalone chart's extras (off by default; the pins apply when an # installation turns them on). Snapshot of the agent-platform-standalone # chart's tested pins on 2026-09-08; the kserve charts move together (one diff --git a/helm/agent-platform/templates/NOTES.txt b/helm/agent-platform/templates/NOTES.txt index 220062a8..f8e6fb42 100644 --- a/helm/agent-platform/templates/NOTES.txt +++ b/helm/agent-platform/templates/NOTES.txt @@ -107,3 +107,9 @@ Workspaces, base URL {{ $wmBase }} (routed: /.well-known/jwks.json): {{- end }} {{- end }} {{- end }} +{{- with (include "agent-platform.muster.redirectAllowlist" . | fromJsonArray) }} +{{- if not (dig "muster" "oauth" "mcpClient" "enabled" false ($.Values.muster | default dict)) }} + +Tool approval: muster renders its redirect allowlist ({{ join ", " . }}) only with muster.muster.oauth.mcpClient.enabled on, which is off. Until it is, the approval page records an answer but never sends the browser back to the portal or Slack: the person returns by hand (Done in the portal, or Slack). +{{- end }} +{{- end }} diff --git a/helm/agent-platform/templates/_helpers.tpl b/helm/agent-platform/templates/_helpers.tpl index c6803480..f2428dce 100644 --- a/helm/agent-platform/templates/_helpers.tpl +++ b/helm/agent-platform/templates/_helpers.tpl @@ -521,6 +521,13 @@ schema refuses the key. An installation's own rbac.namespaces stays. */ -}} {{- fail (printf "agent-manager.muster.url (%s) differs from the platform's muster MCP URL (%s): agent-manager composes every agent's RemoteMCPServer against the muster this chart installs — the URL follows muster.fullnameOverride and muster.service.port; leave agent-manager.muster.url unset" $ownUrl $url) -}} {{- end -}} {{- $musterValues := dict "url" $url -}} +{{- /* agent-manager calls muster's session bindings API on its own port +(agent-platform.muster.sessionBindings); an own bindingsUrl stands. */ -}} +{{- with (include "agent-platform.muster.sessionBindings" .root | fromJson).url -}} +{{- if not (dig "muster" "bindingsUrl" "" (index $.root.Values "agent-manager" | default dict)) -}} +{{- $_ := set $musterValues "bindingsUrl" . -}} +{{- end -}} +{{- end -}} {{- /* muster trusts a bound Session's actor JWT: every Session start_session binds carries the agent's toolset, and agent-manager reports it as bound to each session at its start (agent-manager 2.9.0, giantswarm/agent-manager#228). */ -}} @@ -548,6 +555,43 @@ takes the key (agent-platform.agentManager.toolchainsFloor). */ -}} {{- $_ := set $musterValues "toolchainsToolsPrefix" $prefix -}} {{- end -}} {{- end -}} +{{- /* Tool approval per agent: +agent-manager binds an agent's approval settings with every Session and +refuses settings while it does not. On while muster takes them, from the +floors agent-platform.muster.agentApprovalFloor and +agent-platform.agentManager.toolApprovalFloor (below the agent-manager floor +its chart has no such key); an own value stands. */ -}} +{{- if include "agent-platform.componentFloorAtLeast" (dict "root" .root "name" "agent-manager" "version" (include "agent-platform.agentManager.toolApprovalFloor" .root)) -}} +{{- $ownTa := dig "muster" "toolApproval" "enabled" nil (index .root.Values "agent-manager" | default dict) -}} +{{- if kindIs "invalid" $ownTa -}} +{{- $musterTakes := and (include "agent-platform.componentEnabled" (dict "root" .root "name" "muster")) (include "agent-platform.componentFloorAtLeast" (dict "root" .root "name" "muster" "version" (include "agent-platform.muster.agentApprovalFloor" .root))) -}} +{{- $_ := set $musterValues "toolApproval" (dict "enabled" (ternary true false (not (empty $musterTakes)))) -}} +{{- end -}} +{{- /* The default agent's settings live in its release, which this chart +renders in its own Flux namespace, not in the kagent namespace agent-manager +manages: agent-manager reads it by the Agent's Flux labels and gets get on +it by name (muster.toolApproval.platformReleases, with the Agent it renders: +an agent-manager that reads the release only for the listed agent, and refuses +it when the Agent's labels name another release), so every person who may +start a session with the default agent can. With a remote target the release +is on this cluster and agent-manager on the target, where it cannot read it: +agent-manager gets the release's approval values instead +(muster.toolApproval.platformAgents, agent-platform.defaultAgent.approval), +rendered here from the values the release is rendered with, so only whoever +may change the release may change them; agent-manager checks them against +the Agent's Flux labels and the agent chart's X-Muster-Tool-Approval header. */ -}} +{{- if include "agent-platform.componentEnabled" (dict "root" .root "name" "default-agent") -}} +{{- $ta := get $musterValues "toolApproval" | default dict -}} +{{- $release := dict "namespace" (dig "namespace" "" (.root.Values.gitops | default dict) | default .root.Release.Namespace) "name" (include "agent-platform.childName" (dict "root" .root "name" "default-agent")) -}} +{{- $agent := include "agent-platform.defaultAgent.approval" (dict "root" .root "release" $release) | fromJson -}} +{{- if include "agent-platform.targetSecretName" .root -}} +{{- $_ := set $ta "platformAgents" (list $agent) -}} +{{- else -}} +{{- $_ := set $ta "platformReleases" (list (dict "namespace" $release.namespace "name" $release.name "agent" (dict "namespace" $agent.namespace "name" $agent.name))) -}} +{{- end -}} +{{- $_ := set $musterValues "toolApproval" $ta -}} +{{- end -}} +{{- end -}} {{- $_ := set $derived "muster" $musterValues -}} {{- /* The installation's toolchains, while the toolchain-manager is on: toolchains.repository the first source's registry (an own value stands), and @@ -648,6 +692,14 @@ renders (networkPolicy.mcpBackends). */ -}} {{- with $mcpBackends -}} {{- $_ := set $derived "networkPolicy" (dict "mcpBackends" .) -}} {{- end -}} +{{- /* agent-manager's egress to muster's session bindings port +(agent-platform.muster.sessionBindings). */ -}} +{{- with (include "agent-platform.muster.sessionBindings" .root | fromJson).sessionBindings -}} +{{- $np := get $derived "networkPolicy" | default dict -}} +{{- $_ := set $np "musterSessionBindingsPort" (int (dig "port" 8091 .)) -}} +{{- $_ := set $np "musterSessionBindingsNamespace" (include "agent-platform.muster.namespace" $.root) -}} +{{- $_ := set $derived "networkPolicy" $np -}} +{{- end -}} {{- /* agent-manager's migrate run pins through the skill-manager too: its URL, its namespace and the service token's Secret, which the connectivity release generates (agent-platform.skillManager.serviceToken). */ -}} @@ -687,6 +739,29 @@ connectivity release installs elsewhere. */ -}} {{- end -}} {{- end -}} {{- end -}} +{{- if eq .name "backstage" -}} +{{- /* The portal backend's own workload token for muster (audience muster), +projected where its muster backend reads it, while the platform binds the +portal's ServiceAccount to muster-approval-decider +(agent-platform.backstage.musterWorkloadToken). Appended to the block's own +extraVolumes and extraVolumeMounts, which derived values would replace. The +portal chart's own projection (backstage.backstage.musterWorkloadToken) or an +own entry of that name would declare it twice: the render fails. */ -}} +{{- with (include "agent-platform.backstage.musterWorkloadToken" .root | fromJson) -}} +{{- $own := dig "backstage" dict ($.root.Values.backstage | default dict) | default dict -}} +{{- if dig "musterWorkloadToken" "enabled" false $own -}} +{{- fail "backstage.backstage.musterWorkloadToken.enabled is on, and the platform projects the portal's workload token for muster itself: turn the value off" -}} +{{- end -}} +{{- range concat (dig "extraVolumes" list $own | default list) (dig "extraVolumeMounts" list $own | default list) -}} +{{- if eq (toString (get (. | default dict) "name")) "muster-workload-token" -}} +{{- fail "backstage.backstage.extraVolumes or extraVolumeMounts name muster-workload-token, which the platform projects itself for the portal's workload token: drop the entry" -}} +{{- end -}} +{{- end -}} +{{- $volumes := append (dig "extraVolumes" list $own | default list) .volume -}} +{{- $mounts := append (dig "extraVolumeMounts" list $own | default list) .mount -}} +{{- $_ := set $derived "backstage" (dict "extraVolumes" $volumes "extraVolumeMounts" $mounts) -}} +{{- end -}} +{{- end -}} {{- if eq .name "toolchain-manager" -}} {{- $derived = include "agent-platform.toolchainManager.derived" .root | fromJson -}} {{- end -}} @@ -1098,6 +1173,9 @@ workspaces on and no releasable instance agent-platform.validateWorkspaceAuth has failed the render. */ -}} {{- $provider := include "agent-platform.muster.credentialProvider" .root | fromJson -}} {{- if or $provider.releasable (dig "actorBearer" "enabled" false $provider) -}} +{{- with (include "agent-platform.muster.sessionBindings" .root | fromJson).sessionBindings -}} +{{- $_ := set $provider "sessionBindings" . -}} +{{- end -}} {{- $muster := get $derived "muster" | default dict -}} {{- $_ := set $muster "credentialProvider" $provider -}} {{- $_ := set $derived "muster" $muster -}} @@ -1120,7 +1198,7 @@ installation keeps its own (agent-platform.chatgpt.personalLogin). */ -}} {{- $_ := set $derived "muster" $muster -}} {{- end -}} {{- /* The customer's platform team writes the servers and workflows of -muster's namespace beside the Giant Swarm admin groups +muster's namespace beside the configured editor groups (giantswarm/agent-platform#706): tenants.platformTeam is appended to both editor bindings' subjects, so an installation names its team without repeating the admin groups. */ -}} @@ -1138,6 +1216,39 @@ repeating the admin groups. */ -}} {{- $muster := get $derived "muster" | default dict -}} {{- $_ := set $derived "muster" (mergeOverwrite $muster (dict "toolsetPresets" .)) -}} {{- end -}} +{{- /* muster's governance configuration from the platform's governance mode +(agent-platform.muster.governance), from the muster floor that reads it. */ -}} +{{- with (include "agent-platform.muster.governance" .root | fromJson) -}} +{{- $muster := get $derived "muster" | default dict -}} +{{- $_ := set $muster "governance" . -}} +{{- $_ := set $derived "muster" $muster -}} +{{- end -}} +{{- /* muster's approval configuration and the pages it may return the +browser to after an approval, from the same muster floor. */ -}} +{{- with (include "agent-platform.muster.approval" .root | fromJson) -}} +{{- $muster := get $derived "muster" | default dict -}} +{{- $_ := set $muster "approval" . -}} +{{- $_ := set $derived "muster" $muster -}} +{{- end -}} +{{- /* agent-manager's ServiceAccount, the one sender of approval settings, +bound to muster-approval-binder by the muster chart in muster's namespace. */ -}} +{{- with (include "agent-platform.muster.approvalBinderSubjects" .root | fromJsonArray) -}} +{{- $rbac := get $derived "rbac" | default dict -}} +{{- $_ := set $rbac "approvalBinder" (dict "subjects" .) -}} +{{- $_ := set $derived "rbac" $rbac -}} +{{- end -}} +{{- /* The portal's ServiceAccount, the one workload muster takes a person's +approval decision and handoff request from (beside the person's token), +bound to muster-approval-decider by the muster chart in muster's namespace. */ -}} +{{- with (include "agent-platform.muster.approvalDeciderSubjects" .root | fromJsonArray) -}} +{{- $rbac := get $derived "rbac" | default dict -}} +{{- $_ := set $rbac "approvalDecider" (dict "subjects" .) -}} +{{- $_ := set $derived "rbac" $rbac -}} +{{- end -}} +{{- with (include "agent-platform.muster.redirectAllowlist" .root | fromJsonArray) -}} +{{- $muster := get $derived "muster" | default dict -}} +{{- $_ := set $derived "muster" (mergeOverwrite $muster (dict "oauth" (dict "mcpClient" (dict "postLoginRedirectAllowlist" .)))) -}} +{{- end -}} {{- end -}} {{- if and (eq .name "model-manager") (not (include "agent-platform.componentEnabled" (dict "root" .root "name" "kagent"))) -}} {{- $_ := set $derived "kagent" (dict "disableWiring" true) -}} @@ -1782,12 +1893,13 @@ Usage: include "agent-platform.agentManager.installationModelsFloor" $root {{/* Whether the floor of components..versionRange is at least version, a release candidate of it included: "true", else empty (a range without a floor -too). +too, and an empty version: a floor whose release does not exist yet admits +nothing, so what it gates stays off). Usage: include "agent-platform.componentFloorAtLeast" (dict "root" $root "name" "" "version" "X.Y.Z") */}} {{- define "agent-platform.componentFloorAtLeast" -}} {{- $floor := regexReplaceAll "-.*$" (include "agent-platform.semverRangeFloor" (dig .name "versionRange" "" .root.Values.components)) "" -}} -{{- if and $floor (ge ((semver $floor).Compare (semver .version)) 0) -}}true{{- end -}} +{{- if and $floor .version (ge ((semver $floor).Compare (semver .version)) 0) -}}true{{- end -}} {{- end -}} {{/* @@ -2212,8 +2324,263 @@ earlier muster refuses such a binding, so a Session would not start. One line each, no comment inside the define. */}} {{- define "agent-platform.agentManager.toolsetBindingFloor" -}}2.9.0{{- end -}} + +{{/* +The floors of tool approval per agent: the first agent-manager +whose chart takes muster.toolApproval, and the first muster that takes an +agent's approval settings with a Session binding: agent-manager 4.1.0-rc.1 +and muster 5.67.0-rc.61 (giantswarm/giantswarm#38902). An empty floor admits +no release, so what it gates stays off and the agent chart line cannot move to +3.x. A guess would switch the wiring on against released versions without the +feature (muster 5.66.x and 5.67.0-rc.1 have no agent approval). One line each, +no comment inside the define. +*/}} +{{- define "agent-platform.agentManager.toolApprovalFloor" -}}4.1.0-rc.1{{- end -}} +{{- define "agent-platform.muster.agentApprovalFloor" -}}5.67.0-rc.61{{- end -}} +{{- /* The first muster serving the session bindings API on its own port +(muster.credentialProvider.sessionBindings). */ -}} +{{- define "agent-platform.muster.sessionBindingsPortFloor" -}}5.67.0-rc.61{{- end -}} +{{- /* The first muster reading approval.trustedClients (handoffClients +renamed; the trusted client also decides approvals inline, POST +/approvals/{id}/decision) and reviewing the trusted client's own workload +token (verb decide, muster-approval-decider; giantswarm/muster#1912). +Below it the chart lists no trusted client under either +name: a muster that issues handoff tickets without the workload review and +the sign-in confirmation must not be trusted with them. */ -}} +{{- define "agent-platform.muster.trustedClientsFloor" -}}5.67.0-rc.61{{- end -}} + +{{/* +The session bindings API muster serves agent-manager alone: +from agent-platform.muster.sessionBindingsPortFloor, while muster runs its +credential provider, on its own port and no longer on the aggregator port, +its network policy admitting agent-manager's pods only. Emits JSON: +{sessionBindings, url} -- muster's credentialProvider.sessionBindings and +agent-manager's muster.bindingsUrl -- or {} below the floor or without the +provider. An own muster.muster.credentialProvider.sessionBindings key stands. +Usage: include "agent-platform.muster.sessionBindings" . | fromJson +*/}} +{{- define "agent-platform.muster.sessionBindings" -}} +{{- $out := dict -}} +{{- $provider := include "agent-platform.muster.credentialProvider" . | fromJson -}} +{{- if and $provider.enabled (include "agent-platform.componentFloorAtLeast" (dict "root" . "name" "muster" "version" (include "agent-platform.muster.sessionBindingsPortFloor" .))) -}} +{{- $own := dig "muster" "credentialProvider" "sessionBindings" dict (.Values.muster | default dict) | default dict -}} +{{- $amNs := dig "agent-manager" "targetNamespace" "" .Values.components | default (include "agent-platform.targetNamespace" .) -}} +{{- $amName := dig "nameOverride" "agent-manager" (index .Values "agent-manager" | default dict) -}} +{{- $sb := dict "onMainPort" false "allowedFrom" (list (dict "namespace" $amNs "podLabels" (dict "app.kubernetes.io/name" $amName))) -}} +{{- range $k, $v := $own -}}{{- $_ := set $sb $k $v -}}{{- end -}} +{{- $port := dig "port" 8091 $sb -}} +{{- $out = dict "sessionBindings" $sb "url" (printf "http://%s.%s.svc.cluster.local:%v/session-bindings" (include "agent-platform.musterFullname" .) (include "agent-platform.muster.namespace" .) $port) -}} +{{- end -}} +{{- $out | toJson -}} +{{- end -}} {{- define "agent-platform.muster.toolsetBindingFloor" -}}5.49.0{{- end -}} +{{/* +The first agent-manager whose migrate has the Generic chart 2.x -> 3.x hop +: agent chart 3.0 removes +muster.requireApproval, and that migrate rewrites it to default: Ask before +it moves a namespace's chart source. The same release as +agent-platform.agentManager.toolApprovalFloor; unset, it keeps every 3.x +line refused. One line, no comment inside the define. +*/}} +{{- define "agent-platform.agentManager.agentChartV3Floor" -}}4.1.0-rc.1{{- end -}} + +{{/* +The release floors depend on one another: the governance floor +(agent-platform.muster.governanceFloor) gates the binder, the approval block +and the redirect allowlist that muster's approval enforcement needs, and the +floors of tool approval per agent, of the session bindings port and of the +agent chart 3.x line each make agent-manager bind settings muster refuses +without them. A floor set while the governance floor is unset (a release that +sets them in two steps) renders agent-manager against a muster wired for none +of it: no Session starts. Fails naming the floor that is set and the one that +is missing. Governance itself (governance.mode governed, governance.roleFloors) +needs muster as a component of this release: with muster off (an external one) +nothing here would enforce it, so it fails too. Emits nothing. +*/}} +{{- define "agent-platform.validateReleaseFloors" -}} +{{- if not (include "agent-platform.muster.governanceFloor" .) -}} +{{- range $name := list "agentManager.toolApprovalFloor" "muster.agentApprovalFloor" "muster.sessionBindingsPortFloor" "agentManager.agentChartV3Floor" "muster.trustedClientsFloor" -}} +{{- if include (printf "agent-platform.%s" $name) $ -}} +{{- fail (printf "agent-platform.%s is set while agent-platform.muster.governanceFloor is unset: the muster approval binder, approval block and redirect allowlist render only from the governance floor, so agent-manager would bind settings that muster refuses from it and no Session would start; set agent-platform.muster.governanceFloor in the same release" $name) -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- if not (include "agent-platform.componentEnabled" (dict "root" . "name" "muster")) -}} +{{- if ne (include "agent-platform.governance" .) "trusted" -}} +{{- fail (printf "governance.mode %s needs muster as a component of this release (components.muster.enabled): with muster off nothing here enforces governance, so the platform would claim a governed state it does not have; enable components.muster, or keep governance.mode trusted" (include "agent-platform.governance" .)) -}} +{{- end -}} +{{- if dig "roleFloors" nil (.Values.governance | default dict) -}} +{{- fail "governance.roleFloors is set while muster is off (components.muster.enabled): the role floors are rendered into muster's governance configuration, so they would be dropped and the servers of those roles would not ask; enable components.muster, or remove governance.roleFloors" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +The release majors a range admits, as a JSON list of strings, decided as +agent-manager's migrate decides its target major (TargetMajor) and the +agent-platform-operator the major of a chart source move: every version the +range names, with its next patch and next minor (so an exact pin, a narrow +bound, ~2.250 and each alternative of a `||` range count: `3.0.1 || 2.6.0` +admits 2 and 3); and majors 0-99, each probed with its first and a very late +version, majors 0-9 also with every minor 0-199 (first and late patch), so +x-ranges, carets, tildes and bounds all count. A probe counts only when the +range admits it. A range that admits only pre-releases admits no major. +Release versions only, as Flux's semver admits them without a pre-release +comparator. +Supported grammar, the same in agent-manager's migrate and the +agent-platform-operator: a Masterminds semver range as Flux reads it +(x-ranges, carets, tildes, comparisons, hyphen ranges, `||` alternatives) +over release majors 0-99. A range that admits a version of major 100 or more +is unsupported (agent-platform.agentChart.beyondProbes) and refused by +agent-platform.validateAgentChartLine: the probes stop at 99. These are +finite probes, not a general semver intersection. +Usage: include "agent-platform.agentChart.majors" "" | fromJsonArray +*/}} +{{- define "agent-platform.agentChart.majors" -}} +{{- $range := toString . -}} +{{- $named := list -}} +{{- range $lit := regexFindAll "[0-9]+(\\.[0-9]+)?(\\.[0-9]+)?" $range -1 -}} +{{- $p := splitList "." $lit -}} +{{- $maj := atoi (index $p 0) -}} +{{- $min := 0 -}}{{- if gt (len $p) 1 -}}{{- $min = atoi (index $p 1) -}}{{- end -}} +{{- $pat := 0 -}}{{- if gt (len $p) 2 -}}{{- $pat = atoi (index $p 2) -}}{{- end -}} +{{- range $v := list (printf "%d.%d.%d" $maj $min $pat) (printf "%d.%d.%d" $maj $min (add1 $pat)) (printf "%d.%d.0" $maj (add1 $min)) -}} +{{- if semverCompare $range $v -}}{{- $named = append $named (toString $maj) -}}{{- end -}} +{{- end -}} +{{- end -}} +{{- $out := list -}} +{{- range $m := until 100 -}} +{{- $hit := or (has (toString $m) $named) (semverCompare $range (printf "%d.0.0" $m)) (semverCompare $range (printf "%d.999999.999999" $m)) -}} +{{- if and (not $hit) (lt $m 10) -}} +{{- range $n := until 200 -}} +{{- if and (not $hit) (or (semverCompare $range (printf "%d.%d.0" $m $n)) (semverCompare $range (printf "%d.%d.999999" $m $n))) -}}{{- $hit = true -}}{{- end -}} +{{- end -}} +{{- end -}} +{{- if $hit -}}{{- $out = append $out (toString $m) -}}{{- end -}} +{{- end -}} +{{- $out | toJson -}} +{{- end -}} + +{{/* +"true" when a range admits a version of a major past the probes of +agent-platform.agentChart.majors (99): a version of major 100 or more it names +(with its next patch and minor), or any version of major 100 (first and late +version of minors 0-199, and a late minor); empty otherwise. Read as +agent-manager's migrate and the agent-platform-operator read it (beyondProbes). +Usage: include "agent-platform.agentChart.beyondProbes" "" +*/}} +{{- define "agent-platform.agentChart.beyondProbes" -}} +{{- $range := toString . -}} +{{- $hit := false -}} +{{- range $lit := regexFindAll "[0-9]+(\\.[0-9]+)?(\\.[0-9]+)?" $range -1 -}} +{{- $p := splitList "." $lit -}} +{{- $maj := atoi (index $p 0) -}} +{{- if gt $maj 99 -}} +{{- $min := 0 -}}{{- if gt (len $p) 1 -}}{{- $min = atoi (index $p 1) -}}{{- end -}} +{{- $pat := 0 -}}{{- if gt (len $p) 2 -}}{{- $pat = atoi (index $p 2) -}}{{- end -}} +{{- range $v := list (printf "%d.%d.%d" $maj $min $pat) (printf "%d.%d.%d" $maj $min (add1 $pat)) (printf "%d.%d.0" $maj (add1 $min)) -}} +{{- if semverCompare $range $v -}}{{- $hit = true -}}{{- end -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- if or (semverCompare $range "100.0.0") (semverCompare $range "100.999999.999999") -}}{{- $hit = true -}}{{- end -}} +{{- range $n := until 200 -}} +{{- if and (not $hit) (or (semverCompare $range (printf "100.%d.0" $n)) (semverCompare $range (printf "100.%d.999999" $n))) -}}{{- $hit = true -}}{{- end -}} +{{- end -}} +{{- if $hit -}}true{{- end -}} +{{- end -}} + +{{/* +The first pre-release of the next major a range admits (e.g. 3.0.0-rc.1 under +">=2.6.0 <=3.0.0-rc.1"), or empty: Flux would serve that chart under a range +read as the lower major. Takes a dict: range, major (the one major found). +*/}} +{{- define "agent-platform.agentChart.nextMajorPreRelease" -}} +{{- $next := add1 (atoi .major) -}} +{{- $found := "" -}} +{{- range $pre := list "0" "alpha.0" "rc.1" "rc.999" -}} +{{- $v := printf "%d.0.0-%s" $next $pre -}} +{{- if and (not $found) (semverCompare $.range $v) -}}{{- $found = $v -}}{{- end -}} +{{- end -}} +{{- /* Helm 3.17 bundles a semver library that never matches a pre-release against a range whose lower bound names none, so the probes above see nothing there; read the upper bounds as written too: `<=` or `<` naming a pre-release of the next major other than `=!~^*|,+-]+$" $range) (regexMatch "[0-9]" $range) (not (regexMatch "(^|[\\s|,<>=~^])[A-Za-uwyzA-WYZ]" $range))) -}} +{{- fail (printf "agent-manager.agentChart.semver %q is not a semver range: name the line as a range of one major (\">=2.6.0 <3.0.0\")" $range) -}} +{{- end -}} +{{- $majors := include "agent-platform.agentChart.majors" $range | fromJsonArray -}} +{{- if and (le (len $majors) 1) (include "agent-platform.agentChart.beyondProbes" $range) -}} +{{- fail (printf "agent-manager.agentChart.semver %q admits an agent chart major of 100 or more, which this chart, agent-manager's migrate and the agent-platform-operator do not read: name the line as a range of one major below 100 (\">=3.0.0 <4.0.0\")" $range) -}} +{{- end -}} +{{- if not $majors -}} +{{- fail (printf "agent-manager.agentChart.semver %q admits no release version of the agent chart: name the line as a range of one major (\">=2.6.0 <3.0.0\"; \">=3.0.0 <4.0.0\" once it may move), never a pre-release alone" $range) -}} +{{- end -}} +{{- if gt (len $majors) 1 -}} +{{- $shown := join ", " $majors -}} +{{- if gt (len $majors) 5 -}}{{- $shown = printf "%s, …" (join ", " (slice $majors 0 5)) -}}{{- end -}} +{{- fail (printf "agent-manager.agentChart.semver %q admits agent chart majors %s: agent-manager's migrate moves an installation's agents to exactly one major; bound the range below the next major (\">=3.0.0 <4.0.0\", or a 2.x range)" $range $shown) -}} +{{- end -}} +{{- $major := first $majors -}} +{{- with include "agent-platform.agentChart.nextMajorPreRelease" (dict "range" $range "major" $major) -}} +{{- fail (printf "agent-manager.agentChart.semver %q admits %s, a pre-release of the next agent chart major: Flux would serve it under a range read as %s.x; bound it below %d.0.0-0" $range . $major (add1 (atoi $major))) -}} +{{- end -}} +{{- if not (has $major (list "2" "3")) -}} +{{- fail (printf "agent-manager.agentChart.semver %q selects agent chart %s.x: this chart renders agents of the 2.x and 3.x lines only" $range $major) -}} +{{- end -}} +{{- if eq $major "3" -}} +{{- $amFloor := include "agent-platform.agentManager.agentChartV3Floor" . -}} +{{- $musterFloor := include "agent-platform.muster.agentApprovalFloor" . -}} +{{- if not (and $amFloor $musterFloor) -}} +{{- fail (printf "agent-manager.agentChart.semver %q moves the agents to agent chart 3.x, which removes muster.requireApproval: this chart does not know yet which releases make that safe — the agent-manager whose migrate rewrites requireApproval to default: Ask (agent-platform.agentManager.agentChartV3Floor) and the muster that enforces default: Ask (agent-platform.muster.agentApprovalFloor) are unset; keep the 2.x line until a platform release sets them" $range) -}} +{{- end -}} +{{- if not (include "agent-platform.componentFloorAtLeast" (dict "root" . "name" "agent-manager" "version" $amFloor)) -}} +{{- fail (printf "agent-manager.agentChart.semver %q moves the agents to agent chart 3.x, but components.agent-manager.versionRange %q admits a release below %s: agent chart 3.0 removes muster.requireApproval, and only agent-manager %s's migrate rewrites it to default: Ask before it moves a namespace's chart source; move components.agent-manager.versionRange to %s or later in the same change" $range (dig "agent-manager" "versionRange" "" .Values.components) $amFloor $amFloor $amFloor) -}} +{{- end -}} +{{- if not (and (include "agent-platform.componentEnabled" (dict "root" . "name" "muster")) (include "agent-platform.componentFloorAtLeast" (dict "root" . "name" "muster" "version" $musterFloor))) -}} +{{- fail (printf "agent-manager.agentChart.semver %q moves the agents to agent chart 3.x, but muster is off or components.muster.versionRange %q admits a release below %s: chart 3.0 replaces muster.requireApproval with default: Ask, which only muster %s enforces; move components.muster.versionRange to %s or later in the same change" $range (dig "muster" "versionRange" "" .Values.components) $musterFloor $musterFloor $musterFloor) -}} +{{- end -}} +{{- $ownTa := dig "muster" "toolApproval" "enabled" nil $am -}} +{{- if and (not (kindIs "invalid" $ownTa)) (not $ownTa) -}} +{{- fail (printf "agent-manager.agentChart.semver %q moves the agents to agent chart 3.x, but agent-manager.muster.toolApproval.enabled is false: an agent migrated from muster.requireApproval to default: Ask would start no Session (agent-manager refuses settings it does not bind); leave the key unset" $range) -}} +{{- end -}} +{{- end -}} +{{- if include "agent-platform.componentEnabled" (dict "root" . "name" "default-agent") -}} +{{- $da := dig "default-agent" "versionRange" "" .Values.components | toString -}} +{{- if $da -}} +{{- $daMajors := include "agent-platform.agentChart.majors" $da | fromJsonArray -}} +{{- if ne (toJson $daMajors) (toJson $majors) -}} +{{- fail (printf "components.default-agent.versionRange %q and agent-manager.agentChart.semver %q select different agent chart majors (%s and %s): the default agent is a release of the same chart and moves with the line (\">=3.0.0 <4.0.0\" for both, or a 2.x range for both)" $da $range (join ", " $daMajors) $major) -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- end -}} + {{/* While muster trusts the actor JWT, agent-manager is told so (muster.actorBearer) and binds every Session with the agent's toolset: the @@ -2764,8 +3131,11 @@ source-controller uses). Usage: include "agent-platform.semverRangeFloor" "" */}} {{- define "agent-platform.semverRangeFloor" -}} +{{- $lowest := "" -}} +{{- $open := false -}} +{{- range $alt := splitList "||" (toString .) -}} {{- $floor := "" -}} -{{- range splitList " " (. | replace "," " " | trim) -}} +{{- range splitList " " ($alt | replace "," " " | trim) -}} {{- $term := trim . -}} {{- if and (not $floor) $term (not (hasPrefix "<" $term)) -}} {{- $v := $term | trimPrefix ">=" | trimPrefix ">" | trimPrefix "^" | trimPrefix "~" | trimPrefix "=" | trimPrefix "v" -}} @@ -2774,7 +3144,13 @@ Usage: include "agent-platform.semverRangeFloor" "" {{- end -}} {{- end -}} {{- end -}} -{{- $floor -}} +{{- if not $floor -}} +{{- $open = true -}} +{{- else if or (not $lowest) (lt ((semver $floor).Compare (semver $lowest)) 0) -}} +{{- $lowest = $floor -}} +{{- end -}} +{{- end -}} +{{- if not $open -}}{{- $lowest -}}{{- end -}} {{- end -}} {{/* @@ -5004,6 +5380,417 @@ comment inside the define. */}} {{- define "agent-platform.muster.presetIconsFloor" -}}5.61.0{{- end -}} +{{/* +The first muster release that reads the governance configuration +(muster.governance: the mode and the servers it names per role) and enforces +tool approval (Governing tool calls): 5.67.0-rc.61 (giantswarm/muster#1912). +A guessed floor would render the configuration for a muster that ignores +it, so a `governed` platform would not be governed. The +same floor gates the approval block and the redirect allowlist entries below +(agent-platform.muster.approval, agent-platform.muster.redirectAllowlist), and +tests/verify-tool-approval.py takes it from here. Below it the meta chart +forwards none of them. One line, no comment inside the define. +*/}} +{{- define "agent-platform.muster.governanceFloor" -}}5.67.0-rc.61{{- end -}} + +{{/* +The platform's governance mode (top-level `governance`: trusted, the default, +or governed), validated: anything else fails the render naming the key. +Usage: include "agent-platform.governance" $root +*/}} +{{- define "agent-platform.governance" -}} +{{- $g := .Values.governance | default dict -}} +{{- if not (kindIs "map" $g) -}} +{{- fail (printf "governance %q: governance is a map mirroring muster's governance configuration, {mode: trusted|governed, roleFloors: {role: [tools]}}: set governance.mode: %v" (toString $g) (toString $g)) -}} +{{- end -}} +{{- range $k, $_ := $g -}} +{{- if not (has $k (list "mode" "roleFloors")) -}} +{{- fail (printf "governance.%s: unknown key (want mode and roleFloors)" $k) -}} +{{- end -}} +{{- end -}} +{{- $mode := toString ($g.mode | default "trusted") -}} +{{- if not (has $mode (list "trusted" "governed")) -}} +{{- fail (printf "governance.mode %q: want trusted or governed (Governing tool calls: trusted lets agents create and start agents freely, governed asks a person first)" $mode) -}} +{{- end -}} +{{- $mode -}} +{{- end -}} + +{{/* +The namespace a component's release installs its workloads (and its muster +MCPServer) into, as components.yaml places it: the kagent namespace with +components..inKagentNamespace, else components..targetNamespace, +else the platform's (agent-platform.targetNamespace). +Usage: include "agent-platform.componentNamespace" (dict "root" $ "name" "model-manager") +*/}} +{{- define "agent-platform.componentNamespace" -}} +{{- $c := index (.root.Values.components | default dict) .name | default dict -}} +{{- if $c.inKagentNamespace -}} +{{- include "agent-platform.kagent.namespace" .root -}} +{{- else -}} +{{- $c.targetNamespace | default (include "agent-platform.targetNamespace" .root) -}} +{{- end -}} +{{- end -}} + +{{/* +muster's key for an MCPServer (muster's api.MCPServerKey): the name for a +server in muster's own namespace (muster.muster.namespace, else the muster +release's), namespace/name for one outside it. +Usage: include "agent-platform.muster.serverKey" (dict "root" $ "namespace" $ns "name" $name) +*/}} +{{- define "agent-platform.muster.serverKey" -}} +{{- $musterNs := dig "muster" "namespace" "" (.root.Values.muster | default dict) | default (include "agent-platform.muster.namespace" .root) -}} +{{- if or (not .namespace) (eq .namespace $musterNs) -}}{{- .name -}}{{- else -}}{{- printf "%s/%s" .namespace .name -}}{{- end -}} +{{- end -}} + +{{/* +The muster server keys of a governedServers source (top-level +governedServers.), as a JSON list: the MCPServers the platform ships +for it while they render. + - the manager components (agent-manager, model-manager, vm-manager, + cluster-manager, workspace-manager, toolchain-manager, skill-manager): + .muster.mcpServer.name (default the component's name) in the + component's namespace, while the component is on; + - kagent: the connectivity chart's MCPServer kagent (kagent's session and + sandbox tools), while the kagent component is on; + - mcp-kubernetes: the connectivity chart's [-]mcp-kubernetes + while the mcp-kubernetes component and mcp-kubernetes.mcpServer.enabled are + on, and every agent-platform-mcps.mcpServers entry of group kubernetes + (its name, else -mcp-kubernetes, in its namespace, else the + component's); + - any other source is a server key itself (an installation's own server). +Usage: include "agent-platform.muster.governedKeys" (dict "root" $ "source" $source) | fromJsonArray +*/}} +{{- define "agent-platform.muster.governedKeys" -}} +{{- $root := .root -}} +{{- $keys := list -}} +{{- $managers := list "agent-manager" "model-manager" "vm-manager" "cluster-manager" "workspace-manager" "toolchain-manager" "skill-manager" -}} +{{- $connNs := dig "agent-platform-connectivity" "targetNamespace" "" ($root.Values.components | default dict) | default (include "agent-platform.targetNamespace" $root) -}} +{{- if has .source $managers -}} +{{- if and (include "agent-platform.componentEnabled" (dict "root" $root "name" .source)) (dig "muster" "mcpServer" "enabled" true (index $root.Values .source | default dict)) -}} +{{- $name := dig "muster" "mcpServer" "name" .source (index $root.Values .source | default dict) -}} +{{- $keys = append $keys (include "agent-platform.muster.serverKey" (dict "root" $root "namespace" (include "agent-platform.componentNamespace" (dict "root" $root "name" .source)) "name" $name)) -}} +{{- end -}} +{{- else if eq .source "kagent" -}} +{{- if include "agent-platform.componentEnabled" (dict "root" $root "name" "kagent") -}} +{{- $keys = append $keys (include "agent-platform.muster.serverKey" (dict "root" $root "namespace" $connNs "name" "kagent")) -}} +{{- end -}} +{{- else if eq .source "mcp-kubernetes" -}} +{{- $mcpk := index $root.Values "mcp-kubernetes" | default dict -}} +{{- if and (include "agent-platform.componentEnabled" (dict "root" $root "name" "mcp-kubernetes")) (dig "mcpServer" "enabled" true $mcpk) -}} +{{- $cluster := dig "mcpServer" "managementCluster" "" $mcpk -}} +{{- $keys = append $keys (include "agent-platform.muster.serverKey" (dict "root" $root "namespace" $connNs "name" (printf "%smcp-kubernetes" (ternary (printf "%s-" $cluster) "" (ne $cluster ""))))) -}} +{{- end -}} +{{- if include "agent-platform.componentEnabled" (dict "root" $root "name" "agent-platform-mcps") -}} +{{- $mcpsNs := include "agent-platform.componentNamespace" (dict "root" $root "name" "agent-platform-mcps") -}} +{{- range (dig "mcpServers" list (index $root.Values "agent-platform-mcps" | default dict)) -}} +{{- if eq (toString .group) "kubernetes" -}} +{{- $name := .name | default (printf "%s-mcp-%s" .cluster .group) -}} +{{- $key := include "agent-platform.muster.serverKey" (dict "root" $root "namespace" (.namespace | default $mcpsNs) "name" $name) -}} +{{- if not (has $key $keys) -}}{{- $keys = append $keys $key -}}{{- end -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- else -}} +{{- $keys = append $keys .source -}} +{{- end -}} +{{- $keys | toJson -}} +{{- end -}} + +{{/* +muster's governance configuration (Governing tool calls), rendered from the +platform's governance mode: `mode` (governance), `roleFloors` +(governance.roleFloors, when it names a role: role -> tool names muster adds to +its built-in floors) and `governedServers`, one entry {server, role, safe} per +MCPServer the platform ships for each source of the top-level governedServers +(agent-platform.muster.governedKeys): its role names the floors muster asks +agents for in both modes, its safe list the tools agents call unasked on +governed (every other tool of a governed server asks agents there, new and +renamed ones too). A source set to null governs nothing (the coverage test, +tests/verify-tool-approval.py, then wants it in governanceExempt). An own +muster.muster.governance.governedServers entry stands for its server key, +first; an own mode that differs from `governance` fails (single source), and +so does an own muster.muster.governance.servers (the earlier shape, which +muster refuses beside governedServers). Only from the muster floor +agent-platform.muster.governanceFloor; {} below it, where `governed` fails the +render rather than silently asking nothing. +Usage: include "agent-platform.muster.governance" $root | fromJson +*/}} +{{- define "agent-platform.muster.governance" -}} +{{- $root := . -}} +{{- $mode := include "agent-platform.governance" . -}} +{{- $out := dict -}} +{{- $floor := include "agent-platform.muster.governanceFloor" . -}} +{{- if include "agent-platform.componentFloorAtLeast" (dict "root" . "name" "muster" "version" $floor) -}} +{{- $own := dig "muster" "governance" dict (.Values.muster | default dict) | default dict -}} +{{- with $own.mode -}} +{{- if ne (toString .) $mode -}} +{{- fail (printf "muster.muster.governance.mode (%v) differs from governance.mode (%s): the platform's governance mode is governance.mode; leave muster.muster.governance.mode unset" . $mode) -}} +{{- end -}} +{{- end -}} +{{- if $own.servers -}} +{{- fail "muster.muster.governance.servers is the earlier governance shape, which muster does not read beside governedServers: name a server's role and safe list in the top-level governedServers (or muster.muster.governance.governedServers entries {server, role, safe})" -}} +{{- end -}} +{{- $servers := list -}} +{{- $seen := list -}} +{{- range ($own.governedServers | default list) -}} +{{- $servers = append $servers . -}} +{{- $seen = append $seen (toString .server) -}} +{{- end -}} +{{- range $source, $entry := (.Values.governedServers | default dict) -}} +{{- if $entry -}} +{{- if not (kindIs "map" $entry) -}} +{{- fail (printf "governedServers.%s: want {role, safe} or null, got %v" $source $entry) -}} +{{- end -}} +{{- range $k, $_ := $entry -}} +{{- if not (has $k (list "role" "safe")) -}} +{{- fail (printf "governedServers.%s.%s: unknown key (want role and safe)" $source $k) -}} +{{- end -}} +{{- end -}} +{{- range (include "agent-platform.muster.governedKeys" (dict "root" $root "source" $source) | fromJsonArray) -}} +{{- if not (has . $seen) -}} +{{- $server := dict "server" . "safe" ($entry.safe | default list) -}} +{{- with $entry.role -}}{{- $_ := set $server "role" . -}}{{- end -}} +{{- $servers = append $servers $server -}} +{{- $seen = append $seen . -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- $out = dict "mode" $mode "governedServers" $servers -}} +{{- $floors := dig "roleFloors" dict (.Values.governance | default dict) | default dict -}} +{{- if not (kindIs "map" $floors) -}} +{{- fail "governance.roleFloors: want a map of role names to lists of tool names" -}} +{{- end -}} +{{- range $role, $tools := $floors -}} +{{- if not (regexMatch "^[a-z][A-Za-z0-9]*$" $role) -}} +{{- fail (printf "governance.roleFloors: role %q: want a camelCase name (e.g. exampleManager)" $role) -}} +{{- end -}} +{{- if not (kindIs "slice" $tools) -}} +{{- fail (printf "governance.roleFloors.%s: want a list of the server's own tool names" $role) -}} +{{- end -}} +{{- range $tools -}} +{{- if not (and (kindIs "string" .) (regexMatch "^[A-Za-z0-9_.-]+$" .)) -}} +{{- fail (printf "governance.roleFloors.%s: %v is not a tool name" $role .) -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- if $floors -}} +{{- with $own.roleFloors -}} +{{- fail "muster.muster.governance.roleFloors and governance.roleFloors are both set: name role floors in governance.roleFloors only" -}} +{{- end -}} +{{- $_ := set $out "roleFloors" $floors -}} +{{- end -}} +{{- else -}} +{{- if dig "roleFloors" nil (.Values.governance | default dict) -}} +{{- fail (printf "governance.roleFloors is set, but this chart renders muster's governance configuration only from the muster release that reads it (agent-platform.muster.governanceFloor%s), so the floors would be dropped and the servers of those roles would not ask: remove governance.roleFloors until then" (ternary ", unset in this chart" (printf " %s, above components.muster.versionRange" $floor) (not $floor))) -}} +{{- end -}} +{{- if dig "muster" "governance" nil (.Values.muster | default dict) -}} +{{- fail "muster.muster.governance is set, but this chart renders muster's governance configuration only from the muster release that reads it (agent-platform.muster.governanceFloor), and none is pinned: a mode passed to muster directly would claim a governed platform that governs nothing. Remove muster.muster.governance; the platform's governance is the governance value (mode, roleFloors)" -}} +{{- end -}} +{{- if ne $mode "trusted" -}} +{{- if not $floor -}} +{{- fail (printf "governance.mode %s: no muster release this chart knows reads the governance configuration yet (agent-platform.muster.governanceFloor is unset until one is released and pinned), so nothing would ask agents; keep governance.mode trusted" $mode) -}} +{{- end -}} +{{- fail (printf "governance.mode %s needs muster %s or later (the first release that reads the governance configuration), but components.muster.versionRange %q allows earlier releases: below it nothing would ask agents. Move components.muster.versionRange to >=%s, or keep governance.mode trusted" $mode $floor (dig "muster" "versionRange" "" .Values.components) $floor) -}} +{{- end -}} +{{- end -}} +{{- $out | toJson -}} +{{- end -}} + +{{/* +muster's approval-binder subjects (muster.rbac.approvalBinder.subjects): the +muster chart ships the Role muster-approval-binder and binds it, in muster's +namespace where muster's sender review asks, to these subjects. The platform +binds agent-manager's ServiceAccount and nothing else, while agent-manager is +on: agent-manager.serviceAccount.name, else agent-manager.fullnameOverride, +in agent-manager's namespace. A ServiceAccount the chart does not create +needs its name (the namespace's `default` would let every pod using it send +approval settings). An own muster.rbac.approvalBinder.subjects stands. Only +from the muster floor agent-platform.muster.governanceFloor; [] below it. +Usage: include "agent-platform.muster.approvalBinderSubjects" $root | fromJsonArray +*/}} +{{- define "agent-platform.muster.approvalBinderSubjects" -}} +{{- $out := list -}} +{{- if and (include "agent-platform.componentFloorAtLeast" (dict "root" . "name" "muster" "version" (include "agent-platform.muster.governanceFloor" .))) (include "agent-platform.componentEnabled" (dict "root" . "name" "agent-manager")) (not (dig "rbac" "approvalBinder" "subjects" list (.Values.muster | default dict))) -}} +{{- $am := index .Values "agent-manager" | default dict -}} +{{- $name := dig "serviceAccount" "name" "" $am -}} +{{- if not (dig "serviceAccount" "create" true $am) -}} +{{- if not $name -}} +{{- fail "agent-manager.serviceAccount.create is false without agent-manager.serviceAccount.name: muster-approval-binder would bind the namespace's default ServiceAccount, so every pod using it could send approval settings; name agent-manager's ServiceAccount" -}} +{{- end -}} +{{- else -}} +{{- $name = $name | default (required "agent-manager.fullnameOverride must be set" (dig "fullnameOverride" "" $am)) -}} +{{- end -}} +{{- $out = list (dict "kind" "ServiceAccount" "name" $name "namespace" (include "agent-platform.componentNamespace" (dict "root" . "name" "agent-manager"))) -}} +{{- end -}} +{{- $out | toJson -}} +{{- end -}} + +{{/* +muster's approval-decider subjects (muster.rbac.approvalDecider.subjects): the +muster chart ships the Role muster-approval-decider (verb decide on +toolapprovals) and binds it, in muster's namespace where muster's workload +review asks, to these subjects. muster takes a trusted client's decision or +handoff request only with that client's own workload token beside the +person's (IA-01 of the inline approval security review). The platform binds +the portal's ServiceAccount (backstage.name, default backstage, in the +portal's namespace) and nothing else, while the portal is on and muster's +approval trusts a client (agent-platform.muster.approval renders +trustedClients) from agent-platform.muster.trustedClientsFloor, the first +muster that reviews the workload. An own muster.rbac.approvalDecider.subjects +stands (a portal deployed as its own release names its ServiceAccount there +and projects the token itself), but every entry must be a ServiceAccount: any +other kind fails the render, since a bound group or user could approve for +any person whose token it holds. [] otherwise. +Usage: include "agent-platform.muster.approvalDeciderSubjects" $root | fromJsonArray +*/}} +{{- define "agent-platform.muster.approvalDeciderSubjects" -}} +{{- range $s := (dig "rbac" "approvalDecider" "subjects" list (.Values.muster | default dict)) -}} +{{- if ne (toString (get ($s | default dict) "kind")) "ServiceAccount" -}} +{{- fail (printf "muster.rbac.approvalDecider.subjects lists a %s (%v): bind only the portal backend's ServiceAccount, the one workload that sends its token beside a person's; a bound group or user could approve for any person whose token it holds" (toString (get ($s | default dict) "kind") | default "subject without a kind") (get ($s | default dict) "name")) -}} +{{- end -}} +{{- end -}} +{{- $out := list -}} +{{- if and (include "agent-platform.componentFloorAtLeast" (dict "root" . "name" "muster" "version" (include "agent-platform.muster.trustedClientsFloor" .))) (include "agent-platform.componentEnabled" (dict "root" . "name" "backstage")) (not (dig "rbac" "approvalDecider" "subjects" list (.Values.muster | default dict))) -}} +{{- with (include "agent-platform.muster.approval" . | fromJson).trustedClients -}} +{{- $name := dig "name" "backstage" ($.Values.backstage | default dict) | default "backstage" -}} +{{- $out = list (dict "kind" "ServiceAccount" "name" $name "namespace" (include "agent-platform.componentNamespace" (dict "root" $ "name" "backstage"))) -}} +{{- end -}} +{{- end -}} +{{- $out | toJson -}} +{{- end -}} + +{{/* +The portal backend's projected ServiceAccount token for muster (audience +muster, an hour, rotated by the kubelet), at the path its muster backend +reads by default (/var/run/secrets/muster.giantswarm.io/serviceaccount/token), +while the platform binds the portal's ServiceAccount to muster-approval-decider +(agent-platform.muster.approvalDeciderSubjects). Emits JSON {volume, mount}, +or {} otherwise. +Usage: include "agent-platform.backstage.musterWorkloadToken" $root | fromJson +*/}} +{{- define "agent-platform.backstage.musterWorkloadToken" -}} +{{- if include "agent-platform.muster.approvalDeciderSubjects" . | fromJsonArray -}} +{{- dict "volume" (dict "name" "muster-workload-token" "projected" (dict "sources" (list (dict "serviceAccountToken" (dict "audience" "muster" "expirationSeconds" 3600 "path" "token"))))) "mount" (dict "name" "muster-workload-token" "mountPath" "/var/run/secrets/muster.giantswarm.io/serviceaccount" "readOnly" true) | toJson -}} +{{- else -}} +{{- dict | toJson -}} +{{- end -}} +{{- end -}} + +{{/* +muster's approval configuration (muster.approval, rendered as `approval` into +config.yaml): installation, the name the approval page shows, from +backstage.installationName (the name the portal shows for this platform, +default agent-platform) unless muster.muster.approval.installation names its +own; any other own key (ttl) is kept. trustedClients, the OAuth clients muster +trusts with a person's approvals (the portal decides them inline in chat with +the person's token, and opens muster's connector sign-in signed in through a +one-time handoff ticket): the portal's own client +(agent-platform.backstage.oidcClient) while the portal is on with a dedicated +client, backstage.signInHandoff is on and muster is at least +agent-platform.muster.trustedClientsFloor, and none below it (an earlier +muster issues handoff tickets without the workload review and the sign-in +confirmation). An own list under either name (handoffClients, the earlier +one) stands from that floor (below it a non-empty one fails the render), and every entry must be the portal's dedicated +client: one naming the platform's shared client (global.identity.clientId, +else muster's login client) fails the render (every holder of such a token, +muster, an agent's delegation, a CLI, could then approve without the page's +own sign-in), and so does any other id (dex-k8s-authenticator, the kagent +UI's or klaus-gateway's client, a CLI's: people hold tokens of those too). Only from the muster floor +agent-platform.muster.governanceFloor; {} below it. +Usage: include "agent-platform.muster.approval" $root | fromJson +*/}} +{{- define "agent-platform.muster.approval" -}} +{{- $out := dict -}} +{{- if include "agent-platform.componentFloorAtLeast" (dict "root" . "name" "muster" "version" (include "agent-platform.muster.governanceFloor" .)) -}} +{{- $own := dig "muster" "approval" dict (.Values.muster | default dict) | default dict -}} +{{- $out = mergeOverwrite (dict "installation" (include "agent-platform.portalInstallationName" .)) $own -}} +{{- $portal := include "agent-platform.backstage.oidcClient" . | fromJson -}} +{{- if and (not (hasKey $own "handoffClients")) (not (hasKey $own "trustedClients")) $portal.dedicated (dig "signInHandoff" true (.Values.backstage | default dict)) (include "agent-platform.componentEnabled" (dict "root" . "name" "backstage")) -}} +{{- if include "agent-platform.componentFloorAtLeast" (dict "root" . "name" "muster" "version" (include "agent-platform.muster.trustedClientsFloor" .)) -}} +{{- $_ := set $out "trustedClients" (list $portal.clientId) -}} +{{- end -}} +{{- end -}} +{{- range $key := list "trustedClients" "handoffClients" -}} +{{- if and (get $out $key | default list) (not (include "agent-platform.componentFloorAtLeast" (dict "root" $ "name" "muster" "version" (include "agent-platform.muster.trustedClientsFloor" $)))) -}} +{{- fail (printf "muster.muster.approval.%s is set, but muster is below agent-platform.muster.trustedClientsFloor (or the floor is unset): an earlier muster issues handoff tickets without the workload review and the sign-in confirmation, so it must trust no client; raise components.muster.versionRange or drop the list" $key) -}} +{{- end -}} +{{- range $client := (get $out $key | default list) -}} +{{- if and $portal.platformClientId (eq (toString $client) $portal.platformClientId) -}} +{{- fail (printf "muster.muster.approval.%s lists %q, the platform's shared OAuth client: every holder of a token of that client (muster itself, agents acting for a person, CLIs) could approve a person's requests without muster's sign-in; list only the portal's own client (backstage.oidcClientId)" $key $portal.platformClientId) -}} +{{- end -}} +{{- if not (and $portal.dedicated (eq (toString $client) $portal.clientId)) -}} +{{- fail (printf "muster.muster.approval.%s lists %q, which is not the portal's own OAuth client (backstage.oidcClientId, set and other than the platform's shared client): muster trusts a listed client with a person's approvals, and people sign in to other clients (dex-k8s-authenticator, the kagent UI, klaus-gateway, CLIs) with tokens of their own; list only the portal's dedicated client" $key (toString $client)) -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- $out | toJson -}} +{{- end -}} + +{{/* +The OAuth client the portal signs people in with: backstage.oidcClientId, else +the platform's shared client (global.identity.clientId). dedicated is true when +the portal's client is set and differs from the platform's client (global +.identity.clientId, else muster's login client); only a dedicated client may +be trusted for sign-in handoff (agent-platform.muster.approval). Emits JSON +{clientId, platformClientId, dedicated}. +Usage: include "agent-platform.backstage.oidcClient" $root | fromJson +*/}} +{{- define "agent-platform.backstage.oidcClient" -}} +{{- $login := include "agent-platform.identity.musterLogin" .Values | fromJson -}} +{{- $platform := toString (dig "identity" "clientId" "" (.Values.global | default dict) | default ($login.clientID | default "")) -}} +{{- $own := toString (dig "oidcClientId" "" (.Values.backstage | default dict) | default "") -}} +{{- dict "clientId" ($own | default $platform) "platformClientId" $platform "dedicated" (and (ne $own "") (ne $own $platform)) | toJson -}} +{{- end -}} + +{{/* +The pages muster may send the browser back to after an approval +(muster.oauth.mcpClient.postLoginRedirectAllowlist; muster compares scheme and +host with its port exactly, and an entry admits its path and everything below +it at a segment boundary): the portal's Sessions pages, +https://[:]/sessions, while the portal is on +and has a host (backstage.hostname, else backstage.; the port +only when backstage.publicPort is set and not 443, as on a lab edge on 8443), +and klaus-gateway's return, /auth/slack/return +(scheme, host and port as written; an http(s) URL with a host, else the +render fails naming the key), while klaus-gateway is on and names its +callbackBaseUrl. An own list's entries stay, first, each entry once. Only +from the muster floor agent-platform.muster.governanceFloor; [] below it. +muster renders the list only while muster.muster.oauth.mcpClient.enabled is +on (NOTES.txt says so when the list is not empty and it is off). +Usage: include "agent-platform.muster.redirectAllowlist" $root | fromJsonArray +*/}} +{{- define "agent-platform.muster.redirectAllowlist" -}} +{{- $out := list -}} +{{- if include "agent-platform.componentFloorAtLeast" (dict "root" . "name" "muster" "version" (include "agent-platform.muster.governanceFloor" .)) -}} +{{- $out = dig "muster" "oauth" "mcpClient" "postLoginRedirectAllowlist" list (.Values.muster | default dict) | default list -}} +{{- $derived := list -}} +{{- $backstage := .Values.backstage | default dict -}} +{{- if include "agent-platform.componentEnabled" (dict "root" . "name" "backstage") -}} +{{- $host := dig "hostname" "" $backstage -}} +{{- if and (not $host) .Values.global.domain -}}{{- $host = printf "backstage.%s" .Values.global.domain -}}{{- end -}} +{{- $port := toString (dig "publicPort" "" $backstage | default "") -}} +{{- if and $port (or (not (regexMatch "^[1-9][0-9]{0,4}$" $port)) (gt (atoi $port) 65535)) -}} +{{- fail (printf "backstage.publicPort %q: want the port the portal's public URL carries (1-65535), or empty for 443" $port) -}} +{{- end -}} +{{- if $host -}}{{- $derived = append $derived (printf "https://%s%s/sessions" $host (ternary (printf ":%s" $port) "" (and (ne $port "") (ne $port "443")))) -}}{{- end -}} +{{- end -}} +{{- if include "agent-platform.componentEnabled" (dict "root" . "name" "klaus-gateway") -}} +{{- $base := dig "obo" "callbackBaseUrl" "" (.Values.klausGateway | default dict) | trimSuffix "/" -}} +{{- if $base -}} +{{- $u := urlParse $base -}} +{{- if or (not (has $u.scheme (list "http" "https"))) (not $u.host) $u.userinfo $u.query $u.fragment -}} +{{- fail (printf "klausGateway.obo.callbackBaseUrl %q: want an http(s) URL with a host (and port, if not the scheme's default), no user, query or fragment, e.g. https://gw.example.com" $base) -}} +{{- end -}} +{{- $derived = append $derived (printf "%s/auth/slack/return" $base) -}} +{{- end -}} +{{- end -}} +{{- range $derived -}}{{- if not (has . $out) -}}{{- $out = append $out . -}}{{- end -}}{{- end -}} +{{- end -}} +{{- $out | toJson -}} +{{- end -}} + {{/* Icons of the shipped presets (infrastructure, agent-platform), for each one muster.muster.toolsetPresets still defines and leaves without an icon, while @@ -5578,6 +6365,36 @@ Usage: include "agent-platform.defaultAgent.derived" $ | fromJson {{- $out | toJson -}} {{- end -}} +{{/* +The default agent as agent-manager's muster.toolApproval.platformAgents entry, +for a remote target (gitops.target.kubeConfig), where agent-manager runs on +the target and cannot read the release on this cluster: the Agent (kagent +namespace, values agent.name else the release name default-agent), the +release its Flux labels name (.release: {namespace, name}) and the approval +values of the release's spec.values — tools, toolset, default and +muster.requireApproval / muster.enabled — taken from the values the release +is rendered with (components.default-agent.valuesFile under +agent-platform.defaultAgent.derived, as components.yaml merges them). +Usage: include "agent-platform.defaultAgent.approval" (dict "root" $ "release" $release) | fromJson +*/}} +{{- define "agent-platform.defaultAgent.approval" -}} +{{- $c := index .root.Values.components "default-agent" -}} +{{- $vals := include "agent-platform.componentValuesFile" (dict "root" .root "path" $c.valuesFile) | fromJson -}} +{{- $vals = mergeOverwrite (deepCopy $vals) (include "agent-platform.defaultAgent.derived" .root | fromJson) -}} +{{- $approval := dict -}} +{{- range $key := list "tools" "toolset" "default" -}} +{{- if hasKey $vals $key -}}{{- $_ := set $approval $key (get $vals $key) -}}{{- end -}} +{{- end -}} +{{- $muster := dict -}} +{{- range $key := list "requireApproval" "enabled" -}} +{{- if hasKey ($vals.muster | default dict) $key -}}{{- $_ := set $muster $key (get $vals.muster $key) -}}{{- end -}} +{{- end -}} +{{- with $muster -}}{{- $_ := set $approval "muster" . -}}{{- end -}} +{{- $out := dict "namespace" (include "agent-platform.kagent.namespace" .root) "name" (dig "agent" "name" "default-agent" $vals) "release" .release -}} +{{- with $approval -}}{{- $_ := set $out "values" . -}}{{- end -}} +{{- $out | toJson -}} +{{- end -}} + {{/* A component's values file (components..valuesFile, a path in this chart), as JSON. The release pipeline stamps the tag's commit over the `[[ .SHA ]]` diff --git a/helm/agent-platform/templates/components.yaml b/helm/agent-platform/templates/components.yaml index 25919a3f..77f60c4f 100644 --- a/helm/agent-platform/templates/components.yaml +++ b/helm/agent-platform/templates/components.yaml @@ -267,6 +267,8 @@ knowledge: {{- include "agent-platform.validateInlineSecrets" . -}} {{- include "agent-platform.validatePinnedLoginConnector" . -}} {{- include "agent-platform.validateToolsetPresets" . -}} +{{- include "agent-platform.validateReleaseFloors" . -}} +{{- include "agent-platform.validateAgentChartLine" . -}} {{- $root := . -}} {{- $g := .Values.gitops -}} {{- /* Flux is the only render engine. Agents are Flux objects on every path diff --git a/helm/agent-platform/values.schema.json b/helm/agent-platform/values.schema.json index 6b1b3f43..3134140a 100644 --- a/helm/agent-platform/values.schema.json +++ b/helm/agent-platform/values.schema.json @@ -2240,6 +2240,188 @@ "type": "object", "additionalProperties": true }, + "governance": { + "type": "object", + "description": "The platform's governance (mode and role floors). `trusted` (default) lets agents run what the connectors' settings allow; `governed` also asks a person before an agent runs any tool of a governed server (governedServers) that is not on its safe list, and any muster tool but its reads. In both modes muster's built-in floors ask before an agent adds or repoints a connector, changes approval settings, grants access, adds a model, egress origin, credential or backend, approves an action or toolchain source, or changes muster's configuration. Rendered as muster.governance from agent-platform.muster.governanceFloor; below it `governed` fails the render. Approval needs muster's OAuth server with Dex sign-in, Valkey storage and muster.muster.oauth.mcpClient.publicUrl (with mcpClient.enabled for the redirect allowlist); without them muster refuses asking calls with the reason. No agent tool changes the mode. A string here (the earlier scalar) fails the render. See https://github.com/giantswarm/agent-platform/blob/main/docs/tool-approval.md", + "additionalProperties": false, + "properties": { + "mode": { + "type": "string", + "description": "trusted (the default) or governed; anything else fails the render.", + "enum": [ + "trusted", + "governed" + ] + }, + "roleFloors": { + "type": "object", + "description": "Floors per governance role (muster.governance.roleFloors): role -> tool names that ask agents in both modes on the governed servers of that role, added to muster's built-in floors. A role named here is valid in governedServers. Example for a server the installation registers: governance: roleFloors: exampleManager: [approve_change, merge_change] governedServers: example-manager: role: exampleManager safe: [get_info, list_changes]", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "governanceExempt": { + "type": "object", + "description": "Shipped MCPServer sources muster deliberately does not govern, each with its reason. Read by the meta chart's tests only.", + "properties": { + "capi": { + "type": "string" + }, + "prometheus": { + "type": "string" + } + }, + "additionalProperties": { + "type": "string" + } + }, + "governedServers": { + "type": "object", + "description": "The servers muster governs (muster.governance.governedServers), per source: `role` (agentManager, connectorManager, sessionManager, modelManager, clusterManager, vmManager, workspaceManager, toolchainManager, skillManager, infrastructure, or a role governance.roleFloors declares) and `safe`, the server's own read tools that agents call unasked on governed (never a floor). Every other tool asks agents on governed. A source renders one entry per MCPServer it ships: a manager component's .muster.mcpServer.name; kagent; mcp-kubernetes (the connectivity chart's and every agent-platform-mcps kubernetes entry); any other key is a muster server key itself. null drops a source (list it in governanceExempt). make verify-tool-approval fails on a shipped MCPServer in neither place, and on a safe entry that names a floor, no tool of its server, or starts with a write verb unless a `# safe-write: : ` comment above `safe:` says why.", + "additionalProperties": true, + "properties": { + "agent-manager": { + "type": "object", + "additionalProperties": false, + "properties": { + "role": { + "type": "string" + }, + "safe": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "cluster-manager": { + "type": "object", + "additionalProperties": false, + "properties": { + "role": { + "type": "string" + }, + "safe": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "kagent": { + "type": "object", + "additionalProperties": false, + "properties": { + "role": { + "type": "string" + }, + "safe": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "mcp-kubernetes": { + "type": "object", + "additionalProperties": false, + "properties": { + "role": { + "type": "string" + }, + "safe": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "model-manager": { + "type": "object", + "additionalProperties": false, + "properties": { + "role": { + "type": "string" + }, + "safe": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "skill-manager": { + "type": "object", + "additionalProperties": false, + "properties": { + "role": { + "type": "string" + }, + "safe": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "toolchain-manager": { + "type": "object", + "additionalProperties": false, + "properties": { + "role": { + "type": "string" + }, + "safe": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "vm-manager": { + "type": "object", + "additionalProperties": false, + "properties": { + "role": { + "type": "string" + }, + "safe": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "workspace-manager": { + "type": "object", + "additionalProperties": false, + "properties": { + "role": { + "type": "string" + }, + "safe": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, "gpu-operator": { "type": "object", "additionalProperties": true @@ -2883,6 +3065,12 @@ "type": "integer" } }, + "musterSessionBindingsNamespace": { + "type": "string" + }, + "musterSessionBindingsPort": { + "type": "integer" + }, "substrate": { "type": "object", "additionalProperties": false, @@ -3487,7 +3675,7 @@ "properties": { "editors": { "type": "array", - "description": "The platform's operators: bound to agent-platform:editor in the kagent namespace. RBAC subjects. The Giant Swarm admin groups, as in muster.rbac.*.subjects.", + "description": "The platform's operators: bound to agent-platform:editor in the kagent namespace. RBAC subjects. The default names two admin groups kept from before tool approval: replace them with the installation's own.", "items": { "type": "object", "required": [ diff --git a/helm/agent-platform/values.yaml b/helm/agent-platform/values.yaml index 2cc11b41..695ea6df 100644 --- a/helm/agent-platform/values.yaml +++ b/helm/agent-platform/values.yaml @@ -435,8 +435,8 @@ components: # @schema additionalProperties: true # token-family session ID still wins and the change is a no-op there. # # v5.1.0 (muster#1079) also FAILS the render on an explicitly emptied - # rbac.mcpServerEditor/workflowEditor.subjects. Both are bound to the - # Giant Swarm admin groups below, so the guard is satisfied. + # rbac.mcpServerEditor/workflowEditor.subjects. Both are bound to + # placeholder groups below, so the guard is satisfied. # # The muster values below define toolsetPresets that select by the # tool-group label (`label:` rules, muster#1168), and a muster before @@ -499,7 +499,10 @@ components: # @schema additionalProperties: true # key for every replica (giantswarm/muster#1929). 5.67.0-rc.15 to rc.18 # refuse more than one replica without encryptionKey (giantswarm/muster#1919), # and an older chart keeps the tokens unencrypted; muster.replicaCount is 2. - versionRange: ">=5.67.0-rc.19 <6.0.0-0" + # Floor 5.67.0-rc.61: tool approval (giantswarm/muster#1912), the release + # the muster floors of this chart name (agent-platform.muster.governanceFloor, + # agentApprovalFloor, sessionBindingsPortFloor, trustedClientsFloor). + versionRange: ">=5.67.0-rc.61 <6.0.0-0" valuesFrom: muster # App-owned CRDs: muster ships its MCPServer/Workflow CRDs in its own chart # crds/ dir and owns their version. CreateReplace makes Flux upgrade them @@ -617,7 +620,9 @@ components: # @schema additionalProperties: true agent-platform-mcps: # @schema additionalProperties: true chart: agent-platform-mcps repository: oci://gsoci.azurecr.io/charts/giantswarm - versionRange: "0.12.x" + # 0.13.0-rc.1 is the floor: its servers carry their tool approval + # (spec.approval), which needs muster's tool approval floor. + versionRange: ">=0.13.0-rc.1 <0.14.0-0" valuesFrom: agent-platform-mcps # It renders the agentgateway data plane's one route to muster (the # hostless HTTPRoute behind the public /mcp, viaMuster), so it follows @@ -1052,7 +1057,9 @@ components: # @schema additionalProperties: true # on (giantswarm/klaus-gateway#616); an earlier gateway sends the # organization namespace, and the first Slack message to an organization's # agent is answered invalid_request. - versionRange: ">=4.18.10 <5.0.0" + # The floor is 4.20.0-rc.8: tool approval, approvals bound to the calling + # client and returned to Slack (giantswarm/giantswarm#38902). + versionRange: ">=4.20.0-rc.8 <5.0.0-0" valuesFrom: klausGateway # klausGateway.observability.enabled is this chart's knob (auto | true | # false, resolved by agent-platform.shape.apply); the klaus-gateway chart's @@ -1132,7 +1139,9 @@ components: # @schema additionalProperties: true # 1.25.0 is the floor: its schema has oauth.authorizationServer and # oauth.resourceServer, the keys agent-platform.identity.apply fills # (giantswarm/model-manager#461). - versionRange: ">=1.25.0 <2.0.0-0" + # 1.26.0-rc.1 is the floor: its MCPServer carries its tool approval + # (spec.approval, giantswarm/giantswarm#38902). + versionRange: ">=1.26.0-rc.1 <2.0.0-0" valuesFrom: model-manager enabled: true # Creates a muster.giantswarm.io/MCPServer CR (CRD owned by the muster app) @@ -1234,7 +1243,10 @@ components: # @schema additionalProperties: true # policies and skills are written for, and its schema has # oauth.authorizationServer and oauth.resourceServer, the keys # agent-platform.identity.apply fills. The ceiling is the next major. - versionRange: ">=4.0.0 <5.0.0" + # 4.1.0-rc.1 is the floor: per-agent tool approval and the migrate hop + # to agent chart 3.x (agent-platform.agentManager.toolApprovalFloor, + # agentChartV3Floor; giantswarm/giantswarm#38902). + versionRange: ">=4.1.0-rc.1 <5.0.0-0" valuesFrom: agent-manager # harness.egress travels only when set: the key is new in agent-manager # 1.11.0, and an older chart's closed harness block refuses it; unset, the @@ -1263,7 +1275,9 @@ components: # @schema additionalProperties: true # without it. The ceiling is the next minor: a skill-manager minor rolls # in with the chart release that renders its values. # mcp-oauth v1.15.0 permits private issuer JWKS without a blanket allowance. - versionRange: ">=0.4.0-rc.1 <0.5.0-0" + # 0.5.0-rc.1 is the floor: its MCPServer carries its tool approval + # (spec.approval, giantswarm/giantswarm#38902). + versionRange: ">=0.5.0-rc.1 <0.6.0-0" valuesFrom: skill-manager # Creates a muster.giantswarm.io/MCPServer CR (CRD owned by the muster # app); the reference is dropped at render time when muster is off. @@ -1282,7 +1296,8 @@ components: # @schema additionalProperties: true chart: agent repository: oci://gsoci.azurecr.io/charts/giantswarm # The agent chart line, moved with agent-manager.agentChart.semver - # (make verify-default-agent). The floor is 2.6.0, whose empty + # (make verify-default-agent; another major fails the render, + # agent-platform.validateAgentChartLine). The floor is 2.6.0, whose empty # modelConfig.name renders no model (giantswarm/agent#130). versionRange: ">=2.6.0 <3.0.0" valuesFile: agents/default-agent/values.yaml @@ -1335,7 +1350,9 @@ components: # @schema additionalProperties: true # writes the image certificate the artifact carries into each VM's UEFI db, # and create_vm's layer_certificates and cni_version are optional # (giantswarm/vm-manager#266, #286). The chart's values are those of 0.27. - versionRange: ">=0.29.0 <0.30.0" + # 0.30.0-rc.2 is the floor: its MCPServer carries its tool approval + # (spec.approval, giantswarm/giantswarm#38902). + versionRange: ">=0.30.0-rc.2 <0.31.0-0" valuesFrom: vm-manager enabled: false # Creates a muster.giantswarm.io/MCPServer CR (CRD owned by the muster @@ -1376,7 +1393,9 @@ components: # @schema additionalProperties: true # chart follows (UNCAPPED in tests/verify-range-ceilings.py). # 0.40.0-rc.1 is the floor: its schema has oauth.authorizationServer and # oauth.resourceServer, the keys agent-platform.identity.apply fills. - versionRange: ">=0.40.0-rc.1" + # 0.40.0-rc.3 is the floor: its MCPServer carries its tool approval + # (spec.approval, giantswarm/giantswarm#38902). + versionRange: ">=0.40.0-rc.3" valuesFrom: cluster-manager enabled: false # Creates a muster.giantswarm.io/MCPServer CR (CRD owned by the muster app); @@ -1424,7 +1443,9 @@ components: # @schema additionalProperties: true # minor: a workspace-manager minor rolls in with the chart release that # renders its values. # mcp-oauth v1.15.0 permits private issuer JWKS without a blanket allowance. - versionRange: ">=0.16.0-rc.1 <0.17.0-0" + # 0.17.0-rc.1 is the floor: its MCPServer carries its tool approval + # (spec.approval, giantswarm/giantswarm#38902). + versionRange: ">=0.17.0-rc.1 <0.18.0-0" valuesFrom: workspace-manager # Creates a muster.giantswarm.io/MCPServer CR (CRD owned by the muster app); # the reference is dropped at render time when the component is off. With @@ -1460,7 +1481,9 @@ components: # @schema additionalProperties: true # lists the manager's ServiceAccount in its allowedCallers). The ceiling is # the next minor: a toolchain-manager minor rolls in with the chart release # that renders its values. - versionRange: ">=0.5.0 <0.6.0" + # 0.6.0-rc.16 is the floor: its MCPServer carries its tool approval + # (spec.approval, giantswarm/giantswarm#38902). + versionRange: ">=0.6.0-rc.16 <0.7.0-0" valuesFrom: toolchain-manager enabled: false # Creates a muster.giantswarm.io/MCPServer CR (CRD owned by the muster app); @@ -1527,7 +1550,10 @@ components: # @schema additionalProperties: true # AgentPlatformOrganizations, whose namespaces and Kustomizations these # policies refuse. Its chart ships no crds/ dir: the Organization CRD is # organization-operator's, or agentPlatformOrganizations.organizationCRD's. - versionRange: ">=0.5.0 <0.6.0" + # 0.6.0-rc.1 is the floor: it moves an organization's chart source to a + # higher major only once migrate's ready mark names every release on it + # (ChartSourceHeld otherwise), which the agent chart 3.x cut-over needs. + versionRange: ">=0.6.0-rc.1 <0.7.0-0" valuesFrom: agent-platform-operator # The connectivity release first: the admission policies that hold the # operator, its kagent machine-caller binding, its network policies, and @@ -1582,6 +1608,7 @@ components: # @schema additionalProperties: true # top-level block and are dropped on the way out, the kagent shape. omitKeys: - hostname + - publicPort - parentRefs - installationName - extraScopes @@ -1592,6 +1619,8 @@ components: # @schema additionalProperties: true - skillPullRequests - metaAgents - configReload + - oidcClientId + - signInHandoff enabled: false # Renders a CNPG Cluster for its database when backstage.database.engine is # postgresql (the chart's default is sqlite); dropped at render time while @@ -1876,6 +1905,14 @@ components: # @schema additionalProperties: true # The flux-engine subchart's values are the engine's, not wiring: never # forwarded (Helm coalesces the subchart's defaults into this block). - flux-engine + # The governance mode is read by the meta chart alone: it reaches muster + # as its governance configuration (agent-platform.muster.governance); + # no wiring of the connectivity chart reads it. + - governance + # The governed servers and the exempt list are the meta chart's too + # (muster.governance.governedServers and its coverage test). + - governedServers + - governanceExempt - credential-api # Read by the meta chart alone (merged into the four components' own # scheduling knobs before their releases render, agent-platform.scheduling.apply); @@ -2600,6 +2637,14 @@ networkPolicy: musterInClusterMcpPorts: - 8080 - 8443 + # Port of muster's session bindings API (agent-manager only); set from + # muster's floor. 0 opens no egress for it: agent-manager binds on muster's + # aggregator port. + musterSessionBindingsPort: 0 + # Namespace muster runs in, for that egress rule; set by the meta chart from + # muster's namespace (components.muster.targetNamespace). Empty selects the + # release's own namespace. + musterSessionBindingsNamespace: "" # In-cluster MCP backends an installation registers with muster (its own # MCPServer entries, e.g. through agent-platform-mcps). A ClusterIP Service # without a policy admits every pod on the cluster, and a direct call skips @@ -2790,32 +2835,27 @@ muster: # @schema skipProperties: true; additionalProperties: true # with the crds/-dir copy. Stays as a guard regardless of the muster version below. crds: install: false - # Who may register MCPServers and author Workflows through muster's - # writes-as-caller path. The muster sub-chart defaults both editor - # RoleBindings to system:authenticated (single-team fit); on a shared - # platform MC every registered server and authored workflow is visible to - # and routed through by other users, so the umbrella narrows both bindings - # explicitly to the Giant Swarm admin groups (the same groups the config - # default layer feeds rbac-operator as oidc.giantswarm.write_all_group/ - # _groups). Installations wanting customer self-service widen subjects via - # their gitops values. + # Who may register MCPServers and author Workflows (muster's writes-as-caller + # path). The defaults bind no person: a ServiceAccount nobody can + # authenticate as, so only cluster admins register servers, author workflows + # or change tool approval (fail closed). Set the installation's admin groups + # as the API server sees them (with the OIDC groups prefix); tenants.platformTeam + # is appended to both; an empty list fails muster's render. + # mcpServerEditor is the connector-admin role: its holders edit connectors, + # set their tool approval and alone may let an agent skip an Ask. Binding + # system:authenticated makes everyone a connector admin. See + # https://github.com/giantswarm/agent-platform/blob/main/docs/tool-approval.md rbac: mcpServerEditor: subjects: - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-ad:giantswarm-admins - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-github:giantswarm:giantswarm-admins + - kind: ServiceAccount + name: agent-platform-unset-connector-admins + namespace: kube-system workflowEditor: subjects: - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-ad:giantswarm-admins - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-github:giantswarm:giantswarm-admins + - kind: ServiceAccount + name: agent-platform-unset-workflow-editors + namespace: kube-system # Muster's NetworkPolicy mirrors the umbrella's flavor split (`cilium` vs # `kubernetes`). `auto` (the default) is replaced by the resolved top-level # `networkPolicy.flavor` before the block is forwarded, so muster and the @@ -4151,6 +4191,30 @@ kagent: # @schema skipProperties: true; additionalProperties: true # The line the Dev Portal shows under the server's name (the MCPServer's # spec.description, at most 500 characters); empty renders none. description: "Your agent sessions on this installation, as the signed-in person: list them, send one a message, and checkpoint or fork them" + # The connector's tool approval (spec.approval): the Allow all preset, + # the connectivity chart's (kagent.controllerRoute.mcp.approval there). + # Set it here to tighten a tool (Ask or Block). + approval: + rule: Allow + tools: + list_sessions: Allow + invoke_session: Allow + create_session_checkpoint: Allow + list_session_checkpoints: Allow + fork_session: Allow + list_sandbox_templates: Allow + create_sandbox: Allow + list_sandboxes: Allow + get_sandbox: Allow + suspend_sandbox: Allow + resume_sandbox: Allow + delete_sandbox: Allow + start_sandbox_process: Allow + get_sandbox_process: Allow + kill_sandbox_process: Allow + read_sandbox_outputs: Allow + read_sandbox_file: Allow + write_sandbox_file: Allow # The first of the controller's two authentication layers, on by default # (docs/authentication.md, "The kagent controller route"). Renders an # AgentgatewayPolicy on the GRPCRoute (plus a static AgentgatewayBackend for @@ -5509,7 +5573,14 @@ agent-manager: # @schema skipProperties: true; additionalProperties: true # the v1alpha2 Agent of kagent 0.10. A range, so patch and minor releases # of the line reach the agents on their own; the major is the API boundary # and moves only with this chart. The floor moves with components.kagent - # and components.default-agent.versionRange. + # and components.default-agent.versionRange. The same range drives + # agent-manager's migrate run and the agent-platform-operator. 3.x renders + # only with agent-manager and muster at their floors + # (agent-platform.agentManager.agentChartV3Floor, + # agent-platform.muster.agentApprovalFloor), agent-manager's tool approval on + # and the default agent's range on 3.x, moved together + # (make verify-agent-chart-line). Both floors are unset until those releases + # exist, so every 3.x range is refused for now (UPGRADE.md). semver: ">=2.6.0 <3.0.0" # Deprecated: set skillManager.sources. Read only while agent-manager does # not pin through the skill-manager (components.skill-manager off, or @@ -5676,6 +5747,8 @@ agentManager: # @schema skipProperties: true; additionalProperties: true repository: giantswarm/agent-manager tag: 3.5.11 dryRun: false + # preflightSemver and cutover (unset): forwarded when set; documented in + # the connectivity chart's values.yaml and UPGRADE.md. gitopsNamespaces: [] # === Skill repositories === @@ -5949,6 +6022,92 @@ clusterManager: # @schema skipProperties: true; additionalProperties: true # sessions.api.kagent.dev cluster-wide (the ClusterRole # agent-platform:workspace-manager-sessions): the manager lists every creator's # Sessions for the session directories' cleanup, which no tenant role grants. +# === Governance mode (Governing tool calls) === +# -- The platform's governance (mode and role floors). `trusted` (default) lets +# agents run what the connectors' settings allow; `governed` also asks a person +# before an agent runs any tool of a governed server (governedServers) that is +# not on its safe list, and any muster tool but its reads. In both modes +# muster's built-in floors ask before an agent adds or repoints a connector, +# changes approval settings, grants access, adds a model, egress origin, +# credential or backend, approves an action or toolchain source, or changes +# muster's configuration. Rendered as muster.governance from +# agent-platform.muster.governanceFloor; below it `governed` fails the render. +# Approval needs muster's OAuth server with Dex sign-in, Valkey storage and +# muster.muster.oauth.mcpClient.publicUrl (with mcpClient.enabled for the +# redirect allowlist); without them muster refuses asking calls with the reason. +# No agent tool changes the mode. A string here (the earlier scalar) fails the +# render. See https://github.com/giantswarm/agent-platform/blob/main/docs/tool-approval.md +governance: # @schema additionalProperties: false + # -- trusted (the default) or governed; anything else fails the render. + mode: trusted # @schema enum: [trusted, governed] + # -- Floors per governance role (muster.governance.roleFloors): role -> tool + # names that ask agents in both modes on the governed servers of that role, + # added to muster's built-in floors. A role named here is valid in + # governedServers. Example for a server the installation registers: + # governance: + # roleFloors: + # exampleManager: [approve_change, merge_change] + # governedServers: + # example-manager: + # role: exampleManager + # safe: [get_info, list_changes] + roleFloors: {} # @schema additionalProperties: {type: array, items: {type: string}} + +# -- The servers muster governs (muster.governance.governedServers), per source: +# `role` (agentManager, connectorManager, sessionManager, modelManager, +# clusterManager, vmManager, workspaceManager, toolchainManager, skillManager, +# infrastructure, or a role governance.roleFloors declares) and `safe`, the +# server's own read tools that agents call unasked on governed (never a floor). +# Every other tool asks agents on governed. A source renders one entry per +# MCPServer it ships: a manager component's .muster.mcpServer.name; +# kagent; mcp-kubernetes (the connectivity chart's and every agent-platform-mcps +# kubernetes entry); any other key is a muster server key itself. null drops a +# source (list it in governanceExempt). make verify-tool-approval fails on a +# shipped MCPServer in neither place, and on a safe entry that names a floor, +# no tool of its server, or starts with a write verb unless a +# `# safe-write: : ` comment above `safe:` says why. +governedServers: # @schema additionalProperties: true + agent-manager: + role: agentManager + safe: [get_info, list_agents, get_agent, get_agent_status, validate_agent, list_model_configs, list_egress_policies, list_skills, list_sessions, get_session, get_session_turn, toolchain_users, list_organizations, get_organization, list_organization_members, list_organization_connectors] + kagent: + role: sessionManager + safe: [list_sessions, list_session_checkpoints, list_sandbox_templates, list_sandboxes, get_sandbox, get_sandbox_process, read_sandbox_outputs, read_sandbox_file] + model-manager: + role: modelManager + safe: [get_info, get_backend, list_backends, list_models, get_model, list_loaded_models, list_presets, search_models, check_fit, list_nodes, list_jobs, get_job] + cluster-manager: + role: clusterManager + safe: [get_info, list_clusters, list_releases, list_node_pools] + vm-manager: + role: vmManager + # get_vm_console is left off: a console can carry secrets. + safe: [get_info, get_host, list_images, get_image, list_networks, get_network, list_vms, get_vm, get_vm_metrics, get_vm_attestation] + toolchain-manager: + role: toolchainManager + # add_packages, add_binary and init_source write nothing but render files + # an agent could feed elsewhere: they ask until their asks prove noisy. + safe: [list_sources, list_toolchains, describe_toolchain, toolchain_build_status, search_packages] + workspace-manager: + role: workspaceManager + # authorize_workspace returns a repository grant for start_session. + safe: [list_providers, list_owners, list_workspaces, get_workspace, list_repositories, preview_workspace] + skill-manager: + role: skillManager + safe: [list_skill_sources, list_skills, resolve_skills, get_skill, get_skill_file] + mcp-kubernetes: + role: infrastructure + # The write tools (create, apply, delete, patch, scale, exec, + # port_forward, context_use, the stop tools) and the deprecated + # kubernetes_* aliases ask agents on governed. + safe: [logs, list_port_forward_sessions, context_list, context_get_current, can_i, api_resources, cluster_health, capi_list_clusters, capi_get_cluster, capi_resolve_cluster, capi_cluster_health, get, list, describe] + +# -- Shipped MCPServer sources muster deliberately does not govern, each with its +# reason. Read by the meta chart's tests only. +governanceExempt: # @schema additionalProperties: {type: string} + prometheus: "agent-platform-mcps' prometheus family (mcp-prometheus): every tool reads" + capi: "agent-platform-mcps' capi family (mcp-kubernetes' CAPI tools): every tool reads" + tenants: platform: # -- Every signed-in person: bound to agent-platform:platform-user in the @@ -5966,8 +6125,8 @@ tenants: kind: Group name: system:authenticated # -- The platform's operators: bound to agent-platform:editor in the - # kagent namespace. RBAC subjects. The Giant Swarm admin groups, as in - # muster.rbac.*.subjects. + # kagent namespace. RBAC subjects. The default names two admin groups kept + # from before tool approval: replace them with the installation's own. editors: # @schema item: object; itemRequired: [kind, name]; itemProperties: {"apiGroup": {"type": "string"}, "kind": {"type": "string"}, "name": {"type": "string"}, "namespace": {"type": "string"}} - apiGroup: rbac.authorization.k8s.io kind: Group @@ -6917,6 +7076,10 @@ backstage: # @schema skipProperties: true; additionalProperties: true # --- Wiring (read by the connectivity chart, not passed to the backstage chart) --- # Public hostname; empty derives backstage.. hostname: "" + # publicPort: the port of the portal's public URL when it is not 443 (a lab + # edge on 8443); read by the meta chart alone, for the portal's entry in + # muster's redirect allowlist. Unset or 443 writes none. + # publicPort: 8443 # Gateway of the Backstage route; empty follows the platform default (the # chart-owned edge, else global.gatewayApi.parentRefs). parentRefs: [] @@ -6931,6 +7094,30 @@ backstage: # @schema skipProperties: true; additionalProperties: true extraScopes: - federated:id - audience:server:client_id:dex-k8s-authenticator + # The portal's own OAuth client at the identity provider. Empty (default) + # signs in with the platform's shared client (global.identity.clientId). Set, + # its secret is the key portal-dex-client-secret of + # global.identity.existingSecret, the provider registers only the portal's + # redirect URI (https:///api/auth/oidc-agent-platform/handler/frame) + # for it, and audience:server:client_id: is added to + # extraScopes so tokens keep the platform client's audience. On Dex, the + # platform client and every client whose audience extraScopes request list + # this client under trustedPeers. Sessions are keyed by client too: a person's + # connector sign-ins made through the shared client are not the portal's + # (subject-scoped ones are). + oidcClientId: "" + # With a dedicated oidcClientId, the chart lists it in + # muster.approval.trustedClients: the portal then shows a tool approval in + # chat and decides it on the person's click, and opens muster's connector + # sign-in through a one-time ticket. muster accepts the person's portal token + # there only together with the portal backend's own ServiceAccount token + # (audience muster; the chart projects it and binds the ServiceAccount to + # muster-approval-decider). Trade-off: the portal backend can approve a + # person's pending requests without muster's browser sign-in, on the person's + # click only. false keeps every decision on muster's own pages. Without a + # dedicated client nothing is listed; an own muster.muster.approval.trustedClients + # may name this client only. + signInHandoff: true # Extra query parameters on the login provider's authorize request. Dex needs # none; Google needs access_type: offline and prompt: consent for a refresh # token. @@ -6998,6 +7185,14 @@ backstage: # @schema skipProperties: true; additionalProperties: true secretKeyRef: name: "{{ .Values.global.identity.existingSecret }}" key: dex-client-secret + # The portal's own client secret, read while backstage.oidcClientId + # names a dedicated client (optional: absent otherwise). + - name: AGENT_PLATFORM_PORTAL_OIDC_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: "{{ .Values.global.identity.existingSecret }}" + key: portal-dex-client-secret + optional: true - name: NODE_EXTRA_CA_CERTS value: "{{ with (dig \"identity\" \"ca\" \"secretName\" \"\" .Values.global) }}/etc/agent-platform/idp-ca/{{ dig \"identity\" \"ca\" \"key\" \"ca.crt\" $.Values.global }}{{ end }}" extraVolumes: diff --git a/skills/agent-platform-agent-management/SKILL.md b/skills/agent-platform-agent-management/SKILL.md index 587c1841..3641d540 100644 --- a/skills/agent-platform-agent-management/SKILL.md +++ b/skills/agent-platform-agent-management/SKILL.md @@ -1,6 +1,6 @@ --- name: agent-platform-agent-management -description: Use when asked to create, change, inspect, troubleshoot, re-pin or delete an agent on the Agent Platform, to choose its model, skills, toolset or egress, or to read or evaluate one of its sessions. +description: Use when asked to create, change, inspect, troubleshoot, re-pin or delete an agent on the Agent Platform, to choose its model, skills, toolset (its tool list and Allow/Ask/Block settings) or egress, or to read or evaluate one of its sessions. metadata: version: "3.4.1" --- @@ -98,7 +98,10 @@ never assume an argument. The agent tools drop an unknown key without an error: status about every 30 s for up to about five minutes; still `progressing`, tell the person its summary and call it again at the start of your next turn. 3. `x_agent-manager_update_agent` for follow-ups: only the fields passed change; `skills`, `plugins`, - `egress` and `toolset` replace their whole list. `refreshSkills: true` re-pins every git skill and + `egress` and `toolset` replace their whole list. Where `x_agent-manager_update_agent_access` + exists, `update_agent` takes only name, description, prompt, model, tags, icon, labels and + annotations; the tool list, skills, plugins, egress, connectors, Harness and toolchains go to + `update_agent_access`, and settings to `set_agent_approval`. `refreshSkills: true` re-pins every git skill and plugin to the head of its ref, as you: it fails when you cannot read one of the agent's repositories. @@ -137,12 +140,42 @@ stored credentials; do not replace it to repair a retry. See - **Toolset**: the smallest that does the job; `preset:none` for chat only; the broadest preset only on an explicit request. An own-account (OAuth) connector without `grantScope: subject` needs a sign-in in each of the agent's conversations (`agent-platform-tools`); say so before choosing it. +- **Tool approval** (further reading, optional: https://github.com/giantswarm/agent-platform/blob/main/docs/tool-approval.md): + today a toolset only selects tools; their Allow/Ask/Block settings are the connectors' + (`agent-platform-tools`). On a **governed** platform every agent-manager tool that is not a read + asks the person when an agent calls it; on a trusted one (the default) they run, except the floors + that ask in both modes (`set_organization_connector`, `add_organization_member`, + `set_organization_model`, `set_organization_egress_policy`, `replace_organization_credential`). + Check the `filter_tools` `approval` of the tool before you promise an outcome. + **Only once agent-manager ships per-agent tool lists** (`create_agent`'s schema has `tools`; + `update_agent_access` and `set_agent_approval` exist; `describe_tool` them first): the toolset + becomes the agent's **tool list**, the same selectors each optionally `Allow`, `Ask` or `Block`, + plus a `default`; at most 32 entries, an unlisted tool invisible. + - An agent's settings only tighten its connectors' (the strictest wins). `Allow` over a + connector's `Ask` is an **exception** only a connector admin of that connector grants, through + `set_agent_approval` (it asks the person whenever an agent calls it); a save drops the + exceptions the saver may not grant, so say so before saving. `create_agent` and + `update_agent_access` refuse such an `Allow` and any `default: Allow`. + - `set_agent_approval` takes `settings` (`{"": "Allow"|"Ask"|"Block"|""}` for entries + already in `tools`) and `default`. `get_agent`/`list_agents` return the list as `toolSettings` + (`tools` stays the kagent MCP bindings), plus `defaultApproval`, `grants` (`grantedBy`) and + `approvalSettings` (false: this installation refuses settings). `list_approval_grants` lists a + namespace's grants; `filter_tools` with `agentTools` shows how a list resolves before you save. + - `sessionsUpdated: false` or `warnings` on a save mean running sessions still carry a dropped + exception until agent-manager tells muster again: say so. A governed platform's asks cannot be + lifted per agent; to make an agent ask before every call, set `default: Ask`. + - Agent chart 3.0 removes `muster.requireApproval`: agent-manager's migrate rewrites `true` to + `default: Ask` in the releases it owns and reports the others (GitOps, `valuesFrom`); check its + report. An organization stays on chart 2.x (`Ready=False`, `ChartSourceHeld`) until every + release there is on 3.x values and migrate ran again. The fix is replacing the key with + `default: Ask`, never deleting it; never write the key. - **An organization's connectors**: a kagent `RemoteMCPServer` in the organization namespace (`x_agent-manager_set_organization_connector`), not a Muster server, so no `toolset` selector reaches it. From agent-manager 3.3.0 (`connectors` in `x_agent-manager_create_agent`'s schema; without it the agent takes none), pass the names of the connectors that `x_agent-manager_list_organization_connectors` gives as `connectors` to `create_agent`, - `validate_agent` or `update_agent`: each name alone, once. On update the list replaces the + `validate_agent` or `update_agent_access` (`update_agent` before agent-manager split its update + tools): each name alone, once. On update the list replaces the agent's connectors, `[]` removes them, and an absent argument keeps them; `get_agent` and `list_agents` return them. The agent calls the connector itself with the connector's credential; its host needs no `EgressPolicy`. A connector that does not point at Muster, or that sends a @@ -153,7 +186,7 @@ stored credentials; do not replace it to repair a retry. See workload cluster, and an agent's binding to Muster: the `RemoteMCPServer` that one HelmRelease renders with an agent of its name, which the list marks `musterBindingOf` from agent-manager 3.3.4 (how to tell it without the field: `agent-platform-tools`). From agent-manager 3.3.4, - `update_agent` and `validate_agent` refuse `connectors`, `[]` too, on an agent whose HelmRelease + the update tool and `validate_agent` refuse `connectors`, `[]` too, on an agent whose HelmRelease has `spec.valuesFrom` (the message names it): tell the person that this agent's connectors are set where its `valuesFrom` values are managed, not through the tool. - **Toolchains and workspace**: `defaultToolchains` and `defaultWorkspace`, the smallest set the job diff --git a/skills/agent-platform-building-blocks/SKILL.md b/skills/agent-platform-building-blocks/SKILL.md index 5ba3af48..4ed72ce5 100644 --- a/skills/agent-platform-building-blocks/SKILL.md +++ b/skills/agent-platform-building-blocks/SKILL.md @@ -2,7 +2,7 @@ name: agent-platform-building-blocks description: Use when someone new asks what connectors, toolsets, toolchains or workspaces are, how they differ, or which one they need — or when a person's goal needs one they have not set up, so you can suggest it before the mechanics. metadata: - version: "1.0.0" + version: "1.1.0" --- # Connectors, toolsets, toolchains, workspaces @@ -27,6 +27,11 @@ gateway. Every call runs as the person: what they may do in the service is what the agent may do there. Some connectors ask the person to sign in once with their own account; until then their tools are hidden for that person. +Each tool of a connector is **Allow** (runs), **Ask** (a person confirms the call first) or +**Block** (hidden); a connector's rule covers tools nobody has set yet, and the strictest setting +wins. A governed platform also asks before an agent changes anything through the platform's own +connectors (https://github.com/giantswarm/agent-platform/blob/main/docs/tool-approval.md). + **Suggest one** when the goal needs a system no connector reaches yet ("read our Jira tickets"): someone registers it with **Add connector**. A connector that exists but whose tools are missing for this person usually needs their sign-in. diff --git a/skills/agent-platform-tools/SKILL.md b/skills/agent-platform-tools/SKILL.md index 5bd5b904..136a83a0 100644 --- a/skills/agent-platform-tools/SKILL.md +++ b/skills/agent-platform-tools/SKILL.md @@ -1,8 +1,8 @@ --- name: agent-platform-tools -description: Use when a question is about tools on the Agent Platform — Muster's meta-tools and call_tool, finding or running a tool, what a toolset or preset resolves to, why a tool is missing or refused, connectors and signing in to one, workflows, or model-manager. +description: Use when a question is about tools on the Agent Platform — Muster's meta-tools and call_tool, finding or running a tool, what a toolset or preset resolves to, why a tool is missing, refused or asks for approval, a connector's Allow/Ask/Block settings and presets, connectors and signing in to one, workflows, or model-manager. metadata: - version: "3.4.0" + version: "3.5.0" --- # Tools on the Agent Platform @@ -145,6 +145,52 @@ Tools register live when a server connects. Adding connectors: https://docs.giantswarm.io/tutorials/agent-platform/managing-mcp-servers/ and https://docs.giantswarm.io/tutorials/agent-platform/connecting-custom-mcp-servers/. +## Tool approval: Allow, Ask, Block + +Further reading (optional): https://github.com/giantswarm/agent-platform/blob/main/docs/tool-approval.md. +Muster decides every call by its tool's setting, whoever calls (an agent, the portal, Slack, Claude Code): + +- **Allow** runs. **Ask**: a person confirms the exact call first (inline in portal chat, or on Muster's + approval page); the call then runs once. An agent cannot decide its own request, and no token you + hold decides one. **Block**: hidden, absent from `filter_tools`, refused as not found. +- A connector carries `spec.approval`: a `rule` for every tool without its own entry (**new tools + follow it**, so `Block` hides every unreviewed tool) and per-tool entries by the server's own tool + name (no `x__` prefix). Without `approval` it runs everything and is shown as *not + reviewed*. An agent's settings can only tighten them (the strictest wins). +- `filter_tools` and `describe_tool` report each tool's `approval` for **you**: `setting`; `source` + (`tool`, `connector`, `unreviewed`, `builtin`, `governance`, `unavailable`, and with agent tool + lists `agent`, `agent-exception`); `new` for a tool without its own entry; `unavailable` with the + reason when asking calls are refused here. `connectorAdmin` says whether you may change the + connector's settings; the result's `governance` field says `trusted` or `governed`. +- **Presets** fill in every tool once, on save, from the tools listed then: *Recommended* (rule Ask, + read-only tools Allow, the rest Ask), *Allow all*, *Ask all*. `core_mcpserver_create` requires + `preset` or explicit `approval`; `core_mcpserver_set_approval` changes them (pass `generation` from + `core_mcpserver_get` as `expectedGeneration`; a conflict means read again). Only a connector admin + (whoever may update `mcpservers` in its namespace, the `connector-admin` role) may write them, and + an agent writing them always asks a person. The portal wizard pre-selects *Allow all* on a trusted + platform, *Recommended* on a governed one. The platform's management servers arrive on *Allow all*, + its infrastructure servers (Kubernetes, Prometheus, Cluster API) on *Recommended*. +- **When a call asks**, you get an approval link (or an `approval_required` text with the URL). Give + the person the link as is, wait, then call the tool again with the same arguments **as the same + client** (any MCP session of it): approved, it runs once; declined, accept it and never retry + another way. Another client of the person asks anew. A workflow asks once, up front, for all its + steps. At most 3 calls of one client (10 of one person) wait at a time. Never press *Approve* + yourself or ask the person to approve something you did not show them; with no person to open the + link the call expires and is refused. +- **Built in, every mode** (agents only): asked before adding or repointing a connector, changing + approval settings, creating, changing or deleting a workflow, granting or changing access + (organization members, connectors, models, egress, credentials), adding a model backend, + approving an action or a toolchain source, or changing Muster's configuration (that one asks every + caller). A **governed** platform also asks an agent before every tool of the platform's own servers + that is not a read on their safe list, new tools too, and before Muster's own non-read tools. A + **trusted** one (the default) leaves those to the connectors' settings. A person is only ever + asked by the connectors' settings. +- Missing prerequisites (Muster's Valkey store, its OAuth server with browser sign-in, a public URL + on that server's origin) make every asking call refused with the reason, reported as + `approval.unavailable`; tell the person, it is the installation's to fix. So does an MCPServer CRD + without `spec.approval` (every server tool refused until upgraded). Without a redirect allowlist + entry the person returns to the portal or Slack by hand. + ## Workflows A `Workflow` resource is a list of tool calls Muster runs server-side, returning one shaped answer; it @@ -234,6 +280,8 @@ clients. Procedure and version prerequisites: grant backend permissions. A successful agent-manager read with `releaseWithheld` is a partial answer, not an error: use the readable Agent data and explain which release details are unavailable. Do not send an authenticated person through sign-in again or blame them for this platform limit. +- `approval_required`, or an approval link instead of a result: the tool's setting is Ask (above). A + tool that `filter_tools` no longer lists may be blocked for you: its connector's admins decide. - "tool `x_…` not found" from the runtime: a backend tool was emitted as a function — go through `call_tool`. - An issuer discovery or TLS error is installation connectivity, not a request for the person to diff --git a/tests/golden/meta-ci-engine-off.yaml b/tests/golden/meta-ci-engine-off.yaml index dce1c7ea..055a8139 100644 --- a/tests/golden/meta-ci-engine-off.yaml +++ b/tests/golden/meta-ci-engine-off.yaml @@ -77,12 +77,21 @@ spec: enabled: true muster: actorBearer: true + bindingsUrl: http://muster.default.svc.cluster.local:8091/session-bindings mcpServer: auth: forwardToken: true requiredAudiences: - dex-k8s-authenticator enabled: true + toolApproval: + enabled: true + platformReleases: + - agent: + name: default-agent + namespace: kagent + name: default-agent + namespace: default url: http://muster.default.svc.cluster.local:8090/mcp networkPolicy: enabled: false @@ -336,6 +345,12 @@ spec: secretKeyRef: key: dex-client-secret name: '{{ .Values.global.identity.existingSecret }}' + - name: AGENT_PLATFORM_PORTAL_OIDC_CLIENT_SECRET + valueFrom: + secretKeyRef: + key: portal-dex-client-secret + name: '{{ .Values.global.identity.existingSecret }}' + optional: true - name: NODE_EXTRA_CA_CERTS value: '{{ with (dig "identity" "ca" "secretName" "" .Values.global) }}/etc/agent-platform/idp-ca/{{ dig "identity" "ca" "key" "ca.crt" $.Values.global }}{{ end }}' @@ -382,10 +397,12 @@ spec: endpoint: http://otlp-gateway.kube-system.svc:4317 headers: X-Scope-OrgID=giantswarm protocol: grpc + oidcClientId: "" parentRefs: [] resources: verticalPodAutoscaler: enabled: false + signInHandoff: true skillsRepositories: - https://github.com/giantswarm/agent-skills startUrlSearchParams: {} @@ -721,6 +738,27 @@ spec: enabled: false mode: Strict mcp: + approval: + rule: Allow + tools: + create_sandbox: Allow + create_session_checkpoint: Allow + delete_sandbox: Allow + fork_session: Allow + get_sandbox: Allow + get_sandbox_process: Allow + invoke_session: Allow + kill_sandbox_process: Allow + list_sandbox_templates: Allow + list_sandboxes: Allow + list_session_checkpoints: Allow + list_sessions: Allow + read_sandbox_file: Allow + read_sandbox_outputs: Allow + resume_sandbox: Allow + start_sandbox_process: Allow + suspend_sandbox: Allow + write_sandbox_file: Allow description: 'Your agent sessions on this installation, as the signed-in person: list them, send one a message, and checkpoint or fork them' displayName: Kagent @@ -1242,20 +1280,14 @@ spec: rbac: mcpServerEditor: subjects: - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-ad:giantswarm-admins - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-github:giantswarm:giantswarm-admins + - kind: ServiceAccount + name: agent-platform-unset-connector-admins + namespace: kube-system workflowEditor: subjects: - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-ad:giantswarm-admins - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-github:giantswarm:giantswarm-admins + - kind: ServiceAccount + name: agent-platform-unset-workflow-editors + namespace: kube-system replicaCount: 2 musterMcpServerViewers: null networkPolicy: @@ -1294,6 +1326,8 @@ spec: musterInClusterMcpPorts: - 8080 - 8443 + musterSessionBindingsNamespace: default + musterSessionBindingsPort: 8091 substrate: credentialProvider: egressFQDNs: [] @@ -2682,12 +2716,89 @@ spec: image: registry: gsoci.azurecr.io muster: + approval: + installation: agent-platform credentialProvider: actorBearer: enabled: true issuer: https://idp.ate-system.svc enabled: true gatewayIdentity: spiffe://cluster.local/ns/ate-system/sa/atenet-egress + sessionBindings: + allowedFrom: + - namespace: default + podLabels: + app.kubernetes.io/name: agent-manager + onMainPort: false + governance: + governedServers: + - role: agentManager + safe: + - get_info + - list_agents + - get_agent + - get_agent_status + - validate_agent + - list_model_configs + - list_egress_policies + - list_skills + - list_sessions + - get_session + - get_session_turn + - toolchain_users + - list_organizations + - get_organization + - list_organization_members + - list_organization_connectors + server: agent-manager + - role: sessionManager + safe: + - list_sessions + - list_session_checkpoints + - list_sandbox_templates + - list_sandboxes + - get_sandbox + - get_sandbox_process + - read_sandbox_outputs + - read_sandbox_file + server: kagent + - role: modelManager + safe: + - get_info + - get_backend + - list_backends + - list_models + - get_model + - list_loaded_models + - list_presets + - search_models + - check_fit + - list_nodes + - list_jobs + - get_job + server: model-manager + - role: skillManager + safe: + - list_skill_sources + - list_skills + - resolve_skills + - get_skill + - get_skill_file + server: skill-manager + - role: vmManager + safe: + - get_info + - get_host + - list_images + - get_image + - list_networks + - get_network + - list_vms + - get_vm + - get_vm_metrics + - get_vm_attestation + server: vm-manager + mode: trusted oauth: server: baseUrl: "" @@ -2751,22 +2862,21 @@ spec: enabled: true minAvailable: 1 rbac: + approvalBinder: + subjects: + - kind: ServiceAccount + name: agent-manager + namespace: default mcpServerEditor: subjects: - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-ad:giantswarm-admins - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-github:giantswarm:giantswarm-admins + - kind: ServiceAccount + name: agent-platform-unset-connector-admins + namespace: kube-system workflowEditor: subjects: - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-ad:giantswarm-admins - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-github:giantswarm:giantswarm-admins + - kind: ServiceAccount + name: agent-platform-unset-workflow-editors + namespace: kube-system replicaCount: 2 --- # Source: agent-platform/templates/components.yaml @@ -3317,7 +3427,8 @@ spec: mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip operation: copy ref: - semver: ">=4.0.0 <5.0.0" + semver: ">=4.1.0-rc.1 <5.0.0-0" + semverFilter: "^v?[0-9]+\\.[0-9]+\\.[0-9]+(-rc\\.[0-9]+)?$" --- # Source: agent-platform/templates/components.yaml apiVersion: source.toolkit.fluxcd.io/v1 @@ -3367,7 +3478,8 @@ spec: mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip operation: copy ref: - semver: "0.12.x" + semver: ">=0.13.0-rc.1 <0.14.0-0" + semverFilter: "^v?[0-9]+\\.[0-9]+\\.[0-9]+(-rc\\.[0-9]+)?$" --- # Source: agent-platform/templates/components.yaml apiVersion: source.toolkit.fluxcd.io/v1 @@ -3569,7 +3681,8 @@ spec: mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip operation: copy ref: - semver: ">=4.18.10 <5.0.0" + semver: ">=4.20.0-rc.8 <5.0.0-0" + semverFilter: "^v?[0-9]+\\.[0-9]+\\.[0-9]+(-rc\\.[0-9]+)?$" --- # Source: agent-platform/templates/components.yaml apiVersion: source.toolkit.fluxcd.io/v1 @@ -3594,7 +3707,7 @@ spec: mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip operation: copy ref: - semver: ">=1.25.0 <2.0.0-0" + semver: ">=1.26.0-rc.1 <2.0.0-0" semverFilter: "^v?[0-9]+\\.[0-9]+\\.[0-9]+(-rc\\.[0-9]+)?$" --- # Source: agent-platform/templates/components.yaml @@ -3620,7 +3733,7 @@ spec: mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip operation: copy ref: - semver: ">=5.67.0-rc.19 <6.0.0-0" + semver: ">=5.67.0-rc.61 <6.0.0-0" semverFilter: "^v?[0-9]+\\.[0-9]+\\.[0-9]+(-rc\\.[0-9]+)?$" --- # Source: agent-platform/templates/components.yaml @@ -3646,7 +3759,7 @@ spec: mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip operation: copy ref: - semver: ">=0.4.0-rc.1 <0.5.0-0" + semver: ">=0.5.0-rc.1 <0.6.0-0" semverFilter: "^v?[0-9]+\\.[0-9]+\\.[0-9]+(-rc\\.[0-9]+)?$" --- # Source: agent-platform/templates/components.yaml @@ -3747,4 +3860,5 @@ spec: mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip operation: copy ref: - semver: ">=0.29.0 <0.30.0" + semver: ">=0.30.0-rc.2 <0.31.0-0" + semverFilter: "^v?[0-9]+\\.[0-9]+\\.[0-9]+(-rc\\.[0-9]+)?$" diff --git a/tests/golden/meta-default.yaml b/tests/golden/meta-default.yaml index c4f436c7..aab5d5ef 100644 --- a/tests/golden/meta-default.yaml +++ b/tests/golden/meta-default.yaml @@ -536,6 +536,12 @@ spec: secretKeyRef: key: dex-client-secret name: '{{ .Values.global.identity.existingSecret }}' + - name: AGENT_PLATFORM_PORTAL_OIDC_CLIENT_SECRET + valueFrom: + secretKeyRef: + key: portal-dex-client-secret + name: '{{ .Values.global.identity.existingSecret }}' + optional: true - name: NODE_EXTRA_CA_CERTS value: '{{ with (dig "identity" "ca" "secretName" "" .Values.global) }}/etc/agent-platform/idp-ca/{{ dig "identity" "ca" "key" "ca.crt" $.Values.global }}{{ end }}' @@ -582,10 +588,12 @@ spec: endpoint: http://otlp-gateway.kube-system.svc:4317 headers: X-Scope-OrgID=giantswarm protocol: grpc + oidcClientId: "" parentRefs: [] resources: verticalPodAutoscaler: enabled: false + signInHandoff: true skillsRepositories: - https://github.com/giantswarm/agent-skills startUrlSearchParams: {} @@ -893,6 +901,27 @@ spec: enabled: false mode: Strict mcp: + approval: + rule: Allow + tools: + create_sandbox: Allow + create_session_checkpoint: Allow + delete_sandbox: Allow + fork_session: Allow + get_sandbox: Allow + get_sandbox_process: Allow + invoke_session: Allow + kill_sandbox_process: Allow + list_sandbox_templates: Allow + list_sandboxes: Allow + list_session_checkpoints: Allow + list_sessions: Allow + read_sandbox_file: Allow + read_sandbox_outputs: Allow + resume_sandbox: Allow + start_sandbox_process: Allow + suspend_sandbox: Allow + write_sandbox_file: Allow description: 'Your agent sessions on this installation, as the signed-in person: list them, send one a message, and checkpoint or fork them' displayName: Kagent @@ -1413,20 +1442,14 @@ spec: rbac: mcpServerEditor: subjects: - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-ad:giantswarm-admins - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-github:giantswarm:giantswarm-admins + - kind: ServiceAccount + name: agent-platform-unset-connector-admins + namespace: kube-system workflowEditor: subjects: - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-ad:giantswarm-admins - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-github:giantswarm:giantswarm-admins + - kind: ServiceAccount + name: agent-platform-unset-workflow-editors + namespace: kube-system replicaCount: 2 musterMcpServerViewers: null networkPolicy: @@ -1456,6 +1479,8 @@ spec: musterInClusterMcpPorts: - 8080 - 8443 + musterSessionBindingsNamespace: "" + musterSessionBindingsPort: 0 substrate: credentialProvider: egressFQDNs: [] @@ -2150,6 +2175,26 @@ spec: image: registry: gsoci.azurecr.io muster: + approval: + installation: agent-platform + governance: + governedServers: + - role: modelManager + safe: + - get_info + - get_backend + - list_backends + - list_models + - get_model + - list_loaded_models + - list_presets + - search_models + - check_fit + - list_nodes + - list_jobs + - get_job + server: model-manager + mode: trusted oauth: server: baseUrl: "" @@ -2215,20 +2260,14 @@ spec: rbac: mcpServerEditor: subjects: - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-ad:giantswarm-admins - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-github:giantswarm:giantswarm-admins + - kind: ServiceAccount + name: agent-platform-unset-connector-admins + namespace: kube-system workflowEditor: subjects: - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-ad:giantswarm-admins - - apiGroup: rbac.authorization.k8s.io - kind: Group - name: giantswarm-github:giantswarm:giantswarm-admins + - kind: ServiceAccount + name: agent-platform-unset-workflow-editors + namespace: kube-system replicaCount: 2 --- # Source: agent-platform/templates/components.yaml @@ -2513,7 +2552,8 @@ spec: mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip operation: copy ref: - semver: "0.12.x" + semver: ">=0.13.0-rc.1 <0.14.0-0" + semverFilter: "^v?[0-9]+\\.[0-9]+\\.[0-9]+(-rc\\.[0-9]+)?$" --- # Source: agent-platform/templates/components.yaml apiVersion: source.toolkit.fluxcd.io/v1 @@ -2588,7 +2628,7 @@ spec: mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip operation: copy ref: - semver: ">=1.25.0 <2.0.0-0" + semver: ">=1.26.0-rc.1 <2.0.0-0" semverFilter: "^v?[0-9]+\\.[0-9]+\\.[0-9]+(-rc\\.[0-9]+)?$" --- # Source: agent-platform/templates/components.yaml @@ -2614,7 +2654,7 @@ spec: mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip operation: copy ref: - semver: ">=5.67.0-rc.19 <6.0.0-0" + semver: ">=5.67.0-rc.61 <6.0.0-0" semverFilter: "^v?[0-9]+\\.[0-9]+\\.[0-9]+(-rc\\.[0-9]+)?$" --- # Source: agent-platform/templates/components.yaml diff --git a/tests/verify-agent-chart-line.py b/tests/verify-agent-chart-line.py new file mode 100755 index 00000000..d294c726 --- /dev/null +++ b/tests/verify-agent-chart-line.py @@ -0,0 +1,391 @@ +#!/usr/bin/env python3 +"""Assert that the agent chart line moves to 3.x only with what makes it safe +. + +Agent chart 3.0 removes muster.requireApproval; agent-manager's migrate +rewrites it to `default: Ask` from agent-platform.agentManager.agentChartV3Floor, +and muster enforces `default: Ask` from agent-platform.muster.agentApprovalFloor. +agent-manager.agentChart.semver feeds agent-manager, its migrate run and the +agent-platform-operator (every organization's chart source), so: + +- the default renders on the 2.x line; +- a 3.x line with agent-manager and muster at their floors and the default + agent's range on 3.x renders, and the range reaches agent-manager's release, + the connectivity release (the migrate run's input) and the default agent's + source; +- a 3.x line is refused with agent-manager below its floor, with muster below + its floor, with agent-manager.muster.toolApproval.enabled false, with the + default agent's range on the other major, and a range spanning both majors + is refused; the default agent on 3.x with the line on 2.x is refused too; +- the placeholder floors (agent approval, the hop, governance, session + bindings) are unset or above the last release without the feature; while + the hop's or muster's floor is unset every 3.x range is refused, whatever + its form (~3.2, 3.1.x, bounds), a pre-release alone and >=3.0.0 (spans + majors, as migrate says) too; once they are set, the same ranges are + refused with agent-manager and muster below them and the 3.x line renders + with the default ranges; the gated paths run on a copy of the chart + with test floors; +- a floor that needs the governance wiring (agent approval, the hop, tool + approval, session bindings) set while the governance floor is unset fails + the render naming both, 3.x line or not; +- the bounds that admit a pre-release of the next major: the probes serve + Helm 4 and the textual read of the upper bounds Helm 3.17 (whose semver + never matches a pre-release against a range with no pre-release lower + bound); HELM_LEGACY, the Helm 3.17 binary, runs the bound cases once more + under it (`make` passes the one in .bin/ when it is there). + +Stdlib only: documents are matched by text. +Usage: verify-agent-chart-line.py +Environment: HELM selects the binary. +""" +from __future__ import annotations + +import os +import re +import shutil +import subprocess +import sys +import tempfile + +META = META_ORIG = sys.argv[1] +CONN = sys.argv[2] if len(sys.argv) > 2 else "" +HELM = os.environ.get("HELM") or "helm" +BASE = [ + "--namespace", "agent-platform", + "--set", "global.domain=example.com", + "--set", "global.identity.issuerUrl=https://dex.example.com", + "--set", "global.identity.clientId=agent-platform", + "--set", "global.identity.existingSecret=agent-platform-idp", + "--set", "global.gatewayApi.parentRefs[0].name=example-gateway", + "--set", "model-manager.ollama.endpoint=http://ollama.example.com:11434", + "--set", "kagent.harness.snapshotLocation=s3://ci-agent-snapshots/agents", + "--set", "kagent.database.postgres.urlFile=/etc/kagent-db/uri", + "--set", "postgres.enabled=true", + "--set", "components.kagent.enabled=true", + "--set", "components.agent-manager.enabled=true", +] +V3 = ">=3.0.0 <4.0.0" +LINE = ["--set", f"agent-manager.agentChart.semver={V3}"] +AM = ["--set", "components.agent-manager.versionRange=>={floor}-rc.1 <5.0.0-0"] +MUSTER = ["--set", "components.muster.versionRange=>={floor} <6.0.0"] +DEFAULT_AGENT = ["--set", f"components.default-agent.versionRange={V3}"] + +failures: list[str] = [] + + +def fail(msg: str) -> None: + failures.append(msg) + + +def run(*args: str) -> subprocess.CompletedProcess: + return subprocess.run([HELM, "template", "ap", META, *BASE, *args], capture_output=True, text=True) + + +def renders(what: str, *args: str) -> str: + r = run(*args) + if r.returncode != 0: + fail(f"{what}: render failed:\n{r.stderr}") + return "" + return r.stdout + + +def refused(what: str, needle: str, *args: str) -> None: + r = run(*args) + if r.returncode == 0 or needle not in r.stderr: + fail(f"{what}: not refused with {needle!r}:\n{r.stderr[-600:]}") + + +# The releases that do not carry what the 3.x line needs: a floor at or below +# them would let a 3.x line through against a muster that ignores default: Ask +# or an agent-manager whose migrate has no 2.x -> 3.x hop. +LAST_WITHOUT = {"muster.agentApprovalFloor": "5.67.0-rc.60", "agentManager.agentChartV3Floor": "4.0.1", + "agentManager.toolApprovalFloor": "4.0.1", "muster.governanceFloor": "5.67.0-rc.60", + "muster.sessionBindingsPortFloor": "5.67.0-rc.60"} +PLACEHOLDERS = list(LAST_WITHOUT) +# Test values for the floors in a copy of the chart, so the paths they gate +# are exercised while the chart itself keeps them unset. +# They sit above the default component ranges, so the default render is below +# every one of them. +TEST_FLOORS = {"muster.agentApprovalFloor": "5.68.0", "agentManager.agentChartV3Floor": "4.6.0", + "agentManager.toolApprovalFloor": "4.6.0", "muster.governanceFloor": "5.68.0", + "muster.sessionBindingsPortFloor": "5.68.0"} +# agent-manager and muster below the chart's own floors (the last lines +# without the feature). +BELOW = ["--set", "components.agent-manager.versionRange=>=4.0.0 <4.1.0-0", "--set", "components.muster.versionRange=>=5.66.0 <5.67.0-0"] +BYPASS = ["~3.2", "3.1.x", ">=3.1.0 <3.6.0", "3.0.0-rc.6", ">=3.0.0", "3.x", V3] + + +def semver_key(v: str) -> tuple: + """Semver precedence: a pre-release sorts below its release, its + dot-separated identifiers numerically where they are numbers.""" + core, _, pre = v.partition("-") + ids = tuple((0, int(i), "") if i.isdigit() else (1, 0, i) for i in pre.split(".")) if pre else () + return (tuple(map(int, core.split("."))), 0 if pre else 1, ids) + + +def floor_value(chart: str, name: str) -> str | None: + text = open(os.path.join(chart, "templates", "_helpers.tpl"), encoding="utf-8").read() + m = re.search(r'\{\{- define "agent-platform\.' + re.escape(name) + r'" -\}\}([^{]*)\{\{- end -\}\}', text) + if not m: + fail(f"agent-platform.{name}: no one-line define") + return None + return m.group(1) + + +def with_floors(dst: str, floors: dict[str, str] | None = None) -> str: + chart = os.path.join(dst, "agent-platform") + shutil.copytree(META_ORIG, chart) + path = os.path.join(chart, "templates", "_helpers.tpl") + text = open(path, encoding="utf-8").read() + for name, v in (TEST_FLOORS if floors is None else floors).items(): + text, n = re.subn(r'(\{\{- define "agent-platform\.' + re.escape(name) + r'" -\}\})[^{]*(\{\{- end -\}\})', r"\g<1>" + v + r"\g<2>", text) + if n != 1: + fail(f"agent-platform.{name}: cannot set the test floor") + open(path, "w", encoding="utf-8").write(text) + return chart + + +# The chart's own floors: unset until the releases exist, else above the last +# release without the feature. +for name in PLACEHOLDERS: + v = floor_value(META, name) + if v is None or v == "": + continue + if not re.fullmatch(r"\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?", v): + fail(f"agent-platform.{name} {v!r} is neither unset nor one X.Y.Z[-pre]") + elif semver_key(v) <= semver_key(LAST_WITHOUT[name]): + fail(f"agent-platform.{name} {v} admits a release without the feature (last without it: {LAST_WITHOUT[name]})") +unset = not floor_value(META, "agentManager.agentChartV3Floor") or not floor_value(META, "muster.agentApprovalFloor") + +out = renders("default") +if V3 in out: + fail("the default render carries the 3.x line") +if "'>=2.6.0 <3.0.0'" not in out and '">=2.6.0 <3.0.0"' not in out: + fail("the default render does not carry the 2.x line") + +# The preflight range reaches the connectivity release and is not the line: +# no guard refuses it. +out = renders("preflight on the 2.x line", "--set", f"agentManager.migration.preflightSemver={V3}") +if f"preflightSemver: '{V3}'" not in out: + fail("agentManager.migration.preflightSemver does not reach the connectivity release") + +# Ranges the guard must read as migrate does, on the chart as it is. +for r in ["~3.2", "3.1.x", ">=3.1.0 <3.6.0", "3.x", V3]: + if unset: + refused(f"{r} while the floors are unset", "are unset; keep the 2.x line", "--set", f"agent-manager.agentChart.semver={r}") + else: + refused(f"{r} below the floors", "admits a release below", *BELOW, "--set", f"agent-manager.agentChart.semver={r}") +if not unset: + out = renders("3.x line at the chart's floors with the default ranges", *LINE, *DEFAULT_AGENT) + if out.count(V3) < 3: + fail(f"at the chart's floors the 3.x line reaches {out.count(V3)} places; want agent-manager's release, the connectivity release and the default agent's source") +refused("a pre-release alone", "admits no release version", "--set", "agent-manager.agentChart.semver=3.0.0-rc.6") +refused(">=3.0.0 spans majors as for migrate", "admits agent chart majors 3, 4, 5, 6, 7, …", "--set", "agent-manager.agentChart.semver=>=3.0.0") +# QB-07: majors past the probes (99) are refused as unsupported, as +# agent-manager's migrate and the operator refuse them, never read short. +for r in [">=100.0.0 <102.0.0", "100.x", ">=99.5.0", "^2.0.0 || 150.0.0"]: + refused(f"{r} past major 99", "admits an agent chart major of 100 or more", "--set", f"agent-manager.agentChart.semver={r}") +refused("range spanning 2.x and 3.x", "admits agent chart majors 2, 3", "--set", "agent-manager.agentChart.semver=>=2.6.0") +refused("3.x with agent-manager off: the operator still gets the range", "keep the 2.x line" if unset else "admits a release below", + *([] if unset else BELOW), "--set", "components.agent-manager.enabled=false", "--set", f"agent-manager.agentChart.semver={V3}") + +# With the floors set (a copy of the chart), the gated paths. +with tempfile.TemporaryDirectory() as tmp: + META = with_floors(tmp) + am = [a.replace("{floor}", TEST_FLOORS["agentManager.agentChartV3Floor"]) for a in AM] + muster = [a.replace("{floor}", TEST_FLOORS["muster.agentApprovalFloor"]) for a in MUSTER] + out = renders("3.x line with its floors", *LINE, *am, *muster, *DEFAULT_AGENT) + if out.count(V3) < 3: + fail(f"the 3.x line reaches {out.count(V3)} places; want agent-manager's release, the connectivity release and the default agent's source") + for r in ["~3.2", "3.1.x", ">=3.1.0 <3.6.0"]: + renders(f"{r} with its floors", "--set", f"agent-manager.agentChart.semver={r}", *am, *muster, "--set", f"components.default-agent.versionRange={r}") + refused(f"{r}, muster below its floor", "admits a release below 5.68.0", "--set", f"agent-manager.agentChart.semver={r}", *am, "--set", f"components.default-agent.versionRange={r}") + refused("3.x line, agent-manager below its floor", f"admits a release below {TEST_FLOORS['agentManager.agentChartV3Floor']}", *LINE, *muster, *DEFAULT_AGENT) + refused("3.x line, muster below its floor", "admits a release below 5.68.0", *LINE, *am, *DEFAULT_AGENT) + refused("3.x line, tool approval off", "agent-manager.muster.toolApproval.enabled is false", + *LINE, *am, *muster, *DEFAULT_AGENT, "--set", "agent-manager.muster.toolApproval.enabled=false") + refused("3.x line, default agent on 2.x", "select different agent chart majors", *LINE, *am, *muster) + refused("2.x line, default agent on 3.x", "select different agent chart majors", *DEFAULT_AGENT) + +META = META_ORIG + +# The migrate run reads organization namespaces on the 3.x path: +# list on namespaces always, cluster-wide reads of releases, sources and Agents +# with organizations on, no write anywhere outside its own namespaces. +if CONN: + conn_base = [HELM, "template", "t", CONN, "-n", "agent-platform", "-f", f"{CONN}/ci/test-substrate-values.yaml", + "-f", f"{CONN}/ci/test-llm-routing-values.yaml", "-f", os.path.join(os.path.dirname(__file__), "fixtures", "organizations-operator-values.yaml"), + "--set", "kagent.fluxServiceAccountName=kagent-flux", "--set", "global.domain=ci.example.com", + "--set", "components.agent-manager.enabled=true", "--set", "global.identity.issuerUrl=https://dex.ci.example.com", + "--set", "global.identity.clientId=platform", "--set", "global.identity.existingSecret=platform-oauth", + "--api-versions", "admissionregistration.k8s.io/v1/MutatingAdmissionPolicy"] + + def migrate_cluster_rules(*args: str) -> str: + r = subprocess.run([*conn_base, *args], capture_output=True, text=True) + if r.returncode != 0: + fail(f"connectivity render {args} failed:\n{r.stderr[-600:]}") + return "" + found = [d for d in r.stdout.split("\n---\n") if "\nkind: ClusterRole\n" in "\n" + d and "-agent-manager-migrate-crds\n" in d] + return found[0] if found else "" + + v3 = ("--set", f"agent-manager.agentChart.semver={V3}") + ns_rule = 'resources: ["namespaces"]\n verbs: ["list"]' + two = migrate_cluster_rules() + two_orgs = migrate_cluster_rules("--set", "agentPlatformOrganizations.enabled=true") + three = migrate_cluster_rules(*v3) + three_orgs = migrate_cluster_rules(*v3, "--set", "agentPlatformOrganizations.enabled=true") + cutover = ("--set", "agentManager.migration.cutover=true") + three_cut = migrate_cluster_rules(*v3, *cutover, "--set", "agentPlatformOrganizations.enabled=true") + for what, text in (("2.x line", two), ("2.x line with organizations", two_orgs)): + if ns_rule in text or "helm.toolkit.fluxcd.io" in text: + fail(f"{what}: the migrate run reads no organization namespace, so its identity gets no namespace list and no cluster-wide release read") + pre = ("--set", f"agentManager.migration.preflightSemver={V3}") + pre_orgs = migrate_cluster_rules(*pre, "--set", "agentPlatformOrganizations.enabled=true") + if ns_rule not in pre_orgs or 'resources: ["helmreleases"]\n verbs: ["get", "list"]' not in pre_orgs: + fail("a 3.x preflight range on the 2.x line grants the reads its dry run needs") + r = subprocess.run([*conn_base, *pre], capture_output=True, text=True) + cron = [d for d in r.stdout.split("\n---\n") if "\nkind: CronJob\n" in "\n" + d and "-agent-manager-migrate-preflight\n" in d] + if len(cron) != 1: + fail("a preflight range renders one CronJob -preflight") + else: + body = cron[0] + if "suspend: true" not in body or "- --dry-run" not in body or f"value: '{V3}'" not in body or "AGENT_CHART_SEMVER_FILTER" in body: + fail(f"the preflight CronJob is suspended, runs migrate --dry-run against the preflight range, without the line's filter:\n{body}") + r = subprocess.run([*conn_base], capture_output=True, text=True) + if "-agent-manager-migrate-preflight" in r.stdout: + fail("without a preflight range no preflight CronJob renders") + if ns_rule not in three or "helm.toolkit.fluxcd.io" in three: + fail("3.x line without organizations: the run lists namespaces (and finds none) and reads no release cluster-wide") + for want in ('resources: ["helmreleases"]\n verbs: ["get", "list"]', 'resources: ["ocirepositories"]\n verbs: ["get", "list"]', 'resources: ["agents"]\n verbs: ["list"]', ns_rule): + if want not in three_orgs: + fail(f"3.x line with organizations: the migrate run's ClusterRole lacks {want!r}") + # D-GO-03, D-GO-27: on the 3.x line itself (not a preflight) and only + # while agentManager.migration.cutover is set, the run rewrites the + # organization releases agent-manager owns and writes its report there: + # update on HelmReleases, the report ConfigMap; nothing else, and the + # scope policy holds those writes to organization namespaces and the + # kagent namespace, spec.values only, the report's name only. + def org_rules(text: str) -> str: + return text.split("cluster-wide list on their kagent.dev", 1)[-1].split('resources: ["namespaces"]', 1)[-1] + writes = ('resources: ["helmreleases"]\n verbs: ["update"]', 'resources: ["configmaps"]\n verbs: ["create"]', + 'resources: ["configmaps"]\n resourceNames: ["agent-manager-migrate-report"]\n verbs: ["get", "update"]') + for want in writes: + if want not in three_cut: + fail(f"3.x line with organizations during the cut-over: the migrate run's ClusterRole lacks {want!r}") + rules = org_rules(three_cut) + for w in writes: + rules = rules.replace(w, "") + for verb in ("create", "update", "patch", "delete", "watch"): + if f'"{verb}"' in rules: + fail(f"the migrate run's organization rights carry {verb} beyond the release update and its report") + pre_cut = migrate_cluster_rules(*pre, *cutover, "--set", "agentPlatformOrganizations.enabled=true") + for what, text in (("a 3.x preflight on the 2.x line", pre_orgs), ("a 3.x preflight with cutover set", pre_cut), + ("3.x line without organizations", three), ("3.x line with organizations, cutover unset", three_orgs)): + for verb in ("create", "update", "patch", "delete", "watch"): + if f'"{verb}"' in org_rules(text): + fail(f"{what}: the migrate run's cluster-wide rights carry {verb}; only the 3.x line with organizations writes") + if '"get", "list"]\n' in rules.split('resources: ["agents"]', 1)[-1][:40]: + fail("the run lists Agents in organization namespaces, it gets none") + + def scope_policy(*args: str) -> str: + r = subprocess.run([*conn_base, *args], capture_output=True, text=True) + found = [d for d in r.stdout.split("\n---\n") if "\nkind: ValidatingAdmissionPolicy\n" in "\n" + d and "name: agent-platform-organization-migrate-scope\n" in d] + return found[0] if found else "" + policy = scope_policy(*v3, *cutover, "--set", "agentPlatformOrganizations.enabled=true") + if not policy: + fail("3.x line with organizations: no agent-platform-organization-migrate-scope policy holds the run's writes") + else: + for want in ("system:serviceaccount:", "-agent-manager-migrate'", "request.name == 'agent-manager-migrate-report'", + "k == 'values'", "variables.organizationNamespace", 'resources: ["helmreleases"]', 'resources: ["configmaps"]', + "variables.sameMetadata", "ownerReferences", "finalizers"): + if want not in policy: + fail(f"the migrate scope policy lacks {want!r}:\n{policy}") + for what, args in (("2.x line", (*cutover, "--set", "agentPlatformOrganizations.enabled=true")), ("preflight", (*pre, *cutover, "--set", "agentPlatformOrganizations.enabled=true")), + ("3.x without organizations", (*v3, *cutover)), ("3.x, cutover unset", (*v3, "--set", "agentPlatformOrganizations.enabled=true"))): + if scope_policy(*args): + fail(f"{what}: the migrate scope policy renders without the writes it holds") + + # D-GO-38: only a boolean true grants the writes. A string, also "false", + # fails the render naming the key; a boolean false and an unset value + # grant none. + for text in ("false", "true", "no", ""): + r = subprocess.run([*conn_base, *v3, "--set-string", f"agentManager.migration.cutover={text}", "--set", "agentPlatformOrganizations.enabled=true"], + capture_output=True, text=True) + if r.returncode == 0 or "agentManager.migration.cutover must be the boolean" not in r.stderr: + fail(f"agentManager.migration.cutover as the string {text!r} is not refused:\n{r.stderr[-400:]}") + if scope_policy(*v3, "--set", "agentManager.migration.cutover=false", "--set", "agentPlatformOrganizations.enabled=true"): + fail("a boolean false cutover renders the migrate scope policy") + if not scope_policy(*v3, "--set-json", "agentManager.migration.cutover=true", "--set", "agentPlatformOrganizations.enabled=true"): + fail("a boolean true cutover (set as JSON) renders no migrate scope policy") + + # D-GO-08: every alternative of a || range and every version a range + # names counts, here as in migrate and the agent-platform-operator. + refused("an alternative on another major", "admits agent chart majors 2, 3", "--set", "agent-manager.agentChart.semver=3.0.1 || 2.6.0") + for r in (">=2.6.1 <2.6.9", "= 2.6.1", "~2.250", "2.6.1 - 2.6.5"): + renders(f"{r} reads as 2.x", "--set", f"agent-manager.agentChart.semver={r}") + # The connectivity chart's own probe (isV3): an exact pin and an + # alternative only the named-version probes see (D-GO-08, D-GO-31). + for r in ("3.0.1", "=3.0.1", "2.6.0 || 3.0.1", "3.0.1 || 3.2.0"): + if ns_rule not in migrate_cluster_rules("--set", f"agent-manager.agentChart.semver={r}"): + fail(f"the connectivity chart does not read {r} as a 3.x line") + for r in ("2.6.1", ">=2.6.1 <2.6.9", "~2.250"): + if ns_rule in migrate_cluster_rules("--set", f"agent-manager.agentChart.semver={r}"): + fail(f"the connectivity chart reads {r} as a 3.x line") + +# A floor that needs the governance wiring, set while the governance floor is +# unset (a release that sets its floors in two steps): the render fails naming +# both, not an agent-manager that binds what muster refuses. +for dependent in ("muster.agentApprovalFloor", "agentManager.agentChartV3Floor", "agentManager.toolApprovalFloor", "muster.sessionBindingsPortFloor"): + with tempfile.TemporaryDirectory() as tmp: + META = with_floors(tmp, {n: "" for n in PLACEHOLDERS} | {dependent: TEST_FLOORS[dependent]}) + refused(f"{dependent} set, governance floor unset", f"agent-platform.{dependent} is set while agent-platform.muster.governanceFloor is unset") + refused(f"{dependent} set, governance floor unset, 2.x line", "agent-platform.muster.governanceFloor is unset", "--set", "agent-manager.agentChart.semver=2.6.1") +META = META_ORIG +with tempfile.TemporaryDirectory() as tmp: + META = with_floors(tmp, {n: v for n, v in TEST_FLOORS.items() if n != "muster.governanceFloor"} | {"muster.governanceFloor": ""}) + refused("every floor but the governance floor set", "agent-platform.muster.governanceFloor is unset", *LINE, "--set", "components.default-agent.versionRange=" + V3) +META = META_ORIG + + +# A bound that admits a pre-release of the next major, and range +# shapes that are no semver range. Run under the Helm of the run, and once more +# under Helm 3.17 (HELM_LEGACY), whose semver library never matches a +# pre-release against a range with no pre-release lower bound, so only the +# textual read of the upper bounds (nextMajorPreRelease) can see them there. +def bound_cases() -> None: + refused("<=3.0.0-rc.1 bound", "admits 3.0.0-0, a pre-release of the next agent chart major", "--set", "agent-manager.agentChart.semver=>=2.6.0 <=3.0.0-rc.1") + refused("<3.0.0-rc.1 bound", "a pre-release of the next agent chart major", "--set", "agent-manager.agentChart.semver=>=2.6.0 <3.0.0-rc.1") + refused("<3.0.0-0.1 bound (not the -0 exception)", "a pre-release of the next agent chart major", "--set", "agent-manager.agentChart.semver=>=2.6.0 <3.0.0-0.1") + renders("<3.0.0-0 bound (the exception)", "--set", "agent-manager.agentChart.semver=>=2.6.0 <3.0.0-0") + + +bound_cases() +if os.environ.get("HELM_LEGACY"): + HELM = os.environ["HELM_LEGACY"] + bound_cases() + HELM = os.environ.get("HELM") or "helm" +elif not failures: + print("note: HELM_LEGACY (Helm 3.17) is not set: the textual read of pre-release upper bounds ran only where the probes find them", file=sys.stderr) +refused("majors beyond 5", "admits agent chart majors 3, 6", "--set", "agent-manager.agentChart.semver=>=3.0.0 <4.0.0 || 6.x") +refused("latest", "is not a semver range", "--set", "agent-manager.agentChart.semver=latest") +refused("empty", "is not a semver range", "--set-string", "agent-manager.agentChart.semver=") +renders("an exact 2.x pin", "--set-string", "agent-manager.agentChart.semver=2.6.1") +refused("an exact 3.x pin", "keep the 2.x line" if unset else "admits a release below", *([] if unset else BELOW), "--set-string", "agent-manager.agentChart.semver=3.0.0") +renders("prerelease-widened 2.x line", "--set", "agent-manager.agentChart.semver=>=2.6.0-0 <3.0.0-0") + +# An || range is held to its lowest alternative's floor. +with tempfile.TemporaryDirectory() as tmp: + META = with_floors(tmp) + am = [a.replace("{floor}", TEST_FLOORS["agentManager.agentChartV3Floor"]) for a in AM] + muster = [a.replace("{floor}", TEST_FLOORS["muster.agentApprovalFloor"]) for a in MUSTER] + for what, args in (("muster", ["--set", "components.muster.versionRange=>=5.68.0 <6.0.0 || >=5.0.0", *am]), + ("muster, exact alternatives", ["--set", "components.muster.versionRange=5.68.0 || 5.66.2", *am]), + ("agent-manager", ["--set", "components.agent-manager.versionRange=>=4.6.0 || >=4.5.0", *muster])): + refused(f"|| range of {what} below its floor", "admits a release below", *LINE, *DEFAULT_AGENT, *args) +META = META_ORIG + +if failures: + for f in failures: + print(f"FAIL: {f}", file=sys.stderr) + sys.exit(1) +print("agent chart line verified.") diff --git a/tests/verify-chatgpt-personal-login.py b/tests/verify-chatgpt-personal-login.py index 9fa669b8..20b3aaf1 100755 --- a/tests/verify-chatgpt-personal-login.py +++ b/tests/verify-chatgpt-personal-login.py @@ -38,6 +38,10 @@ "--set", "global.identity.existingSecret=platform-oauth", "--set", "muster.muster.oauth.server.existingSecret=platform-oauth"] MUSTER_CHART = ("oci://gsoci.azurecr.io/charts/giantswarm/muster", "5.52.5") +# The muster chart the release's values render against: the default range's +# floor, whose schema takes what the meta chart derives from its release floors +# (approval, governance, the session bindings port). +MUSTER_RELEASE_CHART = ("oci://gsoci.azurecr.io/charts/giantswarm/muster", "5.67.0-rc.61") KAGENT_CHART = ("oci://gsoci.azurecr.io/giantswarm/kagent/helm/kagent", "1.24.0-rc.1") PROVIDER = "chatgpt:\n{i} hostname: chatgpt.com\n{i} pathPrefix: /backend-api/codex/\n{i} scheme: Bearer\n" APP = "- flow: chatgptDeviceCode\n{i} name: chatgpt\n" @@ -132,13 +136,13 @@ def main(chart: str) -> int: fail(f"an own muster App chatgpt does not stand in place of the derived one:\n{apps}") ok("an own key of the provider entry and an own muster App chatgpt stand") - config = component_render(release(on, "muster"), MUSTER_CHART) + config = component_render(release(on, "muster"), MUSTER_RELEASE_CHART) if not re.search(r"providerApps:\n(?:\s+.*\n)*?\s+- flow: chatgptDeviceCode\n\s+name: chatgpt", config): - fail(f"the muster chart {MUSTER_CHART[1]} does not keep the chatgpt App:\n{config}") + fail(f"the muster chart {MUSTER_RELEASE_CHART[1]} does not keep the chatgpt App:\n{config}") controller = component_render(release(on, "kagent"), KAGENT_CHART).replace('\\"', '"') if '"chatgpt":{"hostname":"chatgpt.com","pathPrefix":"/backend-api/codex/","scheme":"Bearer"}' not in controller: fail(f"the kagent chart {KAGENT_CHART[1]} does not list the chatgpt provider in KAGENT_SESSION_ACTOR_JWT_PROVIDERS") - ok(f"the muster chart {MUSTER_CHART[1]} keeps the App; the kagent chart {KAGENT_CHART[1]} lists the provider") + ok(f"the muster chart {MUSTER_RELEASE_CHART[1]} keeps the App; the kagent chart {KAGENT_CHART[1]} lists the provider") # --- without a prerequisite nothing is derived ------------------------------------- for flags, case in ( diff --git a/tests/verify-cluster-manager.py b/tests/verify-cluster-manager.py index 26ef471c..80886548 100755 --- a/tests/verify-cluster-manager.py +++ b/tests/verify-cluster-manager.py @@ -172,10 +172,18 @@ def main(meta: str, connectivity: str) -> int: fail(f"switching the component on added documents other than its two: {sorted(added)}") if set(off_docs) - set(on_docs): fail(f"switching the component on removed documents: {sorted(set(off_docs) - set(on_docs))}") + # muster governs the component's server (muster.governance.governedServers, + # tests/verify-tool-approval.py): the one entry it gains. + governed = re.compile(r"^ - role: clusterManager\n(?: .*\n)*", re.M) for key, doc in off_docs.items(): if key == ("HelmRelease", "agent-platform-connectivity"): continue - if on_docs[key] != doc: + on_doc = on_docs[key] + if key == ("HelmRelease", "muster"): + if len(governed.findall(on_doc)) != 1 or governed.search(doc): + fail("switching the component on must add one governedServers entry for its server to muster's release") + on_doc = governed.sub("", on_doc) + if on_doc != doc: fail(f"switching the component on changed {key}") ok(f"on: one OCIRepository ({rng}) + one HelmRelease dependsOn muster, the block forwarded (Service name, OAuth as the caller, the muster registration, global), the namespace derived, the two blocks reach connectivity; nothing else moved") diff --git a/tests/verify-organization-namespaces.py b/tests/verify-organization-namespaces.py index 374d62a3..d5c546d0 100755 --- a/tests/verify-organization-namespaces.py +++ b/tests/verify-organization-namespaces.py @@ -869,6 +869,76 @@ def prove_operator_scope(): case("the operator deletes an organization's Agent", kubectl(["delete", "agent", "probe", "-n", ORG_NS, "--dry-run=server", "--wait=false"], None, op)) +HELMRELEASE_CRD = { + "apiVersion": "apiextensions.k8s.io/v1", "kind": "CustomResourceDefinition", + "metadata": {"name": "helmreleases.helm.toolkit.fluxcd.io"}, + "spec": {"group": "helm.toolkit.fluxcd.io", "scope": "Namespaced", + "names": {"plural": "helmreleases", "singular": "helmrelease", "kind": "HelmRelease", "listKind": "HelmReleaseList"}, + "versions": [{"name": "v2", "served": True, "storage": True, + "schema": {"openAPIV3Schema": {"type": "object", "properties": { + "spec": {"type": "object", "x-kubernetes-preserve-unknown-fields": True}}}}}]}, +} + + +def prove_migrate_scope(chart): + """agent-platform-organization-migrate-scope (D-GO-03, D-GO-27): during + the cut-over on the 3.x line the migrate run may update HelmReleases and + write its report cluster-wide; the policy holds it to organization + namespaces and the kagent namespace, to spec.values of an organization's + HelmRelease (its labels, annotations, ownerReferences and finalizers as + they were), and to the report's name.""" + r = connectivity(chart, "kubernetes", "--set", "components.agent-manager.enabled=true", + "--set", "global.identity.issuerUrl=https://dex.ci.example.com", "--set", "global.identity.clientId=platform", + "--set", "global.identity.existingSecret=platform-oauth", "--set", "agent-manager.agentChart.semver=>=3.0.0 <4.0.0", + "--set", "agentManager.migration.cutover=true") + if r.returncode != 0: + fail(f"connectivity render on the 3.x line:\n{r.stderr[-800:]}") + docs_ = [d for d in yaml.safe_load_all(r.stdout) if d and d.get("metadata", {}).get("name") == "agent-platform-organization-migrate-scope"] + if len(docs_) != 2: + fail(f"the 3.x line renders the migrate scope policy and its binding, got {len(docs_)} objects") + return + policy = next(d for d in docs_ if d["kind"] == "ValidatingAdmissionPolicy") + user = re.search(r"username == '([^']+)'", policy["spec"]["matchConditions"][0]["expression"]).group(1) + must(kubectl(["apply", "--server-side", "-f", "-"], yaml.safe_dump(HELMRELEASE_CRD)), "install the HelmRelease CRD") + must(kubectl(["wait", "--for=condition=Established", "crd/helmreleases.helm.toolkit.fluxcd.io", "--timeout=60s"]), "wait for the HelmRelease CRD") + for d in docs_: + must(kubectl(["apply", "--server-side", "-f", "-"], yaml.safe_dump(d)), f"apply {d['kind']} {d['metadata']['name']}") + API.settle(docs_) + + def hr(ns, values, interval="10m"): + return {"apiVersion": "helm.toolkit.fluxcd.io/v2", "kind": "HelmRelease", "metadata": {"name": "triage", "namespace": ns}, + "spec": {"interval": interval, "serviceAccountName": "kagent-flux", "chartRef": {"kind": "OCIRepository", "name": "agent"}, "values": values}} + old = {"muster": {"requireApproval": True}} + for ns in (ORG_NS, PLAIN_NS): + must(create(hr(ns, old), dry=False), f"create a HelmRelease in {ns}") + + def replace(obj): + return kubectl(["replace", "-f", "-", "--dry-run=server"], yaml.safe_dump(obj), user) + + def with_meta(**meta): + obj = hr(ORG_NS, {"default": "Ask"}) + obj["metadata"].update(meta) + return obj + owner = [{"apiVersion": "v1", "kind": "ConfigMap", "name": "gone", "uid": "00000000-0000-0000-0000-000000000000"}] + for what, meta in (("a label", {"labels": {"kustomize.toolkit.fluxcd.io/name": "flux"}}), + ("an annotation", {"annotations": {"reconcile.fluxcd.io/forceAt": "now"}}), + ("an owner", {"ownerReferences": owner}), + ("a finalizer", {"finalizers": ["example.com/hold"]})): + case(f"migrate adds {what} to an organization release", replace(with_meta(**meta)), "agent-platform-organization-migrate-scope") + case("migrate rewrites an organization release's values", replace(hr(ORG_NS, {"default": "Ask"}))) + case("migrate changes more than an organization release's values", replace(hr(ORG_NS, {"default": "Ask"}, "20m")), "agent-platform-organization-migrate-scope") + case(f"migrate rewrites a release in {PLAIN_NS}", replace(hr(PLAIN_NS, {"default": "Ask"})), "agent-platform-organization-migrate-scope") + report = lambda ns, name="agent-manager-migrate-report": {"apiVersion": "v1", "kind": "ConfigMap", "metadata": {"name": name, "namespace": ns}} + case("migrate writes its report in an organization namespace", create(report(ORG_NS), as_=user)) + marked = report(ORG_NS) | {"metadata": {"name": "agent-manager-migrate-report", "namespace": ORG_NS, + "annotations": {"agent-platform.giantswarm.io/agent-chart-ready-major": "3"}}} + case("migrate marks its report in an organization namespace", create(marked, as_=user)) + case("migrate writes its report in the kagent namespace", create(report("kagent"), as_=user)) + case("migrate writes its report in kube-system", create(report("kube-system"), as_=user), "agent-platform-organization-migrate-scope") + case("migrate writes another ConfigMap in an organization namespace", create(report(ORG_NS, "settings"), as_=user), "agent-platform-organization-migrate-scope") + case("a person's ConfigMap is not the migrate policy's business", create(report(ORG_NS, "settings"), as_=PERSON)) + + def prove_worker_access(): """CONNECT and the ephemeralcontainers subresource are admitted before the API server looks for the pod's node, so a Pending pod is enough.""" @@ -984,6 +1054,7 @@ def main(): prove_label(meta_chart, k8s) prove_netpol(k8s) prove_operator_scope() + prove_migrate_scope(chart) prove_worker_access() prove_render_check(chart) prove_model_manager(chart) diff --git a/tests/verify-prereleases.py b/tests/verify-prereleases.py index fadb21a2..9056bf2a 100755 --- a/tests/verify-prereleases.py +++ b/tests/verify-prereleases.py @@ -214,12 +214,12 @@ def main() -> None: fail(f"{release}: agentChart.semver {on_semver!r} does not admit {rc}") if not on_flt or any(re.search(on_flt, t) for t in TAGS_REFUSED) or not all(re.search(on_flt, t) for t in TAGS_ADMITTED): fail(f"{release}: agentChart.semverFilter {on_flt!r} is not the release tag filter") - own = agent_charts(helm(chart, [*ON, "--set", "agent-manager.agentChart.semver=1.x", "--set", "agent-manager.agentChart.semverFilter=^1[.]x$"])) - if set(own.values()) != {("1.x", "^1[.]x$")}: + own = agent_charts(helm(chart, [*ON, "--set", "agent-manager.agentChart.semver=2.x", "--set", "agent-manager.agentChart.semverFilter=^2[.]x$"])) + if set(own.values()) != {("2.x", "^2[.]x$")}: fail(f"an agentChart with its own semverFilter: {own}, want it as written") - pinned = agent_charts(helm(chart, [*ON, "--set-string", "agent-manager.agentChart.semver=1.5.0"])) - if set(pinned.values()) != {("1.5.0", "")}: - fail(f"an agentChart pinned to 1.5.0: {pinned}, want the pin as written and no filter") + pinned = agent_charts(helm(chart, [*ON, "--set-string", "agent-manager.agentChart.semver=2.6.1"])) + if set(pinned.values()) != {("2.6.1", "")}: + fail(f"an agentChart pinned to 2.6.1: {pinned}, want the pin as written and no filter") # An exact pin and an exclusion stay as written: `-0` would turn 1.2.3 # into a version that does not exist and stop != from excluding. A range # of those only admits no pre-release, so it gets no filter. A range that diff --git a/tests/verify-target.py b/tests/verify-target.py index 42e6c93b..9510edb4 100755 --- a/tests/verify-target.py +++ b/tests/verify-target.py @@ -132,8 +132,11 @@ def targeted(doc: str) -> str: skill-manager's Service that agent-manager is pointed at (skillManager.url and, on the connectivity release, agentManager.skillManager.namespace), and muster's in-cluster address its consumers are given (muster.url, muster.mcpUrl, - kagent's actor JWT provider hostname).""" - out, section, backends, skills = [], "", -1, -1 + muster.bindingsUrl, kagent's actor JWT provider hostname), and agent-manager's + namespace muster's session bindings and approval binder name + (muster.credentialProvider.sessionBindings.allowedFrom, + rbac.approvalBinder.subjects, networkPolicy.musterSessionBindingsNamespace).""" + out, section, backends, skills, agentManagerNs = [], "", -1, -1, -1 for line in doc.split("\n"): if re.match(r"^ \S", line): section = line.strip() @@ -142,15 +145,23 @@ def targeted(doc: str) -> str: backends = -1 if skills >= 0 and line.strip() and indent <= skills: skills = -1 + if agentManagerNs >= 0 and line.strip() and indent <= agentManagerNs: + agentManagerNs = -1 if re.match(r"^ +mcpBackends:$", line): backends = indent elif re.match(r"^ +skillManager:$", line): skills = indent + elif re.match(r"^ +(sessionBindings|approvalBinder):$", line): + agentManagerNs = indent elif (backends >= 0 or skills >= 0) and re.match(r"^ +namespace: default$", line): line = line.replace(": default", ": agent-platform") + elif agentManagerNs >= 0 and re.match(r"^ +(- )?namespace: default$", line): + line = line.replace(": default", ": agent-platform") + elif re.match(r"^ +musterSessionBindingsNamespace: default$", line): + line = line.replace(": default", ": agent-platform") elif skills >= 0 and re.match(r"^ +url: http://[^.]+\.default\.svc\.cluster\.local[:/]", line): line = line.replace(".default.svc.", ".agent-platform.svc.", 1) - elif section == "values:" and re.match(r"^ +(url|mcpUrl): http://muster\.default\.svc\.cluster\.local:|^ +hostname: muster\.default\.svc\.cluster\.local$", line): + elif section == "values:" and re.match(r"^ +(url|mcpUrl|bindingsUrl): http://muster\.default\.svc\.cluster\.local:|^ +hostname: muster\.default\.svc\.cluster\.local$", line): line = line.replace(".default.svc.", ".agent-platform.svc.", 1) if re.match(r"^ name: ", line) and section.startswith("name:"): line = line.replace("name: ", "name: t-", 1) @@ -165,6 +176,27 @@ def targeted(doc: str) -> str: return "\n".join(out) +def without_platform_agents(doc: str) -> str: + """The document without agent-manager's muster.toolApproval.platformReleases + or platformAgents block: with a remote target agent-manager gets the default + agent's approval values instead of its release (tests/verify-tool-approval.py, + check_default_agent_on_remote_target).""" + out, skip = [], -1 + for line in doc.split("\n"): + indent = len(line) - len(line.lstrip()) + if skip >= 0 and line.strip() and indent <= skip and not line.lstrip().startswith("- "): + skip = -1 + elif skip >= 0 and line.strip() and indent < skip: + skip = -1 + if skip >= 0: + continue + if re.match(r"^ +platform(Releases|Agents):$", line): + skip = indent + continue + out.append(line) + return "\n".join(out) + + def ok(msg: str) -> None: print(f"ok: {msg}") @@ -189,8 +221,8 @@ def check_knob(meta: str) -> None: # a target (targeted: the names prefixed, the workloads and their Helm # storage in agent-platform); what else leaves the render is the hook # family (a hook runs where the chart is installed — check_hooks). - stripped = {k: "\n".join(line for line in d.split("\n") if line not in lines) for k, d in docs.items() if k[0] in FLUX_KINDS} - expected = {(k[0], f"t-{k[1]}"): targeted(d) for k, d in documents(plain).items() if k[0] in FLUX_KINDS} + stripped = {k: without_platform_agents("\n".join(line for line in d.split("\n") if line not in lines)) for k, d in docs.items() if k[0] in FLUX_KINDS} + expected = {(k[0], f"t-{k[1]}"): without_platform_agents(targeted(d)) for k, d in documents(plain).items() if k[0] in FLUX_KINDS} if stripped != expected: diff = sorted(k for k in set(stripped) | set(expected) if stripped.get(k) != expected.get(k)) sys.exit(f"FAIL: the knob changed an OCIRepository / HelmRelease beyond the kubeConfig lines and the target placement ({flags}): {diff}") @@ -394,7 +426,10 @@ def check_hooks(meta: str) -> None: if jobs(helm(meta, runtime)): sys.exit("FAIL: the runtime shape (engine off) renders a hook Job; a cluster's own Flux gets no hook of the kagent line") with_knob = helm(meta, [*runtime, "-f", f"{meta}/ci/test-target-values.yaml"]) - if jobs(with_knob) or "kind: ServiceAccount" in with_knob: + # A ServiceAccount object (a document), not a subject named in a + # release's values (muster's editor placeholders are ServiceAccount + # subjects). + if jobs(with_knob) or any(kind == "ServiceAccount" for kind, _ in documents(with_knob)): sys.exit("FAIL: a hook Job or its identity renders with the target knob; hooks run on the installation, not on the target") ok("no hook Job renders with the target knob, none without it on the runtime shape") diff --git a/tests/verify-tenant-rbac.py b/tests/verify-tenant-rbac.py index d085be77..91ad9a03 100755 --- a/tests/verify-tenant-rbac.py +++ b/tests/verify-tenant-rbac.py @@ -379,13 +379,15 @@ def muster_rbac(args): if d.get("kind") == "HelmRelease" and d["metadata"]["name"] == "muster": return d["spec"]["values"].get("rbac", {}) fail("no muster HelmRelease in the meta render") - for role in ("mcpServerEditor", "workflowEditor"): - if subject_names(muster_rbac([])[role]) != ADMINS: + defaults = {"mcpServerEditor": ["agent-platform-unset-connector-admins"], "workflowEditor": ["agent-platform-unset-workflow-editors"]} + team_names = [a.split("=", 1)[1] for a in TEAM if a.startswith("tenants.platformTeam[") and ".name=" in a] + for role, want in defaults.items(): + if subject_names(muster_rbac([])[role]) != want: fail(f"muster.rbac.{role} changed without tenants.platformTeam") rbac = muster_rbac(TEAM) - for role in ("mcpServerEditor", "workflowEditor"): - if subject_names(rbac[role]) != ADMINS + ["acme:platform"]: - fail(f"muster.rbac.{role}.subjects are {subject_names(rbac[role])}, want the admin groups and acme:platform once") + for role, want in defaults.items(): + if subject_names(rbac[role]) != want + team_names: + fail(f"muster.rbac.{role}.subjects are {subject_names(rbac[role])}, want the placeholder subject and the platform team once each") ok("the meta chart appends tenants.platformTeam to muster's two editor bindings, each subject once") diff --git a/tests/verify-tool-approval.py b/tests/verify-tool-approval.py new file mode 100755 index 00000000..d3ef8cb6 --- /dev/null +++ b/tests/verify-tool-approval.py @@ -0,0 +1,1169 @@ +#!/usr/bin/env python3 +"""Assert the platform side of Governing tool calls. + +- governance: the meta chart renders muster's governance configuration into the + muster release (muster.governance: mode and governedServers {server, role, + safe}) from the top-level `governance` and `governedServers` values, from the + muster floor that reads it (agent-platform.muster.governanceFloor): mode + trusted by default, governed when set; one entry per MCPServer a source ships + while it renders, keyed as muster keys servers (name in muster's namespace, + namespace/name outside it); an own governedServers entry stands; the earlier + servers. shape, an own mode that differs, an unknown key or an unknown + mode fail; below the floor nothing is forwarded and `governed` fails. +- coverage: every MCPServer source the platform ships (the manager components + whose release values carry muster.mcpServer, the connectivity chart's + MCPServers, agent-platform-mcps' families and, where the component checkouts + sit beside this repository, every chart that renders an MCPServer) is in + governedServers or in governanceExempt; no safe entry is a floor; every safe + entry names a tool of its server (the connectivity chart's approval maps + here, the component charts' where their checkouts are beside this one); the + connectivity and agent-platform-mcps kubernetes maps are equal. +- approval configuration: from the same floor the muster release carries + muster.approval.installation (backstage.installationName, default + agent-platform; an own value and an own ttl stand) and the redirect allowlist + muster.oauth.mcpClient.postLoginRedirectAllowlist: the portal's + https://[:]/sessions while the portal is on + and has a host (no port for 443), and klaus-gateway's + /auth/slack/return with its port while klaus-gateway is + on and names it; invalid ports and URLs fail; own entries stay, first, once + each; none below the floor. +- trusted clients: muster.approval.trustedClients is the portal's own client + (backstage.oidcClientId, when it differs from the platform's shared client) + while the portal is on, backstage.signInHandoff is on and muster is at least + agent-platform.muster.trustedClientsFloor, and under neither name below it + (an earlier muster issues tickets without the workload review); an own list under either name stands while it names only + the dedicated portal client (any other id fails: the shared client, + dex-k8s-authenticator, any client people sign in to); the backstage release + mounts portal-dex-client-secret and the connectivity app-config signs in + with that client, requesting the platform client's audience. +- approval decider: from the trusted-clients floor, while muster trusts the + portal's client, the muster release binds muster-approval-decider to the + portal's ServiceAccount (backstage.name in the portal's namespace) and + nothing else (an own list stands), and the backstage release projects that + ServiceAccount's token for audience muster where the portal's muster + backend reads it, beside its own extra volumes; none without a trusted + client or below the floor. +- governance floor: agent-platform.muster.governanceFloor is one X.Y.Z[-pre]; its + PLACEHOLDER-GOVERNANCE-FLOOR marker, while it is still there, appears once. +- connector-admin: muster's mcpserver-editor Role (the platform's + connector-admin role) is bound to the configured groups: by default a + ServiceAccount subject no identity provider can issue a token for + (kube-system/agent-platform-unset-connector-admins; never empty, so muster's + upgrade guard passes, never everyone, never a group name), tenants.platformTeam + appended, an installation's own list standing. +- role floors: governance.roleFloors renders muster.governance.roleFloors (a + role an installation declares for its own server, usable in + governedServers); malformed values and a second definition in + muster.muster.governance.roleFloors fail; the default ships no server or + role outside the platform's own components. +- muster-approval-binder: the muster release binds muster's Role + muster-approval-binder (in muster's namespace, the muster chart's) to + agent-manager's ServiceAccount and nothing else + (muster.rbac.approvalBinder.subjects, its name and namespace following + agent-manager's); an own list stands; a ServiceAccount the chart does not + create needs a name; none with agent-manager off or below the floor; the + connectivity chart ships no binding of its own. +- approval: every MCPServer the connectivity chart renders carries explicit + settings: mcp-kubernetes the Recommended preset (rule Ask, reads Allow, writes + Ask), kagent's session tools the Allow all preset (rule Allow, every tool + Allow); a rule Block renders, a per-tool override reaches spec.approval (also + from the meta chart's values), null renders none, a value outside the CRD's + enums or an unknown key fails naming the key. + +Stdlib only (the CI image has no PyYAML): documents are matched by text. + +Usage: verify-tool-approval.py +Environment: HELM selects the binary; COMPONENT_CHECKOUTS (default: the +directory holding this repository) is where the component repositories are +looked for; the checks that need them say when they are skipped. +""" +from __future__ import annotations + +import atexit +import os +import re +import shutil +import subprocess +import sys +import tempfile + +HELM = os.environ.get("HELM", "helm") +FLOOR_RANGE = "" # set in main from agent-platform.muster.governanceFloor +META = ["--set", "components.flux.enabled=false"] +CONN = [ + "--namespace", "agent-platform", + "--set", "ingress.parentRefs[0].name=x", + "--set", "kagent.harness.snapshotLocation=s3://ci-agent-snapshots/agents", + "--set", "kagent.database.postgres.urlFile=/etc/kagent-db/uri", + "--set", "global.domain=ci.example.com", + "--set", "global.identity.issuerUrl=https://dex.ci.example.com", + "--set", "global.identity.clientId=platform", + "--set", "global.identity.existingSecret=platform-oauth", + "--set", "gateway.jwksEgress.enabled=true", + "--set", "components.kagent.enabled=true", + "--set", "components.agentgateway.enabled=true", +] +AGENT_MANAGER = ["--set", "components.agent-manager.enabled=true"] +KAGENT_MCP = ["--set", "kagent.controllerRoute.enabled=true"] +MCPK = ["--set", "components.mcp-kubernetes.enabled=true"] + + +def governance_floor(meta_dir: str) -> str: + """The value of agent-platform.muster.governanceFloor, and its one marker.""" + text = open(os.path.join(meta_dir, "templates", "_helpers.tpl")).read() + m = re.search(r'define "agent-platform\.muster\.governanceFloor" -\}\}((?:[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?)?)\{\{-', text) + if not m: + fail("agent-platform.muster.governanceFloor must be one line holding one X.Y.Z[-pre], or nothing while its release does not exist") + if not m.group(1): + print("note: the governance floor is unset (PLACEHOLDER-GOVERNANCE-FLOOR): nothing it gates renders; set it in the platform release that pins the muster release carrying tool approval") + return "" + markers = text.count("PLACEHOLDER-GOVERNANCE-FLOOR") + if markers > 1: + fail("the governance floor placeholder must be marked at most once (PLACEHOLDER-GOVERNANCE-FLOOR) next to its define") + if markers and m.group(1): + print(f"note: the governance floor {m.group(1)} is still a placeholder (PLACEHOLDER-GOVERNANCE-FLOOR): move it to the muster release that carries tool approval before releasing") + return m.group(1) + + +def fail(msg: str) -> None: + sys.exit(f"FAIL: {msg}") + + +def render(chart: str, args: list[str], expect_fail: bool = False) -> str: + r = subprocess.run([HELM, "template", "t", chart, *args], capture_output=True, text=True) + if expect_fail: + if r.returncode == 0: + fail(f"render with {args} succeeded, want a failure") + return r.stderr + if r.returncode != 0: + fail(f"render with {args} failed:\n{r.stderr}") + return r.stdout + + +def docs(out: str) -> list[str]: + return [d for d in ("\n" + out).split("\n---\n") if d.strip()] + + +def doc(out: str, kind: str, name: str) -> str | None: + found = [d for d in docs(out) if f"\nkind: {kind}\n" in "\n" + d and f"\n name: {name}\n" in d] + if len(found) > 1: + fail(f"{len(found)} {kind} {name}, want at most one") + return found[0] if found else None + + +def block(text: str, header: str) -> str: + """The lines of `header` and everything indented deeper below it.""" + lines = text.split("\n") + for i, line in enumerate(lines): + if line.rstrip() == header.rstrip(): + indent = len(line) - len(line.lstrip()) + out = [line] + for nxt in lines[i + 1:]: + if nxt.strip() and len(nxt) - len(nxt.lstrip()) <= indent and not nxt.lstrip().startswith("- "): + break + if nxt.strip() and len(nxt) - len(nxt.lstrip()) < indent: + break + out.append(nxt) + return "\n".join(out) + return "" + + +def muster_release(args: list[str]) -> str: + hr = doc(render_meta(args), "HelmRelease", "muster") + if hr is None: + fail(f"no muster HelmRelease with {args}") + return hr + + +def render_meta(args: list[str]) -> str: + return render(META_DIR, META + args) + + +def governance(meta_args: list[str]) -> str: + return block(muster_release(meta_args), " governance:") + + +def governed_entries(gov: str) -> dict[str, dict]: + """server key -> {"role": str, "safe": [str]} of a rendered governance block.""" + out: dict[str, dict] = {} + cur: dict = {} + field = "" + for line in gov.split("\n"): + st = line.strip() + if st.startswith("- role: ") or st.startswith("- safe:") or st.startswith("- server: "): + cur = {"role": "", "safe": [], "server": ""} + st = st[2:] + if st.startswith("role: "): + cur["role"] = st[len("role: "):] + elif st.startswith("safe:"): + field = "safe" + elif st.startswith("server: "): + cur["server"] = st[len("server: "):] + out[cur["server"]] = cur + elif st.startswith("- ") and field == "safe" and cur is not None and line.startswith(" - "): + cur["safe"].append(st[2:]) + return out + + +FULL = [ + "--namespace", "agent-platform", + "--set", "global.domain=example.com", + "--set", "global.identity.issuerUrl=https://dex.example.com", + "--set", "global.identity.clientId=agent-platform", + "--set", "global.identity.existingSecret=agent-platform-idp", + "--set", "global.gatewayApi.parentRefs[0].name=example-gateway", + "--set", "model-manager.ollama.endpoint=http://ollama.example.com:11434", + "--set", "kagent.harness.snapshotLocation=s3://ci-agent-snapshots/agents", + "--set", "kagent.database.postgres.urlFile=/etc/kagent-db/uri", + "--set", "postgres.enabled=true", + "--set", "components.kagent.enabled=true", + "--set", "components.agent-manager.enabled=true", +] + + +def check_governance() -> None: + trusted = governance(["--set", FLOOR_RANGE]) + entries = governed_entries(trusted) + if " mode: trusted" not in trusted: + fail(f"default governance, want mode trusted:\n{trusted}") + if entries.get("model-manager", {}).get("role") != "modelManager": + fail(f"default governance must govern model-manager as modelManager:\n{trusted}") + roles = {e.get("role") for e in entries.values()} + if not roles <= {"agentManager", "sessionManager", "modelManager", "clusterManager", "vmManager", "toolchainManager", "workspaceManager", "skillManager", "infrastructure"}: + fail(f"the default governs only the platform's own components: {sorted(roles)}") + if "roleFloors" in trusted: + fail(f"the default declares no role floors:\n{trusted}") + # An installation's own server and role. + own_role = governance(["--set", FLOOR_RANGE, "--set-json", 'governance.roleFloors={"exampleManager":["approve_change","merge_change"]}', + "--set", "governedServers.example-manager.role=exampleManager", "--set", "governedServers.example-manager.safe[0]=get_info"]) + if "roleFloors:\n exampleManager:\n - approve_change\n - merge_change" not in own_role: + fail(f"governance.roleFloors must render as muster.governance.roleFloors:\n{own_role}") + if governed_entries(own_role).get("example-manager", {}).get("role") != "exampleManager": + fail(f"an installation's own server key governs with its declared role:\n{own_role}") + for args, want in ((["--set-json", 'governance.roleFloors={"Bad Role":["x"]}', "--skip-schema-validation"], 'role "Bad Role": want a camelCase name'), + (["--set-json", 'governance.roleFloors={"exampleManager":"x"}', "--skip-schema-validation"], "governance.roleFloors.exampleManager: want a list"), + (["--set-json", 'governance.roleFloors={"exampleManager":["a b"]}', "--skip-schema-validation"], "is not a tool name"), + (["--set-json", 'governance.roleFloors={"exampleManager":["x"]}', "--set-json", 'muster.muster.governance.roleFloors={"exampleManager":["y"]}'], "are both set")): + err = render(META_DIR, META + ["--set", FLOOR_RANGE, *args], expect_fail=True) + if want not in err: + fail(f"{args}: want {want!r}, got:\n{err}") + if "agent-manager" in entries or "vm-manager" in entries: + fail(f"components that are off ship no server to govern:\n{trusted}") + governed = governed_entries(governance(["--set", FLOOR_RANGE, "--set", "governance.mode=governed", "--set", "components.agent-manager.enabled=true", "--set", "agent-manager.muster.mcpServer.name=agents"])) + am = governed.get("agents") + if not am or am["role"] != "agentManager" or "list_agents" not in am["safe"] or "update_agent" in am["safe"]: + fail(f"governed with a renamed agent-manager server: want agents as agentManager with its reads safe, got {governed}") + if "mode: governed" not in governance(["--set", FLOOR_RANGE, "--set", "governance.mode=governed"]): + fail("governance.mode=governed must render mode governed") + apart = governed_entries(governance(["--set", FLOOR_RANGE, "--set", "components.muster.targetNamespace=muster", "--set", "components.vm-manager.enabled=true"])) + if not any(k.endswith("/vm-manager") for k in apart): + fail(f"a server outside muster's namespace is keyed namespace/name: {sorted(apart)}") + own = governance(["--set", FLOOR_RANGE, + "--set", "muster.muster.governance.governedServers[0].server=model-manager", + "--set", "muster.muster.governance.governedServers[0].role=modelManager", + "--set", "muster.muster.governance.governedServers[0].safe[0]=list_models"]) + mm = governed_entries(own)["model-manager"] + if mm["safe"] != ["list_models"] or own.count("server: model-manager") != 1: + fail(f"an own governedServers entry must stand for its server, once:\n{own}") + dropped = governed_entries(governance(["--set", FLOOR_RANGE, "--set-json", "governedServers.model-manager=null"])) + if "model-manager" in dropped: + fail("a source set to null governs nothing") + if governance([]): + fail("below the muster floor the muster release must carry no governance block") + err = render(META_DIR, META + ["--set", "governance.mode=governed"], expect_fail=True) + if "governance.mode governed needs muster" not in err or "components.muster.versionRange" not in err: + fail(f"governed below the floor must fail naming governance and components.muster.versionRange:\n{err}") + err = render(META_DIR, META + ["--set", "governance.mode=open"], expect_fail=True) + if "governance" not in err: + fail(f"an unknown mode must fail in the schema naming governance:\n{err}") + err = render(META_DIR, META + ["--set", "governance.mode=open", "--skip-schema-validation"], expect_fail=True) + if 'governance.mode "open": want trusted or governed' not in err: + fail(f"an unknown mode must fail in the template naming governance:\n{err}") + for args, want in ((["--set", "governance=governed"], "governance"), + (["--set", "governance=governed", "--skip-schema-validation"], "governance is a map mirroring muster's governance configuration"), + (["--set", "governance.policy=x", "--skip-schema-validation"], "governance.policy: unknown key")): + err = render(META_DIR, META + args, expect_fail=True) + if want not in err: + fail(f"{args}: want {want!r}, got:\n{err}") + err = render(META_DIR, META + ["--set", FLOOR_RANGE, "--set", "muster.muster.governance.mode=governed"], expect_fail=True) + if "muster.muster.governance.mode (governed) differs from governance.mode (trusted)" not in err: + fail(f"an own mode that differs must fail naming both keys:\n{err}") + err = render(META_DIR, META + ["--set", FLOOR_RANGE, "--set", "muster.muster.governance.servers.agentManager[0]=am"], expect_fail=True) + if "muster.muster.governance.servers is the earlier governance shape" not in err: + fail(f"the earlier servers shape must fail:\n{err}") + err = render(META_DIR, META + ["--set", FLOOR_RANGE, "--set", "governedServers.model-manager.safe_list[0]=x"], expect_fail=True) + if "governedServers" not in err or "safe_list" not in err: + fail(f"an unknown key of a source must fail in the schema naming it:\n{err}") + err = render(META_DIR, META + ["--set", FLOOR_RANGE, "--set", "governedServers.model-manager.safe_list[0]=x", "--skip-schema-validation"], expect_fail=True) + if "governedServers.model-manager.safe_list: unknown key" not in err: + fail(f"an unknown key of a source must fail naming it:\n{err}") + connectivity = doc(render_meta([]), "HelmRelease", "agent-platform-connectivity") + if connectivity and ("\n governance:" in connectivity or "governedServers" in connectivity or "governanceExempt" in connectivity): + fail("governance, governedServers and governanceExempt must not reach the connectivity release (omitKeys)") + print("ok: governance renders muster's governance configuration (mode, governedServers per shipped server, keys, own entries, null sources), none below the floor, governed below the floor, the earlier shape, unknown keys and conflicting modes fail") + + +# muster's floors (muster internal/api/governance.go roleFloors): never safe. +FLOORS = { + "agentManager": {"set_agent_approval", "set_organization_connector", "add_organization_member", "set_organization_model", "set_organization_egress_policy", "replace_organization_credential"}, + "connectorManager": {"mcpserver_create", "mcpserver_connect", "mcpserver_set_approval"}, + "toolchainManager": {"approve_source"}, + "modelManager": {"add_backend"}, +} +MANAGERS = ["agent-manager", "model-manager", "vm-manager", "cluster-manager", "workspace-manager", "toolchain-manager", "skill-manager"] + + +def values_block(text: str, key: str) -> list[str]: + """The lines of a top-level values.yaml block.""" + lines = text.split("\n") + start = next(i for i, l in enumerate(lines) if l.startswith(f"{key}:")) + out = [] + for l in lines[start + 1:]: + if l and not l.startswith(" ") and not l.startswith("#"): + break + out.append(l) + return out + + +def sources(meta_dir: str) -> tuple[dict[str, str], dict[str, str]]: + """governedServers source -> role ('' for null) and governanceExempt source -> reason, from values.yaml.""" + text = open(os.path.join(meta_dir, "values.yaml")).read() + governed: dict[str, str] = {} + cur = None + for l in values_block(text, "governedServers"): + m = re.match(r"^ ([a-z0-9-]+):\s*(null)?\s*$", l) + if m: + cur = m.group(1) + governed[cur] = "" + continue + m = re.match(r"^ role: (\S+)", l) + if m and cur: + governed[cur] = m.group(1) + exempt = {} + for l in values_block(text, "governanceExempt"): + m = re.match(r'^ ([a-z0-9-]+): "(.+)"$', l) + if m: + exempt[m.group(1)] = m.group(2) + return governed, exempt + + +def tools_map(text: str, header: re.Pattern[str]) -> dict[str, str]: + """tool -> setting of the approval block whose `approval:` line follows the first match of header.""" + lines = text.split("\n") + i = next(n for n, l in enumerate(lines) if header.search(l)) + i = next(n for n in range(i, len(lines)) if lines[n].strip().startswith("approval:")) + t = next(n for n in range(i, len(lines)) if lines[n].strip().startswith("tools:")) + indent = len(lines[t]) - len(lines[t].lstrip()) + out = {} + for l in lines[t + 1:]: + if l.strip().startswith("#"): + continue + if not l.strip() or len(l) - len(l.lstrip()) <= indent: + break + m = re.match(r"^\s+([A-Za-z0-9_.-]+): (Allow|Ask|Block)\b", l) + if m: + out[m.group(1)] = m.group(2) + return out + + +# A safe entry whose name starts with one of these verbs looks like a write: +# refused unless the source's block says why it is a read with a comment +# `# safe-write: : `. +WRITE_VERBS = { + "create", "update", "delete", "patch", "apply", "scale", "exec", "set", "add", "remove", "approve", + "grant", "revoke", "write", "start", "stop", "kill", "invoke", "fork", "merge", "deprecate", + "authorize", "sync", "wire", "unwire", "load", "unload", "pull", "push", "cancel", "replace", + "suspend", "resume", "reboot", "run", "send", "mint", "init", "enable", "disable", "port", + "forward", "rename", "move", "restart", "upgrade", "install", "uninstall", "edit", "import", +} + + +def write_like_safe(vtext: str) -> dict[str, str]: + """source -> why, for safe entries that look like writes and carry no safe-write annotation.""" + out = {} + for m in re.finditer(r"\n ([a-z0-9-]+):\n role: \S+\n((?: #.*\n)*) safe: \[(.*)\]\n", "\n" + "\n".join(values_block(vtext, "governedServers")) + "\n"): + src, comments, listed = m.group(1), m.group(2), m.group(3) + annotated = set(re.findall(r"# safe-write: ([A-Za-z0-9_]+): \S", comments)) + for tool in (t.strip() for t in listed.split(",") if t.strip()): + tokens = tool.lower().split("_") + if (tokens[0] in WRITE_VERBS or tool.lower() in WRITE_VERBS) and tool not in annotated: + out[src] = f"{tool} looks like a write ({tokens[0]}): take it off the safe list, or say why it is a read in a `# safe-write: {tool}: ` comment above `safe:`" + return out + + +def check_write_like() -> None: + base = "governedServers:\n mcp-kubernetes:\n role: infrastructure\n{c} safe: [get, {t}, list]\nnext: x\n" + for tool in ("delete", "authorize_workspace", "create_vm", "exec"): + if not write_like_safe(base.format(c="", t=tool)): + fail(f"{tool} on a safe list must be refused as write-like") + if write_like_safe(base.format(c=f" # safe-write: delete: dry run only here\n", t="delete")): + fail("an annotated write-like entry must pass") + for tool in ("list_port_forward_sessions", "get_vm_console", "read_sandbox_file", "toolchain_users", "can_i"): + if write_like_safe(base.format(c="", t=tool)): + fail(f"{tool} is a read and must pass") + print("ok: safe entries that look like writes (delete, authorize_workspace, create_vm, exec) are refused unless annotated with safe-write; reads pass") + + +def check_coverage() -> None: + governed, exempt = sources(META_DIR) + covered = {k for k, role in governed.items() if role} | set(exempt) + for k in set(governed) & set(exempt): + fail(f"{k} is both governed and exempt") + # 1. The meta chart's own picture, everything on. + meta = render_meta(FULL + ["--set", FLOOR_RANGE, "--set", "components.mcp-kubernetes.enabled=true", + *[a for m in MANAGERS if m != "workspace-manager" for a in ("--set", f"components.{m}.enabled=true")], + "--set", "workspaces.enabled=true", + "--set", "muster.muster.credentialProvider.releasable.github=https://github.com/apps/ci-agents", + *[a for i, g in enumerate(("kubernetes", "prometheus", "capi")) for a in ( + "--set", f"agent-platform-mcps.mcpServers[{i}].cluster=mc{i}", + "--set", f"agent-platform-mcps.mcpServers[{i}].group={g}", + "--set", f"agent-platform-mcps.mcpServers[{i}].url=https://mc{i}.example.com/mcp")]]) + shipped = {} + for d in docs(meta): + m = re.search(r"\nkind: HelmRelease\nmetadata:\n name: (\S+)\n", "\n" + d) + if m and re.search(r"\n muster:\n( .*\n)*? mcpServer:\n", d + "\n"): + shipped[m.group(1)] = "meta release values carry muster.mcpServer" + conn = render(CONN_DIR, CONN + AGENT_MANAGER + KAGENT_MCP + MCPK) + for d in docs(conn): + m = re.search(r"\nkind: MCPServer\nmetadata:\n name: (\S+)\n", "\n" + d) + if m: + shipped[{"kagent": "kagent", "mcp-kubernetes": "mcp-kubernetes"}.get(m.group(1), m.group(1))] = "connectivity chart MCPServer" + for g in ("kubernetes", "prometheus", "capi"): + shipped[{"kubernetes": "mcp-kubernetes"}.get(g, g)] = "agent-platform-mcps family" + # 2. The component charts beside this repository. + siblings = os.environ.get("COMPONENT_CHECKOUTS") or os.path.dirname(os.path.abspath(os.path.join(META_DIR, "..", ".."))) + seen_siblings = [] + for repo in sorted(os.listdir(siblings)) if os.path.isdir(siblings) else []: + tdir = os.path.join(siblings, repo, "helm", repo, "templates") + if repo == "agent-platform" or not os.path.isdir(tdir): + continue + if any("kind: MCPServer" in open(os.path.join(tdir, f)).read() for f in os.listdir(tdir) if f.endswith((".yaml", ".tpl"))): + seen_siblings.append(repo) + if repo != "agent-platform-mcps": + shipped[repo] = "component chart renders an MCPServer" + for src, why in sorted(shipped.items()): + if src not in covered: + fail(f"{src} ({why}) ships an MCPServer that is neither in governedServers nor in governanceExempt: govern it with its reads safe, or exempt it with the reason") + # 3. The rendered entries: every governed shipped source rendered, no floor is safe. + rendered = governed_entries(block(doc(meta, "HelmRelease", "muster") or "", " governance:")) + for key, e in rendered.items(): + bad = set(e["safe"]) & FLOORS.get(e["role"], set()) + if bad: + fail(f"{key}: floors {sorted(bad)} of role {e['role']} on its safe list (muster refuses to start)") + for src in [s for s in shipped if s in governed and governed[s]]: + if not any(k == src or k.endswith("/" + src) or k.endswith("-" + src) for k in rendered): + fail(f"{src} is governed but no entry rendered for it with every component on: {sorted(rendered)}") + # 4. Safe entries name tools of their server. + conn_values = open(os.path.join(CONN_DIR, "values.yaml")).read() + maps = { + "kagent": tools_map(conn_values, re.compile(r"^ description: \"Your agent sessions")), + "mcp-kubernetes": tools_map(conn_values, re.compile(r"^ description: \"Resources, events and pod logs of this installation")), + } + for repo in seen_siblings: + text = open(os.path.join(siblings, repo, "helm", repo, "values.yaml")).read() + if repo == "agent-platform-mcps": + fam = tools_map(text, re.compile(r"^ kubernetes:\s*$")) + if fam != maps["mcp-kubernetes"]: + fail(f"agent-platform-mcps' kubernetes family map differs from the connectivity chart's mcp-kubernetes map: {sorted(set(fam.items()) ^ set(maps['mcp-kubernetes'].items()))}") + else: + maps[repo] = tools_map(text, re.compile(r"^ mcpServer:\s*$")) + vtext = open(os.path.join(META_DIR, "values.yaml")).read() + for src, why in write_like_safe(vtext).items(): + fail(f"governedServers.{src}.safe: {why}") + for src, role in governed.items(): + if not role or src not in maps: + continue + m = re.search(rf"\n {re.escape(src)}:\n role: \S+\n(?: #.*\n)* safe: \[(.*)\]\n", vtext) + if not m: + fail(f"governedServers.{src}: want role then safe as a one-line list") + safe = [t.strip() for t in m.group(1).split(",") if t.strip()] + unknown = [t for t in safe if t not in maps[src]] + if unknown: + fail(f"governedServers.{src}.safe names no tool of its server: {unknown} (muster counts them in muster_governance_safe_list_unmatched)") + missing = sorted(set(MANAGERS) - set(seen_siblings)) + note = f"; component checkouts not found for {missing}, their safe lists not checked against their tools" if missing else "" + print(f"ok: every shipped MCPServer source ({len(shipped)}) is governed or exempt, no floor is safe, safe entries name tools of their server ({len(maps)} maps), the two kubernetes maps agree" + note) + + +def check_approval_config() -> None: + def release(args: list[str]) -> str: + return muster_release(["--set", FLOOR_RANGE, "--set", "global.domain=ci.example.com", *args]) + + default = release([]) + approval = block(default, " approval:") + if approval.rstrip() != " approval:\n installation: agent-platform": + fail(f"default approval, want installation agent-platform:\n{approval}") + named = block(release(["--set", "backstage.installationName=lab-1"]), " approval:") + if "installation: lab-1" not in named: + fail(f"approval.installation must follow backstage.installationName:\n{named}") + own = block(release(["--set", "muster.muster.approval.installation=mine", "--set", "muster.muster.approval.ttl=10m"]), " approval:") + if "installation: mine" not in own or "ttl: 10m" not in own or "agent-platform" in own: + fail(f"an own installation and ttl must stand:\n{own}") + # the allowlist renders only for muster's OAuth client role, as muster's chart does + mc = ["--set", "muster.muster.oauth.mcpClient.enabled=true"] + portal = ["--set", "components.backstage.enabled=true"] + kg = ["--set", "components.klaus-gateway.enabled=true", "--set", "klausGateway.obo.callbackBaseUrl=https://gw.ci.example.com/"] + list_header = " postLoginRedirectAllowlist:" + if block(release(mc), list_header): + fail("with the portal and klaus-gateway off there is nothing to allow: no allowlist expected") + both = block(release(mc + portal + kg), list_header) + want = list_header + "\n - https://backstage.ci.example.com/sessions\n - https://gw.ci.example.com/auth/slack/return" + if both.rstrip() != want: + fail(f"allowlist with the portal and klaus-gateway, want:\n{want}\ngot:\n{both}") + only_portal = block(release(mc + portal + ["--set", "klausGateway.obo.callbackBaseUrl=https://gw.ci.example.com"]), list_header) + if "auth/slack/return" in only_portal: + fail(f"no klaus-gateway entry while klaus-gateway is off:\n{only_portal}") + off = block(release(mc + kg), list_header) + if "sessions" in off or "https://gw.ci.example.com/auth/slack/return" not in off: + fail(f"klaus-gateway alone must give its return and no portal entry:\n{off}") + no_url = block(release(mc + ["--set", "components.klaus-gateway.enabled=true"]), list_header) + if no_url: + fail(f"klaus-gateway without a callbackBaseUrl names nothing to allow:\n{no_url}") + host = block(release(mc + portal + ["--set", "backstage.hostname=portal.example.org"]), list_header) + if "https://portal.example.org/sessions" not in host or "backstage.ci.example.com" in host: + fail(f"backstage.hostname must win over the global.domain derivation:\n{host}") + merged = block(release(mc + portal + kg + [ + "--set", "muster.muster.oauth.mcpClient.postLoginRedirectAllowlist[0]=https://own.example.com/x", + "--set", "muster.muster.oauth.mcpClient.postLoginRedirectAllowlist[1]=https://backstage.ci.example.com/sessions", + ]), list_header) + lines = [l.strip() for l in merged.split("\n")[1:]] + if lines != ["- https://own.example.com/x", "- https://backstage.ci.example.com/sessions", "- https://gw.ci.example.com/auth/slack/return"]: + fail(f"own entries stay first, each entry once:\n{merged}") + ported = block(release(mc + portal + ["--set", "backstage.publicPort=8443", "--set", "components.klaus-gateway.enabled=true", "--set", "klausGateway.obo.callbackBaseUrl=https://gw.ci.example.com:8443/"]), list_header) + if [l.strip() for l in ported.split("\n")[1:]] != ["- https://backstage.ci.example.com:8443/sessions", "- https://gw.ci.example.com:8443/auth/slack/return"]: + fail(f"a non-default port must stay in both entries (M1-1):\n{ported}") + default_port = block(release(mc + portal + ["--set", "backstage.publicPort=443"]), list_header) + top = block(release(mc + portal + ["--set", "backstage.publicPort=65535"]), list_header) + if "- https://backstage.ci.example.com:65535/sessions" not in top: + fail(f"port 65535 is a port:\n{top}") + if "- https://backstage.ci.example.com/sessions" not in default_port: + fail(f"port 443 writes no port:\n{default_port}") + for args, want in ( + (["--set", "backstage.publicPort=84a3"], 'backstage.publicPort "84a3"'), + (["--set", "backstage.publicPort=65536"], 'backstage.publicPort "65536"'), + (["--set", "backstage.publicPort=99999"], 'backstage.publicPort "99999"'), + (["--set", "components.klaus-gateway.enabled=true", "--set", "klausGateway.obo.callbackBaseUrl=gw.ci.example.com"], 'klausGateway.obo.callbackBaseUrl "gw.ci.example.com": want an http(s) URL'), + ): + err = render(META_DIR, META + ["--set", FLOOR_RANGE, "--set", "global.domain=ci.example.com", *mc, *portal, *args], expect_fail=True) + if want not in err: + fail(f"{args}: want {want!r}, got:\n{err}") + below = muster_release(["--set", "global.domain=ci.example.com", *mc, *portal, *kg]) + if block(below, " approval:") or "auth/slack/return" in below or "/sessions" in below: + fail("below the muster floor the muster release must carry neither approval nor derived allowlist entries") + connectivity = doc(render_meta(["--set", FLOOR_RANGE, *portal]), "HelmRelease", "agent-platform-connectivity") + if connectivity and "\n approval:\n installation:" in connectivity: + fail("the approval block must not reach the connectivity release") + print("ok: muster.approval.installation follows backstage.installationName, the redirect allowlist names the portal's /sessions and klaus-gateway's /auth/slack/return where they are on, with a non-default port, invalid ports and URLs fail, own values stand, none below the floor") + + +def check_connector_admin() -> None: + editor = block(muster_release([]), " mcpServerEditor:") + if "kind: ServiceAccount" not in editor or "name: agent-platform-unset-connector-admins" not in editor or "namespace: kube-system" not in editor or editor.count("name: ") != 1 or "kind: Group" in editor: + fail(f"connector admins by default are the unissuable ServiceAccount subject agent-platform-unset-connector-admins alone (no group an IdP could emit):\n{editor}") + if "system:authenticated" in editor: + fail(f"connector admins must not default to everyone:\n{editor}") + team = block(muster_release(["--set", "tenants.platformTeam[0].kind=Group", "--set", "tenants.platformTeam[0].name=customer:platform"]), " mcpServerEditor:") + if "name: customer:platform" not in team or "agent-platform-unset-connector-admins" not in team: + fail(f"tenants.platformTeam must be appended to the connector admins:\n{team}") + own = block(muster_release(["--set", "muster.rbac.mcpServerEditor.subjects[0].kind=Group", "--set", "muster.rbac.mcpServerEditor.subjects[0].name=ops"]), " mcpServerEditor:") + if "name: ops" not in own or "agent-platform-unset-connector-admins" in own: + fail(f"an installation's own connector admins must stand:\n{own}") + print("ok: the connector-admin role (muster's mcpserver-editor) binds a ServiceAccount nobody holds by default plus tenants.platformTeam, an own list standing") + + +def check_binder() -> None: + def binder(args: list[str]) -> str: + return block(muster_release(["--set", FLOOR_RANGE, *args]), " approvalBinder:") + + on = ["--set", "components.agent-manager.enabled=true"] + got = binder(on) + want = "\n".join([ + " approvalBinder:", + " subjects:", + " - kind: ServiceAccount", + " name: agent-manager", + " namespace: default", + ]) + if got.rstrip() != want: + fail(f"muster-approval-binder must bind agent-manager's ServiceAccount only, want:\n{want}\ngot:\n{got}") + moved = binder(on + ["--set", "components.agent-manager.targetNamespace=am", "--set", "agent-manager.serviceAccount.name=am-sa", "--set", "components.muster.targetNamespace=muster"]) + if "name: am-sa" not in moved or "namespace: am" not in moved: + fail(f"the subject must follow agent-manager's ServiceAccount name and namespace:\n{moved}") + own = binder(on + ["--set", "muster.rbac.approvalBinder.subjects[0].kind=ServiceAccount", "--set", "muster.rbac.approvalBinder.subjects[0].name=other", "--set", "muster.rbac.approvalBinder.subjects[0].namespace=x"]) + if "name: other" not in own or "name: agent-manager" in own: + fail(f"an own approvalBinder list must stand:\n{own}") + err = render(META_DIR, META + ["--set", FLOOR_RANGE, *on, "--set", "agent-manager.serviceAccount.create=false"], expect_fail=True) + if "agent-manager.serviceAccount.create is false without agent-manager.serviceAccount.name" not in err: + fail(f"a ServiceAccount the chart does not create must be named:\n{err}") + if "name: am-sa" not in binder(on + ["--set", "agent-manager.serviceAccount.create=false", "--set", "agent-manager.serviceAccount.name=am-sa"]): + fail("an own ServiceAccount with a name must be bound") + if binder([]): + fail("no approvalBinder subjects with agent-manager off") + if block(muster_release(on), " approvalBinder:"): + fail("no approvalBinder subjects below the muster floor") + conn = render(CONN_DIR, CONN + AGENT_MANAGER) + if "muster-approval-binder" in conn: + fail("the connectivity chart must ship no muster-approval-binder binding (the muster chart binds it in muster's namespace)") + print("ok: muster-approval-binder is bound by the muster chart to agent-manager's ServiceAccount only (name and namespace following agent-manager), an own list stands, an unnamed external ServiceAccount fails, none with agent-manager off or below the floor, none in the connectivity chart") + + +def check_agent_manager_tool_approval() -> None: + def release(args: list[str]) -> str: + hr = doc(render_meta(["--set", "components.agent-manager.enabled=true", *args]), "HelmRelease", "agent-manager") + if hr is None: + fail(f"no agent-manager HelmRelease with {args}") + return block(hr, " toolApproval:") + + am = "components.agent-manager.versionRange=>=4.6.0 <5.0.0-0" + if release(["--set", am]).split() != ["toolApproval:", "enabled:", "false"]: + fail(f"below muster's agent approval floor agent-manager must bind no settings (toolApproval.enabled false):\n{release(['--set', am])}") + on = release(["--set", am, "--set", "components.muster.versionRange=>=5.71.0 <6.0.0-0"]) + if on.split() != ["toolApproval:", "enabled:", "true"]: + fail(f"from both floors agent-manager must bind approval settings:\n{on}") + if release([]): + fail("below agent-manager's tool approval floor its chart takes no muster.toolApproval") + own = release(["--set", am, "--set", "components.muster.versionRange=>=5.71.0 <6.0.0-0", "--set", "agent-manager.muster.toolApproval.enabled=false"]) + if "true" in own: + fail(f"an own agent-manager.muster.toolApproval.enabled must stand:\n{own}") + print("ok: agent-manager's muster.toolApproval.enabled is on from its floor and muster's, off below muster's, absent below its own, an own value stands") + + +def check_session_bindings() -> None: + base = [ + "--set", "global.identity.issuerUrl=https://dex.ci.example.com", + "--set", "global.identity.clientId=platform", + "--set", "components.kagent.enabled=true", + "--set", "components.agent-manager.enabled=true", + "--set", "kagent.harness.snapshotLocation=s3://ci-agent-snapshots/agents", + "--set", "kagent.database.postgres.urlFile=/etc/kagent-db/uri", + "--set", "muster.muster.oauth.server.baseUrl=https://muster.ci.example.com", + ] + floor = ["--set", "components.muster.versionRange=>=5.71.0 <6.0.0-0"] + + def releases(args: list[str]) -> tuple[str, str]: + out = render_meta([*base, *args]) + muster, am = doc(out, "HelmRelease", "muster"), doc(out, "HelmRelease", "agent-manager") + if muster is None or am is None: + fail(f"no muster or agent-manager HelmRelease with {args}") + return block(muster, " sessionBindings:"), am + + conn = doc(render_meta([*base, *floor]), "HelmRelease", "agent-platform-connectivity") or "" + if "musterSessionBindingsPort: 8091" not in conn: + fail("from the floor the connectivity release must open agent-manager's egress to the session bindings port (networkPolicy.musterSessionBindingsPort)") + sb, am = releases(floor) + if "onMainPort: false" not in sb or "namespace:" not in sb or "app.kubernetes.io/name: agent-manager" not in sb: + fail(f"from muster's session bindings floor muster must serve the API on its own port, off the aggregator port, admitting agent-manager's pods alone:\n{sb}") + if not re.search(r"bindingsUrl: http://muster\.[^.]+\.svc\.cluster\.local:8091/session-bindings", am): + fail(f"from the floor agent-manager must call the session bindings port:\n{am}") + sb, am = releases([]) + if sb or "bindingsUrl:" in am: + fail(f"below the floor neither the port nor the URL are derived:\n{sb}") + sb, _ = releases([*floor, "--set", "muster.muster.credentialProvider.sessionBindings.onMainPort=true"]) + if "onMainPort: true" not in sb: + fail(f"an own sessionBindings.onMainPort must stand:\n{sb}") + _, am = releases([*floor, "--set", "agent-manager.muster.bindingsUrl=https://bindings.example.com/session-bindings"]) + if "bindingsUrl: https://bindings.example.com/session-bindings" not in am or ":8091/session-bindings" in am: + fail(f"an own agent-manager.muster.bindingsUrl must stand:\n{am}") + # muster in a namespace of its own: the egress rule selects that namespace, + # in both policy flavours, not the connectivity release's. + ns_args = [*floor, "--set", "components.muster.targetNamespace=muster-only"] + out = render_meta([*base, *ns_args]) + conn = doc(out, "HelmRelease", "agent-platform-connectivity") or "" + if "musterSessionBindingsNamespace: muster-only" not in conn: + fail(f"the connectivity release must carry muster's namespace for the session bindings egress rule:\n{conn}") + _, am = releases(ns_args) + if "muster.muster-only.svc.cluster.local:8091/session-bindings" not in am: + fail(f"agent-manager's bindingsUrl must name muster's namespace:\n{am}") + for flavor, want in (("cilium", "io.kubernetes.pod.namespace: muster-only"), ("kubernetes", "kubernetes.io/metadata.name: muster-only")): + for ns_value, expect in (("muster-only", want), ("", "")): + rendered = render(CONN_DIR, CONN + AGENT_MANAGER + ["--set", f"networkPolicy.flavor={flavor}", "--set", "networkPolicy.musterSessionBindingsPort=8091", "--set", f"networkPolicy.musterSessionBindingsNamespace={ns_value}"]) + rule = rendered.split("session bindings API on its own port", 1) + if len(rule) != 2: + fail(f"{flavor}: no session bindings egress rule rendered") + snippet = rule[1][:400] + if expect and expect not in snippet: + fail(f"{flavor}: the session bindings egress rule must select muster's namespace ({expect}):\n{snippet}") + if not expect and ("muster-only" in snippet or ("metadata.name" not in snippet and flavor == "kubernetes") or ("io.kubernetes.pod.namespace: agent-platform" not in snippet and flavor == "cilium")): + fail(f"{flavor}: without a namespace the rule must select the release's own (agent-platform):\n{snippet}") + print("ok: from muster's session bindings floor muster serves the session bindings API on its own port, off the aggregator port, its network policy admitting agent-manager's pods alone, and agent-manager's bindingsUrl names that port; none below the floor; own values stand") + + +def approval_of(out: str, name: str) -> str: + cr = doc(out, "MCPServer", name) + if cr is None: + fail(f"no MCPServer {name}") + return block(cr, " approval:") + + +def check_approval() -> None: + mcpk = approval_of(render(CONN_DIR, CONN + MCPK), "mcp-kubernetes") + if " rule: Ask" not in mcpk: + fail(f"mcp-kubernetes: want the Recommended rule Ask:\n{mcpk}") + for tool in ("get", "list", "describe", "logs", "can_i", "capi_list_clusters"): + if f" {tool}: Allow" not in mcpk: + fail(f"mcp-kubernetes: read-only {tool} must be Allow:\n{mcpk}") + for tool in ("create", "apply", "delete", "patch", "scale", "exec", "port_forward"): + if f" {tool}: Ask" not in mcpk: + fail(f"mcp-kubernetes: mutating {tool} must be Ask:\n{mcpk}") + if "Block" in mcpk: + fail("mcp-kubernetes: the default blocks nothing") + kagent = approval_of(render(CONN_DIR, CONN + KAGENT_MCP), "kagent") + if " rule: Allow" not in kagent or "Ask" in kagent or "Block" in kagent: + fail(f"kagent: want the Allow all preset:\n{kagent}") + for tool in ("list_sessions", "invoke_session", "fork_session", "write_sandbox_file"): + if f" {tool}: Allow" not in kagent: + fail(f"kagent: {tool} must be listed Allow:\n{kagent}") + tightened = approval_of(render(CONN_DIR, CONN + MCPK + ["--set", "mcp-kubernetes.mcpServer.approval.tools.exec=Block", "--set", "mcp-kubernetes.mcpServer.managementCluster=lab"]), "lab-mcp-kubernetes") + if " exec: Block" not in tightened: + fail(f"a per-tool override must reach spec.approval of the family member:\n{tightened}") + blocked = approval_of(render(CONN_DIR, CONN + MCPK + ["--set", "mcp-kubernetes.mcpServer.approval.rule=Block"]), "mcp-kubernetes") + if " rule: Block" not in blocked: + fail(f"a rule Block must render:\n{blocked}") + forwarded = doc(render_meta(["--set", "mcp-kubernetes.mcpServer.approval.tools.exec=Block", "--set", "kagent.controllerRoute.mcp.approval.tools.invoke_session=Ask"]), "HelmRelease", "agent-platform-connectivity") + if forwarded is None or "exec: Block" not in forwarded or "invoke_session: Ask" not in forwarded: + fail("per-connector overrides in the meta chart's values must reach the connectivity release") + cleared = render(CONN_DIR, CONN + MCPK + ["--set-json", "mcp-kubernetes.mcpServer.approval=null"]) + if approval_of(cleared, "mcp-kubernetes"): + fail("approval null must render no spec.approval") + for args, want in ( + (["--set", "mcp-kubernetes.mcpServer.approval.rule=Deny"], 'mcp-kubernetes.mcpServer.approval.rule "Deny": want Allow, Ask or Block'), + (["--set", "mcp-kubernetes.mcpServer.approval.tools.get=Deny"], 'mcp-kubernetes.mcpServer.approval.tools.get "Deny": want Allow, Ask or Block'), + (["--set", "mcp-kubernetes.mcpServer.approval.preset=recommended"], "mcp-kubernetes.mcpServer.approval.preset: unknown key"), + ): + err = render(CONN_DIR, CONN + MCPK + args, expect_fail=True) + if want not in err: + fail(f"{args}: want {want!r}, got:\n{err}") + err = render(CONN_DIR, CONN + KAGENT_MCP + ["--set", "kagent.controllerRoute.mcp.approval.tools.invoke_session=never"], expect_fail=True) + if "kagent.controllerRoute.mcp.approval.tools.invoke_session" not in err: + fail(f"kagent: an invalid value must fail naming the key:\n{err}") + print("ok: mcp-kubernetes carries the Recommended settings, kagent the Allow all settings, a Block rule renders, overrides reach spec.approval (also from the meta chart), null renders none, invalid values fail naming the key") + + +# Test values for the floors this file's checks need, set in a copy of the +# chart in place of the chart's own. They sit above the floors of +# components.muster.versionRange and components.agent-manager.versionRange, +# so the default render is below every one of them. +TEST_FLOORS = {"muster.governanceFloor": "5.70.0", "muster.agentApprovalFloor": "5.71.0", + "agentManager.toolApprovalFloor": "4.6.0", "muster.sessionBindingsPortFloor": "5.71.0", + "muster.trustedClientsFloor": "5.74.0"} + +# A muster below the trusted-clients floor and above the others: one that +# issued handoff tickets without the workload review and the sign-in +# confirmation. +BELOW_TRUSTED = f"components.muster.versionRange=>=5.73.0 <{TEST_FLOORS['muster.trustedClientsFloor']}" + + +def with_test_floors(meta_dir: str, dst: str) -> str: + """A copy of the meta chart with every floor of TEST_FLOORS set to its test value.""" + chart = os.path.join(dst, "agent-platform") + shutil.copytree(meta_dir, chart) + path = os.path.join(chart, "templates", "_helpers.tpl") + text = open(path).read() + for name, v in TEST_FLOORS.items(): + text, n = re.subn(r'(\{\{- define "agent-platform\.' + re.escape(name) + r'" -\}\})[^{]*(\{\{- end -\}\})', r"\g<1>" + v + r"\g<2>", text) + if n != 1: + fail(f"agent-platform.{name}: no one-line define") + open(path, "w").write(text) + return chart + + +def chart_with_floors(meta_dir: str, dst: str, floors: dict[str, str]) -> str: + """A copy of the meta chart with exactly these floors set; every other + floor of TEST_FLOORS unset.""" + chart = os.path.join(dst, "agent-platform") + shutil.copytree(meta_dir, chart) + path = os.path.join(chart, "templates", "_helpers.tpl") + text = open(path).read() + for name in list(TEST_FLOORS) + ["agentManager.agentChartV3Floor"]: + text, n = re.subn(r'(\{\{- define "agent-platform\.' + re.escape(name) + r'" -\}\})[^{]*(\{\{- end -\}\})', r"\g<1>" + floors.get(name, "") + r"\g<2>", text) + if n != 1: + fail(f"agent-platform.{name}: no one-line define") + open(path, "w").write(text) + return chart + + +def check_floor_dependencies() -> None: + """The floors that need the governance wiring fail the render while the + governance floor is unset, whichever of them is set; governed mode and role + floors fail with muster off.""" + dependent = ["agentManager.toolApprovalFloor", "muster.agentApprovalFloor", "muster.sessionBindingsPortFloor", "agentManager.agentChartV3Floor", "muster.trustedClientsFloor"] + values = {**TEST_FLOORS, "agentManager.agentChartV3Floor": "4.6.0"} + with tempfile.TemporaryDirectory(prefix="verify-floor-deps-") as tmp: + for i, name in enumerate(dependent): + os.makedirs(os.path.join(tmp, str(i))) + chart = chart_with_floors(META_DIR, os.path.join(tmp, str(i)), {name: values[name]}) + err = render(chart, META, expect_fail=True) + want = f"agent-platform.{name} is set while agent-platform.muster.governanceFloor is unset" + if want not in err: + fail(f"floor {name} set with the governance floor unset must fail the render naming both:\n{err}") + os.makedirs(os.path.join(tmp, "all")) + chart = chart_with_floors(META_DIR, os.path.join(tmp, "all"), {n: v for n, v in values.items() if n != "muster.governanceFloor"}) + err = render(chart, META, expect_fail=True) + if "agent-platform.muster.governanceFloor is unset" not in err: + fail(f"every floor but the governance floor set must fail naming it:\n{err}") + os.makedirs(os.path.join(tmp, "ok")) + chart = chart_with_floors(META_DIR, os.path.join(tmp, "ok"), values) + render(chart, META) + for args, want in ( + (["--set", "components.muster.enabled=false", "--set", "governance.mode=governed"], "governance.mode governed needs muster as a component of this release"), + (["--set", "components.muster.enabled=false", "--set-json", 'governance.roleFloors={"exampleManager":["approve_change"]}'], "governance.roleFloors is set while muster is off"), + ): + err = render(chart, META + args, expect_fail=True) + if want not in err: + fail(f"{args}: want {want!r}, got:\n{err}") + render(chart, META + ["--set", "components.muster.enabled=false"]) + print("ok: a floor that needs the governance wiring fails the render while the governance floor is unset, naming both; governed mode and role floors fail with muster off, trusted renders") + + +def check_unset_floors_keep_everything_off() -> None: + """On the chart as it is: a floor whose release does not exist gates its + wiring off whatever the component ranges say.""" + high = ["--set", "components.muster.versionRange=>=5.99.0 <6.0.0-0", "--set", "components.agent-manager.versionRange=>=4.99.0 <5.0.0-0", + "--set", "components.agent-manager.enabled=true"] + text = open(os.path.join(META_DIR, "templates", "_helpers.tpl")).read() + unset = [n for n in TEST_FLOORS if re.search(r'define "agent-platform\.' + re.escape(n) + r'" -\}\}\{\{- end', text)] + if not unset: + return + out = render_meta(high) + muster, am = doc(out, "HelmRelease", "muster"), doc(out, "HelmRelease", "agent-manager") + if "muster.governanceFloor" in unset: + if block(muster, " governance:"): + fail("with the governance floor unset the muster release must carry no governance configuration") + err = render_meta_fail(high + ["--set", "governance.mode=governed"]) + if "no muster release this chart knows reads the governance configuration yet" not in err or ">= " in err or "muster or" in err: + fail(f"with the governance floor unset `governed` must fail naming why, with no empty floor:\n{err}") + err = render_meta_fail(high + ["--set-json", 'governance.roleFloors={"exampleManager":["approve_change"]}']) + if "governance.roleFloors is set, but this chart renders muster's governance configuration only from" not in err: + fail(f"with the governance floor unset governance.roleFloors must fail, not be dropped:\n{err}") + for own in (["--set", "muster.muster.governance.mode=governed"], ["--set", "muster.muster.governance.servers.agentManager[0]=am"]): + err = render_meta_fail(high + own) + if "muster.muster.governance is set" not in err: + fail(f"with the governance floor unset an own {own[1]} must fail (governed, governing nothing):\n{err}") + if "muster.agentApprovalFloor" in unset and "enabled: true" in block(am, " toolApproval:"): + fail("with muster's agent approval floor unset agent-manager must bind no settings") + if "muster.sessionBindingsPortFloor" in unset and block(muster, " sessionBindings:"): + fail("with the session bindings floor unset muster must keep its earlier bindings wiring") + if "muster.trustedClientsFloor" in unset: + portal = render_meta(high + PORTAL_CLIENT + ["--set", "backstage.oidcClientId=platform-portal"]) + release = doc(portal, "HelmRelease", "muster") or "" + if "handoffClients" in release or "trustedClients" in release: + fail("with the trusted-clients floor unset muster must list no trusted client") + print(f"ok: unset floors ({', '.join(unset)}) keep what they gate off for any muster and agent-manager range; `governed` fails") + + +# The default agent: kagent, muster and agent-manager on (componentEnabled). +DEFAULT_AGENT_ON = [ + "--namespace", "agent-platform", + "--set", "global.domain=example.com", + "--set", "global.identity.issuerUrl=https://dex.example.com", + "--set", "global.identity.clientId=agent-platform", + "--set", "global.identity.existingSecret=agent-platform-idp", + "--set", "global.gatewayApi.parentRefs[0].name=example-gateway", + "--set", "model-manager.ollama.endpoint=http://ollama.example.com:11434", + "--set", "kagent.harness.snapshotLocation=s3://ci-agent-snapshots/agents", + "--set", "kagent.database.postgres.urlFile=/etc/kagent-db/uri", + "--set", "postgres.enabled=true", + "--set", "components.kagent.enabled=true", + "--set", "components.agent-manager.enabled=true", +] + + +def check_default_agent_release_readable() -> None: + """The default agent's release lives in the chart's Flux namespace, not in + the kagent namespace agent-manager manages: agent-manager gets get on it + by name (muster.toolApproval.platformReleases), so a session of the + default agent can read its tool approval settings for every person.""" + am = "components.agent-manager.versionRange=>=4.6.0 <5.0.0-0" + musters = "components.muster.versionRange=>=5.71.0 <6.0.0-0" + + def releases(args: list[str]) -> str: + out = render_meta([*DEFAULT_AGENT_ON, *args]) + hr = doc(out, "HelmRelease", "agent-manager") + if hr is None: + fail(f"no agent-manager HelmRelease with {args}") + return block(hr, " platformReleases:") + + def entries(text: str) -> list[str]: + return [line.strip() for line in text.split("\n")[1:] if line.strip()] + + # The release, and the Agent it renders: the only release the Agent's Flux + # labels may name (agent-manager refuses any other, and a missing one). + want = ["- agent:", "name: default-agent", "namespace: kagent", "name: default-agent", "namespace: agent-platform"] + got = releases(["--set", am, "--set", musters]) + if entries(got) != want: + fail(f"agent-manager must be granted the default agent's release agent-platform/default-agent, and be told it renders the Agent kagent/default-agent (the only release its Agent's labels may name):\n{got}") + got = releases(["--set", am, "--set", musters, "--set", "gitops.namespace=flux-giantswarm"]) + if entries(got) != [*want[:-1], "namespace: flux-giantswarm"]: + fail(f"the default agent's release lives in gitops.namespace:\n{got}") + if releases(["--set", am, "--set", musters, "--set", "components.default-agent.enabled=false"]): + fail("no default agent, no platform release to read") + if releases([]): + fail("below agent-manager's tool approval floor its chart takes no muster.toolApproval") + print("ok: agent-manager may get the default agent's release (muster.toolApproval.platformReleases: /default-agent, with the Agent kagent/default-agent it renders) from its tool approval floor, none without the default agent or below the floor") + + +def check_default_agent_on_remote_target() -> None: + """With a remote target (gitops.target.kubeConfig) agent-manager runs on + the target and cannot read the default agent's release on this cluster: + it gets the release's approval values instead + (muster.toolApproval.platformAgents), the Agent, the release its Flux + labels name (/-default-agent) and the + release's own tools/toolset/default, and no platformReleases.""" + am = "components.agent-manager.versionRange=>=4.6.0 <5.0.0-0" + musters = "components.muster.versionRange=>=5.71.0 <6.0.0-0" + target = ["--set", "gitops.target.kubeConfig.secretRef.name=wc1-kubeconfig", "--set", "gitops.target.name=wc1", + "--set", "gitops.namespace=flux-giantswarm"] + + def releases(args: list[str]) -> tuple[str, str, str]: + out = render_meta([*DEFAULT_AGENT_ON, "--set", am, "--set", musters, *target, *args]) + hr = doc(out, "HelmRelease", "wc1-agent-manager") + if hr is None: + fail(f"no wc1-agent-manager HelmRelease with {args}") + da = doc(out, "HelmRelease", "wc1-default-agent") or "" + return block(hr, " platformAgents:"), block(hr, " platformReleases:"), da + + agents, plain, da = releases([]) + if plain: + fail(f"with a remote target agent-manager cannot read the release: no platformReleases, got\n{plain}") + lines = [line.strip().lstrip("- ").strip() for line in agents.split("\n")[1:] if line.strip()] + for want in ["name: default-agent", "namespace: kagent", "release:", "name: wc1-default-agent", "namespace: flux-giantswarm", + "values:", "toolset:", "preset:full"]: + if want not in lines: + fail(f"platformAgents must carry the default agent kagent/default-agent, its release flux-giantswarm/wc1-default-agent and its toolset; missing {want!r}:\n{agents}") + for key in ["tools:", "default:", "requireApproval:"]: + if (key in lines) != (("\n " + key) in da or ("\n " + key) in da): + fail(f"platformAgents' {key} must match the default agent's release values:\n{agents}\n{da}") + if "toolset:\n - preset:full" not in da: + fail(f"the default agent's release carries toolset [preset:full]:\n{da}") + agents, plain, _ = releases(["--set", "components.default-agent.enabled=false"]) + if agents or plain: + fail("no default agent, no platform agent") + print("ok: with a remote target agent-manager gets the default agent's approval values (muster.toolApproval.platformAgents: kagent/default-agent, release /-default-agent, the release's toolset) instead of platformReleases; none without the default agent") + + +# The portal on with the platform's identity (client `platform`). +PORTAL_CLIENT = [ + "--set", "global.domain=ci.example.com", + "--set", "global.identity.issuerUrl=https://dex.ci.example.com", + "--set", "global.identity.clientId=platform", + "--set", "global.identity.existingSecret=platform-oauth", + "--set", "components.backstage.enabled=true", +] + + +def check_handoff_clients() -> None: + """muster.approval.trustedClients lists the portal's own client + (backstage.oidcClientId) while it differs from the platform's shared + client, the portal is on, backstage.signInHandoff is on and muster is at + least agent-platform.muster.trustedClientsFloor, and none under either + name below it (an earlier muster issues handoff tickets without the + workload review and the sign-in confirmation); an own list under either + name stands; a list naming the shared client fails the render.""" + trusted = f"components.muster.versionRange=>={TEST_FLOORS['muster.trustedClientsFloor']} <6.0.0-0" + handoff = BELOW_TRUSTED + + def clients(args: list[str], floor: str = trusted, key: str = "trustedClients") -> list[str]: + release = muster_release(["--set", floor, *PORTAL_CLIENT, *args]) + other = "handoffClients" if key == "trustedClients" else "trustedClients" + if block(release, f" {other}:"): + fail(f"muster's approval must not carry {other} when {key} is expected") + got = block(release, f" {key}:") + return [l.strip() for l in got.split("\n")[1:] if l.strip()] + + dedicated = ["--set", "backstage.oidcClientId=platform-portal"] + if clients(dedicated) != ["- platform-portal"]: + fail(f"a dedicated portal client must be muster's one trusted client, got {clients(dedicated)}") + helpers = open(os.path.join(META_DIR, "templates", "_helpers.tpl")).read() + if re.search(r'set \$\w+ "handoffClients"', helpers): + fail("the chart must render handoffClients from no floor: below the trusted-clients floor a muster issues handoff tickets without the workload review; only an own list may carry the earlier name") + if clients(dedicated, handoff) or clients(dedicated, handoff, "handoffClients"): + fail("below the trusted-clients floor muster must list no trusted client under either name: that muster issues handoff tickets without the workload review") + for args, why in ( + ([], "the portal on the shared client"), + (["--set", "backstage.oidcClientId=platform"], "backstage.oidcClientId equal to the shared client"), + (dedicated + ["--set", "backstage.signInHandoff=false"], "backstage.signInHandoff false"), + (dedicated + ["--set", "components.backstage.enabled=false"], "the portal off"), + ): + if clients(args): + fail(f"{why}: no trusted client expected, got {clients(args)}") + if clients(dedicated, FLOOR_RANGE) or clients(dedicated, FLOOR_RANGE, "handoffClients"): + fail("below the floors muster must list no trusted client") + own = clients(dedicated + ["--set", "muster.muster.approval.trustedClients[0]=platform-portal"]) + if own != ["- platform-portal"]: + fail(f"an own trustedClients list naming the portal's client must stand, got {own}") + own = clients(dedicated + ["--set", "muster.muster.approval.handoffClients[0]=platform-portal"], key="handoffClients") + if own != ["- platform-portal"]: + fail(f"an own handoffClients list (the earlier name) must stand, got {own}") + if clients(dedicated + ["--set-json", "muster.muster.approval.trustedClients=[]"]): + fail("an own empty trustedClients list must stand (no trusted client)") + for key in ("trustedClients", "handoffClients"): + err = render(META_DIR, META + ["--set", trusted, *PORTAL_CLIENT, "--set", f"muster.muster.approval.{key}[0]=platform"], expect_fail=True) + if f'{key} lists "platform", the platform\'s shared OAuth client' not in err: + fail(f"a {key} list naming the shared client must fail the render:\n{err}") + # IA-06: only the portal's dedicated client may be trusted; any other id + # (a client people sign in to with tokens of their own) fails, in an own + # list and through backstage.oidcClientId alike. + for args, client, key in ( + (dedicated + ["--set", "muster.muster.approval.trustedClients[0]=dex-k8s-authenticator"], "dex-k8s-authenticator", "trustedClients"), + (dedicated + ["--set", "muster.muster.approval.trustedClients[0]=platform-portal", "--set", "muster.muster.approval.trustedClients[1]=kubectl-gs"], "kubectl-gs", "trustedClients"), + (dedicated + ["--set", "muster.muster.approval.handoffClients[0]=muster-cli"], "muster-cli", "handoffClients"), + (["--set", "muster.muster.approval.handoffClients[0]=muster-cli"], "muster-cli", "handoffClients"), + (["--set", "muster.muster.approval.trustedClients[0]=other-portal"], "other-portal", "trustedClients"), + ): + err = render(META_DIR, META + ["--set", trusted, *PORTAL_CLIENT, *args], expect_fail=True) + if f'{key} lists "{client}", which is not the portal\'s own OAuth client' not in err: + fail(f"{args}: a {key} list naming {client} must fail the render:\n{err}") + # Below the floor an explicit list fails too (it would trust a client of a + # muster that issues handoff tickets without the workload review). + for key in ("trustedClients", "handoffClients"): + for floor in (handoff, FLOOR_RANGE): + err = render(META_DIR, META + ["--set", floor, *PORTAL_CLIENT, *dedicated, "--set", f"muster.muster.approval.{key}[0]=platform-portal"], expect_fail=True) + if f"muster.muster.approval.{key} is set, but muster is below agent-platform.muster.trustedClientsFloor" not in err: + fail(f"an explicit {key} list below the trusted-clients floor must fail the render:\n{err}") + if clients(dedicated + ["--set-json", "muster.muster.approval.trustedClients=[]"], handoff): + fail("an own empty trustedClients list below the floor must render no trusted client") + rel = doc(render_meta(["--set", trusted, *PORTAL_CLIENT, *dedicated]), "HelmRelease", "backstage") or "" + if "key: portal-dex-client-secret" not in rel or "optional: true" not in rel: + fail("the backstage release must mount the portal's own client secret (portal-dex-client-secret, optional)") + print("ok: muster.approval.trustedClients is the portal's dedicated client from the trusted-clients floor (none below it, under either name; none on the shared client, with signInHandoff false, the portal off or below the floors), an own list under either name naming it stands, the shared client and any other client fail") + + +def check_approval_decider() -> None: + """From the trusted-clients floor, while muster trusts the portal's + client, muster-approval-decider binds the portal's ServiceAccount only, + and the portal's pod projects its token for audience muster where its + muster backend reads it (IA-01).""" + trusted = f"components.muster.versionRange=>={TEST_FLOORS['muster.trustedClientsFloor']} <6.0.0-0" + handoff = BELOW_TRUSTED + dedicated = ["--set", "backstage.oidcClientId=platform-portal"] + + def decider(args: list[str]) -> str: + return block(muster_release([*PORTAL_CLIENT, *args]), " approvalDecider:") + + def backstage(args: list[str]) -> str: + return doc(render_meta([*PORTAL_CLIENT, *args]), "HelmRelease", "backstage") or "" + + got = decider(["--set", trusted, *dedicated]) + want = "\n".join([ + " approvalDecider:", + " subjects:", + " - kind: ServiceAccount", + " name: backstage", + " namespace: default", + ]) + if got.rstrip() != want: + fail(f"muster-approval-decider must bind the portal's ServiceAccount only, want:\n{want}\ngot:\n{got}") + moved = decider(["--set", trusted, *dedicated, "--set", "components.backstage.targetNamespace=portal", "--set", "backstage.name=portal-sa"]) + if "name: portal-sa" not in moved or "namespace: portal" not in moved: + fail(f"the subject must follow the portal's ServiceAccount name and namespace:\n{moved}") + own = decider(["--set", trusted, *dedicated, "--set", "muster.rbac.approvalDecider.subjects[0].kind=ServiceAccount", "--set", "muster.rbac.approvalDecider.subjects[0].name=other", "--set", "muster.rbac.approvalDecider.subjects[0].namespace=x"]) + if "name: other" not in own or "name: backstage" in own: + fail(f"an own approvalDecider list must stand:\n{own}") + # A portal deployed as its own release (components.backstage off): the + # platform binds nobody, and an installation names the portal's + # ServiceAccount and its client itself; both lists stand, and the portal + # projects its token on its own. + separate = ["--set", trusted, *dedicated, "--set", "components.backstage.enabled=false"] + if decider(separate): + fail("a portal outside the platform: no approvalDecider subjects expected") + own_sa = ["--set", "muster.rbac.approvalDecider.subjects[0].kind=ServiceAccount", "--set", "muster.rbac.approvalDecider.subjects[0].name=backstage", "--set", "muster.rbac.approvalDecider.subjects[0].namespace=backstage"] + rel = muster_release([*PORTAL_CLIENT, *separate, *own_sa, "--set", "muster.muster.approval.trustedClients[0]=platform-portal"]) + if "namespace: backstage" not in block(rel, " approvalDecider:") or "- platform-portal" not in block(rel, " trustedClients:"): + fail(f"a portal outside the platform: an own approvalDecider list and trustedClients list must stand:\n{rel}") + if "muster-workload-token" in render_meta([*PORTAL_CLIENT, *separate, *own_sa]): + fail("a portal outside the platform: the platform projects no workload token") + for kind in ("Group", "User"): + err = render_meta_fail([*PORTAL_CLIENT, *separate, "--set", f"muster.rbac.approvalDecider.subjects[0].kind={kind}", "--set", "muster.rbac.approvalDecider.subjects[0].name=admins"]) + if "muster.rbac.approvalDecider.subjects" not in err or "ServiceAccount" not in err: + fail(f"an approvalDecider subject of kind {kind} must fail the render naming the key:\n{err}") + second_group = ["--set", "muster.rbac.approvalDecider.subjects[1].kind=Group", "--set", "muster.rbac.approvalDecider.subjects[1].name=admins"] + for args, why in ( + ([*separate, *own_sa, *second_group], "a ServiceAccount and a Group, the portal outside the platform"), + (["--set", trusted, *dedicated, *own_sa, *second_group], "a ServiceAccount and a Group, the portal on"), + ([*separate, "--set", "muster.rbac.approvalDecider.subjects[0].name=backstage"], "an entry without a kind"), + ): + err = render_meta_fail([*PORTAL_CLIENT, *args]) + if "muster.rbac.approvalDecider.subjects" not in err: + fail(f"{why} must fail the render naming the key:\n{err}") + # The portal chart's own projection, or an own volume of that name, beside + # the platform's would declare the volume twice. + for args in (["--set", "backstage.backstage.musterWorkloadToken.enabled=true"], + ["--set", "backstage.backstage.extraVolumes[0].name=muster-workload-token", "--set", "backstage.backstage.extraVolumes[0].emptyDir.medium=Memory"], + ["--set", "backstage.backstage.extraVolumeMounts[0].name=muster-workload-token", "--set", "backstage.backstage.extraVolumeMounts[0].mountPath=/x"]): + err = render_meta_fail([*PORTAL_CLIENT, "--set", trusted, *dedicated, *args]) + if "muster-workload-token" not in err and "musterWorkloadToken" not in err: + fail(f"a second projection of the workload token must fail the render ({args}):\n{err}") + for args, why in ( + (["--set", trusted], "the portal on the shared client (no trusted client)"), + (["--set", trusted, *dedicated, "--set", "backstage.signInHandoff=false"], "signInHandoff false"), + (["--set", handoff, *dedicated], "below the trusted-clients floor"), + (["--set", trusted, *dedicated, "--set-json", "muster.muster.approval.trustedClients=[]"], "an own empty trustedClients list"), + ): + if decider(args): + fail(f"{why}: no approvalDecider subjects expected") + if "muster-workload-token" in backstage(args): + fail(f"{why}: no workload token projected into the portal") + rel = backstage(["--set", trusted, *dedicated]) + for want in ("name: muster-workload-token", "audience: muster", "path: token", "expirationSeconds: 3600", + "mountPath: /var/run/secrets/muster.giantswarm.io/serviceaccount", + "name: idp-ca", "mountPath: /etc/agent-platform/idp-ca"): + if want not in rel: + fail(f"the backstage release must project the portal's workload token beside its own volumes ({want!r} missing):\n{rel}") + print("ok: muster-approval-decider binds the portal's ServiceAccount only (name and namespace following the portal, an own list standing, also for a portal outside the platform, a subject other than a ServiceAccount failing) and the portal projects its token for audience muster where its muster backend reads it, beside its own volumes; none without a trusted client or below the trusted-clients floor") + + +def check_portal_client_app_config() -> None: + """The connectivity chart's app-config signs the portal in with + backstage.oidcClientId and its own secret env, and requests the platform + client's audience on top of extraScopes; the shared client renders as + before.""" + base = CONN + ["--set", "components.backstage.enabled=true", "--set", "backstage.parentRefs[0].name=x"] + + def cfg(args: list[str]) -> str: + out = render(CONN_DIR, base + args) + cm = doc(out, "ConfigMap", "agent-platform-backstage-app-config") + if cm is None: + fail(f"no backstage app-config with {args}") + return cm + + shared = cfg([]) + if "clientId: platform\n" not in shared or "${AGENT_PLATFORM_OIDC_CLIENT_SECRET}" not in shared or "audience:server:client_id:platform\n" in shared: + fail(f"the shared client must render as before:\n{shared}") + own = cfg(["--set", "backstage.oidcClientId=platform-portal"]) + if "clientId: platform-portal\n" not in own or "${AGENT_PLATFORM_PORTAL_OIDC_CLIENT_SECRET}" not in own: + fail(f"a dedicated client must sign in with its id and its own secret env:\n{own}") + if "- audience:server:client_id:platform\n" not in own or "- audience:server:client_id:dex-k8s-authenticator\n" not in own: + fail(f"a dedicated client must request the platform client's audience on top of extraScopes:\n{own}") + bare = cfg(["--set", "backstage.oidcClientId=platform-portal", "--set-json", "backstage.extraScopes=[]"]) + if "audience:server:client_id:" in bare: + fail(f"empty extraScopes (a provider without Dex's cross-client scopes) must stay empty:\n{bare}") + print("ok: the portal signs in with backstage.oidcClientId and AGENT_PLATFORM_PORTAL_OIDC_CLIENT_SECRET, requesting the platform client's audience; the shared client renders as before") + + +def render_meta_fail(args: list[str]) -> str: + return render(META_DIR, META + args, expect_fail=True) + + +if __name__ == "__main__": + META_DIR, CONN_DIR = sys.argv[1], sys.argv[2] + governance_floor(META_DIR) + check_unset_floors_keep_everything_off() + check_floor_dependencies() + _tmp = tempfile.mkdtemp(prefix="verify-tool-approval-") + atexit.register(shutil.rmtree, _tmp, True) + META_DIR = with_test_floors(META_DIR, _tmp) + FLOOR_RANGE = f"components.muster.versionRange=>={governance_floor(META_DIR)} <6.0.0-0" + check_governance() + check_write_like() + check_coverage() + check_approval_config() + check_handoff_clients() + check_approval_decider() + check_portal_client_app_config() + check_connector_admin() + check_binder() + check_agent_manager_tool_approval() + check_default_agent_release_readable() + check_default_agent_on_remote_target() + check_session_bindings() + check_approval() diff --git a/tests/verify-workspace-manager.py b/tests/verify-workspace-manager.py index f3dde383..1294fb9c 100755 --- a/tests/verify-workspace-manager.py +++ b/tests/verify-workspace-manager.py @@ -241,6 +241,9 @@ def golden(meta: str, connectivity: str) -> None: """With the switch off, the renders are byte-identical to the same chart's renders without the component: its roster entry and its blocks removed (a Helm null).""" absent = [x for key in (f"components.{NAME}", NAME, "workspaceManager", "workspaces") for x in ("--set", f"{key}=null")] + # The meta chart's governedServers.workspace-manager too: without its roster + # entry the source would read as an installation's own server key. + absent_meta = [*absent, "--set", f"governedServers.{NAME}=null"] shapes = [ (meta, ["-f", f"{meta}/ci/ci-values.yaml"]), (meta, []), @@ -250,7 +253,7 @@ def golden(meta: str, connectivity: str) -> None: ] for chart, flags in shapes: head = helm(chart, flags, ci_values=False) - ref = helm(chart, [*flags, *absent], ci_values=False) + ref = helm(chart, [*flags, *(absent_meta if chart == meta else absent)], ci_values=False) if head != ref: with tempfile.NamedTemporaryFile("w", suffix=".ref") as a, tempfile.NamedTemporaryFile("w", suffix=".head") as b: a.write(ref), b.write(head), a.flush(), b.flush() @@ -424,6 +427,12 @@ def main(meta: str, connectivity: str) -> int: if want not in apps: fail(f"switching workspaces on did not derive muster's github provider App ({want.strip()!r}) onto {key}:\n{apps}") on = on.replace(apps, "", 1) + # And muster governs the component's server (muster.governance + # .governedServers, tests/verify-tool-approval.py): one entry. + governed = re.compile(r"^ - role: workspaceManager\n(?: .*\n)*", re.M) + if len(governed.findall(on or "")) != 1 or governed.search(doc): + fail(f"switching workspaces on must add one governedServers entry for its server to {key}") + on = governed.sub("", on or "") if on != doc: fail(f"switching workspaces on changed {key} (muster.* included)") if any(kind == "MCPServer" for kind, _ in on_docs):