Add reference catalog selection to pipeline configuration
This commit is contained in:
@@ -24,7 +24,8 @@ inspection authority.
|
|||||||
Resource resolution consults native entry origins and source contexts. A usable
|
Resource resolution consults native entry origins and source contexts. A usable
|
||||||
effective source supplies the base, otherwise the main source and then captured
|
effective source supplies the base, otherwise the main source and then captured
|
||||||
invocation directory provide the fallback. Explicit CLI paths use the invocation
|
invocation directory provide the fallback. Explicit CLI paths use the invocation
|
||||||
directory. See [resource rules](../config.md#pipeline-imports-and-overlays).
|
directory. Reference-catalog entries are resolved individually from their native
|
||||||
|
field origins; selection does not read unused vocabulary files. See [resource rules](../config.md#pipeline-imports-and-overlays).
|
||||||
|
|
||||||
## Invocation Acquisition
|
## Invocation Acquisition
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,13 @@ Add synthetic local fixtures so tests do not read the catalog checkout.
|
|||||||
|
|
||||||
## Stage 3. Add catalog selections to native pipeline acquisition
|
## Stage 3. Add catalog selections to native pipeline acquisition
|
||||||
|
|
||||||
Status: Pending
|
Status: Complete
|
||||||
|
|
||||||
|
Pipeline acquisition preserves reference-catalog mappings, resolves imported
|
||||||
|
paths from their field origins, and provides selection with unknown-ID errors.
|
||||||
|
Verified with `go test ./internal/config ./internal/doccheck`, including an
|
||||||
|
imported catalog and an operator extension. Campaign/session selection fields
|
||||||
|
and their use of these lookups are introduced in Stage 4.
|
||||||
|
|
||||||
Read `docs/internal/configuration.md` and the roadmap's authoring field table.
|
Read `docs/internal/configuration.md` and the roadmap's authoring field table.
|
||||||
Update `internal/config/config.go`, pipeline definitions/defaults/validation,
|
Update `internal/config/config.go`, pipeline definitions/defaults/validation,
|
||||||
|
|||||||
@@ -37,23 +37,30 @@ func (cfg *Config) PublicationOutputs() []PublishOutputRule {
|
|||||||
return cfg.ArtifactCatalog.PublishOutputs
|
return cfg.ArtifactCatalog.PublishOutputs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReferenceCatalogConfig maps vocabulary selections to native source files.
|
||||||
|
type ReferenceCatalogConfig struct {
|
||||||
|
Settings map[string]string `yaml:"settings" json:"settings"`
|
||||||
|
Systems map[string]string `yaml:"systems" json:"systems"`
|
||||||
|
}
|
||||||
|
|
||||||
// PipelineConfig contains durable pipeline-level settings.
|
// PipelineConfig contains durable pipeline-level settings.
|
||||||
type PipelineConfig struct {
|
type PipelineConfig struct {
|
||||||
Workspace WorkspaceConfig `yaml:"workspace" json:"workspace"`
|
ReferenceCatalog ReferenceCatalogConfig `yaml:"reference_catalog" json:"reference_catalog"`
|
||||||
Campaigns CampaignsConfig `yaml:"campaigns" json:"campaigns"`
|
Workspace WorkspaceConfig `yaml:"workspace" json:"workspace"`
|
||||||
Storage StorageConfig `yaml:"storage" json:"storage"`
|
Campaigns CampaignsConfig `yaml:"campaigns" json:"campaigns"`
|
||||||
Spool SpoolConfig `yaml:"spool" json:"spool"`
|
Storage StorageConfig `yaml:"storage" json:"storage"`
|
||||||
Cache CacheConfig `yaml:"cache" json:"cache"`
|
Spool SpoolConfig `yaml:"spool" json:"spool"`
|
||||||
Publish *PublishConfig `yaml:"publish" json:"publish"`
|
Cache CacheConfig `yaml:"cache" json:"cache"`
|
||||||
WhisperX WhisperXConfig `yaml:"whisperx" json:"whisperx"`
|
Publish *PublishConfig `yaml:"publish" json:"publish"`
|
||||||
Seriatim SeriatimConfig `yaml:"seriatim" json:"seriatim"`
|
WhisperX WhisperXConfig `yaml:"whisperx" json:"whisperx"`
|
||||||
Audita AuditaConfig `yaml:"audita" json:"audita"`
|
Seriatim SeriatimConfig `yaml:"seriatim" json:"seriatim"`
|
||||||
Normalize *NormalizeConfig `yaml:"normalize" json:"normalize"`
|
Audita AuditaConfig `yaml:"audita" json:"audita"`
|
||||||
Trim *TrimConfig `yaml:"trim" json:"trim"`
|
Normalize *NormalizeConfig `yaml:"normalize" json:"normalize"`
|
||||||
Render *RenderConfig `yaml:"render" json:"render"`
|
Trim *TrimConfig `yaml:"trim" json:"trim"`
|
||||||
Scriptorium *ScriptoriumConfig `yaml:"scriptorium" json:"scriptorium"`
|
Render *RenderConfig `yaml:"render" json:"render"`
|
||||||
Notarius *NotariusConfig `yaml:"notarius" json:"notarius"`
|
Scriptorium *ScriptoriumConfig `yaml:"scriptorium" json:"scriptorium"`
|
||||||
Notification NotificationConfig `yaml:"notification" json:"notification"`
|
Notarius *NotariusConfig `yaml:"notarius" json:"notarius"`
|
||||||
|
Notification NotificationConfig `yaml:"notification" json:"notification"`
|
||||||
|
|
||||||
resolution *pipelineResolutionMetadata `yaml:"-" json:"-"`
|
resolution *pipelineResolutionMetadata `yaml:"-" json:"-"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,21 +8,22 @@ import (
|
|||||||
// effectivePipelineProjection safely materializes configuration for persistence
|
// effectivePipelineProjection safely materializes configuration for persistence
|
||||||
// and informational identity. Native results own inspection and comparison.
|
// and informational identity. Native results own inspection and comparison.
|
||||||
type effectivePipelineProjection struct {
|
type effectivePipelineProjection struct {
|
||||||
Workspace WorkspaceConfig `yaml:"workspace" json:"workspace"`
|
ReferenceCatalog ReferenceCatalogConfig `yaml:"reference_catalog" json:"reference_catalog"`
|
||||||
Campaigns CampaignsConfig `yaml:"campaigns" json:"campaigns"`
|
Workspace WorkspaceConfig `yaml:"workspace" json:"workspace"`
|
||||||
Storage effectiveStorageConfig `yaml:"storage" json:"storage"`
|
Campaigns CampaignsConfig `yaml:"campaigns" json:"campaigns"`
|
||||||
Spool SpoolConfig `yaml:"spool" json:"spool"`
|
Storage effectiveStorageConfig `yaml:"storage" json:"storage"`
|
||||||
Cache CacheConfig `yaml:"cache" json:"cache"`
|
Spool SpoolConfig `yaml:"spool" json:"spool"`
|
||||||
Publish *PublishConfig `yaml:"publish" json:"publish"`
|
Cache CacheConfig `yaml:"cache" json:"cache"`
|
||||||
WhisperX WhisperXConfig `yaml:"whisperx" json:"whisperx"`
|
Publish *PublishConfig `yaml:"publish" json:"publish"`
|
||||||
Seriatim SeriatimConfig `yaml:"seriatim" json:"seriatim"`
|
WhisperX WhisperXConfig `yaml:"whisperx" json:"whisperx"`
|
||||||
Audita effectiveAuditaConfig `yaml:"audita" json:"audita"`
|
Seriatim SeriatimConfig `yaml:"seriatim" json:"seriatim"`
|
||||||
Normalize *NormalizeConfig `yaml:"normalize" json:"normalize"`
|
Audita effectiveAuditaConfig `yaml:"audita" json:"audita"`
|
||||||
Trim *TrimConfig `yaml:"trim" json:"trim"`
|
Normalize *NormalizeConfig `yaml:"normalize" json:"normalize"`
|
||||||
Render *RenderConfig `yaml:"render" json:"render"`
|
Trim *TrimConfig `yaml:"trim" json:"trim"`
|
||||||
Scriptorium *effectiveScriptoriumConfig `yaml:"scriptorium" json:"scriptorium"`
|
Render *RenderConfig `yaml:"render" json:"render"`
|
||||||
Notarius *effectiveNotariusConfig `yaml:"notarius" json:"notarius"`
|
Scriptorium *effectiveScriptoriumConfig `yaml:"scriptorium" json:"scriptorium"`
|
||||||
Notification NotificationConfig `yaml:"notification" json:"notification"`
|
Notarius *effectiveNotariusConfig `yaml:"notarius" json:"notarius"`
|
||||||
|
Notification NotificationConfig `yaml:"notification" json:"notification"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type effectiveStorageConfig struct {
|
type effectiveStorageConfig struct {
|
||||||
@@ -77,7 +78,8 @@ type effectiveScriptoriumConfig struct {
|
|||||||
|
|
||||||
func projectEffectivePipeline(cfg *PipelineConfig) effectivePipelineProjection {
|
func projectEffectivePipeline(cfg *PipelineConfig) effectivePipelineProjection {
|
||||||
projection := effectivePipelineProjection{
|
projection := effectivePipelineProjection{
|
||||||
Workspace: cfg.Workspace, Campaigns: cfg.Campaigns, Storage: effectiveStorageConfig{Backend: cfg.Storage.Backend},
|
ReferenceCatalog: cfg.ReferenceCatalog,
|
||||||
|
Workspace: cfg.Workspace, Campaigns: cfg.Campaigns, Storage: effectiveStorageConfig{Backend: cfg.Storage.Backend},
|
||||||
Spool: cfg.Spool, Cache: cfg.Cache, Publish: cfg.Publish,
|
Spool: cfg.Spool, Cache: cfg.Cache, Publish: cfg.Publish,
|
||||||
WhisperX: cfg.WhisperX, Seriatim: cfg.Seriatim,
|
WhisperX: cfg.WhisperX, Seriatim: cfg.Seriatim,
|
||||||
Normalize: cfg.Normalize, Trim: cfg.Trim, Render: cfg.Render,
|
Normalize: cfg.Normalize, Trim: cfg.Trim, Render: cfg.Render,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
configkit "go.maximumdirect.net/configkit"
|
configkit "go.maximumdirect.net/configkit"
|
||||||
@@ -119,6 +120,23 @@ func defaultPublishOutputs() []PublishOutputRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resolvePipelineConfig(cfg *PipelineConfig, resolution *configkit.Resolution, invocationDir string) error {
|
func resolvePipelineConfig(cfg *PipelineConfig, resolution *configkit.Resolution, invocationDir string) error {
|
||||||
|
for _, group := range []struct {
|
||||||
|
name string
|
||||||
|
entries map[string]string
|
||||||
|
}{
|
||||||
|
{"settings", cfg.ReferenceCatalog.Settings}, {"systems", cfg.ReferenceCatalog.Systems},
|
||||||
|
} {
|
||||||
|
ids := make([]string, 0, len(group.entries))
|
||||||
|
for id := range group.entries {
|
||||||
|
ids = append(ids, id)
|
||||||
|
}
|
||||||
|
sort.Strings(ids)
|
||||||
|
for _, id := range ids {
|
||||||
|
value := group.entries[id]
|
||||||
|
resolveHostResource(resolution, configkit.Keys("reference_catalog", group.name, id), &value, invocationDir)
|
||||||
|
group.entries[id] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
resolveHostResource(resolution, configkit.Keys("workspace", "root"), &cfg.Workspace.Root, invocationDir)
|
resolveHostResource(resolution, configkit.Keys("workspace", "root"), &cfg.Workspace.Root, invocationDir)
|
||||||
resolveHostResource(resolution, configkit.Keys("campaigns", "root"), &cfg.Campaigns.Root, invocationDir)
|
resolveHostResource(resolution, configkit.Keys("campaigns", "root"), &cfg.Campaigns.Root, invocationDir)
|
||||||
resolveHostResource(resolution, configkit.Keys("spool", "root"), &cfg.Spool.Root, invocationDir)
|
resolveHostResource(resolution, configkit.Keys("spool", "root"), &cfg.Spool.Root, invocationDir)
|
||||||
|
|||||||
24
internal/config/reference_catalog.go
Normal file
24
internal/config/reference_catalog.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
// SelectSetting returns the source for a selected setting, or no source for an omitted selection.
|
||||||
|
func (catalog ReferenceCatalogConfig) SelectSetting(id string) (string, error) {
|
||||||
|
return selectReference("setting", id, catalog.Settings)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SelectSystem returns the source for a selected system, or no source for an omitted selection.
|
||||||
|
func (catalog ReferenceCatalogConfig) SelectSystem(id string) (string, error) {
|
||||||
|
return selectReference("system", id, catalog.Systems)
|
||||||
|
}
|
||||||
|
|
||||||
|
func selectReference(kind, id string, entries map[string]string) (string, error) {
|
||||||
|
if id == "" {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
path, ok := entries[id]
|
||||||
|
if !ok {
|
||||||
|
return "", fmt.Errorf("unknown reference catalog %s %q", kind, id)
|
||||||
|
}
|
||||||
|
return path, nil
|
||||||
|
}
|
||||||
55
internal/config/reference_catalog_test.go
Normal file
55
internal/config/reference_catalog_test.go
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestReferenceCatalogImportedOriginsAndSelections(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
root := writePipelineFixture(t, dir, "pipeline.yml", `config:
|
||||||
|
imports:
|
||||||
|
- path: catalog/catalog.yml
|
||||||
|
reference_catalog:
|
||||||
|
settings:
|
||||||
|
local: ./local.yml
|
||||||
|
whisperx:
|
||||||
|
transcribe_url: https://transcription.example.test/transcribe
|
||||||
|
`)
|
||||||
|
writePipelineFixture(t, dir, "catalog/catalog.yml", `reference_catalog:
|
||||||
|
settings:
|
||||||
|
sample: ./settings/sample.yml
|
||||||
|
systems:
|
||||||
|
sample: ./systems/sample.yml
|
||||||
|
`)
|
||||||
|
cfg, err := LoadPipeline(root)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, tc := range []struct{ got, want string }{
|
||||||
|
{cfg.ReferenceCatalog.Settings["sample"], filepath.Join(dir, "catalog/settings/sample.yml")},
|
||||||
|
{cfg.ReferenceCatalog.Settings["local"], filepath.Join(dir, "local.yml")},
|
||||||
|
{cfg.ReferenceCatalog.Systems["sample"], filepath.Join(dir, "catalog/systems/sample.yml")},
|
||||||
|
} {
|
||||||
|
if tc.got != tc.want {
|
||||||
|
t.Fatalf("path %q, want %q", tc.got, tc.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if got, err := cfg.ReferenceCatalog.SelectSetting("sample"); err != nil || got != cfg.ReferenceCatalog.Settings["sample"] {
|
||||||
|
t.Fatalf("selection: %q, %v", got, err)
|
||||||
|
}
|
||||||
|
if _, err := cfg.ReferenceCatalog.SelectSystem("missing"); err == nil || !strings.Contains(err.Error(), "missing") {
|
||||||
|
t.Fatalf("missing selection: %v", err)
|
||||||
|
}
|
||||||
|
if got, err := cfg.ReferenceCatalog.SelectSetting(""); err != nil || got != "" {
|
||||||
|
t.Fatalf("omitted selection: %q, %v", got, err)
|
||||||
|
}
|
||||||
|
b, err := MarshalEffectivePipeline(cfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !strings.Contains(string(b), "reference_catalog:") || !strings.Contains(string(b), "sample:") {
|
||||||
|
t.Fatalf("catalog omitted from effective snapshot: %s", b)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user