Preserve version one error record scopes

This commit is contained in:
2026-11-17 03:54:41 +00:00
parent 0c2a2164ec
commit c6be2ec20d
7 changed files with 71 additions and 47 deletions

View File

@@ -100,7 +100,7 @@ func TestStageIDIsLiteralInMarkdownAndExactInYAML(t *testing.T) {
snapshot := Snapshot{
StageNames: []string{StageLabel(0, "grammar", &id), StageLabel(1, "grammar", nil)},
WorkUnits: []WorkUnit{{StageIndex: 0, ChunkIndex: 0, State: "completed", ErrorCount: 1}},
Errors: []ErrorRecord{{Scope: "work_unit", StageID: &id}},
Errors: []ErrorRecord{{Scope: "work_unit", FailureDetails: FailureDetails{StageID: &id}}},
}
header := `| Chunk | 1: grammar (\[party\](https://example.invalid/) \*bold\* \_emphasis\_ \~\~strike\~\~ \\| <tag>) | 2: grammar |`
if rows := markdownTableRows(string(Markdown(snapshot))); len(rows) == 0 || rows[0] != header {

View File

@@ -49,25 +49,31 @@ type Failure struct {
}
type ErrorRecord struct {
Scope string `yaml:"scope"`
StageIndex *int `yaml:"stage_index,omitempty"`
StageID *string `yaml:"stage_id,omitempty"`
ModuleKey string `yaml:"module_key,omitempty"`
ModuleInstance string `yaml:"module_instance,omitempty"`
ChunkIndex *int `yaml:"chunk_index,omitempty"`
StartSegmentID *int `yaml:"start_segment_id,omitempty"`
EndSegmentID *int `yaml:"end_segment_id,omitempty"`
CorrectionsApplied *int `yaml:"corrections_applied,omitempty"`
Failures []Failure `yaml:"failures,omitempty"`
Phase string `yaml:"phase,omitempty"`
Reason string `yaml:"reason,omitempty"`
Message string `yaml:"message,omitempty"`
Operation string `yaml:"operation,omitempty"`
Validator string `yaml:"validator,omitempty"`
BatchIndex *int `yaml:"batch_index,omitempty"`
ProposalIndex *int `yaml:"proposal_index,omitempty"`
RepairAttempt *int `yaml:"repair_attempt,omitempty"`
OutputPath string `yaml:"output_path,omitempty"`
Scope string `yaml:"scope"`
FailureDetails `yaml:",inline"`
StartSegmentID *int `yaml:"start_segment_id,omitempty"`
EndSegmentID *int `yaml:"end_segment_id,omitempty"`
CorrectionsApplied *int `yaml:"corrections_applied,omitempty"`
Failures []Failure `yaml:"failures,omitempty"`
OutputPath string `yaml:"output_path,omitempty"`
Interruptions []FailureDetails `yaml:"interruptions,omitempty"`
}
// FailureDetails carries a run failure's classification and available origin.
type FailureDetails struct {
StageIndex *int `yaml:"stage_index,omitempty"`
StageID *string `yaml:"stage_id,omitempty"`
ModuleKey string `yaml:"module_key,omitempty"`
ModuleInstance string `yaml:"module_instance,omitempty"`
ChunkIndex *int `yaml:"chunk_index,omitempty"`
Phase string `yaml:"phase,omitempty"`
Reason string `yaml:"reason,omitempty"`
Message string `yaml:"message,omitempty"`
Operation string `yaml:"operation,omitempty"`
Validator string `yaml:"validator,omitempty"`
BatchIndex *int `yaml:"batch_index,omitempty"`
ProposalIndex *int `yaml:"proposal_index,omitempty"`
RepairAttempt *int `yaml:"repair_attempt,omitempty"`
}
type FilteredProposal struct {

View File

@@ -13,7 +13,7 @@ func TestYAMLPreservesScalarTypes(t *testing.T) {
falseValue := false
snapshot := Snapshot{RunID: "secret\\\"key", Status: StatusCompleted, StartedAt: time.Date(2026, 9, 24, 0, 0, 0, 0, time.UTC),
Summary: Summary{RunErrors: &zero, CorrectionsApplied: &one},
Errors: []ErrorRecord{{Scope: "run", Phase: "processing", Reason: "internal_failure", Message: "secret\\\"key 1"}},
Errors: []ErrorRecord{{Scope: "run", FailureDetails: FailureDetails{Phase: "processing", Reason: "internal_failure", Message: "secret\\\"key 1"}}},
Recoveries: []RecoveryRecord{{StageIndex: 0, Reasons: []string{"service_recovered"}, ExecutionCounts: ExecutionCounts{RetriesExhausted: &falseValue}}}}
for _, document := range []any{snapshot.ErrorsDocument(), snapshot.RecoveriesDocument()} {
payload, err := YAML(document)