Documentation
ΒΆ
Overview ΒΆ
Package agentspec builds a provision.Spec from an agent row.
It is plan step 22a of the extraction this project came out of (Phase 3.5). It is the FIRST of the three pieces that close doc_seams.go entry 1, and it is deliberately the piece that touches neither the provisioner wrappers nor the chat path: this package has no HTTP client, no cluster client, and no knowledge of any driver.
What it replaces, and why the shape changed ΒΆ
Upstream, the equivalent code was buildHelmValues β a 428-line function returning map[string]any shaped for one vendored Helm chart, supported by ~1,000 further lines of helpers. Its output was only meaningful to that chart's templates, which is the coupling provision.Spec exists to remove.
π΄ THE SINGLE BIGGEST CHANGE IS THAT FILES ARE DATA. Upstream, every file placed into an agent travelled as
{ printf '%s' '<base64>' | base64 -d > /path; } || :
appended to one giant extraInitCommands string. The `|| :` was not caution: the chart's startup script ran under `set -e`, so a bare non-zero exit was a crash loop rather than a missing file β and an audit found three shapes where the guard had been missed. Every file this package emits is a provision.File instead, so the driver places it natively and a test can assert the CONTENT rather than parsing a shell string. See provision.File's own doc comment.
π΄ A COROLLARY WORTH STATING: Init survives, and it is not a dumping ground. A step belongs there only if it is genuinely imperative β something that must RUN, not something that must EXIST. Placing content in Init is how the upstream string grew; this package emits exactly one Init entry and argues for it below.
What this package deliberately does NOT do ΒΆ
Each of these is a named part of another step, not an oversight. They are listed here because a reader's first question is "where did the rest of buildHelmValues go", and a missing answer reads as a gap.
- It does not generate INSTRUCTION CONTENT. Upstream that was skill.go's instructionsFor/skillsFor (902 lines), which plan step 23 deletes and ranked item 3 ports. This package takes the rendered text as an input (Options.Instructions) and places it as a file. That is the right seam: the mechanism and the prose have different owners and different review needs.
- β IT DOES TOUCH CAIRN NOW, AND THIS BULLET USED TO SAY IT DID NOT. Ranked item 3 ("port the chiefβcairn integration") has landed: see cairn.go for the client install, the credential file and the one gate that decides whether either exists, and ChiefInstructions for the prose half. What is still true is the SHAPE the old bullet was defending β the coordinates are Config fields, eligibility is an Options input, and nothing in this package compares an agent name against a constant to decide who gets a credential. Both-unset emits nothing at all, which is the state an installation that has not configured a store runs in.
- It does not build the GATEWAY wiring β the bearer derivation, the chat transport, the responses model sentinel. That is plan step 22c, and internal/agents/responses.go already carries its own OWED record naming the two inputs a caller must supply. β IT DOES DECLARE THE GATEWAY'S PORT NOW, AND THIS BULLET USED TO SAY "the chat endpoint" AMONG WHAT IT OMITS. DefaultGatewayPort and Config.GatewayPort are read by buildPorts, which is what lets a driver RESOLVE an address for an instance this package specified β without it the k8s driver created no Service and answered provision.ErrNoEndpoint for every agent muster provisioned. That is the ADDRESS, not the transport: nothing here speaks the chat wire, derives a bearer or names a model sentinel, and the sentence is corrected rather than deleted because the separation it draws is still the one that governs what may be added.
- It does not ADAPT anything to [api.Provisioner]. That is plan step 22b. Nothing here implements a lifecycle method; Build is a pure function.
Purity, and what it buys ΒΆ
Build reads no environment, no clock, no filesystem and no network. Every input arrives as an argument, so the same inputs always produce the same provision.Spec β which is what makes the golden in agentspec_test.go a meaningful pin rather than a snapshot of one machine. If you find yourself wanting os.Getenv here, put it in Config instead and let the binary resolve it.
Index ΒΆ
- Constants
- Variables
- func Build(a agents.Agent, cfg Config, opts Options) (provision.Spec, error)
- func ChiefInstructions(cairn, plugins bool) string
- func ChiefInstructionsClaudeCode(plugins bool) string
- func ClaudeCodeNetwork() provision.Network
- func ClaudeCodeWorkingDir(a agents.Agent) (string, error)
- func JobBypassListed(a agents.Agent, cfg Config) bool
- func ResolveGatewayPort(port int) int
- func SameRepo(a, b string) bool
- func StripsRepoConfig(a agents.Agent, cfg Config) bool
- type ClaudeCodeConfig
- type ClaudeCodeSession
- type Config
- type Options
- type PoolDeployKey
- type RuntimeConfig
Constants ΒΆ
const ( // EnvAPIURL is the base URL the instance's CLI and skills talk to. EnvAPIURL = "MUSTER_API_URL" // EnvToken carries the agent's OWN per-agent token. It is a SECRET, and // Build puts it in [provision.Spec.Secrets] rather than Env for that // reason β see the note on Build. EnvToken = "MUSTER_HOOK_TOKEN" // EnvGatewayToken carries the SAME per-agent token under the name the // runtime's OWN chat gateway derives its half of the bearer from. Also a // SECRET, and in Secrets for the same reason. // // π΄ IT IS A WIRE CONTRACT WITH A SECOND IMPLEMENTATION IN ANOTHER // REPOSITORY, WHICH IS WHY THE NAME CANNOT BE CHOSEN HERE. The agent // container computes its own gateway credential as // // GATEWAY_TOKEN=$(echo -n "gw-${HOOKS_TOKEN}" | sha256sum | cut -d' ' -f1) // // β see internal/agentgateway/runtime.go, whose Bearer() is muster's half of // exactly that formula. The deployment that implements the container half is // not importable from here, so the agreement is held by a test rather than by // the type system: cmd/muster-server's // TestTheProvisionedContainerCanDeriveTheBearerMusterSends reproduces the // container's derivation over the built spec's own environment and compares // the two bearers. // // π΄ IT IS A SECOND NAME FOR ONE VALUE AND *NOT* A RENAME OF EnvToken, AND // RENAMING WOULD HAVE TRADED ONE 401 FOR ANOTHER. EnvToken is what the in-pod // CLI reads (cmd/muster/config.go's envToken) and what the work-autosave // daemon sends when it posts a durability alarm to the agent's own task // thread; dropping it would break the instance's call-back path, which fails // as "the agent went quiet" rather than as a missing variable. Both names // carry a.HooksToken, and buildSecrets emits them together. // // β IT IS A CONSTANT RATHER THAN CONFIGURATION, UNLIKE THE PORT AND THE MODEL // SENTINEL BESIDE IT, AND THE LINE IS WHERE THE SCHEME'S EDGE IS. This name // is part of the `hooks-sha256` derivation, not an independent property of // the image: the formula that consumes it is itself hardcoded in // agentgateway.HooksSHA256, and MUSTER_AGENT_GATEWAY is the knob that selects // the whole scheme. A runtime that read a different variable is a different // scheme and brings its own name β which is the change that should also move // this constant onto agentgateway.Runtime as a method. // // β DECLARING IT IN agentgateway TODAY WAS RULED OUT, not overlooked: this // package deliberately imports no HTTP client (see the package doc), and // agentgateway holds one. So the name lives in this const block β whose own // header already says these spellings "ARE NOT INVENTED HERE" β and the // cross-package agreement is held by the seam test named above. EnvGatewayToken = "HOOKS_TOKEN" // EnvNodeOptions passes Node heap/flag tuning through to the runtime. EnvNodeOptions = "NODE_OPTIONS" // EnvGitTerminalPrompt is pinned to "0" unconditionally. // // π΄ IT IS A HANG GUARD, NOT A PREFERENCE. Git prompts for credentials on a // terminal it believes is interactive. In a pod there is nobody to answer, // so a clone against a repository the instance cannot read BLOCKS instead of // failing β and a blocked init step is indistinguishable from a slow one // until the deadline fires. Failing fast is the whole point. EnvGitTerminalPrompt = "GIT_TERMINAL_PROMPT" // EnvOpenRouterKey is the shared model-provider credential. Also a secret. EnvOpenRouterKey = "OPENROUTER_API_KEY" // EnvRuntimeConfig tells the operator's install script where muster placed // the runtime-configuration template: [RuntimeConfigPath]. // // π΄ IT EXISTS SO THE SCRIPT DOES NOT HARDCODE A muster PATH. The script // lives in the operator's ConfigMap and muster owns where the bundle is // mounted; a script spelling the path itself would break on any change to // [RuntimeConfigDir], in a container, at startup, with no version of the two // values ever compared. It is NOT a secret: it names a file, and the bundle // it names holds no credential. EnvRuntimeConfig = "MUSTER_RUNTIME_CONFIG" // EnvGatewayBearer carries the credential the agent's OWN gateway must // accept, already derived. It is a SECRET. // // π΄ IT IS THE DERIVED VALUE AND NOT ANOTHER COPY OF THE TOKEN, WHICH IS WHAT // MAKES IT DIFFERENT FROM [EnvGatewayToken] BESIDE IT. EnvGatewayToken ships // the raw token for a runtime that derives its own credential from it; this // ships the RESULT, so the operator's install script needs no hash and no // second implementation of muster's formula. See runtimeconfig.go on why that // second implementation is the failure mode worth removing: two sha256 // expressions that disagree produce a 401 reading as a bad credential. // // β BOTH NAMES ARE SHIPPED, NOT ONE. EnvGatewayToken stays because it is part // of the `hooks-sha256` scheme's contract with runtimes that read it, and // because removing a variable the agent image may read is a change this // package cannot verify. They carry different values and neither is the // other's rename. EnvGatewayBearer = "MUSTER_GATEWAY_BEARER" // EnvCairnConfig points the subsystem-store client at [CairnConfigPath]. // // π΄ IT IS SET ONLY WHEN THE INTEGRATION IS ON, and it is NOT a secret: it // names a path, and the credential it names travels as a confidential // [provision.File]. It is in this block β and in buildEnv's reserved set β // because a caller shadowing it through [Options.ExtraEnv] would point the // client at a file muster did not write, which fails as "the store is // unreachable" rather than as a configuration mistake. See cairn.go. EnvCairnConfig = "CAIRN_CONFIG" // EnvConnectURL is the base URL of muster's agent-facing connector surface // (the proxy at /connect/β¦ and /agent/connectors). Set only when the // deployment configures one ([Config.ConnectURL]); not a secret. EnvConnectURL = "MUSTER_CONNECT_URL" )
Environment variable names handed to the instance.
π΄ THESE ARE NOT INVENTED HERE, AND THEY MUST NOT BE RENAMED IN THIS PACKAGE. They are the spellings cmd/muster (the in-pod CLI) already reads β see that package's envAPIURL/envToken and the comment there, which names the pod case explicitly: "Inside a managed AGENT POD it is that pod's OWN per-agent token". A rename here would leave the CLI reading names nothing sets, and the failure would look like a broken agent rather than a broken spec.
β THERE IS ONE BASE URL, NOT TWO, AND THAT IS A DELIBERATE NARROWING. Upstream injected a ROUTER-side base URL variable *and* a TASK-side one, because the permission router and the task board were separate services, and a cutover made those two values diverge. muster serves both route families from its own mux, so a second variable would have no different value to hold. cmd/muster/config.go makes the same argument and cites the test that checks it (TestEveryWiredRouteIsServedByThisProject).
const ( // EnvClaudeOAuthToken is the variable the Claude Code CLI reads its // subscription `setup-token` from. // // π΄ IT IS PLACED IN EXACTLY ONE PLACE: the claude-code agent's own per-agent // Secret (Spec.Secrets, rendered by the k8s driver as the `<agent>-env` // Secret, consumed by envFrom). Never Env, never a File, never another kind's // spec. TestTheClaudeTokenNameAppearsOnlyInTheClaudeCodeKindsSecret is the seam // ledger that holds it there. EnvClaudeOAuthToken = "CLAUDE_CODE_OAUTH_TOKEN" // ClaudeCodeDataPath is where the agent's persistent volume is mounted. ClaudeCodeDataPath = "/data" // ClaudeCodeWorkspacePath is the CLI's workspace (the image's CCD_WORKSPACE). ClaudeCodeWorkspacePath = "/data/workspace" // ClaudeCodeUID is the image's numeric user and group. ClaudeCodeUID = 1000 // DefaultClaudeCodeStorage is the volume size when the profile names none. DefaultClaudeCodeStorage = "10Gi" // LabelKind is the label a claude-code instance carries naming its kind. LabelKind = "muster.agent/kind" )
The claude-code kind's profile: the Claude Code pod (cmd/ccd + the pinned CLI, images/claude-code-agent).
Every value below is a property of THAT IMAGE, read from its Dockerfile, entrypoint and ccd's own config, not chosen here:
- port 18789, named provision.DefaultPortName: ccd's listen port (agentspec.DefaultGatewayPort β ccd serves muster's /v1/responses wire on it);
- health "/" on that port, startup + liveness and NO readiness (the k8s driver's fixed shape, see k8s/render.go): ccd's `GET /` gates only on its tmux session and its CLI not crash-looping, NEVER on auth or a rate limit, so a rate-limited account cannot get its pod restarted;
- uid/gid 1000: the image's `USER 1000:1000`;
- the volume at /data: CLAUDE_CONFIG_DIR=/data/claude and CCD_WORKSPACE=/data/workspace are siblings under it, so the conversation transcripts `claude --resume <id>` resumes survive a pod restart;
- resources: the scoping measurement (an idle TUI ~300Mi/128m; long-running real sessions 460-562MiB RSS) β request 512Mi/250m, limit 3Gi, no CPU limit.
const ( // DeployKeySecretKey is the key of the operator's Secret that holds the // private key: the key a `kubernetes.io/ssh-auth` Secret uses. DeployKeySecretKey = "ssh-privatekey" // DeployKeyPath is where that key is mounted, in the holder only. DeployKeyPath = "/etc/muster/deploy-key/ssh-privatekey" // KnownHostsPath is where GitHub's pinned host keys are placed, in the // holder only. KnownHostsPath = "/etc/muster/deploy-key/known_hosts" // DeployKeyHolderName is the holder's container. DeployKeyHolderName = "deploy-key" // DeployKeyHolderUID is the holder's uid and gid: not ClaudeCodeUID, which // the agent's session runs as. DeployKeyHolderUID = 1001 // MirrorDir is the directory the holder shares (an emptyDir: written by the // holder, read-only in the agent's container), outside the workspace. MirrorDir = "/var/lib/muster-mirror" // MirrorPath is the bare mirror of the repository in it. MirrorPath = MirrorDir + "/repo.git" // EnvCCDRepoMirror hands ccd the mirror's path (cmd/ccd/checkout.go): it // clones from it. EnvCCDRepoMirror = "CCD_REPO_MIRROR" )
The deploy key's place in the pod: in its KEY HOLDER alone (provision.KeyHolder) β a container named DeployKeyHolderName, under uid DeployKeyHolderUID β which mounts the Secret's one key at DeployKeyPath, GitHub's pinned host keys (podagent.GitHubKnownHosts) at KnownHostsPath, and keeps the repository's mirror at MirrorPath in MirrorDir, which the agent's container mounts READ-ONLY. ccd is told only the mirror's path (EnvCCDRepoMirror): no path to the key, and the key, are in no variable of the agent's container.
const ( EnvCCDJobPermissionMode = "CCD_JOB_PERMISSION_MODE" CCDJobPermissionBypass = "bypassPermissions" )
EnvCCDJobPermissionMode tells ccd how to start the pod's JOB lanes (a machine job's worktree). Its one value is CCDJobPermissionBypass; ccd refuses any other (cmd/ccd/jobmode.go), and TestCcdReadsTheJobPermissionModeAgentspecWrites pins both spellings on both sides.
π΄ WHAT IT GRANTS: a job lane on such a pod runs every tool call without approval, on the code the job hands it β and can read anything ccd's user can in the pod, the agent's own Claude setup-token included. It is for pools that review trusted members' PRs only.
const ( // EnvCCDRepo is the repository, owner/name, ccd clones from // https://github.com/<owner/name> before it starts the CLI. EnvCCDRepo = "CCD_REPO" // EnvCCDRepoBranch is the branch to check out (empty: the remote's default). EnvCCDRepoBranch = "CCD_REPO_BRANCH" // EnvCCDWorkspace is the CLI's working directory. The image sets it to // ClaudeCodeWorkspacePath; the spec overrides it ONLY for an agent with a // repository, to the checkout, so the session's project is the repository β // its CLAUDE.md and .claude/skills load, and the workspace trust ccd seeds is // for that directory. EnvCCDWorkspace = "CCD_WORKSPACE" )
The variables that hand a claude-code pod its repository. ccd reads them (cmd/ccd/checkout.go); TestCcdReadsTheRepositoryVariablesAgentspecWrites pins the spellings on both sides.
const ( // CairnConfigPath is where the store credential is placed. // // π΄ IT IS AN ABSOLUTE PATH OF OUR CHOOSING, AND [EnvCairnConfig] IS WHAT // MAKES THAT LEGAL. Read at the pinned revision from lib/cairn_instances.py's // config_path(): with the variable unset it returns the user's home directory // joined with `.config/subsystem-store/env`, and with it set it returns the // path verbatim. Relying on the default would mean asserting what HOME is // inside an image this package has never seen; naming the file explicitly // removes that assumption FOR THE CREDENTIAL. // // π΄ FOR THE CREDENTIAL, AND NOT FOR THE CLIENT β THE SENTENCE ABOVE USED TO // CLAIM IT "REMOVES THE ASSUMPTION ENTIRELY", WHICH WAS AN OVER-CLAIM. Read at // the pinned revision: lib/subsystem_read_store.py's DEFAULT_CACHE_ROOT is // derived from the process's home directory, and lib/env_aliases.py's own // ledger records that NOTHING in either language reads a cache-root variable. // So every read verb still writes a home-derived cache and [EnvCairnConfig] // cannot move it. The assumption this constant removes is the one about where // the CREDENTIAL is read from β the half a spec can control. The cache half is // the image's by DEFAULT, and this constant does not move it. // // β "NOT BY AN ENVIRONMENT VARIABLE" IS NOT "NOT AT ALL", AND THIS PARAGRAPH // USED TO READ AS THOUGH IT WERE. Read at the pinned revision: the top-level // parser declares a `--cache` option, and the resolver returns the given path // whenever the flag APPEARED (the flag's action sets an explicit marker; the // default is false) rather than the home-derived default. So the cache root IS // movable β by an explicit flag, which is a thing [cairnWrapperFile] could pass // on every invocation. THE UNMITIGATED HAZARD IS THE DEFAULT WE SHIP, NOT AN // ABSENT CAPABILITY. // // THE CANDIDATE FIX IS RECORDED AND DELIBERATELY NOT TAKEN HERE: have the // wrapper exec the client with `--cache <workspace>/.muster/cairn-cache`, // derived from the workspace path [checkCairnWorkspace] already refuses to let // be unsafe, which removes the home-writability case below wherever the // workspace itself is writable. It is not a comment fix β it changes what every // installed agent runs β so it belongs to its own review, and one thing that // review must settle: five verbs (sync, ls-entries, doctor, an all-scopes // search, routes --check) REFUSE an explicit `--cache` when MORE THAN ONE // instance is configured, because it would make them share a directory. So the // flag is only unconditionally safe while a spec places exactly one credential, // which is what [CairnConfigured] gates today. THE CLOSING CONDITION is a change // to [cairnWrapperFile] that passes `--cache` under the workspace, checked by // that change's reviewer against one mechanical run: a read verb succeeding with // an unwritable home. // // π΄ CONSEQUENCE: THE INSTALL CAN REPORT SUCCESS OVER A CLIENT THAT CANNOT // FUNCTION, AND THESE ARE THE CASES. Probes 1 and 3 are `--help` β the staged // file and then the command on PATH; probe 2 is the IMPORT probe, which this // file's own "DOWNLOAD -> VERIFY" section names as such. (The premise used to // read "all three probes are `--help`", which was wrong about probe 2 and is // corrected here because it is the stated premise of the hazard below.) The // conclusion is unchanged and was measured rather than inferred: with an EMPTY, // READ-ONLY home and no credential configured, probe 1's `--help` and probe 2's // import of every [cairnLibModules] entry each exit 0 and create nothing under // it. So neither of the following is observable at install time β each surfaces // later, when the agent runs a verb: // - A HOME THE PROCESS CANNOT WRITE. Every read verb wants a cache beneath // it; nothing in the install ever tries to create one. // - A CREDENTIAL THE PROCESS CANNOT READ. The file lands 0600 (see // [cairnCredentialMode]), and NOTHING in internal/provision sets a // SecurityContext, RunAsUser, RunAsGroup or FSGroup β measured absent // across the repository's own Go, not assumed β so under an image whose // user is not the mount's owner the credential is unreadable. Measured // client behaviour in that state is a refusal at exit 3 naming the two // variables it wanted and the file it looked in: loud, but only once a verb // runs. // // β AND THE RUNTIME IMAGE MUST PROVIDE `curl`, `python3`, AND A `timeout` THAT // ACCEPTS `-k`. The install entry uses all three and checks for none of them, // and nothing else in this repository records the requirement β so this is the // note whoever changes the image will see. A missing one fails the INSTALL // rather than the agent, which is the better of the two failures and still not // a diagnosed one. // // β THE SENTENCE ABOVE DESCRIBES THAT DEFAULT RATHER THAN QUOTING THE PYTHON, // and not for style. tests/leakscan.py's private-hostname rule matches a // dotted label ending in one of a handful of lab suffixes, and the upstream // call's receiver-plus-method spelling is one of those shapes β so quoting it // refuses the file. The first attempt to explain that in a comment quoted it // twice and refused the file twice, which is the gate working correctly on // prose rather than on infrastructure. Describe, do not quote. CairnConfigPath = "/etc/muster/cairn/env" )
The subsystem-store ("cairn") integration: the client, its credential, and the one gate that decides whether either exists.
What this is ΒΆ
cairn is the client for a hosted, curated knowledge store about how an operator's subsystems actually work β durable notes that outlive an instance. The store itself is not part of muster; this file installs its PUBLIC client (github.com/ZacxDev/cairn, pinned by sha) into one eligible instance and places the credential that client reads.
π΄ IT SHIPS OFF, AND "OFF" MEANS NOTHING IS EMITTED AT ALL ΒΆ
Config.CairnURL and Config.CairnToken are BOTH-OR-NEITHER, and with either one empty this file contributes no Init entry, no file and no environment variable. That is not a courtesy default: a store URL without a token is useless in exactly the case a credential exists for, and a token without a URL has nowhere to go. Config.CairnConfigured is the ONE predicate for that question and every branch below reads it β including the caller's, which uses the same method to decide whether the instruction prose may claim the capability. Two separately-spelled gates is how a prompt comes to describe a credential the instance does not hold.
π΄ IT IS SCOPED TO ONE AGENT BY THE CALLER, NOT BY THIS PACKAGE ΒΆ
The credential is READ+WRITE across ALL scopes of the store. A dispatched worker is a short-lived agent running a model over somebody's repository contents; handing every one of them a write key widens the blast radius of a bad turn or a prompt injection from "one branch on one repo" to "the operator's curated knowledge base", which nothing here would notice and no test could restore. So eligibility is Options.CairnEligible β an explicit input β and the policy that sets it lives with the caller that knows which agent is the supervisor. This package deliberately does not compare an agent name against a constant; Options.SeedFiles makes the same argument for the same reason.
Widening it later is a one-line change at that caller. Un-polluting a store a fleet of agents wrote to is not, which is the asymmetry that sets the default.
π΄ WHAT CHANGED ON THE WAY ACROSS, AND WHY EACH CHANGE IS FORCED ΒΆ
Upstream this was one ~41-line shell entry appended to a Helm chart's extraInitCommands, which ran in the APPLICATION container under `set -e`. Three properties of that environment do not hold here, and a verbatim port would have been broken in a way no test of the string could see:
- π΄ provision.Spec.Init RUNS IN A SEPARATE CONTAINER. The kubernetes driver renders it as an initContainer (internal/provision/k8s/render.go), and that container's own filesystem is discarded when it exits. Upstream's entry downloaded the client to /opt and linked it into /usr/local/bin β both of which would vanish before the agent ever ran. The only writable surface both containers see is the WORKSPACE volume, which is why the client lands under the workspace and the wrapper that reaches it is a provision.File (placed by the driver into both containers) rather than something the shell writes. k8s.workspaceVolumeName's own comment names this as "the single most common way an init container is written and silently does nothing".
- π΄ FAILURE IS HARD HERE, AND UPSTREAM'S WAS SOFT. Upstream wrapped the whole entry in `{ β¦ } || :` and echoed WARNING lines, because a bare non-zero exit in that chart's startup script was a crash loop rather than a missing file β so nothing in that block could ever be observed to fail. muster's driver runs Init under `sh -eu` and states that a failing step SHOULD stop the pod. Importing the swallow would have imported the workaround without the problem, which is the specific mistake autosave.go's header warns about. β THE COST IS REAL AND A REVIEWER SHOULD WEIGH IT RATHER THAN WAVE IT THROUGH: a transient failure fetching the client now crash-loops the eligible instance instead of degrading it. The argument for accepting that is the gate above β the install exists only because an operator supplied a store credential, and the prose that ships with it TELLS the agent it has a working client. A soft failure would ship exactly the falsehood the gate exists to prevent, with no channel to report it; a crash loop is a log.
- THE CREDENTIAL IS DATA, NOT A SHELL WRITE. Upstream read two env vars in the init script, tested them with `[ -n β¦ ]`, and printf'd a file under a umask. Here it is a provision.File with Secret set, so the driver places it at mode 0600 and a driver whose Capabilities.Secrets is false REFUSES the spec instead of downgrading it. The `[ -n β¦ ]` arm disappears with the shell that needed it β the Go gate above is the only gate, and it is type-checked.
β WHAT WAS DROPPED ΒΆ
- THE `SUBSYSTEM_STORE_*` COMPATIBILITY SPELLINGS. Upstream wrote four keys into the credential file β the current `CAIRN_*` pair and the pre-rename `SUBSYSTEM_STORE_*` pair β because its live pods could be running a client older than the rename. muster has no such pod: [cairnRev] and this file ship in one commit, so the only client an installation can get is the one pinned here, which reads the current names. The old keys are not free β read at the pinned rev, lib/env_aliases.py emits one deprecation line per old key per process, to stderr, forever. And the failure mode if a client older than the rename ever did run is LOUD: it refuses at exit 3 naming the variables it wanted. Carrying a compatibility window for a client this installation cannot produce would be prose and noise rather than safety.
- THE WARNING ECHOES. They belonged to the soft-failure arms, which are gone with item 2 above.
const ClaudeCodeInstructionsPath = "/etc/claude-code/CLAUDE.md"
ClaudeCodeInstructionsPath is where a claude-code agent's Options.Instructions is placed: the Claude Code CLI's MANAGED-POLICY memory file on Linux.
Documented at https://code.claude.com/docs/en/memory ("Choose where to put CLAUDE.md files": managed policy, "Linux and WSL: /etc/claude-code/CLAUDE.md"; and "Managed policy CLAUDE.md files cannot be excluded"). It is loaded at every launch, first in load order, alongside β never instead of β any CLAUDE.md the session's working directory holds. MEASURED in the pinned CLI (2.1.296, the linux-x64 binary's bundled source): the "Managed" memory file is the managed directory joined with "CLAUDE.md", and that directory's non-macOS, non-Windows case returns "/etc/claude-code". Re-check it when CLAUDE_CODE_VERSION moves.
π΄ WHY THERE AND NOT THE WORKSPACE: /data/workspace is the agent's persistent volume and whatever it holds is the session's. A project CLAUDE.md placed there by a subPath mount would SHADOW a file of the same name the session wrote or a repository brought in, and would itself be edited by nobody. The managed path is outside every volume, so nothing the agent owns is touched, the file is read-only to it, and the driver re-renders it from the spec on every apply (the instance picks it up when its pod next starts β the same as the gateway kind's AGENTS.md).
β NOT --append-system-prompt: the CLI is launched by ccd's supervisor with a fixed argv (`claude` / `claude --resume <id>`), so a flag would mean an image change, and the docs scope that flag to scripted use.
const ClaudeCodePublicEgressPort = 443
ClaudeCodePublicEgressPort is the one TCP port a claude-code agent may reach on public addresses: HTTPS.
const ConfigKeyModel = "model"
ConfigKeyModel is the one key Build writes into provision.Spec.Config.
β Spec.Config IS OPAQUE TO EVERY DRIVER by contract, so this key is a statement about the RUNTIME inside the instance, not about provisioning. It is named here so the runtime side and this side agree in one place rather than in two string literals.
const ConfigKeyWorkspace = "workspace"
ConfigKeyWorkspace is the key Build writes the instance's workspace path under in provision.Spec.Config: the directory InstructionsFileName and the seed files are placed in, which the runtime must use as its agent workspace.
π΄ WITHOUT IT A GATEWAY AGENT NEVER READS ITS OWN AGENTS.md. The runtime's default workspace is under its HOME ($HOME/.<runtime>/workspace in the 2026.5.7 image: resolveDefaultAgentWorkspaceDir, used whenever agents.defaults.workspace is unset), not DefaultWorkspacePath β so the instructions muster places in the workspace sat beside a runtime that looked elsewhere, and found that directory's own default AGENTS.md instead. The operator's install script maps this key to the runtime's setting (agents.defaults.workspace), as it maps ConfigKeyModel; see docs/configuration.md.
const DefaultGatewayHealthPath = "/"
DefaultGatewayHealthPath is the path a serving gateway answers on.
π΄ MEASURED, NOT ASSUMED: a live container of the agent runtime image answered HTTP 200 on this path both when its model-response route was registered and when it was not, so it reports "the gateway process is serving" independently of whether chat is configured β which is exactly what a startup probe must measure. A probe pointed at the response route instead would hold a healthy agent unready whenever its configuration omitted that one key.
β IT IS A CONSTANT WITH NO OVERRIDE, UNLIKE DefaultGatewayPort BESIDE IT, AND THE ASYMMETRY IS ARGUED RATHER THAN INHERITED. The port needs an override because a wrong port makes the instance UNADDRESSABLE and fails as provision.ErrNoEndpoint β a resolution error with nothing pointing at the port. A wrong health path fails as a probe failure naming the path, in the pod's own events, which is self-diagnosing; and nothing in muster consumes the path, so a second environment variable would be surface with no measured need. This repository's own finding is that a documented knob nothing reads is worse than no knob.
const DefaultGatewayPort = 18789
DefaultGatewayPort is the port an agent runtime's MODEL GATEWAY listens on, used when Config.GatewayPort is zero.
π΄ WITHOUT A PORT IN THE SPEC, AN AGENT muster PROVISIONS HAS NO ADDRESS AT ALL. The chain is mechanical and every link of it is in this repository: Build produced Ports nil, so k8s's renderService returned nil and created no Service; (*k8s.Driver).Endpoint read the port back from the Deployment's `muster.dev/port` annotation, which renderAnnotations only writes when Spec.PortNumber(provision.DefaultPortName) is non-zero; so provision.ResolveEndpoint was handed port 0 and answered provision.ErrNoEndpoint β "declares no port". internal/agentgateway resolves an endpoint BEFORE it builds a request, so that error was the only observable of a chat turn against such an agent. This constant is what breaks that chain.
π΄ MEASUREMENT, SO THE NUMBER IS NOT A GUESS NOBODY CAN RE-CHECK: a live pod of the agent runtime image the deployment this was written against pins answered HTTP 200 for a real `/v1/responses` turn on this port, over loopback inside the pod. The same pod's injected service environment exposed the port under the `..._SERVICE_PORT_GATEWAY` name β the same word provision.DefaultPortName carries β and a SECOND port one higher, which is that image's skills API and is NOT what a chat turn wants: agents.ResponsesURL appends `/v1/responses` to whatever endpoint resolves, so the port declared here has to be the gateway's.
π΄ A DEFAULT *WITH* AN OVERRIDE, WHICH IS STRICTLY MORE THAN THE MODEL SENTINEL BESIDE IT GETS, AND THE ASYMMETRY IS THE ARGUMENT. cmd/muster-server's config.AgentGatewayModel is configuration and NOT a constant because "the value belongs to the IMAGE" and no default could be right for an image this project has never seen. The port belongs to the image in exactly the same way β so it takes Config.GatewayPort for the same reason β but unlike an opaque sentinel string it has a defensible default: it is a number that was MEASURED against the image a deployment actually runs, and the alternative to defaulting it is that every deployment is unreachable until an operator discovers a variable, which is the state this constant exists to end. Pointing muster at a runtime whose gateway listens elsewhere is therefore a configuration change rather than a code change β the same three-layer shape provision.EndpointTemplate argues for on the HOST half of the address.
β IT IS DECLARED WHETHER OR NOT A CHAT GATEWAY IS CONFIGURED, deliberately. The port reaches the cluster at CREATE time (the Service and the annotation are both written by k8s apply), so gating it on the gateway tier would leave every instance provisioned while chat was off permanently addressless β turning on MUSTER_AGENT_GATEWAY would then need each agent re-provisioned, and nothing would say so.
const DefaultImageTag = "latest"
DefaultImageTag is used when Config.ImageTag is empty.
β IT IS "latest", AND THAT IS A DEFAULT RATHER THAN A RECOMMENDATION. A mutable tag means two instances created a week apart can run different code with identical specs, which is exactly the ambiguity that made muster's own deployment pin a digest. Callers that care should set Config.ImageTag; this constant exists so that an unset field produces a runnable spec instead of an image reference ending in a bare colon.
const DefaultWorkspacePath = "/data/workspace"
DefaultWorkspacePath is where an agent's working files live when Config does not say otherwise. It matches what the upstream chart used, because the agent runtime images already expect to find a workspace there.
const EnvCCDGatewayUpstreamBearer = "CCD_GATEWAY_UPSTREAM_BEARER"
EnvCCDGatewayUpstreamBearer is the credential an OLDER muster gave ccd for the gateway runtime it ran beside a claude-code chief (a sidecar, removed). Nothing writes it now. It stays in TurnCredentialEnv because a pod built by that older muster keeps the variable until it is next started, and muster's execs into such a pod must still strip it.
CLOSING CONDITION: delete it, and its entry in TurnCredentialEnv and in ccd's list, once no agent pod's spec carries it (every claude-code chief has been Stop β Started on a muster without the sidecar: its pod has one container).
const EnvClaudeDisableNonessentialTraffic = "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"
EnvClaudeDisableNonessentialTraffic is the Claude Code CLI's switch for its non-inference traffic (auto-updater, telemetry, error reporting, feedback, release notes, feature flags β https://code.claude.com/docs/en/network-config and /en/data-usage). An egress-locked pod sets it to "1": those hosts are unreachable there by design, and the CLI is told not to try rather than having each attempt time out against the policy.
β IT DOES NOT COVER EVERYTHING. Per the docs, the WebFetch domain-safety preflight (to api.anthropic.com, which a locked pod still reaches through the cluster's FQDN allow) and the claude.ai MCP connectors (mcp-proxy.anthropic.com, which it does not) are separate switches. Neither is needed for the pod to work: the first succeeds, the second fails closed.
const InstructionsFileName = "AGENTS.md"
InstructionsFileName is the file Options.Instructions is written to, inside the workspace.
const RuntimeConfigDir = "/muster/runtime"
RuntimeConfigDir is the directory muster places the operator's bundle in.
β IT IS NOT UNDER THE WORKSPACE, DELIBERATELY. The workspace is the agent's own working storage β a repository checkout, its notes, whatever it writes β and on a persistent deployment it SURVIVES the instance. A startup bundle living there would be restored from a previous release's content on the next start, and the operator's edit would appear not to have taken.
const RuntimeConfigPath = RuntimeConfigDir + "/config"
RuntimeConfigPath is where RuntimeConfig.Template is placed.
β IT HAS NO FILE EXTENSION BECAUSE THIS PACKAGE DOES NOT KNOW THE FORMAT. The template is opaque bytes: muster never parses it, never validates it and never edits it. Naming it `.json` would be an assertion about somebody else's schema β exactly the assertion this whole file exists to avoid making.
const RuntimeInstallPath = RuntimeConfigDir + "/install"
RuntimeInstallPath is where RuntimeConfig.Install is placed, and the script Build runs as the container's command.
const WorkerInstructions = `---
name: muster-task
description: Read and update your assigned muster task β get its details, post progress comments, advance its status, and report a blocker you cannot resolve instead of retrying it. Use proactively when you start work, make progress, finish, or get stuck on something you cannot fix from inside this instance.
---
# muster task self-service
You are a muster-managed agent. muster assigned you a task, and the ` + "`muster`" + ` CLI is
on your PATH to read and update it. Use it to keep the human informed without
waiting to be asked.
## Auth & base URL
Nothing to configure: ` + "`muster`" + ` reads your agent token and the server's address from
the environment this instance already carries β ` + "`$MUSTER_HOOK_TOKEN`" + ` and
` + "`$MUSTER_API_URL`" + `. Your token IS your identity: the server resolves which task is
yours from it, which is why none of the commands below take a task id.
There is ONE base URL, and every command uses it. If you hand-roll a ` + "`curl`" + `, build it
on ` + "`$MUSTER_API_URL`" + `.
Check it works at any point with ` + "`muster health`" + `.
## Read your task
` + "```bash" + `
muster agent task get
` + "```" + `
Returns JSON: ` + "`body`" + ` (the task), ` + "`status`" + `, and ` + "`comments`" + ` (the thread).
Exit 7 means no task is assigned to you.
## Comment on your task
` + "```bash" + `
muster agent task comment --body "Reproduced the issue; investigating the deploy step."
` + "```" + `
For anything longer than a sentence, write the report to a file first and pass
` + "`--body-file report.md`" + ` β a long shell string is where quoting mistakes silently
truncate the very error text someone needs.
Your comments are attributed to YOU by name, so a reader can tell your report from a
human's. Do not reach for ` + "`muster task comment`" + ` (with an id) instead: that is the
operator/human command, it would record your report under a generic name, and it can
set statuses you are not allowed to set.
## Advance the status
` + "```bash" + `
muster agent task status in_progress
` + "```" + `
Allowed values you may set: ` + "`open`, `in_progress`, `ready_for_review`" + `.
You CANNOT set ` + "`complete`" + ` β only the operator/human marks a task done. The command
refuses it before sending, and the server refuses it too. Nor can you change a task once
it is complete: if you think it needs reopening, ask the operator with the
` + "`attention_ask`" + ` tool instead.
Convention: set ` + "`in_progress`" + ` when you begin, and ` + "`ready_for_review`" + ` with a summary
comment when you finish.
A task ends one of two ways β you finished, or you are blocked β and BOTH of them
report. Never walk away from a task still sitting in ` + "`in_progress`" + `; that reads as
"still working" and nobody will come looking. See "Blocked and cannot proceed" below
for the second ending.
## Blocked and cannot proceed
Some obstacles cannot be resolved from inside this instance however you approach
them. When you hit one, report it and stop β do not keep trying variations of the
same blocked operation. This is the failure branch of the close-out convention
above, and it is just as much a close-out: an unreported blocker is worse than a
failed task, because nobody learns the task failed.
Typical cases:
- a ` + "`git push`" + `, branch, or pull-request operation the remote rejects for a missing
token scope, a protected branch, or a permission your credentials do not carry
- access you do not have and cannot grant yourself β a cluster, a namespace, a
third-party system. Report it as a blocker; a human reading it can arrange the
access. There is no self-service request path from here.
- a tool, runtime, or toolchain that is missing and that you cannot install
- a dependency, package registry, or host you cannot reach from this instance
- a credential that is absent, expired, or rejected
- a task instruction that cannot be carried out as written, where guessing at the
intent would be worse than asking
Rule of thumb: when two genuinely different attempts fail for the same underlying
reason, it is a blocker. A third route is how ten minutes disappear with nobody
watching. Retrying a rejected operation through a different API does not change the
permission that rejected it.
Do all three, in this order, then stop:
1. **Comment with the blocker.** Post a comment (see above) containing the EXACT
error text β verbatim and complete, not a paraphrase or a summary of it β the
command that produced it, what you had already accomplished, and what you think
would unblock it. The exact text is the diagnosis; a paraphrase throws it away.
2. **Say where the work is, in the same comment.** Nothing on this instance's disk
outlives the instance. Name any branch and commit you did manage to push. muster
also runs a work-autosave daemon that snapshots your repository to a rescue
branch β read ` + "`/tmp/muster-autosave.log`" + ` and report whether it is succeeding,
because a blocker on ` + "`git push`" + ` blocks that daemon too. If the work is durable
nowhere, paste the work itself into the comment (` + "`git diff HEAD`" + `, plus
` + "`git log --oneline`" + ` and ` + "`git format-patch`" + ` output for anything committed). A
comment is the only storage you have that survives you β use it before the work
is lost.
3. **Set ` + "`ready_for_review`" + `.** It is the terminal status you are allowed to set, and
it is what puts the task in front of a human. Leaving it ` + "`in_progress`" + ` hides the
failure.
Then stop working on the task. Reporting a blocker accurately is a successful
outcome; grinding silently against an unfixable one is the only real failure.
`
WorkerInstructions is the always-in-context guidance for a dispatched worker agent: how to read its task, report progress, advance status, and β the half that matters most β close out a blocker instead of grinding against it.
β IT IS FOR A WORKER, NOT FOR A SUPERVISOR, AND THE SUPERVISOR'S PROSE IS NOW HERE TOO. This paragraph used to end "That prompt is entangled with the integration ranked item 3 owns β¦ so it is not carried here." Item 3 has landed: see ChiefInstructions below. The distinction the sentence was drawing still holds β a supervisor's prose is not a worker's, which is why they are two constants and not one with a flag β but the reason for the ABSENCE is gone, and a comment that still named it would read as a gap to whoever looked next.
Variables ΒΆ
var ClaudeCodeResources = provision.Resources{CPURequest: "250m", MemoryRequest: "512Mi", MemoryLimit: "3Gi"}
ClaudeCodeResources is the claude-code kind's compute budget.
var ClaudeCodeSecurity = provision.Security{ RunAsUser: ClaudeCodeUID, RunAsGroup: ClaudeCodeUID, FSGroup: ClaudeCodeUID, RunAsNonRoot: true, Restricted: true, NoServiceAccountToken: true, }
ClaudeCodeSecurity is the claude-code kind's isolation.
π΄ NoServiceAccountToken IS TRUE: a shell-capable agent holding a subscription token does not also get a Kubernetes API credential. A privilege profile granted to such an agent binds RBAC to a ServiceAccount whose token is never mounted, so the grant has no effect on it β by design, until a deliberate opt-in exists (scoping proposal Q6).
var DeployKeyHolderResources = provision.Resources{CPURequest: "10m", MemoryRequest: "64Mi", MemoryLimit: "1Gi"}
DeployKeyHolderResources is the holder's budget: it idles, and clones and fetches one repository.
var TurnCredentialEnv = []string{EnvGatewayBearer, EnvCCDGatewayUpstreamBearer, EnvGatewayToken}
TurnCredentialEnv names every variable a claude-code container may carry that drives a TURN API: ccd's (EnvGatewayBearer, or EnvGatewayToken it can be derived from), and the retired EnvCCDGatewayUpstreamBearer.
π΄ NO PROCESS AN AGENT'S SESSION CAN REACH MAY HOLD ONE. ccd unsets them before it starts the CLI (cmd/ccd/turncred.go, whose list a test holds equal to this one); every exec muster runs into the container strips them (internal/agentprovision/scrubexec, the adapter's only driver), because an exec inherits the container's environment, not ccd's.
Functions ΒΆ
func Build ΒΆ
Build assembles the spec for one agent.
π΄ SECRETS GO IN Secrets, NEVER IN Env, AND THE SPLIT IS THE WHOLE REASON provision.Spec HAS TWO FIELDS. The type system is what makes the confidential set enumerable: a driver cannot accidentally log, diff or ConfigMap something it was handed through Secrets. Two SECRETS qualify here β the agent's own per-agent token and the shared provider key β and both are routed accordingly. If you add a third, ask which list it belongs in before asking where in the function to put it.
β TWO SECRETS, THREE ENTRIES: this sentence said "Two values" and the list has three. The per-agent token travels under BOTH EnvToken and EnvGatewayToken β one value, two names, because the in-pod CLI and the runtime's own gateway read different variables. buildSecrets emits the pair from one branch so they cannot drift apart; the count differing from the secret count is the thing a reader is owed rather than left to discover.
The returned spec is validated before it is returned, so a nil error means the spec satisfies provision.Spec.Validate and every driver's precondition that does not depend on the driver's own capabilities. A driver may still refuse it through CheckSpec β that is a capability question, not a construction one.
func ChiefInstructions ΒΆ
ChiefInstructions is the always-in-context guidance for the SUPERVISOR agent: the one agent with no task and no repository, whose job is answering the operator about state.
π΄ cairn MUST BE Config.CairnConfigured FOR THE SAME Config THE SPEC IS BUILT FROM, AND THE GATE IS ON THE CLAIM RATHER THAN ON THE CAPABILITY. Passing true concatenates a section asserting the agent holds a read+write credential across every scope of the store. With no credential configured the client refuses every store command locally β it does not reach the store and does not 401 β so every sentence in that section would be false and the agent would report a working subsystem as broken. Read the flag from the same predicate cairn.go's gate reads; do not compute it a second way.
π΄ plugins MUST BE Config.Plugins FOR THE SAME Config, which the server sets from the one predicate that also decides whether the plugin store β and with it task_create_gated β is wired (cmd/muster-server's config.pluginsEnabled).
func ChiefInstructionsClaudeCode ΒΆ
ChiefInstructionsClaudeCode is ChiefInstructions for a supervisor running on the claude-code kind: the instance's managed CLAUDE.md (ClaudeCodeInstructionsPath).
π΄ THERE IS NO cairn ARGUMENT, BY CONSTRUCTION: the claude-code chief never holds the store credential (see the comment above chiefIdentityClaudeCode), so the prose cannot claim it. plugins MUST BE Config.Plugins for the Config the spec is built from, as for ChiefInstructions. The caller must also have checked Config.ClaudeCodeMCPOffered: every tool this prose names is an MCP tool.
func ClaudeCodeNetwork ΒΆ
ClaudeCodeNetwork is the claude-code kind's network confinement: reachable only by muster, on ccd's port; able to reach only name resolution and TCP 443 on public addresses (the Anthropic API and GitHub).
π΄ IT IS UNCONDITIONAL, LIKE ClaudeCodeSecurity, AND THAT IS WHAT MAKES THE KIND FAIL CLOSED. There is no knob that builds a claude-code spec without it: a driver that cannot confine an instance refuses the spec (provision.CheckSpec) instead of starting a shell-capable pod holding a subscription token with the cluster's API, its neighbours and the operator's LAN in reach.
β WHAT IT DOES NOT BUY: this is "public internet on 443", not "Anthropic and GitHub". Nothing here names a host. A prompt-injected agent can still send what it holds to any public HTTPS endpoint. An egress-locked agent (an officer instance: ClaudeCodeSession.EgressLocked) does NOT get the public rule, or the DNS rule, at all; see claudeCodeNetworkFor.
β MUSTER ITSELF IS NOT REACHABLE FROM THE POD through this policy, although the spec still hands it MUSTER_API_URL: that address is in-cluster, so it is on the wrong side of this. The ONE deliberate allowance is the connector surface: see claudeCodeNetworkFor, which adds egress to muster's connect port (and no other) when the deployment offers the connector store.
func ClaudeCodeWorkingDir ΒΆ
ClaudeCodeWorkingDir is the directory a claude-code agent's CLI works in: its repository's checkout when the row names one, else the bare workspace. With a repository it is the CCD_WORKSPACE claudeCodeEnv writes, derived by the same function, so a caller resolving a path "in the agent's workspace" cannot land somewhere the CLI is not.
func JobBypassListed ΒΆ
JobBypassListed reports whether agent a's worker pool is configured for job-lane permission bypass: ONLY a pooled agent (a.WorkerPool set) whose pool BypassPools lists, and never a chief, whatever its row says. It is the CONFIGURATION half; Build also needs Options.JobBypassVeto to be empty before the pod gets EnvCCDJobPermissionMode = CCDJobPermissionBypass.
π΄ THE ENVIRONMENT IS WRITTEN WHEN THE SPEC IS BUILT, i.e. when the agent is provisioned or started. An agent's pool is fixed at creation (agents.Agent.WorkerPool), but the deployment's list is not: a pool added to or removed from MUSTER_AGENT_CC_BYPASS_POOLS reaches an agent already running only at its next Stop -> Start, which re-applies the spec.
func ResolveGatewayPort ΒΆ
ResolveGatewayPort is the ONE place a zero Config.GatewayPort becomes DefaultGatewayPort.
π΄ IT IS EXPORTED BECAUSE THERE ARE TWO READERS AND THEY MUST NOT DISAGREE, WHICH IS THE ARGUMENT agents.ResolveNamespacePrefix ALREADY WON IN THIS REPOSITORY. buildPorts resolves it to put the number in the spec; cmd/muster-server's boot banner resolves it to PRINT the number an operator will compare against a `kubectl get svc`. Two `if n == 0` branches holding the same literal is how one of them comes to hold a different one β and the observable of that drift is a banner naming a port the cluster does not publish, which sends a reader to debug the Service.
It does NOT range-check: a caller that wants the refusal wants it to name the field it read, and this function does not know which field that was. buildPorts and cmd/muster-server's loadConfig each refuse in their own words.
func SameRepo ΒΆ added in v0.110.0
SameRepo reports whether two owner/name spellings name one GitHub repository (GitHub's names are case-insensitive).
func StripsRepoConfig ΒΆ added in v0.110.0
StripsRepoConfig reports whether a job on agent a gets NONE of its repository's agent configuration β every `.claude/`, the root CLAUDE.md, CLAUDE.local.md, AGENTS.md and .mcp.json removed from its worktree and none restored β whatever the job asks: an agent of a pool with a deploy key (a private repository's reviewers, whose configuration muster does not vouch for). It is THE predicate; the job API refuses a config_ref by it and the worktree script strips by it.
Types ΒΆ
type ClaudeCodeConfig ΒΆ
type ClaudeCodeConfig struct {
// Image is the FULL image reference, tag or digest included. Required.
Image string
// Accounts maps an account name to its setup-token. The agent row names its
// account (agents.Agent.CCAccount); Build looks the token up here.
Accounts map[string]string
// StorageSize is the /data volume's size. Empty means [DefaultClaudeCodeStorage].
StorageSize string
// BypassPools names the worker pools whose agents' JOB lanes run with
// permissions bypassed (MUSTER_AGENT_CC_BYPASS_POOLS): see [JobBypassListed].
// Empty is none, the default.
BypassPools []string
// PoolDeployKeys maps a worker pool's name to the read-only deploy key its
// workers clone and fetch their PRIVATE repository with
// (MUSTER_AGENT_CC_POOL_DEPLOY_KEYS): see [PoolDeployKeyFor]. A pool with no
// entry β every pool, by default β clones and fetches anonymously.
PoolDeployKeys map[string]PoolDeployKey
}
ClaudeCodeConfig enables the claude-code kind. A nil *ClaudeCodeConfig on Config means the kind is NOT enabled, and Build refuses a claude-code row.
type ClaudeCodeSession ΒΆ added in v0.106.0
type ClaudeCodeSession struct {
// AllowMCPTools are bare muster MCP tool names ("officer_claim"); each
// becomes permissions.allow "mcp__muster__<name>". Nothing else can be
// allowed through this field.
AllowMCPTools []string
// Model is the session's model; "" leaves the account default.
Model string
// BypassPermissions starts every session in the pod with every tool
// allowed (podagent.EnvPermissionMode=bypassPermissions): no permission
// prompt at all. Set for an officer instance only.
BypassPermissions bool
}
ClaudeCodeSession is a claude-code pod's per-agent session settings (internal/podagent/session.go): emitted as podagent.EnvAllowMCPTools, podagent.EnvModel and podagent.EnvPermissionMode, which the pod's `ccd seed` writes into settings.json.
func (ClaudeCodeSession) EgressLocked ΒΆ added in v0.108.0
func (s ClaudeCodeSession) EgressLocked() bool
EgressLocked reports whether the pod's network policy drops the public-443 rule and the cluster-DNS rule (claudeCodeNetworkFor) and the pod is told to skip the CLI's non-essential traffic (EnvClaudeDisableNonessentialTraffic).
π΄ IT IS BypassPermissions, NOT A SECOND KNOB, AND THAT IS THE DECISION. A session that runs every tool without a prompt reads untrusted text (an officer reads public PRs) while its pod holds CLAUDE_CODE_OAUTH_TOKEN and MUSTER_HOOK_TOKEN; "public internet on 443" lets one injected `curl` send them anywhere. Deriving the lock from the bypass means no configuration can have the bypass without the lock. Today only an officer instance sets BypassPermissions (internal/api OfficerClaudeCodeSession), so only officers are locked; task agents, the chief and bypass JOB lanes (MUSTER_AGENT_CC_BYPASS_POOLS, a different mechanism) keep the public rule.
type Config ΒΆ
type Config struct {
// ImageRepo is the runtime image WITHOUT a tag, e.g.
// "ghcr.io/example-org/agent-runtime". Required.
ImageRepo string
// ImageTag defaults to [DefaultImageTag].
ImageTag string
// APIBaseURL is what [EnvAPIURL] is set to. Required.
APIBaseURL string
// OpenRouterAPIKey, when set, is injected as [EnvOpenRouterKey] in the
// SECRETS list. Empty means the installation expects the runtime image to
// carry its own provider credentials.
OpenRouterAPIKey string
// Model is the DEPLOYMENT-WIDE DEFAULT primary model slug, not the slug
// every agent gets: an agent row carrying its own Model outranks it (see
// resolvePrimaryModel, which delegates that precedence to
// [agents.ResolveModel]). Empty means the runtime decides, which is why
// Build omits the config key entirely rather than writing "".
Model string
// ModelFallbacks are tried in order after Model.
//
// β DEPLOYMENT-WIDE, AND DROPPED FOR AN AGENT THAT NAMES ITS OWN MODEL.
// There is no per-agent fallbacks column, so pairing this chain with a
// hand-picked per-agent primary would produce a combination no operator
// authored; buildRuntimeConfig's own comment records the full reasoning.
ModelFallbacks []string
// MemoryRequest and MemoryLimit are passed to the driver verbatim, in the
// units it understands. See [provision.Resources] on why they are strings.
MemoryRequest string
MemoryLimit string
// CPURequest and CPULimit likewise.
CPURequest string
CPULimit string
// NodeOptions, when set, becomes [EnvNodeOptions].
NodeOptions string
// GatewayPort is the port the runtime image's model gateway listens on. Zero
// means [DefaultGatewayPort]; see that constant for the measurement and for
// why this field exists rather than the number being written inline.
//
// β A VALUE OUTSIDE 1-65535 IS REFUSED BY Build NAMING THIS FIELD.
// [provision.Spec.Validate] would refuse it too, one layer down, but its
// message names the PORT ("port \"gateway\" number -1 out of range") and not
// the knob somebody set β and the only way this field holds a bad number is
// that somebody set it.
GatewayPort int
// ConnectURL, when set, is handed to every agent as [EnvConnectURL]: where
// muster's connector proxy is. Empty means the connector store is not offered.
ConnectURL string
// ConnectPort is the POD port of that surface on muster's own pods. A
// claude-code agent's network policy allows egress to it (and only it) when
// ConnectURL is set. Required with ConnectURL for that kind.
ConnectPort int
// WorkspacePath defaults to [DefaultWorkspacePath].
WorkspacePath string
// WorkspaceSize is the workspace volume size, e.g. "10Gi". Empty leaves the
// driver's own default in place.
WorkspaceSize string
// WorkspacePersist asks for storage that survives a restart.
WorkspacePersist bool
// Labels are added to every spec this Config builds, BEFORE the per-agent
// labels, which win on a key collision. Nil is fine.
Labels map[string]string
// AutosaveExcludePatterns are gitignore patterns for the agent RUNTIME's own
// bookkeeping files, handed to the work-autosave daemon so it does not
// force-push them into the agent's repository.
//
// π΄ THERE IS NO DEFAULT, DELIBERATELY. See autosave.go's note: a built-in list
// names one specific runtime, and is wrong for every other one in two
// directions at once. Nil is valid and silent. Anchor each entry with a leading
// "/" unless you mean it to match at every depth.
AutosaveExcludePatterns []string
// CairnURL and CairnToken are the hosted subsystem-store coordinates.
//
// π΄ BOTH-OR-NEITHER, AND INERT WHEN UNSET. With either one empty nothing
// cairn-related is emitted β no install step, no credential file, no
// environment variable β and the prose half claims nothing. A token without a
// URL is useless in exactly the case a credential exists for. Read the
// pair through [Config.CairnConfigured], never field by field.
//
// π΄ CairnToken IS A READ+WRITE KEY ACROSS EVERY SCOPE OF THE STORE, which is
// why eligibility is an explicit per-call input ([Options.CairnEligible])
// rather than something every agent gets. cairn.go's header carries the
// blast-radius argument in full.
//
// β THERE IS DELIBERATELY NO DEFAULT URL. A built-in would collapse the gate
// to "is the token set", and a store's address is deployment state rather
// than a constant this package should assert.
CairnURL string
CairnToken string
// Plugins reports that the plugin interface is on for this deployment
// (MUSTER_PLUGINS=1 with a database). It decides one thing here: whether the
// supervisor's prose carries the plugin section ([ChiefInstructions]). The
// server sets it from the same predicate that wires the plugin store.
Plugins bool
// RuntimeConfig is the operator-supplied bundle that makes the agent
// runtime's own gateway START. Zero means nothing is installed and the
// image's entrypoint runs unchanged, which is what every deployment did
// before this field existed β and, measured, is what crashlooped. See
// runtimeconfig.go's header for the defect, the measurements, and why the
// content is the operator's rather than this package's.
//
// β IT IS A deployment-WIDE FIELD HOLDING ONE PER-AGENT FUNCTION, which is
// the only shape in this struct that mixes the two. The template and the
// script are properties of the IMAGE, so they belong here; the credential is
// derived from the agent ROW, so it cannot be a value here β hence
// [RuntimeConfig.DeriveBearer] rather than a fourth [Options] field, which
// would have let a caller ship a bundle with no derivation.
RuntimeConfig RuntimeConfig
// ClaudeCode enables the claude-code agent kind and carries its profile's
// deployment half (image, account tokens). Nil means the kind is not enabled.
// It is read ONLY by a claude-code row's build: the gateway kind's spec is
// identical whether or not this is set. See claudecode.go.
ClaudeCode *ClaudeCodeConfig
}
Config is the deployment-wide part of a spec: everything that is true of every agent in this installation rather than of one agent row.
β EVERY FIELD IS OPTIONAL EXCEPT ImageRepo AND APIBaseURL, and Build says so by returning an error rather than by producing a spec that fails later inside a driver. The two required ones are required because there is no defensible default: an image repository is installation-specific, and a base URL that guessed at a service name would produce an instance that cannot phone home.
func (Config) CairnConfigured ΒΆ
CairnConfigured reports whether a USABLE store credential exists: BOTH coordinates, non-blank.
π΄ IT IS EXPORTED BECAUSE THE CALLER NEEDS THE SAME ANSWER. The instance's spec and the instance's PROSE are built in two places, and they must not be able to disagree about whether the agent holds a credential β a prompt that describes a read+write key the pod does not carry makes the agent report a working subsystem as broken. One predicate, read by both, is what makes that impossible rather than merely unlikely.
func (Config) ClaudeCodeMCPOffered ΒΆ
ClaudeCodeMCPOffered reports whether a claude-code agent built from this Config can reach muster's MCP server β its ONLY route to muster's tools (the image carries no muster CLI). ccd registers that server exactly when the pod carries EnvConnectURL (cmd/ccd/seed.go seedMCP), which claudeCodeEnv sets from this same predicate, and the network policy's one controller allowance is decided by it too. A caller writing prose that names those tools reads it here rather than spelling `ConnectURL != ""` a second time.
type Options ΒΆ
type Options struct {
// Instructions is the rendered agent-instruction document. When non-empty
// Build writes it to [InstructionsFileName] inside the workspace.
//
// π΄ ITS CONTENT IS NOT THIS PACKAGE'S BUSINESS, and that separation is the
// point. Upstream this text was generated by skill.go, which plan step 23
// deletes; ranked item 3 owns porting the generator. Keeping it an input
// means item 3 changes what the file SAYS without touching how it is
// PLACED, and a test here can assert placement without asserting prose.
Instructions string
// SeedFiles are extra files to place in the workspace. Keys are names
// relative to the workspace root; a key containing a path separator is an
// error rather than a silently-created subdirectory, because the upstream
// shell form could not express one and a caller writing "a/b.md" is more
// likely to be confused than deliberate.
//
// Upstream these were the chief-only BOOTSTRAP.md / IDENTITY.md / USER.md
// writes in workspaceSeedInitCommands, selected by comparing the agent name
// against a hardcoded constant. That selection is a CALLER's policy, not a
// spec-building rule, so it does not live here.
SeedFiles map[string]string
// ExtraEnv is appended after the env this package computes. A name that
// collides with one of the constants above is an error: silently shadowing
// [EnvAPIURL] would point an instance at the wrong server, and silently
// dropping the caller's value would be worse.
ExtraEnv []provision.EnvVar
// CairnEligible declares that THIS agent may hold the subsystem-store
// credential. It is one half of the gate; [Config.CairnConfigured] is the
// other, and both must be true before anything is emitted.
//
// π΄ IT IS AN INPUT BECAUSE ELIGIBILITY IS A CALLER'S POLICY, exactly as
// [Options.SeedFiles] argues for its own case: upstream this was an agent name
// compared against a hardcoded constant inside the spec builder, and a
// name-to-privilege rule is not a spec-building rule. The caller that knows
// which agent is the supervisor sets it. Today that is one agent; see
// cairn.go's header for why widening it is a one-line change here and an
// unrecoverable one in the store.
//
// β SETTING IT WITH NO CREDENTIAL CONFIGURED IS NOT AN ERROR, it is simply
// inert. The alternative β refusing β would make an installation that has not
// configured a store unable to dispatch its supervisor at all.
CairnEligible bool
// JobBypassVeto, for a claude-code agent only, is why its JOB lanes must NOT
// run with permissions bypassed even though its worker pool is listed in
// ClaudeCodeConfig.BypassPools β e.g. it holds an approved grant on a
// connector that reaches GitHub (agentprovision). Non-empty vetoes the
// bypass; "" leaves the decision to [JobBypassListed].
JobBypassVeto string
// ClaudeCodeSession, for a claude-code agent only, is its primary CLI's
// per-agent settings: muster MCP tools to pre-allow, the model and the
// all-tools bypass. The zero
// value changes nothing (no variable is emitted).
ClaudeCodeSession ClaudeCodeSession
}
Options is the per-call part that is neither deployment config nor a column on the agent row.
type PoolDeployKey ΒΆ added in v0.110.0
type PoolDeployKey struct {
// Repo is owner/name. A worker of the pool must work on it, and a job on
// such a worker must name it; anything else is refused.
Repo string
// Secret names a Secret in the agents' namespace, made by the operator
// (muster never creates, reads or changes it), whose key
// [DeployKeySecretKey] holds the PRIVATE half of a deploy key added to Repo
// WITHOUT write access.
Secret string
}
PoolDeployKey is one worker pool's private-repository access: the ONE repository its key may be used for, and the Secret holding the key.
func PoolDeployKeyFor ΒΆ added in v0.110.0
func PoolDeployKeyFor(a agents.Agent, cfg Config) (PoolDeployKey, bool)
PoolDeployKeyFor is the deploy key agent a's pool is configured with: ONLY a pooled agent (a.WorkerPool set), never a chief, and only for a pool PoolDeployKeys names. ok=false is the anonymous default.
β Like JobBypassListed, it is read when the spec is built and when a job's worktree is made: a pool added to the configuration reaches a running worker's clone only at its next Stop -> Start (a worker that already has its checkout is not re-cloned), while its jobs' fetches follow the configuration at once.
type RuntimeConfig ΒΆ
type RuntimeConfig struct {
// Template is the runtime's configuration file, verbatim and OPAQUE. muster
// places it at [RuntimeConfigPath] and never looks inside.
Template []byte
// Install is the shell script Build runs as the container's command. It is
// placed at [RuntimeInstallPath] and executed with `sh -eu`.
//
// π΄ IT MUST END BY EXEC'ING THE IMAGE'S REAL ENTRYPOINT, and nothing in this
// repository can check that it does. Overriding a container's command
// discards the image's default arguments as well as its entrypoint, so a
// script that merely installs a file and exits turns an agent into a pod that
// completes successfully and never serves. The failure is NOT silent β the
// instance reports no ready endpoint and this change's startup probe never
// passes β but it is not diagnosable from here either, which is why it is
// written down.
//
// β `sh -eu`, SO A FAILING STEP STOPS THE CONTAINER. That is the same
// decision internal/provision/k8s's init container records at length: the
// project this came from wrapped its startup script so a failure could not
// abort the pod, and the cost was that nothing in the block could ever be
// OBSERVED to fail. A crash loop with a parse error in the log is the better
// outcome.
Install []byte
// DeriveBearer turns an agent's own hooks token into the credential its
// gateway will accept, and is muster's ONE implementation of that formula.
//
// π΄ IT IS A FUNCTION AND NOT A VALUE BECAUSE THE INPUT IS PER-AGENT, and it
// is injected rather than imported because this package deliberately holds no
// HTTP client while the package that owns the formula does β the identical
// argument [EnvGatewayToken] records for its own name living here. The
// binary's wiring supplies agentgateway.Runtime.Bearer; nothing else may
// supply anything else.
DeriveBearer func(hooksToken string) string
}
RuntimeConfig is the operator-supplied bundle that makes a provisioned agent's own gateway start, plus muster's half of the credential it will serve on.
π΄ ALL THREE FIELDS MOVE TOGETHER OR NONE OF THEM DO β see [Configured], and see buildSecrets for the same pattern applied to the token pair. Each pair of them without the third is a different silent failure: a template with no script is a file nothing reads; a script with no template is a command that fails on a missing input, inside a container, at startup; and either without the derivation is an installer that writes an EMPTY gateway credential, which is a well-formed configuration the runtime accepts and then refuses every turn against with a 401.
func (RuntimeConfig) Configured ΒΆ
func (r RuntimeConfig) Configured() bool
Configured reports whether the bundle is complete enough to install.
π΄ IT IS AN AND OF ALL THREE AND NOT A CONVENIENCE. Every caller asks this question once and emits every piece from that one branch, which is what makes a partial install UNEXPRESSIBLE rather than merely discouraged. cmd/muster-server refuses an incomplete bundle at boot, so a partial one should never reach here; this is the second line of that defence, and it fails toward "install nothing", which leaves the pre-existing behaviour rather than a half-written config.