Finish native completion and retire legacy command machinery

This commit is contained in:
2026-11-20 06:32:47 +00:00
parent 7db626781e
commit faa8cb5822
72 changed files with 841 additions and 2966 deletions

View File

@@ -495,11 +495,11 @@ scriptorium:
inherited := load(t, false)
expanded := load(t, true)
inheritedValues, err := EffectivePipelineValues(inherited.Pipeline)
inheritedValues, err := MarshalEffectivePipeline(inherited.Pipeline)
if err != nil {
t.Fatal(err)
}
expandedValues, err := EffectivePipelineValues(expanded.Pipeline)
expandedValues, err := MarshalEffectivePipeline(expanded.Pipeline)
if err != nil {
t.Fatal(err)
}

View File

@@ -7,7 +7,6 @@ import (
)
const (
pipelineDefaultOwnershipSource = "default"
effectivePipelineDigestVersion = "narratio-effective-pipeline-v4\n"
)

View File

@@ -33,25 +33,6 @@ func NormalizedConfigurationPath(path string) string {
return normalizedProvenancePath(path)
}
// EffectivePipelineValueRecord identifies one normalized, secret-free
// effective configuration value. Values use deterministic compact JSON
// representations so command output can be compared without raw YAML layout.
type EffectivePipelineValueRecord struct {
Path string
Value string
}
// EffectivePipelineValues projects a fully resolved pipeline into sorted
// logical configuration values. Mappings are flattened, while sequences remain
// atomic values. The projection uses the same normalized effective mapping as
// persistence and informational identity; it is not a native inspection view.
func EffectivePipelineValues(cfg *PipelineConfig) ([]EffectivePipelineValueRecord, error) {
if cfg == nil {
return nil, fmt.Errorf("pipeline config is required")
}
return projectionValueRecords(projectEffectivePipeline(cfg))
}
// MarshalEffectivePipeline materializes completed configuration for persistence.
// Credentials retain reference names; domain catalogs remain separate.
func MarshalEffectivePipeline(cfg *PipelineConfig) ([]byte, error) {

View File

@@ -1,11 +1,8 @@
package config
import (
"bytes"
"encoding/json"
"fmt"
"sort"
"strings"
)
// effectivePipelineProjection safely materializes configuration for persistence
@@ -78,11 +75,6 @@ type effectiveScriptoriumConfig struct {
Artifacts map[string]ScriptoriumArtifactConfig `yaml:"artifacts" json:"artifacts"`
}
type projectedPipelineValue struct {
record EffectivePipelineValueRecord
segments []string
}
func projectEffectivePipeline(cfg *PipelineConfig) effectivePipelineProjection {
projection := effectivePipelineProjection{
Workspace: cfg.Workspace, Campaigns: cfg.Campaigns, Storage: effectiveStorageConfig{Backend: cfg.Storage.Backend},
@@ -118,65 +110,3 @@ func projectionJSON(projection effectivePipelineProjection) ([]byte, error) {
}
return data, nil
}
func projectionValueTree(value any) (any, error) {
data, err := json.Marshal(value)
if err != nil {
return nil, fmt.Errorf("encode typed pipeline projection: %w", err)
}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.UseNumber()
var root any
if err := decoder.Decode(&root); err != nil {
return nil, fmt.Errorf("decode effective pipeline projection: %w", err)
}
return root, nil
}
func projectionValueRecords(projection effectivePipelineProjection) ([]EffectivePipelineValueRecord, error) {
detailed, err := projectionDetailedRecords(projection)
if err != nil {
return nil, err
}
records := make([]EffectivePipelineValueRecord, 0, len(detailed))
for _, value := range detailed {
records = append(records, value.record)
}
return records, nil
}
func projectionDetailedRecords(value any) ([]projectedPipelineValue, error) {
decoded, err := projectionValueTree(value)
if err != nil {
return nil, err
}
root, ok := decoded.(map[string]any)
if !ok {
return nil, fmt.Errorf("effective pipeline projection must be a mapping")
}
var records []projectedPipelineValue
appendProjectionRecords(&records, nil, root)
sort.Slice(records, func(i, j int) bool { return records[i].record.Path < records[j].record.Path })
return records, nil
}
func appendProjectionRecords(records *[]projectedPipelineValue, segments []string, value any) {
if mapping, ok := value.(map[string]any); ok && len(mapping) > 0 {
keys := make([]string, 0, len(mapping))
for key := range mapping {
keys = append(keys, key)
}
sort.Strings(keys)
for _, key := range keys {
child := append(append([]string(nil), segments...), key)
appendProjectionRecords(records, child, mapping[key])
}
return
}
encoded, _ := json.Marshal(value)
path := strings.Join(segments, ".")
*records = append(*records, projectedPipelineValue{
record: EffectivePipelineValueRecord{Path: path, Value: string(encoded)},
segments: append([]string(nil), segments...),
})
}

View File

@@ -115,14 +115,6 @@ notarius:
if err != nil {
t.Fatal(err)
}
firstValues, err := EffectivePipelineValues(first)
if err != nil {
t.Fatal(err)
}
serializedValues := ""
for _, value := range firstValues {
serializedValues += value.Path + "=" + value.Value + "\n"
}
directYAML, err := yaml.Marshal(first)
if err != nil {
t.Fatal(err)
@@ -131,7 +123,7 @@ notarius:
if err != nil {
t.Fatal(err)
}
for _, output := range []string{string(firstYAML), serializedValues, string(directYAML), string(directJSON)} {
for _, output := range []string{string(firstYAML), string(directYAML), string(directJSON)} {
if strings.Contains(output, firstCanary) {
t.Fatalf("effective output exposed credential value: %q", output)
}
@@ -165,12 +157,12 @@ notarius:
if err != nil {
t.Fatal(err)
}
secondValues, err := EffectivePipelineValues(second)
secondYAML, err := MarshalEffectivePipeline(second)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(firstValues, secondValues) {
t.Fatalf("credential value change altered effective projection:\nfirst=%#v\nsecond=%#v", firstValues, secondValues)
if string(firstYAML) != string(secondYAML) {
t.Fatal("credential value change altered safe materialization")
}
if EffectivePipelineDigest(first) != EffectivePipelineDigest(second) {
t.Fatal("credential value change altered effective digest")
@@ -195,16 +187,12 @@ notarius:
}
}
func TestEffectivePipelineValuesPreserveNilEmptyAndExactIntegers(t *testing.T) {
func TestPipelineMaterializationPreservesNilEmptyAndExactIntegers(t *testing.T) {
base := &PipelineConfig{
Audita: AuditaConfig{Modules: nil},
Scriptorium: &ScriptoriumConfig{Artifacts: nil},
resolution: &pipelineResolutionMetadata{},
}
nilValues, err := EffectivePipelineValues(base)
if err != nil {
t.Fatal(err)
}
nilYAML, err := MarshalEffectivePipeline(base)
if err != nil {
t.Fatal(err)
@@ -237,19 +225,6 @@ func TestEffectivePipelineValuesPreserveNilEmptyAndExactIntegers(t *testing.T) {
base.Scriptorium.Artifacts = map[string]ScriptoriumArtifactConfig{
"recap": {Vars: map[string]any{"exact": int64(9007199254740993)}},
}
emptyValues, err := EffectivePipelineValues(base)
if err != nil {
t.Fatal(err)
}
if got := effectiveValueForTest(t, nilValues, "audita.modules"); got != "null" {
t.Fatalf("nil sequence value = %q, want null", got)
}
if got := effectiveValueForTest(t, emptyValues, "audita.modules"); got != "[]" {
t.Fatalf("empty sequence value = %q, want []", got)
}
if got := effectiveValueForTest(t, emptyValues, "scriptorium.artifacts.recap.vars.exact"); got != "9007199254740993" {
t.Fatalf("exact integer value = %q", got)
}
if err := recomputePipelineEffectiveDigest(base); err != nil {
t.Fatal(err)
}
@@ -262,17 +237,6 @@ func TestEffectivePipelineValuesPreserveNilEmptyAndExactIntegers(t *testing.T) {
}
}
func effectiveValueForTest(t *testing.T, values []EffectivePipelineValueRecord, path string) string {
t.Helper()
for _, value := range values {
if value.Path == path {
return value.Value
}
}
t.Fatalf("effective value %q not found", path)
return ""
}
func TestValidateMissingAudioSource(t *testing.T) {
cfg := loadedValidConfig(t)
cfg.Session.Inputs.AudioDir = ""

View File

@@ -1,6 +1,7 @@
package config
import (
"bytes"
"strings"
"testing"
@@ -103,21 +104,12 @@ func TestScriptoriumInheritsResolvedTypedCredentialsSafely(t *testing.T) {
t.Fatalf("%s serialization omitted the inherited Scriptorium credential", name)
}
}
values, err := EffectivePipelineValues(cfg)
if err != nil {
var inspection bytes.Buffer
if err := cfg.ConfigKitResult().WriteEffective(&inspection); err != nil {
t.Fatal(err)
}
inspection, err := yaml.Marshal(values)
if err != nil {
t.Fatal(err)
}
foundInheritedCredential := false
for _, value := range values {
if value.Path == "scriptorium.credentials" && strings.Contains(value.Value, envName) {
foundInheritedCredential = true
}
}
if !foundInheritedCredential || strings.Contains(string(inspection), secret) {
t.Fatal("effective inspection did not safely expose inherited credential identity")
if !strings.Contains(inspection.String(), envName) || strings.Contains(inspection.String(), secret) {
t.Fatal("native inspection did not safely expose inherited credential identity")
}
}