Skip to content

Test parallel execution of sleeping commands in JavaScript and Rust - #124

Merged
konard merged 5 commits into
mainfrom
issue-22-51ab60ad
Sep 16, 2026
Merged

konard merged 5 commits into
mainfrom
issue-22-51ab60ad

Conversation

@konard

@konard konard commented Sep 9, 2025

Copy link
Copy Markdown
Member

Summary

Issue #22 asks for a test that 2-3 commands with a sleep inside can be started in parallel and that all of them execute. This PR adds that coverage to both implementations the repository ships — JavaScript (js/tests/parallel-sleep.test.mjs) and Rust (rust/tests/parallel_sleep.rs) — and merges the current main into the branch, which is what moved the JavaScript test from tests/ to js/tests/.

What each test asserts

Wall-clock timing alone is a weak signal on a loaded CI machine, so every test checks three independent properties:

  1. Every command finished — exit code 0, and the expected output where the command produces some.
  2. The execution windows overlap — each command's start and end instants are recorded and every pair is asserted to have been in flight at the same moment. This is the property "parallel" actually describes, and it holds regardless of machine load.
  3. The wall clock beat the sequential total — the batch must finish below 75% of the sum of the sleeps, which fails loudly if the commands were serialized.

Cases covered (identical in both languages)

Test What it covers
2 sleeping commands Two sleep 0.5 commands started together
3 sleeping commands Three sleep 0.5 commands started together
Mixed durations 0.2s / 0.5s / 0.3s finish in the time of the longest one, not the sum
Real sleep processes Bypasses the built-in sleep (JS: disableVirtualCommands(), Rust: /bin/sleep) so actual child processes are spawned
Output preserved sh -c 'echo start; sleep; echo end' × 3 — each command keeps its own output intact
Environment isolated Each parallel sh -c keeps its own shell variable

The sh -c and real-process cases are skipped on Windows (test.skipIf(isWindows) / #[cfg(unix)]); the first three run everywhere, because sleep is a built-in virtual command in both implementations.

Language parity

The reviewer asked for parity across languages and for main to be synced into the branch. Both are done:

  • main is merged (d7a7c11), so the branch sits on the current js/ + rust/ monorepo layout.
  • The Rust tests mirror the JavaScript ones case for case, with the same thresholds and the same three assertions.
  • Release triggers for both toolchains are included: js/.changeset/issue-22-parallel-sleep-tests.md and rust/changelog.d/20260916_091500_parallel_sleep_tests.md.

Verification

bun test js/tests/parallel-sleep.test.mjs --timeout 10000   # 6 pass, 0 fail, 74 expect() calls
cargo test --all-features --test parallel_sleep             # 6 passed; 0 failed
cargo fmt --all -- --check                                  # clean
cargo clippy --all-targets --all-features -- -D warnings    # clean
bun run lint && bun run format:check                        # clean

Full bun test js/tests/ and cargo test --all-features suites were run locally as well.

Fixes #22

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #22
@konard konard self-assigned this Sep 9, 2025
konard and others added 2 commits September 9, 2025 22:32
Implements test for issue #22 that validates the ability to execute 2-3 commands with sleep inside in parallel. The test suite includes:

- 2 parallel sleep commands with timing validation
- 3 parallel sleep commands with timing validation
- Mixed duration sleep commands executed in parallel
- Parallel commands with output verification
- Individual execution context verification for parallel commands

All tests verify that commands execute truly in parallel (not sequentially) by measuring execution time and ensuring it matches the longest sleep duration rather than the sum of all sleep durations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Add test, that we can start 2-3 commands with sleep inside in parallel and for all to execute Add test for parallel execution of 2-3 commands with sleep Sep 9, 2025
@konard
konard marked this pull request as ready for review September 9, 2025 19:37
@konard

konard commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

We need to check that we have programming language parity of all features, so all languages are supported, and latest version of main branch synced here.

@konard
konard marked this pull request as draft September 16, 2026 09:07
@konard

konard commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

🤖 AI Work Session Started

Starting automated work session at 2026-09-16T09:07:46.080Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback.

Runtime: solve v2.29.0 · tool claude · model opus · task image konard/hive-mind-dind:2.29.0@sha256:11a236d03854cbaea86fdd7ca06265c912cf0b67d1fcc9b3eb60bd84c43ff749

Relocates tests/parallel-sleep.test.mjs to js/tests/ to match the
JavaScript/Rust monorepo layout introduced on main.
Issue #22 asks for a test that 2-3 commands with a sleep inside can be
started in parallel and all of them finish. The JavaScript test moved to
js/tests/ with the monorepo layout, and the same coverage now exists for
the Rust crate so both implementations stay in parity.

Wall-clock thresholds alone are a weak signal on a loaded CI machine, so
each test also records the window every command occupied and asserts the
windows overlap - that is the property 'parallel' actually describes.
Coverage spans the built-in sleep, real sleep processes, and sh -c
scripts that sleep between writes while keeping their own output and
environment.
@konard konard changed the title Add test for parallel execution of 2-3 commands with sleep Test parallel execution of sleeping commands in JavaScript and Rust Sep 16, 2026
@konard
konard marked this pull request as ready for review September 16, 2026 09:20
@konard

konard commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

@konard both points are addressed:

Latest main synced — merged origin/main into this branch in d7a7c11. The branch predated the monorepo restructuring, so the test file moved from tests/parallel-sleep.test.mjs to js/tests/parallel-sleep.test.mjs as part of that merge. HEAD..origin/main is now empty and the PR is MERGEABLE.

Language parity — the test exists in both languages with the same six cases, thresholds and assertions:

  • js/tests/parallel-sleep.test.mjs
  • rust/tests/parallel_sleep.rs
Case JS Rust
2 sleeping commands at the same time
3 sleeping commands at the same time
mixed durations finish in the time of the longest
real sleep processes (built-in bypassed)
output kept when a command sleeps between writes
each parallel command keeps its own environment

Each case asserts three independent things rather than wall clock alone: every command succeeded with the expected output, every pair of execution windows overlaps (which is what "parallel" actually means), and the batch finished under 75% of the sequential total.

Two implementation notes: JS disables virtual commands via disableVirtualCommands() for the real-process case, while Rust calls /bin/sleep by absolute path instead — Rust test threads share process-global state, so toggling it would race other tests. Process-dependent cases are skipped on Windows (test.skipIf(isWindows) / #[cfg(unix)]).

Release triggers for both languages are included: js/.changeset/issue-22-parallel-sleep-tests.md and rust/changelog.d/20260916_091500_parallel_sleep_tests.md.

All five CI runs are green on 35b7589: JavaScript checks and release, Rust checks and release, Language parity check, Repository quality checks, Security.

@konard

konard commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $6.168250

📊 Context and tokens usage:

Claude Opus 5: (2 sub-sessions)

  1. 116.9K / 1M (12%) input tokens, 35.2K / 128K (28%) output tokens
  2. 37.2K / 1M (4%) input tokens, 3.5K / 128K (3%) output tokens

Total: (2.3K new + 130.5K cache writes + 7.4M cache reads) input tokens, 46.8K output tokens, $6.168250 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus (claude-opus-5)
  • Thinking level: high (~23999 tokens)
  • Model: Claude Opus 5 (claude-opus-5)

📎 Log file uploaded as Gist (2573KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
konard merged commit 428d75b into main Sep 16, 2026
34 checks passed
@konard

konard commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

🎉 Auto-merged

This pull request has been automatically merged by hive-mind.

  • All CI checks have passed

Auto-merged by hive-mind with --auto-merge flag

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.

Add test, that we can start 2-3 commands with sleep inside in parallel and for all to execute

1 participant