Share the locked invocation lifecycle
This commit is contained in:
@@ -140,7 +140,7 @@ can call it without rebuilding requests or acquiring a second lock.
|
||||
|
||||
## Stage 3: Extract The Runner's Locked Invocation Lifecycle
|
||||
|
||||
Status: Pending.
|
||||
Status: Complete. Verified with `GOTOOLCHAIN=go1.27.4 go test ./internal/app` and `git diff --check`.
|
||||
|
||||
Read `internal/app/{runner,runner_runtime,runner_stage_execution,runner_finalization,runner_composition,runner_dependencies}.go`,
|
||||
[Workspace Internals](../internal/workspace.md), and runner cancellation,
|
||||
|
||||
@@ -45,7 +45,11 @@ func executePlan(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts
|
||||
return executePlanWithDependencies(ctx, cfg, plan, opts, invocationDependencies{})
|
||||
}
|
||||
|
||||
func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts RunOptions, dependencies invocationDependencies) (summary *RunSummary, resultErr error) {
|
||||
func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts RunOptions, dependencies invocationDependencies) (*RunSummary, error) {
|
||||
return withLockedInvocation(ctx, cfg, plan, opts, dependencies, executeSelectedStages)
|
||||
}
|
||||
|
||||
func withLockedInvocation(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts RunOptions, dependencies invocationDependencies, operation func(*invocationRuntime) error) (summary *RunSummary, resultErr error) {
|
||||
dependencies = dependencies.normalized()
|
||||
runtime, err := prepareInvocation(ctx, cfg, plan, opts, dependencies)
|
||||
if err != nil {
|
||||
@@ -92,16 +96,20 @@ func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan B
|
||||
}
|
||||
|
||||
runtime.env.Info("selected run destinations", "session", runtime.identity.SessionID, "run", runtime.identity.RunID, "manifest", runtime.manifestPath, "workspace", runtime.identity.LocalWorkDir)
|
||||
return nil, operation(runtime)
|
||||
}
|
||||
|
||||
func executeSelectedStages(runtime *invocationRuntime) error {
|
||||
downstreamChecked := false
|
||||
for index, selected := range runtime.stages {
|
||||
if selected.Name() != "prepare" && !downstreamChecked {
|
||||
downstreamChecked = true
|
||||
if err := inspectInvocationRequirements(runtime, index); err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
if err := runtime.ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
outcome, err := executeSelectedStage(runtime, selected)
|
||||
result := &runtime.stageResults[index]
|
||||
@@ -129,10 +137,10 @@ func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan B
|
||||
runtime.skipped = append(runtime.skipped, selected.Name())
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil, ctx.Err()
|
||||
return runtime.ctx.Err()
|
||||
}
|
||||
|
||||
func stagesContainAny(stages []stage.Stage, names ...string) bool {
|
||||
|
||||
Reference in New Issue
Block a user