From 26207d93ef8028268e655b620517fdf492b7d70f Mon Sep 17 00:00:00 2001 From: Mikhail Date: Sat, 29 Aug 2026 11:16:07 +0300 Subject: [PATCH] GEN2-016: add intelligence strategy and benchmark evidence --- contracts/capability/intelligence.go | 41 +++++++++++++++++++ contracts/self/benchmark.go | 25 +++++++++++ dev/ACTIVE_TASK.json | 2 +- .../capability/domain/intelligence_test.go | 15 +++++++ modules/self/domain/benchmark_test.go | 17 ++++++++ modules/self/domain/self.go | 10 +++-- modules/self/domain/self_test.go | 19 ++++++++- 7 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 contracts/capability/intelligence.go create mode 100644 contracts/self/benchmark.go create mode 100644 modules/capability/domain/intelligence_test.go create mode 100644 modules/self/domain/benchmark_test.go diff --git a/contracts/capability/intelligence.go b/contracts/capability/intelligence.go new file mode 100644 index 0000000..8eab948 --- /dev/null +++ b/contracts/capability/intelligence.go @@ -0,0 +1,41 @@ +package capability + +type IntelligencePath string + +const ( + PathRule IntelligencePath = "RULE" + PathReflex IntelligencePath = "REFLEX" + PathSkill IntelligencePath = "SKILL" + PathSmallLocal IntelligencePath = "SMALL_LOCAL" + PathStrongLocal IntelligencePath = "STRONG_LOCAL" + PathExternal IntelligencePath = "EXTERNAL" + PathResearch IntelligencePath = "RESEARCH" + PathTeam IntelligencePath = "TEAM" +) + +type StrategyRequest struct { + RequiredQuality int64 + PreferLowLatency bool + CostBudgetMicros int64 + RiskClass string + FreshnessRequired bool + CostOfError int64 +} +type StrategyDecision struct { + Path IntelligencePath + Reason string + Escalate bool +} + +func (r StrategyRequest) Select() StrategyDecision { + if r.RiskClass == "HIGH" || r.CostOfError >= 800 { + return StrategyDecision{Path: PathStrongLocal, Reason: "high consequence requires deeper reasoning", Escalate: true} + } + if r.RequiredQuality <= 500 && r.CostBudgetMicros > 0 { + return StrategyDecision{Path: PathRule, Reason: "bounded low-risk path"} + } + if r.PreferLowLatency { + return StrategyDecision{Path: PathReflex, Reason: "latency preference with later escalation"} + } + return StrategyDecision{Path: PathSkill, Reason: "validated reusable strategy"} +} diff --git a/contracts/self/benchmark.go b/contracts/self/benchmark.go new file mode 100644 index 0000000..d6f5efa --- /dev/null +++ b/contracts/self/benchmark.go @@ -0,0 +1,25 @@ +package self + +type BenchmarkCaseRef string +type PersonalBenchmark struct { + ID string + PrincipalID string + ApprovedCaseRefs []BenchmarkCaseRef + GoalProfile []string + PreferenceEvidenceRefs []SemanticReference + RecordedAt int64 +} +type BenchmarkEvaluation struct { + CaseRef BenchmarkCaseRef + Path string + QualityMillis int64 + ReliabilityMillis int64 + LatencyMillis int64 + CostMicros int64 + CorrectionCount int64 + EvidenceRefs []SemanticReference +} + +func (e BenchmarkEvaluation) Valid() bool { + return e.CaseRef != "" && len(e.EvidenceRefs) > 0 && e.QualityMillis >= 0 && e.ReliabilityMillis >= 0 && e.CorrectionCount >= 0 +} diff --git a/dev/ACTIVE_TASK.json b/dev/ACTIVE_TASK.json index 8256381..ac473f6 100644 --- a/dev/ACTIVE_TASK.json +++ b/dev/ACTIVE_TASK.json @@ -1 +1 @@ -{"task_file":"dev/tasks/GEN2-015-add-evidence-backed-self-foundation-and-learning-ledger.json","task_id":"GEN2-015","task_revision":1} \ No newline at end of file +{"task_file":"dev/tasks/GEN2-016-intelligence-strategy-resource-cost-policy-and-personal-benchmark.json","task_id":"GEN2-016","task_revision":1} \ No newline at end of file diff --git a/modules/capability/domain/intelligence_test.go b/modules/capability/domain/intelligence_test.go new file mode 100644 index 0000000..2847aa1 --- /dev/null +++ b/modules/capability/domain/intelligence_test.go @@ -0,0 +1,15 @@ +package domain_test + +import ( + "git.cin.su/m/Assistant/contracts/capability" + "testing" +) + +func TestStrategyUsesRiskAndCostSignals(t *testing.T) { + if got := (capability.StrategyRequest{RequiredQuality: 400, CostBudgetMicros: 10}).Select().Path; got != capability.PathRule { + t.Fatal(got) + } + if got := (capability.StrategyRequest{RiskClass: "HIGH", CostOfError: 900}).Select(); got.Path != capability.PathStrongLocal || !got.Escalate { + t.Fatalf("%#v", got) + } +} diff --git a/modules/self/domain/benchmark_test.go b/modules/self/domain/benchmark_test.go new file mode 100644 index 0000000..b638437 --- /dev/null +++ b/modules/self/domain/benchmark_test.go @@ -0,0 +1,17 @@ +package domain_test + +import ( + selfcontract "git.cin.su/m/Assistant/contracts/self" + "testing" +) + +func TestBenchmarkRequiresEvidenceAndDoesNotPromoteAlone(t *testing.T) { + e := selfcontract.BenchmarkEvaluation{CaseRef: "case", QualityMillis: 900} + if e.Valid() { + t.Fatal("benchmark without evidence accepted") + } + e.EvidenceRefs = []selfcontract.SemanticReference{{OwnerNamespace: "epistemics", SemanticKind: "evaluation", StableID: "e"}} + if !e.Valid() { + t.Fatal("evidence-backed evaluation rejected") + } +} diff --git a/modules/self/domain/self.go b/modules/self/domain/self.go index cdb5f4c..fe32524 100644 --- a/modules/self/domain/self.go +++ b/modules/self/domain/self.go @@ -1,4 +1,8 @@ package domain -import("git.cin.su/m/Assistant/contracts/self") -func ValidateCompetence(v self.CompetenceAssessment) error{return v.Validate()} -func ValidateLearning(v self.LearningLedgerEntry) error{return v.Validate()} + +import ( + "git.cin.su/m/Assistant/contracts/self" +) + +func ValidateCompetence(v self.CompetenceAssessment) error { return v.Validate() } +func ValidateLearning(v self.LearningLedgerEntry) error { return v.Validate() } diff --git a/modules/self/domain/self_test.go b/modules/self/domain/self_test.go index a377135..b18175e 100644 --- a/modules/self/domain/self_test.go +++ b/modules/self/domain/self_test.go @@ -1,3 +1,18 @@ package domain_test -import("testing"; selfcontract "git.cin.su/m/Assistant/contracts/self"; "git.cin.su/m/Assistant/modules/self/domain") -func TestCompetenceCannotBeSelfDeclaredWithoutEvidence(t *testing.T){v:=selfcontract.CompetenceAssessment{ID:"a",PrincipalID:"p",SubjectRef:selfcontract.SemanticReference{OwnerNamespace:"capability",SemanticKind:"skill",StableID:"s"},Revision:1,ConfidenceMillis:1000,AssessedAt:1};if domain.ValidateCompetence(v)==nil{t.Fatal("unsupported competence accepted")};v.EvidenceRefs=[]selfcontract.SemanticReference{{OwnerNamespace:"epistemics",SemanticKind:"evaluation",StableID:"e"}};if err:=domain.ValidateCompetence(v);err!=nil{t.Fatal(err)}} + +import ( + selfcontract "git.cin.su/m/Assistant/contracts/self" + "git.cin.su/m/Assistant/modules/self/domain" + "testing" +) + +func TestCompetenceCannotBeSelfDeclaredWithoutEvidence(t *testing.T) { + v := selfcontract.CompetenceAssessment{ID: "a", PrincipalID: "p", SubjectRef: selfcontract.SemanticReference{OwnerNamespace: "capability", SemanticKind: "skill", StableID: "s"}, Revision: 1, ConfidenceMillis: 1000, AssessedAt: 1} + if domain.ValidateCompetence(v) == nil { + t.Fatal("unsupported competence accepted") + } + v.EvidenceRefs = []selfcontract.SemanticReference{{OwnerNamespace: "epistemics", SemanticKind: "evaluation", StableID: "e"}} + if err := domain.ValidateCompetence(v); err != nil { + t.Fatal(err) + } +}