Stages: optional skills block loading pinned library skills per visit

A model stage may declare a skills block (name or name@N per line).
Drafts and publications are validated against the server skill library;
human/ntfy stages reject the block. Each run resolves unpinned names to the
latest version at admission and records name@N per stage (run
stage_skills, step skills); retry reuses the recorded versions. Every visit
gets a private read-only copy of exactly those bundles under the run's
artifact tree, and the harness loads only them: Claude via a session
plugin (--plugin-dir, Skill tool with per-skill allow rules, bundled skills
off, ambient loads fail the visit), Pi via --skill under --no-skills, and
OpenCode via per-session instruction entries (V2 only). The app shows the
block in the stage definition and the resolved versions on each visit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 19:17:16 +00:00
parent 509d4c624f
commit 85a7284fba
34 changed files with 1418 additions and 35 deletions
+24 -3
View File
@@ -228,6 +228,19 @@ func (r *runner) startWithSchedule(request protocol.Message, origin *pipeline.Sc
if err != nil {
return nil, err
}
// Pin every skills block to library versions now. A retry reuses the
// versions its source run recorded for unpinned names, so a newer import
// never changes what a replayed stage loads.
var priorSkills map[string][]string
if request.RetrySource > 0 {
if priorSkills, err = r.store.RunStageSkills(r.ctx, request.RetrySource); err != nil {
return nil, err
}
}
stageSkills, err := r.store.ResolveStageSkills(r.ctx, d.Graph, priorSkills)
if err != nil {
return nil, err
}
for _, s := range d.Graph.Stages {
if stage.EffectiveType(s.Type) != stage.ModelType {
continue
@@ -345,7 +358,7 @@ func (r *runner) startWithSchedule(request protocol.Message, origin *pipeline.Sc
workspace = tree
request.Input["pwd"] = workspace
}
id, created, err := r.store.CreateRunTitled(r.ctx, d, request.RequestKey, workspace, request.AllowTools, request.WritePaths, request.Input, pipeline.RunOverrides{Schedule: origin, Model: request.Model, StageModels: request.StageModels, NotifyMode: request.NotifyMode, OutputFormat: request.OutputFormat}, runTitle, retryOf...)
id, created, err := r.store.CreateRunTitled(r.ctx, d, request.RequestKey, workspace, request.AllowTools, request.WritePaths, request.Input, pipeline.RunOverrides{Schedule: origin, Model: request.Model, StageModels: request.StageModels, NotifyMode: request.NotifyMode, OutputFormat: request.OutputFormat, StageSkills: stageSkills}, runTitle, retryOf...)
if isolated != "" && (err != nil || !created) {
// The run was refused or an identical request won the race: the fresh
// tree holds nothing yet.
@@ -1857,6 +1870,12 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
def.ArtifactsDir = artifactsDir
def.Turn = stageTurnPaths(visitTurn)
publicBefore = publicFileSet(visitTurn.RunDir)
skillSet, skillErr := r.visitSkills(ctx, id, key, visitTurn, adopted != nil)
if skillErr != nil {
finish("failed", "error", "skills: "+skillErr.Error())
return
}
def.Skills = skillSet
}
operations := &stage.OperationLog{}
var landing stage.LandingAccess
@@ -1874,6 +1893,7 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
landing = access
}
client := r.agentClient(id, sequence, state.artifactDirs, workspace, artifactsDir, operations, request.WritePaths, tools)
client.Skills = def.Skills
client.LandingAccess = landing
client.OnSession = func(session string, active bool) error {
c, cancel := context.WithTimeout(context.Background(), 10*time.Second)
@@ -1943,6 +1963,7 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
return
}
piClient = r.piClient(id, sequence, state.artifactDirs, profile.Executable, workspace, artifactsDir, request.WritePaths, tools)
piClient.Skills = def.Skills
piClient.OnOwnership = func(session, reference string, active bool) error {
c, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
@@ -1952,7 +1973,7 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
stageSession = piClient.SessionID
client.Transcript = piClient.Transcript
} else if modelConfig.Harness == stage.ClaudeBackend {
claudeClient := &stage.ClaudeStageClient{Directory: workspace, Tools: tools, WritePaths: request.WritePaths, ArtifactsDir: artifactsDir}
claudeClient := &stage.ClaudeStageClient{Directory: workspace, Tools: tools, WritePaths: request.WritePaths, ArtifactsDir: artifactsDir, Skills: def.Skills}
claudeClient.OnOwnership = func(session, reference string, active bool) error {
c, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
@@ -1965,7 +1986,7 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
result, err = (stage.ModelStage{Client: client}).Run(stageCtx, def, input)
stageSession = client.SessionID
} else if stage.EffectiveType(def.Type) == stage.ModelType {
plain := &stage.OpenCodeClient{Directory: workspace, Operations: operations, ArtifactsDir: artifactsDir}
plain := &stage.OpenCodeClient{Directory: workspace, Operations: operations, ArtifactsDir: artifactsDir, Skills: def.Skills}
if adopted != nil {
plain.Backend, plain.Reference = adopted.owner.Backend, adopted.owner.Reference
}