package proposals import ( "fmt" "gitea.maximumdirect.net/eric/audita/v3/internal/core/schema" ) // CorrectionProposal is the base proposal emitted by correction modules. type CorrectionProposal struct { TargetSegmentID int `json:"id"` OriginalText string `json:"original_text"` CorrectedText string `json:"corrected_text"` } // ProposalMetadata is framework-enriched execution metadata for a proposal. type ProposalMetadata struct { ProposalIndex int `json:"proposal_index"` ModuleKey string `json:"module_key"` ModuleInstance string `json:"module_instance"` SectionIndex *int `json:"section_index,omitempty"` } // EnrichedCorrectionProposal combines module-emitted proposal data with // framework execution metadata. type EnrichedCorrectionProposal struct { CorrectionProposal ProposalMetadata OriginalApplicability Applicability `json:"-"` } // Applicability records whether validation previewed a proposal against the // original section and could apply it there. type Applicability uint8 const ( ApplicabilityUnknown Applicability = iota Applicable Inapplicable ) // Validate checks only basic structural integrity of the proposal. // Semantic checks (staleness, span presence, replacement behavior) are handled // by proposal preview/application and validator execution. func (p CorrectionProposal) Validate() error { if p.TargetSegmentID <= 0 { return fmt.Errorf("proposal id must be positive") } if p.OriginalText == "" { return fmt.Errorf("proposal original_text must not be empty") } return nil } // SegmentIDAtReference maps a one-based model reference in the supplied // section to the transcript's segment ID. Zero represents an invalid reference. func SegmentIDAtReference(section *schema.Transcript, reference int) int { if section == nil || reference <= 0 || reference > len(section.Segments) { return 0 } return section.Segments[reference-1].ID }