fix(volition): rest an action on the belief about that action

An intention's supporting beliefs came from a text search on the target,
and ties on rank and confidence had no order, so a verification miss could
revise an unrelated belief about the same service. Beliefs that mention the
proposed action now come first, and belief search breaks ties by id.

The incident scenario asserts the first support is the belief about
restarting, and waits for the blocked intention and the procedural memory
instead of reading them once.
This commit is contained in:
Andy Dixon
2026-10-04 19:46:55 +01:00
parent f609fae746
commit edcc6580b6
3 changed files with 24 additions and 10 deletions
+1 -1
View File
@@ -872,7 +872,7 @@ func (s *Store) Search(ctx context.Context, mind ids.ID, text string, limit int)
}
q := strings.Join(toks, " | ")
rows, err := s.db.Query(ctx, `SELECT `+cols+` FROM beliefs b WHERE b.mind_id=$1 AND b.status NOT IN ('superseded') AND b.search @@ to_tsquery('english', $2)
ORDER BY ts_rank_cd(b.search, to_tsquery('english', $2)) DESC, b.confidence DESC LIMIT $3`, mind, q, limit)
ORDER BY ts_rank_cd(b.search, to_tsquery('english', $2)) DESC, b.confidence DESC, b.id LIMIT $3`, mind, q, limit)
if err != nil {
return nil, err
}