feat: add frozen project context and isolated worker boundary

This commit is contained in:
阿白叔 committed 2026-10-14 15:32:55 +08:00
1 parent 4f457b1e88
commit 855af0bd12
7 files changed
+430

No files matched your search

@@ -0,0 +1,50 @@
# Task 1 report: single-project context and isolated worker
Implemented the backend portion of the single-project workflow without starting
CAD, packaging, or modifying project files.
## Public API
`TaskCenterService.task_context(task_id: str) -> ProjectTaskContext` returns a
cached immutable context for UI refreshes. `TaskCenterService.refresh_bound_project(task_id:
str) -> ProjectTaskContext` rereads the task and its bound project from SQLite,
without scanning a directory or attaching COM. A bound task must have one
`primary_project_id` and exactly one project. Historical tasks without that
binding remain available through `task_context` with `legacy=True` and
`project=None`; `refresh_bound_project` rejects them so new execution cannot
accidentally mutate a multi-project record.
`ProjectTaskContext` fields are:
```python
ProjectTaskContext(
task, project, rules, targets, progress, phase,
has_evidence, interrupted, legacy
)
```
The target plan is authoritative for target-plan tasks. An empty or fully
disabled plan produces zero queued items and never falls back to broad mapping
rules.
`IsolatedDesktopWorker` is an opt-in research boundary. Its request contract is
`IsolatedWorkerRequest(protocol_version, task_id, project_path, target_uids,
plan_hash, allow_writes=False)`. `run()` rejects the default disabled mode,
rejects unrelated existing CAD identity, rejects write enablement, and emits
versioned `request.json`/`evidence.json` files when an evidence root is given.
It does not attach COM or launch CAD.
`PrivateDesktop` owns the Windows desktop handle and processes started with
`STARTUPINFO.lpDesktop`; launch fails when no private desktop was created, so
there is no input-desktop fallback. Cleanup terminates only processes created by
the worker and closes the owned desktop handle.
## Verification
- `tests/v1_1/test_project_context.py` and `test_isolated_desktop.py`: **6 passed**.
- Existing target/quick-run checks (`test_service_target_integration.py`,
`test_target_execution.py`): **8 passed**.
- Python bytecode compilation passed for all changed backend modules.
The private desktop path remains research-only until a native DxDesigner build
is validated on a disposable project; no production write claims are made.