fix(eda): type-aware actions classifier, one stable-identifier grammar, loader tests that fail for the named reason
This commit is contained in:
1 parent
3a4af23caa
commit
4237b560b0
10 files changed
+111
-75
No files matched your search
@@ -226,7 +226,7 @@
|
||||
"url": "/dev/prds/eda-playbook-engine/",
|
||||
"title": "EDA playbook engine -- design",
|
||||
"section": "PRDs",
|
||||
"body": "# EDA playbook engine -- design\n\n**Status:** Draft\n**Date:** 2026-09-03\n**Beads epic:** `archie-core-t2db`\n\n## Problem\n\n\"Which workflow runs for which trigger\" is hardcoded Go: a literal\nlabel vocabulary (`workintake.labelKinds`) and a literal label-\u003eworkflow map\n(`workflow/routing.go`), extended only by adding a Go case or shipping a\nskill whose `metadata.archie.workflow` overrides one *named* built-in\nworkflow. Extending the system to a new trigger, a new action, or a new\nevent source means a feature branch, a code change in a hardcoded\npath, and new Go tests -- for every addition. That is the barrier this\ndocument exists to remove.\n\nThe goal: triggers, the actions they run, and the\nconditions that connect them should be **drop-in and load**, not **drop-in\nand touch application code**. Yaegi-evaluated Go is the unit of imperative\n\"do a thing\" logic; YAML playbooks are pure orchestration data -- no logic,\njust \"on this event, with this data, call these actions, in this order,\nunder these conditions.\" The daemon's event coordinator doesn't know what a\n`bugfix` or `image-gen` action does, it resolves the name against a\nregistry and pipes typed data through.\n\nThis is explicitly **not** scoped to code-generation workflows. A playbook\naction can be any registered capability -- run a codegen workflow, send a\nmessage on a channel, open something on a forge, generate an image -- so\nlong as it's implemented behind one of the typed engine families below.\n\n## Relationship to existing decisions\n\n- `docs/prds/event-sources-and-reactions.md` ruled\n that reactions in the two epics it covers are **producer-only** (no veto,\n no mutation of in-flight work) and explicitly rejected a single generic\n `Source` interface as \"the untyped-hook shape the plugin engine rule\n exists to prevent.\" **This document extends that scope**: playbooks can\n dispatch to multiple typed action kinds, not just \"produce a\n `TaskEnvelope`.\" It does not relitigate producer-only-ness (still no\n veto/mutation of in-flight work here) and it does not introduce one\n generic interface -- see \"Typed positions, not one generic hook\" below,\n which is how it stays compliant with the plugin engine rule instead of\n reopening that document's #4.\n- `docs/architecture/plugins-and-extensions.md#plugin-engine-rule-strict`\n governs every extension point\n introduced here. Every position below is a typed domain contract with an\n owning registry, not a generic callback map. This is a hard constraint,\n confirmed against the existing rule text before writing this doc.\n- Yaegi is already a proven in-process extension mechanism\n (`internal/plugin`, `internal/domain/workflow/wfeval/yaegi.go`,\n `internal/gate/gateeval/yaegi.go`, `internal/skill/plugin.go`) -- this\n design generalizes its existing role, it does not introduce a new\n execution mechanism.\n- `internal/domain/workflow/skillbuild.BuildRegistry` already composes a\n `workflow.Registry` from a skills catalog, plugin-defined overriding\n built-in. The playbook loader described here supersedes label routing\n specifically; it does not replace `skillbuild`'s workflow-composition role,\n it becomes an additional input the daemon composes at startup.\n- Webhook event intake is a separate design. This\n document defines the router each webhook-sourced event should be able to\n reach; it does not redesign webhook receipt itself.\n\n## Shape: four logic positions, each a typed engine family\n\nEvery entrypoint kind (mechanism, action, loop, schedule, route, trigger) is itself a schema emitter: defining a new kind produces the\ngenerated contract downstream tooling consumes. The kinds slot into a fixed\nhierarchy of logic positions:\n\n```\nWorkflow -\u003e Module -\u003e Channel (telegram/whatsapp/email/...)\n -\u003e Forge (GitHub/Gitea/GitLab/...)\n```\n\nEach position is its own typed engine family per the plugin engine rule:\nidentity + capability-specific operations, an owning `Registry`/`Manager`,\nexplicit lifecycle where the implementation owns resources, narrow host\naccess. Concretely:\n\n- **Workflow** -- already exists (`internal/domain/workflow`). A playbook\n action of kind `workflow` invokes a registered `workflow.Registry` entry\n by name, unchanged from the existing execution path.\n- **Module** -- the new general-purpose action position. A `Module` is a\n Yaegi-evaluated implementation of a generated interface (args in, typed\n result out) for one declared action kind (e.g. `image-gen`, `notify`,\n `open-pr-comment`). This is the position that makes actions \"not\n restricted to code-generation.\" Full design (schema-per-kind, the\n registry shape, the trust boundary, the recommended first slice):\n `docs/prds/module-position.md`.\n- **Channel** -- already exists as `channels.Channel` (telegram, email,\n webhook). A playbook action of kind `channel` sends through Line truncated
|
||||
"body": "# EDA playbook engine -- design\n\n**Status:** Draft\n**Date:** 2026-09-03\n**Beads epic:** `archie-core-t2db`\n\n## Problem\n\n\"Which workflow runs for which trigger\" is hardcoded Go: a literal\nlabel vocabulary (`workintake.labelKinds`) and a literal label-\u003eworkflow map\n(`workflow/routing.go`), extended only by adding a Go case or shipping a\nskill whose `metadata.archie.workflow` overrides one *named* built-in\nworkflow. Extending the system to a new trigger, a new action, or a new\nevent source means a feature branch, a code change in a hardcoded\npath, and new Go tests -- for every addition. That is the barrier this\ndocument exists to remove.\n\nThe goal: triggers, the actions they run, and the\nconditions that connect them should be **drop-in and load**, not **drop-in\nand touch application code**. Yaegi-evaluated Go is the unit of imperative\n\"do a thing\" logic; YAML playbooks are pure orchestration data -- no logic,\njust \"on this event, with this data, call these actions, in this order,\nunder these conditions.\" The daemon's event coordinator doesn't know what a\n`bugfix` or `image-gen` action does, it resolves the name against a\nregistry and pipes typed data through.\n\nThis is explicitly **not** scoped to code-generation workflows. A playbook\naction can be any registered capability -- run a codegen workflow, send a\nmessage on a channel, open something on a forge, generate an image -- so\nlong as it's implemented behind one of the typed engine families below.\n\n## Relationship to existing decisions\n\n- `docs/prds/event-sources-and-reactions.md` ruled\n that reactions in the two epics it covers are **producer-only** (no veto,\n no mutation of in-flight work) and explicitly rejected a single generic\n `Source` interface as \"the untyped-hook shape the plugin engine rule\n exists to prevent.\" **This document extends that scope**: playbooks can\n dispatch to multiple typed action kinds, not just \"produce a\n `TaskEnvelope`.\" It does not relitigate producer-only-ness (still no\n veto/mutation of in-flight work here) and it does not introduce one\n generic interface -- see \"Typed positions, not one generic hook\" below,\n which is how it stays compliant with the plugin engine rule instead of\n reopening that document's #4.\n- `docs/architecture/plugins-and-extensions.md#plugin-engine-rule-strict`\n governs every extension point\n introduced here. Every position below is a typed domain contract with an\n owning registry, not a generic callback map. This is a hard constraint,\n confirmed against the existing rule text before writing this doc.\n- Yaegi is already a proven in-process extension mechanism\n (`internal/plugin`, `internal/domain/workflow/wfeval/yaegi.go`,\n `internal/gate/gateeval/yaegi.go`, `internal/skill/plugin.go`) -- this\n design generalizes its existing role, it does not introduce a new\n execution mechanism.\n- `internal/domain/workflow/skillbuild.BuildRegistry` already composes a\n `workflow.Registry` from a skills catalog, plugin-defined overriding\n built-in. The playbook loader described here supersedes label routing\n specifically; it does not replace `skillbuild`'s workflow-composition role,\n it becomes an additional input the daemon composes at startup.\n- Webhook event intake is a separate design. This\n document defines the router each webhook-sourced event should be able to\n reach; it does not redesign webhook receipt itself.\n\n## Shape: four logic positions, each a typed engine family\n\nEvery entrypoint kind (mechanism, action, loop, schedule, route, trigger) is itself a schema emitter: defining a new kind produces the\ngenerated contract downstream tooling consumes. The kinds slot into a fixed\nhierarchy of logic positions:\n\n```\nWorkflow -\u003e Module -\u003e Channel (telegram/whatsapp/email/...)\n -\u003e Forge (GitHub/Gitea/GitLab/...)\n```\n\nEach position is its own typed engine family per the plugin engine rule:\nidentity + capability-specific operations, an owning `Registry`/`Manager`,\nexplicit lifecycle where the implementation owns resources, narrow host\naccess. Concretely:\n\n- **Workflow** -- already exists (`internal/domain/workflow`). A playbook\n action of kind `workflow` invokes a registered `workflow.Registry` entry\n by name, unchanged from the existing execution path.\n- **Module** -- the new general-purpose action position. A `Module` is a\n Yaegi-evaluated implementation of a generated interface (args in, typed\n result out) for one declared action kind (e.g. `image-gen`, `notify`,\n `open-pr-comment`). This is the position that makes actions \"not\n restricted to code-generation.\" Full design (schema-per-kind, the\n registry shape, the trust boundary, the recommended first slice):\n `docs/prds/module-position.md`.\n- **Channel** -- already exists as `channels.Channel` (telegram, email,\n webhook). A playbook action of kind `channel` sends through Line truncated
|
||||
},
|
||||
{
|
||||
"url": "/dev/prds/embedded-nats/",
|
||||
|
||||
@@ -169,7 +169,10 @@ a case that should just be visible and fixed by a human. Instead:
|
||||
exiting non-zero on any collision / malformed file / invalid binding.
|
||||
A finding about one binding key leads with the key's `file:line`, read
|
||||
from the `yaml.Node` the loader decodes; the linter agrees with runtime
|
||||
validation by construction, which is the load-bearing property.
|
||||
validation by construction, which is the load-bearing property. That
|
||||
agreement covers the routing loaders only: EDA playbooks under
|
||||
`eda_playbook_dir` (`playbook.Load`, with its CEL and action-id checks)
|
||||
have no lint path yet and are validated only at daemon startup.
|
||||
Discoverable via `task lint:playbooks` or direct `go run
|
||||
./cmd/archie-playbooks lint -dir ...`. The LSP/serve mode is a later
|
||||
entrypoint of the SAME binary, per the shared-package decision above.
|
||||
|
||||
@@ -280,50 +280,41 @@ func (e *Env) Compile(src string) (*Program, error) {
|
||||
return &Program{prg: prg, actionIDs: ids, resolvable: resolvable}, nil
|
||||
}
|
||||
|
||||
// actionReferences walks the compiled AST once and classifies every read of
|
||||
// actionReferences walks the checked AST once and classifies every read of
|
||||
// the `actions` context root as either a statically-resolvable action id or
|
||||
// not. The invariant is exhaustive by construction: each read of `actions`
|
||||
// consumes exactly one `actions` identifier node, so counting identifier
|
||||
// nodes and counting the reads that match the static access shape (a field
|
||||
// selection on the `actions` ident) yields
|
||||
// not. A root read is an identifier the checker typed as the `actions`
|
||||
// object: matching on type rather than name keeps a comprehension variable
|
||||
// that happens to be called `actions` out of the count. Each root read
|
||||
// consumes exactly one such identifier, so
|
||||
//
|
||||
// resolvable = (identCount == staticCount)
|
||||
//
|
||||
// Any other spelling that mentions `actions` contributes an identifier node
|
||||
// without a matching static access, so it reports unresolvable rather than
|
||||
// slipping through as a runtime miss. The returned ids are the sorted,
|
||||
// de-duplicated ids of the static accesses.
|
||||
//
|
||||
// With the per-playbook object type the CEL checker rejects every non-static
|
||||
// `actions` read at compile time -- a dynamic index, `in`, `size`, or a
|
||||
// method/field selection that is not a declared id never reaches this walk.
|
||||
// The one spelling the checker does NOT reject is a bare `actions` value
|
||||
// read, which compiles as an object value but cannot be pinned to an action
|
||||
// id at load. This walk is retained solely to reject that spelling; the ids
|
||||
// return is now informational (the unknown-id check moved to the checker's
|
||||
// per-playbook object type).
|
||||
// where staticCount is the root reads that are a field selection. The
|
||||
// checker already rejects every other non-static read (a dynamic index,
|
||||
// `in`, `size`, an undeclared id); the spelling it accepts is a bare
|
||||
// `actions` value, which compiles but cannot be pinned to an action id at
|
||||
// load. This walk exists to reject that spelling; the ids return is
|
||||
// informational. The ids are sorted and de-duplicated.
|
||||
func actionReferences(ast *cel.Ast) ([]string, bool) {
|
||||
if ast == nil || ast.NativeRep() == nil {
|
||||
return nil, true
|
||||
}
|
||||
checked := ast.NativeRep()
|
||||
isRoot := func(e celast.Expr) bool {
|
||||
return e.Kind() == celast.IdentKind && checked.GetType(e.ID()).TypeName() == actionsTypeName
|
||||
}
|
||||
var identCount, staticCount int
|
||||
seen := map[string]struct{}{}
|
||||
visitor := celast.NewExprVisitor(func(e celast.Expr) {
|
||||
switch e.Kind() {
|
||||
case celast.IdentKind:
|
||||
if e.AsIdent() == "actions" {
|
||||
identCount++
|
||||
}
|
||||
case celast.SelectKind:
|
||||
sel := e.AsSelect()
|
||||
if !isActionsIdent(sel.Operand()) {
|
||||
return
|
||||
}
|
||||
switch {
|
||||
case isRoot(e):
|
||||
identCount++
|
||||
case e.Kind() == celast.SelectKind && isRoot(e.AsSelect().Operand()):
|
||||
staticCount++
|
||||
seen[sel.FieldName()] = struct{}{}
|
||||
seen[e.AsSelect().FieldName()] = struct{}{}
|
||||
}
|
||||
})
|
||||
celast.PreOrderVisit(ast.NativeRep().Expr(), visitor)
|
||||
celast.PreOrderVisit(checked.Expr(), visitor)
|
||||
ids := make([]string, 0, len(seen))
|
||||
for id := range seen {
|
||||
ids = append(ids, id)
|
||||
@@ -332,11 +323,6 @@ func actionReferences(ast *cel.Ast) ([]string, bool) {
|
||||
return ids, identCount == staticCount
|
||||
}
|
||||
|
||||
// isActionsIdent reports whether e is the `actions` context-root identifier.
|
||||
func isActionsIdent(e celast.Expr) bool {
|
||||
return e.Kind() == celast.IdentKind && e.AsIdent() == "actions"
|
||||
}
|
||||
|
||||
// Program is a compiled, cost-limited playbook expression.
|
||||
type Program struct {
|
||||
prg cel.Program
|
||||
|
||||
@@ -266,6 +266,24 @@ func TestActionReferences(t *testing.T) {
|
||||
wantIDs: nil,
|
||||
wantResolvable: false,
|
||||
},
|
||||
{
|
||||
name: "loop variable named actions is not the root",
|
||||
src: `event.list.exists(actions, actions == 1)`,
|
||||
wantIDs: nil,
|
||||
wantResolvable: true,
|
||||
},
|
||||
{
|
||||
name: "field of a loop variable named actions is not an action id",
|
||||
src: `event.list.exists(actions, actions.a == 1)`,
|
||||
wantIDs: nil,
|
||||
wantResolvable: true,
|
||||
},
|
||||
{
|
||||
name: "bare root still unresolvable beside a shadowing loop",
|
||||
src: `[actions].exists(actions, actions.build.result.written)`,
|
||||
wantIDs: []string{"build"},
|
||||
wantResolvable: false,
|
||||
},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
||||
@@ -23,13 +23,13 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/eda/expr"
|
||||
"github.com/samcharles93/archie-core/internal/domain/stableid"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workintake"
|
||||
)
|
||||
|
||||
@@ -131,14 +131,6 @@ type rawAction struct {
|
||||
Args map[string]string `yaml:"args"`
|
||||
}
|
||||
|
||||
// actionIDPattern is the stable-identifier shape a WORKFLOW action id must
|
||||
// match when declared: a lowercase, dotted/dashed identifier (shared with
|
||||
// internal/plugin/host.go:21 and internal/domain/workflow/vocabulary.go:19),
|
||||
// so an id has exactly one spelling and cannot smuggle whitespace or case into
|
||||
// the vocabulary two processes compare. Module action ids are stricter (see
|
||||
// validateModuleActionIDs) because they must also be CEL field selections.
|
||||
var actionIDPattern = regexp.MustCompile(`^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$`)
|
||||
|
||||
// Module action ids are stricter than workflow ids because they must also be
|
||||
// readable as `actions.<id>` in CEL field selection. The authoritative check
|
||||
// is expr.IsCELFieldName (which compiles the probe), plus a lowercase policy:
|
||||
@@ -157,8 +149,8 @@ func validateActionIDs(actions []rawAction) error {
|
||||
if id == "" {
|
||||
continue
|
||||
}
|
||||
if !actionIDPattern.MatchString(id) {
|
||||
return fmt.Errorf("action id %q is not a valid stable identifier (want %s)", id, actionIDPattern.String())
|
||||
if !stableid.Valid(id) {
|
||||
return fmt.Errorf("action id %q is not a valid stable identifier (want %s)", id, stableid.Pattern)
|
||||
}
|
||||
if _, dup := seen[id]; dup {
|
||||
return fmt.Errorf("duplicate action id %q", id)
|
||||
|
||||
@@ -520,23 +520,25 @@ func TestValidateActionIDs(t *testing.T) {
|
||||
// whole load, naming the playbook path -- never a runtime miss. Under the
|
||||
// per-playbook object type these forms are rejected at compile time: the
|
||||
// field-selection spelling names the undefined id, while a dynamic index, an
|
||||
// `in` test, or a size read fails with cel-go's overload error (no id name).
|
||||
// `in` test, or a size read fails with cel-go's overload error on the actions
|
||||
// type. wantErr pins that stage, so a case cannot pass on a YAML parse error
|
||||
// or an undeclared root instead.
|
||||
func TestLoadWhenActionsReferenceFails(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
when string
|
||||
wantID string
|
||||
name string
|
||||
when string
|
||||
wantErr string
|
||||
}{
|
||||
{name: "undeclared field selection", when: `actions.build.result.x == true`, wantID: "build"},
|
||||
{name: "dynamic index on actions", when: `actions["a"].result.x == true`},
|
||||
{name: "non-literal index key", when: `actions[key].result.x == true`},
|
||||
{name: "in operator on actions", when: `"notify" in actions`},
|
||||
{name: "size of actions", when: `size(actions) > 0`},
|
||||
{name: "undeclared field selection", when: `actions.build.result.x == true`, wantErr: "undefined field 'build'"},
|
||||
{name: "dynamic index on actions", when: `actions["a"].result.x == true`, wantErr: "'_[_]' applied to '(actions, string)'"},
|
||||
{name: "non-literal index key", when: `actions[event.kind].result.x == true`, wantErr: "'_[_]' applied to '(actions, dyn)'"},
|
||||
{name: "in operator on actions", when: `"notify" in actions`, wantErr: "'@in' applied to '(string, actions)'"},
|
||||
{name: "size of actions", when: `size(actions) > 0`, wantErr: "'size' applied to '(actions)'"},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFile(t, dir, "pb.yaml", "\ntrigger:\n kind: bug\nactions:\n - position: workflow\n workflow: tdd\n when: "+tc.when+"\n")
|
||||
writeFile(t, dir, "pb.yaml", "\ntrigger:\n kind: bug\nactions:\n - position: workflow\n workflow: tdd\n when: '"+tc.when+"'\n")
|
||||
_, err := Load(dir, testSchemas(t))
|
||||
if err == nil {
|
||||
t.Fatal("Load = nil, want load failure")
|
||||
@@ -544,8 +546,8 @@ func TestLoadWhenActionsReferenceFails(t *testing.T) {
|
||||
if !strings.Contains(err.Error(), "pb.yaml") {
|
||||
t.Errorf("Load error = %q, want the playbook path named", err.Error())
|
||||
}
|
||||
if tc.wantID != "" && !strings.Contains(err.Error(), tc.wantID) {
|
||||
t.Errorf("Load error = %q, want the unknown id %q named", err.Error(), tc.wantID)
|
||||
if !strings.Contains(err.Error(), tc.wantErr) {
|
||||
t.Errorf("Load error = %q, want %q", err.Error(), tc.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Package stableid owns the stable-identifier shape shared by plugin
|
||||
// manifests, workflow step types and playbook action ids: a lowercase,
|
||||
// dotted or dashed identifier, so one name has exactly one spelling and
|
||||
// cannot smuggle whitespace or case into a vocabulary two processes compare.
|
||||
package stableid
|
||||
|
||||
import "regexp"
|
||||
|
||||
// Pattern is the stable-identifier grammar, for error messages that quote it.
|
||||
const Pattern = `^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$`
|
||||
|
||||
var re = regexp.MustCompile(Pattern)
|
||||
|
||||
// Valid reports whether id is a stable identifier.
|
||||
func Valid(id string) bool { return re.MatchString(id) }
|
||||
@@ -0,0 +1,27 @@
|
||||
package stableid
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestValid(t *testing.T) {
|
||||
tests := []struct {
|
||||
id string
|
||||
want bool
|
||||
}{
|
||||
{"tdd", true},
|
||||
{"forge.github", true},
|
||||
{"step-type2.v1", true},
|
||||
{"", false},
|
||||
{"Tdd", false},
|
||||
{"2fa", false},
|
||||
{"a..b", false},
|
||||
{"a.", false},
|
||||
{"-a", false},
|
||||
{"a b", false},
|
||||
{"a_b", false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := Valid(tt.id); got != tt.want {
|
||||
t.Errorf("Valid(%q) = %v, want %v", tt.id, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,11 @@ import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"slices"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// stepTypeIdentifier is the shape a provider name and a step type name must
|
||||
// have: a lowercase, dotted identifier, so a contributed step type cannot
|
||||
// smuggle whitespace or case into the vocabulary two processes compare, and so
|
||||
// one step type has exactly one spelling. It reserves nothing: a contribution
|
||||
// that spells a shipped stage's name is well formed, and what refuses it is
|
||||
// Register's claimed-name check, not this rule.
|
||||
var stepTypeIdentifier = regexp.MustCompile(`^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$`)
|
||||
"github.com/samcharles93/archie-core/internal/domain/stableid"
|
||||
)
|
||||
|
||||
// StepType is one named workflow step type: the vocabulary word a YAML
|
||||
// workflow names, plus the factory that builds its stage.
|
||||
@@ -88,7 +81,7 @@ func (m *Manager) Register(provider StepTypeProvider) error {
|
||||
return errors.New("workflow step type provider is nil")
|
||||
}
|
||||
name := provider.Name()
|
||||
if !stepTypeIdentifier.MatchString(name) {
|
||||
if !stableid.Valid(name) {
|
||||
return fmt.Errorf("workflow step type provider name %q is not a stable identifier", name)
|
||||
}
|
||||
|
||||
@@ -97,7 +90,7 @@ func (m *Manager) Register(provider StepTypeProvider) error {
|
||||
order := make([]string, 0, len(contributed))
|
||||
for _, stepType := range contributed {
|
||||
switch {
|
||||
case !stepTypeIdentifier.MatchString(stepType.Name):
|
||||
case !stableid.Valid(stepType.Name):
|
||||
return fmt.Errorf("workflow step type provider %q: step type %q is not a stable identifier", name, stepType.Name)
|
||||
case stepType.Factory == nil:
|
||||
return fmt.Errorf("workflow step type provider %q: step type %q has no factory", name, stepType.Name)
|
||||
|
||||
@@ -12,14 +12,14 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/stableid"
|
||||
)
|
||||
|
||||
// HostAPIVersion is the capability-host contract version understood by this
|
||||
// archied binary.
|
||||
const HostAPIVersion = "1.0.0"
|
||||
|
||||
var stableIdentifier = regexp.MustCompile(`^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$`)
|
||||
|
||||
var semanticVersion = regexp.MustCompile(
|
||||
`^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$`,
|
||||
)
|
||||
@@ -48,7 +48,7 @@ type Manifest struct {
|
||||
|
||||
// Validate checks manifest identity, compatibility, declarations, and schema.
|
||||
func (m Manifest) Validate() error {
|
||||
if !stableIdentifier.MatchString(m.ID) {
|
||||
if !stableid.Valid(m.ID) {
|
||||
return fmt.Errorf("plugin manifest id %q is not a stable identifier", m.ID)
|
||||
}
|
||||
if strings.TrimSpace(m.Name) == "" {
|
||||
@@ -167,7 +167,7 @@ func validateIdentifiers(kind string, values []string, required bool) error {
|
||||
}
|
||||
seen := make(map[string]struct{}, len(values))
|
||||
for _, value := range values {
|
||||
if !stableIdentifier.MatchString(value) {
|
||||
if !stableid.Valid(value) {
|
||||
return fmt.Errorf("plugin manifest %s %q is not a stable identifier", kind, value)
|
||||
}
|
||||
if _, exists := seen[value]; exists {
|
||||
|
||||
Reference in new issue
Block a user