
eval 1
Prompt
Act as a Principal Staff Engineer. I need you to design and implement a core Python module for a distributed, dependency-aware Task Execution Engine. Here are the strict requirements: 1. The engine must accept a Directed Acyclic Graph (DAG) of tasks. Each task has a unique ID, a base priority level (1-10), and a list of dependencies. 2. Dynamic Priority Inversion Resolution: If a high-priority task (e.g., priority 9) is blocked by a low-priority task (e.g., priority 2), the engine must automatically elevate the priority of the blocking task and all of its upstream dependencies to match the high-priority task. 3. Concurrency: The engine must use `asyncio`. Tasks that have no pending dependencies should be scheduled concurrently. 4. Failure Handling: If a task fails, all downstream dependent tasks must immediately be marked as "CANCELLED", but independent branches of the DAG must continue executing. Deliverables: 1. First, write out a brief architectural reasoning document explaining how you will track state and handle the recursive priority elevation efficiently without massive overhead. 2. Provide the complete, fully typed Python code using only standard libraries. 3. Include a `__main__` block with a rigorous test case that proves the priority inversion resolution works correctly and that a failure properly cancels only the downstream tasks. Constraint: Do not use any external libraries (no `networkx`, `celery`, etc.). Your code must be production-ready, clean, and self-contained.