Skip to content

fix(shell): preserve task origin in job snapshots - #5869

Merged
1 commit merged into
Hmbown:mainfrom
zhuowp:fix/shell-task-origin-upstream
Sep 5, 2026
Merged

fix(shell): preserve task origin in job snapshots#5869
1 commit merged into
Hmbown:mainfrom
zhuowp:fix/shell-task-origin-upstream

Conversation

@zhuowp

@zhuowp zhuowp commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Problem

Background shell job snapshots and completion events do not carry stable origin identifiers. When multiple jobs exist in the same session, a host must rely on heuristics such as command text to reconcile updates, which can project an earlier job's error output onto a newer tool card.

Changes

  • Stamp the originating turn ID and tool-call ID when the Engine dispatches tools, including serial execution, ordinary parallel execution, approval context overrides, and multi_tool_use.parallel.
  • Freeze the origin when a BackgroundShell is created and preserve it through job snapshots, completion events, runtime handoffs, and evidence artifacts.
  • Use serde(default) for the new fields so payloads created before this change remain compatible.
  • Keep shell execution, permissions, output buffering, job lifecycle, and completion delivery behavior unchanged.

Verification

  • cargo fmt --all -- --check
  • cargo check -p codewhale-tui --lib --locked
  • tool_context_for_call_preserves_turn_and_sets_call_origin
  • background_shell_job_preserves_origin_identity
  • drain_finished_jobs_reports_once
  • shell_completion_status_is_concise_and_shell_handoff_is_untrusted
  • completion_evidence_preserves_arbitrary_stream_bytes

Each targeted test was executed and passed.

Signed-off-by: zhuowp <zwp-1989@qq.com>
@zhuowp
zhuowp requested a review from Hmbown as a code owner September 4, 2026 02:54
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Thanks @zhuowp for taking the time to contribute.

This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant recurring PR access by commenting /lgtm on a pull request.

@zhuowp zhuowp changed the title fix(shell): 保留后台任务来源标识 fix(shell): preserve task origin in job snapshots Sep 4, 2026
@Hmbown Hmbown closed this pull request by merging all changes into Hmbown:main in dcd4c20 Sep 5, 2026
Garfield1985 pushed a commit to Garfield1985/DeepSeek-TUI that referenced this pull request Sep 5, 2026
Background shell job snapshots and completion events carried no stable
identity for the work that created them, so a host reconciling updates had to
fall back on heuristics like matching command text. With several jobs live in
one session that mis-attributes: an earlier job's error output could land on a
newer tool card.

The fix stamps the originating turn id and tool-call id onto `ToolContext` at
dispatch, freezes them when a `BackgroundShell` is created, and carries them
through job snapshots, completion events, runtime handoffs, and evidence
artifacts. New fields are `serde(default)`, so payloads written before this
change still deserialize.

Reviewed rather than taken on the title: all three dispatch sites in
`execute_planned_tools` route through the new `tool_context_for_call` —
ordinary parallel, the serial path, and the approval-context override — so no
path can produce an unstamped context. Shell execution, permissions, output
buffering, job lifecycle, and completion delivery are untouched.

Merged as one commit authored by zhuowp; `merge-tree` was clean against main
and CI was green on the branch.

Gates: fmt CLEAN · clippy -p codewhale-tui PASS · nextest -p codewhale-tui
12007 passed / 0 failed / 13 skipped. A first run showed
`session_control_acceptance::tui_and_api_listings_agree` failing under
parallel load; it passes in isolation and the full re-run was clean, so it is
load flake, not this change.

Harvested-from: PR Hmbown#5869 by @zhuowp
Co-authored-by: zhuowp <9426526+zhuowp@users.noreply.github.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QCLLenseqfQdVaZUBqn9yG
Garfield1985 pushed a commit to Garfield1985/DeepSeek-TUI that referenced this pull request Sep 5, 2026
0.9.12 had no `### Contributors` section, `web/lib/release-credits.ts`
still held the 0.9.11 cohort, and the contributor doc band was missing
five people whose work landed. Three surfaces that must agree, disagreeing
three ways.

Everyone whose work reached main this cycle is now named in all three,
derived from `Co-authored-by` and `Harvested-from` trailers on
v0.9.11..HEAD rather than from memory. The five who were missing:

- @qiuYliangM (秋月凉梦) — co-author on Hmbown#5621, Hmbown#5622, Hmbown#5623
- @whp233Hmbown#5716, landed as Hmbown#5719
- @Gabriel-DegretHmbown#5867
- @huangxianzhanHmbown#5868
- @zhuowpHmbown#5869

@aboimpinto's entry gained Hmbown#5825 and Hmbown#5865, @M-Maciej's gained Hmbown#5533/Hmbown#5831.

`requiredCandidateCredits` in public-surface-facts.json moves from the
0.9.11 cohort to this one — that guard is meant to hold the *current*
release's credits in every surface, and it had been pinning the previous
release's.

`RELEASE_HELPERS` is deliberately empty. Every credited contribution this
cycle arrived as code that landed; a name there that no landed change can
point at would be a nicer-looking ledger and a less true one.

AUTHOR_MAP gains canonical numeric-noreply identities for all five, since
the trailers on their harvest commits used raw emails and old-style
noreply addresses.

web: 386 tests, 386 passed. check:facts, check:docs, check:tokens,
check:locales all PASS.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QCLLenseqfQdVaZUBqn9yG
@zhuowp
zhuowp deleted the fix/shell-task-origin-upstream branch September 5, 2026 12:56
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.

2 participants