Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36272b9036 |
@@ -0,0 +1,24 @@
|
|||||||
|
package work
|
||||||
|
|
||||||
|
type ConsequenceAssessment struct {
|
||||||
|
ID string
|
||||||
|
TargetRefs []string
|
||||||
|
Impact int64
|
||||||
|
Reversibility int64
|
||||||
|
Uncertainty int64
|
||||||
|
Scope int64
|
||||||
|
Recoverability int64
|
||||||
|
CostOfError int64
|
||||||
|
ExpectedConsequences []string
|
||||||
|
MitigationOptions []string
|
||||||
|
RequiresDryRun bool
|
||||||
|
RequiresBackup bool
|
||||||
|
RecommendedConfirmation string
|
||||||
|
OwnerAccepted bool
|
||||||
|
EvidenceRefs []EvidenceRef
|
||||||
|
RecordedAtUnixMillis int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a ConsequenceAssessment) Valid() bool {
|
||||||
|
return a.ID != "" && len(a.TargetRefs) > 0 && a.Impact >= 0 && a.Impact <= 1000 && a.Reversibility >= 0 && a.Reversibility <= 1000 && a.Uncertainty >= 0 && a.Uncertainty <= 1000 && a.Recoverability >= 0 && a.Recoverability <= 1000 && a.RecordedAtUnixMillis > 0
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
{"task_file":"dev/tasks/GEN2-018-add-perspective-and-dynamic-specialist-team-semantics-on-existing-work-g.json","task_id":"GEN2-018","task_revision":1}
|
{"task_file":"dev/tasks/GEN2-019-add-consequence-risk-assessment-without-artificial-capability-blacklist.json","task_id":"GEN2-019","task_revision":1}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import "git.cin.su/m/Assistant/contracts/work"
|
||||||
|
|
||||||
|
func AssessConsequences(id string, target string, impact, reversibility, uncertainty, recoverability, cost int64, at int64) work.ConsequenceAssessment {
|
||||||
|
a := work.ConsequenceAssessment{ID: id, TargetRefs: []string{target}, Impact: impact, Reversibility: reversibility, Uncertainty: uncertainty, Recoverability: recoverability, CostOfError: cost, RecordedAtUnixMillis: at}
|
||||||
|
a.RequiresDryRun = impact >= 700 || reversibility >= 700
|
||||||
|
a.RequiresBackup = reversibility >= 500
|
||||||
|
a.RecommendedConfirmation = "STANDARD"
|
||||||
|
if uncertainty*cost > 500000 {
|
||||||
|
a.RecommendedConfirmation = "EXPLICIT_OWNER_CONFIRMATION"
|
||||||
|
}
|
||||||
|
return a
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package domain_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.cin.su/m/Assistant/modules/work/domain"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestConsequenceAdvisesMitigationWithoutCapabilityBlacklist(t *testing.T) {
|
||||||
|
a := domain.AssessConsequences("a", "database:a", 800, 800, 900, 300, 900, 1)
|
||||||
|
if !a.Valid() || !a.RequiresDryRun || !a.RequiresBackup || a.RecommendedConfirmation != "EXPLICIT_OWNER_CONFIRMATION" {
|
||||||
|
t.Fatalf("%#v", a)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user