chore(conductor): Enhance all 6 backlog tracks to Surgical Spec Protocol
This commit is contained in:
@@ -1,10 +1,31 @@
|
||||
# Implementation Plan: Concurrent Tier Isolation
|
||||
# Implementation Plan: Concurrent Tier Source Isolation (concurrent_tier_source_tier_20260302)
|
||||
|
||||
## Phase 1: Thread-Local Storage
|
||||
## Phase 1: Thread-Local Context Refactoring
|
||||
- [ ] Task: Initialize MMA Environment `activate_skill mma-orchestrator`
|
||||
- [ ] Task: Replace `current_tier` with `threading.local()`.
|
||||
- [ ] Task: Conductor - User Manual Verification 'Phase 1'
|
||||
- [ ] Task: Refactor `ai_client` to `threading.local()`
|
||||
- [ ] WHERE: `ai_client.py`
|
||||
- [ ] WHAT: Replace `current_tier = None` with `_local_context = threading.local()`. Implement safe getters/setters for the tier.
|
||||
- [ ] HOW: Use standard `threading.local` attributes.
|
||||
- [ ] SAFETY: Provide defaults (e.g., `getattr(_local_context, 'tier', None)`) so uninitialized threads don't crash.
|
||||
- [ ] Task: Update Lifecycle Callers
|
||||
- [ ] WHERE: `multi_agent_conductor.py`, `conductor_tech_lead.py`
|
||||
- [ ] WHAT: Update how they set the current tier around `send()` calls.
|
||||
- [ ] HOW: Use the new setter/getter functions from `ai_client`.
|
||||
- [ ] SAFETY: Ensure `finally` blocks clean up the thread-local state.
|
||||
- [ ] Task: Conductor - User Manual Verification 'Phase 1: Refactoring' (Protocol in workflow.md)
|
||||
|
||||
## Phase 2: Refactor & Test
|
||||
- [ ] Task: Update loggers and test with mock concurrent threads.
|
||||
- [ ] Task: Conductor - User Manual Verification 'Phase 2'
|
||||
## Phase 2: Testing Concurrency
|
||||
- [ ] Task: Write Concurrent Execution Test
|
||||
- [ ] WHERE: `tests/test_ai_client_concurrency.py` (New)
|
||||
- [ ] WHAT: Spawn two threads. Thread A sets Tier 3 and calls a mock `send`. Thread B sets Tier 4 and calls mock `send`.
|
||||
- [ ] HOW: Assert that the resulting `comms_log` correctly maps the entries to Tier 3 and Tier 4 respectively without race condition overwrites.
|
||||
- [ ] SAFETY: Use `threading.Barrier` to force race conditions in the test to ensure the isolation holds.
|
||||
- [ ] Task: Conductor - User Manual Verification 'Phase 2: Testing Concurrency' (Protocol in workflow.md)
|
||||
|
||||
## Phase 3: Final Validation
|
||||
- [ ] Task: Full Suite Validation & Warning Cleanup
|
||||
- [ ] WHERE: Project root
|
||||
- [ ] WHAT: `uv run pytest`
|
||||
- [ ] HOW: Ensure 100% pass rate.
|
||||
- [ ] SAFETY: None.
|
||||
- [ ] Task: Conductor - User Manual Verification 'Phase 3: Final Validation' (Protocol in workflow.md)
|
||||
@@ -1,8 +1,18 @@
|
||||
# Track Specification: Concurrent Tier Source Isolation
|
||||
# Track Specification: Concurrent Tier Source Isolation (concurrent_tier_source_tier_20260302)
|
||||
|
||||
## Overview
|
||||
Prepares the architecture for parallel Tier 3/4 agents by replacing the global `ai_client.current_tier` with thread-safe `threading.local()` or explicit call signatures.
|
||||
Currently, `ai_client.current_tier` is a module-level `str | None`. This works safely only because the MMA engine serializes `ai_client.send()` calls. To prepare the architecture for parallel agents (e.g., executing multiple Tier 3 worker tickets concurrently), this global state must be replaced. This track will refactor the tagging system to use thread-safe context.
|
||||
|
||||
## Architectural Constraints
|
||||
- **Thread Safety**: The solution MUST guarantee that if two threads call `ai_client.send()` simultaneously, their `source_tier` logs do not cross-contaminate.
|
||||
- **API Surface**: Prefer passing `source_tier` explicitly in the `send()` method signature over implicit global/local state to ensure functional purity, OR use strictly isolated `threading.local()`.
|
||||
|
||||
## Functional Requirements
|
||||
- Refactor `current_tier` to be thread-safe.
|
||||
- Update all logging calls to use the thread-safe context.
|
||||
- Refactor `ai_client.py` to remove the global `current_tier` variable.
|
||||
- Update `run_worker_lifecycle` and `generate_tickets` to pass the tier context directly to the AI client or into a `threading.local` context block.
|
||||
- Update `_append_comms` and `_append_tool_log` to utilize the thread-safe context.
|
||||
|
||||
## Acceptance Criteria
|
||||
- [ ] `ai_client.current_tier` global variable is removed.
|
||||
- [ ] `source_tier` tagging in `_comms_log` and `_tool_log` continues to function accurately.
|
||||
- [ ] Tests simulate concurrent `send()` calls from different threads and assert correct log tagging without race conditions.
|
||||
Reference in New Issue
Block a user