feat(config): Kit profiles pin a workload Kit and mixins by digest
This commit is contained in:
1 parent
0d042b72d9
commit
bc215e8daa
3 files changed
+54
-2
No files matched your search
@@ -445,6 +445,11 @@ target = "127.0.0.1:9090" # REQUIRED. The State Store gRPC address arch
|
||||
# [containers.profiles.network-investigator]
|
||||
# image = "archie-agent-net:local" # docker compose build agent-net; empty uses [containers].image
|
||||
# tools = [] # allowlist over MCP, script and plugin tools; empty allows all
|
||||
# A Kit profile runs every agent stage on an external CLI packaged as a Kit v3
|
||||
# image: the workload Kit, then mixins, each pinned by digest.
|
||||
# [containers.profiles.claude]
|
||||
# kit = ["docker/claude-code-kit@sha256:<digest>"]
|
||||
# adapter = "claude-code" # output adapter; empty runs without capture tools or usage
|
||||
|
||||
# At least one [[repos]] entry is required before archied will poll
|
||||
# anything -- it is deliberately left commented rather than shipped active:
|
||||
|
||||
@@ -857,6 +857,13 @@ type ContainerConfig struct {
|
||||
type AgentProfile struct {
|
||||
// Image is the container image; empty means [containers].image.
|
||||
Image string `toml:"image" yaml:"image"`
|
||||
// Kit makes this a harness profile: the workload Kit, then its mixins,
|
||||
// each pinned by digest. The task container is the workload's image and
|
||||
// every agent stage runs on its CLI. Exclusive with Image.
|
||||
Kit []string `toml:"kit" yaml:"kit"`
|
||||
// Adapter names the output adapter reading the Kit's CLI; empty runs it
|
||||
// with no capture tools and no usage.
|
||||
Adapter string `toml:"adapter" yaml:"adapter"`
|
||||
// Tools allowlists the tools archie adds to the agent (MCP servers,
|
||||
// repository scripts and skill plugins) by name. Empty allows them all.
|
||||
// The agent loop's own file tools are always present, read-only when a
|
||||
@@ -874,18 +881,33 @@ func (c ContainerConfig) Profile(name string) (AgentProfile, error) {
|
||||
if !ok {
|
||||
return AgentProfile{}, fmt.Errorf("agent profile %q is not configured", name)
|
||||
}
|
||||
if p.Image == "" {
|
||||
if p.Image == "" && !p.IsKit() {
|
||||
p.Image = c.Image
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// ValidateProfiles rejects a profile with an empty name or an empty tool name.
|
||||
// IsKit reports whether the profile runs a Kit harness.
|
||||
func (p AgentProfile) IsKit() bool { return len(p.Kit) > 0 }
|
||||
|
||||
// ValidateProfiles rejects a profile with an empty name, an empty tool
|
||||
// name, or a Kit that is not pinned by digest or also names an image.
|
||||
func (c ContainerConfig) ValidateProfiles() error {
|
||||
for name, p := range c.Profiles {
|
||||
if strings.TrimSpace(name) == "" {
|
||||
return fmt.Errorf("containers.profiles: a profile name must not be empty")
|
||||
}
|
||||
switch {
|
||||
case p.IsKit() && p.Image != "":
|
||||
return fmt.Errorf("containers.profiles.%s: image and kit are exclusive; a Kit profile runs the Kit's image", name)
|
||||
case !p.IsKit() && p.Adapter != "":
|
||||
return fmt.Errorf("containers.profiles.%s: adapter needs a kit", name)
|
||||
}
|
||||
for _, ref := range p.Kit {
|
||||
if !strings.Contains(ref, "@sha256:") {
|
||||
return fmt.Errorf("containers.profiles.%s.kit: %q must be pinned by digest", name, ref)
|
||||
}
|
||||
}
|
||||
for _, tool := range p.Tools {
|
||||
if strings.TrimSpace(tool) == "" {
|
||||
return fmt.Errorf("containers.profiles.%s.tools: a tool name must not be empty", name)
|
||||
|
||||
@@ -39,3 +39,28 @@ func TestContainerProfileResolution(t *testing.T) {
|
||||
t.Error("ValidateProfiles accepted an empty tool name")
|
||||
}
|
||||
}
|
||||
|
||||
func TestKitProfiles(t *testing.T) {
|
||||
const pinned = "docker/claude-code-kit@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
|
||||
c := ContainerConfig{Image: "archie-agent:1", Profiles: map[string]AgentProfile{
|
||||
"claude": {Kit: []string{pinned}, Adapter: "claude-code"},
|
||||
}}
|
||||
p, err := c.Profile("claude")
|
||||
if err != nil || p.Image != "" || !p.IsKit() {
|
||||
t.Fatalf("Profile() = %+v, %v; a Kit profile must not inherit the agent image", p, err)
|
||||
}
|
||||
for name, bad := range map[string]AgentProfile{
|
||||
"image and kit": {Image: "archie-agent:1", Kit: []string{pinned}},
|
||||
"unpinned kit": {Kit: []string{"docker/claude-code-kit:latest"}},
|
||||
"unpinned mixin": {Kit: []string{pinned, "me/setup:1"}},
|
||||
"adapter without a kit": {Adapter: "claude-code"},
|
||||
} {
|
||||
c := ContainerConfig{Profiles: map[string]AgentProfile{"p": bad}}
|
||||
if err := c.ValidateProfiles(); err == nil {
|
||||
t.Errorf("%s: ValidateProfiles accepted %+v", name, bad)
|
||||
}
|
||||
}
|
||||
if err := c.ValidateProfiles(); err != nil {
|
||||
t.Fatalf("a digest-pinned Kit profile was refused: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user