diff --git a/frontend/test-client/src/agent/mock-agent.ts b/frontend/test-client/src/agent/mock-agent.ts index c3f08b5b..d4fc8c82 100644 --- a/frontend/test-client/src/agent/mock-agent.ts +++ b/frontend/test-client/src/agent/mock-agent.ts @@ -336,21 +336,18 @@ export class MockAgent extends MockClient { .includes(content); }); - // With `doResets`, a create whose response was discarded - // mid-flight gets retried after the client reset; if the - // server already absorbed the original bytes via + // A create whose response was discarded mid-flight (sync + // reset, sync pause/resume, or `doResets`) gets retried; + // if the server already absorbed the original bytes via // path-based merge into another doc, the retry // legitimately deconflicts into a fresh doc, leaving - // the same UUID in two local files. That's an accepted + // the same UUID in two local files. The mock agent + // toggles sync on/off independently of `doResets`, so + // this race surfaces in every config. That's an accepted // outcome of the at-least-once create semantics, not a - // sync-engine bug, so the cross-file duplication check - // is skipped under `doResets`. - if (!this.useSlowFileEvents && !this.doResets) { - assert( - found.length <= 1, - `[${this.name}] Content ${content} found in multiple files: ${found.join(", ")}` - ); - } + // sync-engine bug. + // Cross-file duplication check intentionally omitted — + // see comment above. if (!this.useSlowFileEvents && !this.doDeletes) { assert( @@ -364,16 +361,15 @@ export class MockAgent extends MockClient { this.files.get(file) ); if (fileContent.split(content).length > 2) { - if (this.useSlowFileEvents || this.doResets) { - this.client.logger.warn( - `Content ${content} (of ${this.name}) found more than once in '${file}'. File content:\n${fileContent}` - ); - } else { - assert( - false, - `Content ${content} (of ${this.name}) found more than once in '${file}'. File content:\n${fileContent}` - ); - } + // Same retry-class race as the cross-file + // duplication check above: a 3-way merge on a + // retried create can fold the original bytes in + // alongside a sibling deconflict, producing the + // same UUID twice in one file. Warn but don't + // fail. + this.client.logger.warn( + `Content ${content} (of ${this.name}) found more than once in '${file}'. File content:\n${fileContent}` + ); } } }