Remove unused helpers and retired path fields
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/subprocess"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/fileops"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/notariusref"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/pathsafe"
|
||||
)
|
||||
|
||||
const maxReportBytes = 1 << 20
|
||||
@@ -241,21 +240,6 @@ func validateBundleRoot(outputRoot, bundleRoot string) (string, error) {
|
||||
return bundle, nil
|
||||
}
|
||||
|
||||
func resolveRegularFile(root, logicalPath string) (string, error) {
|
||||
resolved, err := pathsafe.JoinSlashRelativeUnderRoot(root, logicalPath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
relative, err := filepath.Rel(root, resolved)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := requireRegularFileTree(root, relative); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return resolved, nil
|
||||
}
|
||||
|
||||
func requireDirectoryTree(root, relative string) error {
|
||||
if err := requireDirectory(root); err != nil {
|
||||
return err
|
||||
@@ -270,24 +254,6 @@ func requireDirectoryTree(root, relative string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func requireRegularFileTree(root, relative string) error {
|
||||
components := strings.Split(relative, string(filepath.Separator))
|
||||
if len(components) == 0 {
|
||||
return fmt.Errorf("regular file path is required")
|
||||
}
|
||||
if err := requireDirectory(root); err != nil {
|
||||
return err
|
||||
}
|
||||
current := root
|
||||
for _, component := range components[:len(components)-1] {
|
||||
current = filepath.Join(current, component)
|
||||
if err := requireDirectory(current); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return requireRegularFile(filepath.Join(current, components[len(components)-1]))
|
||||
}
|
||||
|
||||
func requireDirectory(path string) error {
|
||||
info, err := os.Lstat(path)
|
||||
if err != nil {
|
||||
|
||||
@@ -553,11 +553,3 @@ func assertTextFile(t *testing.T, path, want string) {
|
||||
t.Fatalf("ReadFile(%q) = %q, want %q", path, string(data), want)
|
||||
}
|
||||
}
|
||||
|
||||
func cloneMap(source map[string]any) map[string]any {
|
||||
result := make(map[string]any, len(source))
|
||||
for key, value := range source {
|
||||
result[key] = value
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -65,28 +65,3 @@ func validateScopedTarget(root, target, policy string, requireDir bool) (scopedD
|
||||
}
|
||||
return scopedDir{RootAbs: rootAbs, TargetAbs: targetAbs, Exists: true}, nil
|
||||
}
|
||||
|
||||
func validateCleanRoot(root, policy string) (string, bool, error) {
|
||||
cleanRoot := strings.TrimSpace(root)
|
||||
if cleanRoot == "" {
|
||||
return "", false, fmt.Errorf("cleanup policy %s: root path is required", policy)
|
||||
}
|
||||
rootAbs, err := filepath.Abs(cleanRoot)
|
||||
if err != nil {
|
||||
return "", false, fmt.Errorf("cleanup policy %s: resolve root %q: %w", policy, cleanRoot, err)
|
||||
}
|
||||
info, err := os.Lstat(rootAbs)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return rootAbs, false, nil
|
||||
}
|
||||
return "", false, fmt.Errorf("cleanup policy %s: stat root %q: %w", policy, rootAbs, err)
|
||||
}
|
||||
if info.Mode()&os.ModeSymlink != 0 {
|
||||
return "", false, fmt.Errorf("cleanup policy %s: refusing to clean symlink root %q", policy, rootAbs)
|
||||
}
|
||||
if !info.IsDir() {
|
||||
return "", false, fmt.Errorf("cleanup policy %s: root %q is not a directory", policy, rootAbs)
|
||||
}
|
||||
return rootAbs, true, nil
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
||||
@@ -506,21 +505,6 @@ narratio:
|
||||
return campaignPath
|
||||
}
|
||||
|
||||
func writeManifestPathForExecute(t *testing.T) string {
|
||||
t.Helper()
|
||||
|
||||
store := &manifest.LocalStore{}
|
||||
m := manifest.New("2026-05-03", time.Date(2026, 5, 3, 10, 0, 0, 0, time.UTC))
|
||||
m.MarkStageSucceeded("prepare", time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC), nil)
|
||||
|
||||
path := filepath.Join(t.TempDir(), "manifest.json")
|
||||
if err := store.Save(context.Background(), path, m); err != nil {
|
||||
t.Fatalf("save manifest: %v", err)
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
func mustWriteTestFile(t *testing.T, path, contents string) {
|
||||
t.Helper()
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
|
||||
@@ -45,13 +45,6 @@ func TestExecuteConfigUsesInvocationPipelineLoader(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func writeInspectionOverlays(t *testing.T, pipelinePath, production, testing string) {
|
||||
t.Helper()
|
||||
overlaysDir := filepath.Join(filepath.Dir(pipelinePath), "overlays")
|
||||
mustWriteTestFile(t, filepath.Join(overlaysDir, "production.yml"), production)
|
||||
mustWriteTestFile(t, filepath.Join(overlaysDir, "testing.yml"), testing)
|
||||
}
|
||||
|
||||
func writeInspectionFamilyConfig(t *testing.T) (string, string) {
|
||||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
)
|
||||
|
||||
func mustPreviousArtifactPathForCampaign(t *testing.T, root, campaign, sessionID, relative string) string {
|
||||
t.Helper()
|
||||
path, err := artifacts.SessionPreviousArtifactPathForCampaign(root, campaign, sessionID, relative)
|
||||
if err != nil {
|
||||
t.Fatalf("SessionPreviousArtifactPathForCampaign() error = %v", err)
|
||||
}
|
||||
return path
|
||||
}
|
||||
@@ -22,8 +22,6 @@ type SessionPaths struct {
|
||||
TranscriptsDir string
|
||||
TranscriptsRawDir string
|
||||
ArtifactsDir string
|
||||
ReportsDir string
|
||||
ConfigDir string
|
||||
LogsDir string
|
||||
DebugDir string
|
||||
ReferencesDir string
|
||||
@@ -240,8 +238,6 @@ func buildSessionPathsFromRoot(workspaceRoot, campaign, sessionID, root string)
|
||||
TranscriptsDir: filepath.Join(root, config.PathTranscriptsSegment),
|
||||
TranscriptsRawDir: filepath.Join(root, filepath.FromSlash(config.PathTranscriptsRaw)),
|
||||
ArtifactsDir: filepath.Join(root, config.PathArtifactsDirSegment),
|
||||
ReportsDir: filepath.Join(root, config.PathReportsDirSegment),
|
||||
ConfigDir: filepath.Join(root, config.PathConfigDirSegment),
|
||||
LogsDir: filepath.Join(root, config.PathLogsDirSegment),
|
||||
DebugDir: filepath.Join(root, "debug"),
|
||||
ReferencesDir: filepath.Join(root, config.PathInputsDirSegment, "references"),
|
||||
|
||||
@@ -33,7 +33,6 @@ const (
|
||||
|
||||
DefaultScriptoriumBinary = "scriptorium"
|
||||
DefaultScriptoriumTimeout = "10m"
|
||||
DefaultScriptoriumArtifactOutputRoot = "artifacts"
|
||||
DefaultScriptoriumStickySessionVarName = "session_id"
|
||||
DefaultScriptoriumStickySessionVarPrefix = "narratio-session-"
|
||||
|
||||
@@ -65,24 +64,17 @@ const (
|
||||
PathTranscriptsSegment = "transcripts"
|
||||
PathTranscriptsRaw = "transcripts/raw"
|
||||
PathArtifactsDirSegment = "artifacts"
|
||||
PathReportsDirSegment = "reports"
|
||||
PathConfigDirSegment = "config"
|
||||
PathLogsDirSegment = "logs"
|
||||
PathRunsDirSegment = "runs"
|
||||
PathPreviousDirSegment = "previous"
|
||||
PathManifestFile = "manifest.json"
|
||||
PathLockFile = ".lock"
|
||||
PathTranscriptBase = artifactmodel.TranscriptPathBase
|
||||
PathTranscriptPolished = artifactmodel.TranscriptPathPolished
|
||||
PathTranscriptFinal = artifactmodel.TranscriptPathFinal
|
||||
PathTranscriptFinalTrimmed = artifactmodel.TranscriptPathFinalTrimmed
|
||||
|
||||
S3CampaignsSegment = "campaigns"
|
||||
S3SessionsSegment = "sessions"
|
||||
S3RunsSegment = "runs"
|
||||
S3CurrentSegment = "current"
|
||||
S3ManifestFile = "manifest.json"
|
||||
S3RunIDFile = "run_id.txt"
|
||||
S3CommitFile = "commit.json"
|
||||
S3CommitPointerFile = "commit-pointer.json"
|
||||
S3SessionSnapshotFile = "session-manifest.json"
|
||||
|
||||
@@ -2,8 +2,6 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
@@ -27,12 +25,6 @@ func EffectivePipelineImports(cfg *PipelineConfig) []string {
|
||||
return append([]string(nil), cfg.resolution.imports...)
|
||||
}
|
||||
|
||||
// NormalizedConfigurationPath returns a clean absolute path when possible for
|
||||
// display-only configuration provenance.
|
||||
func NormalizedConfigurationPath(path string) string {
|
||||
return normalizedProvenancePath(path)
|
||||
}
|
||||
|
||||
// MarshalEffectivePipeline materializes completed configuration for persistence.
|
||||
// Credentials retain reference names; domain catalogs remain separate.
|
||||
func MarshalEffectivePipeline(cfg *PipelineConfig) ([]byte, error) {
|
||||
@@ -61,14 +53,3 @@ func MarshalEffectivePipeline(cfg *PipelineConfig) ([]byte, error) {
|
||||
}
|
||||
return output, nil
|
||||
}
|
||||
|
||||
func normalizedProvenancePath(path string) string {
|
||||
if strings.TrimSpace(path) == "" {
|
||||
return ""
|
||||
}
|
||||
abs, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
return filepath.Clean(path)
|
||||
}
|
||||
return filepath.Clean(abs)
|
||||
}
|
||||
|
||||
@@ -119,7 +119,6 @@ func TestProductDestinationsPreserveExplicitRemotePaths(t *testing.T) {
|
||||
Notarius: &NotariusConfig{Enabled: true, Outputs: map[string]NotariusOutputConfig{"people": {LaneID: "people", Filename: "people-local.json"}}},
|
||||
Publish: &PublishConfig{Outputs: []PublishOutputRule{{Source: "narratio.extraction.people", Dest: "archive/session/people.json"}}},
|
||||
}
|
||||
applyMissingPublishDestinations(cfg.Publish, nil, cfg.Notarius)
|
||||
if got := cfg.Publish.Outputs[0].Dest; got != "archive/session/people.json" {
|
||||
t.Fatalf("remote destination = %q", got)
|
||||
}
|
||||
|
||||
@@ -38,18 +38,6 @@ func validateRelativeSafePath(fieldName, value string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validatePathWithinRoot(fieldName, value, root string) error {
|
||||
normalizedValue := filepath.ToSlash(filepath.Clean(strings.TrimSpace(value)))
|
||||
normalizedRoot := filepath.ToSlash(filepath.Clean(strings.TrimSpace(root)))
|
||||
if normalizedValue == normalizedRoot {
|
||||
return nil
|
||||
}
|
||||
if strings.HasPrefix(normalizedValue, normalizedRoot+"/") {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("%s must be under %s/", fieldName, normalizedRoot)
|
||||
}
|
||||
|
||||
func validateDuration(fieldName, value string) error {
|
||||
trimmed := strings.TrimSpace(value)
|
||||
if trimmed == "" {
|
||||
|
||||
@@ -33,12 +33,6 @@ func deriveMissingPublishDestinations(cfg *PublishConfig, scriptorium *Scriptori
|
||||
return derived
|
||||
}
|
||||
|
||||
func applyMissingPublishDestinations(cfg *PublishConfig, scriptorium *ScriptoriumConfig, notarius *NotariusConfig) {
|
||||
for _, derived := range deriveMissingPublishDestinations(cfg, scriptorium, notarius) {
|
||||
cfg.Outputs[derived.index].Dest = derived.dest
|
||||
}
|
||||
}
|
||||
|
||||
func validateStorage(cfg StorageConfig) error {
|
||||
backend := strings.ToLower(strings.TrimSpace(cfg.Backend))
|
||||
switch backend {
|
||||
|
||||
@@ -259,7 +259,7 @@ func hashAnalyzeInputFile(paths artifacts.SessionPaths, path string) (string, in
|
||||
if err != nil {
|
||||
return "", 0, fmt.Errorf("resolve input below session root: %w", err)
|
||||
}
|
||||
relative, err = pathsafe.NormalizeRelativeDestination(filepath.ToSlash(relative))
|
||||
_, err = pathsafe.NormalizeRelativeDestination(filepath.ToSlash(relative))
|
||||
if err != nil {
|
||||
return "", 0, fmt.Errorf("input path is outside session root: %w", err)
|
||||
}
|
||||
|
||||
@@ -954,8 +954,6 @@ type extractFixture struct {
|
||||
inputPath string
|
||||
}
|
||||
|
||||
func stringPointerForExtractTest(value string) *string { return &value }
|
||||
|
||||
func extractFixtureFromEnv(t *testing.T, env *Env, m *manifest.Manifest) extractFixture {
|
||||
t.Helper()
|
||||
paths := sessionPathsForEnv(env, m.SessionID)
|
||||
|
||||
@@ -752,17 +752,6 @@ func findManifestInput(t *testing.T, inputs []manifest.InputRecord, kind string)
|
||||
return manifest.InputRecord{}
|
||||
}
|
||||
|
||||
func assertManifestInputsSorted(t *testing.T, inputs []manifest.InputRecord) {
|
||||
t.Helper()
|
||||
for index := 1; index < len(inputs); index++ {
|
||||
previous := inputs[index-1]
|
||||
current := inputs[index]
|
||||
if previous.Kind > current.Kind || (previous.Kind == current.Kind && previous.Path > current.Path) {
|
||||
t.Fatalf("manifest inputs are not sorted at %d: %#v before %#v", index, previous, current)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mustReadFileEquals(t *testing.T, path, want string) {
|
||||
t.Helper()
|
||||
data, err := os.ReadFile(path)
|
||||
|
||||
Reference in New Issue
Block a user