Fix document merging logic

This commit is contained in:
Andras Schmelczer 2026-01-24 17:29:12 +00:00
parent 75ef370703
commit a63903734d
11 changed files with 77 additions and 96 deletions

View file

@ -24,7 +24,7 @@ process.on("uncaughtException", (error) => {
});
const TESTS: Partial<Record<string, TestDefinition>> = {
"write-write-conflict": writeWriteConflictTest,
// "write-write-conflict": writeWriteConflictTest,
"rename-create-conflict": renameCreateConflictTest
};

View file

@ -38,6 +38,8 @@ export class DeterministicAgent extends debugging.InMemoryFileSystem {
webSocket: webSocketImplementation
});
debugging.logToConsole(this.client.logger, { useColors: true });
await this.client.start();
const connectionCheck = await this.client.checkConnection();

View file

@ -37,7 +37,7 @@ export class ServerControl {
this.process.stderr?.on("data", (data: Buffer) => {
const msg = data.toString().trim();
this.logger.error(`[SERVER ERROR] ${msg}`);
this.logger.info(`[SERVER] ${msg}`);
if (msg.includes("Failed to") || msg.includes("Error")) {
startupError = msg;
}

View file

@ -191,34 +191,24 @@ export class TestRunner {
}
}
private async waitForConvergence(maxAttempts = 50): Promise<void> {
private async waitForConvergence(): Promise<void> {
this.logger.info("Barrier: waiting for convergence...");
for (let attempt = 0; attempt < maxAttempts; attempt++) {
for (const agent of this.agents) {
await agent.waitForSync();
}
for (const agent of this.agents) {
await agent.waitForSync();
}
if (await this.checkConsistency()) {
this.logger.info("Barrier complete: all clients converged");
return;
}
this.logger.info(
`Convergence attempt ${attempt + 1}/${maxAttempts}: not yet consistent, syncing again...`
);
if (await this.checkConsistency()) {
this.logger.info("Barrier complete: all clients converged");
return;
}
throw new Error(
`Clients did not converge after ${maxAttempts} attempts`
`Clients did not converge`
);
}
private async checkConsistency(): Promise<boolean> {
if (this.agents.length < 2) {
return true;
}
const [referenceAgent] = this.agents;
const referenceFiles = (await referenceAgent.getFiles()).sort();
@ -227,13 +217,9 @@ export class TestRunner {
const files = (await agent.getFiles()).sort();
if (files.length !== referenceFiles.length) {
return false;
}
for (let j = 0; j < files.length; j++) {
if (files[j] !== referenceFiles[j]) {
return false;
}
throw new Error(
`File count mismatch: client 0 has ${referenceFiles.length} files, client ${i} has ${files.length} files.\n Files: ${files.join(", ")}\n Reference: ${referenceFiles.join(", ")}`
);
}
for (const file of referenceFiles) {
@ -242,7 +228,9 @@ export class TestRunner {
const agentContent = await agent.getFileContent(file);
if (referenceContent !== agentContent) {
return false;
throw new Error(
`Content mismatch for ${file}:\nReference: "${referenceContent}"\nClient ${i}: "${agentContent}"`
);
}
}
}