Fix owner context loss after finalize; green the test suite
Owner continuity: - Seed a freshly created owner task with the previous task's latest owner final on a cold start after the previous task already closed, so a user reply to a finalized TASK_DONE no longer produces a "no context" answer. Activated for this deployment via PAIRED_CARRY_FORWARD_LATEST_OWNER_FINAL (.env); carried text is injected as clearly-marked background only. - Skip intermediate STEP_DONE outputs when picking the carry-forward anchor. Single-mode routing: - enforceRoomModeOnLease strips a stale reviewer/arbiter lease from a room switched back to single, preventing single-mode messages from stalling in the paired path on a stuck execution lease. Session auth / credentials: - Pre-sync Claude credentials into each session dir before the agent spawns. - Honor CLAUDE_CREDENTIALS_PATH in setup/login.ts (per-service isolation). - Add a relogin-required gate so a permanently logged-out claude-code room asks the user to re-login instead of spawning a doomed agent. Other: - Arbiter verdicts written in the user's language (verdict keyword stays EN). - status-dashboard chatName field; runtime-inventory credential path resolver. Tests (make suite fully green: 1595 pass / 3 skip): - service-routing: default owner is now the claude service and reviewer is codex-review; update the 7 failover/default expectations accordingly. - migrate-room-registrations: owner inferred as claude-code (configured OWNER_AGENT_TYPE) for a dual legacy room; reviewer becomes codex. - register: mock paired-workspace provisioning + reload signal (registration now provisions a workspace and hot-reloads); assert RELOADED status. - paired-execution-context: force a claude-code reviewer to exercise the Claude read-only branch regardless of the deployment default. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -161,4 +161,89 @@ describe('paired execution carry-forward attachments', () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('carries context forward on a cold start after the previous task already closed', () => {
|
||||
vi.clearAllMocks();
|
||||
const previousTask = buildTask({
|
||||
id: 'task-previous',
|
||||
status: 'completed',
|
||||
completion_reason: 'done',
|
||||
});
|
||||
// No open task exists -> cold start path.
|
||||
vi.mocked(db.getLatestOpenPairedTaskForChat).mockReturnValue(undefined);
|
||||
vi.mocked(db.getLatestPairedTaskForChat).mockReturnValue(previousTask);
|
||||
vi.mocked(db.getPairedTurnOutputs).mockReturnValue([
|
||||
{
|
||||
id: 1,
|
||||
task_id: previousTask.id,
|
||||
turn_number: 1,
|
||||
role: 'owner',
|
||||
output_text:
|
||||
'TASK_DONE\n사용자 액션 아이템: 1. 재배포 2. 서버 업데이트',
|
||||
created_at: '2026-03-28T00:01:00.000Z',
|
||||
},
|
||||
]);
|
||||
|
||||
const resolved = resolveOwnerTaskForHumanMessage({
|
||||
group,
|
||||
chatJid: 'dc:test',
|
||||
roomRoleContext: ownerContext,
|
||||
// no existingTask -> resolves via getLatestOpenPairedTaskForChat (none)
|
||||
});
|
||||
|
||||
expect(resolved.supersededTask).toBeNull();
|
||||
expect(db.insertPairedTurnOutput).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
0,
|
||||
'owner',
|
||||
expect.stringContaining(
|
||||
'TASK_DONE\n사용자 액션 아이템: 1. 재배포 2. 서버 업데이트',
|
||||
),
|
||||
expect.objectContaining({ createdAt: '2026-03-28T00:01:00.000Z' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('carries the last final owner output, skipping an intermediate STEP_DONE', () => {
|
||||
vi.clearAllMocks();
|
||||
const previousTask = buildTask({
|
||||
id: 'task-arbiter',
|
||||
status: 'completed',
|
||||
completion_reason: 'arbiter_escalated',
|
||||
});
|
||||
vi.mocked(db.getLatestOpenPairedTaskForChat).mockReturnValue(undefined);
|
||||
vi.mocked(db.getLatestPairedTaskForChat).mockReturnValue(previousTask);
|
||||
vi.mocked(db.getPairedTurnOutputs).mockReturnValue([
|
||||
{
|
||||
id: 1,
|
||||
task_id: previousTask.id,
|
||||
turn_number: 1,
|
||||
role: 'owner',
|
||||
output_text:
|
||||
'TASK_DONE\n사용자 액션 아이템: 1. 재배포 2. 서버 업데이트',
|
||||
created_at: '2026-03-28T00:01:00.000Z',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
task_id: previousTask.id,
|
||||
turn_number: 3,
|
||||
role: 'owner',
|
||||
output_text: 'STEP_DONE\nexception 경로 버그를 고쳤습니다.',
|
||||
created_at: '2026-03-28T00:03:00.000Z',
|
||||
},
|
||||
]);
|
||||
|
||||
resolveOwnerTaskForHumanMessage({
|
||||
group,
|
||||
chatJid: 'dc:test',
|
||||
roomRoleContext: ownerContext,
|
||||
});
|
||||
|
||||
expect(db.insertPairedTurnOutput).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
0,
|
||||
'owner',
|
||||
expect.stringContaining('사용자 액션 아이템'),
|
||||
expect.objectContaining({ createdAt: '2026-03-28T00:01:00.000Z' }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user