Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/ADRs/0045-forge-portable-harness-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ resolved as follows:
| `skills` | Merged with deduplication by basename (forge overrides top-level) | Absent (nil) = inherit; `skills: []` = no forge-specific additions (top-level skills still apply) |
| `runner_env` | Top-level map merged with forge map; forge keys win | Absent (nil) = inherit; `runner_env: {}` = no forge-specific keys (top-level env still inherited) |
| `validation_loop`| Forge value replaces top-level value entirely | Absent (nil) = inherit from top level; explicit empty struct = intended to mean "no validation" but requires implementation changes (see note¹) |
| `providers` | Top-level + forge (concatenated) | Absent (nil) = inherit; `providers: []` = no forge-specific additions (top-level providers still apply) |
| `openshell` | `profiles` concatenated (top-level + forge) | Absent (nil) = inherit; empty `profiles: []` = no forge-specific additions |

¹ An explicit empty `validation_loop: {}` currently conflicts with
`Validate()`, which requires `Script` when `ValidationLoop` is non-nil.
Expand Down Expand Up @@ -250,6 +252,8 @@ compatibility.
| `runner_env` | Token names and event URLs differ per forge |
| `validation_loop` | Validation scripts may call forge-specific tools |
| `policy` | Sandbox policies may need forge-specific filesystem or process rules; network access is managed via providers (ADR-0065) but non-network policy sections can still differ per forge |
| `providers` | Providers may need forge-specific entries (e.g., different API endpoints per platform); concatenated (top-level + forge) |
| `openshell` | OpenShell profiles may need forge-specific configuration; `profiles` concatenated (top-level + forge) |

#### Fields that stay at top level only (platform-neutral)

Expand All @@ -259,7 +263,6 @@ compatibility.
| `model` | Model selection is independent of forge |
| `image` | Container images are platform-neutral |
| `host_files` | File delivery is a runner concern, not forge (note: forge-specific `host_files` added in #5917) |
| `providers` | OpenShell providers are forge-agnostic |
| `api_servers` | REST proxies abstract forge details |
| `plugins` | MCP plugins are forge-agnostic; can be local paths or URLs (ADR-0038) |
| `agent_input` | Agent prompt input is forge-agnostic |
Expand Down Expand Up @@ -364,7 +367,9 @@ The same inheritance table applies to base→child merging:
- **`validation_loop`**: child replaces base entirely (if non-nil)
- **`host_files`**: concatenated (base + child); if both declare the same
`dest` path, the child entry wins (last-writer-wins deduplication)
- **`plugins`, `providers`, `api_servers`**: concatenated (base + child)
- **`providers`**: concatenated (base + child); applies at both top level and per-forge
- **`openshell`**: `profiles` concatenated (base + child); applies at both top level and per-forge
- **`plugins`, `api_servers`**: concatenated (base + child)
- **`security`**: child replaces base entirely (if non-nil)
- **`forge` blocks**: child's `forge:` map merges key-by-key with base's
`forge:` map. For each platform key present in both, the per-platform
Expand Down Expand Up @@ -473,6 +478,8 @@ type ForgeConfig struct {
PostScript string `yaml:"post_script,omitempty"`
Policy string `yaml:"policy,omitempty"`
Skills []string `yaml:"skills,omitempty"`
Providers []string `yaml:"providers,omitempty"`
OpenShell *OpenShellConfig `yaml:"openshell,omitempty"`
HostFiles []HostFile `yaml:"host_files,omitempty"` // added in #5917
ValidationLoop *ValidationLoop `yaml:"validation_loop,omitempty"`
RunnerEnv map[string]string `yaml:"runner_env,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ repo baseline and overrides)
([ADR 0022](ADRs/0022-harness-level-output-schema-enforcement.md)).
- Forge-portable harness schema: `role` and `slug` move into the harness
YAML (eliminating the config.yaml `agents:` block dependency), and a
`forge:` section separates platform-specific config (scripts, skills,
runner_env) from platform-neutral fields. Forge blocks inherit from
`forge:` section separates platform-specific config from platform-neutral
fields (see ADR-0045 for the full list of forge-overridable fields). Forge blocks inherit from
top-level defaults and override only deltas
([ADR 0045](ADRs/0045-forge-portable-harness-schema.md)).
- Unified env var delivery: a single `env:` key with `runner` and `sandbox`
Expand Down
2 changes: 1 addition & 1 deletion docs/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ See [autonomy-spectrum.md](problems/autonomy-spectrum.md).

### Base Composition

The mechanism for customizing an agent's harness: a thin harness file sets `base:` to a local path or URL pointing at an upstream harness, then declares only the fields that differ. Scalars override the base value; `skills` merges with deduplication by basename (child overrides); `plugins`, `providers`, and `api_servers` concatenate (base + child, no dedup at composition time); `env.runner` and `env.sandbox` merge as independent maps (child keys win); `runner_env` is deprecated in favor of `env.runner`. Replaced the deprecated [`customized/` directory](#customized-directory) overlay, which required copying and maintaining an entire upstream YAML file to change a single field.
The mechanism for customizing an agent's harness: a thin harness file sets `base:` to a local path or URL pointing at an upstream harness, then declares only the fields that differ. Scalars override the base value; `skills` merges with deduplication by basename (child overrides); `plugins`, `providers`, `openshell.profiles`, and `api_servers` concatenate (base + child, no dedup at composition time); `env.runner` and `env.sandbox` merge as independent maps (child keys win); `runner_env` is deprecated in favor of `env.runner`. Replaced the deprecated [`customized/` directory](#customized-directory) overlay, which required copying and maintaining an entire upstream YAML file to change a single field.
See [ADR 0045](ADRs/0045-forge-portable-harness-schema.md), [ADR 0055](ADRs/0055-unified-env-var-delivery.md), [ADR 0064](ADRs/0064-deprecate-customized-directory-overlay.md), and [Configuring Agent Behavior](guides/user/customizing-agents.md).

### Blast Radius
Expand Down
8 changes: 6 additions & 2 deletions docs/guides/user/bring-your-own-agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Key patterns to note:
- **`policy: policies/triage.yaml`** is a per-agent policy that includes filesystem, landlock, process, and network rules (via inline `network_policies`). This agent predates the provider-based pattern — new agents can use `providers:` instead (see [Minimum viable agent](#minimum-viable-agent)).
- **`host_files`** copy credentials from the trusted runner into the sandbox. `expand: true` resolves `${VAR}` references before copying.
- **`validation_loop.schema`** references the JSON schema file directly — the validation script checks agent output against it.
- **`forge.github`** scopes scripts, skills, host_files, and env vars to GitHub. When running on GitLab, a `forge.gitlab` block would take effect instead.
- **`forge.github`** scopes scripts, skills, providers, openshell, host_files, and env vars to GitHub. When running on GitLab, a `forge.gitlab` block would take effect instead.
- **`common/env/gcp-vertex.env`** is referenced by relative path because both files live in the same repo. If your agent lives in a different repo, reference it by URL (see [Remote references](#referencing-resources-local-vs-remote)) or copy it locally.

## Harness field reference
Expand Down Expand Up @@ -278,6 +278,9 @@ forge:
pre_script: scripts/pre-gh.sh
post_script: scripts/post-gh.sh
skills: [skills/github-specific] # Concatenated with top-level
providers: [providers/github.yaml] # Concatenated with top-level
openshell:
profiles: [profiles/github.yaml] # Concatenated with top-level
host_files: # Forge-specific host files
- src: env/github.env
dest: /run/secrets/forge.env
Expand Down Expand Up @@ -313,7 +316,8 @@ security:
|-----------|----------|
| Scalars (`model`, `pre_script`, `policy`, `image`, etc.) | Child wins if non-empty |
| `skills` | Merged with deduplication by basename (child overrides base) |
| `plugins`, `providers`, `api_servers`, `openshell.profiles` | Concatenated (base + child) |
| `providers`, `openshell.profiles` | Concatenated (base + child); also applies per-forge |
| `plugins`, `api_servers` | Concatenated (base + child) |
| `host_files` | Concatenated; child overrides by `dest` |
| `env`, `runner_env` (deprecated) | Merged; child keys win |
| `validation_loop`, `security` | Child replaces entirely |
Expand Down
8 changes: 6 additions & 2 deletions internal/cli/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,8 @@ func resolveFromLock(h *harness.Harness, entry *lock.HarnessLock, workspaceRoot
deps = append(deps, dep)
continue
}
if strings.HasPrefix(lockDep.Field, "openshell.profiles[") {
if strings.HasPrefix(lockDep.Field, "openshell.profiles[") ||
(strings.HasPrefix(lockDep.Field, "forge.") && strings.Contains(lockDep.Field, ".openshell.profiles[")) {
id, err := resolve.ParseProfileID(cachedContent)
if err != nil {
return resolve.ResolveResult{}, fmt.Errorf("cached profile %s: %w", lockDep.Field, err)
Expand All @@ -838,7 +839,8 @@ func resolveFromLock(h *harness.Harness, entry *lock.HarnessLock, workspaceRoot
localPath = namedPath
dep.LocalPath = namedPath
profiles = append(profiles, resolve.ResolvedProfile{ID: id, LocalPath: localPath, FromURL: true})
} else if strings.HasPrefix(lockDep.Field, "providers[") {
} else if strings.HasPrefix(lockDep.Field, "providers[") ||
(strings.HasPrefix(lockDep.Field, "forge.") && strings.Contains(lockDep.Field, ".providers[")) {
var def harness.ProviderDef
if err := yaml.Unmarshal(cachedContent, &def); err != nil {
return resolve.ResolveResult{}, fmt.Errorf("parsing cached provider %s: %w", lockDep.Field, err)
Expand Down Expand Up @@ -958,6 +960,8 @@ func resolveFromLock(h *harness.Harness, entry *lock.HarnessLock, workspaceRoot
// correctly named path is already in place. This entry exists for
// cache verification only — appending it via the default case
// would duplicate the skill under the cache's internal tree name.
case strings.HasPrefix(m.field, "forge.") && strings.Contains(m.field, ".providers["):
case strings.HasPrefix(m.field, "forge.") && strings.Contains(m.field, ".openshell.profiles["):
default:
var idx int
if _, err := fmt.Sscanf(m.field, "skills[%d]", &idx); err == nil && idx >= 0 && idx < len(h.Skills) {
Expand Down
110 changes: 97 additions & 13 deletions internal/harness/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,15 @@ func resolveBaseHostFiles(ctx context.Context, base *Harness, baseURL string, al
// fetched from the base URL's directory, cached content-addressed, and the
// entry is rewritten to the local cache path.
func resolveBaseProfiles(ctx context.Context, base *Harness, baseURL string, allowlist []string, opts ComposeOpts) ([]Dependency, error) {
if base.OpenShell == nil || len(base.OpenShell.Profiles) == 0 {
hasTopLevel := base.OpenShell != nil && len(base.OpenShell.Profiles) > 0
hasForge := false
for _, fc := range base.Forge {
if fc != nil && fc.OpenShell != nil && len(fc.OpenShell.Profiles) > 0 {
hasForge = true
break
}
}
if !hasTopLevel && !hasForge {
return nil, nil
}

Expand All @@ -985,20 +993,44 @@ func resolveBaseProfiles(ctx context.Context, base *Harness, baseURL string, all

var deps []Dependency

for i, p := range base.OpenShell.Profiles {
if p == "" || IsURL(p) || isFullsendCachePath(p, opts.WorkspaceRoot) {
continue
if base.OpenShell != nil {
for i, p := range base.OpenShell.Profiles {
if p == "" || IsURL(p) || isFullsendCachePath(p, opts.WorkspaceRoot) {
continue
}
fieldName := fmt.Sprintf("openshell.profiles[%d]", i)
if err := validateBaseRelPath(fieldName, p); err != nil {
return nil, err
}
dep, cachePath, err := fetchBaseFile(ctx, fieldName, baseURLDir, p, allowlist, opts, "resource", false)
if err != nil {
return nil, err
}
base.OpenShell.Profiles[i] = cachePath
deps = append(deps, dep)
}
fieldName := fmt.Sprintf("openshell.profiles[%d]", i)
if err := validateBaseRelPath(fieldName, p); err != nil {
return nil, err
}

// Forge-specific profiles: same fetch treatment as top-level profiles.
for platform, fc := range base.Forge {
if fc == nil || fc.OpenShell == nil {
continue
}
dep, cachePath, err := fetchBaseFile(ctx, fieldName, baseURLDir, p, allowlist, opts, "resource", false)
if err != nil {
return nil, err
for i, p := range fc.OpenShell.Profiles {
if p == "" || IsURL(p) || isFullsendCachePath(p, opts.WorkspaceRoot) {
continue
}
fieldName := fmt.Sprintf("forge.%s.openshell.profiles[%d]", platform, i)
if err := validateBaseRelPath(fieldName, p); err != nil {
return nil, err
}
dep, cachePath, err := fetchBaseFile(ctx, fieldName, baseURLDir, p, allowlist, opts, "resource", false)
if err != nil {
return nil, err
}
fc.OpenShell.Profiles[i] = cachePath
deps = append(deps, dep)
}
base.OpenShell.Profiles[i] = cachePath
deps = append(deps, dep)
}

return deps, nil
Expand All @@ -1010,7 +1042,15 @@ func resolveBaseProfiles(ctx context.Context, base *Harness, baseURL string, all
// the file is fetched from the base URL's directory, cached
// content-addressed, and the entry is rewritten to the local cache path.
func resolveBaseProviders(ctx context.Context, base *Harness, baseURL string, allowlist []string, opts ComposeOpts) ([]Dependency, error) {
if len(base.Providers) == 0 {
hasTopLevel := len(base.Providers) > 0
hasForge := false
for _, fc := range base.Forge {
if fc != nil && len(fc.Providers) > 0 {
hasForge = true
break
}
}
if !hasTopLevel && !hasForge {
return nil, nil
}

Expand Down Expand Up @@ -1040,6 +1080,31 @@ func resolveBaseProviders(ctx context.Context, base *Harness, baseURL string, al
deps = append(deps, dep)
}

// Forge-specific providers: same fetch treatment as top-level providers.
for platform, fc := range base.Forge {
if fc == nil {
continue
}
for i, p := range fc.Providers {
if p == "" || IsURL(p) || isFullsendCachePath(p, opts.WorkspaceRoot) {
continue
}
if !IsProviderPath(p) {
continue
}
fieldName := fmt.Sprintf("forge.%s.providers[%d]", platform, i)
if err := validateBaseRelPath(fieldName, p); err != nil {
return nil, err
}
dep, cachePath, err := fetchBaseFile(ctx, fieldName, baseURLDir, p, allowlist, opts, "resource", false)
if err != nil {
return nil, err
}
fc.Providers[i] = cachePath
deps = append(deps, dep)
}
}

return deps, nil
}

Expand Down Expand Up @@ -1868,6 +1933,25 @@ func mergeForgeConfigInto(base, child *ForgeConfig) {
child.Skills = mergeSkills(base.Skills, child.Skills)
}

// Providers: base + child (concatenated)
if base.Providers != nil {
merged := make([]string, 0, len(base.Providers)+len(child.Providers))
merged = append(merged, base.Providers...)
merged = append(merged, child.Providers...)
child.Providers = merged
}

// OpenShell.Profiles: base + child (concatenated)
if base.OpenShell != nil && len(base.OpenShell.Profiles) > 0 {
if child.OpenShell == nil {
child.OpenShell = &OpenShellConfig{}
}
merged := make([]string, 0, len(base.OpenShell.Profiles)+len(child.OpenShell.Profiles))
merged = append(merged, base.OpenShell.Profiles...)
merged = append(merged, child.OpenShell.Profiles...)
child.OpenShell.Profiles = merged
}

// HostFiles: concatenated with last-writer-wins dedup by Dest
if base.HostFiles != nil {
child.HostFiles = mergeHostFiles(base.HostFiles, child.HostFiles)
Expand Down
Loading
Loading