refactor(workflow): drop the root identity alias from workflow definitions

This commit is contained in:
sam committed 2026-10-17 17:09:37 +11:00
1 parent 44a10943c3
commit db982f2d93
5 files changed
+2 -14

No files matched your search

+2 -3
View File
@@ -60,12 +60,11 @@ 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. RootRef names the instance root, whose name differs per install,
// so the shipped workflows can declare it.
// install.
func (d *Daemon) declaredIdentity(ctx context.Context, task *workflow.Task, ref string) (identity.IdentityID, string, error) {
var id identity.IdentityID
var name string
if ref == workflow.RootRef || identity.IdentityID(ref) == d.RootIdentityID || identity.StableID(ref) == d.RootIdentityID {
if identity.IdentityID(ref) == d.RootIdentityID || identity.StableID(ref) == d.RootIdentityID {
id = d.RootIdentityID
} else {
id, name = identity.IdentityID(ref), ref
@@ -108,7 +108,6 @@ func TestWorkflowIdentity(t *testing.T) {
{"refused execution is parked", deploy, "", runAllowed{"root": true}, "", true, []identity.IdentityID{"id-deployer"}, false},
{"called workflow runs as its own identity, not its caller's", callee, "id-deployer", runAllowed{"id-deployer": true, "id-bot": true}, "id-bot", false, nil, false},
{"caller refused the called workflow is parked", callee, "id-deployer", runAllowed{"id-bot": true}, "", true, []identity.IdentityID{"id-deployer"}, false},
{"workflow naming the root runs as the root", "id: deploy\nidentity: root\n", "id-bot", runAllowed{"root": true, "id-bot": true}, "", false, nil, false},
{"no declared identity is refused", "id: deploy\n", "id-bot", runAllowed{"root": true, "id-bot": true}, "", true, nil, false},
{"unconfigured identity is parked", "id: deploy\nidentity: ghost\n", "", runAllowed{"root": true}, "", true, nil, false},
{"disabled workflow is parked", deploy, "id-bot", runAllowed{"id-bot": true, "id-deployer": true}, "", true, nil, true},
-5
View File
@@ -69,11 +69,6 @@ type SwitchStep struct {
Cases map[string][]StepRecord `yaml:"cases" json:"cases"`
}
// RootRef is the identity a workflow declares to run as the instance root.
// Nothing ships with it; stored copies that still name it keep running as
// the root until edited.
const RootRef = "root"
const switchDefault = "default"
// RetryPolicy is how often a failed step runs again, and how long it waits
@@ -81,7 +81,6 @@ func TestCredentialUsesPinnedExecutionIdentity(t *testing.T) {
denied bool
}{
{"id: x\nidentity: execution-agent\n", "execution-agent", false},
{"id: x\nidentity: root\n", "", false},
{"id: x\n", "", true},
} {
task := &task.Task{Identity: "requester", WorkflowDefinitionYAML: tt.definition}
@@ -20,7 +20,6 @@ import (
"github.com/samcharles93/archie-core/internal/domain/identity"
"github.com/samcharles93/archie-core/internal/domain/presence"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/domain/workflow"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/events"
"github.com/samcharles93/archie-core/internal/infrastructure/rpctls"
@@ -356,9 +355,6 @@ func executionReference(t *task.Task) (string, error) {
if iface.Identity == "" {
return "", fmt.Errorf("pinned workflow declares no execution identity")
}
if iface.Identity == workflow.RootRef {
return "", nil
}
return iface.Identity, nil
}