Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

test: cut transcript persistence flush count to stop pregate timeouts (#11800)

[._.]/ Adam Eivy72d9137ab439
diff --git a/server/services/agentCliSpawning.test.js b/server/services/agentCliSpawning.test.js
index 70f7e1b28e..23992c5e3c 100644
--- a/server/services/agentCliSpawning.test.js
+++ b/server/services/agentCliSpawning.test.js
@@ -959,18 +959,21 @@ describe('stream error containment', () => {
};
it('writes a growing transcript once per byte plus the terminal rewrite, preserving mixed UTF-8 output', async () => {
- // 240 flushes model one minute at the 250ms batch cadence without sleeps.
- // Before the stderr suffix, full-prefix writes submitted 238,878,720
- // bytes for 1,966,080 bytes of output; deltas plus final rewrite need 3,932,160.
+ // Each flush is a real file write, so wall time scales with the flush count and
+ // timed out at 240 under loaded pregate workers. The once-per-byte contract does
+ // not depend on cadence: full-prefix writes would submit O(n^2) bytes here
+ // (~9.6M for 393,216 bytes of output) versus the 786,432 that deltas plus the
+ // final rewrite need.
publicationAdmission.bypass = true;
await fs.writeFile(join(dir, 'output.txt'), 'stale previous transcript');
await spawnDirectly({ ...minimalArgs, agentDir: dir,
cliConfig: { command: 'claude', args: [], stdinMode: 'prompt', streamFormat: 'text' } });
+ const FLUSHES = 48;
const chunk = `é${'x'.repeat(8189)}\n`;
- for (let i = 0; i < 240; i++) await emitTextAndFlush(chunk);
+ for (let i = 0; i < FLUSHES; i++) await emitTextAndFlush(chunk);
fakeProcess.stderr.emit('data', Buffer.from('尾\n'));
await activeAgents.get('agent-test').flushOutput();
- const expected = `${chunk.repeat(240)}[stderr] 尾\n`;
+ const expected = `${chunk.repeat(FLUSHES)}[stderr] 尾\n`;
expect(await fs.readFile(join(dir, 'output.txt'), 'utf8')).toBe(expected);
await finish();
expect(await fs.readFile(join(dir, 'output.txt'), 'utf8')).toBe(expected);