modules

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

README

haistack-modules (pkg/modules)

pkg/modules installs manifest-driven capability modules into a HAIStack runtime. A module is a local directory containing a module.json manifest and optional FHIR definition files. The installer validates the module, checks its dependencies, enables declared resource types, imports definitions into the registry, and records the installation through backend-neutral store interfaces.

The package does not load Go plugins or execute arbitrary module code. In v1, modules are manifests plus JSON definitions. Core and SDC definitions are authored in FSH under conformance/fsh/ and installed from compiled IG output in modules/*/ig (make ig).

Module Layout

The package lives at pkg/modules; module directories are normally kept under the repository-level modules/ directory:

modules/<name>/
├── module.json
├── ig/                 # compiled IG JSON (core and sdc)
└── definitions/        # optional hand-authored JSON
    └── *.json

For example, modules/core enables foundational FHIR resources and installs compiled IG artefacts from ig/ (built from conformance/fsh). modules/scheduling still uses hand-authored definitions/.

Manifest

{
  "name": "scheduling",
  "version": "1.0.0",
  "description": "Scheduling resources and search parameters.",
  "dependencies": [
    {"name": "core", "version": "1.0.0"}
  ],
  "resources": ["Appointment", "Schedule", "Slot"],
  "definitionFiles": ["definitions/Appointment-search-date.json"],
  "views": ["AppointmentCalendar"],
  "aiTools": [],
  "permissions": ["read-appointment"],
  "syncPolicies": [],
  "subscriptions": [],
  "migrations": []
}
Field Purpose
name Unique module name.
version Semver module version.
description Human-readable description.
dependencies Required modules and their minimum compatible versions.
resources Base FHIR resource types to enable.
definitionFiles Module-relative JSON definitions to ingest with provenance.
igPackage Module-relative directory of compiled IG JSON (all *.json files are loaded).
views, aiTools, permissions, syncPolicies, subscriptions, migrations Capability declarations recorded as metadata but not executed by v1.

Definition paths must remain inside the module directory. The loader also validates manifest structure, rejects duplicate entries, and applies size and file-count limits.

Package install completion

Module installs record completion in PackageInstallStore under registry.ModulesPackageID(<moduleName>) (for example haistack-modules/core) and the manifest version. CompletePackageInstall runs after all definitions are ingested. Module identity also remains in registry provenance (ModuleName, SourceModule).

Lifecycle

Manager is the runtime-facing API:

Load and validate module
        |
Optional signature verification
        |
Resolve dependency graph
        |
Build install or upgrade plan
        |
Optional authorization
        |
Apply registry changes and persist module state

The main operations are:

  • PlanInstall previews an install or upgrade without changing state.
  • Install installs a module and can apply a newer version of an existing module.
  • InstallAll applies several module paths as one compensating operation.
  • Upgrade explicitly upgrades an installed module.
  • Uninstall removes a module and its registry contributions when safe.
  • List returns installed modules and their contributions.
  • Inspect returns one installed module.

Installs seed bundled FHIR definitions before enabling resources. Definition records retain module provenance, and the registry snapshot is rebuilt after the operation. Failed multi-store operations are compensated so partial registry and module state is not intentionally left behind.

Upgrades must use a greater version and are additive in v1. Removing a previously declared resource or definition is rejected with ErrUpgradeWouldRemove. Uninstall is blocked when another module depends on the target or when removing a resource would leave persisted resources without an enabled type.

CLI

The haistack CLI exposes the module lifecycle when a configured runtime is available:

haistack module plan modules/core
haistack module install modules/core
haistack module upgrade modules/core
haistack module list
haistack module inspect core
haistack module uninstall core --force

module plan is useful for checking dependencies, resource enablement, and definition changes before installation.

Go Usage

Construct the manager with the stores used by the rest of the runtime. SQLite and Postgres provide concrete implementations of these pkg/store contracts.

import (
    "context"
    "time"

    "github.com/degoke/haistack/pkg/modules"
    "github.com/degoke/haistack/pkg/registry"
)

// Construct these from the selected persistence backend.
var moduleStore store.ModuleStore
var definitionStore store.DefinitionStore
var installStore store.RegistryInstallStore
var resourceStore store.ResourceStore

registryManager := registry.NewManager(registry.Config{
    Definitions: definitionStore,
    Installs:    installStore,
})

manager := modules.NewManager(modules.Config{
    ModuleStore:          moduleStore,
    DefinitionStore:      definitionStore,
    RegistryInstallStore: installStore,
    RegistryManager:      registryManager,
    ResourceStore:        resourceStore,
    Now:                  time.Now,
})

ctx := context.Background()
plan, err := manager.PlanInstall(ctx, "modules/scheduling")
if err != nil {
    // Handle invalid manifests, missing dependencies, or registry conflicts.
}
_ = plan

result, err := manager.Install(ctx, "modules/scheduling")
if err != nil {
    // Handle the install error.
}
_ = result

The store import is omitted above only for brevity; the store variables are typically supplied by pkg/sqlite or pkg/postgres.

For runtime composition, pkg/runtime wires a modules.Manager and can call InstallAll for configured module paths during startup.

Signature Verification

Deployments that install modules from an untrusted source can configure a ModuleVerifier. The built-in Ed25519ModuleVerifier expects a detached module.json.sig next to the manifest by default:

manager := modules.NewManager(modules.Config{
    ModuleStore:          moduleStore,
    DefinitionStore:      definitionStore,
    RegistryInstallStore: installStore,
    RegistryManager:      registryManager,
    Verifier: modules.Ed25519ModuleVerifier{
        PublicKey: publicKey,
    },
})

The signature covers the exact manifest bytes and every referenced definition file, including its manifest-order path framing. Verification happens before dependency resolution or registry mutation.

Current Scope

v1 is registry-first:

  • Resource enablement and FHIR definition installation are active.
  • Module dependencies, semver checks, upgrades, uninstall safety, and optional signatures are supported.
  • View, AI tool, permission, sync policy, subscription, and migration entries are persisted as declarations only.
  • Remote registry synchronization, tenant-specific module layers, paid modules, and execution of deferred subsystem declarations are not implemented yet.

See doc.go for the complete package-level API and behavior notes.

Documentation

Overview

Package modules implements haistack-modules, a manifest-driven installer for HAIStack. It turns a local module directory into runtime capabilities by driving the existing registry catalog, ModuleStore, and RegistryInstallStore.

v1 is registry-first: it fully installs and upgrades resource enablement, profiles, and search parameters. It persists declarations for views, AI tools, permissions, sync policies, subscriptions, and migrations in module metadata but does not execute those subsystems yet.

Module layout

A module is a directory containing a module.json manifest and optional definition JSON files. Compiled IG artefacts may be loaded from an ig/ directory declared as igPackage:

modules/<name>/
├── module.json
├── ig/*.json
└── definitions/*.json

module.json declares the module identity, dependencies, resources to enable, definition files and/or an igPackage directory to ingest, and deferred subsystem declarations.

Manifest format

Recommended manifest shape for v1:

{
  "name": "scheduling",
  "version": "1.0.0",
  "dependencies": [{"name": "core", "version": "1.0.0"}],
  "resources": ["Appointment", "Schedule", "Slot"],
  "definitionFiles": ["definitions/Appointment-search-date.json"],
  "views": ["AppointmentCalendar"],
  "aiTools": [],
  "permissions": ["read-appointment"],
  "syncPolicies": [],
  "subscriptions": [],
  "migrations": []
}

Fields:

  • name: module identity. Must be unique across installed modules.
  • version: semver string. Upgrades must move to a greater version.
  • dependencies: required modules with a minimum compatible semver version.
  • resources: FHIR resource types to enable from the seeded base definitions.
  • definitionFiles: relative JSON files to ingest as profiles or search parameters.
  • igPackage: relative directory of compiled IG JSON (all *.json files are loaded).
  • views, aiTools, permissions, syncPolicies, subscriptions, migrations: declaration-only arrays stored in ModuleRecord.Metadata for future subsystems.

Public API

Manager is the primary runtime-facing entry point. Construct it with the existing persistence stores and a registry.Manager:

reg := registry.NewManager(registry.Config{Definitions: defs, Installs: installs})
mgr := modules.NewManager(modules.Config{
    ModuleStore:          moduleStore,
    DefinitionStore:      defs,
    RegistryInstallStore: installs,
    RegistryManager:      reg,
    Now:                  time.Now,
})

result, err := mgr.Install(ctx, "modules/scheduling")

Manager methods:

  • Install loads a module directory and applies it to the registry.
  • InstallAll applies a build-time module set as one compensating transaction.
  • Upgrade loads a module directory and upgrades an already-installed module.
  • Uninstall removes a module and its registry contributions.
  • List returns all installed modules with their runtime contributions.
  • Inspect returns one installed module.
  • PlanInstall returns the intended install or upgrade plan without mutating state.

Deployments that distribute modules from an untrusted source should set modules.Config.Verifier. Ed25519ModuleVerifier verifies a detached module.json.sig over the exact manifest and definition bytes; custom ModuleVerifier implementations can enforce another trust root or format.

Install/upgrade behavior:

  • Dependencies are validated for exact name match and minimum semver version.
  • Cycles in the dependency graph, including self-references, are rejected.
  • Base FHIR definitions are seeded before any resource is enabled.
  • Declared resources are enabled and declared definitions are ingested with ModuleName and SourceModule provenance.
  • The registry snapshot is rebuilt once at the end.
  • Upgrades must be to a newer version and are additive only in v1; removing a previously declared resource or definition returns ErrUpgradeWouldRemove.

Uninstall behavior:

  • Refuses if another installed module depends on the target.
  • Refuses to disable a resource type that still has persisted resources when ResourceStore is configured.
  • Disables resources contributed by the target that are not still required.
  • Removes registry install rows and definition records owned by the target.
  • Removes the ModuleStore entry last, after registry state is safely updated.
  • Rebuilds the registry snapshot after uninstall.

Internal services

The Manager composes several focused services:

  • Loader reads and validates a module directory.
  • DependencyResolver validates dependencies and detects cycles.
  • RegistryApplier enables resources, installs definitions, and rebuilds snapshots.
  • Installer orchestrates install/upgrade/uninstall planning and execution.
  • CapabilitySnapshotBuilder returns a module-centric view of installed modules.

Paid modules, remote registry syncing, hospital-specific patch layering, and tenant-specific modules are out of v1 scope but are intended future extensions.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrManifestNotFound is returned when a module directory does not contain
	// a module.json manifest.
	ErrManifestNotFound = errors.New("module manifest not found")

	// ErrInvalidManifest is returned when a manifest fails validation.
	ErrInvalidManifest = errors.New("invalid module manifest")

	// ErrMissingDependency is returned when a required module dependency is not
	// installed.
	ErrMissingDependency = errors.New("missing module dependency")

	// ErrDependencyVersionMismatch is returned when an installed dependency is
	// below the required minimum version.
	ErrDependencyVersionMismatch = errors.New("module dependency version mismatch")

	// ErrCircularDependency is returned when a module's dependency graph contains
	// a cycle.
	ErrCircularDependency = errors.New("circular module dependency")

	// ErrAmbiguousModule is returned when a module name maps to multiple
	// conflicting versions or sources.
	ErrAmbiguousModule = errors.New("ambiguous module reference")

	// ErrDowngradeNotAllowed is returned when an upgrade would move to an older
	// or equal version.
	ErrDowngradeNotAllowed = errors.New("module downgrade not allowed")

	// ErrModuleNotFound is returned when an operation references a module that
	// is not installed.
	ErrModuleNotFound = errors.New("module not found")

	// ErrModuleInUse is returned when uninstall is blocked because another
	// installed module depends on the target.
	ErrModuleInUse = errors.New("module is required by another installed module")

	// ErrResourceTypeInUse is returned when uninstalling a module would disable
	// a resource type that still has persisted resources.
	ErrResourceTypeInUse = errors.New("resource type still has persisted resources")

	// ErrModuleFileTooLarge is returned when a manifest or definition file
	// exceeds the loader's configured safety limit.
	ErrModuleFileTooLarge = errors.New("module file is too large")

	// ErrModuleSignatureMissing is returned when a configured verifier cannot
	// find the module's detached signature.
	ErrModuleSignatureMissing = errors.New("module signature missing")

	// ErrModuleSignatureInvalid is returned when a configured verifier rejects
	// the module signature or its signed content.
	ErrModuleSignatureInvalid = errors.New("invalid module signature")

	// ErrUpgradeWouldRemove is returned when an upgrade would remove
	// resources or definitions that were previously declared, requiring manual
	// action in v1.
	ErrUpgradeWouldRemove = errors.New("upgrade would remove previously declared resources or definitions")
)

Functions

func LoadDefinitionsFromIG

func LoadDefinitionsFromIG(dir string) ([][]byte, error)

LoadDefinitionsFromIG reads FHIR JSON definition files from a compiled IG output directory (SUSHI fsh-generated/resources or an unpacked NPM package).

func ManifestToMetadata

func ManifestToMetadata(manifest Manifest) (map[string]string, error)

ManifestToMetadata serializes a manifest for storage in a module record.

func ModuleSigningDigest

func ModuleSigningDigest(module Module) []byte

ModuleSigningDigest returns the digest signed by Ed25519ModuleVerifier. Framing prevents concatenation ambiguity between manifest and definitions.

Types

type CapabilitySnapshotBuilder

type CapabilitySnapshotBuilder struct {
	// contains filtered or unexported fields
}

CapabilitySnapshotBuilder returns a module-centric view of what each installed module contributed, built from ModuleStore plus RegistryInstallStore.

func NewCapabilitySnapshotBuilder

func NewCapabilitySnapshotBuilder(modules store.ModuleStore, installs store.RegistryInstallStore) *CapabilitySnapshotBuilder

NewCapabilitySnapshotBuilder creates a builder backed by the module and registry install stores.

func (*CapabilitySnapshotBuilder) Build

Build returns one InstalledModule per registered module, with resources and definitions derived from registry install rows that name the module as their source.

type Config

type Config struct {
	ModuleStore          store.ModuleStore
	DefinitionStore      store.DefinitionStore
	RegistryInstallStore store.RegistryInstallStore
	RegistryManager      *registry.Manager
	ResourceStore        store.ResourceStore
	Authorizer           InstallAuthorizer
	Verifier             ModuleVerifier
	Now                  func() time.Time
}

Config supplies the stable persistence pieces required by the module manager. Tenant-aware wrappers can be added later without changing this shape.

type Declarations

type Declarations struct {
	Views         []string `json:"views,omitempty"`
	AITools       []string `json:"aiTools,omitempty"`
	Permissions   []string `json:"permissions,omitempty"`
	SyncPolicies  []string `json:"syncPolicies,omitempty"`
	Subscriptions []string `json:"subscriptions,omitempty"`
	Migrations    []string `json:"migrations,omitempty"`
}

Declarations groups deferred subsystem names that are stored but not executed in v1.

type DefinitionRef

type DefinitionRef struct {
	CanonicalURL string `json:"canonicalUrl"`
	Version      string `json:"version"`
}

DefinitionRef identifies one installed definition by canonical URL and version.

type DependencyRef

type DependencyRef struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

DependencyRef names a required module and its minimum compatible version.

type DependencyResolver

type DependencyResolver struct {
	// contains filtered or unexported fields
}

DependencyResolver validates dependency presence and version compatibility before install. v1 policy: exact module name match and semver-compatible minimum version; fail on ambiguity or cycles.

func NewDependencyResolver

func NewDependencyResolver(modules store.ModuleStore) *DependencyResolver

NewDependencyResolver creates a resolver backed by the installed module store.

func (*DependencyResolver) Resolve

func (r *DependencyResolver) Resolve(ctx context.Context, mod *Module) error

Resolve checks that the module's dependencies are satisfied by installed modules and that the combined dependency graph is acyclic.

type Ed25519ModuleVerifier

type Ed25519ModuleVerifier struct {
	PublicKey     ed25519.PublicKey
	SignaturePath string
}

Ed25519ModuleVerifier verifies a detached Ed25519 signature stored next to module.json. The signature covers ModuleSigningDigest, which includes the exact manifest bytes and every loaded definition file in manifest order. Signatures may be raw 64-byte values or standard base64 text.

func (Ed25519ModuleVerifier) VerifyModule

func (v Ed25519ModuleVerifier) VerifyModule(ctx context.Context, module Module) error

VerifyModule verifies one module using the configured Ed25519 public key.

type InstallAuthRequest

type InstallAuthRequest struct {
	Path   string
	Module Module
	Plan   *Plan
	Action string
}

InstallAuthRequest carries module authorization context for install and upgrade operations.

type InstallAuthorizer

type InstallAuthorizer interface {
	AuthorizeModuleInstall(ctx context.Context, req InstallAuthRequest) error
}

InstallAuthorizer is the pluggable authorization seam for module install/upgrade operations.

type InstallAuthorizerFunc

type InstallAuthorizerFunc func(ctx context.Context, req InstallAuthRequest) error

InstallAuthorizerFunc adapts a function to InstallAuthorizer.

func (InstallAuthorizerFunc) AuthorizeModuleInstall

func (f InstallAuthorizerFunc) AuthorizeModuleInstall(ctx context.Context, req InstallAuthRequest) error

AuthorizeModuleInstall implements InstallAuthorizer.

type InstallResult

type InstallResult struct {
	Action               string             `json:"action"`
	Name                 string             `json:"name"`
	Version              string             `json:"version"`
	EnabledResources     []string           `json:"enabledResources,omitempty"`
	InstalledDefinitions []DefinitionRef    `json:"installedDefinitions,omitempty"`
	Deferred             Declarations       `json:"deferred,omitempty"`
	Snapshot             *registry.Snapshot `json:"-"`
}

InstallResult reports what an install changed in the registry.

type InstallWorker

type InstallWorker struct {
	Manager                    *Manager
	Store                      store.JobStore
	TerminologyInstalls        store.TerminologyInstallStoreFactory
	DefaultTerminologyTenantID string
}

InstallWorker handles modules.install jobs.

func (*InstallWorker) HandleJob

func (w *InstallWorker) HandleJob(ctx context.Context, job store.JobRecord) error

HandleJob installs a module from a local directory path.

type InstalledModule

type InstalledModule struct {
	Name         string          `json:"name"`
	Version      string          `json:"version"`
	Dependencies []DependencyRef `json:"dependencies,omitempty"`
	Resources    []string        `json:"resources,omitempty"`
	Definitions  []DefinitionRef `json:"definitions,omitempty"`
	Deferred     Declarations    `json:"deferred,omitempty"`
	RegisteredAt time.Time       `json:"registeredAt"`
}

InstalledModule is a module-centric view of one registered module and its runtime contributions.

type Installer

type Installer struct {
	OnProgress ProgressFunc
	// contains filtered or unexported fields
}

Installer orchestrates install/upgrade/uninstall planning and execution. It owns the registry applier and module store updates.

func NewInstaller

func NewInstaller(modules store.ModuleStore, defs store.DefinitionStore, installs store.RegistryInstallStore, reg *registry.Manager, now func() time.Time) *Installer

NewInstaller creates an installer from the same persistence pieces used by the public manager. Resource usage checks are disabled when no resource store is supplied; use NewInstallerWithResources for production lifecycle protection.

func NewInstallerWithResources

func NewInstallerWithResources(modules store.ModuleStore, defs store.DefinitionStore, installs store.RegistryInstallStore, reg *registry.Manager, resources store.ResourceStore, now func() time.Time) *Installer

NewInstallerWithResources creates an installer that also checks persisted resources before disabling a resource type during uninstall.

func (*Installer) Install

func (i *Installer) Install(ctx context.Context, mod *Module) (*InstallResult, error)

Install applies a module to the registry and registers the module.

The persistence interfaces intentionally remain backend-neutral, so the installer uses a compensating state transaction around the multi-store operation. This keeps a failed install from leaving registry or module records half-applied.

func (*Installer) PlanInstall

func (i *Installer) PlanInstall(ctx context.Context, mod *Module) (*Plan, error)

PlanInstall computes the desired state for a module without mutating the registry or module store.

func (*Installer) Uninstall

func (i *Installer) Uninstall(ctx context.Context, name string) error

Uninstall removes a module's registry contributions and module record.

func (*Installer) Upgrade

func (i *Installer) Upgrade(ctx context.Context, mod *Module) (*UpgradeResult, error)

Upgrade applies a newer version of an already-installed module.

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader reads a local module directory, parses module.json, resolves relative file references, and returns a normalized Module.

func NewLoader

func NewLoader() *Loader

NewLoader creates a loader that reads from the real filesystem.

func (*Loader) Load

func (l *Loader) Load(path string) (*Module, error)

Load reads the manifest at path/module.json and loads all referenced definition files.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is the public runtime-facing API for installing, upgrading, uninstalling, and inspecting modules.

func NewManager

func NewManager(cfg Config) *Manager

NewManager constructs a module manager from persistence stores.

func (*Manager) Inspect

func (m *Manager) Inspect(ctx context.Context, name string) (*InstalledModule, error)

Inspect returns one installed module, or ErrModuleNotFound if it is not registered.

func (*Manager) Install

func (m *Manager) Install(ctx context.Context, path string) (InstallResult, error)

Install loads a local module directory and applies it to the registry.

func (*Manager) InstallAll

func (m *Manager) InstallAll(ctx context.Context, paths ...string) error

InstallAll installs a build-time module set as one logical operation. If a later module fails, all state changes made by this batch are compensated.

func (*Manager) InstallWithProgress

func (m *Manager) InstallWithProgress(ctx context.Context, path string, progress ProgressFunc) (InstallResult, error)

InstallWithProgress loads a module and reports incremental install progress.

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]InstalledModule, error)

List returns all installed modules with their runtime contributions.

func (*Manager) PlanInstall

func (m *Manager) PlanInstall(ctx context.Context, path string) (*Plan, error)

PlanInstall returns the intended install or upgrade plan without mutating persistent state.

func (*Manager) SetAfterChange

func (m *Manager) SetAfterChange(fn func(ctx context.Context) error)

SetAfterChange registers a callback invoked after successful install, upgrade, or uninstall operations.

func (*Manager) Uninstall

func (m *Manager) Uninstall(ctx context.Context, name string) error

Uninstall removes a module and its registry contributions.

func (*Manager) Upgrade

func (m *Manager) Upgrade(ctx context.Context, path string) (UpgradeResult, error)

Upgrade loads a local module directory and upgrades the already-installed module of the same name to a newer version.

func (*Manager) UpgradeWithProgress

func (m *Manager) UpgradeWithProgress(ctx context.Context, path string, progress ProgressFunc) (UpgradeResult, error)

UpgradeWithProgress upgrades a module and reports incremental progress.

type Manifest

type Manifest struct {
	Name            string          `json:"name"`
	Version         string          `json:"version"`
	Description     string          `json:"description,omitempty"`
	Dependencies    []DependencyRef `json:"dependencies,omitempty"`
	Resources       []string        `json:"resources,omitempty"`
	DefinitionFiles []string        `json:"definitionFiles,omitempty"`
	// IGPackage is a module-relative directory of compiled IG JSON resources
	// (typically modules/<name>/ig produced by make ig). When set, every
	// *.json file in that directory is loaded as a definition.
	IGPackage     string   `json:"igPackage,omitempty"`
	Views         []string `json:"views,omitempty"`
	AITools       []string `json:"aiTools,omitempty"`
	Permissions   []string `json:"permissions,omitempty"`
	SyncPolicies  []string `json:"syncPolicies,omitempty"`
	Subscriptions []string `json:"subscriptions,omitempty"`
	Migrations    []string `json:"migrations,omitempty"`
}

Manifest describes a module's identity and declared capabilities. Declarations for views, aiTools, permissions, syncPolicies, subscriptions, and migrations are persisted but not executed in v1.

type Module

type Module struct {
	Path            string
	Manifest        Manifest
	ManifestBytes   []byte
	Definitions     [][]byte
	DefinitionPaths []string
}

Module is a normalized, loaded module with its manifest and in-memory definition payloads.

type ModuleVerifier

type ModuleVerifier interface {
	VerifyModule(ctx context.Context, module Module) error
}

ModuleVerifier verifies a loaded module before dependency resolution or registry mutation. Deployments can use this seam to enforce their own trust roots and signature formats.

type ModuleVerifierFunc

type ModuleVerifierFunc func(ctx context.Context, module Module) error

ModuleVerifierFunc adapts a function to ModuleVerifier.

func (ModuleVerifierFunc) VerifyModule

func (f ModuleVerifierFunc) VerifyModule(ctx context.Context, module Module) error

VerifyModule implements ModuleVerifier.

type Plan

type Plan struct {
	Name                 string          `json:"name"`
	Version              string          `json:"version"`
	Action               string          `json:"action"`
	Dependencies         []DependencyRef `json:"dependencies,omitempty"`
	ResourcesToEnable    []string        `json:"resourcesToEnable,omitempty"`
	DefinitionsToInstall []DefinitionRef `json:"definitionsToInstall,omitempty"`
	DefinitionsToRemove  []DefinitionRef `json:"definitionsToRemove,omitempty"`
	Deferred             Declarations    `json:"deferred,omitempty"`
}

Plan describes the intended outcome of an install or upgrade without mutating persistent state.

type ProgressFunc

type ProgressFunc func(current, total int, message string)

ProgressFunc reports incremental module install progress.

type RegistryApplier

type RegistryApplier struct {
	// contains filtered or unexported fields
}

RegistryApplier installs module-owned definitions, enables or disables base resources, and rebuilds the registry snapshot. It is the boundary between the module installer and the registry.Manager.

func NewRegistryApplier

func NewRegistryApplier(reg *registry.Manager, defs store.DefinitionStore, installs store.RegistryInstallStore) *RegistryApplier

NewRegistryApplier creates an applier backed by the registry manager and its persistence stores.

func (*RegistryApplier) CompletePackageInstall

func (a *RegistryApplier) CompletePackageInstall(ctx context.Context, provenance registry.InstallProvenance) error

CompletePackageInstall enqueues batched ValueSet pre-expand for a package install.

func (*RegistryApplier) DefinitionStore

func (a *RegistryApplier) DefinitionStore() store.DefinitionStore

DefinitionStore returns the underlying definition store for queries.

func (*RegistryApplier) DeleteDefinition

func (a *RegistryApplier) DeleteDefinition(ctx context.Context, canonicalURL, version string) error

DeleteDefinition removes a definition catalog entry and its target mappings.

func (*RegistryApplier) DeleteInstall

func (a *RegistryApplier) DeleteInstall(ctx context.Context, filter store.RegistryInstallFilter) error

DeleteInstall removes registry install rows matching the filter.

func (*RegistryApplier) DisableResource

func (a *RegistryApplier) DisableResource(ctx context.Context, resourceType string) error

DisableResource marks a base resource type as disabled.

func (*RegistryApplier) EnableResource

func (a *RegistryApplier) EnableResource(ctx context.Context, resourceType string) error

EnableResource marks a base resource type as enabled.

func (*RegistryApplier) InstallDefinition

func (a *RegistryApplier) InstallDefinition(ctx context.Context, jsonData []byte, provenance registry.InstallProvenance) error

InstallDefinition ingests a definition JSON with module provenance.

func (*RegistryApplier) InstallStore

func (a *RegistryApplier) InstallStore() store.RegistryInstallStore

InstallStore returns the underlying registry install store for queries.

func (*RegistryApplier) RebuildSnapshot

func (a *RegistryApplier) RebuildSnapshot(ctx context.Context) (*registry.Snapshot, error)

RebuildSnapshot compiles the registry snapshot.

func (*RegistryApplier) SeedBundled

func (a *RegistryApplier) SeedBundled(ctx context.Context) error

SeedBundled ensures the embedded FHIR base definitions are present.

type UpgradeResult

type UpgradeResult struct {
	Name                 string             `json:"name"`
	OldVersion           string             `json:"oldVersion"`
	NewVersion           string             `json:"newVersion"`
	EnabledResources     []string           `json:"enabledResources,omitempty"`
	InstalledDefinitions []DefinitionRef    `json:"installedDefinitions,omitempty"`
	RemovedDefinitions   []DefinitionRef    `json:"removedDefinitions,omitempty"`
	Deferred             Declarations       `json:"deferred,omitempty"`
	Snapshot             *registry.Snapshot `json:"-"`
}

UpgradeResult reports what an upgrade changed in the registry.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL