fix: preserve bound project paths through progress and health checkpoints
Core regression / Python core and release configuration (push) Successful in 33s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 31s
Core regression / JavaScript syntax (pull_request) Successful in 3s

This commit is contained in:
阿白叔 committed 2026-11-06 15:27:05 +08:00
1 parent 960c66b196
commit e78cdd3c97
4 files changed
+59 -3

No files matched your search

@@ -39,8 +39,10 @@ python -m pytest tests/v1_1/test_problem_workflow.py tests/v1_1/test_problem_ite
首次远端 Python 回归暴露项目键在 Linux 保留大小写、与库存及命令身份的 casefold 规则不一致,以及纯核心读取模块经 UI 包提前导入 Qt 的问题。另有一个 Qt 对话框用例混在无 Qt 的便携测试组中。
- `_path_key` 统一采用已有的大小写不敏感项目身份规则,未修改实际工程路径。
- 进度同步也使用同一项目键;源文件检查点从任务绑定工程查回实际路径读取,不把折叠的身份字符串当作文件路径。绑定缺失仍保持待核验。
- UI 包延迟导出主窗口,纯 execution_state/messages 导入不再要求 Qt;窗口的既有导出保持兼容。
- 对话框用例在有 PySide6/pytest-qt 的 Windows 环境仍执行,无依赖的便携环境明确跳过。
- 新增 `test_headless_core.py`,先复现项目键不一致和无 Qt 导入失败,再验证修复。
- 修复后的 Windows 定向回归:`test_headless_core.py`、`test_problem_workflow.py`、`tests/dsh/test_run_journal.py`、BOM 部分导入对话框用例和 `test_application.py` 共 **37 passed**,包含真实源码入口启动验证。
- 后续进度同步与源路径绑定修复后的 Windows 相关组:`test_headless_core.py`、`test_project_session_health.py`、`test_problem_workflow.py` 共 **23 passed**。覆盖源文件变化撤销放行、原生证明绑定、较新核验基线、旧轮次定向重试等保护条件。
- 独立审查未发现新的必要修复或保护放宽;远端最终结果见 PR 的最新提交状态。
@@ -405,8 +405,15 @@ class ExecutionJournal:
if healths:
from pathlib import Path
from .project_session_health import verified_source_checkpoint, health_reference
project = next((project.path for project in self.store.list_projects(attempt.task_id)
if str(canonical_path(project.path)).casefold() == command['project_path']), None)
if project is None:
raise TaskCenterError('quick_run_uncertain', '已核验源文件检查点缺少绑定的原工程路径。')
# Folded journal identities are comparison keys. Filesystem
# reads must retain the bound project's actual spelling.
source_row = dict(command, task_id=attempt.task_id, job_id=attempt.job_id, project_path=str(project))
source_checkpoint = verified_source_checkpoint(Path(self.store.path).parent / 'task-evidence' / attempt.task_id,
dict(command, task_id=attempt.task_id, job_id=attempt.job_id), attempt, proof,
source_row, attempt, proof,
[health_reference(value) for value in healths], excluded_root=healths[0]['source_excluded_root'],
native_source=proof.get('verified_source_health'))
if source_checkpoint:
@@ -1389,7 +1389,7 @@ class TaskCenterService:
)
if self._supervised:
return progress # Only the batch process persists live execution state.
by_path = {os.path.normcase(os.path.abspath(str(project.path))): project.project_id for project in projects}
by_path = {_path_key(project.path): project.project_id for project in projects}
project_by_id = {project.project_id: project for project in projects}
summary_by_id = {
by_path[_path_key(path)]: summary
@@ -1407,7 +1407,7 @@ class TaskCenterService:
completed_project_ids = tuple(
by_path[path_key]
for path in progress.completed_project_paths
if (path_key := os.path.normcase(os.path.abspath(str(path)))) in by_path
if (path_key := _path_key(path)) in by_path
and by_path[path_key] not in failed_project_ids
)
changed_project_ids = tuple(
+47
View File
@@ -4,6 +4,9 @@ from pathlib import Path
import subprocess
import sys
from types import SimpleNamespace
from threading import Event
from test_nonblocking_items import component_case
def test_windows_project_keys_remain_case_insensitive_on_portable_host(tmp_path, monkeypatch):
@@ -32,3 +35,47 @@ assert not any(name.startswith(('PySide6', 'shiboken6')) for name in sys.modules
result = subprocess.run([sys.executable, '-c', script], capture_output=True, text=True,
env=os.environ | {'PYTHONPATH': str(source)}, timeout=15)
assert result.returncode == 0, result.stderr
def test_progress_uses_same_project_keys_as_the_execution_queue(component_case, monkeypatch):
from dx_productivity.trial_task_center import quick_run
from dx_productivity.trial_task_center.task_queue import execute_task_queue
monkeypatch.setattr(quick_run.os.path, 'normcase', lambda path: path)
service, _, tasks, _, outcomes = component_case
task_id = tasks[0].task_id
outcomes[(task_id, ('R1',))] = 'batch_failed'
result = execute_task_queue(service, (task_id,), stop_event=Event())
assert not result.paused
progress = service.quick_run_progress(task_id)
assert progress.queue_complete and progress.failed_items == progress.saved_items == 1
def test_source_checkpoint_reads_the_original_project_spelling(component_case, monkeypatch):
from dx_productivity.trial_task_center import project_session_health
from dx_productivity.trial_task_center.task_queue import execute_task_queue
service, _, tasks, _, outcomes = component_case
task_id = tasks[0].task_id
project = str(service.projects(task_id)[0].path)
assert project != project.casefold()
original = project_session_health.verified_source_checkpoint
reads = []
def checkpoint(data_root, row, *args, **kwargs):
reads.append(row['project_path'])
assert str(row['project_path']) == project
return original(data_root, row, *args, **kwargs)
monkeypatch.setattr(project_session_health, 'verified_source_checkpoint', checkpoint)
outcomes[(task_id, ('R1',))] = 'batch_failed'
def saved(count):
if count != 2:
return
from dx_productivity.trial_task_center.execution_journal import read_command_rows
from dx_productivity.trial_task_center.quick_run import _encode_vbs_field
root = service.for_project_task(task_id)._quick_run_preparer.data_root / 'quick-run'
row = read_command_rows(root / 'current-command.tsv')[0]
fields = ('job_id', 'project_path', 'schematic_name', 'sheet_number', 'semantic_state')
values = (row['job_id'], project, 'MAIN', '1', 'S\tfull_sheet_v1\r\nverified R2')
(root / ('post-state-' + row['job_id'] + '.tsv')).write_text('\t'.join(fields) + '\n' +
'\t'.join(_encode_vbs_field(value) for value in values) + '\n', encoding='utf-8')
outcomes['after_call'] = saved
result = execute_task_queue(service, (task_id,), stop_event=Event())
assert not result.paused and reads == [project]