Validate internal decisions and reconcile exact model references
This commit is contained in:
@@ -62,6 +62,25 @@ type Decision struct {
|
||||
DiagnosticArtifactPath string `json:"diagnostic_artifact_path,omitempty"`
|
||||
}
|
||||
|
||||
// EffectiveDisposition resolves an omitted disposition from the declared
|
||||
// approval and detects inconsistent explicit decisions.
|
||||
func (d Decision) EffectiveDisposition() (DecisionDisposition, error) {
|
||||
switch d.Disposition {
|
||||
case "":
|
||||
if d.Approved {
|
||||
return DispositionApproved, nil
|
||||
}
|
||||
return DispositionRejected, nil
|
||||
case DispositionApproved, DispositionRejected, DispositionUnavailable:
|
||||
if d.Approved == (d.Disposition == DispositionApproved) {
|
||||
return d.Disposition, nil
|
||||
}
|
||||
return "", fmt.Errorf("contradictory approval and disposition %q for proposal %d", d.Disposition, d.ProposalIndex)
|
||||
default:
|
||||
return "", fmt.Errorf("invalid decision disposition %q for proposal %d", d.Disposition, d.ProposalIndex)
|
||||
}
|
||||
}
|
||||
|
||||
// DecisionDisposition separates normal editorial rejection from a candidate
|
||||
// excluded because its model operation could not provide a trustworthy decision.
|
||||
type DecisionDisposition string
|
||||
@@ -80,7 +99,10 @@ type Result struct {
|
||||
Operations []outcomes.Operation `json:"operations,omitempty"`
|
||||
}
|
||||
|
||||
// Validator is the deterministic runtime validator interface.
|
||||
// Validator evaluates one section's candidates. An instance may be called
|
||||
// concurrently across sections and may keep synchronized state. Request data
|
||||
// is borrowed for the call; inputs must be copied before modification or
|
||||
// retention. Request.Preview may populate the caller's pass-local cache.
|
||||
type Validator interface {
|
||||
Name() string
|
||||
Validate(ctx context.Context, req Request) (Result, error)
|
||||
|
||||
Reference in New Issue
Block a user