Stabilize guarded model delivery

Add validated OpenCode-only delivery capabilities, canonical linked-worktree access checks, isolated candidate verification, and guarded main settlement.

Wire the bounded reconnect-foreground controlled HTTP fixture through ordinary server construction so target verification obtains server-controlled provenance and rejects unknown or incompatible fixture evidence.

Checked packaged templates and packaged authoring skill references; no updates are needed because this draft-only infrastructure activates no definition. Recorded the stale reference and activation guidance in docs/notes/delivery-stabilization.md for the docs fold.
This commit is contained in:
2026-10-18 14:50:18 +01:00
parent 66b5f60b28
commit 2cdb9a9e93
15 changed files with 1335 additions and 5 deletions
+59 -2
View File
@@ -58,8 +58,11 @@ type runner struct {
// directory. It defaults to stage.ExportSession; a failure is best-effort and
// never changes the stage's status, outcome, target or result validation.
exportSession func(context.Context, stage.SessionExportRequest) (stage.SessionExportResult, error)
wg sync.WaitGroup
schedulerWG sync.WaitGroup
// verifyTarget is installed only by server wiring for a controlled fixture
// workflow. Leaving it nil fails closed for target-aware definitions.
verifyTarget stage.VerificationRunner
wg sync.WaitGroup
schedulerWG sync.WaitGroup
// attentionMu guards attentionSent, the per-run set of run-attention events
// already delivered — by a stage's own notify policy or by the run-level
// default — so neither republishes the same genuine event.
@@ -1079,7 +1082,22 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
}
}
operations := &stage.OperationLog{}
var landing stage.LandingAccess
delivery, deliveryErr := stage.DeliveryEnabled(def)
if deliveryErr != nil {
finish("failed", "error", deliveryErr.Error())
return
}
if delivery {
access, accessErr := landingAccess(workspace)
if accessErr != nil {
finish("failed", "error", "delivery access denied: "+accessErr.Error())
return
}
landing = access
}
client := r.agentClient(id, sequence, state.artifactDirs, workspace, artifactsDir, operations, request.WritePaths, tools)
client.LandingAccess = landing
client.OnSession = func(session string, active bool) error {
c, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
@@ -1222,6 +1240,45 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
step.Output["salvage"] = result.Output
}
}
if err == nil && result.Outcome == "success" {
target, targetErr := stage.VerificationTargetFor(def)
if targetErr != nil {
err = targetErr
} else if target != nil {
if r.verifyTarget == nil {
err = fmt.Errorf("verification target %q requires a server-controlled fixture runner", target.Fixture)
} else {
evidence, verificationErr := r.verifyTarget(stageCtx, *target)
if verificationErr != nil {
err = verificationErr
} else {
err = stage.VerifyTargetEvidence(*target, evidence)
}
}
}
if err != nil {
step.Status = "failed"
step.Diagnostic = err.Error()
step.Outcome = "error"
step.Output = stage.Values{"error": err.Error(), "stage": key, "input": input}
}
}
if err == nil && delivery && result.Outcome == "success" {
checks, checksErr := stage.DeliveryChecks(def)
if checksErr != nil {
err = checksErr
} else {
gateCtx, gateCancel := context.WithTimeout(stageCtx, modelConfig.Timeout)
err = verifyDelivery(gateCtx, workspace, landing, checks)
gateCancel()
}
if err != nil {
step.Status = "failed"
step.Diagnostic = err.Error()
step.Outcome = "error"
step.Output = stage.Values{"error": err.Error(), "stage": key, "input": input}
}
}
// A failed or timed-out step carries the session pointer even when the
// bounded transcript would otherwise be only its stage_limits envelope.
if err != nil && stageSession != "" {