feat: implement PI core chat timeline
This commit is contained in:
1 parent
54d8bb2e4a
commit
612135f911
40 files changed
+3881
-119
No files matched your search
@@ -93,6 +93,83 @@ describe('Pi session registry', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('serializes first bindings for different Conversations in one project', async () => {
|
||||
const projectPath = await mkdtemp(path.join(tmpdir(), 'makelore-pi-registry-concurrent-'));
|
||||
roots.push(projectPath);
|
||||
const projectStore = createCodingProjectStore(createMemoryCodingProjectStorage(), {
|
||||
createId: () => 'project-concurrent',
|
||||
now: () => NOW,
|
||||
});
|
||||
await createLocalCodingProject({ projectPath, now: NOW }, projectStore);
|
||||
await createCodingProjectAgent(projectPath, {
|
||||
id: 'agent-a',
|
||||
avatarId: 'avatar-01',
|
||||
roleName: 'Implementer',
|
||||
name: 'Agent A',
|
||||
model: { accountId: 'account-a', modelId: 'model-a', thinkingLevel: 'medium' },
|
||||
modelResolution: 'resolved',
|
||||
responsibility: { mission: 'Implement', owns: [], boundaries: [], collaborators: [], principles: [] },
|
||||
}, { now: NOW });
|
||||
const conversationIds = [
|
||||
'f47ac10b-58cc-4372-a567-0e02b2c3d482',
|
||||
'f47ac10b-58cc-4372-a567-0e02b2c3d483',
|
||||
];
|
||||
const conversations = createCodingConversationStore(projectPath, {
|
||||
createId: () => conversationIds.shift() as string,
|
||||
now: () => NOW,
|
||||
});
|
||||
const left = await conversations.create({
|
||||
agentId: 'agent-a',
|
||||
title: 'Left',
|
||||
model: { accountId: 'account-a', modelId: 'model-a', thinkingLevel: 'medium' },
|
||||
modelResolution: 'resolved',
|
||||
});
|
||||
const right = await conversations.create({
|
||||
agentId: 'agent-a',
|
||||
title: 'Right',
|
||||
model: { accountId: 'account-a', modelId: 'model-a', thinkingLevel: 'medium' },
|
||||
modelResolution: 'resolved',
|
||||
});
|
||||
let storeCreations = 0;
|
||||
const registry = new PiSessionRegistry({
|
||||
projectStore,
|
||||
createConversationStore: (candidatePath, options) => {
|
||||
storeCreations += 1;
|
||||
return createCodingConversationStore(candidatePath, options);
|
||||
},
|
||||
});
|
||||
const prepareInput = (conversation: typeof left) => ({
|
||||
conversationId: conversation.id,
|
||||
projectId: 'project-concurrent',
|
||||
agentId: 'agent-a',
|
||||
title: conversation.title,
|
||||
model: { model: conversation.model, modelResolution: conversation.modelResolution },
|
||||
});
|
||||
|
||||
await Promise.all([left, right].map((conversation) => registry.ensureBinding(
|
||||
prepareInput(conversation),
|
||||
async () => ({
|
||||
piSessionId: `session-${conversation.id}`,
|
||||
sessionKey: `key-${conversation.id}`,
|
||||
}),
|
||||
)));
|
||||
|
||||
const reopened = await conversations.read();
|
||||
expect(storeCreations).toBe(1);
|
||||
expect(reopened.conversations).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: left.id,
|
||||
piSessionId: `session-${left.id}`,
|
||||
sessionKey: `key-${left.id}`,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: right.id,
|
||||
piSessionId: `session-${right.id}`,
|
||||
sessionKey: `key-${right.id}`,
|
||||
}),
|
||||
]));
|
||||
});
|
||||
|
||||
it('maps first session binding persistence failure to the stable storage error', async () => {
|
||||
const projectPath = await mkdtemp(path.join(tmpdir(), 'makelore-pi-registry-binding-failure-'));
|
||||
roots.push(projectPath);
|
||||
|
||||
Reference in new issue
Block a user