revert: remove cross-agent worker direction synchronization
This commit is contained in:
1 parent
7e633b2056
commit
76210b9933
9 files changed
+11
-425
No files matched your search
@@ -202,72 +202,3 @@ func TestIntentInterventionAcceptanceCanRetryAfterStateSettlement(t *testing.T)
|
||||
t.Fatalf("retry acceptance: activity=%+v duplicate=%v err=%v", activity, duplicate, err)
|
||||
}
|
||||
}
|
||||
|
||||
func acceptTestWorkerDirection(t *testing.T, store *ExplorationStore, intentID int64, requestID, message string) Activity {
|
||||
t.Helper()
|
||||
if claimed, err := store.ClaimIntent(intentID, "direction-test-worker"); err != nil || !claimed {
|
||||
t.Fatalf("claim direction intent: claimed=%v err=%v", claimed, err)
|
||||
}
|
||||
if _, err := store.ReserveIntentIntervention(intentID, requestID, message); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if changed, err := store.CompareAndSetIntentState(intentID, "running", "paused"); err != nil || !changed {
|
||||
t.Fatalf("pause direction intent: changed=%v err=%v", changed, err)
|
||||
}
|
||||
activity, duplicate, err := store.AcceptIntentIntervention(intentID, requestID, message)
|
||||
if err != nil || duplicate {
|
||||
t.Fatalf("accept direction: activity=%+v duplicate=%v err=%v", activity, duplicate, err)
|
||||
}
|
||||
return activity
|
||||
}
|
||||
|
||||
func TestLatestWorkerDirectionsKeepsLatestPerIntentAcrossStoreReopen(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v) - skipping", err)
|
||||
}
|
||||
defer d.Close()
|
||||
task, err := d.CreateTask("worker direction persistence", "keep latest directions", nil, 0, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteTask(task.ID) //nolint:errcheck
|
||||
store := d.Exploration(task.ExplorationID)
|
||||
firstIntent, err := store.AddIntent(map[string]any{"summary": "first route"}, 1, nil, "planner")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
secondIntent, err := store.AddIntent(map[string]any{"summary": "second route"}, 1, nil, "planner")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
acceptTestWorkerDirection(t, store, firstIntent, "direction-old", "先检查旧方向")
|
||||
secondActivity := acceptTestWorkerDirection(t, store, secondIntent, "direction-second", "保留第二条意图方向")
|
||||
latestActivity := acceptTestWorkerDirection(t, store, firstIntent, "direction-latest", "改为验证最新权限边界")
|
||||
|
||||
d2, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d2.Close()
|
||||
directions, err := d2.Exploration(task.ExplorationID).LatestWorkerDirections(10)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(directions) != 2 {
|
||||
t.Fatalf("directions=%+v, want one latest row per intent", directions)
|
||||
}
|
||||
byIntent := make(map[int64]WorkerDirection, len(directions))
|
||||
for _, direction := range directions {
|
||||
byIntent[direction.IntentID] = direction
|
||||
}
|
||||
if got := byIntent[firstIntent]; got.ActivityID != latestActivity.ID || got.RequestID != "direction-latest" ||
|
||||
got.Message != "改为验证最新权限边界" || got.IntentSummary != "first route" {
|
||||
t.Fatalf("latest first direction=%+v", got)
|
||||
}
|
||||
if got := byIntent[secondIntent]; got.ActivityID != secondActivity.ID || got.Message != "保留第二条意图方向" ||
|
||||
got.IntentSummary != "second route" {
|
||||
t.Fatalf("second direction=%+v", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user