AI/Tasks/HeuristicsUpgrades/Heuristics_Phase06_FinalIntegration_TestPlan_Strict.txt

STRICT MODE: Merge the heuristics changes and produce the final test plan.
 
Mission:
- Complete this phase with bounded steps and deterministic fallback behavior.
- Apply changes ONLY within the final integration surfaces for the heuristics subsystem.
 
Concrete scope:
- AI/Tasks/HeuristicsUpgrades/Heuristics_Phase06_FinalIntegration_TestPlan_Strict.txt
- Unified scoring model, updated tool routing logic, updated fallback logic, updated strict-mode boundaries, full test plan, validation gates, and acceptance criteria for the heuristics subsystem.
 
Requirements:
- Merge all heuristics changes into one unified scoring model.
- Merge the pattern, cost, session, and clarification layers into a coherent routing flow.
- Produce updated tool-routing logic that respects the full heuristics stack.
- Produce updated fallback logic for unsafe, ambiguous, or low-confidence cases.
- Produce updated strict-mode boundaries that preserve safety and bounded behavior.
- Produce a full test plan that covers the earlier phases and the integrated system.
- Produce validation gates and acceptance criteria that are mechanically verifiable where possible.
- Add an end-to-end decision table describing each major input class, the computational path, the safety gates, the final decision, and the expected output.
- Add invariant-based tests for the global contract: score range, clamping, default values, precedence ordering, clarification-versus-refusal behavior, tie-breaking, and safety invariants.
- Explicitly verify that the integrated system respects precedence: policy > safety > authorization/confirmation > user intent > pattern evidence > session reinforcement > cost heuristics.
- Produce a single normative end-to-end pipeline or numbered algorithm for the full heuristics flow and keep it aligned with the earlier phase contracts.
- Add negative tests that prove advisory signals (pattern, session, cost) cannot bypass any safety gate or authorization requirement.
- Include a migration or compatibility strategy that covers existing route and pattern interfaces, score semantics, and precedence behavior across phases.
- Add characterization or phase-specific tests before or alongside each major change.
- Define dependency and compatibility gates before moving beyond this phase.
- Make acceptance criteria explicit and audit-friendly.
- Do not expand beyond the heuristics subsystem unless a cross-phase dependency must be named.
- Enforce sensitive-data redaction and resource-limit checks in any diagnostics or logging introduced here.
- Do not re-open unrelated agent subsystems or transport layers in this phase.
- Explicitly prohibit the integrated heuristics stack from weakening authorization, confirmation, sandboxing, or execution safety requirements.
 
Step budget (hard limits):
1) Discovery: <= 6 read/search tool calls.
2) Edits: <= 8 file edits total.
3) Validation: 1 build + 1 targeted test run; allow exactly 1 repair cycle if failures are phase-related.
4) Stop once acceptance criteria pass.
 
Loop guards:
- If the integration pass begins to duplicate responsibilities already owned by earlier phases, stop and keep the phase boundaries explicit.
- If the final test plan expands into unrelated subsystems, stop and constrain it to heuristics.
 
Fallback behavior:
- Fallback A: merge the unified scoring model and the updated routing logic first, then attach the remaining gating and validation pieces.
- Fallback B: if full integration is too risky, produce a conservative integration plan that preserves existing behavior and clearly names the remaining deltas.
- Fallback C: after one failed repair cycle, emit FAILED_VALIDATION with the exact failing assertions.
 
Acceptance criteria:
- The heuristics subsystem has one unified scoring model and one coherent routing flow.
- Fallback logic covers unsafe, ambiguous, and low-confidence cases.
- Strict-mode boundaries remain explicit and preserved.
- The final test plan covers all six phases and the integrated system.
- The end-to-end decision table and invariant-based tests cover score range, clamping, defaults, precedence, clarification-vs-refusal behavior, tie-breaking, and safety invariants.
- Validation gates and acceptance criteria are mechanically verifiable.
- Dependency and ownership boundaries are explicit for the full heuristics set.
- Logging and diagnostics redact sensitive data and respect resource limits.
- The integrated heuristics stack does not weaken authorization, confirmation, sandboxing, or execution safety requirements.
 
Validation commands:
- dotnet build src/TechToolbox.Agent/TechToolbox.Agent.csproj -c Release
- dotnet test src/TechToolbox.Agent/Tests/TechToolbox.Agent.Tests.csproj -c Release --filter "Heuristic|Pattern|Cost|Session|Clarification|Integration|Strict"
 
Output results in markdown using this structure:
1) Summary
2) Files changed
3) Unified scoring model
4) Updated routing and fallback logic
5) Strict-mode boundaries
6) Tests added/updated
7) Validation results
8) Step-budget report (planned vs actual counts)