fix: harden paired runtime turn coordination

This commit is contained in:
ejclaw
2026-04-09 13:52:42 +09:00
parent e7a7b538b2
commit 0f994ab2ce
27 changed files with 2108 additions and 295 deletions

View File

@@ -11,6 +11,7 @@ vi.mock('./config.js', async () => {
});
import {
matchesExpectedPairedFollowUpIntent,
resolveFollowUpDispatch,
resolveExecutionTarget,
resolveNextTurnAction,
@@ -79,6 +80,40 @@ describe('message-runtime-rules', () => {
).toEqual({ kind: 'none' });
});
it('rejects stale reviewer and finalize follow-ups once the latest persisted turn already closed that handoff', () => {
expect(
matchesExpectedPairedFollowUpIntent({
taskStatus: 'review_ready',
lastTurnOutputRole: 'reviewer',
intentKind: 'reviewer-turn',
}),
).toBe(false);
expect(
matchesExpectedPairedFollowUpIntent({
taskStatus: 'merge_ready',
lastTurnOutputRole: 'owner',
intentKind: 'finalize-owner-turn',
}),
).toBe(false);
});
it('keeps owner follow-ups schedulable when reviewer or arbiter is still the latest persisted turn', () => {
expect(
matchesExpectedPairedFollowUpIntent({
taskStatus: 'active',
lastTurnOutputRole: 'reviewer',
intentKind: 'owner-follow-up',
}),
).toBe(true);
expect(
matchesExpectedPairedFollowUpIntent({
taskStatus: 'active',
lastTurnOutputRole: 'arbiter',
intentKind: 'owner-follow-up',
}),
).toBe(true);
});
it('maps active tasks with reviewer output to an owner follow-up', () => {
expect(
resolveNextTurnAction({