Skip to content

Expose cancellable child process handles in JavaScript and Rust - #126

Merged
konard merged 5 commits into
mainfrom
issue-20-171029a1
Sep 21, 2026
Merged

konard merged 5 commits into
mainfrom
issue-20-171029a1

Conversation

@konard

@konard konard commented Sep 9, 2025 •

Copy link
Copy Markdown
Member

Summary

Expose the owned child process through supported, cancellable handles in both implementations.

  • JavaScript: reading runner.child starts a lazy command and synchronously returns a stable pending handle. runner.child.kill('SIGTERM') can cancel before shell parsing/spawn, can stop in-process built-ins, and later reflects the native Node.js or Bun child. After cleanup, runner.child is null.
  • Rust: ProcessRunner::child() returns a borrowed ProcessChild after start().await, with PID/native Tokio child access and signal-aware kill() / kill_with() methods.
  • Internals now keep the native JavaScript child in _child, so internal lifecycle checks do not accidentally trigger the public auto-starting getter.
  • A post-classification cancellation guard prevents real-shell commands from spawning after an immediate child-handle kill.
  • Executable feature documentation, JavaScript changeset, and Rust changelog fragment cover the cross-language API.

Closes #20.

Reproduction and regression coverage

Before this change, a newly-created JavaScript runner had no accessible child, so the requested synchronous call could not stop it:

const command = $`long-running-command`;
command.child.kill('SIGTERM');

js/tests/child-access.test.mjs now verifies immediate cancellation before spawn, the real-shell/redirection startup race, native-child delegation after spawn, built-in cancellation, and cleanup. rust/tests/child_access.rs verifies the corresponding Rust lifecycle, native access, and child-handle termination.

Validation

  • bun test js/tests/ --timeout 10000 — 1,609 passed, 6 skipped, 0 failed
  • bun run lint, bun run format:check, bun run check:duplication
  • Node.js ESM/CommonJS compatibility and regression tests from the JavaScript workflow
  • cargo test --all-features --verbose and cargo test --doc --all-features --verbose
  • cargo fmt --check, Clippy with warnings denied, rustdoc with warnings denied, and cargo package --allow-dirty
  • Rust release-script tests plus file-size and packaged-crate-size checks
  • JavaScript changeset and Rust changelog/version validators
  • All 25 executable features pass JavaScript/Rust parity; Node.js and Bun observations match
  • Generated feature documentation is current
  • Fresh merge simulation confirms the branch contains current main

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

Issue: #20
@konard konard self-assigned this Sep 9, 2025
konard and others added 2 commits September 9, 2025 22:38
This change enables users to access and kill child processes immediately
without having to await the process result first. The implementation
addresses both virtual commands and real child processes.

Key changes:
- Add child getter that provides immediate access to process for killing
- For virtual commands: return proxy object with kill() method that delegates
- For real commands: auto-start process when child is accessed
- Update internal references from this.child to this._child
- Fix kill() method to properly handle virtual commands

The solution allows both patterns to work:
- Virtual: $`sleep 5`.child.kill('SIGTERM')
- Real: $`/bin/sleep 5`.child.kill('SIGTERM')

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

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] The child object should be accessable and it should be possible to be able to kill process using it Fix #20: Enable immediate child process access for killing Sep 9, 2025
@konard
konard marked this pull request as ready for review September 9, 2025 19:52
@konard

konard commented Sep 21, 2026 •

Copy link
Copy Markdown
Member Author

We need to double check that all requirements are fully delivered for all programming languages we currently support.

@konard
konard marked this pull request as draft September 21, 2026 07:28
@konard

konard commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

🤖 AI Work Session Started

Starting automated work session at 2026-09-21T07:28:43.825Z

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 codex · model gpt-5.6-sol · task image konard/hive-mind-dind:2.29.0@sha256:11a236d03854cbaea86fdd7ca06265c912cf0b67d1fcc9b3eb60bd84c43ff749

@konard konard changed the title Fix #20: Enable immediate child process access for killing Expose cancellable child process handles in JavaScript and Rust Sep 21, 2026
@konard
konard marked this pull request as ready for review September 21, 2026 08:11
@konard

konard commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

Working session summary

Implemented and finalized PR #126.

  • Added cancellable child handles for JavaScript and Rust.
  • Covered immediate pre-spawn cancellation, native children, built-ins, shell startup races, and cleanup.
  • Added documentation and release metadata.
  • Merged current main; branch is conflict-free and up to date.
  • Local suites passed, including 1,609 JavaScript tests and full Rust tests.
  • CI: 28 successful checks, 6 expected skips, 0 failures.
  • Working tree is clean.
  • PR is marked ready for review and is MERGEABLE/CLEAN.

Final commit: 6c7118e6a70663d043abfc7cde6698d5bdd60b9f


This summary was automatically extracted from the AI working session output.

@konard

konard commented Sep 21, 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 estimation:

  • Model: GPT-5.6 Sol
  • Provider: OpenAI
  • Public pricing estimate: $16.078063

📊 Context and tokens usage:

  • 491.9K / 200K (246%) input tokens, 53.2K / 128K (42%) output tokens

Total: (491.9K + 13.2M cached) input tokens, 53.2K output tokens, $16.078063 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.6-sol
  • Thinking level: xhigh (~31999 tokens)
  • Model: GPT-5.6 Sol (gpt-5.6-sol)

📎 Log file uploaded as Gist (6084KB)


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

@konard
konard merged commit a606918 into main Sep 21, 2026
34 checks passed
@konard

konard commented Sep 21, 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.

The child object should be accessable and it should be possible to be able to kill process using it

1 participant