paired: repair safe owner workspace branch mismatches

This commit is contained in:
ejclaw
2026-04-11 08:45:47 +09:00
parent 2b8f55deb6
commit fe9d265c66
5 changed files with 269 additions and 5 deletions

View File

@@ -29,6 +29,7 @@ vi.mock('./db.js', () => {
});
vi.mock('./paired-workspace-manager.js', () => ({
isOwnerWorkspaceRepairNeededError: vi.fn(() => false),
markPairedTaskReviewReady: vi.fn(),
prepareReviewerWorkspaceForExecution: vi.fn(),
provisionOwnerWorkspaceForPairedTask: vi.fn(),
@@ -448,6 +449,34 @@ describe('paired execution context', () => {
);
});
it('blocks owner execution when the owner workspace needs branch repair', () => {
const repairError = new Error(
'BLOCKED\nOwner workspace needs repair.\nOwner workspace branch mismatch: `codex/owner/paired-room-sync` -> expected `codex/owner/paired-room`.',
);
vi.mocked(
pairedWorkspaceManager.provisionOwnerWorkspaceForPairedTask,
).mockImplementation(() => {
throw repairError;
});
vi.mocked(
pairedWorkspaceManager.isOwnerWorkspaceRepairNeededError,
).mockReturnValue(true);
const result = preparePairedExecutionContext({
group,
chatJid: 'dc:test',
runId: 'run-owner-repair-needed',
roomRoleContext: ownerContext,
hasHumanMessage: true,
});
expect(result?.blockMessage).toContain('Owner workspace needs repair.');
expect(result?.blockMessage).toContain(
'`codex/owner/paired-room-sync` -> expected `codex/owner/paired-room`',
);
expect(result?.envOverrides.EJCLAW_WORK_DIR).toBeUndefined();
});
it('blocks reviewer execution when an in-review snapshot became stale', () => {
vi.mocked(db.getLatestOpenPairedTaskForChat).mockReturnValue({
id: 'task-1',