Skip to content

feat(process): own Windows shell ranges and private channels - #908

Draft
Haoming9527 wants to merge 2 commits into
work/872-resident-isolationfrom
work/872-resident-shell-process
Draft

Haoming9527 wants to merge 2 commits into
work/872-resident-isolationfrom
work/872-resident-shell-process

Conversation

@Haoming9527

@Haoming9527 Haoming9527 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #872. Stacked on #906 (work/872-resident-isolation). This is the Windows process and channel slice; #872 remains open.

What was wrong

The resident kernel could own independently cancellable file leaves, but had no process range suitable for long-lived shells launched with the host's exact confinement argv. A shell needs atomic ownership before any child can run, isolated cancellation, bounded private channels and cleanup that waits for every reader.

The change

Add ops-process::shell with an atomic nested Windows Job and explicit inherited-handle list. Each shell gets a hidden private console, an explicit environment and EOF stdin. Private named pipes have bounded retention and connection counts, owner/logon ACLs, and peer membership checks against the shell's Job. Cleanup drains admitted peers to EOF and joins all readers even after an earlier reader error.

Ctrl+C is attempted by a short-lived controller in its own owned range. This avoids a reproduced Windows race where resetting the resident process's console handlers terminated the kernel with STATUS_CONTROL_C_EXIT. The controller has fixed internal argv, an empty environment, bounded diagnostics and a deadline; it is joined on success, timeout and crash. A successful receipt means an interrupt attempt, not target cooperation. Restricted wrappers may require hard termination of the affected range.

Add a real public-host Windows probe to CI and bilingual documentation. No new dependency versions; only features of the existing windows-sys pin are enabled. The slice has approximately 1,090 production Rust lines, excluding tests; the largest added code file is 434 lines. Atomic creation and drain/cancellation handling stay together in the platform module.

Published tools and the pinned Niubash distribution retain their current behavior. Persistent command receipts, session queues, permission readmission, explicit DSH jobs and full performance acceptance follow in connected slices. POSIX support for this new range returns an explicit unsupported error: independent process groups have not established the required host-fallback ownership.

Validation

Local Windows x64 results:

node bench/probes/probe-872-shell-range.mjs
13 passed, 0 failed; no tracked survivors

cargo test --locked --manifest-path native/Cargo.toml -p ops-process
17 passed, 0 failed, 1 existing child fixture ignored
(the child fixture is explicitly invoked by its lifecycle tests)

cargo test --workspace --locked --manifest-path native/Cargo.toml
exit 0

cargo clippy --workspace --all-targets --locked --manifest-path native/Cargo.toml -- -D warnings
exit 0

npm run build
exit 0

node scripts/check-file-size.mjs
860 files passed (after the cooperative-target fixture correction)

node scripts/check-workflows.mjs
117 checks passed

cargo fmt --all --check --manifest-path native/Cargo.toml
exit 0

git diff --cached --check
exit 0

The public-host probe covers all three permission modes (the two restricted modes report their actual partial enforcement), exact confined argv, argument quoting, private descriptor channels, rejected foreign peers, four independent 1 MiB streams retaining 1,024 bytes each, early detached children remaining owned, helper timeout/crash, subsequent kernel requests, sibling survival, two cooperative fixture shells trapping INT and exiting 42, hard kernel death and control EOF. Regressions caught and corrected during development include lost final output, short-circuited reader joins and the console-handler race. These are process-layer results, not a completed persistent-shell acceptance report.

The first run (https://github.com/T-Auto/dsh-ops/actions/runs/43455915383) passed all functional gates but failed the Windows probe's cooperative INT assumption. This reproduced locally under Git Bash: its inherited ignore-Ctrl+C state differed from PowerShell. A test-only wrapper now explicitly enables Ctrl+C for the positive target and protects its waiter with a non-inherited handler. Production behavior is unchanged. The corrected probe passes 13/13 under both Git Bash and PowerShell, with no survivors, retries or skipped assertions; focused Clippy, formatting, workflow checks and size checks pass.

pull_request CI passed for corrected commit 02b9368b116b317b2734a89d2151fa267189f795: https://github.com/T-Auto/dsh-ops/actions/runs/43458944117 . Every required job passed, including all four platform functional gates, Linux/Windows/macOS Clippy, Node-floor compatibility, and the real-host Windows shell probe.

Environment

Windows x64, Node 26.12.1, Rust 1.99.0 locally; CI uses the repository-pinned Rust toolchain. Base: e9068c78cac751d96ae1ebff3db65b9ae581c2f0. Public DSH packages and the frozen official Niubash 1.5.0 payload from the existing locked checkout. No published dependency or package version changes.

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.

1 participant