From d31a950daa5926672eb3e2c8799194cdf516f210 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Mon, 12 Oct 2026 01:53:55 +1100 Subject: [PATCH] feat(workflow): shipped workflows run as the instance root --- internal/daemon/workflow_identity.go | 5 +++-- internal/domain/workflow/definition.go | 3 +++ internal/domain/workflow/shipped/feasibility.yaml | 1 + internal/domain/workflow/shipped/implement.yaml | 1 + internal/domain/workflow/shipped/pr-review.yaml | 1 + internal/domain/workflow/shipped/remediate.yaml | 1 + internal/domain/workflow/shipped/tdd.yaml | 1 + internal/domain/workflow/shipped/triage.yaml | 1 + 8 files changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/daemon/workflow_identity.go b/internal/daemon/workflow_identity.go index 3a8bf3df5..8d73a8a3d 100644 --- a/internal/daemon/workflow_identity.go +++ b/internal/daemon/workflow_identity.go @@ -56,12 +56,13 @@ func (d *Daemon) adoptWorkflowIdentity(ctx context.Context, task *workflow.Task) // declaredIdentity resolves a workflow's declared identity to the ID it is // authorized as and the name the task carries while it runs: a configured // identity's name, or empty for the root identity of a single-identity -// install. +// install. RootRef names the instance root, whose name differs per install, +// so the shipped workflows can declare it. func (d *Daemon) declaredIdentity(ref string) (identity.IdentityID, string, bool) { if runner := d.identityFor(&workflow.Task{Identity: ref}); runner != nil { return runner.ID, runner.Name, true } - if identity.IdentityID(ref) == d.RootIdentityID || identity.StableID(ref) == d.RootIdentityID { + if ref == workflow.RootRef || identity.IdentityID(ref) == d.RootIdentityID || identity.StableID(ref) == d.RootIdentityID { return d.RootIdentityID, "", true } return "", "", false diff --git a/internal/domain/workflow/definition.go b/internal/domain/workflow/definition.go index 811949bbe..15db664e1 100644 --- a/internal/domain/workflow/definition.go +++ b/internal/domain/workflow/definition.go @@ -69,6 +69,9 @@ type SwitchStep struct { Cases map[string][]StepRecord `yaml:"cases" json:"cases"` } +// RootRef is the identity a workflow declares to run as the instance root. +const RootRef = "root" + const switchDefault = "default" // RetryPolicy is how often a failed step runs again, and how long it waits diff --git a/internal/domain/workflow/shipped/feasibility.yaml b/internal/domain/workflow/shipped/feasibility.yaml index e686b6e27..08f5ef65f 100644 --- a/internal/domain/workflow/shipped/feasibility.yaml +++ b/internal/domain/workflow/shipped/feasibility.yaml @@ -1,4 +1,5 @@ id: feasibility +identity: root steps: - type: repo.prepare - id: assess diff --git a/internal/domain/workflow/shipped/implement.yaml b/internal/domain/workflow/shipped/implement.yaml index bb2ce8a4b..812395198 100644 --- a/internal/domain/workflow/shipped/implement.yaml +++ b/internal/domain/workflow/shipped/implement.yaml @@ -1,4 +1,5 @@ id: implement +identity: root steps: - type: repo.prepare - type: gate.repository diff --git a/internal/domain/workflow/shipped/pr-review.yaml b/internal/domain/workflow/shipped/pr-review.yaml index cf154258e..f110acf38 100644 --- a/internal/domain/workflow/shipped/pr-review.yaml +++ b/internal/domain/workflow/shipped/pr-review.yaml @@ -1,4 +1,5 @@ id: pr-review +identity: root inputs: pr_number: type: number diff --git a/internal/domain/workflow/shipped/remediate.yaml b/internal/domain/workflow/shipped/remediate.yaml index ffb149b34..a6753cdc2 100644 --- a/internal/domain/workflow/shipped/remediate.yaml +++ b/internal/domain/workflow/shipped/remediate.yaml @@ -1,4 +1,5 @@ id: remediate +identity: root steps: - type: review.start-round - type: repo.prepare diff --git a/internal/domain/workflow/shipped/tdd.yaml b/internal/domain/workflow/shipped/tdd.yaml index f5d80d7b1..230276b31 100644 --- a/internal/domain/workflow/shipped/tdd.yaml +++ b/internal/domain/workflow/shipped/tdd.yaml @@ -1,4 +1,5 @@ id: tdd +identity: root steps: - type: repo.prepare - type: gate.repository diff --git a/internal/domain/workflow/shipped/triage.yaml b/internal/domain/workflow/shipped/triage.yaml index d181d1dcb..8044bd050 100644 --- a/internal/domain/workflow/shipped/triage.yaml +++ b/internal/domain/workflow/shipped/triage.yaml @@ -1,4 +1,5 @@ id: triage +identity: root steps: - type: repo.prepare - id: classify