Repository navigation
test: stop CI timeouts and keep the suite out of the real home directory - #160
Merged
Merged
Conversation
The tests that loop over hundreds of generated documents took 2-3 s on a fast machine and over 5 s on a loaded one, so vitest's default 5 s timeout failed them for speed alone (CI on ef28d1d; locally two of them timed out when the whole suite ran in parallel). Give the nine heavy generated-document tests in telegram-split and telegram-delivery an explicit 60 s timeout. Seed counts and assertions are unchanged. The splitter itself is linear (about 7.6 renders per chunk from its binary search), so there is no performance fix to make in format.ts.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
The suite wrote into the real ~/.roundhouse (telegram-pairing.json, soul.md, tools.md, crons/, memory-state/, active-topics.json, logs/), so on a machine where it had run once the next run failed: "isPairingPending returns false when no pairing file exists" found the pairing file a previous run left behind. CI passed only because its home is fresh. That test set process.env.ROUNDHOUSE_DIR, which config.ts never reads, so it was writing to the real home all along. - vitest.config.ts: a global setup points HOME/USERPROFILE at a temp dir for the whole run (spawned processes inherit it), and a setup file gives every test file its own empty HOME before any src module is imported; both are removed afterwards. - telegram-setup.test.ts: the pairing tests isolate through HOME instead of the ignored ROUNDHOUSE_DIR variable. - subagent-command.ts: use ROUNDHOUSE_DIR from config instead of its own copy. Production behavior is unchanged.
A local run with an empty HOME made vitest write .local/share/vitest/.vitest-secret-token inside the repo, and it was committed by mistake. The token is a throwaway local vitest API token; the file is deleted on the machine that made it, so the token is no longer used.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR has two test-only fixes. Production behavior is unchanged.
1. Generated-document tests timing out on slow CI
Problem
CI "Test" failed on
main(ef28d1d, v0.7.0).telegram-split.test.ts > generated documents > covers what it claims to…hit vitest's default 5000 ms timeout. Locally, with the full suite running in parallel, two more timed out the same way:holds its properties for 400 documents(5714 ms) andtelegram-delivery > a table that is being streamed…(5540 ms).Root cause
These tests are slow because each one loops over hundreds of generated documents. They are not hanging. They take 1–3 s on an idle machine and over 5 s on a loaded one, so the default timeout fails them for speed alone.
I profiled
splitMarkdownForTelegramand found nothing super-linear. Each chunk only scanslimitplus 3 lines (reach). The binary search costs about 7.6 renders per chunk (14,253 probes for 1,866 chunks over 400 docs), and only 85 of those repeat, so memoizing would save nothing. A single-passescapeHtmlgave the same output (hash checked over 1,200 docs × 4 limits) but was only about 5% faster, within noise, so I left it out. Cutting the number of probes would mean bounding the search by HTML length against source length, and that relationship isn't monotone. That isn't a safe change.Change
Only tests change. The 9 heavy generated-document tests get
GENERATED_DOCS_TIMEOUT_MS = 60_000: the 3 intelegram-split.test.tsand 6 intelegram-delivery.test.ts. Seed counts and assertions are unchanged.Timings (slowest tests)
taskset -c 0+ busy loop (after)Checks
npm ci✓npm run typecheck✓npm test×3 ✓ (64 files, 884 tests each)npm publish --dry-run: packs 154 files, then exits with "cannot publish over 0.7.0". That's expected because the version isn't bumped. Not caused by this PR.2. The suite was not hermetic: it wrote into the real ~/.roundhouse
Problem
On a machine where the suite had already run once, the next run failed:
telegram-setup.test.ts > TelegramAdapter.handlePairing > isPairingPending returns false when no pairing file exists(expected true to be false). CI passed only because its home directory is fresh. Reproduced by runningvitest runtwice with the sameHOME: the first run passed 884/884, the second failed this test.Root cause
src/config.tscomputesROUNDHOUSE_DIR = resolve(homedir(), ".roundhouse")at import time, andPAIRING_PATH,CRON_JOBS_DIRetc. derive from it. Nothing in the test setup redirected the home directory, so tests wrotetelegram-pairing.json,soul.md,tools.md,user.md,crons/,memory-state/,active-topics.jsonandlogs/into the real~/.roundhouse(plus~/.pi/agentand~/.mcporter). The pairing tests setprocess.env.ROUNDHOUSE_DIRto a temp dir, butconfig.tsnever reads that variable. They believed they were isolated but were reading and writing the real pairing file, so one run's leftover file failed the next run.Change
vitest.config.ts(new):test/setup/global-home.ts(globalSetup) pointsHOME/USERPROFILEat a temp root for the whole run, so worker processes and any processes the tests spawn inherit it. It is removed at teardown.test/setup/isolate-home.ts(setupFiles) gives every test file its own empty HOME before the test file or anysrcmodule is imported. It is removed inafterAll.test/telegram-setup.test.ts: the pairing tests isolate throughHOME+vi.resetModules()instead of the ignoredROUNDHOUSE_DIRvariable. Assertions are unchanged.src/cli/subagent-command.ts: usesROUNDHOUSE_DIRfromconfiginstead of its own copy.ROUNDHOUSE_DIRenv override was added. Several production paths (telemetry, kiro sessions, the sub-agent orchestrator, whisper,/later, doctor) build~/.roundhousefromhomedir()themselves, so an override that only some of them honored would be a trap for users..local/share/vitest/.vitest-secret-tokenthat was committed by mistake (from a local run with an emptyHOME; it is a throwaway local vitest API token, now deleted) and adds.local/to.gitignore.Checks
~/.roundhousedid not exist before the runs and still does not after them.~/.pi,~/.mcporter,~/.local/share/vitest: no files modified during the runs.npm test×3 in a row with the realHOME: 64 files / 884 tests passed each time.HOMEset to a home already polluted by the old code (staletelegram-pairing.jsonetc.): 884/884.npm ci✓,npm run typecheck✓,npm pack --dry-run✓ (154 files; no test or vitest config files in the package).