Trust scores: per (agent, action_type) pair, stored in agent_trust
table. Auto-adjusts when human reacts to AI agent messages (approve
+0.05, reject -0.1). Scores clamped [0.0, 1.0]. MCP get_trust action
+ REST API /api/trust/{agent}. Web UI shows trust progress bars on
agent detail pages.
Claim semantics: only one in_progress reaction per message enforced.
First agent to claim wins, duplicates rejected with clear error.
State-change webhooks: StateChangeNotifier interface fires
workflow.state_changed events through existing webhook infrastructure
when reactions change a message's derived workflow state.
Channel thresholds: publish_threshold and approve_threshold fields
on channels for configuring autonomy gates.
Migration 014_trust_claims.sql. 17 new test cases across trust
model + store.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
33 lines
700 B
Go
33 lines
700 B
Go
package trust
|
|
|
|
import "testing"
|
|
|
|
func TestClampScore(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input float64
|
|
want float64
|
|
}{
|
|
{"zero", 0.0, 0.0},
|
|
{"one", 1.0, 1.0},
|
|
{"mid", 0.5, 0.5},
|
|
{"below zero", -0.1, MinScore},
|
|
{"far below zero", -10.0, MinScore},
|
|
{"above one", 1.1, MaxScore},
|
|
{"far above one", 100.0, MaxScore},
|
|
{"small positive", 0.001, 0.001},
|
|
{"near max", 0.999, 0.999},
|
|
{"exactly min", MinScore, MinScore},
|
|
{"exactly max", MaxScore, MaxScore},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := ClampScore(tt.input)
|
|
if got != tt.want {
|
|
t.Errorf("ClampScore(%f) = %f, want %f", tt.input, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|