93 lines
2.7 KiB
Go
93 lines
2.7 KiB
Go
package self
|
|
|
|
import "fmt"
|
|
|
|
type AssessmentID string
|
|
type LearningLedgerEntryID string
|
|
type AssessmentState string
|
|
|
|
const (
|
|
AssessmentCandidate AssessmentState = "CANDIDATE"
|
|
AssessmentConfirmed AssessmentState = "CONFIRMED"
|
|
AssessmentMonitoring AssessmentState = "MONITORING"
|
|
AssessmentResolved AssessmentState = "RESOLVED"
|
|
)
|
|
|
|
type CompetenceAssessment struct {
|
|
ID AssessmentID
|
|
PrincipalID string
|
|
SubjectRef SemanticReference
|
|
Revision uint64
|
|
ContextMatcher []string
|
|
QualityMillis int64
|
|
ReliabilityMillis int64
|
|
ConfidenceMillis int64
|
|
EvidenceRefs []SemanticReference
|
|
LastValidatedAt int64
|
|
AssessedAt int64
|
|
SupersedesRef *SemanticReference
|
|
}
|
|
type WeaknessPattern struct {
|
|
ID AssessmentID
|
|
PrincipalID string
|
|
Revision uint64
|
|
PatternKey string
|
|
ContextMatcher []string
|
|
FailureMode string
|
|
DetectionEvidenceRefs []SemanticReference
|
|
State AssessmentState
|
|
RecordedAt int64
|
|
}
|
|
type DependencyAssessment struct {
|
|
ID AssessmentID
|
|
SubjectRef SemanticReference
|
|
DependencyRef SemanticReference
|
|
ImpactClass string
|
|
CurrentEffect string
|
|
EvidenceRefs []SemanticReference
|
|
AssessedAt int64
|
|
}
|
|
type ImprovementNeed struct {
|
|
ID AssessmentID
|
|
PrincipalID string
|
|
SubjectRef SemanticReference
|
|
ProblemSummary string
|
|
EvidenceRefs []SemanticReference
|
|
ExpectedBenefit string
|
|
Priority int
|
|
State string
|
|
CreatedAt int64
|
|
}
|
|
type LearningLedgerEntry struct {
|
|
ID LearningLedgerEntryID
|
|
PrincipalID string
|
|
ImprovementNeedRef *SemanticReference
|
|
ObservedProblem string
|
|
EvidenceRefs []SemanticReference
|
|
Diagnosis string
|
|
Hypothesis string
|
|
ProposedChangeRef SemanticReference
|
|
ExpectedImprovement string
|
|
ActualEvaluationRefs []SemanticReference
|
|
DevelopmentGateRef *SemanticReference
|
|
BeforeVersionRefs []SemanticReference
|
|
AfterVersionRefs []SemanticReference
|
|
Decision string
|
|
SideEffects []string
|
|
RollbackRef *SemanticReference
|
|
RecordedAt int64
|
|
}
|
|
|
|
func (a CompetenceAssessment) Validate() error {
|
|
if a.ID == "" || a.PrincipalID == "" || !a.SubjectRef.Valid() || a.Revision < 1 || a.ConfidenceMillis < 0 || a.ConfidenceMillis > 1000 || len(a.EvidenceRefs) == 0 || a.AssessedAt < 1 {
|
|
return fmt.Errorf("competence requires evidence")
|
|
}
|
|
return nil
|
|
}
|
|
func (l LearningLedgerEntry) Validate() error {
|
|
if l.ID == "" || l.PrincipalID == "" || l.ObservedProblem == "" || len(l.EvidenceRefs) == 0 || l.Decision == "" || l.RecordedAt < 1 {
|
|
return fmt.Errorf("learning ledger entry is incomplete")
|
|
}
|
|
return nil
|
|
}
|