Remove retired reporting and diagnostic code

This commit is contained in:
2026-11-10 20:26:43 +00:00
parent a0e45c8f92
commit 9a52c8c246
21 changed files with 59 additions and 706 deletions

View File

@@ -4,9 +4,6 @@ import (
"context"
"errors"
"net/http"
"os"
"path/filepath"
"strings"
"testing"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/config"
@@ -22,38 +19,6 @@ func (r rejectingTransport) RoundTrip(*http.Request) (*http.Response, error) {
return nil, errors.New("provider access forbidden")
}
func TestExplanationYAMLIncludesSafeInheritanceEvidence(t *testing.T) {
data := `version: 3
glossary_collections:
common:
entries:
- id: a
name: secret-value-not-for-explanation
category: character
derived:
extends: common
`
file := filepath.Join(t.TempDir(), "config.yml")
if err := os.WriteFile(file, []byte(data), 0600); err != nil {
t.Fatal(err)
}
loaded, err := config.Load(ck.Input{Source: ck.File(file)}, "")
if err != nil {
t.Fatalf("%v: %+v", err, err.(*ck.LoadError).Diagnostics())
}
explanation, err := ExplanationYAML(loaded)
if err != nil {
t.Fatal(err)
}
text := string(explanation)
if strings.Contains(text, "secret-value-not-for-explanation") {
t.Fatal("explanation exposed an effective value")
}
if !strings.Contains(text, "/glossary_collections/derived/entries") || !strings.Contains(text, "inheritance:") || !strings.Contains(text, "/glossary_collections/common/entries") {
t.Fatalf("inherited field evidence missing: %s", text)
}
}
func TestRuntimeInspectionDoesNotRequireCredentialsOrProvider(t *testing.T) {
loaded, err := config.Load(ck.Input{Source: ck.NoSource()}, "")
if err != nil {
@@ -62,7 +27,4 @@ func TestRuntimeInspectionDoesNotRequireCredentialsOrProvider(t *testing.T) {
if _, err := NewRuntime(context.Background(), loaded, &http.Client{Transport: rejectingTransport{t}}); err != nil {
t.Fatal(err)
}
if _, err := ExplanationYAML(nil); err == nil {
t.Fatal("nil configuration accepted")
}
}

View File

@@ -1,80 +0,0 @@
package llm
import (
"fmt"
"strings"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/config"
ck "go.maximumdirect.net/configkit"
"gopkg.in/yaml.v3"
)
type derivationView struct {
Operation ck.ChangeKind `yaml:"operation"`
Reason string `yaml:"reason"`
Dependencies []string `yaml:"dependencies,omitempty"`
}
type inheritanceStepView struct {
From string `yaml:"from"`
To string `yaml:"to"`
Reference string `yaml:"reference"`
}
type explanationView struct {
Path string `yaml:"path"`
Source string `yaml:"source"`
Layer ck.Layer `yaml:"layer"`
Derivations []derivationView `yaml:"derivations,omitempty"`
Inheritance []inheritanceStepView `yaml:"inheritance,omitempty"`
}
// ExplanationYAML reports only origins and recorded resolution operations.
// It intentionally excludes effective and historical values, including secrets.
func ExplanationYAML(result *ck.Result[config.Config]) ([]byte, error) {
if result == nil {
return nil, fmt.Errorf("configuration result is unavailable")
}
metadata := result.Metadata()
sources := make(map[string]string)
for _, source := range result.Sources() {
sources[source.ID] = source.Label
}
records := make([]explanationView, 0)
paths := metadata.HistoricalPaths()
for i, path := range paths {
if path.String() == "" {
continue
}
if i+1 < len(paths) && strings.HasPrefix(paths[i+1].String(), path.String()+"/") {
continue
}
info, ok := metadata.Lookup(path)
if !ok {
continue
}
record := explanationView{Path: path.String(), Layer: info.Origin.Layer, Source: string(info.Origin.Layer)}
for _, step := range info.Origin.Inheritance {
record.Inheritance = append(record.Inheritance, inheritanceStepView{
From: step.From.String(), To: step.To.String(), Reference: step.Reference.String(),
})
}
if len(info.Origin.Locations) > 0 {
if label := sources[info.Origin.Locations[0].SourceID]; label != "" {
record.Source = label
}
}
for _, change := range metadata.History(path) {
if change.Origin.Layer != ck.LayerResolution {
continue
}
for _, reason := range change.Reasons {
derivation := derivationView{Operation: change.Origin.Operation, Reason: reason}
for _, dependency := range change.Dependencies {
derivation.Dependencies = append(derivation.Dependencies, dependency.String())
}
record.Derivations = append(record.Derivations, derivation)
}
}
records = append(records, record)
}
return yaml.Marshal(records)
}