Run pipeline stages on Claude Code (harness=claude)

A model stage with harness=claude, provider=anthropic and a Claude model id
runs one claude -p process per visit with the server user's Claude sign-in.
Only the declared tools exist (--tools) and nothing else is approved
(--permission-mode dontAsk); edits are approved only below the run directory
and the stage's artifacts directory. A permissions block, run write paths,
delivery=true and reasoning_effort none/minimal are refused, not widened.

Usage comes from the CLI's final result and counts toward budgets. Failures
are fixed text; billing, quota and rate-limit refusals map to
ErrProviderQuota. The redacted stream is the session export and evidence.
provider-check --harness claude and model overrides are covered.
This commit is contained in:
2026-11-11 10:30:37 +00:00
parent 16643b9f1b
commit bd07abcde8
19 changed files with 1448 additions and 16 deletions
+20 -2
View File
@@ -14,6 +14,7 @@ import (
"sync"
"time"
"git.a-wan.net/alan/pipelines/internal/claude"
"git.a-wan.net/alan/pipelines/internal/filediff"
"git.a-wan.net/alan/pipelines/internal/harness"
"git.a-wan.net/alan/pipelines/internal/opencode"
@@ -223,13 +224,20 @@ func (r *runner) startWithSchedule(request protocol.Message, origin *pipeline.Sc
// admission: an unknown stage key or a malformed provider/model must never
// insert a run row. The resolution is O(#overrides + #stages) with no model or
// network call, and the same helper is the authoritative precedence rule.
if _, err := pipeline.EffectiveModels(d.Graph, request.Model, request.StageModels); err != nil {
launchModels, err := pipeline.EffectiveModels(d.Graph, request.Model, request.StageModels)
if err != nil {
return nil, err
}
for _, s := range d.Graph.Stages {
if stage.EffectiveType(s.Type) != stage.ModelType {
continue
}
if s.Configs["harness"] == stage.ClaudeBackend && launchModels[s.Key].Provider != stage.ClaudeProvider {
return nil, fmt.Errorf("stage %q runs on the claude harness and needs an %s/<model> override", s.Key, stage.ClaudeProvider)
}
if s.Configs["harness"] == stage.ClaudeBackend && r.execute == nil && !claude.Available() {
return nil, fmt.Errorf("Claude Code is not installed on this execution server; run pipelines harness setup claude there")
}
if s.Configs["harness"] == "pi" && r.execute == nil {
configured, err := harness.Load()
if err != nil {
@@ -1941,6 +1949,16 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
result, err = (stage.ModelStage{Client: piClient}).Run(stageCtx, def, input)
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.OnOwnership = func(session, reference string, active bool) error {
c, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
return r.store.RunSession(c, id, sequence, session, active, stage.ClaudeBackend, reference)
}
result, err = (stage.ModelStage{Client: claudeClient}).Run(stageCtx, def, input)
stageSession = claudeClient.SessionID
client.Transcript = claudeClient.Transcript
} else if useAgent {
result, err = (stage.ModelStage{Client: client}).Run(stageCtx, def, input)
stageSession = client.SessionID
@@ -2242,7 +2260,7 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
func (r *runner) exportStageSession(ctx context.Context, owner pipeline.SessionOwner, artifactsDir string, runID int64, sequence int, key string, modelConfig stage.ModelConfig) *protocol.SessionExport {
evidence := &protocol.SessionExport{SessionID: owner.ID, Backend: owner.Backend, Directory: owner.Directory, RecordedAt: time.Now().UTC().Format(time.RFC3339)}
defer classifySessionExport(evidence)
if owner.Backend != "v1" && owner.Backend != "v2" && !(owner.Backend == "pi" && owner.Reference != "") {
if owner.Backend != "v1" && owner.Backend != "v2" && !((owner.Backend == "pi" || owner.Backend == stage.ClaudeBackend) && owner.Reference != "") {
evidence.Source = "unavailable"
evidence.Diagnostic = "session export unavailable: harness has no native export path"
return evidence