diff --git a/config.example.toml b/config.example.toml index 442176d96..605924ef2 100644 --- a/config.example.toml +++ b/config.example.toml @@ -17,7 +17,6 @@ # database_url = "postgres://archie:archie@127.0.0.1:5432/archie?sslmode=disable" # skills_dir = "~/.local/share/archie/skills" # SKILL.md search path; defaults under work_dir when unset -# module_dir = "~/.local/share/archie/modules" # EDA playbook Module action kinds (log.go etc.); unset means no modules loaded # workflow_routing_file = "~/.local/share/archie/workflow-routing.yaml" # kind->workflow rebinding (bug/feature/bootstrap) # workflow_labels_file = "~/.local/share/archie/workflow-labels.yaml" # arbitrary forge label -> workflow (EDA playbook slice 2) # playbook_dirs = ["~/.local/share/archie/workflows"] # list of dirs of *.yaml binding files, merged with the two above (slice 3); a key bound twice across sources is a load failure diff --git a/examples/modules/log.go b/examples/modules/log.go deleted file mode 100644 index 465aed7cb..000000000 --- a/examples/modules/log.go +++ /dev/null @@ -1,35 +0,0 @@ -//go:build ignore - -// log module implementation for archied's EDA playbook engine. The first action -// kind: side-effect-free -- it only writes a line to the daemon's log, so it -// proves the schema -> go:generate -// -> Yaegi load -> ModuleRegistry -> dispatch mechanism end to end without -// needing an idempotency answer. -// -// Install: copy this file into the configured module_dir (see module_dir -// in config.example.toml, e.g. ~/.local/share/archie/modules) and restart -// archied. The daemon evaluates it -// with Yaegi and registers kind "log". The //go:build ignore tag is a -// comment to the interpreter, so this file loads normally; the Go toolchain -// skips it, so it may live inside the module tree. -// -// Contract: package main, func Run(log.Args) log.Result -- resolved by name -// against logextract.Symbols, exactly as a custom gate resolves "gate.Check" -// against gateextract.Symbols. Args decode is strict: an unknown or -// wrong-typed field is a reported failure, not a silent zero fill. -package main - -import ( - "github.com/samcharles93/archie-core/internal/domain/eda/module/log" -) - -func Run(a log.Args) log.Result { - level := a.Level - if level == "" { - level = "info" - } - return log.Result{ - Written: a.Message != "", - Level: level, - } -} diff --git a/internal/app/archied/bootstrap.go b/internal/app/archied/bootstrap.go index 829affc7e..e3ac7407a 100644 --- a/internal/app/archied/bootstrap.go +++ b/internal/app/archied/bootstrap.go @@ -174,17 +174,11 @@ type boot struct { chatTasks gateway.TaskCreator defaultChatIdentity string - startGateways []func() - // pluginReconciler loads plugin and module files dropped into - // the running config's directories without a restart. Nil before boot's - // startPluginReconcile, and in processes that load no directory (the - // Gateway), where a stored plugin-settings change still layers but loads - // nothing. - pluginReconciler *pluginReconciler - trees *worktree.Manager - worktreeGrants *worktreerpc.Grants - identityRunners []*daemon.IdentityRunner - d *daemon.Daemon + startGateways []func() + trees *worktree.Manager + worktreeGrants *worktreerpc.Grants + identityRunners []*daemon.IdentityRunner + d *daemon.Daemon // schedulingEngine is the cron/scheduling ticker engine (setupScheduling). // Nil when no chat task creator is configured, in which case startServices // leaves it unstarted rather than running with no reachable job kind. @@ -492,9 +486,7 @@ func (b *boot) loadWorkflows() error { if err := b.loadWorkflowRouting(cfg, log); err != nil { return err } - if err := b.loadModules(cfg, log); err != nil { - return err - } + b.modules = module.New() if err := b.loadEDAPlaybooks(cfg, log); err != nil { return err } @@ -539,36 +531,6 @@ func (b *boot) loadWorkflowRouting(cfg config.Config, log *slog.Logger) error { return nil } -// loadModules builds the daemon's Module registry: operator-trusted, -// in-process, Yaegi-interpreted. A broken module is a startup failure -- the -// daemon does not start with a partial module set, matching the routing-file -// load pattern (not the degrade-and-skip plugin pattern). Kinds whose file is -// not present in the directory are simply not loaded. Split out of -// loadWorkflows; pure extraction, same log messages and error-return order as -// before. -func (b *boot) loadModules(cfg config.Config, log *slog.Logger) error { - b.modules = module.New() - if cfg.ModuleDir == "" { - return nil - } - for _, kind := range module.Kinds() { - path := filepath.Join(cfg.ModuleDir, kind+".go") - if _, err := os.Stat(path); err != nil { - if errors.Is(err, os.ErrNotExist) { - continue // kind not installed in this module dir - } - log.Error("module stat failed", "kind", kind, "path", path, "err", err) - return err - } - if err := b.modules.Register(kind, cfg.ModuleDir); err != nil { - log.Error("module load failed", "kind", kind, "dir", cfg.ModuleDir, "err", err) - return err - } - } - log.Info("module registry built", "dir", cfg.ModuleDir, "kinds", b.modules.Len()) - return nil -} - // loadEDAPlaybooks loads the EDA playbook documents: trigger + workflow-kind // actions and module-kind action playbooks with CEL when conditions and args // values. Loaded at startup with the same reject-at-load rule -- any malformed diff --git a/internal/app/archied/control_plane.go b/internal/app/archied/control_plane.go index fe6753cd2..bf89b31f8 100644 --- a/internal/app/archied/control_plane.go +++ b/internal/app/archied/control_plane.go @@ -9,7 +9,6 @@ import ( "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/config" - "github.com/samcharles93/archie-core/internal/domain/applystatus" "github.com/samcharles93/archie-core/internal/domain/workflow" "github.com/samcharles93/archie-core/internal/infrastructure/configuration" "github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog" @@ -340,13 +339,7 @@ func (b *boot) applyRuntimeResourceUpdate(ctx context.Context, kind string, upda } b.publishConfig(ctx, cfg) b.log.Info("runtime settings applied", "kind", kind, "version", update.Version) - switch kind { - case controlplane.PluginSettingsKind: - // The document's directories are live now; load what they hold and - // report the reconciliation's own outcome, which is the one that knows - // whether a removal is outstanding. - b.reconcileRuntimePlugins(ctx) - case controlplane.ContainerRuntimePoliciesKind: + if kind == controlplane.ContainerRuntimePoliciesKind { // The pool reads the republished config itself; the dispatcher holds // its limit, so a raise must be woken to admit queued work now and a // lower must be honoured as running tasks finish. @@ -365,42 +358,6 @@ func (b *boot) resizeTaskDispatcher(maxConcurrency int) { } } -// startPluginReconcile establishes the plugin and module directory -// reconciliation on the apply-status restamp interval. Boot calls it -// after loadPlugins and loadWorkflows have loaded -// the directories, so the seed records what is already running and the first -// tick loads only what appears or changes afterwards. -func (b *boot) startPluginReconcile(ctx context.Context) { - r := newPluginReconciler(b.log, pluginReconcileTargets{ - modules: b.modules, - dirs: func() config.Config { return b.cfgHolder.Get() }, - relayer: func(ctx context.Context) error { - cfg, _, err := b.runtimeConfig(ctx, b.cfgHolder.Get()) - if err != nil { - return err - } - b.publishConfig(ctx, cfg) - return nil - }, - report: func(ctx context.Context, err error) { - b.applyStatus.Report(ctx, controlplane.PluginSettingsKind, b.applyStatus.AppliedVersion(controlplane.PluginSettingsKind), err) - }, - }) - b.pluginReconciler = r - r.seed() - go r.run(ctx, applystatus.RestampInterval) -} - -// reconcileRuntimePlugins runs one directory reconciliation after a stored -// plugin-settings change, so a new directory loads on the tick the document -// lands rather than waiting for the poller. -func (b *boot) reconcileRuntimePlugins(ctx context.Context) { - if b.pluginReconciler == nil { - return - } - _ = b.pluginReconciler.reconcile(ctx) -} - // refuseSkillsDirChange refuses a stored plugin-settings document whose // skills_dir differs from the value in force. skills_dir is the one directory // with no live consumer, so a change to it stays a restart-scoped edit rather diff --git a/internal/app/archied/main.go b/internal/app/archied/main.go index c73363b2e..0d53e7f33 100644 --- a/internal/app/archied/main.go +++ b/internal/app/archied/main.go @@ -191,9 +191,6 @@ func Run() int { //nolint:cyclop,funlen // the composition root's setup sequence if err := b.loadWorkflows(); err != nil { return 1 } - // Every directory loader has run by here, so the reconciliation seeds the - // running set and from its first tick loads only what appears or changes. - b.startPluginReconcile(ctx) if err := b.registerNATSRPC(); err != nil { return 1 diff --git a/internal/app/archied/plugin_reconcile.go b/internal/app/archied/plugin_reconcile.go deleted file mode 100644 index 2af094f1a..000000000 --- a/internal/app/archied/plugin_reconcile.go +++ /dev/null @@ -1,266 +0,0 @@ -package archied - -import ( - "context" - "crypto/sha256" - "encoding/hex" - "errors" - "fmt" - "io/fs" - "log/slog" - "os" - "path/filepath" - "slices" - "strings" - "sync" - "time" - - "github.com/samcharles93/archie-core/internal/config" - "github.com/samcharles93/archie-core/internal/domain/eda/module" -) - -// The directory families a plugin-settings document names and a -// reconciliation reads. -const reconcileModules = "module" - -// pluginReconciler loads plugin and module files that appear or -// change in the directories the running configuration names, so an operator can -// drop a file beside a running daemon and have it take effect without a -// restart. Yaegi cannot unload an interpreter, so a removed file's code keeps -// running and the reconciler reports it through apply status until the process -// restarts. -// -// Files are content-hashed, so a tick loads only what appeared or changed: the -// boot load's files are seeded as already loaded. A file whose load fails is -// forgotten until its content changes, the same degrade-and-skip rule the boot -// loaders apply. -type pluginReconciler struct { - log *slog.Logger - pluginReconcileTargets - - // reconcileMu serializes reconciliations: the poller's tick and a stored - // plugin-settings update both run one, and they share the loaded set. - reconcileMu sync.Mutex - loaded map[string]loadedPluginFile -} - -type pluginReconcileTargets struct { - modules *module.ModuleRegistry - // dirs returns the running configuration, the source of the - // directories. It is read each tick so a changed directory retargets the - // next reconciliation without a restart. - dirs func() config.Config - // relayer re-runs the configuration layering, which re-resolves provider - // credentials against the engines running by then. Nil in tests that do not - // layer. - relayer func(ctx context.Context) error - // report publishes the reconciliation outcome, including a nil error on a - // clean pass so an outstanding removal clears. - report func(ctx context.Context, err error) -} - -type loadedPluginFile struct { - hash string - category string - // failed marks a file whose last load failed. It is not reported as a - // removal while it is still present, and a content change retries it. - failed bool -} - -func newPluginReconciler(log *slog.Logger, targets pluginReconcileTargets) *pluginReconciler { - if log == nil { - log = slog.New(slog.DiscardHandler) - } - return &pluginReconciler{ - log: log, - pluginReconcileTargets: targets, - loaded: make(map[string]loadedPluginFile), - } -} - -// seed records the files the boot load already evaluated, so the first tick -// loads only what appeared or changed since boot. The daemon calls it after -// loadPlugins and loadWorkflows have run. -func (r *pluginReconciler) seed() { - next := make(map[string]loadedPluginFile) - for _, spec := range r.categories(r.dirs()) { - paths, err := goFiles(spec.dir) - if err != nil { - r.log.Warn("plugin directory not seeded", "category", spec.category, "dir", spec.dir, "err", err) - continue - } - for _, path := range paths { - hash, err := fileHash(path) - if err != nil { - continue - } - next[path] = loadedPluginFile{hash: hash, category: spec.category} - } - } - r.reconcileMu.Lock() - r.loaded = next - r.reconcileMu.Unlock() -} - -// run reconciles on interval until ctx ends. The interval is the apply-status -// restamp constant, so a dropped file needs no filesystem watch and a -// reconciliation report is refreshed at the same cadence as every other apply -// status record. -func (r *pluginReconciler) run(ctx context.Context, interval time.Duration) { - ticker := time.NewTicker(interval) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - _ = r.reconcile(ctx) - } - } -} - -type reconcileCategory struct { - category string - dir string -} - -func (r *pluginReconciler) categories(cfg config.Config) []reconcileCategory { - return []reconcileCategory{ - {reconcileModules, cfg.ModuleDir}, - } -} - -// reconcile re-reads the plugin and module directories against the running config and -// loads every new or changed file. It returns the outstanding problems -- a -// removal, a failed load, an unreadable directory -- joined, and reports the -// same through apply status. A nil return is a clean pass and clears the -// record's error. -func (r *pluginReconciler) reconcile(ctx context.Context) error { - r.reconcileMu.Lock() - defer r.reconcileMu.Unlock() - - var problems []error - next := make(map[string]loadedPluginFile, len(r.loaded)) - - for _, spec := range r.categories(r.dirs()) { - problems = append(problems, r.reconcileCategory(ctx, spec, next)...) - } - - for path, file := range r.loaded { - if _, ok := next[path]; ok || file.failed { - continue - } - problems = append(problems, fmt.Errorf("%s file %s was removed; it keeps running until the process restarts", file.category, path)) - } - - r.loaded = next - - // The layering re-runs every tick: it re-resolves provider credentials, so a - // provider disabled at boot for an unresolvable engine is re-resolved on the - // first tick that finds it - if r.relayer != nil { - if err := r.relayer(ctx); err != nil { - problems = append(problems, fmt.Errorf("re-resolve provider credentials: %w", err)) - } - } - - err := errors.Join(problems...) - if r.report != nil { - r.report(ctx, err) - } - return err -} - -// reconcileCategory loads the new and changed files of one directory into -// next, returning the problems it met. A directory that became unreadable -// keeps the entries this category already had: it is not a removal of the -// files loaded before that. -func (r *pluginReconciler) reconcileCategory(ctx context.Context, spec reconcileCategory, next map[string]loadedPluginFile) []error { - var problems []error - paths, err := goFiles(spec.dir) - if err != nil { - problems = append(problems, fmt.Errorf("%s directory %q: %w", spec.category, spec.dir, err)) - for path, file := range r.loaded { - if file.category == spec.category { - next[path] = file - } - } - return problems - } - for _, path := range paths { - hash, err := fileHash(path) - if err != nil { - problems = append(problems, fmt.Errorf("read %s: %w", path, err)) - continue - } - if previous, ok := r.loaded[path]; ok && previous.hash == hash { - next[path] = previous - continue - } - if err := r.load(ctx, spec.category, path); err != nil { - problems = append(problems, fmt.Errorf("%s %s: %w", spec.category, path, err)) - // Record the failed content so the same broken file is not retried - // every tick; changing it retries the load. - next[path] = loadedPluginFile{hash: hash, category: spec.category, failed: true} - continue - } - next[path] = loadedPluginFile{hash: hash, category: spec.category} - r.log.Info("runtime directory file loaded", "category", spec.category, "path", path) - } - return problems -} - -func (r *pluginReconciler) load(ctx context.Context, category, path string) error { - switch category { - case reconcileModules: - return r.loadModule(path) - default: - return fmt.Errorf("unknown reconcile category %q", category) - } -} - -func (r *pluginReconciler) loadModule(path string) error { - if r.modules == nil { - return errors.New("no module registry to load into") - } - kind := strings.TrimSuffix(filepath.Base(path), ".go") - if !slices.Contains(module.Kinds(), kind) { - // A .go file for a kind this build has no contract for; the boot load - // iterates the known kinds and ignores it too. - return nil - } - return r.modules.Register(kind, filepath.Dir(path)) -} - -// goFiles lists the .go files directly under dir, sorted. A missing directory -// reconciles to an empty set, the convention every boot loader already follows. -func goFiles(dir string) ([]string, error) { - if dir == "" { - return nil, nil - } - entries, err := os.ReadDir(dir) - if errors.Is(err, fs.ErrNotExist) { - return nil, nil - } - if err != nil { - return nil, err - } - paths := make([]string, 0, len(entries)) - for _, entry := range entries { - if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".go") { - continue - } - paths = append(paths, filepath.Join(dir, entry.Name())) - } - slices.Sort(paths) - return paths, nil -} - -func fileHash(path string) (string, error) { - content, err := os.ReadFile(path) - if err != nil { - return "", err - } - sum := sha256.Sum256(content) - return hex.EncodeToString(sum[:]), nil -} diff --git a/internal/app/controlplane/operational_settings.go b/internal/app/controlplane/operational_settings.go index 227d9880e..de04d1fd9 100644 --- a/internal/app/controlplane/operational_settings.go +++ b/internal/app/controlplane/operational_settings.go @@ -29,7 +29,6 @@ type schedulingPolicy struct { } type pluginSettings struct { - ModuleDir string `json:"module_dir"` SkillsDir string `json:"skills_dir"` } @@ -48,7 +47,7 @@ func operationalDefinitions() []Definition { // restart. A removal cannot unload Yaegi's interpreter, so it stays an // outstanding apply-status problem rather than a restart of the whole kind {Kind: PluginSettingsKind, Title: "Plugin settings", ApplyMode: "live", Document: pluginSettings{}, Seed: func(cfg config.Config) any { - return pluginSettings{cfg.ModuleDir, cfg.SkillsDir} + return pluginSettings{cfg.SkillsDir} }, Validate: validatePluginSettings}, // Live: each process that supervises extensions re-reads this on its sync // tick, then starts, restarts or stops what changed. diff --git a/internal/app/controlplane/runtime_config.go b/internal/app/controlplane/runtime_config.go index a5c0a7d84..d4e877370 100644 --- a/internal/app/controlplane/runtime_config.go +++ b/internal/app/controlplane/runtime_config.go @@ -182,7 +182,7 @@ func runtimeToolConfigFrom(ctx context.Context, reader controlplanerpc.ResourceR if err := json.Unmarshal(value, &settings); err != nil { return err } - out.ModuleDir, out.SkillsDir = settings.ModuleDir, settings.SkillsDir + out.SkillsDir = settings.SkillsDir return nil }); err != nil { return config.Config{}, nil, err diff --git a/internal/config/config.go b/internal/config/config.go index 9fc8e0999..a388f1b21 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -376,9 +376,6 @@ type Config struct { // MaxRetries caps how many times a parked task is retried before // being permanently parked (status "dead"). Defaults to 3. MaxRetries int `toml:"max_retries" yaml:"max_retries"` - // ModuleDir is an optional directory of Yaegi module implementations, one - // *.go file per kind exporting "Run". A broken module stops startup. - ModuleDir string `toml:"module_dir" yaml:"module_dir"` // StateDir is the host directory archie keeps non-database state in: the // embedded NATS store and its endpoint file, the task-log registry, and // the readiness disk probe's data target. Bootstrap-only. diff --git a/internal/domain/eda/module/log/logextract/github_com-samcharles93-archie-core-internal-domain-eda-module-log.go b/internal/domain/eda/module/log/logextract/github_com-samcharles93-archie-core-internal-domain-eda-module-log.go deleted file mode 100644 index 4d490d124..000000000 --- a/internal/domain/eda/module/log/logextract/github_com-samcharles93-archie-core-internal-domain-eda-module-log.go +++ /dev/null @@ -1,22 +0,0 @@ -// Code generated by 'yaegi extract github.com/samcharles93/archie-core/internal/domain/eda/module/log'. DO NOT EDIT. - -package logextract - -import ( - "go/constant" - "go/token" - "reflect" - - "github.com/samcharles93/archie-core/internal/domain/eda/module/log" -) - -func init() { - Symbols["github.com/samcharles93/archie-core/internal/domain/eda/module/log/log"] = map[string]reflect.Value{ - // function, constant and variable definitions - "SchemaVersion": reflect.ValueOf(constant.MakeFromLiteral("1", token.INT, 0)), - - // type definitions - "Args": reflect.ValueOf((*log.Args)(nil)), - "Result": reflect.ValueOf((*log.Result)(nil)), - } -} diff --git a/internal/domain/eda/module/log/logextract/logextract.go b/internal/domain/eda/module/log/logextract/logextract.go deleted file mode 100644 index 61123db13..000000000 --- a/internal/domain/eda/module/log/logextract/logextract.go +++ /dev/null @@ -1,15 +0,0 @@ -// Package logextract holds the Yaegi symbol table for -// internal/domain/eda/module/log, generated by `go generate`. Kept separate -// from the log package itself so the generated file can import it without a -// self-import cycle. -// -// The generated file is used verbatim. A wrapper whose method fields are not -// all populated is refused in yaegiutil.Resolve, so it needs no hand-added -// nil-guards -- an earlier convention that every regeneration silently undid. -package logextract - -import "reflect" - -//go:generate go run github.com/traefik/yaegi/cmd/yaegi extract -name logextract github.com/samcharles93/archie-core/internal/domain/eda/module/log - -var Symbols = map[string]map[string]reflect.Value{} diff --git a/internal/domain/eda/module/module.go b/internal/domain/eda/module/module.go index d71d6d7f6..6844e78b8 100644 --- a/internal/domain/eda/module/module.go +++ b/internal/domain/eda/module/module.go @@ -1,87 +1,49 @@ -// Package module loads and invokes EDA module actions, Yaegi-interpreted Go -// files with a fixed entrypoint per kind. +// Package module is the registry of EDA playbook action kinds. Each kind is +// built in and has one typed contract: Args and Result struct types the +// playbook loader declares to CEL, so a typo in an arg key or result field is a +// load failure rather than a dispatch failure. package module import ( "context" "fmt" - "os" - "path/filepath" + "log/slog" "reflect" "sort" "strings" - "github.com/traefik/yaegi/interp" - "github.com/samcharles93/archie-core/internal/domain/eda/module/log" - "github.com/samcharles93/archie-core/internal/domain/eda/module/log/logextract" - "github.com/samcharles93/archie-core/internal/yaegiutil" ) -// Kind is a resolved module implementation: how to load a Yaegi file against -// this kind's generated contract, and how to invoke it. +// invoker decodes raw args, runs the kind, and marshals its typed result. +type invoker func(ctx context.Context, rawArgs map[string]any) (map[string]any, error) + +// Kind is one built-in action kind: its schema and how to run it. type Kind struct { - // loadSymbols returns the kind's generated Yaegi symbol table. - loadSymbols func() map[string]map[string]reflect.Value - // exportPath is the fixed exported function name the interpreted file - // must define (e.g. "main.Run"). - exportPath string - // argsType and resultType are the kind's hand-written Args and Result - // struct types. They are the schema the playbook loader declares to CEL - // so an arg key or result field typo is a load failure rather than a - // dispatch failure (multi-action-playbooks.md, D4). argsType reflect.Type resultType reflect.Type + invoke invoker } -// registry maps kind name to its one typed contract. Adding a new kind is a -// new entry here plus its own schema package -- no generic interface grows. +// registry maps kind name to its one typed contract. Adding a kind is a new +// entry here plus its own schema package. var registry = map[string]Kind{ "log": { - loadSymbols: func() map[string]map[string]reflect.Value { return logextract.Symbols }, - exportPath: "main.Run", - argsType: reflect.TypeFor[log.Args](), - resultType: reflect.TypeFor[log.Result](), + argsType: reflect.TypeFor[log.Args](), + resultType: reflect.TypeFor[log.Result](), + invoke: runLog, }, } -// ModuleRegistry maps kind names to their resolved, type-erased invokers. -// It is not a service locator: it owns one capability family (Module action -// kinds) and exposes Register/Invoke only. -type ModuleRegistry struct { - // kinds holds the resolved invoker per kind. Erasure is internal-only: - // the kind's interpreted contract remains fully typed. - kinds map[string]invoker -} +// ModuleRegistry answers the playbook engine's questions about action kinds. +// It holds no state: every kind is built in. +type ModuleRegistry struct{} -// invoker is the type-erased callable the registry stores: it decodes raw -// args, invokes the interpreted function, and marshals the typed result. -type invoker func(ctx context.Context, rawArgs map[string]any) (map[string]any, error) - -// New returns an empty registry. -func New() *ModuleRegistry { - return &ModuleRegistry{kinds: make(map[string]invoker)} -} - -// Kinds returns the known action-kind names, sorted for determinism. Only kinds -// with a registered contract can be loaded; the log kind is the shipped -// proof-of-concept. -func Kinds() []string { - names := make([]string, 0, len(registry)) - for name := range registry { - names = append(names, name) - } - sort.Strings(names) - return names -} - -// Len returns how many kinds were successfully registered (loaded). -func (r *ModuleRegistry) Len() int { - return len(r.kinds) -} +// New returns the registry. +func New() *ModuleRegistry { return &ModuleRegistry{} } // KindSchema returns a known kind's Args and Result types. -func (r *ModuleRegistry) KindSchema(kind string) (reflect.Type, reflect.Type, bool) { +func (*ModuleRegistry) KindSchema(kind string) (reflect.Type, reflect.Type, bool) { k, ok := registry[kind] if !ok { return nil, nil, false @@ -89,77 +51,35 @@ func (r *ModuleRegistry) KindSchema(kind string) (reflect.Type, reflect.Type, bo return k.argsType, k.resultType, true } -// Register loads
{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&Ci(f)&&f.data===`]`?a(t.anchor=f):(yi(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,s,l)=>{if(ji(e,t)||yi(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)c(n);else break}}let u=a(e),d=o(e);return c(e),n(null,t,d,u,r,i,Si(d),s),r&&(r.vnode.el=t.el,So(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&Ci(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var Ti=new Set([`src`,`srcset`,`href`,`poster`]);function Ei(e,t,n){return Ti.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var Di=`data-allow-mismatch`,Oi={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function ki(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(Di);)e=e.parentElement;return Ai(e&&e.getAttribute(Di),t)}function Ai(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(Oi[t])}}function ji(e,t){return ki(e.parentElement,1)||Mi(e)||Ni(t)}function Mi(e){return e.nodeType===1&&Ai(e.getAttribute(Di),1)}function Ni({props:e}){let t=e&&e[Di];return typeof t==`string`&&Ai(t,1)}var Pi=ge().requestIdleCallback||(e=>setTimeout(e,1)),Fi=ge().cancelIdleCallback||(e=>clearTimeout(e)),Ii=(e=1e4)=>t=>{let n=Pi(t,{timeout:e});return()=>Fi(n)};function Li(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t0&&r0&&n {let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&Ci(f)&&f.data===`]`?a(t.anchor=f):(yi(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,s,l)=>{if(ji(e,t)||yi(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)c(n);else break}}let u=a(e),d=o(e);return c(e),n(null,t,d,u,r,i,Si(d),s),r&&(r.vnode.el=t.el,xo(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&Ci(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var Ti=new Set([`src`,`srcset`,`href`,`poster`]);function Ei(e,t,n){return Ti.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var Di=`data-allow-mismatch`,Oi={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function ki(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(Di);)e=e.parentElement;return Ai(e&&e.getAttribute(Di),t)}function Ai(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(Oi[t])}}function ji(e,t){return ki(e.parentElement,1)||Mi(e)||Ni(t)}function Mi(e){return e.nodeType===1&&Ai(e.getAttribute(Di),1)}function Ni({props:e}){let t=e&&e[Di];return typeof t==`string`&&Ai(t,1)}var Pi=ge().requestIdleCallback||(e=>setTimeout(e,1)),Fi=ge().cancelIdleCallback||(e=>clearTimeout(e)),Ii=(e=1e4)=>t=>{let n=Pi(t,{timeout:e});return()=>Fi(n)};function Li(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t0&&r0&&ne.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?vf+r:void 0})(),Sf=e=>{let{theme:t,classGroups:n}=e;return Cf(n,t)},Cf=(e,t)=>{let n=hf();for(let r in e){let i=e[r];wf(i,n,r,t)}return n},wf=(e,t,n,r)=>{let i=e.length;for(let a=0;a{if(typeof e==`string`){Ef(e,t,n);return}if(typeof e==`function`){Df(e,t,n,r);return}Of(e,t,n,r)},Ef=(e,t,n)=>{let r=e===``?t:kf(t,e);r.classGroupId=n},Df=(e,t,n,r)=>{if(Af(e)){wf(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(mf(n,e))},Of=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e{let n=e,r=t.split(gf),i=r.length;for(let e=0;e`isThemeGetter`in e&&e.isThemeGetter===!0,jf=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Mf=`!`,Nf=`:`,Pf=[],Ff=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),If=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;se.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?_f+r:void 0})(),xf=e=>{let{theme:t,classGroups:n}=e;return Sf(n,t)},Sf=(e,t)=>{let n=mf();for(let r in e){let i=e[r];Cf(i,n,r,t)}return n},Cf=(e,t,n,r)=>{let i=e.length;for(let a=0;a{if(typeof e==`string`){Tf(e,t,n);return}if(typeof e==`function`){Ef(e,t,n,r);return}Df(e,t,n,r)},Tf=(e,t,n)=>{let r=e===``?t:Of(t,e);r.classGroupId=n},Ef=(e,t,n,r)=>{if(kf(e)){Cf(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(pf(n,e))},Df=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e{let n=e,r=t.split(hf),i=r.length;for(let e=0;e`isThemeGetter`in e&&e.isThemeGetter===!0,Af=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},jf=`!`,Mf=`:`,Nf=[],Pf=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Ff=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;se&&(e.type===`block-map`||e.type===`block-seq`);function DX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?cY:uY))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;ae&&(e.type===`block-map`||e.type===`block-seq`);function EX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?sY:lY))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;ac&&(c=r.length);else{r.length