Skip to content

feat(resident): adapt native tasks to public Jobs - #916

Draft
Haoming9527 wants to merge 3 commits into
work/872-native-task-kernelfrom
work/872-resident-task-host
Draft

Haoming9527 wants to merge 3 commits into
work/872-native-task-kernelfrom
work/872-resident-task-host

Conversation

@Haoming9527

@Haoming9527 Haoming9527 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #872. Stacked on #915; this is an internal task/Jobs adapter, not the production fresh migration or feature closure.

What was wrong

The resident kernel's fresh-task protocol had no host adapter for existing DSH execution and Jobs contracts. A job record alone cannot authorize ordinary descendants to survive root exit, and foreground timeout must promote the existing physical task without relaunch. Registration, cancellation and owner disposal can race before a public job ID is returned.

The change

Add bounded task correlation to the existing resident connection and one activation-owned adapter keyed by exact Agent/Session identities. Every native head requires an asynchronous current-authority callback with ownership rechecks. Agent/session disposal and provider teardown stop admission and await all owned cleanup. Accepted traffic retains unknown effects until a native receipt proves otherwise; final results wait for both output streams and confirmed outer teardown after transport failure.

Adapt the existing public Jobs registry with exact explicit-background handoff, promotion arbitration, final source pumping, owner fencing and joined cancellation. Foreground waiting uses the existing public observation timer while the native hard execution cap is omitted for work intended to continue. Live byte cursors defer split UTF-8 sequences, preserve capture failures and withdraw invalidated spill metadata. No second scheduler, job registry, process wrapper or output writer is added.

The implementation plus repository probe is approximately 832 added lines, excluding tests/docs. Production fresh arguments, approval/runtime/script preparation, authority-change integration, complete spill/ledger parity and the capability-gated backend switch remain pending. Public default behavior, schema, runtime pins and dependencies remain unchanged. Bilingual docs and changelog state the internal boundary and concrete evidence.

Validation

Final targeted suites pass 44/44 checks, zero failures, zero skips: eight task-channel checks, ten execution/ownership checks, twelve real Jobs race checks and fourteen existing shell-channel checks. Rebased source builds and typechecks; the generated SDK remains 120,684 bytes. Diff and size checks pass, with every new source/test/probe file below 1000 lines.

The separate real public-host probe passes 7/7 checks across nine native task submissions and eight actual sandbox-confined launches: closed stdin and terminal tails; explicit background handoff and official Jobs controls; foreground promotion of the original physical task; cancellation during head preparation; exact Agent disposal with a usable sibling; bounded two-stream tails; and fresh stock Bash command/script argv including spaces and Chinese characters. Workspace-write confinement reports partial enforcement. Kernel PID 15456 was gone and cleanup was confirmed. This proof does not qualify stock Bash for persistent sessions or establish complete spill/public policy parity.

Exact worker SHA-256 after integrating the base's atomic owner/admission fix: 2fcf7f1d608b71fe53d121c892465bd58bf0bb04765d7ee260c441c1c58c3b2e. Fresh Bash SHA-256: 7ec3ec04ce91bae64c23d7150e6b16574e9d91df8fcf0df997006e2b37bf2f1e. Report SHA-256: 3d0c4e3831abf1e462a5838d5e1959281593a8a090a829943fb4005cc1eef1e8. The earlier report remains recorded in the bilingual docs. The first ownership assertion incorrectly expected Cordis fiber disposal to reject; the corrected regression checks the adapter's explicit disposal promise, and the original failure log is retained.

The first final-head CI run exposed an existing fixture timing bug in shells-execution: a one-millisecond deadline can correctly expire before fake spawn, but the test awaited a listener that only spawn installed, ending with Node exit 13. A deterministic pre-spawn repro retains that failure. The test now captures the deadline callback after asserting spawn and separately verifies expiry before spawn; 6/6 checks pass, with production execution unchanged. The failed run is retained at https://github.com/T-Auto/dsh-ops/actions/runs/43485247603 . Corrective head 8c0f06c19953d56dbad43ddb2cce2d7796ecfe74 passed its own pull-request CI required: https://github.com/T-Auto/dsh-ops/actions/runs/43488735893 .

Environment

Windows x64, Node 26.12.1; unchanged locked public DSH packages and official Jobs controller. Updated stack base: 672cb9f7ad4e0a4e339d407d33171097f5e15d50. No PR merge, release or deployment.

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