fix(cognition): decisions and cycle output no longer depend on map order
Formation summed its terms by ranging over a map, so the score could differ in the last bit between runs of the same state; the volition hook assessed commitments, metacognition raised repeated-failure candidates and the forensic explanation listed commitments in map iteration order, so the events a cycle emits and an explanation's order varied between runs. Each now iterates in sorted order, as replay determinism (PLAN §1 R3) requires.
This commit is contained in:
@@ -381,7 +381,12 @@ func (s *Service) Explain(ctx context.Context, mind ids.ID, ref Ref) (Explanatio
|
||||
x.Resolution = append(x.Resolution, d.Kind+" ("+d.Outcome+"): "+d.Rationale)
|
||||
}
|
||||
}
|
||||
cids := make([]ids.ID, 0, len(commitmentIDs))
|
||||
for id := range commitmentIDs {
|
||||
cids = append(cids, id)
|
||||
}
|
||||
sort.Slice(cids, func(i, j int) bool { return cids[i] < cids[j] })
|
||||
for _, id := range cids {
|
||||
if c, err := s.Volition.GetCommitment(ctx, nil, mind, id); err == nil {
|
||||
x.Commitments = append(x.Commitments, c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user