fix: harden supervised replacement and missing uid handling

This commit is contained in:
阿白叔 committed 2026-10-30 16:33:10 +08:00
1 parent 656f43e2ff
commit 131b6dbbb3
30 files changed
+1655 -92

No files matched your search

@@ -0,0 +1,30 @@
# Reliable Supervision Design
## Goal
Make batch execution diagnosable and recoverable when the worker crashes, exits without a result, loses its transport channel, or is forcibly stopped.
## Scope
This change covers the supervisor/worker protocol, durable lifecycle evidence, forced-stop precedence, and Windows process/resource diagnostics. It does not change replacement business rules or UI layout.
## Design
The worker writes an append-only lifecycle journal and atomically commits its final result. The supervisor records child exit status and bounded stdout/stderr evidence before interpreting the result. Missing result files become a typed failure that preserves the original lifecycle state and never authorizes automatic replay.
Lifecycle entries and output tails are supplemental diagnostics. Failure to write them must not erase a committed business result or forced-stop outcome. The existing strict supervisor ownership journal and uncertainty markers continue to authorize/block operations; supplemental logs never do.
Forced termination is an explicit state machine. The supervisor persists the forced intent and uncertainty protection before terminating the owned Job Object. Protection or termination errors remain visible as blocked states; they cannot be replaced by a generic transport error.
The Windows launcher continues to use suspended creation, Job Object assignment, and resume, but records assignment and membership evidence. Cleanup reports success only after process identity, Job accounting, desktop handles, and release records all agree.
Investigation identified a current-interpreter venv redirector rather than a broken desktop release algorithm. Only non-frozen launches of the current venv interpreter use the base interpreter with its child-local venv identity. Retain existing strict identity admission and desktop release checks. Atomic Job assignment at process creation is deferred as a separate change; externally killing the creator between suspended creation and Job assignment remains outside this iteration's guarantee.
## Acceptance criteria
1. Every worker attempt has a durable lifecycle record even when it exits before producing a result.
2. A missing or malformed result reports a typed diagnostic containing exit code and captured stderr/stdout evidence.
3. Forced stop reports `user_forced_stop` after confirmed termination and remains blocked with a retryable diagnostic when confirmation fails.
4. No failure path automatically reruns a write operation.
5. Windows tests cover worker crash, missing result, callback failure, forced-stop retry, orphan descendants, and resource-release mismatch.
6. Existing UI and business tests remain green.