Classify invalid artifact relations as input errors
This commit is contained in:
@@ -72,6 +72,16 @@ Required remediation:
|
||||
|
||||
## 2. P2: Classify identifiable Narratio input errors consistently
|
||||
|
||||
Status: Domain-validation unit completed; native identity classification remains
|
||||
pending upstream support. Catalog derivation now identifies invalid relations
|
||||
with a typed input error, retaining its underlying cause. Native `artifacts list`
|
||||
and `run --stage analyze` regressions return status 2 for an unknown dependency;
|
||||
joined storage/cancellation errors retain status 1. ckconfig v0.9.0 and the current
|
||||
upstream checkout classify native ConfigKit load errors only and expose no
|
||||
consumer classification hook. An upstream extension and its adoption are still
|
||||
needed for campaign/session assertions in native acquisition and comparison;
|
||||
permission to modify that repository has been requested.
|
||||
|
||||
Stages: 1, 7–10, and 12; native outcome verification in Stage 21.
|
||||
|
||||
Locations: `internal/app/configuration_commands.go:75–96`,
|
||||
@@ -497,3 +507,13 @@ test or application changes. Earlier full application verification remains
|
||||
applicable to the unchanged source. Documentation checks and `git diff --check`
|
||||
were repeated for this update. No live services or performance measurements were
|
||||
used.
|
||||
|
||||
## Remediation verification
|
||||
|
||||
The completed Narratio units and domain-validation portion of finding 2 pass
|
||||
`go test ./...`, `go test -race ./...`, `go vet ./...`, and `go build ./...`
|
||||
with official Go 1.27.4. Documentation checks and `git diff --check` also pass.
|
||||
Native regression coverage verifies equivalent-party resume, real roster changes,
|
||||
source normalization, and typed domain-input outcomes. No upstream files,
|
||||
dependencies, releases, tags, or remote repositories were changed. Finding 2's
|
||||
native configuration identity classification remains outstanding as recorded above.
|
||||
|
||||
@@ -29,7 +29,7 @@ func operationOutcome(err error) commandkit.Outcome {
|
||||
|
||||
func classifyOperationError(err error) commandkit.OutcomeKind {
|
||||
switch err.(type) {
|
||||
case *inputError, *config.SessionIdentityError:
|
||||
case *inputError, *config.SessionIdentityError, *config.ArtifactCatalogInputError:
|
||||
return commandkit.OutcomeUsage
|
||||
}
|
||||
switch wrapped := err.(type) {
|
||||
|
||||
@@ -114,11 +114,21 @@ func TestOperationOutcomePreservesCausesAndOperationalPrecedence(t *testing.T) {
|
||||
}
|
||||
input := &inputError{message: "invalid identity selection"}
|
||||
operational := errors.New("storage unavailable")
|
||||
_, catalogInput := config.DeriveArtifactCatalog(&config.PipelineConfig{Scriptorium: &config.ScriptoriumConfig{Artifacts: map[string]config.ScriptoriumArtifactConfig{
|
||||
"result": {OutputPath: "artifacts/result.md", DependsOn: []string{"missing"}},
|
||||
}}}, config.ResolvedParty{})
|
||||
var catalogError *config.ArtifactCatalogInputError
|
||||
if !errors.As(catalogInput, &catalogError) || errors.Unwrap(catalogError) == nil {
|
||||
t.Fatalf("catalog validation lost its typed input cause: %v", catalogInput)
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
err error
|
||||
status int
|
||||
}{
|
||||
{nil, 0}, {input, 2}, {invalid, 2},
|
||||
{catalogInput, 2},
|
||||
{errors.Join(catalogInput, operational), 1},
|
||||
{errors.Join(catalogInput, context.Canceled), 1},
|
||||
{&config.SessionIdentityError{Source: "session.yml", Field: "session_id", Expected: "one", Actual: "two"}, 2},
|
||||
{fmt.Errorf("request: %w", errors.Join(input, invalid)), 2},
|
||||
{errors.Join(input, operational), 1},
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
@@ -23,6 +24,32 @@ func catalogReportForTest(t *testing.T, args []string) *artifactCatalogReport {
|
||||
return &report
|
||||
}
|
||||
|
||||
func TestNativeCatalogValidationErrorsAreUsage(t *testing.T) {
|
||||
pipeline, campaign, session := writeValidConfigFiles(t, t.TempDir())
|
||||
data, err := os.ReadFile(pipeline)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mustWriteTestFile(t, pipeline, string(data)+`scriptorium:
|
||||
artifacts:
|
||||
result:
|
||||
enabled: false
|
||||
output_path: artifacts/result.md
|
||||
depends_on: [missing]
|
||||
`)
|
||||
for _, args := range [][]string{
|
||||
{"artifacts", "list", "--config", pipeline},
|
||||
{"run", "2026-05-03", "--stage", "analyze", "--config", pipeline, "--campaign-file", campaign, "--session-file", session},
|
||||
} {
|
||||
var out, diagnostic bytes.Buffer
|
||||
outcome := Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &diagnostic})
|
||||
var input *config.ArtifactCatalogInputError
|
||||
if outcome.Status != 2 || !errors.As(outcome.Cause, &input) {
|
||||
t.Fatalf("%v: status=%d cause=%v diagnostics=%s", args, outcome.Status, outcome.Cause, &diagnostic)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestArtifactCatalogCommandWithoutCampaignPreservesDependencies(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
pipeline := filepath.Join(dir, "pipeline.yml")
|
||||
|
||||
@@ -23,12 +23,24 @@ var memberVariableSelectors = map[string]func(PartyCharacter) string{
|
||||
"character.alias_summary": func(character PartyCharacter) string { return character.AliasSummary() },
|
||||
}
|
||||
|
||||
// ArtifactCatalogInputError identifies invalid relations in supplied artifact
|
||||
// configuration. Catalog derivation performs no external I/O.
|
||||
type ArtifactCatalogInputError struct{ cause error }
|
||||
|
||||
func (e *ArtifactCatalogInputError) Error() string { return e.cause.Error() }
|
||||
func (e *ArtifactCatalogInputError) Unwrap() error { return e.cause }
|
||||
|
||||
// DeriveArtifactCatalog interprets the completed pipeline and selected roster
|
||||
// without changing either native configuration result.
|
||||
func DeriveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) (*ArtifactCatalog, error) {
|
||||
func DeriveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) (derived *ArtifactCatalog, err error) {
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("pipeline config is required")
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
err = &ArtifactCatalogInputError{cause: err}
|
||||
}
|
||||
}()
|
||||
result := &ArtifactCatalog{Artifacts: map[string]ScriptoriumArtifactConfig{}}
|
||||
definitionSources := declarationSourceLookup(cfg)
|
||||
if cfg.Scriptorium == nil {
|
||||
|
||||
Reference in New Issue
Block a user