Add Notarius reference configuration vocabulary

This commit is contained in:
2026-08-29 14:55:24 +00:00
parent 42ed81cbe1
commit 5831c0c9e6
12 changed files with 476 additions and 42 deletions

View File

@@ -0,0 +1,43 @@
// Package notariusref owns Narratio's Notarius CLI reference-selector
// vocabulary without depending on Notarius implementation packages.
package notariusref
import (
"fmt"
"strings"
)
// NormalizeSelector validates and normalizes a Notarius v0.6 reference
// selector. It intentionally validates selector structure only; Notarius owns
// target, slot, and media compatibility.
func NormalizeSelector(value string) (string, error) {
selector := strings.TrimSpace(value)
if selector == "" {
return "", fmt.Errorf("reference selector is required")
}
if strings.Contains(selector, "=") {
return "", fmt.Errorf("reference selector must not contain '='")
}
parts := strings.Split(selector, ".")
for index := range parts {
parts[index] = strings.TrimSpace(parts[index])
if parts[index] == "" {
return "", fmt.Errorf("reference selector components must not be empty")
}
}
switch len(parts) {
case 1, 2:
return strings.Join(parts, "."), nil
case 3:
switch parts[1] {
case "extract", "merge", "normalize":
return strings.Join(parts, "."), nil
default:
return "", fmt.Errorf("three-component reference selector must use extract, merge, or normalize as its middle component")
}
default:
return "", fmt.Errorf("reference selector must use slot, chunk.slot, lane.slot, or lane.stage.slot")
}
}