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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test: settle loaded CI fixtures without longer timeouts (#10962)
[._.]/ Adam Eivy34690087b797
diff --git a/client/src/pages/PersistentMindTools.test.jsx b/client/src/pages/PersistentMindTools.test.jsxindex bf05dec93e..7f60718225 100644--- a/client/src/pages/PersistentMindTools.test.jsx+++ b/client/src/pages/PersistentMindTools.test.jsx@@ -1,5 +1,5 @@import { beforeEach, describe, expect, it, vi } from 'vitest';-import { fireEvent, render, screen, waitFor } from '@testing-library/react';+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';import userEvent from '@testing-library/user-event';import { MemoryRouter } from 'react-router';@@ -256,16 +256,16 @@ describe('PersistentMindTools', () => {it('saves the progressive tool-exposure retention window on blur and shows its current value', async () => {const user = userEvent.setup();- renderPage();+ // Drain the initial fetch and passive capability-sync effects before+ // editing: finding the field alone is not a completed mount barrier.+ await act(async () => { renderPage(); });const retentionInput = await screen.findByLabelText('Retention window (extra turns)');expect(retentionInput).toHaveValue(3);- // One change event (3 -> 5) instead of clear-then-type: a clear is its own- // controlled-input transition that a late capabilities sync can overwrite- // under CI load, leaving the field at 3.- fireEvent.change(retentionInput, { target: { value: '5' } });- await waitFor(() => expect(retentionInput).toHaveValue(5));await user.click(retentionInput);+ // Replace in one event; clearing a numeric input is a separate value (0).+ fireEvent.change(retentionInput, { target: { value: '5' } });+ expect(retentionInput).toHaveValue(5);await user.tab();await waitFor(() => expect(api.updateCosConfig).toHaveBeenCalledWith({diff --git a/scripts/ci-install-db-tools.test.js b/scripts/ci-install-db-tools.test.jsindex 0093e79701..b25d157ca7 100644--- a/scripts/ci-install-db-tools.test.js+++ b/scripts/ci-install-db-tools.test.js@@ -21,18 +21,27 @@ Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg`;// Runs the real script against a fake filesystem root and a fake sudo/curl/-// apt-get on PATH; nothing touches the host's package manager or network.+// apt-get/timeout on PATH; nothing touches the host's package manager or network.// `mirror` decides how the fake apt-get behaves:// ok — every source answers promptly-// slowRunner — anything while the runner's Azure mirror is configured stalls-// dead — every download stalls-function run(mirror, { primaryBudget = '1', totalBudget = '3' } = {}) {+// slowRunner — the watchdog expires while the Azure mirror is configured+// dead — the watchdog expires for every download+// Inject a Bash clock and watchdog instead of sleeping against 1–3 second+// budgets: startup/source rewriting consumed those budgets under load, and+// macOS does not ship GNU timeout. The real script still computes deadlines.+function run(mirror) {const dir = mkdtempSync(join(tmpdir(), 'ci-db-tools-'));const bin = join(dir, 'bin');const root = join(dir, 'root');const sourcesFile = join(root, 'etc/apt/sources.list.d/ubuntu.sources');const log = join(dir, 'calls');const githubPath = join(dir, 'github_path');+ const clock = join(dir, 'clock');+ const bashEnv = join(dir, 'bash-env');+ writeFileSync(clock, '0\n');+ // Unsetting Bash's special SECONDS turns it into an ordinary variable.+ // DEBUG/functrace refresh it before commands inside bounded() too.+ writeFileSync(bashEnv, `unset SECONDS\nSECONDS=0\nset -T\ntrap 'read -r SECONDS < "$TEST_CLOCK"' DEBUG\n`);mkdirSync(bin);mkdirSync(join(root, 'etc/apt/sources.list.d'), { recursive: true });writeFileSync(join(root, 'etc/os-release'), 'VERSION_CODENAME=noble\n');@@ -44,15 +53,29 @@ function run(mirror, { primaryBudget = '1', totalBudget = '3' } = {}) {fake('sed', 'if [ "$(uname -s)" = Darwin ]; then\n [ "$1" = "-i" ] && [ "$2" = "-E" ] || exit 2\n shift 2\n exec /usr/bin/sed -i "" -E "$@"\nfi\nexec /usr/bin/sed -i -E "$@"');fake('curl', 'while [ $# -gt 0 ]; do [ "$1" = -o ] && echo key > "$2"; shift; done');const stall = { ok: 'false', slowRunner: `grep -q azure '${sourcesFile}'`, dead: 'true' }[mirror];- fake('apt-get', `echo "apt-get $*" >> '${log}'\nif ${stall}; then exec sleep 30; fi`);+ fake('timeout', `+[ "$1" = --kill-after=10 ] || exit 2+shift+budget="$1"+echo "timeout $budget" >> '${log}'+[ "$1" -gt 0 ] || exit 2+shift+"$@"+status=$?+if [ "$status" = 124 ]; then+ read -r elapsed < "$TEST_CLOCK"+ echo "$((elapsed + budget))" > "$TEST_CLOCK"+fi+exit "$status"`);+ fake('apt-get', `echo "apt-get $*" >> '${log}'\nif ${stall}; then exit 124; fi`);const result = spawnSync('/bin/bash', [script], {encoding: 'utf8',env: {PATH: `${bin}:${process.env.PATH}`,APT_ROOT: root,- APT_PRIMARY_BUDGET_SECONDS: primaryBudget,- APT_TOTAL_BUDGET_SECONDS: totalBudget,+ BASH_ENV: bashEnv,+ TEST_CLOCK: clock,PG_MAJOR: '17',GITHUB_PATH: githubPath,},@@ -60,7 +83,8 @@ function run(mirror, { primaryBudget = '1', totalBudget = '3' } = {}) {const read = (file) => readFileSync(file, { encoding: 'utf8', flag: 'a+' });const out = {...result,- calls: read(log).split('\n').filter(Boolean).map((line) => line.replace(/ -o \S+/g, '')),+ budgets: read(log).split('\n').filter((line) => line.startsWith('timeout ')).map((line) => Number(line.split(' ')[1])),+ calls: read(log).split('\n').filter((line) => line.startsWith('apt-get ')).map((line) => line.replace(/ -o \S+/g, '')),sources: read(sourcesFile),pgdg: read(join(root, 'etc/apt/sources.list.d/pgdg.list')),githubPath: read(githubPath),@@ -73,9 +97,8 @@ const INSTALL_FROM_CACHE = 'apt-get install -y --no-download postgresql-client-1describe.skipIf(process.platform === 'win32')('CI DB tool installation', () => {it('installs the service-major client from the signed PostgreSQL repository', () => {- // Leave room for loaded runners; only the stall cases need tiny budgets.- const result = run('ok', { primaryBudget: '60', totalBudget: '120' });- expect(result.status).toBe(0);+ const result = run('ok');+ expect(result.status, result.stderr).toBe(0);expect(result.pgdg).toBe('deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt noble-pgdg main\n');expect(result.calls).toEqual(['apt-get update',@@ -88,17 +111,18 @@ describe.skipIf(process.platform === 'win32')('CI DB tool installation', () => {it('recovers from a stalled runner mirror through the official archive, keeping signing', () => {const result = run('slowRunner');- expect(result.status).toBe(0);+ expect(result.status, result.stderr).toBe(0);expect(result.stdout).toContain('switching to http://archive.ubuntu.com/ubuntu/');expect(result.sources).toBe(RUNNER_SOURCES.replace('azure.archive.ubuntu.com', 'archive.ubuntu.com'));- // The stalled first update is killed on a 1s budget, so on a loaded host it- // may die before the fake logs its call: allow zero or one leading attempt.- expect(result.calls.slice(-3)).toEqual([+ expect(result.calls).toEqual([+ 'apt-get update','apt-get update','apt-get install -y --download-only postgresql-client-17 ffmpeg',INSTALL_FROM_CACHE,]);- expect(result.calls.slice(0, -3)).toSatisfy((stalled) => stalled.length <= 1 && stalled.every((c) => c === 'apt-get update'));+ // The primary stall spends 180s of fake time, leaving 210s of the one+ // total deadline for BOTH fallback commands (no per-command reset).+ expect(result.budgets).toEqual([180, 210, 210]);expect(result.githubPath).toBe('/usr/lib/postgresql/17/bin\n');});@@ -106,7 +130,8 @@ describe.skipIf(process.platform === 'win32')('CI DB tool installation', () => {const result = run('dead');expect(result.status).toBe(1);expect(result.stderr).toContain('::error title=DB tool installation failed::');- expect(result.stderr).toContain('within 3s');+ expect(result.stderr).toContain('within 390s');+ expect(result.budgets).toEqual([180, 210]);expect(result.calls).not.toContain(INSTALL_FROM_CACHE);expect(result.githubPath).toBe('');});diff --git a/server/routes/hostControlPipelineProviderDispatch.test.js b/server/routes/hostControlPipelineProviderDispatch.test.jsindex 5af708b8b7..42368c4918 100644--- a/server/routes/hostControlPipelineProviderDispatch.test.js+++ b/server/routes/hostControlPipelineProviderDispatch.test.js@@ -1,5 +1,6 @@import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import express from 'express';+import { EventEmitter } from 'node:events';import { request } from '../lib/testHelper.js';import { errorMiddleware } from '../lib/errorHandler.js';import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from '../lib/mockPathsDataRoot.js';@@ -74,6 +75,7 @@ vi.mock('../services/pipeline/seriesCanon.js', async (importOriginal) => ({import { authGate, hostControlRouteGate } from '../services/authGate.js';import { createSession } from '../services/auth.js';import pipelineRoutes from './pipeline/index.js';+import { attachClient, isReverseOutlineActive } from '../services/pipeline/reverseOutline.js';const operations = [[`/api/pipeline/series/${SERIES_ID}/reverse-outline/generate`, { providerId: cliProvider.id, force: true }],@@ -131,12 +133,32 @@ describe('Pipeline generation never reaches a CLI provider for unauthorized callsink.runPromptThroughProvider.mockClear();const response = await post(appFor(address), operation, headers);expect(response.status, `${operation[0]}: ${JSON.stringify(response.body)}`).toBe(200);- // The run starts asynchronously after the 200; vi.waitFor's 1 s default is- // too tight under a loaded pregate, and a generous cap costs nothing on a pass.- await vi.waitFor(- () => expect(sink.runPromptThroughProvider, operation[0]).toHaveBeenCalledTimes(1),- { timeout: 10_000 },- );+ if (operation[0].includes('/reverse-outline/')) {+ // A provider call is not completion: persistence is still in flight.+ // Await the public SSE terminal frame (including its late replay) so+ // the next local/operator request cannot reuse the previous run.+ const connection = new EventEmitter();+ try {+ const terminal = await new Promise((resolve) => {+ expect(attachClient(SERIES_ID, {+ req: connection,+ writeHead() {},+ end() {},+ write(frame) {+ const payload = JSON.parse(frame.slice('data: '.length));+ if (['complete', 'error', 'canceled'].includes(payload.type)) resolve(payload);+ },+ })).toBe(true);+ });+ expect(terminal).toMatchObject({ type: 'complete', runId: response.body.runId });+ // The coordinator marks the run finished after broadcasting.+ await new Promise((resolve) => setImmediate(resolve));+ expect(isReverseOutlineActive(SERIES_ID)).toBe(false);+ } finally {+ connection.emit('close');+ }+ }+ expect(sink.runPromptThroughProvider, operation[0]).toHaveBeenCalledTimes(1);expect(sink.runPromptThroughProvider.mock.calls[0][0].provider).toEqual(cliProvider);}}