diff --git a/contracts/work/self_evolution.go b/contracts/work/self_evolution.go new file mode 100644 index 0000000..ec73a95 --- /dev/null +++ b/contracts/work/self_evolution.go @@ -0,0 +1,36 @@ +package work + +type EvolutionChangeLevel string + +const ( + EvolutionKnowledge EvolutionChangeLevel = "KNOWLEDGE" + EvolutionBehavior EvolutionChangeLevel = "BEHAVIOR" + EvolutionCapability EvolutionChangeLevel = "CAPABILITY" + EvolutionCore EvolutionChangeLevel = "CORE" +) + +type EvolutionCandidate struct { + ID string + ProposalRef string + ChangeLevel EvolutionChangeLevel + CreatorIdentity string + BaseVersionRef string + CandidateVersionRef string + MustNotWorsen []string + SandboxEvidenceRefs []EvidenceRef + BenchmarkEvidenceRefs []EvidenceRef + RollbackRef string + State string +} +type EvolutionEvaluation struct { + CandidateRef string + EvaluatorIdentity string + Approved bool + EvidenceRefs []EvidenceRef + MustNotWorsenPassed bool + RecordedAtUnixMillis int64 +} + +func (e EvolutionEvaluation) ValidFor(c EvolutionCandidate) bool { + return e.CandidateRef == c.ID && e.EvaluatorIdentity != "" && e.EvaluatorIdentity != c.CreatorIdentity && e.Approved && e.MustNotWorsenPassed && len(e.EvidenceRefs) > 0 && e.RecordedAtUnixMillis > 0 +} diff --git a/dev/ACTIVE_TASK.json b/dev/ACTIVE_TASK.json index 04d3594..ccbbfd5 100644 --- a/dev/ACTIVE_TASK.json +++ b/dev/ACTIVE_TASK.json @@ -1 +1 @@ -{"task_file":"dev/tasks/GEN2-021-add-independent-supervisor-lifeboat-for-release-health-and-rollback.json","task_id":"GEN2-021","task_revision":1} \ No newline at end of file +{"task_file":"dev/tasks/GEN2-022-wire-governed-self-evolution-loop-using-existing-development-gates.json","task_id":"GEN2-022","task_revision":1} \ No newline at end of file diff --git a/modules/work/domain/self_evolution.go b/modules/work/domain/self_evolution.go new file mode 100644 index 0000000..072bf69 --- /dev/null +++ b/modules/work/domain/self_evolution.go @@ -0,0 +1,7 @@ +package domain + +import "git.cin.su/m/Assistant/contracts/work" + +func PromoteEvolution(c work.EvolutionCandidate, e work.EvolutionEvaluation) bool { + return e.ValidFor(c) && c.ProposalRef != "" && c.RollbackRef != "" && len(c.SandboxEvidenceRefs) > 0 && len(c.BenchmarkEvidenceRefs) > 0 +} diff --git a/modules/work/domain/self_evolution_test.go b/modules/work/domain/self_evolution_test.go new file mode 100644 index 0000000..84b474e --- /dev/null +++ b/modules/work/domain/self_evolution_test.go @@ -0,0 +1,19 @@ +package domain_test + +import ( + "git.cin.su/m/Assistant/contracts/work" + "git.cin.su/m/Assistant/modules/work/domain" + "testing" +) + +func TestEvolutionRequiresIndependentEvaluatorAndRollbackEvidence(t *testing.T) { + c := work.EvolutionCandidate{ID: "c", ProposalRef: "p", ChangeLevel: work.EvolutionBehavior, CreatorIdentity: "creator", RollbackRef: "rollback", SandboxEvidenceRefs: []work.EvidenceRef{"sandbox"}, BenchmarkEvidenceRefs: []work.EvidenceRef{"benchmark"}} + e := work.EvolutionEvaluation{CandidateRef: "c", EvaluatorIdentity: "creator", Approved: true, MustNotWorsenPassed: true, EvidenceRefs: []work.EvidenceRef{"eval"}, RecordedAtUnixMillis: 1} + if domain.PromoteEvolution(c, e) { + t.Fatal("creator promoted own change") + } + e.EvaluatorIdentity = "independent" + if !domain.PromoteEvolution(c, e) { + t.Fatal("independently evaluated candidate rejected") + } +}