Skip to content

Conversation

@neekolas
Copy link
Contributor

@neekolas neekolas commented Nov 11, 2025

Fork test overhaul

Refactors

  • Separates ChaosProviders to be modular.
  • Refactors error handling to allow for more chaotic tests
  • Refactors config to allow more configuration values to be set at run-time
  • Uses yargs​ for the CLI arguments to simplify CLI arg parsing
  • Uses a shared constant to check logs for forks

Features

  • Adds optional network chaos
  • Adds optional DB chaos (randomly disconnects/reconnects SQLite)
  • Adds optional background streams
  • Checks for forks using the commit log if available

Copy link
Contributor Author

neekolas commented Nov 11, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@macroscopeapp
Copy link

macroscopeapp bot commented Nov 11, 2025

Add chaos providers to fork tests and modify workers to support WorkerClient.lockDB and WorkerClient.clone, with CLI forks/cli.ts injecting FORK_TEST_CONFIG and validating local-only network chaos

Introduce DbChaos, NetworkChaos, and StreamsChaos providers, extend the fork test to run chaos during operations, add runtime config presets and env serialization, and update the CLI to parse chaos flags and pass FORK_TEST_CONFIG. Fork detection now uses a standardized forkDetectedString and considers debugInfo.isCommitLogForked.

📍Where to Start

Start with chaos orchestration in startChaos inside forks/forks.test.ts, then review runtime config building in buildRuntimeConfig in forks/cli.ts and presets in forks/config.ts.


Macroscope summarized 20e7ef4.

@neekolas neekolas force-pushed the 11-07-add_network_chaos_to_fork_tests branch 10 times, most recently from 3a0d67c to d361051 Compare November 12, 2025 18:26
@neekolas neekolas force-pushed the 11-07-add_network_chaos_to_fork_tests branch 7 times, most recently from 09c57e6 to 2804af1 Compare November 12, 2025 19:44
@neekolas neekolas marked this pull request as ready for review November 12, 2025 19:47
@neekolas neekolas force-pushed the 11-07-add_network_chaos_to_fork_tests branch 3 times, most recently from bcfd965 to 1416ee2 Compare November 12, 2025 21:56
@neekolas neekolas force-pushed the 11-07-add_network_chaos_to_fork_tests branch 3 times, most recently from 02d407e to 138b611 Compare November 17, 2025 16:24
@neekolas neekolas force-pushed the 11-07-add_network_chaos_to_fork_tests branch from 138b611 to 6b1f17d Compare November 17, 2025 16:36
runtimeConfig: RuntimeConfig,
): boolean {
const envFlag = options.env ? `--env ${options.env}` : "";
const command =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execSync builds a shell command with options.logLevel, which enables shell injection. Consider validating logLevel against a safe enum (e.g., ['debug','info','warn','error']) or switch to execFile/spawn with args to avoid shell parsing.

-   const command =
-     `yarn test forks ${envFlag} --log ${options.logLevel} --file`.trim();
+   const logLevel = ["debug","info","warn","error"].includes(options.logLevel) ? options.logLevel : "warn";
+   const command =
+     `yarn test forks ${envFlag} --log ${logLevel} --file`.trim();

🚀 Reply to ask Macroscope to explain or update this suggestion.

👍 Helpful? React to give us feedback.

@neekolas neekolas force-pushed the 11-07-add_network_chaos_to_fork_tests branch from 6b1f17d to a44ea29 Compare November 17, 2025 18:44
@neekolas neekolas force-pushed the 11-07-add_network_chaos_to_fork_tests branch 2 times, most recently from 6ee6e0f to b96795f Compare November 17, 2025 20:33
@neekolas neekolas force-pushed the 11-07-add_network_chaos_to_fork_tests branch from 5d3881f to 3620985 Compare November 18, 2025 05:05
@neekolas neekolas force-pushed the 11-07-add_network_chaos_to_fork_tests branch from 3620985 to 94cb0a3 Compare November 18, 2025 16:48
@neekolas neekolas force-pushed the 11-07-add_network_chaos_to_fork_tests branch 3 times, most recently from 5459d67 to c11ad1b Compare November 18, 2025 17:13
@neekolas neekolas force-pushed the 11-07-add_network_chaos_to_fork_tests branch from c11ad1b to 20e7ef4 Compare November 18, 2025 17:29
Copy link
Collaborator

@api-Hypernova api-Hypernova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!! Huge improvement 👍

@api-Hypernova api-Hypernova merged commit a1d42c4 into main Nov 18, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants