55 lines
4.2 KiB
Markdown
55 lines
4.2 KiB
Markdown
# R17: AI waits and execution admission
|
|
|
|
Scope: T3 in `2026-11-06-nonblocking-repair-checklist.md`. Adapt the applicable PR19 admission/pool changes without importing its model-readiness UI or replacing current protections.
|
|
|
|
## Behavior
|
|
|
|
- Diagnosis, reflection, issue publication/resubmission, operations history/health/experience/impact reads, ticket synchronization, and schedule preparation use application-owned independent Qt pools. They do not enter the window execution worker set.
|
|
- Operations still publish their own activity/busy state, while native execution confirmation can proceed during an operations read. Schedule preparation rechecks GUI activity before opening a confirmation or dispatching work.
|
|
- Actual retry obtains GUI admission, checks cancellation, current run identity, dirty plans, open confirmations, loading and existing execution. The runner then compares the current task context against immutable pre-model evidence before reserving any retry.
|
|
- Admission spans preparation, actual execution and verification. Explicit GUI release acknowledgement precedes reflection/publication, including when GUI release takes longer than five seconds. A timed-out acquisition cannot acquire later.
|
|
- Finishing an old diagnosis preserves a newer manual run's stop object, owner and live state. Close cancels model waiters and waits for the AI worker before releasing application resources; cancelling the window close keeps subsequent automation available. Evidence remains pending and cancellation does not start a ticket submission.
|
|
- New service integration: `reserve_problem_retry(task_id, source='dsh')` returns the exact authorized operation keys, forwarded as `prepare_failed_quick_run(task_id, operation_keys=reserved)`. An empty reservation denies execution. The old exclusive retry-budget file is used only by legacy adapters without the shared API.
|
|
|
|
## Red/green evidence
|
|
|
|
Initial test-first command:
|
|
|
|
```text
|
|
python -m pytest tests/dsh/test_incident_admission.py tests/ui/test_dsh_ai_nonblocking.py -q
|
|
10 failed, 3 errors in 22.83s
|
|
```
|
|
|
|
The expected failures showed rejected admission still executing, changed model-time context still executing, retry scope missing, cancellation unsupported, shared retry denial ignored, operations reads reserving the lane, old diagnosis clearing a new manual run, and close not waking the waiter. The errors exposed baseline Qt widget teardown during blocked diagnosis plus one fixture ordering error; fixture order and cleanup were corrected.
|
|
|
|
Initial focused green after minimal implementation:
|
|
|
|
```text
|
|
python -m pytest tests/dsh/test_incident_admission.py tests/ui/test_dsh_ai_nonblocking.py -q
|
|
13 passed in 5.58s
|
|
```
|
|
|
|
Shared reservation forwarding was independently red (`[None] != [('uid-operation',)]`), then passed in the affected regressions:
|
|
|
|
```text
|
|
python -m pytest tests/dsh/test_incidents.py tests/dsh/test_incident_admission.py tests/ui/test_dsh_ai_nonblocking.py tests/ui/test_dsh_operations.py tests/ui/test_dsh_native_menu.py tests/ui/test_dsh_task_lifecycle.py -q
|
|
79 passed in 55.62s
|
|
```
|
|
|
|
Final concurrency review added targeted red cases: empty shared reservation incorrectly left `retry_budget_available=True`; delayed GUI release let reflection start before acknowledgement (`1 failed in 7.73s`); cancelled close left idle/finished automation permanently closing (`2 failed`). These justify only the subsequent focused rerun, not repeating the 79-test regression set.
|
|
|
|
Final focused verification after those fixes and Qt fixture cleanup:
|
|
|
|
```text
|
|
python -m pytest tests/dsh/test_incident_admission.py tests/ui/test_dsh_ai_nonblocking.py -q
|
|
17 passed in 17.85s
|
|
git diff --check
|
|
exit 0 (no output)
|
|
```
|
|
|
|
## Limits
|
|
|
|
Tests use real Qt worker scheduling, controlled model waiters and service doubles, plus the existing UI SQLite/service fixtures. No real AI, remote ticket creation, CAD, PCB or redundant full suites were run. The shared retry API is supplied by T1 and needs the parent task's integration verification with actual per-operation journals. A ticket request already in progress must finish or hit its existing network timeout before close completes; it does not reserve task execution while waiting.
|
|
|
|
`src/dx_productivity/dsh/task_lifecycle.py` and the UI lifecycle controller were not changed.
|