改动 / #3663

#3663 [TUI] preserve log config and add indexed log rotation on launch

open · draft · @TalenMud · 0 评论 · 去 GitHub 看

AMD / HIPNVIDIA / CUDAWindows

说明

<!--
Read CONTRIBUTING.md first. Lead with the problem and the result, not a file-by-file list.
Placeholders below are not test results: replace them with what you observed, or write "none".
-->

## Problem and result
- Trigger: Repeatedly invoking the TUI launcher unconditionally clobbered the previous run's log file under `%LOCALAPPDATA%` and overwrote the user-defined `log` path stored in the persistent configuration.

- Before: Starting a new session caused immediate diagnostic loss of previous run logs due to an unindexed overwrite, while also resetting custom configuration paths.

- After: The launcher preserves existing run logs using an indexed backup scheme (`.log.1`, `.log.2`, up to a 5-file cap) prior to opening a new session log, and leaves user-specified `log` paths in the configuration file intact.


## Related discussion
- Issue: Closes #3656

- Maintainer agreement on scope: Focused bugfix and CLI harness hygiene; keeps rotation bounded to 5 files to prevent disk sprawl without altering core engine telemetry.


## Approach
- Inspected the launcher startup sequence where log destinations and config paths are initialized. *(TODO)*

- Added a pre-launch rotation check: if an active log file already exists at the target path, existing indexed copies are shifted up sequentially (e.g. `.log.4` -> `.log.5`, `.log.1` -> `.log.2`), any file exceeding the 5-log cap is pruned, and the current log is moved to `.log.1`. *(TODO)*

- Guarded the configuration serializer to prevent ephemeral launcher arguments from overwriting the explicit persistent `log` key in the user's config file. *(TODO)*


## Validation

**Passed:**
- `python -m pytest tests/test_tui_launcher.py` (or your repo test command): all tests passed, 0 failures. *(TODO)*

- Manual reproduction on commit `<YOUR_COMMIT_HASH>` (Windows / `<YOUR_OS>`): *(TODO)*

  - Ran `strata launch` 3 consecutive times with test prompts. *(TODO)*
  - Inspected `%LOCALAPPDATA%/Strata/logs/`: confirmed creation of `session.log`, `session.log.1`, and `session.log.2` containing distinct invocation timestamps and process traces. *(TODO)*
  - Verified `config.json` retained custom `"log": "custom/path.log"` across invocations. *(TODO)*

**Failed:**
none observed *(TODO: verify during testing)*

**Not run:**
- Engine-level backend compilation (CUDA, HIP, SYCL) and model tensor execution; this change is isolated strictly to the TUI launch script and configuration file handling.


## Limits
- Log rotation cap is fixed at 5 files; does not introduce a CLI flag or configuration setting to customize the rotation depth.

本站相关内容

相关页面的快捷入口。