Flatten session inspection error aggregation
This commit is contained in:
@@ -41,9 +41,9 @@ their scope. Unless assigned otherwise, a finding remains independent audit
|
|||||||
remediation. Shared code does not make a refactoring a prerequisite or assign
|
remediation. Shared code does not make a refactoring a prerequisite or assign
|
||||||
the whole finding to a roadmap.
|
the whole finding to a roadmap.
|
||||||
|
|
||||||
Eighteen entries are closed by the safety, transfer, audio discovery, S3
|
Nineteen entries are closed by the safety, transfer, audio discovery, S3
|
||||||
planning, prerequisite-history, publication-import, CLI classification, and
|
planning, prerequisite-history, publication-import, CLI classification, inspection aggregation, and
|
||||||
associated documentation work; 25 remain open. **Planned** identifies
|
associated documentation work; 24 remain open. **Planned** identifies
|
||||||
an agreed remedy awaiting implementation. **Potentially eliminated** requires verification that the offending
|
an agreed remedy awaiting implementation. **Potentially eliminated** requires verification that the offending
|
||||||
lifecycle is removed. **Coordinate** identifies shared changes, not a commitment
|
lifecycle is removed. **Coordinate** identifies shared changes, not a commitment
|
||||||
that a related feature implements the entire finding. Findings close only after their
|
that a related feature implements the entire finding. Findings close only after their
|
||||||
@@ -501,7 +501,11 @@ failures stay operational; no new validation rule is needed.
|
|||||||
|
|
||||||
### CAT-16 — P3: Flatten inspection-error aggregation
|
### CAT-16 — P3: Flatten inspection-error aggregation
|
||||||
|
|
||||||
Status: Open
|
Status: Closed
|
||||||
|
|
||||||
|
**Closure.** Publication and enclosing session inspection collect ordered errors and
|
||||||
|
join once. `TestPublishedOutputInspectionRetainsMultipleLookupFailures` verifies
|
||||||
|
partial rows, ordered messages, and retained error causes.
|
||||||
|
|
||||||
Original findings: [EF-05](02-efficiency.md#ef-05--p3-publication-inspection-errors-form-a-quadratic-formatting-tree).
|
Original findings: [EF-05](02-efficiency.md#ef-05--p3-publication-inspection-errors-form-a-quadratic-formatting-tree).
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ Stage 26 verifies integration and final catalog closure for all rows.
|
|||||||
|
|
||||||
## Stage 1: Flatten Publication Inspection Errors
|
## Stage 1: Flatten Publication Inspection Errors
|
||||||
|
|
||||||
CAT IDs: CAT-16. Status: Pending.
|
CAT IDs: CAT-16. Status: Complete.
|
||||||
|
|
||||||
Read [EF-05](audit/02-efficiency.md#ef-05--p3-publication-inspection-errors-form-a-quadratic-formatting-tree)
|
Read [EF-05](audit/02-efficiency.md#ef-05--p3-publication-inspection-errors-form-a-quadratic-formatting-tree)
|
||||||
and `internal/app/session_state_command.go` with its inspection tests.
|
and `internal/app/session_state_command.go` with its inspection tests.
|
||||||
|
|||||||
@@ -233,6 +233,49 @@ func TestPublishedOutputInspectionKeepsCarriedIdentityWithoutPayloadReads(t *tes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type inspectionFailingStore struct {
|
||||||
|
storage.ObjectStore
|
||||||
|
failures map[string]error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s inspectionFailingStore) Exists(_ context.Context, key string) (bool, error) {
|
||||||
|
return false, s.failures[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPublishedOutputInspectionRetainsMultipleLookupFailures(t *testing.T) {
|
||||||
|
cfg := restorePlanConfig(t)
|
||||||
|
rules := []config.PublishOutputRule{
|
||||||
|
{Source: "narratio.transcript.final_trimmed", Dest: "first.json"},
|
||||||
|
{Source: "narratio.transcript.final", Dest: "second.json"},
|
||||||
|
}
|
||||||
|
cfg.ArtifactCatalog = &config.ArtifactCatalog{PublishOutputs: rules}
|
||||||
|
fake := &storage.FakeBackend{}
|
||||||
|
current := seedCommittedRestoreSnapshot(t, cfg, fake, "20260519T010203Z-a1b2c3d4", nil)
|
||||||
|
failures := []error{&os.PathError{Op: "first", Path: "one", Err: os.ErrPermission}, &os.PathError{Op: "second", Path: "two", Err: os.ErrNotExist}}
|
||||||
|
store := inspectionFailingStore{ObjectStore: fake, failures: map[string]error{}}
|
||||||
|
for i, rule := range rules {
|
||||||
|
key := artifacts.S3RunRelativeDestinationKey(artifacts.S3RunPrefix(current.SessionPrefix, current.RunID), "published/"+rule.Dest)
|
||||||
|
current.Commit.Artifacts = append(current.Commit.Artifacts, artifacts.RemoteArtifact{Type: artifacts.RemoteArtifactTypePublishedOutput, Source: rule.Source, DestinationKey: key})
|
||||||
|
store.failures[key] = failures[i]
|
||||||
|
}
|
||||||
|
outputs, err := inspectPublishedOutputs(context.Background(), cfg, store, nil, current, nil, true, "current")
|
||||||
|
if len(outputs) != len(rules) {
|
||||||
|
t.Fatalf("outputs = %#v", outputs)
|
||||||
|
}
|
||||||
|
for i, output := range outputs {
|
||||||
|
if output.Source != rules[i].Source || output.State != "error" || output.Error != failures[i].Error() {
|
||||||
|
t.Fatalf("output %d = %#v", i, output)
|
||||||
|
}
|
||||||
|
if !errors.Is(err, failures[i]) {
|
||||||
|
t.Fatalf("missing cause %v in %v", failures[i], err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var pathErr *os.PathError
|
||||||
|
if !errors.As(err, &pathErr) || pathErr != failures[0] || err.Error() != failures[0].Error()+"\n"+failures[1].Error() {
|
||||||
|
t.Fatalf("ordered errors = %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSessionStateCommandsLeaveManifestUnchanged(t *testing.T) {
|
func TestSessionStateCommandsLeaveManifestUnchanged(t *testing.T) {
|
||||||
pipeline, campaign, session := writeValidConfigFiles(t, t.TempDir())
|
pipeline, campaign, session := writeValidConfigFiles(t, t.TempDir())
|
||||||
cfg, err := config.LoadWithSessionOptions(pipeline, campaign, session, config.SessionLoadOptions{})
|
cfg, err := config.LoadWithSessionOptions(pipeline, campaign, session, config.SessionLoadOptions{})
|
||||||
|
|||||||
@@ -108,16 +108,16 @@ func inspectSelectedSessionState(ctx context.Context, input *sessionInspectionIn
|
|||||||
|
|
||||||
func inspectSessionState(ctx context.Context, cfg *config.Config, status, remote bool, deps commandDependencies) (*sessionStateReport, error) {
|
func inspectSessionState(ctx context.Context, cfg *config.Config, status, remote bool, deps commandDependencies) (*sessionStateReport, error) {
|
||||||
report := &sessionStateReport{Campaign: cfg.Session.Campaign, SessionID: cfg.Session.SessionID, SessionSource: sessionSourceSummary(cfg), LocalManifest: "missing", Stages: []sessionStageState{}, Artifacts: []sessionArtifactState{}, Findings: []finding{}}
|
report := &sessionStateReport{Campaign: cfg.Session.Campaign, SessionID: cfg.Session.SessionID, SessionSource: sessionSourceSummary(cfg), LocalManifest: "missing", Stages: []sessionStageState{}, Artifacts: []sessionArtifactState{}, Findings: []finding{}}
|
||||||
var resultErr error
|
var failures []error
|
||||||
fail := func(category string, err error) {
|
fail := func(category string, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
report.Findings = append(report.Findings, errorFinding(category, err.Error()))
|
report.Findings = append(report.Findings, errorFinding(category, err.Error()))
|
||||||
resultErr = errors.Join(resultErr, err)
|
failures = append(failures, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := config.Validate(cfg); err != nil {
|
if err := config.Validate(cfg); err != nil {
|
||||||
fail("config", err)
|
fail("config", err)
|
||||||
return report, resultErr
|
return report, errors.Join(failures...)
|
||||||
}
|
}
|
||||||
report.Configuration = effectiveConfigSummary(cfg)
|
report.Configuration = effectiveConfigSummary(cfg)
|
||||||
paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
|
paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
|
||||||
@@ -224,7 +224,7 @@ func inspectSessionState(ctx context.Context, cfg *config.Config, status, remote
|
|||||||
requirements, collectErr := artifacts.CollectPreviousArtifactRequirements(configuredScriptoriumArtifacts(cfg), effective)
|
requirements, collectErr := artifacts.CollectPreviousArtifactRequirements(configuredScriptoriumArtifacts(cfg), effective)
|
||||||
fail("artifacts", collectErr)
|
fail("artifacts", collectErr)
|
||||||
if collectErr != nil {
|
if collectErr != nil {
|
||||||
return report, resultErr
|
return report, errors.Join(failures...)
|
||||||
}
|
}
|
||||||
previous := inspectPreviousArtifactReadiness(ctx, cfg, store, requirements)
|
previous := inspectPreviousArtifactReadiness(ctx, cfg, store, requirements)
|
||||||
fail("previous", previous.Err)
|
fail("previous", previous.Err)
|
||||||
@@ -237,7 +237,7 @@ func inspectSessionState(ctx context.Context, cfg *config.Config, status, remote
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return report, resultErr
|
return report, errors.Join(failures...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Built-in inspection reports manifest evidence without opening artifact payloads.
|
// Built-in inspection reports manifest evidence without opening artifact payloads.
|
||||||
@@ -275,7 +275,7 @@ func inspectPublishedOutputs(ctx context.Context, cfg *config.Config, store stor
|
|||||||
if current != nil {
|
if current != nil {
|
||||||
declarations = committedPublishedOutputs(current.Commit)
|
declarations = committedPublishedOutputs(current.Commit)
|
||||||
}
|
}
|
||||||
var resultErr error
|
var failures []error
|
||||||
for _, rule := range rules {
|
for _, rule := range rules {
|
||||||
source := strings.TrimSpace(rule.Source)
|
source := strings.TrimSpace(rule.Source)
|
||||||
destination, err := artifactpolicy.ResolvePublishedDestinationWithExtractions(source, rule.Dest, configuredOutputs, extractionOutputs)
|
destination, err := artifactpolicy.ResolvePublishedDestinationWithExtractions(source, rule.Dest, configuredOutputs, extractionOutputs)
|
||||||
@@ -310,11 +310,11 @@ func inspectPublishedOutputs(ctx context.Context, cfg *config.Config, store stor
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
output.State = "error"
|
output.State = "error"
|
||||||
output.Error = err.Error()
|
output.Error = err.Error()
|
||||||
resultErr = errors.Join(resultErr, err)
|
failures = append(failures, err)
|
||||||
}
|
}
|
||||||
outputs = append(outputs, output)
|
outputs = append(outputs, output)
|
||||||
}
|
}
|
||||||
return outputs, resultErr
|
return outputs, errors.Join(failures...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func inspectionSkipReason(record *manifest.StageRecord) string {
|
func inspectionSkipReason(record *manifest.StageRecord) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user