From cf671a1d3f85cc7521e7c9575fd8db2bad748ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E7=99=BD=E5=8F=94?= <11794527+absfan@user.noreply.gitee.com> Date: Mon, 19 Oct 2026 15:11:27 +0800 Subject: [PATCH] perf(catalog): share verified cell cache across task execution and UI --- src/dx_productivity/trial_task_center/native_helper.py | 9 ++++++++- src/dx_productivity/trial_task_center/recovery.py | 5 +++-- tests/v1_1/test_target_cell_execution.py | 10 ++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/dx_productivity/trial_task_center/native_helper.py b/src/dx_productivity/trial_task_center/native_helper.py index d87c164..3cd22aa 100644 --- a/src/dx_productivity/trial_task_center/native_helper.py +++ b/src/dx_productivity/trial_task_center/native_helper.py @@ -74,12 +74,19 @@ def snapshot_target_cell(path, *, required=True): return value +def cell_catalog_evidence_root(snapshot): + root = Path(snapshot).resolve().parent.parent + if root.parent.name.casefold() == "tasks": + root = root.parent.parent + return root / "cell-catalog" + + def target_cell_catalog(app, snapshot, metadata, selected): raw_path = str(app.GetProjectData().CentralLibraryPath) library = Path(raw_path) if not raw_path.strip() or not library.is_absolute(): raise ValueError("Active project has no absolute central library path for Cell validation") - return cell_catalog_binding(library, metadata[3], selected, Path(snapshot).parent.parent / "cell-catalog") + return cell_catalog_binding(library, metadata[3], selected, cell_catalog_evidence_root(snapshot)) def cell_catalog_binding(library, part_number, selected, evidence_root): diff --git a/src/dx_productivity/trial_task_center/recovery.py b/src/dx_productivity/trial_task_center/recovery.py index 3d6912d..e8e97c8 100644 --- a/src/dx_productivity/trial_task_center/recovery.py +++ b/src/dx_productivity/trial_task_center/recovery.py @@ -12,7 +12,8 @@ import subprocess from uuid import uuid4 from .errors import TaskCenterError -from .native_helper import read_snapshot, require_resumable_transaction, snapshot_target_cell, cell_catalog_binding +from .native_helper import (read_snapshot, require_resumable_transaction, snapshot_target_cell, + cell_catalog_binding, cell_catalog_evidence_root) from .quick_run import ( TERMINAL_STATES, IDLE_PROGRESS_TIMEOUT_SECONDS, QuickRunStepResult, _native_helper_launch_arguments, _next_unfinished_command, _path_key, @@ -90,7 +91,7 @@ def require_current_cell_binding(snapshot, binding, project, metadata): raise ValueError('Recovery has no bound target Cell catalog') from .cell_catalog import project_library_path library = project_library_path(project) - current = cell_catalog_binding(library, metadata[3], cell, snapshot.parent.parent / 'cell-catalog') + current = cell_catalog_binding(library, metadata[3], cell, cell_catalog_evidence_root(snapshot)) if current != binding['cell_catalog']: raise ValueError('Recovery target Cell catalog has changed') return current diff --git a/tests/v1_1/test_target_cell_execution.py b/tests/v1_1/test_target_cell_execution.py index d0ad7e7..0183c10 100644 --- a/tests/v1_1/test_target_cell_execution.py +++ b/tests/v1_1/test_target_cell_execution.py @@ -138,3 +138,13 @@ WScript.Echo CStr(Failure<>0) If Failure=0 Then WScript.Echo QPTargetCell(Result("meta")) ''') assert output.splitlines()==(['True'] if fault else ['False','CELL_A']) + + +def test_cell_catalog_cache_is_shared_by_project_tasks_but_outside_queue(tmp_path): + data=tmp_path/'data' + for task in ('first','second'): + snapshot=data/'tasks'/task/'quick-run'/'snapshot-job.tsv' + snapshot.parent.mkdir(parents=True);snapshot.write_text('snapshot') + assert native_helper.cell_catalog_evidence_root(snapshot)==data/'cell-catalog' + plain=data/'quick-run'/'snapshot-job.tsv';plain.parent.mkdir();plain.write_text('snapshot') + assert native_helper.cell_catalog_evidence_root(plain)==data/'cell-catalog'