Skip to content

feat(runtime): define managed child process contract - #903

Closed
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/managed-child-process-contract
Closed

feat(runtime): define managed child process contract#903
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/managed-child-process-contract

Conversation

@luoye520ww

Copy link
Copy Markdown
Collaborator

Problem

Shell, LSP, Whisper, extension host, and subagent processes need one bounded lifecycle record before they can share shutdown, cancellation, and crash-recovery handling.

Root cause

The existing background shell record describes a user-facing session, but there is no cross-module contract for the actual OS child process. Reusing that record for process cleanup would mix business state with process ownership.

Scope

This PR defines and tests the shared ManagedChildProcess contract only. It does not register or terminate processes yet.

Changes

  • Add strict Zod validation for process identity, owner, PID, start time, detach state, and cleanup policy.
  • Bound identifiers and reject unknown fields so commands, environment values, and secrets cannot be smuggled into the lifecycle record.
  • Default cleanup to terminating the process tree; explicit preserve remains available for detached owners such as extension hosts.

Safety

  • No command line, environment, token, path, or raw process output is stored.
  • PID and timestamp inputs are validated and unknown fields are rejected.
  • Runtime integration and platform-specific termination remain follow-up PRs with their own lifecycle tests.

Typecheck

npm.cmd run typecheck

Passed.

Tests

npm.cmd exec vitest run src/shared/managed-child-process.test.ts
npm.cmd run lint
npm.cmd run build
git diff --check

Passed: 3 contract tests; root lint and build passed; diff check passed.

Review performed

  • Functional correctness
  • Architecture and ownership boundaries
  • Concurrency/lifecycle field semantics
  • Data and secret safety
  • Cross-platform compatibility of the contract
  • Test quality and PR scope

Non-goals

  • Process registry storage
  • Shell/LSP/Whisper/extension-host/subagent integration
  • Platform-specific process-tree termination

Follow-ups

The registry and runtime integration should land as separate PRs after this contract is reviewed.

@luoye520ww

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated tool/process lifecycle PR #946, which passed Typecheck, Linux, macOS, and Windows packaged checks. Closing this duplicate to keep the review surface focused.

@luoye520ww luoye520ww closed this Jul 14, 2026
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