diff --git a/docs/releases/v0.9.11.md b/docs/releases/v0.9.11.md new file mode 100644 index 0000000..012cbda --- /dev/null +++ b/docs/releases/v0.9.11.md @@ -0,0 +1,7 @@ +An issue that changed while an actor slept rides with the wake, not in a second turn. + +- **A tick of an actor carries the issues that changed.** An actor is suspended between wakes and reads the open issues only once it runs. The wake the core ordered read the rooms before its turn and the issues after it, so an issue that had changed while the actor slept was found when the turn was over and started a second turn a few seconds later, with the whole prompt and tool list again. The ordered wake now reads the issues with the rooms, before its turn: the change is a fact of that turn. + +Upgrade: chart `oci://ghcr.io/triageagent-dev/charts/tria-spot` 0.9.11, image `ghcr.io/triageagent-dev/spot:0.9.11`. + +**Full Changelog**: https://github.com/triageagent-dev/spot/compare/v0.9.10...v0.9.11 diff --git a/internal/supervisor/supervisor.go b/internal/supervisor/supervisor.go index 2e54986..dbe8066 100644 --- a/internal/supervisor/supervisor.go +++ b/internal/supervisor/supervisor.go @@ -417,16 +417,17 @@ func (s *Supervisor) primeRooms(ctx context.Context) { s.hold(s.pollRooms(pctx, cold...)) } -// withRooms reads the rooms for a wake the core ordered from an actor and adds -// what it finds to that wake. The core's request may have come with no usable -// token, which the actor answers with a plain tick that reads nothing of it: -// what was said in the rooms is then a fact of this wake, not of a wake that may -// never come. The wake keeps its reason and the words it was ordered with. +// withRooms reads the rooms and the open issues for a wake the core ordered +// from an actor and adds what it finds to that wake. The core's request may +// have come with no usable token, which the actor answers with a plain tick +// that reads nothing of it: what was said in the rooms is then a fact of this +// wake, not of a wake that may never come. An issue that changed while the +// actor was suspended is a fact of this wake too: read only after the turn, it +// started a second turn a few seconds later, with the whole prompt again. The +// wake keeps its reason and the words it was ordered with. func (s *Supervisor) withRooms(ctx context.Context, p *pending) { - pctx, cancel := context.WithTimeout(ctx, 30*time.Second) - defer cancel() now := s.now() - for _, e := range s.pollRooms(pctx, BusRoom) { + for _, e := range s.poll(ctx) { p.facts = append(p.facts, e.Fact) p.edges = append(p.edges, heldEdge{Edge: e, at: now}) if e.Human { diff --git a/internal/supervisor/supervisor_test.go b/internal/supervisor/supervisor_test.go index 650fcb4..7dbd7b7 100644 --- a/internal/supervisor/supervisor_test.go +++ b/internal/supervisor/supervisor_test.go @@ -2405,6 +2405,36 @@ func TestATickOfAnActorReadsTheRooms(t *testing.T) { } } +// An issue that changed while the actor was suspended rides with the tick that +// wakes it: one turn, not a tick turn and then a second turn for the change. +func TestATickOfAnActorCarriesTheIssueThatChanged(t *testing.T) { + trig := newFakeTrigger(true) + h := newHarness(t, func(c *config.Config) { + c.Runtime = config.RuntimeSubstrate + c.PollInterval = 5 * time.Millisecond + }) + h.trig = trig + h.core.setIssues(issue("a", "warning", 0)) + h.set("next", `{"after":"2h"}`) + h.start() + trig.say(triggers.Pending{Order: &triggers.Order{Reason: "tick"}}) + h.waitIdle(1) + h.stop() + + h.core.setIssues(issue("a", "critical", 0)) + h.start() + defer h.stop() + trig.say(triggers.Pending{Order: &triggers.Order{Reason: "tick"}}) + h.waitIdle(2) + if in := h.file("stdin", 2); !strings.Contains(in, "Wake reason: tick") || !strings.Contains(in, `severity "warning" -> "critical"`) { + t.Fatalf("the tick must carry the change:\n%s", in) + } + time.Sleep(100 * time.Millisecond) + if h.turns() != 2 { + t.Fatalf("the change started a turn of its own: %d turns", h.turns()) + } +} + // What a wake was ordered for is not lost to what was said in a room: the // promise is still the reason, and the line in the room comes with it. func TestAPromisedWakeKeepsItsWordsWhenARoomHasNews(t *testing.T) {