## 1. Run State Primitives - [x] 1.1 Implement structurally immutable RunContext with explicit identity, deadline, cancellation, budget, retry policy, and lifecycle handles. - [x] 1.2 Implement first-reason-wins cancellation with resource callbacks and first-terminal-wins Run lifecycle. - [x] 1.3 Add Run identity, cancellation, and terminal race tests with a controlled Clock. ## 2. Budget and Capacity - [x] 2.1 Implement validated caller-supplied RunBudgetLimits and thread-safe Model/Tool/per-Tool/Token accounting. - [x] 2.2 Implement atomic single-Run byte capacity reservation with no partial update on rejection. - [x] 2.3 Add budget tests for consistent counters, actual Token recording, concurrent reservations, and exhaustion details. ## 3. Harness Core - [x] 3.1 Implement DiagnosisHarnessCore Run creation, active/deadline checks, budget gates, explicit cancellation, and success/failure completion. - [x] 3.2 Add Fake Model/Tool tests proving explicit synchronous/asynchronous RunContext propagation and cancellation/deadline/budget terminal outcomes. ## 4. Retry Boundary - [x] 4.1 Implement typed RetryFailure, bounded RetryPolicy, strict HarnessRetryPolicies, RetryAttempt, and RetryExecutionException. - [x] 4.2 Implement HarnessRetryExecutor with per-attempt active checks and attempt recording, without backoff, recursion, or hidden loops. - [x] 4.3 Add Fake Router/Tool/SemanticGuard retry tests for allowed technical retry, one-attempt policies, cancellation between attempts, and non-retryable outcomes. ## 5. Tool Store Foundations - [x] 5.1 Implement configurable ToolCallKeyFactory with exact framework ID preservation and safe-segment validation. - [x] 5.2 Add key factory tests covering exact key format, blank/unsafe/oversized segments, and no generated fallback ID. ## 6. Hidden Retry Configuration - [x] 6.1 Set `spring.ai.retry.max-attempts` to 1 without changing Model routing or provider configuration. - [x] 6.2 Add a focused YAML configuration test proving the hidden Spring AI retry override. ## 7. Verification - [x] 7.1 Run focused Harness Core, retry, budget, key/capacity, and retry configuration tests. - [x] 7.2 Run stage 0/1 Harness and ACI contract tests plus existing ChatController test as regression coverage. - [x] 7.3 Verify new production code has no ThreadLocal/current-holder usage and current Chat/AIOps/Controller/JPA/Redis call sites remain unchanged.