[PR #4197] [Engine] preserve native ERR diagnostics in the engine log #4942

Open
opened 2026-11-07 16:31:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4197
Author: @wujian47
Created: 10/26/2026
Status: 🔄 Open

Base: main ← Head: codex/persist-native-engine-errors


📝 Commits (1)

  • e8b7a7c [Engine] preserve native ERR diagnostics in the engine log

📊 Changes

2 files changed (+78 additions, -0 deletions)

View changed files

📝 serve/server.py (+8 -0)
➕ serve/test_engine_error_log.py (+70 -0)

📄 Description

Problem and result

Native ERR diagnostics arrive on stdout's protocol pipe, while only stderr is connected to the engine log. After an engine exit/restart, the native failure line can therefore be absent from the persistent log needed to diagnose the failure.

Write each ERR line to that process's engine log before fatal handling and batch routing. Token and completion protocol lines are not copied into the log.

Searched open and closed PRs for native ERR logging. #1183 concerns releasing batch control after a terminal ERR; this patch preserves that behavior and only adds diagnostic persistence. No new setting, default change or native-engine change is proposed.

Approach

Capture the process's existing log alongside its stdout reader, so an old pump cannot write into its successor's log after restart. Flush ERR diagnostics immediately. A closed or failed log write must not prevent fatal termination, protocol delivery or EOF cleanup.

Validation

Windows 11 x64, Python 3.12.0rc3, psutil 7.2.2 (the version pinned by requirements.txt). Base 4b9e05a2a806a3fe24f7b2560d98626c37dade35; tested candidate e8b7a7cc71e19e924a02e2acdad51570bd0814df (the committed tree is the tree tested).

Passed:

python -m unittest serve.test_engine_error_log serve.test_fatal_recovery serve.test_lifecycle serve.test_lifeline serve.test_restart_waiters serve.test_ready_timeout -q
# Ran 41 tests in 36.133s; OK (skipped=4)
git diff HEAD^ HEAD --check

The four new tests check diagnostic persistence without token logging, logging before fatal termination, old-pump/new-log isolation, and EOF cleanup with missing/disabled/closed logs. Existing fatal recovery, lifecycle and restart tests remain green. The expanded run emitted an existing fixture ResourceWarning about an unclosed stdout wrapper; it completed successfully.

Failed:

On the unpatched base, python -m unittest serve.test_engine_error_log -v produced three expected assertion failures because ERR lines were absent from the log. The patched four-test run passed.

An initial expanded run had one FileNotFoundError in test_the_child_is_recorded_while_it_runs_and_forgotten_after; the same test also failed without this log patch. The local virtual environment lacked psutil, so Windows command_line() returned None and no process record was written. Installing the repository-pinned psutil resolved that failure; the identical 41-test command above then passed. No code outside the log fix was changed to address it.

Not run:

GPU/model inference on this current-main candidate, other operating systems and full repository discovery. These Python-only changes do not modify a native backend; CUDA/HIP/SYCL/Metal builds were not run for this PR.

Limits

This preserves diagnostics for investigation. It does not fix an underlying native-engine failure or guarantee persistence when the filesystem cannot accept the write. Separate older-version hardware backports are not presented as tests of this PR head.

Prepared and reviewed with OpenAI coding assistants; the commands and reported outcomes were checked against actual output.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4197 **Author:** [@wujian47](https://github.com/wujian47) **Created:** 10/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/persist-native-engine-errors` --- ### 📝 Commits (1) - [`e8b7a7c`](https://github.com/Niko1221/Strata/commit/e8b7a7cc71e19e924a02e2acdad51570bd0814df) [Engine] preserve native ERR diagnostics in the engine log ### 📊 Changes **2 files changed** (+78 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+8 -0) ➕ `serve/test_engine_error_log.py` (+70 -0) </details> ### 📄 Description ## Problem and result Native ERR diagnostics arrive on stdout's protocol pipe, while only stderr is connected to the engine log. After an engine exit/restart, the native failure line can therefore be absent from the persistent log needed to diagnose the failure. Write each ERR line to that process's engine log before fatal handling and batch routing. Token and completion protocol lines are not copied into the log. ## Related discussion Searched open and closed PRs for native ERR logging. #1183 concerns releasing batch control after a terminal ERR; this patch preserves that behavior and only adds diagnostic persistence. No new setting, default change or native-engine change is proposed. ## Approach Capture the process's existing log alongside its stdout reader, so an old pump cannot write into its successor's log after restart. Flush ERR diagnostics immediately. A closed or failed log write must not prevent fatal termination, protocol delivery or EOF cleanup. ## Validation Windows 11 x64, Python 3.12.0rc3, psutil 7.2.2 (the version pinned by requirements.txt). Base `4b9e05a2a806a3fe24f7b2560d98626c37dade35`; tested candidate `e8b7a7cc71e19e924a02e2acdad51570bd0814df` (the committed tree is the tree tested). **Passed:** ```sh python -m unittest serve.test_engine_error_log serve.test_fatal_recovery serve.test_lifecycle serve.test_lifeline serve.test_restart_waiters serve.test_ready_timeout -q # Ran 41 tests in 36.133s; OK (skipped=4) git diff HEAD^ HEAD --check ``` The four new tests check diagnostic persistence without token logging, logging before fatal termination, old-pump/new-log isolation, and EOF cleanup with missing/disabled/closed logs. Existing fatal recovery, lifecycle and restart tests remain green. The expanded run emitted an existing fixture ResourceWarning about an unclosed stdout wrapper; it completed successfully. **Failed:** On the unpatched base, `python -m unittest serve.test_engine_error_log -v` produced three expected assertion failures because ERR lines were absent from the log. The patched four-test run passed. An initial expanded run had one FileNotFoundError in `test_the_child_is_recorded_while_it_runs_and_forgotten_after`; the same test also failed without this log patch. The local virtual environment lacked psutil, so Windows `command_line()` returned None and no process record was written. Installing the repository-pinned psutil resolved that failure; the identical 41-test command above then passed. No code outside the log fix was changed to address it. **Not run:** GPU/model inference on this current-main candidate, other operating systems and full repository discovery. These Python-only changes do not modify a native backend; CUDA/HIP/SYCL/Metal builds were not run for this PR. ## Limits This preserves diagnostics for investigation. It does not fix an underlying native-engine failure or guarantee persistence when the filesystem cannot accept the write. Separate older-version hardware backports are not presented as tests of this PR head. Prepared and reviewed with OpenAI coding assistants; the commands and reported outcomes were checked against actual output. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4942
No description provided.