diff --git a/definitions/agent-platform/README.md b/definitions/agent-platform/README.md index 69f6556b..1e40d9e2 100644 --- a/definitions/agent-platform/README.md +++ b/definitions/agent-platform/README.md @@ -5,7 +5,7 @@ policy decides once, and what the definition drops. The render library reads it. | File | What it is | |---|---| -| `schema.json` | JSON Schema (draft 2020-12, `additionalProperties: false`) of the inputs: the record under `installation` (read, never typed) and the ten choices, `modelServing.enabled` (default false), the singletons' placement, `scheduling.singletonsCapacity` (`any`, the default, or `on-demand`), the in-cluster MCP backends the network policy fences, `networkPolicy.mcpBackends` (default none), the LLM listener's rate limits, `llmRouting.rateLimits` (default none), with the comment above them, `llmRouting.rateLimitsComment`, how long an idle agent Session and its workspace directory live, `sessions.idleTTL` (default none, the chart's), the portal's AI chat, `aiChat.enabled` (default false) with `aiChat.model` and `aiChat.provider` (`anthropic` or `vertex`, with `aiChat.google.project` and `location`), the portal's skill repositories, `skills.repositories` (default none), the portal's Hive section, `hive.enabled` (default false) with its repositories and board, the managers' commit modes, `clusterManager.github.enabled`, `modelManager.github.enabled` and `agentManager.github.enabled` (each default false), the bots whose posts reach the chat gateway's thread context, `klausGateway.slack.contextBotIDs` (default none), with the comment above them, `klausGateway.slack.contextBotIDsComment`, the bots admitted by their Slack profile name, `klausGateway.slack.contextBotNames` (default none), with the comment above them, `klausGateway.slack.contextBotNamesComment`, the Agent Platform organizations, `organizations.enabled` (default false) with `organizations.apiHostnames` (default none), `organizations.commit.enabled` and `organizations.portal.enabled` (each default false), the platform tenant's bindings, `tenants.platform.users`, `tenants.platform.editors` and `tenants.platformTeam`, and muster's MCP-server viewers, `musterMcpServerViewers` (each default unset, the chart's), and the version holds, `versions.chart` and `versions.components.` (each default none), with their reasons, `versions.reasons.chart` and `versions.reasons.components.` (the comment above the hold, default none). Every leaf carries `x-source`, `x-feature` and `x-renders`; a choice carries `x-readback`, the file — one, or several, the first on record holding the key answering — and key it is read back from, and the kind where it is not the key's value (`present`, `host`, `installation`, `comment`, `entries`, `file`). A choice that renders only under a switch carries `x-requires`, the switch's key: typed other than its default with the switch off, it is refused; read back, it renders nothing. `x-files` names each file's path, `` the installation and `` the installation hosting the portal the platform's portal section is written into, so a portal choice is read back where the section is rendered, whichever installation's plan reads it. | +| `schema.json` | JSON Schema (draft 2020-12, `additionalProperties: false`) of the inputs: the record under `installation` (read, never typed) and the ten choices, `modelServing.enabled` (default false), the singletons' placement, `scheduling.singletonsCapacity` (`any`, the default, or `on-demand`), the in-cluster MCP backends the network policy fences, `networkPolicy.mcpBackends` (default none), the LLM listener's rate limits, `llmRouting.rateLimits` (default none), with the comment above them, `llmRouting.rateLimitsComment`, how long an idle agent Session and its workspace directory live, `sessions.idleTTL` (default none, the chart's), the portal's AI chat, `aiChat.enabled` (default false) with `aiChat.model` and `aiChat.provider` (`anthropic` or `vertex`, with `aiChat.google.project` and `location`), the portal's skill repositories, `skills.repositories` (default none), the portal's Hive section, `hive.enabled` (default false) with its repositories and board, the managers' commit modes, `clusterManager.github.enabled`, `modelManager.github.enabled` and `agentManager.github.enabled` (each default false), the skill-manager's sources, `skillManager.sources` (default none), and the GitHub App it reads them with, `skillManager.github.app.secretName` (default none), the platform-shipped default agent, `defaultAgent.enabled` (default true) and `defaultAgent.modelConfig` (default none), the bots whose posts reach the chat gateway's thread context, `klausGateway.slack.contextBotIDs` (default none), with the comment above them, `klausGateway.slack.contextBotIDsComment`, the bots admitted by their Slack profile name, `klausGateway.slack.contextBotNames` (default none), with the comment above them, `klausGateway.slack.contextBotNamesComment`, the Agent Platform organizations, `organizations.enabled` (default false) with `organizations.apiHostnames` (default none), `organizations.commit.enabled` and `organizations.portal.enabled` (each default false), the platform tenant's bindings, `tenants.platform.users`, `tenants.platform.editors` and `tenants.platformTeam`, and muster's MCP-server viewers, `musterMcpServerViewers` (each default unset, the chart's), and the version holds, `versions.chart` and `versions.components.` (each default none), with their reasons, `versions.reasons.chart` and `versions.reasons.components.` (the comment above the hold, default none). Every leaf carries `x-source`, `x-feature` and `x-renders`; a choice carries `x-readback`, the file — one, or several, the first on record holding the key answering — and key it is read back from, and the kind where it is not the key's value (`present`, `host`, `installation`, `comment`, `entries`, `file`). A choice that renders only under a switch carries `x-requires`, the switch's key: typed other than its default with the switch off, it is refused; read back, it renders nothing. `x-files` names each file's path, `` the installation and `` the installation hosting the portal the platform's portal section is written into, so a portal choice is read back where the section is rendered, whichever installation's plan reads it. | | `policy.yaml` | The fleet's decisions, keyed by the owning organisation: which components its installations run, the chat gateway's shape, the connector names a target's Dex registers for a hub (the organisation's plain name for the target's first hub of the organisation, the hub's own for every further one; `fromBase` names the organisations whose hubs' connectors the fleet's Dex base registers, which no target renders), the Teleport cluster and the poll interval of every OCIRepository the definition renders (`flux.sourceInterval`) — and, keyed by installation, where a Slack app exists, which is where the gateway runs, with the installation's own default agent, and which stage and organisations run the platform's release candidates. | | `removals.yaml` | Keys an enabled installation carries today that the definition does not render, each with the reason it is dropped: the template renders it, it becomes a referenced Secret, the platform does not read it, the customer-portal definition owns it, or it is a named migration (M12…) of a former input. A key of kind `kept` is not dropped: its replacement is not on the fleet yet (muster's trusted issuers the shared defaults do not derive, a connector pin, muster's provider token refresh threshold, the kagent controller's and the Postgres instances' on-demand pin, the kagent UI's ingress peer, tuned resources, the installation's own Postgres databases with the kagent controller's mount of its fresh database, kagent's Harnesses, the toolchain-manager's switch and values with the kagent controller's tool image egress origins), so the plan carries it from the record into the render, comments included, and the comparison finds it as defined; the reason says what has to land before the key goes. A removal with `keptWhile` is kept the same way only while the render carries that path: the default ModelConfig's model pin and display name and the inlined ModelConfigs stay while the render carries `kagent.providers`, and go with M43 once it does not. The configmap patch is rendered whole, not edited: a hand-written key no input renders and no `kept` entry names, nested under a rendered block or not, is drift, and a reconcile removes it. | | `migrations.yaml` | Keys the definition renders that an installation enabled before a migration lacks (a referenced client Secret, the hub's token-exchange client in a spoke's Dex, the portal's Component, the edge's JWT provider, …), each with the migration that adds it: a leaf the record lacks under one of them is a planned change, not drift; so is a comma-separated scalar (kagent's `oidc-extra-audience`) whose only change is entries named as `[]`. | @@ -37,6 +37,8 @@ policy decides once, and what the definition drops. The render library reads it. | The cluster-manager's commit mode (`cluster-manager.github.enabled`: registered with muster pinned to its GitHub App, `mode: commit` on `create_node_pool` and `delete_node_pool`, the pull request opened as the person) and its egress to `api.github.com` | one choice, `clusterManager.github.enabled`, read back from the key; where the policy runs the cluster-manager only. The App's OAuth client is the installation's own Secret `giantswarm-cluster-manager-oauth-client`, not rendered | | The model-manager's and the agent-manager's commit mode (`model-manager.github.enabled`, `agent-manager.github.enabled`: each registered with muster pinned to its own GitHub App, `giantswarm-model-manager` and `giantswarm-agent-manager`, `mode: commit` on their write tools, the pull request opened as the person in the repository that owns the target namespace); their egress to `api.github.com` is the connectivity chart's | one choice each, `modelManager.github.enabled` (the 4 chart line only) and `agentManager.github.enabled` (where the policy runs the agent-manager only), read back from the key. Each App's OAuth client is the installation's own Secret, `giantswarm-model-manager-oauth-client` and `giantswarm-agent-manager-oauth-client`, not rendered | | The agent-manager's skill catalog (`agent-manager.skills.repositories`, the repositories `list_skills` discovers for meta agents; `agent-manager.skills.github.app.secretName`, the read-only skills GitHub App's Secret discovery and pinning run with, a private repository offered only to the people who can read it; `agent-manager.skills.gitAuthSecretName`, the Secret in kagent every agent with a git skill boots with, or `agent-manager.skills.mintGitAuthSecret`, that Secret minted from the skills App by agent-manager) | `agentManager.skills.{repositories,github.app.secretName,gitAuthSecretName,mintGitAuthSecret}`, each written only when chosen and read back from the configmap patch; both named Secrets are the installation's own and exist before their names are set, since a missing one stops the pod; minting needs `github.app.secretName` and replaces `gitAuthSecretName`; refused where the fleet policy runs no agent-manager | +| The skill-manager's sources (`skillManager.sources`, the meta chart's component `skill-manager`, which follows the agent-manager: the repositories it lists and pins skills from, after the platform's own `skills/`; the portal offers the same) and the read-only skills GitHub App it reads them with (`skill-manager.github.app.secretName`, a private source listed only to the people who can read it) | two choices. `skillManager.github.app.secretName`, the installation's Secret in the skill-manager's namespace, which exists before its name is set, since a missing one stops the pod; default none (anonymous reads, public sources only). `skillManager.sources`, each an http(s) URL or `{url, ref, path, readOnly}`, written as read with every key kept, default none (the chart's list, giantswarm/agent-skills, stands; a list replaces it, so it names agent-skills to keep it); read back from the configmap patch. No entry names the platform's own repository (the meta chart lists it first, read-only, `skills.platformSource`), and `agentManager.skills.repositories` is refused beside the list (the meta chart takes both, but this definition keeps one list: one reconcile sets the sources and empties the agent-manager's list), where a `versions.components.agent-manager` hold puts the agent-manager at 2.24.0 or later (it then takes its skills from the skill-manager and the meta chart fails on the list; the chart's default range starts below), and, from the release with the skill-manager on, with an entry naming the platform's own repository. Both inputs: the 4 chart line only, where the fleet policy runs the agent-manager, with no `versions.chart` hold below the release with the skill-manager (4.179.0, giantswarm/agent-platform#1265). The object form is the skill-manager's; `agentManager.skills.repositories` stays URLs | +| The default agent, the meta agent the meta chart ships (`components.default-agent`, in `kagent`, the platform's skills pinned to the release) | `defaultAgent.enabled`, default true, the chart's default: nothing is written; false writes `components.default-agent.enabled: false`. `defaultAgent.modelConfig` writes `defaultAgent.modelConfig`, the ModelConfig it answers with; none: the agent gets a model by itself only where the agent-manager's version range (a `versions.components.agent-manager` hold, else the meta chart's default, `>=2.22.0` on 4.179.0) starts at 2.24.0 or later, where the meta chart has agent-manager set the installation's default model once while the agent has none; anywhere else set it, or the agent has no model and kagent reports it not ready (`Compatible=False`, `kagent ModelConfig is required`). Both read back from the configmap patch. Off and the override: the 4 chart line only, where the fleet policy runs kagent and the agent-manager. Off: any chart release (`components` is open). The override: no chart hold below the release shipping the agent (4.179.0, giantswarm/agent-platform#1265). Agents an installation keeps under `extras/agent-platform/agents/` stay kept, not rendered. Set `enabled: false` on an installation that still runs a hand-added meta agent (gazelle's `swarm-operator`) before upgrading to that release | | The Agent Platform organizations (the meta chart 4.176.6 and later, giantswarm/giantswarm#38891): `agentPlatformOrganizations.enabled` — agent-platform-operator, the organizations' role, admission policies and access, agent-manager's organization tools, whose `tenants.enabled` the chart derives from the switch — with `agentPlatformOrganizations.apiHostnames`, the installation's API hostnames beside the derived `api.`; in commit mode agent-manager's `tenants.commit` (the installation's management-clusters repository as the registry names it, `installation.repositories.managementClusters`, the policy's branch, `objectsPath` `management-clusters//extras/agent-platform-organizations/objects` and `contentPrefix` `.../content`) and, together with it and never alone, the operator's Flux values `agentPlatformOrganizations.fluxNamespace`, `fluxSource`, `fluxDecryptionSecret` (the policy's `organizations.flux`) and `fluxPathPrefix` (`./` and the content prefix and `/`), with the operator's `commitMode.installationKustomization`, the installation's Kustomization in the Flux namespace that applies the objects (the policy's `organizations.installationKustomization`). The installation's repository layout (that Kustomization, `objects/kustomization.yaml`, CODEOWNERS and SOPS) is the installation's own, not rendered | `organizations.enabled` (the 4 chart line, where the policy runs kagent; a hold of the meta chart below 4.176.6 is refused), `organizations.apiHostnames` and `organizations.commit.enabled` (each written only with the switch, so turning it off takes them along; commit mode refused where the policy runs no agent-manager, where the registry names no management-clusters repository or under a hold of the meta chart below 4.177.0, the first release with giantswarm/agent-platform#1312; either dependent typed with the switch off is refused, naming the switch, by the schema's `x-requires`), read back from the configmap patch on record — commit mode as the presence of `agent-manager.tenants.commit.repository` — so a reconcile keeps them and no `kept` entry is needed. The meta chart refuses `agent-manager.tenants.commit` before 4.177.0 (giantswarm/agent-platform#1312), so commit mode is turned on only where the installation runs that release or a later one; agent-manager's credential form (`agent-manager.credentials.uiURL`) and its token exchange (`agent-manager.githubTokenExchange`) are not these inputs' | | Who the platform tenant binds in the kagent namespace and who lists muster's MCP servers (giantswarm/agent-platform#706, #1331): `tenants.platform.users` (`agent-platform:platform-user`), `tenants.platform.editors` and `tenants.platformTeam` (`agent-platform:editor`; the meta chart also adds the platform team to muster's `mcpserver-editor` and `workflow-editor` subjects), and `musterMcpServerViewers` (the Role and RoleBinding `agent-platform:mcpserver-viewer` in muster's namespace; unset, the chart falls back to `tenants.platform.users`). Each list in the chart's subject shape (`apiGroup`, `kind`, `name`, `namespace`) | `tenants.platform.users`, `tenants.platform.editors`, `tenants.platformTeam` and `musterMcpServerViewers`, each unset by default: the key is not written and the chart's default stands. An empty list is written as `[]` and binds nobody: the retirement of the platform tenant (giantswarm/giantswarm#38990) sets the viewers, then types the users and editors as `[]`, since a removed key brings the chart's default back. Typed `null`, a list goes and the default comes back. Read back from the configmap patch on record, an empty list too, so a reconcile keeps them and no `kept` entry is needed. Refused: off the 4 chart line; under a hold of the meta chart below 4.132.0-rc.1 (`tenants.*`) or 4.178.0-rc.4 (`musterMcpServerViewers`); the users or editors where the policy runs no kagent; a subject a RoleBinding cannot carry; and, with `organizations.enabled`, no viewer — the viewers empty, or the users empty while the viewers are unset — which the meta chart refuses (`agent-platform.muster.organizations`) | | The stateful singletons' placement (`scheduling.singletons.nodeSelector` `karpenter.sh/capacity-type: on-demand`: muster, muster-valkey, the kagent controller and klaus-gateway off spot capacity, whose reclaim takes muster's token store away for minutes) | one choice, `scheduling.singletonsCapacity: on-demand`, read back from the key; a capa installation only, whose Karpenter NodePool admits on-demand | diff --git a/definitions/agent-platform/features.yaml b/definitions/agent-platform/features.yaml index 762657e1..96b8b633 100644 --- a/definitions/agent-platform/features.yaml +++ b/definitions/agent-platform/features.yaml @@ -72,6 +72,9 @@ features: - {id: kagent-providers, kind: configmap, key: kagent.providers} - {id: kagent-model-configs, kind: configmap, key: kagent.modelConfigs} - {id: singletons-placement, kind: configmap, key: scheduling.singletons} + - {id: skill-manager-sources, kind: configmap, key: "skillManager.sources (the skill-manager's skill sources)"} + - {id: skill-manager-github-app, kind: configmap, key: "skill-manager.github.app.secretName (the skill-manager's GitHub App Secret)"} + - {id: default-agent, kind: configmap, key: "components.default-agent / defaultAgent (the platform-shipped default agent: off, and its ModelConfig)"} - {id: organizations, kind: configmap, key: "agentPlatformOrganizations / agent-platform-operator.commitMode / agent-manager.tenants (the organizations' switch, their API hostnames and commit mode)"} - {id: patch-top-level-keys, kind: configmap, catchAll: true, key: the patch's top-level keys (every key no other dimension names)} - {id: chart-line-on-record, kind: record, key: config.yaml.patch agentPlatform.kagentApiV2 (the meta chart line the record selects; an enable or a reconcile writes the policy's line)} diff --git a/definitions/agent-platform/schema.json b/definitions/agent-platform/schema.json index 577f6dcb..ba3c9c5b 100644 --- a/definitions/agent-platform/schema.json +++ b/definitions/agent-platform/schema.json @@ -492,7 +492,7 @@ "x-readback": {"file": "configmap", "key": "agent-manager.skills.repositories"}, "x-feature": "runtime", "x-renders": ["configmap:agent-manager.skills.repositories"], - "description": "The GitHub repositories agent-manager's list_skills discovers skills in (agent-manager.skills.repositories), the catalog meta agents create agents from. None, the key is not written and the chart's default (giantswarm/agent-skills) stands. Read back from the configmap patch on record." + "description": "The GitHub repositories agent-manager's list_skills discovers skills in (agent-manager.skills.repositories), the catalog meta agents create agents from. None, the key is not written and the chart's default (giantswarm/agent-skills) stands. Refused beside skillManager.sources (the meta chart takes both, but this definition keeps one list: move it into skillManager.sources and empty it in the same reconcile), where a versions.components.agent-manager hold puts the agent-manager at 2.24.0 or later (it then takes its skills from the skill-manager, and the meta chart fails on the list), and, from the release with the skill-manager on, an entry naming the platform's own repository. Read back from the configmap patch on record." }, "github": { "type": "object", @@ -552,6 +552,88 @@ } } }, + "skillManager": { + "type": "object", + "additionalProperties": false, + "description": "Two choices: the skill-manager's skill sources and the GitHub App it reads them with.", + "properties": { + "github": { + "type": "object", + "additionalProperties": false, + "properties": { + "app": { + "type": "object", + "additionalProperties": false, + "properties": { + "secretName": { + "type": "string", + "default": "", + "maxLength": 253, + "pattern": "^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$", + "x-source": "person", + "x-readback": {"file": "configmap", "key": "skill-manager.github.app.secretName"}, + "x-feature": "runtime", + "x-renders": ["configmap:skill-manager.github.app.secretName"], + "description": "The installation's Secret in the skill-manager's namespace (agent-platform unless the component is moved) holding the read-only skills GitHub App's app-id, installation-id and private-key (skill-manager.github.app.secretName): the skill-manager lists and pins skills with the App's installation tokens and lists a private source only to the people who can read it. The Secret exists before this is set: a missing one stops the pod. Empty, anonymous reads, public sources only. The 4 chart line only, where the fleet policy runs the agent-manager, with no versions.chart hold below the release with the skill-manager (4.179.0). Read back from the configmap patch on record." + } + } + } + } + }, + "sources": { + "type": "array", + "items": { + "oneOf": [ + {"type": "string", "pattern": "^https?://\\S+$"}, + { + "type": "object", + "additionalProperties": false, + "required": ["url"], + "properties": { + "url": {"type": "string", "pattern": "^https?://\\S+$"}, + "ref": {"type": "string"}, + "path": {"type": "string"}, + "readOnly": {"type": "boolean"} + } + } + ] + }, + "default": [], + "x-source": "person", + "x-readback": {"file": "configmap", "key": "skillManager.sources"}, + "x-feature": "runtime", + "x-renders": ["configmap:skillManager.sources"], + "description": "The skill sources the skill-manager lists and pins skills from (the meta chart's skillManager.sources), after the platform's own: each a GitHub repository URL, or {url, ref, path, readOnly} (a branch, tag or commit, the directory scanned, the read-only mark); never the platform's own repository, which the meta chart lists first (skills.platformSource). agentManager.skills.repositories is refused beside it: the meta chart takes both, but this definition keeps one list, so one reconcile sets this list and empties the agent-manager's. Written as read, every key kept. None, the key is not written and the chart's list (giantswarm/agent-skills) stands; a list replaces it, so it names agent-skills to keep it. The 4 chart line only, where the fleet policy runs the agent-manager, with no versions.chart hold below the release with the skill-manager (4.179.0). Read back from the configmap patch on record." + } + } + }, + "defaultAgent": { + "type": "object", + "additionalProperties": false, + "description": "Two choices: whether the platform-shipped default agent runs, and the ModelConfig it answers with.", + "properties": { + "enabled": { + "type": "boolean", + "default": true, + "x-source": "person", + "x-readback": {"file": "configmap", "key": "components.default-agent.enabled"}, + "x-feature": "runtime", + "x-renders": ["configmap:components.default-agent.enabled"], + "description": "The default agent, the meta agent the meta chart ships (components.default-agent, kagent namespace, with the platform's skills pinned to the release). On, the chart's default: the key is not written. Off, enabled: false is written: set it on an installation that still runs a hand-added meta agent before upgrading to the release with the default agent. Off: the 4 chart line only, where the fleet policy runs kagent and the agent-manager; any chart release takes it (components is open). Read back from the configmap patch on record." + }, + "modelConfig": { + "type": "string", + "default": "", + "maxLength": 253, + "pattern": "^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$", + "x-source": "person", + "x-readback": {"file": "configmap", "key": "defaultAgent.modelConfig"}, + "x-feature": "runtime", + "x-renders": ["configmap:defaultAgent.modelConfig"], + "description": "The ModelConfig in kagent the default agent answers with (defaultAgent.modelConfig). Empty, the key is not written and the agent gets a model by itself only where the agent-manager's version range (components.agent-manager.versionRange: a versions.components.agent-manager hold, else the meta chart's default, >=2.22.0 on 4.179.0) starts at 2.24.0 or later: the meta chart then has agent-manager set the installation's default model once, while the agent has none, and never re-point it. Anywhere else, set it, or the agent has no model and kagent reports it not ready (Compatible=False, kagent ModelConfig is required). Set it to pin or change the model. The 4 chart line only, where the fleet policy runs kagent and the agent-manager, with no versions.chart hold below the release with the default agent (4.179.0). Read back from the configmap patch on record." + } + } + }, "clusterManager": { "type": "object", "additionalProperties": false, diff --git a/internal/installations/readback_test.go b/internal/installations/readback_test.go index 03bebe71..602c8011 100644 --- a/internal/installations/readback_test.go +++ b/internal/installations/readback_test.go @@ -64,6 +64,7 @@ const readBackFilesSchema = `{ const ( keyEnabled = "enabled" keyGitHub = "github" + keyApp = "app" keyRepositories = "repositories" boardRoadmap = "roadmap" keySkills = "skills" @@ -79,6 +80,7 @@ const ( inputTokenBroker = "federation.tokenBroker" inputSignIn = "federation.signInInstallation" inputBroker = "federation.broker" + skillsApp = "acme-skills-app" ) // The read-back fixture: the installation read for, its base domain, its @@ -328,7 +330,9 @@ func TestDefaults(t *testing.T) { "clusterManager": map[string]any{keyGitHub: map[string]any{keyEnabled: false}}, "modelManager": map[string]any{keyGitHub: map[string]any{keyEnabled: false}}, "klausGateway": map[string]any{"slack": map[string]any{"contextBotIDs": []any{}, "contextBotIDsComment": "", "contextBotNames": []any{}, "contextBotNamesComment": "", "slashCommand": "", "slashCommandComment": ""}}, - "agentManager": map[string]any{"githubTokenExchange": map[string]any{keyEnabled: false}, "credentials": map[string]any{"uiURL": ""}, keyGitHub: map[string]any{keyEnabled: false}, keySkills: map[string]any{keyRepositories: []any{}, keyGitHub: map[string]any{"app": map[string]any{"secretName": ""}}, "gitAuthSecretName": "", "mintGitAuthSecret": false}}, + "agentManager": map[string]any{"githubTokenExchange": map[string]any{keyEnabled: false}, "credentials": map[string]any{"uiURL": ""}, keyGitHub: map[string]any{keyEnabled: false}, keySkills: map[string]any{keyRepositories: []any{}, keyGitHub: map[string]any{keyApp: map[string]any{"secretName": ""}}, "gitAuthSecretName": "", "mintGitAuthSecret": false}}, + "defaultAgent": map[string]any{keyEnabled: true, "modelConfig": ""}, + "skillManager": map[string]any{"sources": []any{}, keyGitHub: map[string]any{keyApp: map[string]any{"secretName": ""}}}, "versions": map[string]any{"chart": "", "components": holds, "reasons": map[string]any{"chart": "", "components": holds}}} want["organizations"] = map[string]any{keyEnabled: false, "apiHostnames": []any{}, "commit": map[string]any{keyEnabled: false}, "portal": map[string]any{keyEnabled: false}} @@ -511,6 +515,10 @@ func TestAgentPlatformReadsBackClusterManagerCommit(t *testing.T) { {"commit mode on", "cluster-manager:\n installation:\n name: rowan\n github:\n enabled: true\n", map[string]any{"clusterManager.github.enabled": true}}, {"commit mode not on record", "cluster-manager:\n installation:\n name: rowan\n", map[string]any{}}, {"model-manager and agent-manager commit mode on", "agent-manager:\n github:\n enabled: true\nmodel-manager:\n github:\n enabled: true\n", map[string]any{"modelManager.github.enabled": true, "agentManager.github.enabled": true}}, + {"the default agent on, written by hand", "components:\n default-agent:\n enabled: true\n", map[string]any{"defaultAgent.enabled": true}}, + {"the default agent off with a model override", "components:\n default-agent:\n enabled: false\ndefaultAgent:\n modelConfig: claude-sonnet\n", map[string]any{"defaultAgent.enabled": false, "defaultAgent.modelConfig": "claude-sonnet"}}, + {"skill-manager sources with ref, path and readOnly", "skillManager:\n sources:\n - https://github.com/acme/skills\n - url: https://github.com/acme/platform\n ref: v4.200.0\n path: skills\n readOnly: false\n", map[string]any{"skillManager.sources": []any{"https://github.com/acme/skills", map[string]any{"url": "https://github.com/acme/platform", "ref": "v4.200.0", "path": "skills", "readOnly": false}}}}, + {"skill-manager GitHub App", "skill-manager:\n github:\n app:\n secretName: " + skillsApp + "\n", map[string]any{"skillManager.github.app.secretName": skillsApp}}, //nolint:gosec // a Secret's name in a fixture, no credential {"agent-manager skill catalog with private repositories", "agent-manager:\n skills:\n repositories:\n - https://github.com/acme/skills\n github:\n app:\n secretName: acme-skills-app\n gitAuthSecretName: acme-skills-token\n", map[string]any{"agentManager.skills.repositories": []any{"https://github.com/acme/skills"}, "agentManager.skills.github.app.secretName": "acme-skills-app", "agentManager.skills.gitAuthSecretName": "acme-skills-token"}}, //nolint:gosec // a Secret's name in a fixture, no credential } { read := files(map[string]string{"acme/configs:" + def.EnabledMarker("rowan"): tc.patch}) diff --git a/internal/verify/verify_test.go b/internal/verify/verify_test.go index d4e509c0..23370bfb 100644 --- a/internal/verify/verify_test.go +++ b/internal/verify/verify_test.go @@ -672,11 +672,11 @@ func TestDrivenInputsAreThePersonsAndTheTyped(t *testing.T) { organizationsInputs := []string{"organizations.apiHostnames", "organizations.commit.enabled", "organizations.enabled", "organizations.portal.enabled"} tenantInputs := []string{"tenants.platform.editors", "tenants.platform.users", "tenants.platformTeam"} got, err := drivenInputs(def, Inputs{Values: doc("a.test", "acme", true)}) - if err != nil || !reflect.DeepEqual(got, slices.Concat(agentInputs, chatInputs, []string{commitInput}, hiveInputs, gatewayInputs, llmInputs, []string{modelCommitInput, servingInput, "musterMcpServerViewers", "networkPolicy.mcpBackends"}, organizationsInputs, []string{"scheduling.singletonsCapacity", "sessions.idleTTL", skillsInput}, tenantInputs, versionInputs)) { + if err != nil || !reflect.DeepEqual(got, slices.Concat(agentInputs, chatInputs, []string{commitInput, "defaultAgent.enabled", "defaultAgent.modelConfig"}, hiveInputs, gatewayInputs, llmInputs, []string{modelCommitInput, servingInput, "musterMcpServerViewers", "networkPolicy.mcpBackends"}, organizationsInputs, []string{"scheduling.singletonsCapacity", "sessions.idleTTL", "skillManager.github.app.secretName", "skillManager.sources", skillsInput}, tenantInputs, versionInputs)) { t.Errorf("from the record: %v %v", got, err) } got, err = drivenInputs(def, Inputs{Values: doc("a.test", "acme", true), Typed: doc("b.test", "acme", false)}) - if err != nil || !reflect.DeepEqual(got, slices.Concat(agentInputs, chatInputs, []string{commitInput}, hiveInputs, []string{baseDomainInput, customerInput}, gatewayInputs, llmInputs, []string{modelCommitInput, servingInput, "musterMcpServerViewers", "networkPolicy.mcpBackends"}, organizationsInputs, []string{"scheduling.singletonsCapacity", "sessions.idleTTL", skillsInput}, tenantInputs, versionInputs)) { + if err != nil || !reflect.DeepEqual(got, slices.Concat(agentInputs, chatInputs, []string{commitInput, "defaultAgent.enabled", "defaultAgent.modelConfig"}, hiveInputs, []string{baseDomainInput, customerInput}, gatewayInputs, llmInputs, []string{modelCommitInput, servingInput, "musterMcpServerViewers", "networkPolicy.mcpBackends"}, organizationsInputs, []string{"scheduling.singletonsCapacity", "sessions.idleTTL", "skillManager.github.app.secretName", "skillManager.sources", skillsInput}, tenantInputs, versionInputs)) { t.Errorf("with facts typed: %v %v", got, err) } } diff --git a/render/agentplatform/consumption_test.go b/render/agentplatform/consumption_test.go index 0b7f6860..854c16e8 100644 --- a/render/agentplatform/consumption_test.go +++ b/render/agentplatform/consumption_test.go @@ -589,7 +589,7 @@ func (c *consumption) include(inc render.Include) { } list := "resources" if inc.Component { - list = "components" + list = keyComponents } entries, _ := k[list].([]any) for _, e := range entries { diff --git a/render/agentplatform/hold_admits_test.go b/render/agentplatform/hold_admits_test.go index 5dad19fb..1985ea17 100644 --- a/render/agentplatform/hold_admits_test.go +++ b/render/agentplatform/hold_admits_test.go @@ -42,3 +42,26 @@ func TestBoundedHoldAboveTheModelFreeChartDeclaresNoModels(t *testing.T) { require.NoError(t, err) require.False(t, in.declaresModels()) } + +func TestComponentFloorAtLeast(t *testing.T) { + for _, c := range []struct { + hold string + want bool + }{ + {"", false}, + {">=2.22.0 <3.0.0", false}, + {"~2.22.0", false}, + {"<3.0.0", false}, + {"2.24.0", true}, + {holdAgentManagerViaSkillManager, true}, + {"^2.25.1", true}, + {">=2.24.0-rc.6 <3.0.0", true}, + {"<3.0.0, >=2.24.0", true}, + {"v2.24.0", true}, + {"2.x", false}, + } { + t.Run(c.hold, func(t *testing.T) { + require.Equal(t, c.want, componentFloorAtLeast(c.hold, agentManagerViaSkillManager)) + }) + } +} diff --git a/render/agentplatform/input.go b/render/agentplatform/input.go index 2144f5e7..6d3f87cc 100644 --- a/render/agentplatform/input.go +++ b/render/agentplatform/input.go @@ -45,6 +45,9 @@ const ( componentAgentManager = "agent-manager" componentKlausGateway = "klaus-gateway" componentClusterManager = "cluster-manager" + // componentDefaultAgent is the platform-shipped default agent, + // a meta agent the meta chart runs by default. + componentDefaultAgent = "default-agent" // componentModelManager is no choice of the policy's: the meta chart's 4 // line runs it by default and the definition leaves it on. componentModelManager = "model-manager" @@ -140,6 +143,18 @@ type Input struct { AgentManagerSkills AgentManagerSkills AgentManagerTokenExchange bool AgentManagerCredentialUI string + // SkillManagerSources are the skill-manager's skill sources + // (skillManager.sources) as the person wrote them, read back from the + // configmap patch on record. + SkillManagerSources []SkillSource + // SkillManagerAppSecret is the Secret of the GitHub App the + // skill-manager reads its sources with (skillManager.github.app.secretName), + // read back from the configmap patch on record. + SkillManagerAppSecret string + // DefaultAgent is the person's choice of the platform-shipped + // default agent (defaultAgent.*), read back from the configmap + // patch on record. + DefaultAgent DefaultAgent // Versions are the person's version holds (versions.*), read back from // the record so a reconcile keeps them. Versions Versions @@ -659,6 +674,11 @@ type document struct { UIURL string `json:"uiURL"` } `json:"credentials"` } `json:"agentManager"` + DefaultAgent DefaultAgent `json:"defaultAgent"` + SkillManager struct { + Sources []SkillSource `json:"sources"` + GitHub githubApp `json:"github"` + } `json:"skillManager"` KlausGateway struct { Slack struct { ContextBotIDs []ContextBot `json:"contextBotIDs"` @@ -751,6 +771,66 @@ type githubApp struct { } `json:"app"` } +// DefaultAgent is the meta chart's platform-shipped default agent +// (component default-agent): whether it runs, nil the chart's +// default (on), and the ModelConfig it answers with, empty the chart's. +type DefaultAgent struct { + Enabled *bool `json:"enabled"` + ModelConfig string `json:"modelConfig"` +} + +// disabled is whether the person turned the default agent off. +func (a DefaultAgent) disabled() bool { return a.Enabled != nil && !*a.Enabled } + +// SkillSource is one of the skill-manager's skill sources, in the form the +// person wrote it: a URL alone, or the URL with the ref and the directory +// scanned and the read-only mark. +type SkillSource struct { + URL string `json:"url"` + // Ref, Path and ReadOnly are nil where the entry does not carry them, + // so an entry is written back with the keys it was read with. + Ref *string `json:"ref,omitempty"` + Path *string `json:"path,omitempty"` + ReadOnly *bool `json:"readOnly,omitempty"` + // object is whether the person wrote the entry as an object. + object bool +} + +// UnmarshalJSON reads a URL or an object; the schema has checked the shape. +func (s *SkillSource) UnmarshalJSON(raw []byte) error { + var url string + if err := json.Unmarshal(raw, &url); err == nil { + *s = SkillSource{URL: url} + return nil + } + type plain SkillSource + var p plain + if err := json.Unmarshal(raw, &p); err != nil { + return err + } + *s = SkillSource(p) + s.object = true + return nil +} + +// MarshalYAML writes the entry in the form it was read in. +func (s SkillSource) MarshalYAML() (any, error) { + if !s.object { + return s.URL, nil + } + m := render.Map{e("url", s.URL)} + if s.Ref != nil { + m = append(m, e("ref", *s.Ref)) + } + if s.Path != nil { + m = append(m, e("path", *s.Path)) + } + if s.ReadOnly != nil { + m = append(m, e("readOnly", *s.ReadOnly)) + } + return m, nil +} + // set is whether the person chose anything for the catalog. func (s AgentManagerSkills) set() bool { return len(s.Repositories) > 0 || s.GitHub.App.SecretName != "" || s.GitAuthSecretName != "" || s.MintGitAuthSecret @@ -775,7 +855,7 @@ type commitChoice struct { // the cluster does not serve PodCertificateRequest, the chat or skill // repositories on an installation whose organisation hosts no portal for // them, the chat without a model, or on Vertex without its Google project or -// location, the Hive where the installation cannot serve it, the MCP backends' network policy or the LLM listener's rate limits on the 3 line, the rate limits or the session idle TTL where no kagent runs, the session idle TTL on the 3 line, the tenant mode on the 3 line, where kagent and the agent-manager do not both run or with a hold below the releases it needs, the cluster-manager's commit mode where no cluster-manager runs, context bots where no chat gateway runs) +// location, the Hive where the installation cannot serve it, the MCP backends' network policy or the LLM listener's rate limits on the 3 line, the rate limits or the session idle TTL where no kagent runs, the session idle TTL on the 3 line, the default agent turned off or its model override on the 3 line, where kagent and the agent-manager do not both run or with a chart hold below the release that ships it, the skill-manager's sources or GitHub App on the 3 line, where no agent-manager runs or with a chart hold below the release with the skill-manager, a source naming the platform's own skill repository, the agent-manager's skill repositories where it may take its skills from the skill-manager or beside the skill-manager's sources, the cluster-manager's commit mode where no cluster-manager runs, context bots where no chat gateway runs) // is ErrInput too. func Parse(raw any) (*Input, error) { schemaBytes, err := definitions.FS.ReadFile("agent-platform/schema.json") @@ -821,7 +901,7 @@ func Parse(raw any) (*Input, error) { return nil, err } in := &Input{Installation: d.Installation, ModelServing: d.ModelServing.Enabled, SingletonsCapacity: d.Scheduling.SingletonsCapacity, MCPBackends: d.NetworkPolicy.MCPBackends, LLMRateLimits: d.LLMRouting.RateLimits, LLMRateLimitsComment: d.LLMRouting.RateLimitsComment, SessionIdleTTL: d.Sessions.IdleTTL, AIChat: d.AIChat, SkillRepositories: d.Skills.Repositories, Hive: d.Hive, - ClusterManagerCommit: d.ClusterManager.GitHub.Enabled, ModelManagerCommit: d.ModelManager.GitHub.Enabled, AgentManagerCommit: d.AgentManager.GitHub.Enabled, AgentManagerSkills: d.AgentManager.Skills, AgentManagerTokenExchange: d.AgentManager.GitHubTokenExchange.Enabled, AgentManagerCredentialUI: d.AgentManager.Credentials.UIURL, Versions: d.Versions, ContextBots: d.KlausGateway.Slack.ContextBotIDs, ContextBotsComment: d.KlausGateway.Slack.ContextBotIDsComment, ContextBotNames: d.KlausGateway.Slack.ContextBotNames, ContextBotNamesComment: d.KlausGateway.Slack.ContextBotNamesComment, SlashCommand: d.KlausGateway.Slack.SlashCommand, SlashCommandComment: d.KlausGateway.Slack.SlashCommandComment, Gateway: pol.gateway(d.Installation), Teleport: pol.Federation.Teleport, SourceInterval: pol.Flux.SourceInterval, + ClusterManagerCommit: d.ClusterManager.GitHub.Enabled, ModelManagerCommit: d.ModelManager.GitHub.Enabled, AgentManagerCommit: d.AgentManager.GitHub.Enabled, AgentManagerSkills: d.AgentManager.Skills, SkillManagerSources: d.SkillManager.Sources, SkillManagerAppSecret: d.SkillManager.GitHub.App.SecretName, DefaultAgent: d.DefaultAgent, AgentManagerTokenExchange: d.AgentManager.GitHubTokenExchange.Enabled, AgentManagerCredentialUI: d.AgentManager.Credentials.UIURL, Versions: d.Versions, ContextBots: d.KlausGateway.Slack.ContextBotIDs, ContextBotsComment: d.KlausGateway.Slack.ContextBotIDsComment, ContextBotNames: d.KlausGateway.Slack.ContextBotNames, ContextBotNamesComment: d.KlausGateway.Slack.ContextBotNamesComment, SlashCommand: d.KlausGateway.Slack.SlashCommand, SlashCommandComment: d.KlausGateway.Slack.SlashCommandComment, Gateway: pol.gateway(d.Installation), Teleport: pol.Federation.Teleport, SourceInterval: pol.Flux.SourceInterval, ReleaseCandidates: pol.releaseCandidates(d.Installation)} if in.Components, err = pol.components(in.Installation); err != nil { return nil, err @@ -975,11 +1055,24 @@ func (in *Input) checkRecord() error { return err } if in.SessionIdleTTL != "" && in.Installation.ChartLine != lineFour { - return refuse(fmt.Sprintf("%s is the 4 chart line's, and this installation runs the %s line; the record's chart line decides", describe("sessions.idleTTL"), in.Installation.ChartLine)) + return in.refuseOffLineFour("sessions.idleTTL") } if in.SessionIdleTTL != "" && !in.kagent() { return refuse(fmt.Sprintf("%s bounds how long kagent keeps an idle Session, and the fleet policy runs no kagent on %s's installations", describe("sessions.idleTTL"), in.Installation.Customer)) } + if err := in.checkSkillManagerChart("kagent with the agent-manager", in.kagent() && in.agentManager(), + skillManagerChartChoice{in.DefaultAgent.disabled(), "defaultAgent.enabled", "turns off the default agent in kagent", true}, + skillManagerChartChoice{in.DefaultAgent.ModelConfig != "", "defaultAgent.modelConfig", "names the default agent's ModelConfig in kagent", false}); err != nil { + return err + } + if err := in.checkSkillManagerChart(componentAgentManager, in.agentManager(), + skillManagerChartChoice{len(in.SkillManagerSources) > 0, "skillManager.sources", "lists the sources of the skill-manager, which runs with the agent-manager", false}, + skillManagerChartChoice{in.SkillManagerAppSecret != "", "skillManager.github.app.secretName", "names the GitHub App of the skill-manager, which runs with the agent-manager", false}); err != nil { + return err + } + if err := in.checkSkillSourceConflicts(); err != nil { + return err + } if len(in.LLMRateLimits) > 0 && !in.kagent() { return refuse(fmt.Sprintf("%s bound the LLM listener, and the fleet policy runs no kagent on %s's installations, so no listener is rendered", describe("llmRouting.rateLimits"), in.Installation.Customer)) } @@ -1113,6 +1206,144 @@ func releaseFilterAdmits(semver string) bool { return releaseTag.MatchString(semver) } +// refuseOffLineFour refuses input, a choice of the 4 chart line's, on an +// installation the record puts on another line. +func (in *Input) refuseOffLineFour(input string) error { + return refuse(fmt.Sprintf("%s is the 4 chart line's, and this installation runs the %s line; the record's chart line decides", describe(input), in.Installation.ChartLine)) +} + +// skillManagerChartChoice is an input the person chose, or not, that the +// meta chart takes from skillManagerChart on; what says what the input does. +// anyChart marks an input every 4 chart takes (a components toggle, open in +// the values schema of every release), so no chart gates it. +type skillManagerChartChoice struct { + chosen bool + input, what string + anyChart bool +} + +// checkSkillManagerChart refuses each chosen input outside the 4 chart +// line, where the fleet policy does not run component (runs), and, unless +// any chart takes it, with a versions.chart hold below skillManagerChart. +func (in *Input) checkSkillManagerChart(component string, runs bool, choices ...skillManagerChartChoice) error { + for _, c := range choices { + if !c.chosen { + continue + } + if in.Installation.ChartLine != lineFour { + return in.refuseOffLineFour(c.input) + } + if !runs { + return refuse(fmt.Sprintf("%s %s, and the fleet policy runs no %s on %s's installations", describe(c.input), c.what, component, in.Installation.Customer)) + } + if c.anyChart { + continue + } + if !holdAdmits(in.Versions.Chart, skillManagerChart) { + return refuse(fmt.Sprintf("%s needs the meta chart %s or later, which runs the skill-manager and the default agent, and %s holds it at %s; move or lift the hold first", describe(c.input), skillManagerChart, describe("versions.chart"), in.Versions.Chart)) + } + } + return nil +} + +// skillManagerChart is the first meta chart that runs the skill-manager and +// ships the default agent (giantswarm/agent-platform#1265), its first release +// candidate with the keys; its release, agent-platform 4.179.0, is stable. +// Its values schema refuses skillManager, skill-manager and defaultAgent +// below it. +const skillManagerChart = "4.179.0-rc.9" + +// reachesSkillManagerChart says whether the meta chart the installation +// resolves to may be skillManagerChart or later: the 4 line and no +// versions.chart hold below it. +func (in *Input) reachesSkillManagerChart() bool { + return in.Installation.ChartLine == lineFour && holdAdmits(in.Versions.Chart, skillManagerChart) +} + +// agentManagerViaSkillManager is the first agent-manager release that takes +// its skills from the skill-manager (the meta chart's +// agent-platform.agentManager.skillManagerFloor, behind its viaSkillManager). +const agentManagerViaSkillManager = "2.24.0" + +// platformSkillsRepository is the platform's own skill source, which the +// meta chart lists first (skills.platformSource, never turned off by this +// definition) and fails the render on a skill source naming it. +const platformSkillsRepository = "https://github.com/giantswarm/agent-platform" + +// namesPlatformSkills says whether a skill source's URL names the platform's +// own repository, compared as the meta chart does (no trailing "/" or ".git"). +func namesPlatformSkills(url string) bool { + return strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(url, "/"), ".git"), "/") == platformSkillsRepository +} + +// takesSkillsFromSkillManager says whether the agent-manager takes its skills +// from the skill-manager, as the meta chart decides it +// (agent-platform.agentManager.viaSkillManager): on a chart with the +// skill-manager, the floor of components.agent-manager.versionRange at +// agentManagerViaSkillManager or later. Only a hold sets that range here; +// without one the chart's default (>=2.22.0) stands, below the floor. +func (in *Input) takesSkillsFromSkillManager() bool { + return in.reachesSkillManagerChart() && componentFloorAtLeast(in.Versions.Components[componentAgentManager], agentManagerViaSkillManager) +} + +// checkSkillSourceConflicts refuses a skill source naming the platform's own +// repository where the meta chart lists it itself: a skillManager.sources +// entry, and an agentManager.skills.repositories entry on a chart with the +// skill-manager; agentManager.skills.repositories where the agent-manager +// takes its skills from the skill-manager, on which the meta chart fails; +// and agentManager.skills.repositories beside skillManager.sources. The +// meta chart takes both lists (an agent-manager below +// agentManagerViaSkillManager reads its own list in place of the sources, the +// skill-manager the sources); refusing the pair is this definition's choice, +// so one reconcile moves an installation and no state leaves the two +// consumers with lists that differ. +func (in *Input) checkSkillSourceConflicts() error { + for i, s := range in.SkillManagerSources { + if namesPlatformSkills(s.URL) { + return refuse(fmt.Sprintf("%s entry %d (%s) names the platform's own skill repository, which the meta chart already lists read-only at its release; remove the entry", describe("skillManager.sources"), i, s.URL)) + } + } + if len(in.AgentManagerSkills.Repositories) > 0 && in.takesSkillsFromSkillManager() { + return refuse(fmt.Sprintf("%s is set, and %s holds the agent-manager at %s or later, which takes its skills from the skill-manager, so the meta chart fails on the list; move it into skillManager.sources, or hold the agent-manager below %s", describe("agentManager.skills.repositories"), describe("versions.components.agent-manager"), agentManagerViaSkillManager, agentManagerViaSkillManager)) + } + if in.reachesSkillManagerChart() { + for i, url := range in.AgentManagerSkills.Repositories { + if namesPlatformSkills(url) { + return refuse(fmt.Sprintf("%s entry %d (%s) names the platform's own skill repository, which the meta chart from %s on already lists read-only at its release; remove the entry", describe("agentManager.skills.repositories"), i, url, skillManagerChart)) + } + } + } + if len(in.SkillManagerSources) > 0 && len(in.AgentManagerSkills.Repositories) > 0 { + return refuse(fmt.Sprintf("%s and %s are both set. The meta chart takes both, but an agent-manager below %s (the meta chart's default range among them) then reads its own list and the skill-manager the sources, two lists that can differ; this definition keeps one list: move the agent-manager's list into skillManager.sources and empty it in the same reconcile", describe("skillManager.sources"), describe("agentManager.skills.repositories"), agentManagerViaSkillManager)) + } + return nil +} + +// componentFloorAtLeast says whether the floor of a component's version +// hold is version or later, its release candidates included, as the meta +// chart reads it (agent-platform.componentFloorAtLeast over +// agent-platform.semverRangeFloor): the version of the first term that is no +// upper bound and reads as a version, its >=, >, ^, ~ or = taken off, the +// pre-release stripped. No hold, or one without a floor, is false. +func componentFloorAtLeast(hold, version string) bool { + for _, term := range strings.Fields(strings.ReplaceAll(hold, ",", " ")) { + if strings.HasPrefix(term, "<") { + continue + } + v := strings.TrimPrefix(term, ">=") + for _, p := range []string{">", "^", "~", "=", "v"} { + v = strings.TrimPrefix(v, p) + } + floor, err := semverlib.StrictNewVersion(v) + if err != nil { + continue + } + release, _ := floor.SetPrerelease("") + return !release.LessThan(semverlib.MustParse(version)) + } + return false +} + // modelFreeChart is the first meta chart that declares no model // (giantswarm/agent-platform#1295): it refuses kagent.providers, // kagent.defaultModelConfig and kagent.modelConfigs, and writes providers: diff --git a/render/agentplatform/rename_test.go b/render/agentplatform/rename_test.go index f7fb3108..38fdf0f8 100644 --- a/render/agentplatform/rename_test.go +++ b/render/agentplatform/rename_test.go @@ -51,7 +51,7 @@ func TestComponentInputsAreNamedAfterTheChartPath(t *testing.T) { var schema map[string]any require.NoError(t, json.Unmarshal(raw, &schema)) - components := map[string]string{"agentManager": "agent-manager", "clusterManager": "cluster-manager", "modelManager": "model-manager", "skillManager": "skill-manager"} + components := map[string]string{"agentManager": componentAgentManager, "clusterManager": "cluster-manager", "modelManager": "model-manager", "skillManager": "skill-manager"} checked := 0 var walk func(node map[string]any, path []string) walk = func(node map[string]any, path []string) { diff --git a/render/agentplatform/render.go b/render/agentplatform/render.go index 7501a8f6..fc0eca96 100644 --- a/render/agentplatform/render.go +++ b/render/agentplatform/render.go @@ -246,6 +246,9 @@ func (in *Input) configmapPatch() render.Map { components := render.Map{e("kagent", render.Map{e("enabled", in.kagent())}), e("agent-manager", render.Map{e("enabled", in.agentManager())})} components = in.componentToggles(components) + if in.DefaultAgent.disabled() { + components = append(components, e(componentDefaultAgent, render.Map{e("enabled", false)})) + } if in.ModelServing { for _, c := range servingComponents { components = append(components, e(c, render.Map{e("enabled", true)})) @@ -296,6 +299,15 @@ func (in *Input) configmapPatch() render.Map { m = append(m, e("agent-platform-mcps", mcps)) } m = in.componentValues(m) + if mc := in.DefaultAgent.ModelConfig; mc != "" { + m = append(m, e("defaultAgent", render.Map{e("modelConfig", mc)})) + } + if len(in.SkillManagerSources) > 0 { + m = append(m, e("skillManager", render.Map{e("sources", in.SkillManagerSources)})) + } + if in.SkillManagerAppSecret != "" { + m = append(m, e("skill-manager", render.Map{e("github", render.Map{e("app", render.Map{e("secretName", in.SkillManagerAppSecret)})})})) + } m = in.organizationsValues(m) m = in.platformTenantValues(m) if len(in.MCPBackends) > 0 { diff --git a/render/agentplatform/render_test.go b/render/agentplatform/render_test.go index f0b3819a..74f0b66f 100644 --- a/render/agentplatform/render_test.go +++ b/render/agentplatform/render_test.go @@ -73,6 +73,26 @@ const ( firstLimitPath = "llmRouting/rateLimits/0" keyGoogle = "google" keyCapacity = "singletonsCapacity" + keyModelConfig = "modelConfig" + keyURL = "url" + keySources = "sources" + keyRef = "ref" + refMain = "main" + acmeSkills = "https://github.com/acme/skills" + caseLineThree = "the 3 line" + inputChartHold = "versions.chart" + // holdBelowSkillManager holds the meta chart below the release with + // the skill-manager and the default agent. + holdBelowSkillManager = "~4.174.0" + // holdReleaseBeforeSkillManager holds the meta chart on the stable + // release before the one with the skill-manager. + holdReleaseBeforeSkillManager = "~4.178.0" + // holdAgentManagerViaSkillManager holds the agent-manager on the release + // that takes its skills from the skill-manager. + holdAgentManagerViaSkillManager = "~2.24.0" + modelSonnet = "claude-sonnet" + // stageTesting is the policy's release-candidate stage. + stageTesting = "testing" ) // shapes are the installation shapes, in the order the goldens are rendered. @@ -779,7 +799,7 @@ func TestManagersCommitMode(t *testing.T) { if patch == nil { t.Fatal("no configmap patch rendered") } - for key, want := range map[string]string{"model-manager": c.wantM, "agent-manager": c.wantA} { + for key, want := range map[string]string{"model-manager": c.wantM, componentAgentManager: c.wantA} { got := "" if v, ok := patch[key].(map[string]any); ok && v[keyGitHub] != nil { got = string(render.MustYAML(map[string]any{keyGitHub: v[keyGitHub]})) @@ -799,6 +819,18 @@ func TestManagersCommitMode(t *testing.T) { } } +// agentManagerBelowSkillManager holds the agent-manager below the release +// that takes its skills from the skill-manager. +var agentManagerBelowSkillManager = map[string]any{keyComponents: map[string]any{componentAgentManager: "~2.22.0"}} + +// runReleaseCandidates puts the installation of input on the policy's +// release-candidate stage: the giantswarm installations there run the +// platform's release candidates. +func runReleaseCandidates(input map[string]any) map[string]any { + input["installation"].(map[string]any)["collectionsStage"] = stageTesting + return input +} + // TestAgentManagerSkills renders the agent-manager's skill catalog from its // choices: only what is chosen is written, under the agent-manager's values // next to its commit mode; refused where the policy runs no agent-manager. @@ -1557,6 +1589,283 @@ func TestKagentProvidersFollowTheChart(t *testing.T) { } } +// renderedPatch renders input and returns the installation's configmap patch. +func renderedPatch(t *testing.T, input map[string]any, secrets map[string]string) string { + t.Helper() + result, err := Render(input, secrets, render.ModeCommit) + if err != nil { + t.Fatal(err) + } + return platformPatch(t, result) +} + +// refusalCase is an input the render refuses, naming the input it names. +type refusalCase struct { + name string + input map[string]any + secrets map[string]string + names string +} + +func requireRefusals(t *testing.T, cases []refusalCase) { + t.Helper() + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + _, err := Render(c.input, c.secrets, render.ModeCommit) + if !errors.Is(err, ErrInput) || !strings.Contains(err.Error(), c.names) { + t.Fatalf("got %v, want ErrInput naming %q", err, c.names) + } + }) + } +} + +// TestDefaultAgent renders the platform-shipped default agent as +// the meta chart runs it: on by default, so neither the toggle nor the model +// override is written and the goldens are the render; turned off, the +// component's toggle, on any chart release; with a model override, the +// ModelConfig it names. Off and the override are refused on the 3 line and +// where no kagent runs; the override also with a chart hold below the +// release that ships the agent. The release is stable, so an installation +// that runs stable releases only takes the override. +func TestDefaultAgent(t *testing.T) { + withDefaultAgent := func(shape string, choice map[string]any) (map[string]any, map[string]string) { + input, secrets := loadInput(t, shape) + if choice != nil { + input["defaultAgent"] = choice + } + return input, secrets + } + for _, choice := range []map[string]any{nil, {keyEnabled: true}} { + input, secrets := withDefaultAgent(shapeHubPrivateTarget, choice) + if got := renderedPatch(t, input, secrets); strings.Contains(got, "\n default-agent:") || strings.Contains(got, "\ndefaultAgent:") { + t.Errorf("on, the chart's default, and the patch carries the default agent (%v):\n%s", choice, got) + } + } + + for _, versions := range []map[string]any{nil, {keyChart: holdBelowSkillManager}} { + input, secrets := withDefaultAgent(shapeHubPrivateTarget, map[string]any{keyEnabled: false}) + if versions != nil { + input[keyVersions] = versions + } + if got := renderedPatch(t, input, secrets); !strings.Contains(got, "\n default-agent:\n enabled: false\n") { + t.Errorf("off on a stable installation (%v), and the patch carries no components.default-agent.enabled: false:\n%s", versions, got) + } + } + + for _, candidates := range []bool{true, false} { + input, secrets := withDefaultAgent(shapeHubPrivateTarget, map[string]any{keyModelConfig: modelSonnet}) + if candidates { + runReleaseCandidates(input) + input[keyVersions] = map[string]any{keyChart: ">=4.100.0 <5.0.0"} + } + if got := renderedPatch(t, input, secrets); !strings.Contains(got, "\ndefaultAgent:\n modelConfig: claude-sonnet\n") { + t.Errorf("a model override (release candidates %v), and the patch carries no defaultAgent.modelConfig:\n%s", candidates, got) + } + } + + var cases []refusalCase + notAName, hubSecrets := withDefaultAgent(shapeHubPrivateTarget, map[string]any{keyModelConfig: "Claude Sonnet"}) + cases = append(cases, refusalCase{"not a ModelConfig name", notAName, hubSecrets, "defaultAgent/modelConfig"}) + for input, choice := range map[string]map[string]any{"defaultAgent.modelConfig": {keyModelConfig: modelSonnet}, "defaultAgent.enabled": {keyEnabled: false}} { + lineThree, lineThreeSecrets := withDefaultAgent(shapePublicCustomer, choice) + noKagent, noKagentSecrets := withDefaultAgent(shapeHubPrivateTarget, choice) + noKagent["installation"].(map[string]any)["customer"] = customerWithoutKagent + noKagent["clusterManager"] = map[string]any{keyGitHub: map[string]any{keyEnabled: false}} + cases = append(cases, + refusalCase{input + " on the 3 line", lineThree, lineThreeSecrets, input}, + refusalCase{input + " without kagent", noKagent, noKagentSecrets, input}) + } + held, heldSecrets := withDefaultAgent(shapeHubPrivateTarget, map[string]any{keyModelConfig: modelSonnet}) + runReleaseCandidates(held) + held[keyVersions] = map[string]any{keyChart: holdBelowSkillManager} + cases = append(cases, + refusalCase{"defaultAgent.modelConfig with the chart held below the agent", held, heldSecrets, inputChartHold}) + requireRefusals(t, cases) +} + +// TestSkillManagerSources renders the skill-manager's sources as the person +// lists them, into the meta chart's skillManager.sources: a URL as a URL, an +// object with its ref, path and read-only mark as the object, in order, +// every key written as it was read. None writes nothing. An entry that is +// no http(s) URL, or an object with a key the skill-manager does not read, +// is refused, and so is an entry naming the platform's own repository, the +// list beside the agent-manager's skill repositories, on the 3 line, where +// the fleet policy runs no agent-manager, and with a chart hold below the +// release with the skill-manager (a stable hold on 4.177 or 4.178 among +// them). A hold on a candidate with the keys, or on the release, takes them, +// and so does an installation that runs stable releases only, the release +// being stable. +func TestSkillManagerSources(t *testing.T) { + withSources := func(shape string, sources ...any) (map[string]any, map[string]string) { + input, secrets := loadInput(t, shape) + if shape == shapeHubPrivateTarget { + runReleaseCandidates(input) + } + input["skillManager"] = map[string]any{keySources: sources} + return input, secrets + } + input, secrets := loadInput(t, shapeHubPrivateTarget) + if got := renderedPatch(t, input, secrets); strings.Contains(got, "skillManager") { + t.Errorf("no sources, and the patch carries skillManager:\n%s", got) + } + + input, secrets = withSources(shapeHubPrivateTarget, acmeSkills, + map[string]any{keyURL: "https://github.com/acme/platform-skills", keyRef: "v1.2.0", "path": "skills", "readOnly": true}, + map[string]any{keyURL: "https://github.com/acme/more-skills", keyRef: "", "readOnly": false}) + got := renderedPatch(t, input, secrets) + want := "\nskillManager:\n sources:\n - https://github.com/acme/skills\n - url: https://github.com/acme/platform-skills\n ref: v1.2.0\n path: skills\n readOnly: true\n - url: https://github.com/acme/more-skills\n ref: \"\"\n readOnly: false\n" + if !strings.Contains(got, want) { + t.Errorf("the patch carries no sources\n%s\nin:\n%s", want, got) + } + + for _, hold := range []string{">=4.100.0 <5.0.0", "4.179.0-rc.12", "~4.179.0"} { + input, secrets = withSources(shapeHubPrivateTarget, acmeSkills) + input[keyVersions] = map[string]any{keyChart: hold} + renderedPatch(t, input, secrets) + } + stableInput, stableSecrets := withSources(shapeHubPrivateTarget, acmeSkills) + stableInput["installation"].(map[string]any)["collectionsStage"] = "" + if got := renderedPatch(t, stableInput, stableSecrets); !strings.Contains(got, "\nskillManager:\n sources:\n - "+acmeSkills+"\n") { + t.Errorf("stable releases only, and the patch carries no sources:\n%s", got) + } + + object := map[string]any{keyURL: acmeSkills, keyRef: refMain} + noURL, noURLSecrets := withSources(shapeHubPrivateTarget, map[string]any{keyRef: refMain}) + unknown, unknownSecrets := withSources(shapeHubPrivateTarget, map[string]any{keyURL: acmeSkills, "branch": refMain}) + notAURL, notAURLSecrets := withSources(shapeHubPrivateTarget, "acme/skills") + objectNotAURL, objectNotAURLSecrets := withSources(shapeHubPrivateTarget, map[string]any{keyURL: "git@github.com:acme/skills.git"}) + lineThree, lineThreeSecrets := withSources(shapePublicCustomer, object) + noAgentManager, noAgentManagerSecrets := withSources(shapeHubPrivateTarget, acmeSkills) + noAgentManager["installation"].(map[string]any)["customer"] = customerWithoutKagent + noAgentManager["clusterManager"] = map[string]any{keyGitHub: map[string]any{keyEnabled: false}} + held, heldSecrets := withSources(shapeHubPrivateTarget, object) + held[keyVersions] = map[string]any{keyChart: holdBelowSkillManager} + heldReleased, heldReleasedSecrets := withSources(shapeHubPrivateTarget, object) + heldReleased[keyVersions] = map[string]any{keyChart: "~4.177.0"} + platform, platformSecrets := withSources(shapeHubPrivateTarget, map[string]any{keyURL: "https://github.com/giantswarm/agent-platform.git/", keyRef: refMain}) + both, bothSecrets := withSources(shapeHubPrivateTarget, acmeSkills) + both["agentManager"] = map[string]any{keySkills: map[string]any{keyRepositories: []any{acmeSkills}}} + heldStable, heldStableSecrets := withSources(shapeHubPrivateTarget, object) + heldStable[keyVersions] = map[string]any{keyChart: holdReleaseBeforeSkillManager} + const sourcesPath, sourcesInput, repositoriesInput = "skillManager/sources", "skillManager.sources", "agentManager.skills.repositories" + requireRefusals(t, []refusalCase{ + {"the chart held on a release without the skill-manager", heldReleased, heldReleasedSecrets, inputChartHold}, + {"the platform's own repository", platform, platformSecrets, sourcesInput}, + {"beside the agent-manager's repositories", both, bothSecrets, repositoriesInput}, + {"no url", noURL, noURLSecrets, sourcesPath}, + {"unknown key", unknown, unknownSecrets, sourcesPath}, + {"not a URL", notAURL, notAURLSecrets, sourcesPath}, + {"an object without a URL", objectNotAURL, objectNotAURLSecrets, sourcesPath}, + {caseLineThree, lineThree, lineThreeSecrets, "skillManager.sources"}, + {"without agent-manager", noAgentManager, noAgentManagerSecrets, "skillManager.sources"}, + {"the chart held below the skill-manager", held, heldSecrets, inputChartHold}, + {"the chart held on the release before the skill-manager", heldStable, heldStableSecrets, inputChartHold}, + }) +} + +// TestSkillManagerAppSecret writes the skill-manager's GitHub App Secret +// where the person names it, and refuses a name that is no Secret's and the +// name where the meta chart runs no skill-manager or a chart hold is below +// the release with it; an installation that runs stable releases only takes +// it, the release being stable. +func TestSkillManagerAppSecret(t *testing.T) { + withApp := func(shape string) (map[string]any, map[string]string) { + input, secrets := loadInput(t, shape) + if shape == shapeHubPrivateTarget { + runReleaseCandidates(input) + } + input["skillManager"] = map[string]any{keyGitHub: appSecret(skillsApp)} + return input, secrets + } + input, secrets := loadInput(t, shapeHubPrivateTarget) + if got := renderedPatch(t, input, secrets); strings.Contains(got, "skill-manager:") { + t.Errorf("no App, and the patch carries skill-manager:\n%s", got) + } + + want := "\nskill-manager:\n github:\n app:\n secretName: " + skillsApp + "\n" + input, secrets = withApp(shapeHubPrivateTarget) + if got := renderedPatch(t, input, secrets); !strings.Contains(got, want) { + t.Errorf("the patch carries no App Secret\n%s\nin:\n%s", want, got) + } + stable, stableSecrets := loadInput(t, shapeHubPrivateTarget) + stable["skillManager"] = map[string]any{keyGitHub: appSecret(skillsApp)} + if got := renderedPatch(t, stable, stableSecrets); !strings.Contains(got, want) { + t.Errorf("stable releases only, and the patch carries no App Secret\n%s\nin:\n%s", want, got) + } + + lineThree, lineThreeSecrets := withApp(shapePublicCustomer) + noAgentManager, noAgentManagerSecrets := withApp(shapeHubPrivateTarget) + noAgentManager["installation"].(map[string]any)["customer"] = customerWithoutKagent + noAgentManager["clusterManager"] = map[string]any{keyGitHub: map[string]any{keyEnabled: false}} + held, heldSecrets := withApp(shapeHubPrivateTarget) + held[keyVersions] = map[string]any{keyChart: holdBelowSkillManager} + notAName, notANameSecrets := loadInput(t, shapeHubPrivateTarget) + notAName["skillManager"] = map[string]any{keyGitHub: appSecret("Acme Skills")} + const appInput = "skillManager.github.app.secretName" + requireRefusals(t, []refusalCase{ + {"not a Secret name", notAName, notANameSecrets, "skillManager/github/app/secretName"}, + {caseLineThree, lineThree, lineThreeSecrets, appInput}, + {"without agent-manager", noAgentManager, noAgentManagerSecrets, appInput}, + {"the chart held below the skill-manager", held, heldSecrets, inputChartHold}, + }) +} + +// TestAgentManagerSkillRepositoriesAreURLs refuses an object in +// agent-manager's deprecated skill repositories: the object form is the +// skill-manager's (skillManager.sources). +func TestAgentManagerSkillRepositoriesAreURLs(t *testing.T) { + input, secrets := loadInput(t, shapeHubPrivateTarget) + input["agentManager"] = map[string]any{keySkills: map[string]any{keyRepositories: []any{map[string]any{keyURL: acmeSkills, keyRef: refMain}}}} + requireRefusals(t, []refusalCase{{"an object", input, secrets, "agentManager/skills/repositories"}}) +} + +// TestAgentManagerSkillRepositoriesBeforeTheSkillManager renders the +// agent-manager's skill repositories wherever it keeps its own list: the +// chart's default range (>=2.22.0) and a hold below 2.24.0, on a chart with +// the skill-manager too. It refuses them where a hold puts the agent-manager +// at 2.24.0 or later (a candidate of it counted), which takes its skills from +// the skill-manager and on which the meta chart fails, and an entry naming +// the platform's own repository on a chart that lists it itself. +func TestAgentManagerSkillRepositoriesBeforeTheSkillManager(t *testing.T) { + withRepositories := func(candidates bool, versions map[string]any, repositories ...any) (map[string]any, map[string]string) { + input, secrets := loadInput(t, shapeHubPrivateTarget) + if candidates { + runReleaseCandidates(input) + } + input["agentManager"] = map[string]any{keySkills: map[string]any{keyRepositories: repositories}} + if versions != nil { + input[keyVersions] = versions + } + return input, secrets + } + for _, versions := range []map[string]any{nil, agentManagerBelowSkillManager, {keyComponents: map[string]any{componentAgentManager: ">=2.23.0 <3.0.0"}}, {keyChart: holdBelowSkillManager, keyComponents: map[string]any{componentAgentManager: holdAgentManagerViaSkillManager}}} { + input, secrets := withRepositories(true, versions, acmeSkills) + if got := renderedPatch(t, input, secrets); !strings.Contains(got, " repositories:\n - "+acmeSkills+"\n") { + t.Errorf("the agent-manager keeps its own list (%v), and the patch carries no agent-manager repositories:\n%s", versions, got) + } + } + for _, c := range []struct { + candidates bool + versions map[string]any + }{{false, map[string]any{keyChart: holdReleaseBeforeSkillManager}}, {true, map[string]any{keyChart: holdBelowSkillManager}}} { + input, secrets := withRepositories(c.candidates, c.versions, platformSkillsRepository) + if got := renderedPatch(t, input, secrets); !strings.Contains(got, " - "+platformSkillsRepository+"\n") { + t.Errorf("a chart without the platform's source (%v, %v), and the patch carries no platform repository:\n%s", c.candidates, c.versions, got) + } + } + const repositoriesInput = "agentManager.skills.repositories" + stablePlatform, stablePlatformSecrets := withRepositories(false, nil, platformSkillsRepository) + atFloor, atFloorSecrets := withRepositories(true, map[string]any{keyComponents: map[string]any{componentAgentManager: holdAgentManagerViaSkillManager}}, acmeSkills) + candidate, candidateSecrets := withRepositories(true, map[string]any{keyComponents: map[string]any{componentAgentManager: ">=2.24.0-rc.6 <3.0.0"}}, acmeSkills) + platform, platformSecrets := withRepositories(true, nil, acmeSkills, platformSkillsRepository+".git") + requireRefusals(t, []refusalCase{ + {"the agent-manager held at the skill-manager's release", atFloor, atFloorSecrets, repositoriesInput}, + {"the agent-manager held from a candidate of it", candidate, candidateSecrets, repositoriesInput}, + {"the platform's own repository", platform, platformSecrets, repositoriesInput + " entry 1"}, + {"the platform's own repository on stable releases only", stablePlatform, stablePlatformSecrets, repositoriesInput + " entry 0"}, + }) +} + // TestAgentModelsProbe lists, on the 4 line, the Agents of every namespace // that name kagent's default-model-config, held up by the agent-models // action; the 3 line renders neither.