support milestone and thrash rotation signals

This commit is contained in:
kami
2026-07-26 20:36:17 +04:00
parent b4d9621d89
commit 4364dff9c2
3 changed files with 22 additions and 2 deletions
+8 -2
View File
@@ -161,8 +161,14 @@ func (c *Coordinator) rotate(ctx context.Context, hard float64) {
if err != nil {
continue
}
reason := "threshold"
if signal, ok := a.(herdr.RotationSignal); ok {
if r, signalErr := signal.RotationSignal(ctx, session); signalErr == nil && r != "" {
reason = r
}
}
occupancy, err := a.Occupancy(session)
if err != nil || occupancy < hard {
if err != nil || (occupancy < hard && reason == "threshold") {
continue
}
if boundary, ok := a.(herdr.TurnBoundary); ok {
@@ -178,7 +184,7 @@ func (c *Coordinator) rotate(ctx context.Context, hard float64) {
if ref == "" {
continue
}
b, _ := json.Marshal(map[string]string{"handoff_ref": ref, "reason": "threshold"})
b, _ := json.Marshal(map[string]string{"handoff_ref": ref, "reason": reason})
e := domain.Event{ID: domain.NewID(), Type: "TaskReleased", TaskID: taskID, Version: task.Version + 1, Payload: b}
if c.Store.Append(e) == nil {
c.mu.Lock()