@ngocsangairvds/vsaf 3.2.13 → 3.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1441) hide show
  1. package/bin/vsaf.js +13 -0
  2. package/package.json +1 -1
  3. package/src/config.js +167 -0
  4. package/src/global.js +34 -51
  5. package/src/utils.js +44 -1
  6. package/tools/vds-scripts/Makefile +9 -31
  7. package/tools/vds-scripts/docker/docker-compose.cli.yml +1 -117
  8. package/tools/vds-scripts/docker/docker-compose.services.yml +1 -40
  9. package/tools/vds-scripts/docker/infrastructure/init-schemas.sql +0 -34
  10. package/tools/vds-scripts/docker/infrastructure/pgbouncer/pgbouncer.ini +2 -6
  11. package/tools/vds-scripts/pyproject.toml +1 -33
  12. package/tools/vds-scripts/uv.lock +80 -1651
  13. package/tools/vds-scripts/vds_cli/pyproject.toml +3 -0
  14. package/tools/vds-scripts/vds_cli/src/vds_cli/cli.py +1 -127
  15. package/tools/vds-scripts/vds_cli/src/vds_cli/commands/lint_cli.py +1 -20
  16. package/tools/vds-scripts/vds_cli/src/vds_cli/router.py +0 -100
  17. package/tools/vds-scripts/vds_cli/tests/conftest.py +0 -2
  18. package/tools/vds-scripts/vds_cli/tests/unit/test_cli.py +0 -25
  19. package/tools/vds-scripts/vds_cli/tests/unit/test_lint_cli.py +2 -2
  20. package/tools/vds-scripts/vds_cli/tests/unit/test_router.py +0 -2
  21. package/tools/vds-scripts/CLOSURE.md +0 -340
  22. package/tools/vds-scripts/ECOSYSTEM-CHANGELOG.md +0 -52
  23. package/tools/vds-scripts/ECOSYSTEM-DOCS.md +0 -602
  24. package/tools/vds-scripts/ECOSYSTEM_ALIGNMENT.md +0 -133
  25. package/tools/vds-scripts/ENV-HYGIENE-OPS-NOTE.md +0 -65
  26. package/tools/vds-scripts/INVESTIGATION-cloud-401.md +0 -103
  27. package/tools/vds-scripts/MEM0_2.0_API_REFERENCE.md +0 -238
  28. package/tools/vds-scripts/PACKAGE_P125B_IMPLEMENTATION_SUMMARY.md +0 -131
  29. package/tools/vds-scripts/PHASE-MERGE-SUMMARY.md +0 -121
  30. package/tools/vds-scripts/PHASES-3-ARCHIVE.md +0 -59
  31. package/tools/vds-scripts/PROJECT_COMPLETION_SUMMARY.md +0 -45
  32. package/tools/vds-scripts/SEARCH-CRASH-REPRO.md +0 -51
  33. package/tools/vds-scripts/analyze_hexagonal.py +0 -217
  34. package/tools/vds-scripts/analyze_profiles.py +0 -60
  35. package/tools/vds-scripts/audit-checklist.xlsx +0 -0
  36. package/tools/vds-scripts/audit_orchestrator/.audit_approvals/approvals_index.json +0 -1
  37. package/tools/vds-scripts/audit_orchestrator/.env.example +0 -85
  38. package/tools/vds-scripts/audit_orchestrator/.github/workflows/audit.yml +0 -47
  39. package/tools/vds-scripts/audit_orchestrator/Dockerfile +0 -92
  40. package/tools/vds-scripts/audit_orchestrator/GOOGLE_SHEETS_IMPLEMENTATION_SUMMARY.md +0 -218
  41. package/tools/vds-scripts/audit_orchestrator/PHASE3_INTEGRATION_SUMMARY.md +0 -268
  42. package/tools/vds-scripts/audit_orchestrator/PHASE7-MERGE-SUMMARY.md +0 -174
  43. package/tools/vds-scripts/audit_orchestrator/README.md +0 -1573
  44. package/tools/vds-scripts/audit_orchestrator/TSK-168-IMPLEMENTATION-SUMMARY.md +0 -191
  45. package/tools/vds-scripts/audit_orchestrator/TSK-196-IMPLEMENTATION-SUMMARY.md +0 -201
  46. package/tools/vds-scripts/audit_orchestrator/alembic/env.py +0 -37
  47. package/tools/vds-scripts/audit_orchestrator/alembic/script.py.mako +0 -28
  48. package/tools/vds-scripts/audit_orchestrator/alembic/versions/0001_initial_audit_state_schema.py +0 -1260
  49. package/tools/vds-scripts/audit_orchestrator/alembic.ini +0 -68
  50. package/tools/vds-scripts/audit_orchestrator/config/category-mapping.json +0 -81
  51. package/tools/vds-scripts/audit_orchestrator/config/profile-timeouts.yaml +0 -17
  52. package/tools/vds-scripts/audit_orchestrator/create_sample.py +0 -55
  53. package/tools/vds-scripts/audit_orchestrator/data/corpus_accuracy_report.json +0 -17
  54. package/tools/vds-scripts/audit_orchestrator/data/exemplar_quality_report.json +0 -1606
  55. package/tools/vds-scripts/audit_orchestrator/data/instruction_plan_fixtures.json +0 -163
  56. package/tools/vds-scripts/audit_orchestrator/data/requirement_exemplars.json +0 -3443
  57. package/tools/vds-scripts/audit_orchestrator/data/requirement_scope_fixtures.json +0 -172
  58. package/tools/vds-scripts/audit_orchestrator/debug_rg.py +0 -46
  59. package/tools/vds-scripts/audit_orchestrator/demo_code_pack.py +0 -127
  60. package/tools/vds-scripts/audit_orchestrator/docs/AGENT_SDK_SELECTION_SPEC.md +0 -720
  61. package/tools/vds-scripts/audit_orchestrator/docs/API.md +0 -804
  62. package/tools/vds-scripts/audit_orchestrator/docs/CONTENT_ANALYSIS_APPROACH.md +0 -1041
  63. package/tools/vds-scripts/audit_orchestrator/docs/CONTENT_SCORING_EVOLUTION_SPEC.md +0 -868
  64. package/tools/vds-scripts/audit_orchestrator/docs/DEPLOYMENT.md +0 -778
  65. package/tools/vds-scripts/audit_orchestrator/docs/LLM_AGENT_AUDIT_SPEC.md +0 -721
  66. package/tools/vds-scripts/audit_orchestrator/docs/LLM_CONTENT_ANALYSIS_SPEC.md +0 -1143
  67. package/tools/vds-scripts/audit_orchestrator/docs/LSP_SETUP_GUIDE.md +0 -221
  68. package/tools/vds-scripts/audit_orchestrator/docs/MULTI_REPO_AUDIT_SPEC.md +0 -951
  69. package/tools/vds-scripts/audit_orchestrator/docs/OLLAMA_EMBEDDINGS_SETUP.md +0 -119
  70. package/tools/vds-scripts/audit_orchestrator/docs/PHASE32_REAL_BENCHMARK_2026-02-08.md +0 -66
  71. package/tools/vds-scripts/audit_orchestrator/docs/PHASE_64_TO_92_HISTORICAL_SPEC.md +0 -1772
  72. package/tools/vds-scripts/audit_orchestrator/docs/TSK-193-flow-trace.md +0 -201
  73. package/tools/vds-scripts/audit_orchestrator/docs/TSK-193-verification.md +0 -124
  74. package/tools/vds-scripts/audit_orchestrator/docs/phase152-hierarchical-query-surface.md +0 -46
  75. package/tools/vds-scripts/audit_orchestrator/examples/bitbucket_metadata_example.json +0 -50
  76. package/tools/vds-scripts/audit_orchestrator/legacy/migrations/README.md +0 -68
  77. package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase117_phase118_shared_state.sql +0 -64
  78. package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase154_published_pages.sql +0 -28
  79. package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase157_dispatch_tables.sql +0 -94
  80. package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase157_events.sql +0 -91
  81. package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase157_scope_snapshots.sql +0 -24
  82. package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase157_status_view.sql +0 -22
  83. package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase169_dispatch_observability.sql +0 -55
  84. package/tools/vds-scripts/audit_orchestrator/legacy/migrations/state_repair_hardening.sql +0 -24
  85. package/tools/vds-scripts/audit_orchestrator/pyproject.toml +0 -211
  86. package/tools/vds-scripts/audit_orchestrator/pyrightconfig.json +0 -51
  87. package/tools/vds-scripts/audit_orchestrator/pytest.ini +0 -37
  88. package/tools/vds-scripts/audit_orchestrator/reproduce_scanner.py +0 -40
  89. package/tools/vds-scripts/audit_orchestrator/scripts/README.md +0 -116
  90. package/tools/vds-scripts/audit_orchestrator/scripts/benchmark_crawl_modes.py +0 -455
  91. package/tools/vds-scripts/audit_orchestrator/scripts/benchmark_dspy.py +0 -513
  92. package/tools/vds-scripts/audit_orchestrator/scripts/benchmark_nlp_accuracy.py +0 -138
  93. package/tools/vds-scripts/audit_orchestrator/scripts/benchmark_retrieval_modes.py +0 -176
  94. package/tools/vds-scripts/audit_orchestrator/scripts/benchmark_upload_update_mode.py +0 -167
  95. package/tools/vds-scripts/audit_orchestrator/scripts/build_check.py +0 -76
  96. package/tools/vds-scripts/audit_orchestrator/scripts/check_live_progress.py +0 -61
  97. package/tools/vds-scripts/audit_orchestrator/scripts/cli_integration_test.py +0 -400
  98. package/tools/vds-scripts/audit_orchestrator/scripts/index_workspace.py +0 -178
  99. package/tools/vds-scripts/audit_orchestrator/scripts/inspect_route_conformance.py +0 -196
  100. package/tools/vds-scripts/audit_orchestrator/scripts/monitor_postgres.py +0 -145
  101. package/tools/vds-scripts/audit_orchestrator/scripts/optimize_audit.py +0 -462
  102. package/tools/vds-scripts/audit_orchestrator/scripts/verify.py +0 -673
  103. package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase111_requirement_analysis.py +0 -375
  104. package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase117_cross_repo_evidence.py +0 -77
  105. package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase121_short_circuit.py +0 -680
  106. package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase122_instruction_handling.py +0 -478
  107. package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase125_skill_integration.py +0 -832
  108. package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase_36.py +0 -394
  109. package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase_37.py +0 -58
  110. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/__init__.py +0 -17
  111. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/__init__.py +0 -29
  112. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/_langchain_warnings.py +0 -17
  113. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/agentic_investigator.py +0 -4130
  114. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/approval.py +0 -490
  115. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/audit_loop_hooks.py +0 -107
  116. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/audit_state.py +0 -50
  117. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/base.py +0 -4035
  118. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/code_agent.py +0 -667
  119. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/code_analysis_helpers.py +0 -236
  120. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/code_analysis_prompts.py +0 -146
  121. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/docs_agent.py +0 -1234
  122. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/langgraph_workflow.py +0 -2002
  123. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/pydantic_base.py +0 -1227
  124. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/requirement_analysis_agent.py +0 -593
  125. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/security_agent.py +0 -1829
  126. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/security_scanner.py +0 -686
  127. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/skill_tools.py +0 -204
  128. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/synthesis_agent.py +0 -1463
  129. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/tool_efficiency_guard.py +0 -609
  130. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/tool_registry.py +0 -3822
  131. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/__init__.py +0 -52
  132. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/evidence_corpus.py +0 -385
  133. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/filesystem.py +0 -1134
  134. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/lsp.py +0 -458
  135. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/mcp_toolset.py +0 -491
  136. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/skills_toolset.py +0 -997
  137. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/vector_evidence.py +0 -842
  138. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/usage_tracker.py +0 -682
  139. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/visualization.py +0 -303
  140. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/analyze_cmds.py +0 -892
  141. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checklist_query/__init__.py +0 -15
  142. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checklist_query/service.py +0 -171
  143. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/__init__.py +0 -20
  144. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/base.py +0 -60
  145. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/bitbucket/__init__.py +0 -6
  146. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/bitbucket/checks.py +0 -257
  147. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/confluence/__init__.py +0 -10
  148. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/confluence/checks.py +0 -78
  149. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/git/__init__.py +0 -6
  150. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/git/file_checks.py +0 -133
  151. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/llm_checks/__init__.py +0 -17
  152. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/llm_checks/api_docs_check.py +0 -80
  153. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/llm_checks/readme_check.py +0 -76
  154. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/llm_checks/security_docs_check.py +0 -78
  155. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/registry.py +0 -402
  156. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/sonarqube/__init__.py +0 -10
  157. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/sonarqube/checks.py +0 -276
  158. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/cli.py +0 -12
  159. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/cli_common.py +0 -128
  160. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/cli_impl.py +0 -9826
  161. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/clients/bitbucket_cli_client.py +0 -187
  162. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/clients/confluence_cli_client.py +0 -977
  163. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/clients/sonarqube_cli_client.py +0 -28
  164. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/__init__.py +0 -21
  165. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/base.py +0 -25
  166. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/bitbucket_downloader.py +0 -644
  167. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/bitbucket_metadata.py +0 -133
  168. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/checklist_parser.py +0 -180
  169. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/completeness/__init__.py +0 -31
  170. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/completeness/bitbucket_probe.py +0 -443
  171. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/completeness/confluence_probe.py +0 -365
  172. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/completeness/freshness_evaluator.py +0 -330
  173. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/completeness/material_completeness_service.py +0 -1079
  174. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/confluence_collector.py +0 -259
  175. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/diagram_extractor.py +0 -280
  176. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/enrichment_extractor.py +0 -200
  177. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/evidence_cache.py +0 -35
  178. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/git_collector.py +0 -148
  179. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/graphify_collector.py +0 -171
  180. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/image_extractor.py +0 -359
  181. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/linked_page_tracker.py +0 -120
  182. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/markdown_converter.py +0 -344
  183. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/material_cache.py +0 -1252
  184. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/material_downloader.py +0 -1165
  185. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/orchestrator.py +0 -168
  186. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/registry_parser.py +0 -3063
  187. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/requirements.py +0 -70
  188. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/runner.py +0 -119
  189. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/sonarqube_collector.py +0 -113
  190. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config.py +0 -1943
  191. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/__init__.py +0 -23
  192. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/discovery.py +0 -90
  193. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/environment_resolver.py +0 -56
  194. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/evidence.py +0 -78
  195. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/models.py +0 -73
  196. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/precedence.py +0 -10
  197. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/redaction.py +0 -20
  198. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/confluence_connectivity.py +0 -140
  199. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/corpus_cmds.py +0 -278
  200. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/db/__init__.py +0 -7
  201. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/db/alembic_filters.py +0 -57
  202. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/docs/__init__.py +0 -29
  203. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/docs/diataxis_validator.py +0 -687
  204. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/doctor_cmds.py +0 -3295
  205. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/dspy_modules/__init__.py +0 -5
  206. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/dspy_modules/evaluation.py +0 -301
  207. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/dspy_modules/modules.py +0 -172
  208. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/dspy_modules/runtime.py +0 -836
  209. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/dspy_modules/signatures.py +0 -406
  210. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/__init__.py +0 -192
  211. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/ad_hoc_analyzer.py +0 -399
  212. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/aggregator.py +0 -220
  213. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/auditor.py +0 -504
  214. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/batch_evidence_cache.py +0 -111
  215. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/batch_processor.py +0 -4776
  216. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/calibration.py +0 -217
  217. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/checklist_generator.py +0 -1201
  218. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/checklist_projection.py +0 -192
  219. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/checklist_scoping.py +0 -221
  220. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/checkpoint.py +0 -159
  221. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/cl003_shared_lib_guard.py +0 -194
  222. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/companion_context_service.py +0 -445
  223. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/confluence_checklist_contract.py +0 -7425
  224. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/cross_check_rules.py +0 -213
  225. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/deterministic_evaluator.py +0 -237
  226. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/drift_detector.py +0 -157
  227. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/dspy_requirement_classifier.py +0 -640
  228. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/evidence_assembler.py +0 -407
  229. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/evidence_collector.py +0 -119
  230. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/evidence_diversity.py +0 -101
  231. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/gap_analyzer.py +0 -549
  232. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/graduated.py +0 -185
  233. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/grounding_validator.py +0 -287
  234. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/instruction_analyzer.py +0 -882
  235. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/instruction_compliance.py +0 -172
  236. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/llm_row_evaluator.py +0 -9270
  237. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/loader.py +0 -1070
  238. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/manual_check_config.py +0 -136
  239. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/mapping.py +0 -269
  240. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/multi_judge.py +0 -65
  241. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/phase120_checklist_update.py +0 -416
  242. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/profile_scorer.py +0 -427
  243. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/project_evidence_context.py +0 -449
  244. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/project_knowledge_query_service.py +0 -155
  245. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/project_knowledge_store.py +0 -383
  246. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/project_topology.py +0 -1920
  247. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/provider_failure_classifier.py +0 -778
  248. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/readiness_cli_helpers.py +0 -341
  249. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/readiness_extractor.py +0 -303
  250. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/readiness_synthesizer.py +0 -730
  251. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/regression_guard.py +0 -138
  252. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/repo_type_classifier.py +0 -297
  253. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/requirement_analysis.py +0 -1433
  254. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/requirement_classification.py +0 -1725
  255. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/result_merger.py +0 -814
  256. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/route_matrix.py +0 -267
  257. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/row_evaluator.py +0 -9437
  258. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/row_evaluator_runtime.py +0 -1270
  259. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/row_evaluator_types.py +0 -2102
  260. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/rubric.py +0 -592
  261. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/scorer.py +0 -1239
  262. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/section_packs.py +0 -645
  263. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/skill_recommendation.py +0 -1183
  264. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/stability_harness.py +0 -207
  265. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/target_selector.py +0 -841
  266. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/telemetry.py +0 -347
  267. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/template_analyzer.py +0 -469
  268. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/token_tracker.py +0 -111
  269. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/tool_first_planner.py +0 -7905
  270. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/topology_query_service.py +0 -80
  271. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/validator.py +0 -449
  272. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/weight_policy.py +0 -464
  273. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/errors.py +0 -430
  274. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/extract_cmds.py +0 -4887
  275. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/identity.py +0 -146
  276. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/incremental/__init__.py +0 -52
  277. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/incremental/baseline.py +0 -378
  278. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/incremental/change_analyzer.py +0 -407
  279. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/incremental/delta_report.py +0 -189
  280. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/incremental/diff_detector.py +0 -301
  281. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/integrations/__init__.py +0 -3
  282. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/__init__.py +0 -50
  283. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/audit_schemas.py +0 -459
  284. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/codex_oauth.py +0 -340
  285. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/cost_tracker.py +0 -288
  286. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/engine.py +0 -751
  287. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/evaluator.py +0 -245
  288. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/__init__.py +0 -32
  289. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/api_docs_evaluation.py +0 -25
  290. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/gap_analysis.py +0 -31
  291. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/instruction_templates.py +0 -634
  292. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/readme_evaluation.py +0 -25
  293. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/row_evaluation.py +0 -247
  294. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/security_docs_evaluation.py +0 -25
  295. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/template_analysis.py +0 -25
  296. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts.py +0 -0
  297. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/provider.py +0 -626
  298. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/logging_config.py +0 -577
  299. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/mappings/__init__.py +0 -58
  300. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/mappings/default_checklist_mapping.json +0 -18
  301. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/mappings/vietnamese_checklist_mapping.json +0 -38
  302. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/misc_cmds.py +0 -4689
  303. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/__init__.py +0 -153
  304. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/calibration.py +0 -98
  305. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/checklist.py +0 -921
  306. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/completeness.py +0 -309
  307. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/enrichment.py +0 -58
  308. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/enums.py +0 -97
  309. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/evidence.py +0 -351
  310. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/findings.py +0 -381
  311. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/gaps.py +0 -299
  312. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/graph.py +0 -42
  313. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/multi_judge.py +0 -50
  314. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/readiness.py +0 -309
  315. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/registry.py +0 -386
  316. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/reporting.py +0 -32
  317. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/task.py +0 -549
  318. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/template.py +0 -477
  319. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/observability/__init__.py +0 -31
  320. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/observability/metrics.py +0 -404
  321. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/parse_cmds.py +0 -608
  322. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/pdf_cmds.py +0 -208
  323. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/performance_gates.py +0 -224
  324. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/phase151_projection.py +0 -84
  325. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/profiles/__init__.py +0 -65
  326. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/profiles/detection.py +0 -842
  327. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/profiles/models.py +0 -474
  328. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/__init__.py +0 -1
  329. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/_confluence_macros.py +0 -145
  330. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/_field_sanitizer.py +0 -25
  331. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/_table_builder.py +0 -63
  332. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/_vietnamese_templates.py +0 -103
  333. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/bitbucket_link_resolver.py +0 -34
  334. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/checklist_renderer.py +0 -483
  335. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/confluence_publisher.py +0 -3048
  336. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/hierarchy_publisher.py +0 -213
  337. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/live_data_injector.py +0 -152
  338. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/macro_builder.py +0 -101
  339. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/markdown_converter.py +0 -154
  340. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/priority_renderer.py +0 -133
  341. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/project_aggregate_renderer.py +0 -423
  342. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/readiness_renderer.py +0 -186
  343. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/system_doc_hierarchy_renderer.py +0 -382
  344. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/system_doc_renderer.py +0 -683
  345. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/report_cmds.py +0 -788
  346. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/__init__.py +0 -13
  347. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/aggregation_report.py +0 -86
  348. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/checklist_generator.py +0 -425
  349. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/excel_generator.py +0 -599
  350. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/gap_report.py +0 -131
  351. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/json_generator.py +0 -188
  352. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/markdown_generator.py +0 -595
  353. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/__init__.py +0 -154
  354. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/collector.py +0 -61
  355. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/department_builder.py +0 -77
  356. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/errors.py +0 -9
  357. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/md_renderer.py +0 -386
  358. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/pdf_models.py +0 -95
  359. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/pdf_writer.py +0 -27
  360. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/repo_project_builders.py +0 -274
  361. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/readiness_report.py +0 -447
  362. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/reporting.py +0 -94
  363. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/sarif_generator.py +0 -519
  364. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/runtime_profiles.py +0 -98
  365. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/seed/__init__.py +0 -29
  366. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/seed/seed_loader.py +0 -561
  367. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/skills/__init__.py +0 -5
  368. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/skills/skill_routing.py +0 -312
  369. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/__init__.py +0 -0
  370. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/base.py +0 -110
  371. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/bitbucket.py +0 -129
  372. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/git_url.py +0 -60
  373. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/github.py +0 -75
  374. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/local.py +0 -58
  375. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/spec_sync_validator.py +0 -15
  376. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/state/__init__.py +0 -6285
  377. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/state/readiness_helpers.py +0 -74
  378. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/state/skill_readiness.py +0 -487
  379. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/state/store.py +0 -12927
  380. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/state_cmds.py +0 -1868
  381. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sync/__init__.py +0 -0
  382. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sync/repo_sync.py +0 -409
  383. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sync_cmds.py +0 -1247
  384. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/utils/__init__.py +0 -3
  385. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/utils/debug_bundle.py +0 -214
  386. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/validators/checklist_validator.py +0 -342
  387. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflow_cmds.py +0 -19147
  388. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/__init__.py +0 -9
  389. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/_test_audit_daily_batch.py +0 -192
  390. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/audit_daily_batch.py +0 -308
  391. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/audit_deep_monthly.py +0 -193
  392. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/audit_drift_scan.py +0 -178
  393. package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/audit_security_daily.py +0 -183
  394. package/tools/vds-scripts/audit_orchestrator/templates/sample_audit_template.xlsx +0 -0
  395. package/tools/vds-scripts/audit_orchestrator/tests/__init__.py +0 -0
  396. package/tools/vds-scripts/audit_orchestrator/tests/_helpers.py +0 -32
  397. package/tools/vds-scripts/audit_orchestrator/tests/collectors/__init__.py +0 -0
  398. package/tools/vds-scripts/audit_orchestrator/tests/collectors/completeness/__init__.py +0 -0
  399. package/tools/vds-scripts/audit_orchestrator/tests/collectors/completeness/test_bitbucket_probe.py +0 -403
  400. package/tools/vds-scripts/audit_orchestrator/tests/collectors/completeness/test_confluence_probe.py +0 -423
  401. package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_bitbucket_downloader.py +0 -289
  402. package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_image_extractor.py +0 -260
  403. package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_markdown_converter.py +0 -57
  404. package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_material_cache.py +0 -197
  405. package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_material_downloader.py +0 -550
  406. package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_registry_parser.py +0 -3514
  407. package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_registry_parser_department_entry.py +0 -214
  408. package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_registry_parser_flow.py +0 -200
  409. package/tools/vds-scripts/audit_orchestrator/tests/conftest.py +0 -988
  410. package/tools/vds-scripts/audit_orchestrator/tests/engine/__init__.py +0 -0
  411. package/tools/vds-scripts/audit_orchestrator/tests/engine/test_calibration.py +0 -48
  412. package/tools/vds-scripts/audit_orchestrator/tests/engine/test_confluence_checklist_phase22_helpers.py +0 -6065
  413. package/tools/vds-scripts/audit_orchestrator/tests/engine/test_multi_judge.py +0 -62
  414. package/tools/vds-scripts/audit_orchestrator/tests/engine/test_stability_harness.py +0 -61
  415. package/tools/vds-scripts/audit_orchestrator/tests/engine/test_structured_metadata.py +0 -419
  416. package/tools/vds-scripts/audit_orchestrator/tests/factories/__init__.py +0 -0
  417. package/tools/vds-scripts/audit_orchestrator/tests/factories/models.py +0 -534
  418. package/tools/vds-scripts/audit_orchestrator/tests/factories/templates.py +0 -241
  419. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/__init__.py +0 -0
  420. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/diagrams/__init__.py +0 -0
  421. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/diagrams/compressed.drawio +0 -2
  422. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/diagrams/mockup.bmpr +0 -0
  423. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/diagrams/simple.drawio +0 -26
  424. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/__init__.py +0 -0
  425. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/bitbucket/__init__.py +0 -0
  426. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/bitbucket/branch_permissions_cli.json +0 -26
  427. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/bitbucket/branch_permissions_direct.json +0 -24
  428. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/bitbucket/repo_conditions_cli.json +0 -14
  429. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/bitbucket/repo_conditions_direct.json +0 -12
  430. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/confluence/__init__.py +0 -0
  431. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/confluence/page_cli.json +0 -7
  432. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/confluence/page_direct.json +0 -7
  433. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/confluence/search_cli.json +0 -11
  434. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/confluence/search_direct.json +0 -7
  435. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/sonarqube/__init__.py +0 -0
  436. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/sonarqube/quality_gate_cli.json +0 -12
  437. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/sonarqube/quality_gate_direct.json +0 -12
  438. package/tools/vds-scripts/audit_orchestrator/tests/fixtures/requirement_strategy_phase115.json +0 -118
  439. package/tools/vds-scripts/audit_orchestrator/tests/integration/__init__.py +0 -0
  440. package/tools/vds-scripts/audit_orchestrator/tests/integration/conftest.py +0 -107
  441. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/__init__.py +0 -0
  442. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/expected_outcomes.md +0 -50
  443. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/__init__.py +0 -0
  444. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/auth.py +0 -27
  445. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/config.py +0 -16
  446. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/db.py +0 -24
  447. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/main.py +0 -18
  448. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/src/__init__.py +0 -1
  449. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/src/utils.py +0 -22
  450. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_checklist_template.json +0 -110
  451. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/__init__.py +0 -0
  452. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/code_evidence_pack.json +0 -40
  453. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/manifest.json +0 -49
  454. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/__init__.py +0 -0
  455. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/__init__.py +0 -0
  456. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/brd.md +0 -19
  457. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/design.md +0 -32
  458. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/security.md +0 -23
  459. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/srs.md +0 -25
  460. package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/test.md +0 -30
  461. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_checkpoint_merge.py +0 -1371
  462. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_decoupling_route_p149.py +0 -176
  463. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_gap_analyzer_batch_p149.py +0 -151
  464. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_hybrid_search.py +0 -799
  465. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_mcp_integration.py +0 -741
  466. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_merge_ranking_p149.py +0 -98
  467. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_modality_mismatch_p149.py +0 -171
  468. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_phase117_118_storage.py +0 -350
  469. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_phase121_short_circuit.py +0 -732
  470. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_phase18_workflow.py +0 -223
  471. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_phase48_e2e_verification.py +0 -763
  472. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_phase81_doc_anchor_regression.py +0 -252
  473. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_provider_failure_finding_p149.py +0 -339
  474. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_readiness_e2e.py +0 -430
  475. package/tools/vds-scripts/audit_orchestrator/tests/integration/test_refined_workflow.py +0 -1180
  476. package/tools/vds-scripts/audit_orchestrator/tests/pdf/__init__.py +0 -0
  477. package/tools/vds-scripts/audit_orchestrator/tests/pdf/snapshots/__init__.py +0 -0
  478. package/tools/vds-scripts/audit_orchestrator/tests/pdf/snapshots/department_renderer.md +0 -24
  479. package/tools/vds-scripts/audit_orchestrator/tests/pdf/snapshots/project_renderer.md +0 -8
  480. package/tools/vds-scripts/audit_orchestrator/tests/pdf/snapshots/repo_renderer.md +0 -10
  481. package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_department_pdf.py +0 -112
  482. package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_e2e_pdf.py +0 -135
  483. package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_idempotency.py +0 -45
  484. package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_md_renderer.py +0 -46
  485. package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_pdf_cmds.py +0 -97
  486. package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_pdf_snapshot.py +0 -77
  487. package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_pdf_writer.py +0 -65
  488. package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_project_builder.py +0 -199
  489. package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_public_api.py +0 -135
  490. package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_repo_builder.py +0 -246
  491. package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_workflow_pdf_flags.py +0 -36
  492. package/tools/vds-scripts/audit_orchestrator/tests/property/__init__.py +0 -0
  493. package/tools/vds-scripts/audit_orchestrator/tests/property/test_properties.py +0 -807
  494. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/__init__.py +0 -0
  495. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_agent_error_compat.py +0 -38
  496. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_agentic_skill_policy_skip.py +0 -234
  497. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_base_event_stream_logging.py +0 -785
  498. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_base_timeout_policy.py +0 -277
  499. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_base_trace_payload_sanitization.py +0 -92
  500. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_code_agent.py +0 -2311
  501. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_code_agent_re_exports.py +0 -25
  502. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_code_analysis_helpers.py +0 -94
  503. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_create_audit_agent_reasoning_effort.py +0 -69
  504. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_docs_agent.py +0 -2044
  505. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_langgraph_workflow_efficiency_metrics.py +0 -71
  506. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_output_validators.py +0 -317
  507. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_phase41_toolsets.py +0 -6427
  508. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_pydantic_ai_models.py +0 -1219
  509. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_pydantic_base_url_resolution.py +0 -84
  510. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_security_agent.py +0 -2069
  511. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_skill_manager_focus.py +0 -439
  512. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_synthesis_agent.py +0 -1195
  513. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_tool_efficiency_guard_fr120.py +0 -683
  514. package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_toolsets.py +0 -716
  515. package/tools/vds-scripts/audit_orchestrator/tests/test_aggregator_p149.py +0 -171
  516. package/tools/vds-scripts/audit_orchestrator/tests/test_alembic_migrations.py +0 -287
  517. package/tools/vds-scripts/audit_orchestrator/tests/test_anchor_allowlist_p149.py +0 -273
  518. package/tools/vds-scripts/audit_orchestrator/tests/test_audit_otel.py +0 -283
  519. package/tools/vds-scripts/audit_orchestrator/tests/test_checklist_models.py +0 -583
  520. package/tools/vds-scripts/audit_orchestrator/tests/test_checks/__init__.py +0 -0
  521. package/tools/vds-scripts/audit_orchestrator/tests/test_checks/test_base_check.py +0 -211
  522. package/tools/vds-scripts/audit_orchestrator/tests/test_checks/test_llm_checks.py +0 -126
  523. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/__init__.py +0 -0
  524. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_analyze_command.py +0 -400
  525. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_archive_stale_page_cli.py +0 -217
  526. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_bitbucket_metadata_cli.py +0 -354
  527. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_cli_impl_profile_availability.py +0 -114
  528. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_codex_profile.py +0 -174
  529. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_compare_backends_cli.py +0 -449
  530. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_confluence_parent_auto_resolve.py +0 -451
  531. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_corpus_purge_cli.py +0 -290
  532. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_credentials_preflight.py +0 -106
  533. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_debug_bundle.py +0 -37
  534. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_deprecation_phase157.py +0 -484
  535. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_dispatch_concurrency_diagnostics.py +0 -758
  536. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_check_confluence_cli.py +0 -320
  537. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_codex.py +0 -187
  538. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_corpus_status_cli.py +0 -236
  539. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_correlation_cli.py +0 -128
  540. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_crawl_status_cli.py +0 -192
  541. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_credentials_cli.py +0 -86
  542. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_dispatch_status_cli.py +0 -421
  543. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_heartbeat_phase169.py +0 -173
  544. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_hierarchy_status_cli.py +0 -199
  545. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_locks_cli.py +0 -134
  546. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_logs_follow_cli.py +0 -305
  547. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_migration.py +0 -333
  548. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_profile_availability_cli.py +0 -151
  549. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_skills_policy_cli.py +0 -153
  550. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_evidence_quality_cli.py +0 -307
  551. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_export_debug_bundle_phase36.py +0 -60
  552. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_export_git_manifest_cli.py +0 -172
  553. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_file_removal_phase157e.py +0 -770
  554. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_grounding_classifier.py +0 -226
  555. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_logging.py +0 -49
  556. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_materials_cli.py +0 -9127
  557. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_metadata_completeness_phase92.py +0 -364
  558. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_parent_dispatch_finalization_phase168f.py +0 -111
  559. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_parse_cli.py +0 -590
  560. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_phase117_118_feature_flags.py +0 -219
  561. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_phase164_control_plane.py +0 -718
  562. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_phase165_runner_scripts.py +0 -230
  563. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_preparation_classifications.py +0 -146
  564. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_prepare_cli.py +0 -398
  565. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_publication_quality_gate.py +0 -126
  566. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_publish_system_doc_cli.py +0 -158
  567. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_query_checklist_cli.py +0 -219
  568. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_readiness_cli.py +0 -673
  569. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_readiness_cli_integration.py +0 -689
  570. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_removed_flags_phase92.py +0 -36
  571. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_report_cmds.py +0 -1317
  572. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_run_history_index.py +0 -57
  573. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_run_management.py +0 -1194
  574. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_runtime_profiles_cli.py +0 -1658
  575. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_smart_run_selection.py +0 -1562
  576. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_state_cli.py +0 -2467
  577. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_state_migration.py +0 -339
  578. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_sync_repos_debug_artifacts.py +0 -1109
  579. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_upload_results_cli.py +0 -809
  580. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_validate_checklist.py +0 -178
  581. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_validate_checklist_cli.py +0 -110
  582. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_validate_spec_sync_cli.py +0 -519
  583. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_default_parameters_baseline.py +0 -101
  584. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_options.py +0 -7896
  585. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_project_db_modes.py +0 -6516
  586. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_project_project_scope.py +0 -831
  587. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_project_target.py +0 -611
  588. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_projects_phase131_lifecycle.py +0 -2488
  589. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_projects_phase131_scaffolding.py +0 -96
  590. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_row_key_guard.py +0 -78
  591. package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_summary_artifacts.py +0 -1872
  592. package/tools/vds-scripts/audit_orchestrator/tests/test_cli_paths_phase2.py +0 -45
  593. package/tools/vds-scripts/audit_orchestrator/tests/test_clients/__init__.py +0 -0
  594. package/tools/vds-scripts/audit_orchestrator/tests/test_clients/test_bitbucket_cli_client.py +0 -124
  595. package/tools/vds-scripts/audit_orchestrator/tests/test_clients/test_cli_parity.py +0 -110
  596. package/tools/vds-scripts/audit_orchestrator/tests/test_clients/test_confluence_cli_client.py +0 -1149
  597. package/tools/vds-scripts/audit_orchestrator/tests/test_clients/test_sonarqube_cli_client.py +0 -19
  598. package/tools/vds-scripts/audit_orchestrator/tests/test_collectors/__init__.py +0 -0
  599. package/tools/vds-scripts/audit_orchestrator/tests/test_collectors/test_linked_page_tracker.py +0 -118
  600. package/tools/vds-scripts/audit_orchestrator/tests/test_companion_context_service.py +0 -230
  601. package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/__init__.py +0 -0
  602. package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/conftest.py +0 -11
  603. package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_compile_artifact.py +0 -465
  604. package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_cross_provider_critique.py +0 -120
  605. package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_cross_provider_critique_e2e.py +0 -75
  606. package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_evaluation.py +0 -515
  607. package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_runtime_loader.py +0 -537
  608. package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_signatures_normalization.py +0 -172
  609. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/__init__.py +0 -0
  610. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_auditor_applicability.py +0 -68
  611. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_checklist_generator.py +0 -1252
  612. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_checklist_projection.py +0 -54
  613. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_confluence_checklist_projection_consistency.py +0 -1696
  614. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_critique_merger_matrix.py +0 -120
  615. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_cross_check_rules.py +0 -459
  616. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_cross_provider_critique.py +0 -55
  617. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_doc_loader.py +0 -73
  618. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_drift_detector.py +0 -34
  619. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_evidence_collectors.py +0 -93
  620. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_lease_timeout.py +0 -114
  621. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_loader.py +0 -350
  622. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_loader_parity.py +0 -179
  623. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_low_confidence_reeval.py +0 -691
  624. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_phase145a_completion.py +0 -209
  625. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_phase31_row_consistency_retry_benchmark.py +0 -150
  626. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_profile_detector.py +0 -286
  627. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_regression_guard.py +0 -53
  628. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_result_merger.py +0 -619
  629. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_row_evaluator.py +0 -15783
  630. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_row_failover.py +0 -215
  631. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_scorer.py +0 -597
  632. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_skill_breakdown_telemetry_fr137.py +0 -421
  633. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_targeted_auto_merge.py +0 -229
  634. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_timeout_failover.py +0 -488
  635. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_timeout_telemetry.py +0 -73
  636. package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_validator.py +0 -419
  637. package/tools/vds-scripts/audit_orchestrator/tests/test_incremental/__init__.py +0 -0
  638. package/tools/vds-scripts/audit_orchestrator/tests/test_incremental/test_diff_detector.py +0 -111
  639. package/tools/vds-scripts/audit_orchestrator/tests/test_infra_persistence.py +0 -291
  640. package/tools/vds-scripts/audit_orchestrator/tests/test_integration/__init__.py +0 -0
  641. package/tools/vds-scripts/audit_orchestrator/tests/test_integration/test_phase3_integration.py +0 -516
  642. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/__init__.py +0 -0
  643. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_cache.py +0 -670
  644. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_codex_model_builder.py +0 -281
  645. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_codex_oauth.py +0 -330
  646. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_codex_streaming.py +0 -433
  647. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_cost_tracker.py +0 -27
  648. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_engine.py +0 -876
  649. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_evaluator.py +0 -212
  650. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_instruction_templates.py +0 -639
  651. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_prompt_metadata.py +0 -97
  652. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_prompts.py +0 -660
  653. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_provider.py +0 -330
  654. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_provider_contract_sync.py +0 -18
  655. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_reasoning_effort_validation.py +0 -565
  656. package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_schemas.py +0 -827
  657. package/tools/vds-scripts/audit_orchestrator/tests/test_logging_config.py +0 -297
  658. package/tools/vds-scripts/audit_orchestrator/tests/test_models/__init__.py +0 -0
  659. package/tools/vds-scripts/audit_orchestrator/tests/test_models/test_enums.py +0 -185
  660. package/tools/vds-scripts/audit_orchestrator/tests/test_models/test_findings.py +0 -1159
  661. package/tools/vds-scripts/audit_orchestrator/tests/test_models/test_project_profile.py +0 -307
  662. package/tools/vds-scripts/audit_orchestrator/tests/test_models/test_registry.py +0 -532
  663. package/tools/vds-scripts/audit_orchestrator/tests/test_models/test_template.py +0 -708
  664. package/tools/vds-scripts/audit_orchestrator/tests/test_observability/__init__.py +0 -0
  665. package/tools/vds-scripts/audit_orchestrator/tests/test_observability/test_metrics.py +0 -60
  666. package/tools/vds-scripts/audit_orchestrator/tests/test_paths_config_phase2.py +0 -21
  667. package/tools/vds-scripts/audit_orchestrator/tests/test_performance/__init__.py +0 -0
  668. package/tools/vds-scripts/audit_orchestrator/tests/test_performance/test_fr79_performance_guardrails.py +0 -199
  669. package/tools/vds-scripts/audit_orchestrator/tests/test_phase156_hardening.py +0 -498
  670. package/tools/vds-scripts/audit_orchestrator/tests/test_phase93_regression_guards.py +0 -123
  671. package/tools/vds-scripts/audit_orchestrator/tests/test_pipeline_integration.py +0 -517
  672. package/tools/vds-scripts/audit_orchestrator/tests/test_profiles/__init__.py +0 -0
  673. package/tools/vds-scripts/audit_orchestrator/tests/test_profiles/test_detection.py +0 -146
  674. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/__init__.py +0 -0
  675. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_bitbucket_link_resolver.py +0 -55
  676. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_checklist_renderer.py +0 -84
  677. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_checklist_renderer_projection.py +0 -97
  678. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_confluence_macros.py +0 -58
  679. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_confluence_publisher.py +0 -2171
  680. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_evidence_links.py +0 -129
  681. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_field_sanitizer.py +0 -108
  682. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_hierarchy_publisher.py +0 -134
  683. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_incremental_plan_parser.py +0 -62
  684. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_live_data_injector.py +0 -48
  685. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_macro_builder.py +0 -22
  686. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_p161_confluence_optimization.py +0 -168
  687. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_priority_renderer.py +0 -96
  688. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_project_aggregate_renderer.py +0 -364
  689. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_storage_validation.py +0 -273
  690. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_summary_refactor.py +0 -118
  691. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_system_doc_hierarchy.py +0 -50
  692. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_table_builder.py +0 -23
  693. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_vietnamese_templates.py +0 -37
  694. package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_wiring_integration.py +0 -290
  695. package/tools/vds-scripts/audit_orchestrator/tests/test_reports/__init__.py +0 -0
  696. package/tools/vds-scripts/audit_orchestrator/tests/test_reports/test_aggregation_report.py +0 -181
  697. package/tools/vds-scripts/audit_orchestrator/tests/test_reports/test_checklist_generator.py +0 -258
  698. package/tools/vds-scripts/audit_orchestrator/tests/test_reports/test_gap_report.py +0 -73
  699. package/tools/vds-scripts/audit_orchestrator/tests/test_reports/test_json_generator.py +0 -317
  700. package/tools/vds-scripts/audit_orchestrator/tests/test_result_merger_p149.py +0 -347
  701. package/tools/vds-scripts/audit_orchestrator/tests/test_route_mode_p149.py +0 -178
  702. package/tools/vds-scripts/audit_orchestrator/tests/test_rubric_parser.py +0 -179
  703. package/tools/vds-scripts/audit_orchestrator/tests/test_scorer.py +0 -110
  704. package/tools/vds-scripts/audit_orchestrator/tests/test_state/__init__.py +0 -0
  705. package/tools/vds-scripts/audit_orchestrator/tests/test_state/test_sparse_coverage.py +0 -117
  706. package/tools/vds-scripts/audit_orchestrator/tests/test_workflow/__init__.py +0 -0
  707. package/tools/vds-scripts/audit_orchestrator/tests/test_workflow/test_langgraph_workflow.py +0 -2072
  708. package/tools/vds-scripts/audit_orchestrator/tests/test_workflow/test_p161_runtime_hardening.py +0 -341
  709. package/tools/vds-scripts/audit_orchestrator/tests/test_workflow_cmds_p149.py +0 -112
  710. package/tools/vds-scripts/audit_orchestrator/tests/test_workflow_cmds_p172.py +0 -126
  711. package/tools/vds-scripts/audit_orchestrator/tests/test_workflow_guidance_p150.py +0 -95
  712. package/tools/vds-scripts/audit_orchestrator/tests/unit/__init__.py +0 -0
  713. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/__init__.py +0 -0
  714. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_agentic_investigator_phase115.py +0 -42
  715. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_requirement_analysis_agent.py +0 -412
  716. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_security_agent_updates.py +0 -131
  717. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_security_scanner.py +0 -397
  718. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_skill_executor.py +0 -316
  719. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_skill_fallback.py +0 -299
  720. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_skill_policy.py +0 -520
  721. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_skill_telemetry.py +0 -306
  722. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_synthesis_fixes.py +0 -761
  723. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_argument_robustness.py +0 -272
  724. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_registry.py +0 -2548
  725. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_registry_ast_grep.py +0 -87
  726. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_registry_phase123_scoping.py +0 -353
  727. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_registry_phase94_ff.py +0 -445
  728. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_registry_vector_search_phase115.py +0 -35
  729. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_utils.py +0 -1007
  730. package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_vector_evidence_toolset.py +0 -622
  731. package/tools/vds-scripts/audit_orchestrator/tests/unit/cli/__init__.py +0 -0
  732. package/tools/vds-scripts/audit_orchestrator/tests/unit/cli/test_workflow_cli.py +0 -123
  733. package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/__init__.py +0 -0
  734. package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/test_cache_guard.py +0 -479
  735. package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/test_checklist_parser_phase120.py +0 -55
  736. package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/test_diagram_extractor.py +0 -467
  737. package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/test_enrichment_extractor.py +0 -59
  738. package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/test_graphify_collector.py +0 -158
  739. package/tools/vds-scripts/audit_orchestrator/tests/unit/completeness/__init__.py +0 -0
  740. package/tools/vds-scripts/audit_orchestrator/tests/unit/completeness/test_completeness.py +0 -563
  741. package/tools/vds-scripts/audit_orchestrator/tests/unit/completeness/test_freshness_evaluator.py +0 -493
  742. package/tools/vds-scripts/audit_orchestrator/tests/unit/completeness/test_material_cache_metrics.py +0 -365
  743. package/tools/vds-scripts/audit_orchestrator/tests/unit/completeness/test_material_completeness_service.py +0 -2736
  744. package/tools/vds-scripts/audit_orchestrator/tests/unit/config_resolution/__init__.py +0 -0
  745. package/tools/vds-scripts/audit_orchestrator/tests/unit/config_resolution/test_discovery.py +0 -47
  746. package/tools/vds-scripts/audit_orchestrator/tests/unit/config_resolution/test_redaction.py +0 -15
  747. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/__init__.py +0 -0
  748. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_ad_hoc_analyzer.py +0 -576
  749. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_agent_loop.py +0 -1896
  750. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_anchor_filter_cl003.py +0 -181
  751. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_batch_evidence_cache.py +0 -155
  752. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_batch_processor.py +0 -3608
  753. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_checklist_contract.py +0 -55
  754. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_checklist_scoping.py +0 -371
  755. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_config_companion_phase123.py +0 -142
  756. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_config_evidence_phase123.py +0 -249
  757. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_confluence_checklist_contract_export_parity.py +0 -813
  758. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_cross_repo_config_phase122.py +0 -613
  759. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_dspy_requirement_classifier.py +0 -517
  760. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_evidence_diversity.py +0 -144
  761. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_evidence_truncation.py +0 -108
  762. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_grounding_validator.py +0 -127
  763. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_guidance_injection_phase120.py +0 -105
  764. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_instruction_analysis_phase122.py +0 -761
  765. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_instruction_pre_filter_phase167.py +0 -334
  766. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_llm_row_evaluator_retries.py +0 -3684
  767. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_loader_phase123.py +0 -345
  768. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_manual_check_gating_phase122.py +0 -474
  769. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_parallel_eval.py +0 -263
  770. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_phase122_verifier_phase122.py +0 -169
  771. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_phase166_route_failover.py +0 -437
  772. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_post_eval_cl003_shared_lib.py +0 -267
  773. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_postproc_streaming.py +0 -194
  774. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_pre_eval_gating_phase122.py +0 -362
  775. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_prepare_topology_coverage.py +0 -247
  776. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_private_dns_sanitization_phase104.py +0 -397
  777. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_project_evidence_context.py +0 -450
  778. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_project_knowledge_store.py +0 -487
  779. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_project_topology.py +0 -1142
  780. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_provider_failure_classifier.py +0 -195
  781. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_readiness_extractor.py +0 -496
  782. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_readiness_synthesizer.py +0 -653
  783. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_repo_type_classifier.py +0 -303
  784. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_analysis.py +0 -508
  785. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_analysis_execution_scope.py +0 -239
  786. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_analysis_phase114.py +0 -919
  787. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_analysis_phase115.py +0 -97
  788. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_analysis_shared_lib.py +0 -340
  789. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_classification_drift.py +0 -729
  790. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_classification_nlp.py +0 -670
  791. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_scope_phase122.py +0 -615
  792. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_route_matrix.py +0 -258
  793. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_route_override.py +0 -141
  794. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_routing_precision.py +0 -650
  795. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_row_evaluator_dual_evidence.py +0 -2987
  796. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_row_evaluator_instruction_runtime_phase122.py +0 -365
  797. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_row_evaluator_runtime.py +0 -830
  798. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_runtime_hardening_phase122.py +0 -225
  799. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_scoped_na_skip.py +0 -107
  800. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_scoring_enhancements.py +0 -404
  801. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_shared_library_retrieval_phase123.py +0 -441
  802. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_shared_library_routing_phase123.py +0 -279
  803. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_shared_resource_indexing_phase122.py +0 -188
  804. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_skill_recommendation.py +0 -225
  805. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_skill_routing_cl003_shared_lib.py +0 -338
  806. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_skills_toolset.py +0 -319
  807. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_stability_metric.py +0 -60
  808. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_target_selector.py +0 -958
  809. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_token_tracker.py +0 -121
  810. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_token_wiring.py +0 -119
  811. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_tool_first_planner.py +0 -7103
  812. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_topology_knowledge_persistence.py +0 -332
  813. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_topology_query_service.py +0 -55
  814. package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_unverified_ref_retry.py +0 -909
  815. package/tools/vds-scripts/audit_orchestrator/tests/unit/models/__init__.py +0 -0
  816. package/tools/vds-scripts/audit_orchestrator/tests/unit/models/test_evidence.py +0 -515
  817. package/tools/vds-scripts/audit_orchestrator/tests/unit/models/test_gaps.py +0 -422
  818. package/tools/vds-scripts/audit_orchestrator/tests/unit/models/test_readiness.py +0 -428
  819. package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/__init__.py +0 -0
  820. package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_confluence_hierarchy.py +0 -227
  821. package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_project_title_generation.py +0 -335
  822. package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_publisher_registry_helpers.py +0 -290
  823. package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_publisher_registry_integration.py +0 -557
  824. package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_readiness_renderer.py +0 -381
  825. package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_repo_title_consistency.py +0 -266
  826. package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_upload_hierarchy_integration.py +0 -470
  827. package/tools/vds-scripts/audit_orchestrator/tests/unit/scripts/__init__.py +0 -0
  828. package/tools/vds-scripts/audit_orchestrator/tests/unit/scripts/test_benchmark_dspy.py +0 -177
  829. package/tools/vds-scripts/audit_orchestrator/tests/unit/scripts/test_benchmark_nlp_accuracy.py +0 -72
  830. package/tools/vds-scripts/audit_orchestrator/tests/unit/scripts/test_benchmark_retrieval_modes.py +0 -123
  831. package/tools/vds-scripts/audit_orchestrator/tests/unit/scripts/test_verify_phase111_requirement_analysis.py +0 -409
  832. package/tools/vds-scripts/audit_orchestrator/tests/unit/seed/__init__.py +0 -0
  833. package/tools/vds-scripts/audit_orchestrator/tests/unit/seed/test_seed_chain_cli.py +0 -277
  834. package/tools/vds-scripts/audit_orchestrator/tests/unit/seed/test_seed_loader.py +0 -502
  835. package/tools/vds-scripts/audit_orchestrator/tests/unit/skills/__init__.py +0 -0
  836. package/tools/vds-scripts/audit_orchestrator/tests/unit/skills/test_skill_routing.py +0 -209
  837. package/tools/vds-scripts/audit_orchestrator/tests/unit/sources/__init__.py +0 -0
  838. package/tools/vds-scripts/audit_orchestrator/tests/unit/sources/test_bitbucket_source.py +0 -66
  839. package/tools/vds-scripts/audit_orchestrator/tests/unit/sources/test_non_retryable_markers.py +0 -88
  840. package/tools/vds-scripts/audit_orchestrator/tests/unit/sources/test_repo_info.py +0 -212
  841. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/__init__.py +0 -0
  842. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_completeness.py +0 -598
  843. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_dispatch_events_contract_phase169.py +0 -100
  844. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_dispatch_hardening_phase158.py +0 -392
  845. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_dispatch_persistence_phase157.py +0 -914
  846. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_embedding_client.py +0 -64
  847. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_get_latest_completed_run.py +0 -313
  848. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_heartbeat_phase169.py +0 -109
  849. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_hybrid_search.py +0 -398
  850. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_normalize_url.py +0 -262
  851. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_phase152_query_surface.py +0 -59
  852. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_phase98_confluence_document_model.py +0 -202
  853. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_published_pages.py +0 -754
  854. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_readiness_helpers.py +0 -193
  855. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_run_ledger.py +0 -522
  856. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_run_management.py +0 -378
  857. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_schema_contract_phase170.py +0 -755
  858. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_state_cmds.py +0 -231
  859. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_state_loaders.py +0 -2151
  860. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_state_run_api.py +0 -2226
  861. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_store.py +0 -1435
  862. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_store_dispatch.py +0 -646
  863. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_store_dispatch_status_view.py +0 -181
  864. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_store_scope.py +0 -213
  865. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_utilization_persist_phase169.py +0 -77
  866. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_vds_search.py +0 -263
  867. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_vector_index_api.py +0 -319
  868. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_vector_index_runtime.py +0 -175
  869. package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_vector_index_store.py +0 -1756
  870. package/tools/vds-scripts/audit_orchestrator/tests/unit/sync/__init__.py +0 -0
  871. package/tools/vds-scripts/audit_orchestrator/tests/unit/sync/test_repo_sync.py +0 -257
  872. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_artifact_exclusion.py +0 -119
  873. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_auto_promote_phase158.py +0 -337
  874. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_carry_forward_artifact_filtering.py +0 -317
  875. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_checklist_precache_p160a.py +0 -416
  876. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_cli_decomposition_fr219.py +0 -269
  877. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_code_chunk_carry_forward.py +0 -203
  878. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_config_coherence.py +0 -180
  879. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_config_secret_policy.py +0 -522
  880. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_corpus_project_id_migration.py +0 -318
  881. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_corpus_status_diagnostics.py +0 -239
  882. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_department_priority_ordering.py +0 -131
  883. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_dispatch_coordinator_phase158.py +0 -402
  884. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_dispatch_job_identity_p167a.py +0 -238
  885. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_dispatch_ramp_up_phase171.py +0 -434
  886. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_dispatcher.py +0 -911
  887. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_doc_type_en_inference.py +0 -246
  888. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_early_exit_unchunked_repos.py +0 -111
  889. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_errors.py +0 -237
  890. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_errors_taxonomy.py +0 -83
  891. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_extract_chunking_config_phase98.py +0 -73
  892. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_extract_cmds_state_helpers.py +0 -33
  893. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_extract_docs_code_chunking.py +0 -260
  894. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_finalize_dispatch_run_phase168.py +0 -341
  895. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_identity.py +0 -221
  896. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_infrastructure_detection.py +0 -441
  897. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_junction_table_phase95.py +0 -259
  898. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_late_binding_assignment_p167c.py +0 -286
  899. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_misc_cmds_fr224_225_hardening.py +0 -194
  900. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_p172_integration.py +0 -306
  901. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_parent_provider_preflight.py +0 -118
  902. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_performance_gates_phase92.py +0 -141
  903. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_performance_gates_phase93.py +0 -50
  904. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase115_search_strategy.py +0 -106
  905. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase154_title_consistency.py +0 -117
  906. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase155_param_forwarding.py +0 -304
  907. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase158_concurrency_defaults.py +0 -207
  908. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase170_doctor_schema.py +0 -319
  909. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase170_regression.py +0 -334
  910. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase94_corpus_lifecycle.py +0 -307
  911. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase96_repo_key_migration.py +0 -305
  912. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_pipelined_scheduling.py +0 -130
  913. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_profile_availability_probe.py +0 -616
  914. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_profile_aware_row_timeout.py +0 -102
  915. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_profile_timeout_stagger_p160cd.py +0 -205
  916. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_progress_summary_phase169.py +0 -96
  917. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_registry_checklist_diagnostics.py +0 -124
  918. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_resume_manifest_p167b.py +0 -268
  919. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_risk_mitigations_p160e1.py +0 -348
  920. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_single_row_shards_p160b.py +0 -357
  921. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_state_repo_discovery.py +0 -504
  922. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_sync_metadata_entries.py +0 -57
  923. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_task_models.py +0 -1796
  924. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_utilization_telemetry_p167e.py +0 -259
  925. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_vietnamese_fts_hardening.py +0 -160
  926. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_workflow_phase98_enrichment.py +0 -92
  927. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_workflow_project_merge_materialization.py +0 -322
  928. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_workflow_row_key_migration_guard.py +0 -88
  929. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_workflow_short_circuit_phase121.py +0 -564
  930. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_workflow_single_target_row_context.py +0 -49
  931. package/tools/vds-scripts/audit_orchestrator/tests/unit/test_zero_result_messaging.py +0 -76
  932. package/tools/vds-scripts/bandit-report.json +0 -2974
  933. package/tools/vds-scripts/brd_orchestrator/README.md +0 -29
  934. package/tools/vds-scripts/brd_orchestrator/pyproject.toml +0 -63
  935. package/tools/vds-scripts/brd_orchestrator/src/vds_brd_orchestrator/__init__.py +0 -17
  936. package/tools/vds-scripts/brd_orchestrator/src/vds_brd_orchestrator/cli.py +0 -187
  937. package/tools/vds-scripts/brd_orchestrator/src/vds_brd_orchestrator/validator.py +0 -121
  938. package/tools/vds-scripts/brd_orchestrator/tests/__init__.py +0 -0
  939. package/tools/vds-scripts/brd_orchestrator/tests/test_cli.py +0 -62
  940. package/tools/vds-scripts/brd_orchestrator/tests/test_validator.py +0 -33
  941. package/tools/vds-scripts/circular_dependency_orchestrator/README.md +0 -30
  942. package/tools/vds-scripts/circular_dependency_orchestrator/pyproject.toml +0 -43
  943. package/tools/vds-scripts/circular_dependency_orchestrator/src/vds_circular_dependency_orchestrator/__init__.py +0 -16
  944. package/tools/vds-scripts/circular_dependency_orchestrator/src/vds_circular_dependency_orchestrator/cli.py +0 -904
  945. package/tools/vds-scripts/circular_dependency_orchestrator/tests/__init__.py +0 -0
  946. package/tools/vds-scripts/circular_dependency_orchestrator/tests/unit/__init__.py +0 -0
  947. package/tools/vds-scripts/circular_dependency_orchestrator/tests/unit/test_cli.py +0 -354
  948. package/tools/vds-scripts/coverage.json +0 -1
  949. package/tools/vds-scripts/create_pr.py +0 -57
  950. package/tools/vds-scripts/diagram_generator/README.md +0 -663
  951. package/tools/vds-scripts/diagram_generator/ci_validate.sh +0 -16
  952. package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-component.png +0 -0
  953. package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-component.puml +0 -23
  954. package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-sequence.png +0 -0
  955. package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-sequence.puml +0 -21
  956. package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-usecase.png +0 -0
  957. package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-usecase.puml +0 -14
  958. package/tools/vds-scripts/diagram_generator/examples/github-actions-validate.yml +0 -39
  959. package/tools/vds-scripts/diagram_generator/generate_all_diagrams.py +0 -827
  960. package/tools/vds-scripts/diagram_generator/generate_insurance_c4_diagrams.py +0 -261
  961. package/tools/vds-scripts/diagram_generator/generate_insurance_c4_quick.py +0 -486
  962. package/tools/vds-scripts/diagram_generator/pyproject.toml +0 -28
  963. package/tools/vds-scripts/diagram_generator/render_png.py +0 -59
  964. package/tools/vds-scripts/diagram_generator/src/vds_diagram_generator/__init__.py +0 -3
  965. package/tools/vds-scripts/diagram_generator/src/vds_diagram_generator/cli.py +0 -50
  966. package/tools/vds-scripts/diagram_generator/test_c4_hierarchical.py +0 -142
  967. package/tools/vds-scripts/diagram_generator/test_c4_quick.py +0 -131
  968. package/tools/vds-scripts/diagram_generator/tests/__init__.py +0 -0
  969. package/tools/vds-scripts/diagram_generator/tests/test_analyzer_completeness.py +0 -260
  970. package/tools/vds-scripts/diagram_generator/tests/test_c4_syntax_correctness.py +0 -138
  971. package/tools/vds-scripts/diagram_generator/tests/test_component_coverage.py +0 -182
  972. package/tools/vds-scripts/diagram_generator/tests/test_mermaid_output.py +0 -80
  973. package/tools/vds-scripts/diagram_generator/tests/test_png_generation.py +0 -112
  974. package/tools/vds-scripts/diagram_generator/tests/test_scenario_templates.py +0 -15
  975. package/tools/vds-scripts/diagram_generator/tests/test_sequence_accuracy.py +0 -93
  976. package/tools/vds-scripts/diagram_generator/tests/test_structurizr_export.py +0 -177
  977. package/tools/vds-scripts/diagram_generator/tests/test_style_consistency.py +0 -174
  978. package/tools/vds-scripts/diagram_generator/tests/test_usecase_generator.py +0 -201
  979. package/tools/vds-scripts/diagram_generator/tests/test_usecase_integration.py +0 -124
  980. package/tools/vds-scripts/docker/compose.phase2-verification.yml +0 -31
  981. package/tools/vds-scripts/docker-compose.openapi-validator.yml +0 -14
  982. package/tools/vds-scripts/excel_orchestrator/README.md +0 -288
  983. package/tools/vds-scripts/excel_orchestrator/RESEARCH_BASED_UPDATES_REPORT.md +0 -261
  984. package/tools/vds-scripts/excel_orchestrator/add_essential_missing_effort.py +0 -255
  985. package/tools/vds-scripts/excel_orchestrator/adjust_effort_complexity.py +0 -184
  986. package/tools/vds-scripts/excel_orchestrator/brd_analysis_and_task_breakdown.py +0 -632
  987. package/tools/vds-scripts/excel_orchestrator/brd_analysis_comprehensive.py +0 -1029
  988. package/tools/vds-scripts/excel_orchestrator/check_overlaps_and_brd_coverage.py +0 -570
  989. package/tools/vds-scripts/excel_orchestrator/clean_remarks_column.py +0 -127
  990. package/tools/vds-scripts/excel_orchestrator/comprehensive_brd_check.py +0 -322
  991. package/tools/vds-scripts/excel_orchestrator/create_buffered_summary.py +0 -119
  992. package/tools/vds-scripts/excel_orchestrator/create_service_totals_sheet.py +0 -118
  993. package/tools/vds-scripts/excel_orchestrator/examples/basic_operations.py +0 -85
  994. package/tools/vds-scripts/excel_orchestrator/expand_all_tasks.py +0 -341
  995. package/tools/vds-scripts/excel_orchestrator/expand_tasks.py +0 -304
  996. package/tools/vds-scripts/excel_orchestrator/fill_brd_references.py +0 -347
  997. package/tools/vds-scripts/excel_orchestrator/fill_remarks_and_colors.py +0 -132
  998. package/tools/vds-scripts/excel_orchestrator/finalize_brd_and_cleanup.py +0 -295
  999. package/tools/vds-scripts/excel_orchestrator/finalize_brd_coverage.py +0 -327
  1000. package/tools/vds-scripts/excel_orchestrator/fix_all_formulas.py +0 -99
  1001. package/tools/vds-scripts/excel_orchestrator/fix_detail_presentation.py +0 -113
  1002. package/tools/vds-scripts/excel_orchestrator/fix_presentation_and_effort.py +0 -116
  1003. package/tools/vds-scripts/excel_orchestrator/fix_presentation_consistency.py +0 -231
  1004. package/tools/vds-scripts/excel_orchestrator/fix_remarks_matching.py +0 -179
  1005. package/tools/vds-scripts/excel_orchestrator/group_tasks_by_service_id.py +0 -210
  1006. package/tools/vds-scripts/excel_orchestrator/increase_brd_coverage.py +0 -497
  1007. package/tools/vds-scripts/excel_orchestrator/increase_effort_complexity.py +0 -155
  1008. package/tools/vds-scripts/excel_orchestrator/organize_and_deduplicate.py +0 -273
  1009. package/tools/vds-scripts/excel_orchestrator/pyproject.toml +0 -64
  1010. package/tools/vds-scripts/excel_orchestrator/rebuild_all_formulas.py +0 -146
  1011. package/tools/vds-scripts/excel_orchestrator/remove_base_multiplier_and_check_duplicates.py +0 -310
  1012. package/tools/vds-scripts/excel_orchestrator/remove_duplicate_brd_tasks.py +0 -137
  1013. package/tools/vds-scripts/excel_orchestrator/research_based_updates.py +0 -457
  1014. package/tools/vds-scripts/excel_orchestrator/restore_e_values.py +0 -172
  1015. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/__init__.py +0 -5
  1016. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/cli.py +0 -746
  1017. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/config.py +0 -74
  1018. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/converters.py +0 -226
  1019. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/errors.py +0 -88
  1020. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/excel_client.py +0 -443
  1021. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/formatters.py +0 -211
  1022. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/logging.py +0 -57
  1023. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/source_contract.py +0 -29
  1024. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/target_state_status.py +0 -837
  1025. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/ulnc_alignment.py +0 -1291
  1026. package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/validators.py +0 -164
  1027. package/tools/vds-scripts/excel_orchestrator/sync_detail_and_total_sheets.py +0 -211
  1028. package/tools/vds-scripts/excel_orchestrator/tests/__init__.py +0 -1
  1029. package/tools/vds-scripts/excel_orchestrator/tests/conftest.py +0 -36
  1030. package/tools/vds-scripts/excel_orchestrator/tests/test_cli.py +0 -383
  1031. package/tools/vds-scripts/excel_orchestrator/tests/test_excel_client.py +0 -129
  1032. package/tools/vds-scripts/excel_orchestrator/tests/test_ulnc_alignment.py +0 -373
  1033. package/tools/vds-scripts/excel_orchestrator/tests/test_validators.py +0 -64
  1034. package/tools/vds-scripts/excel_orchestrator/update_api_database_effort.py +0 -261
  1035. package/tools/vds-scripts/excel_orchestrator/update_buffers_inline.py +0 -115
  1036. package/tools/vds-scripts/excel_orchestrator/update_complex_services_and_add_new.py +0 -336
  1037. package/tools/vds-scripts/excel_orchestrator/update_responsibility_and_fix_rows.py +0 -208
  1038. package/tools/vds-scripts/excel_orchestrator/update_task_breakdown_vietnamese.py +0 -309
  1039. package/tools/vds-scripts/excel_orchestrator/update_vietnamese_and_responsibility.py +0 -415
  1040. package/tools/vds-scripts/excel_orchestrator/verify_brd_coverage_comprehensive.py +0 -401
  1041. package/tools/vds-scripts/hexagonal_orchestrator/README.md +0 -530
  1042. package/tools/vds-scripts/hexagonal_orchestrator/pyproject.toml +0 -48
  1043. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/__init__.py +0 -39
  1044. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/analyzers/__init__.py +0 -19
  1045. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/analyzers/base.py +0 -95
  1046. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/analyzers/fallback.py +0 -614
  1047. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/analyzers/java.py +0 -372
  1048. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/analyzers/python.py +0 -437
  1049. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/cache.py +0 -331
  1050. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/classifier.py +0 -263
  1051. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/cli.py +0 -554
  1052. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/config.py +0 -577
  1053. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/models.py +0 -159
  1054. package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/profiler.py +0 -451
  1055. package/tools/vds-scripts/hexagonal_orchestrator/test-config.yaml +0 -38
  1056. package/tools/vds-scripts/hexagonal_orchestrator/tests/__init__.py +0 -1
  1057. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/__init__.py +0 -1
  1058. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/adapter/driven/persistence/InMemoryUserRepository.java +0 -62
  1059. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/adapter/driving/api/UserController.java +0 -101
  1060. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/application/port/EmailService.java +0 -33
  1061. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/application/port/UserRepository.java +0 -45
  1062. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/application/usecase/CreateUser.java +0 -58
  1063. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/domain/entity/Email.java +0 -80
  1064. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/domain/entity/User.java +0 -98
  1065. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-noncompliant/domain/User.java +0 -64
  1066. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-with-frameworks/domain/Menu.java +0 -13
  1067. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-with-frameworks/domain/Product.java +0 -16
  1068. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/__init__.py +0 -1
  1069. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/application/__init__.py +0 -1
  1070. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/application/ports/__init__.py +0 -1
  1071. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/application/ports/email_service.py +0 -60
  1072. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/application/ports/user_repository.py +0 -78
  1073. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/domain/__init__.py +0 -1
  1074. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/domain/entities/__init__.py +0 -1
  1075. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/domain/entities/user.py +0 -56
  1076. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/domain/value_objects/__init__.py +0 -1
  1077. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/domain/value_objects/email.py +0 -63
  1078. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-noncompliant/application/user_service.py +0 -1837
  1079. package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-noncompliant/domain/user.py +0 -43
  1080. package/tools/vds-scripts/hexagonal_orchestrator/tests/test_cache.py +0 -458
  1081. package/tools/vds-scripts/hexagonal_orchestrator/tests/test_cli_integration.py +0 -942
  1082. package/tools/vds-scripts/hexagonal_orchestrator/tests/test_cli_unit.py +0 -557
  1083. package/tools/vds-scripts/hexagonal_orchestrator/tests/test_cross_repo_pollution.py +0 -275
  1084. package/tools/vds-scripts/hexagonal_orchestrator/tests/test_foundation.py +0 -129
  1085. package/tools/vds-scripts/hexagonal_orchestrator/tests/test_integration.py +0 -1524
  1086. package/tools/vds-scripts/hexagonal_orchestrator/tests/test_java_analyzer.py +0 -642
  1087. package/tools/vds-scripts/hexagonal_orchestrator/tests/test_timing_unit.py +0 -60
  1088. package/tools/vds-scripts/intellij_orchestrator/README.md +0 -55
  1089. package/tools/vds-scripts/intellij_orchestrator/pyproject.toml +0 -64
  1090. package/tools/vds-scripts/intellij_orchestrator/src/vds_intellij_orchestrator/__init__.py +0 -17
  1091. package/tools/vds-scripts/intellij_orchestrator/src/vds_intellij_orchestrator/cli.py +0 -210
  1092. package/tools/vds-scripts/intellij_orchestrator/src/vds_intellij_orchestrator/core.py +0 -260
  1093. package/tools/vds-scripts/intellij_orchestrator/tests/__init__.py +0 -1
  1094. package/tools/vds-scripts/intellij_orchestrator/tests/test_cli.py +0 -112
  1095. package/tools/vds-scripts/intellij_orchestrator/tests/test_core.py +0 -83
  1096. package/tools/vds-scripts/links_orchestrator/README.md +0 -63
  1097. package/tools/vds-scripts/links_orchestrator/pyproject.toml +0 -64
  1098. package/tools/vds-scripts/links_orchestrator/src/vds_links_orchestrator/__init__.py +0 -10
  1099. package/tools/vds-scripts/links_orchestrator/src/vds_links_orchestrator/cli.py +0 -254
  1100. package/tools/vds-scripts/links_orchestrator/src/vds_links_orchestrator/validator.py +0 -244
  1101. package/tools/vds-scripts/links_orchestrator/tests/__init__.py +0 -0
  1102. package/tools/vds-scripts/links_orchestrator/tests/test_cli.py +0 -128
  1103. package/tools/vds-scripts/links_orchestrator/tests/test_validator.py +0 -76
  1104. package/tools/vds-scripts/lsp_orchestrator/.dockerignore +0 -69
  1105. package/tools/vds-scripts/lsp_orchestrator/ARCHITECTURE.md +0 -383
  1106. package/tools/vds-scripts/lsp_orchestrator/CODE_QUALITY_IMPROVEMENTS.md +0 -196
  1107. package/tools/vds-scripts/lsp_orchestrator/COMMANDS.md +0 -870
  1108. package/tools/vds-scripts/lsp_orchestrator/Dockerfile +0 -59
  1109. package/tools/vds-scripts/lsp_orchestrator/IMPLEMENTATION_SUMMARY.md +0 -490
  1110. package/tools/vds-scripts/lsp_orchestrator/LSP_ISSUES_AND_FINDINGS.md +0 -380
  1111. package/tools/vds-scripts/lsp_orchestrator/README.md +0 -616
  1112. package/tools/vds-scripts/lsp_orchestrator/SETUP.md +0 -143
  1113. package/tools/vds-scripts/lsp_orchestrator/TEST_COVERAGE_SUMMARY.md +0 -255
  1114. package/tools/vds-scripts/lsp_orchestrator/VERIFICATION_CHECKLIST.md +0 -814
  1115. package/tools/vds-scripts/lsp_orchestrator/docker-compose.yml +0 -102
  1116. package/tools/vds-scripts/lsp_orchestrator/docs/FOR_LLMS.md +0 -401
  1117. package/tools/vds-scripts/lsp_orchestrator/docs/explanation/lsp-response-matching.md +0 -79
  1118. package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/automate-with-json.md +0 -159
  1119. package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/docker-mode.md +0 -256
  1120. package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/navigate-code.md +0 -116
  1121. package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/parallel-processing.md +0 -179
  1122. package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/project-tool-detection.md +0 -320
  1123. package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/type-check-code.md +0 -46
  1124. package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/use-daemon-mode.md +0 -78
  1125. package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/wsl2-optimization.md +0 -227
  1126. package/tools/vds-scripts/lsp_orchestrator/docs/index.md +0 -88
  1127. package/tools/vds-scripts/lsp_orchestrator/docs/operator-hover-definition.md +0 -143
  1128. package/tools/vds-scripts/lsp_orchestrator/docs/reference/commands.md +0 -581
  1129. package/tools/vds-scripts/lsp_orchestrator/docs/reference/configuration.md +0 -422
  1130. package/tools/vds-scripts/lsp_orchestrator/docs/tutorials/00-quick-start.md +0 -169
  1131. package/tools/vds-scripts/lsp_orchestrator/pyproject.toml +0 -63
  1132. package/tools/vds-scripts/lsp_orchestrator/src/test_file.py +0 -5
  1133. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/__init__.py +0 -3
  1134. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/aggregator.py +0 -340
  1135. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/basedpyright_runner.py +0 -167
  1136. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/cli.py +0 -3370
  1137. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/code_actions.py +0 -79
  1138. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/core.py +0 -3295
  1139. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/daemon_client.py +0 -672
  1140. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/daemon_manager.py +0 -577
  1141. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/daemon_server.py +0 -1040
  1142. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/detectors/__init__.py +0 -9
  1143. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/detectors/project_detector.py +0 -537
  1144. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/formatters.py +0 -141
  1145. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/ipc_protocol.py +0 -225
  1146. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/lsp_client.py +0 -957
  1147. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/lsp_router.py +0 -335
  1148. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/mcp_server.py +0 -181
  1149. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/models/__init__.py +0 -201
  1150. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/models/project_detector.py +0 -646
  1151. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/models/project_tools.py +0 -114
  1152. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/models.py +0 -399
  1153. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/mypy_runner.py +0 -209
  1154. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/protocols.py +0 -52
  1155. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/ruff_lsp_client.py +0 -109
  1156. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/ruff_runner.py +0 -44
  1157. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/utils.py +0 -959
  1158. package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/workspace_indexer.py +0 -1037
  1159. package/tools/vds-scripts/lsp_orchestrator/test_workspace_lsp.py +0 -6
  1160. package/tools/vds-scripts/lsp_orchestrator/tests/__init__.py +0 -1
  1161. package/tools/vds-scripts/lsp_orchestrator/tests/conftest.py +0 -6
  1162. package/tools/vds-scripts/lsp_orchestrator/tests/test_aggregator.py +0 -59
  1163. package/tools/vds-scripts/lsp_orchestrator/tests/test_cli.py +0 -111
  1164. package/tools/vds-scripts/lsp_orchestrator/tests/test_detect_tools_command.py +0 -186
  1165. package/tools/vds-scripts/lsp_orchestrator/tests/test_formatter_linter_detection.py +0 -519
  1166. package/tools/vds-scripts/lsp_orchestrator/tests/test_integration_phase9_10_11.py +0 -367
  1167. package/tools/vds-scripts/lsp_orchestrator/tests/test_mypy_runner.py +0 -482
  1168. package/tools/vds-scripts/lsp_orchestrator/tests/test_package_manager_detection.py +0 -399
  1169. package/tools/vds-scripts/lsp_orchestrator/tests/test_phase10.py +0 -389
  1170. package/tools/vds-scripts/lsp_orchestrator/tests/test_phase11.py +0 -327
  1171. package/tools/vds-scripts/lsp_orchestrator/tests/test_phase12_integration.py +0 -634
  1172. package/tools/vds-scripts/lsp_orchestrator/tests/test_phase9.py +0 -196
  1173. package/tools/vds-scripts/lsp_orchestrator/tests/test_project_detector.py +0 -377
  1174. package/tools/vds-scripts/lsp_orchestrator/tests/test_test_runner_detection.py +0 -549
  1175. package/tools/vds-scripts/lsp_orchestrator/tests/test_type_checker_routing.py +0 -362
  1176. package/tools/vds-scripts/lsp_orchestrator/tests/test_workspace_indexer.py +0 -144
  1177. package/tools/vds-scripts/markdown_orchestrator/README.md +0 -72
  1178. package/tools/vds-scripts/markdown_orchestrator/pyproject.toml +0 -39
  1179. package/tools/vds-scripts/markdown_orchestrator/src/vds_markdown_orchestrator/__init__.py +0 -5
  1180. package/tools/vds-scripts/markdown_orchestrator/src/vds_markdown_orchestrator/cli.py +0 -102
  1181. package/tools/vds-scripts/multi_agent_orchestrator/Dockerfile +0 -65
  1182. package/tools/vds-scripts/multi_agent_orchestrator/README.md +0 -306
  1183. package/tools/vds-scripts/multi_agent_orchestrator/postman/README.md +0 -264
  1184. package/tools/vds-scripts/multi_agent_orchestrator/postman/TEST_RESULTS_SUMMARY.md +0 -197
  1185. package/tools/vds-scripts/multi_agent_orchestrator/postman/VDS-Multi-Agent-Orchestrator-API.postman_collection.json +0 -1010
  1186. package/tools/vds-scripts/multi_agent_orchestrator/postman/environments/local-development.postman_environment.json +0 -55
  1187. package/tools/vds-scripts/multi_agent_orchestrator/postman/test-results.json +0 -24146
  1188. package/tools/vds-scripts/multi_agent_orchestrator/pyproject.toml +0 -63
  1189. package/tools/vds-scripts/multi_agent_orchestrator/run_api.py +0 -9
  1190. package/tools/vds-scripts/multi_agent_orchestrator/run_mock_api.py +0 -9
  1191. package/tools/vds-scripts/multi_agent_orchestrator/simple_test.py +0 -53
  1192. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/__init__.py +0 -25
  1193. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/agent_pool.py +0 -433
  1194. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/api/__init__.py +0 -5
  1195. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/api/main.py +0 -722
  1196. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/api/mock_main.py +0 -812
  1197. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/change_log.py +0 -515
  1198. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/cli.py +0 -424
  1199. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/config.py +0 -220
  1200. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/conflict_resolver.py +0 -462
  1201. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/coordinator.py +0 -627
  1202. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/models.py +0 -389
  1203. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/progress_dashboard.py +0 -380
  1204. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/redis_client.py +0 -245
  1205. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/scheduler_subscriber.py +0 -272
  1206. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/task_manager.py +0 -536
  1207. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/task_tracking.py +0 -550
  1208. package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/vds_ai_memory_client.py +0 -352
  1209. package/tools/vds-scripts/multi_agent_orchestrator/test_complete_system.py +0 -149
  1210. package/tools/vds-scripts/multi_agent_orchestrator/test_infrastructure_only.py +0 -194
  1211. package/tools/vds-scripts/multi_agent_orchestrator/test_integration.py +0 -108
  1212. package/tools/vds-scripts/multi_agent_orchestrator/tests/__init__.py +0 -1
  1213. package/tools/vds-scripts/multi_agent_orchestrator/tests/test_agent_registration_credential_validator.py +0 -223
  1214. package/tools/vds-scripts/multi_agent_orchestrator/tests/test_config.py +0 -210
  1215. package/tools/vds-scripts/multi_agent_orchestrator/tests/test_models.py +0 -195
  1216. package/tools/vds-scripts/multi_agent_orchestrator/tests/test_w9_agent_routes.py +0 -321
  1217. package/tools/vds-scripts/openapi_orchestrator/README.md +0 -197
  1218. package/tools/vds-scripts/openapi_orchestrator/pyproject.toml +0 -106
  1219. package/tools/vds-scripts/openapi_orchestrator/src/vds_openapi_orchestrator/__init__.py +0 -29
  1220. package/tools/vds-scripts/openapi_orchestrator/src/vds_openapi_orchestrator/cli.py +0 -345
  1221. package/tools/vds-scripts/openapi_orchestrator/src/vds_openapi_orchestrator/full_validator.py +0 -183
  1222. package/tools/vds-scripts/openapi_orchestrator/src/vds_openapi_orchestrator/spec_validator.py +0 -197
  1223. package/tools/vds-scripts/openapi_orchestrator/tests/__init__.py +0 -1
  1224. package/tools/vds-scripts/openapi_orchestrator/tests/test_cli.py +0 -234
  1225. package/tools/vds-scripts/openapi_orchestrator/tests/test_full_validator.py +0 -203
  1226. package/tools/vds-scripts/openapi_orchestrator/tests/test_spec_validator.py +0 -295
  1227. package/tools/vds-scripts/pdf_orchestrator/.dockerignore +0 -93
  1228. package/tools/vds-scripts/pdf_orchestrator/.env.example +0 -40
  1229. package/tools/vds-scripts/pdf_orchestrator/.ruff_rules.py +0 -350
  1230. package/tools/vds-scripts/pdf_orchestrator/.yamllint.yml +0 -43
  1231. package/tools/vds-scripts/pdf_orchestrator/DEVELOPMENT_PLAN.md +0 -80
  1232. package/tools/vds-scripts/pdf_orchestrator/Dockerfile +0 -87
  1233. package/tools/vds-scripts/pdf_orchestrator/README.md +0 -608
  1234. package/tools/vds-scripts/pdf_orchestrator/cli_verification_test/test.md +0 -6
  1235. package/tools/vds-scripts/pdf_orchestrator/cli_verification_test/test.pdf +0 -0
  1236. package/tools/vds-scripts/pdf_orchestrator/config/alertmanager.yml +0 -83
  1237. package/tools/vds-scripts/pdf_orchestrator/config/prometheus.prod.yml +0 -98
  1238. package/tools/vds-scripts/pdf_orchestrator/config/prometheus.yml +0 -40
  1239. package/tools/vds-scripts/pdf_orchestrator/config/redis.conf +0 -78
  1240. package/tools/vds-scripts/pdf_orchestrator/docs/COMPETITIVE_ANALYSIS_REPORT.md +0 -309
  1241. package/tools/vds-scripts/pdf_orchestrator/docs/FEATURES_GUIDE.md +0 -518
  1242. package/tools/vds-scripts/pdf_orchestrator/docs/MULTI_USER_DEPLOYMENT_GUIDE.md +0 -615
  1243. package/tools/vds-scripts/pdf_orchestrator/docs/USER_GUIDE.md +0 -829
  1244. package/tools/vds-scripts/pdf_orchestrator/pyproject.toml +0 -87
  1245. package/tools/vds-scripts/pdf_orchestrator/pytest.ini +0 -71
  1246. package/tools/vds-scripts/pdf_orchestrator/ruff.toml +0 -6
  1247. package/tools/vds-scripts/pdf_orchestrator/scripts/debug_security_report.py +0 -59
  1248. package/tools/vds-scripts/pdf_orchestrator/scripts/demo_library_selector.py +0 -109
  1249. package/tools/vds-scripts/pdf_orchestrator/scripts/generate_project_stats.py +0 -52
  1250. package/tools/vds-scripts/pdf_orchestrator/scripts/generate_styled_pdf.py +0 -95
  1251. package/tools/vds-scripts/pdf_orchestrator/scripts/migrate_render_pdfs.py +0 -285
  1252. package/tools/vds-scripts/pdf_orchestrator/scripts/setup_team.bat +0 -283
  1253. package/tools/vds-scripts/pdf_orchestrator/scripts/setup_team.sh +0 -324
  1254. package/tools/vds-scripts/pdf_orchestrator/src/vds_pdf_orchestrator/__init__.py +0 -5
  1255. package/tools/vds-scripts/pdf_orchestrator/src/vds_pdf_orchestrator/cli.py +0 -542
  1256. package/tools/vds-scripts/pdf_orchestrator/src/vds_pdf_orchestrator/config.py +0 -33
  1257. package/tools/vds-scripts/pdf_orchestrator/tests/README.md +0 -650
  1258. package/tools/vds-scripts/pdf_orchestrator/tests/__init__.py +0 -0
  1259. package/tools/vds-scripts/pdf_orchestrator/tests/conftest.py +0 -520
  1260. package/tools/vds-scripts/pdf_orchestrator/tests/requirements.txt +0 -51
  1261. package/tools/vds-scripts/pdf_orchestrator/tests/run_tests.py +0 -659
  1262. package/tools/vds-scripts/pdf_orchestrator/tests/test_config.py +0 -36
  1263. package/tools/vds-scripts/progress_report_orchestrator/Dockerfile +0 -77
  1264. package/tools/vds-scripts/progress_report_orchestrator/README.md +0 -39
  1265. package/tools/vds-scripts/progress_report_orchestrator/alembic/env.py +0 -42
  1266. package/tools/vds-scripts/progress_report_orchestrator/alembic/script.py.mako +0 -28
  1267. package/tools/vds-scripts/progress_report_orchestrator/alembic/versions/0001_initial_progress_schema.py +0 -180
  1268. package/tools/vds-scripts/progress_report_orchestrator/alembic.ini +0 -67
  1269. package/tools/vds-scripts/progress_report_orchestrator/pyproject.toml +0 -67
  1270. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/__init__.py +0 -3
  1271. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/analyzers/__init__.py +0 -1
  1272. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/analyzers/endpoint_scanner.py +0 -238
  1273. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/analyzers/git_activity.py +0 -159
  1274. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/analyzers/hexagonal.py +0 -100
  1275. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/analyzers/test_scanner.py +0 -136
  1276. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/cli.py +0 -743
  1277. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/config.py +0 -50
  1278. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/db/__init__.py +0 -12
  1279. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/db/alembic_filters.py +0 -64
  1280. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/memory.py +0 -82
  1281. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/models/__init__.py +0 -1
  1282. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/models/analysis.py +0 -84
  1283. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/models/report.py +0 -117
  1284. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/models/topology.py +0 -101
  1285. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/parsers/__init__.py +0 -1
  1286. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/parsers/kg_parser.py +0 -252
  1287. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/parsers/uc_reader.py +0 -159
  1288. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/__init__.py +0 -1
  1289. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/concurrency.py +0 -39
  1290. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/llm_eval.py +0 -570
  1291. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/report.py +0 -1256
  1292. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/structural.py +0 -384
  1293. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/sync.py +0 -143
  1294. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/recommendations/__init__.py +0 -5
  1295. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/recommendations/engine.py +0 -105
  1296. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/recommendations/templates.py +0 -236
  1297. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/scheduler_subscriber.py +0 -238
  1298. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/skills/README.md +0 -56
  1299. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/skills/__init__.py +0 -1
  1300. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/skills/srs-architecture-reviewer/SKILL.md +0 -67
  1301. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/skills/srs-endpoint-matcher/SKILL.md +0 -67
  1302. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/state/__init__.py +0 -1
  1303. package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/state/schema.py +0 -625
  1304. package/tools/vds-scripts/progress_report_orchestrator/tests/__init__.py +0 -0
  1305. package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/__init__.py +0 -0
  1306. package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/.gitkeep +0 -0
  1307. package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/__init__.py +0 -0
  1308. package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/doc-dependencies.yaml +0 -79
  1309. package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/fr-to-docs.yaml +0 -478
  1310. package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/fr-to-services.yaml +0 -18
  1311. package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/registry.yaml +0 -346
  1312. package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/phase3_baseline_standard.md +0 -564
  1313. package/tools/vds-scripts/progress_report_orchestrator/tests/integration/__init__.py +0 -0
  1314. package/tools/vds-scripts/progress_report_orchestrator/tests/integration/test_checkpoint.py +0 -276
  1315. package/tools/vds-scripts/progress_report_orchestrator/tests/test_alembic_migrations.py +0 -265
  1316. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/__init__.py +0 -0
  1317. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_analyzers.py +0 -267
  1318. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_bounded_gather.py +0 -176
  1319. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_cli_phase_report.py +0 -119
  1320. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_delta.py +0 -169
  1321. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_error_handling.py +0 -150
  1322. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_gate_exit_codes.py +0 -230
  1323. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_git_activity.py +0 -215
  1324. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_kg_parser.py +0 -267
  1325. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_llm_autodetect.py +0 -183
  1326. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_llm_eval.py +0 -529
  1327. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_memory_integration.py +0 -151
  1328. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_migration_contract.py +0 -254
  1329. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_mode_rendering.py +0 -576
  1330. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_models.py +0 -251
  1331. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_progress_llm_config.py +0 -67
  1332. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_recommendations.py +0 -480
  1333. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_report_enhancements.py +0 -415
  1334. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_resume_reload.py +0 -343
  1335. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_trend_regression.py +0 -294
  1336. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_uc_reader.py +0 -169
  1337. package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_valence_gap.py +0 -293
  1338. package/tools/vds-scripts/project-cycle-report.json +0 -14
  1339. package/tools/vds-scripts/project-dependency-graph.json +0 -11361
  1340. package/tools/vds-scripts/project-topology.json +0 -99
  1341. package/tools/vds-scripts/public_interface_boundary_orchestrator/pyproject.toml +0 -18
  1342. package/tools/vds-scripts/public_interface_boundary_orchestrator/src/vds_public_interface_boundary_orchestrator/__init__.py +0 -0
  1343. package/tools/vds-scripts/public_interface_boundary_orchestrator/src/vds_public_interface_boundary_orchestrator/cli.py +0 -232
  1344. package/tools/vds-scripts/public_interface_boundary_orchestrator/tests/__init__.py +0 -0
  1345. package/tools/vds-scripts/public_interface_boundary_orchestrator/tests/test_cli.py +0 -108
  1346. package/tools/vds-scripts/research_orchestrator/README.md +0 -68
  1347. package/tools/vds-scripts/research_orchestrator/py.typed +0 -0
  1348. package/tools/vds-scripts/research_orchestrator/pyproject.toml +0 -95
  1349. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/__init__.py +0 -3
  1350. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/_env.py +0 -11
  1351. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/cli.py +0 -335
  1352. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/config.py +0 -43
  1353. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/evidence/__init__.py +0 -0
  1354. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/evidence/models.py +0 -89
  1355. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/evidence/scoring.py +0 -102
  1356. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/exceptions.py +0 -78
  1357. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/http_client.py +0 -160
  1358. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/logging.py +0 -49
  1359. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/output/__init__.py +0 -0
  1360. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/output/formatters.py +0 -93
  1361. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/py.typed +0 -1
  1362. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/report/__init__.py +0 -0
  1363. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/report/build.py +0 -156
  1364. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/report/format.py +0 -147
  1365. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/tools/__init__.py +0 -0
  1366. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/tools/health.py +0 -66
  1367. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/tools/health_graph.py +0 -52
  1368. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/tools/registry.py +0 -127
  1369. package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/tools/search.py +0 -230
  1370. package/tools/vds-scripts/research_orchestrator/tests/__init__.py +0 -0
  1371. package/tools/vds-scripts/research_orchestrator/tests/conftest.py +0 -53
  1372. package/tools/vds-scripts/research_orchestrator/tests/test_cli.py +0 -222
  1373. package/tools/vds-scripts/research_orchestrator/tests/test_config.py +0 -23
  1374. package/tools/vds-scripts/research_orchestrator/tests/test_exceptions.py +0 -62
  1375. package/tools/vds-scripts/research_orchestrator/tests/test_formatters.py +0 -89
  1376. package/tools/vds-scripts/research_orchestrator/tests/test_graph_integration.py +0 -149
  1377. package/tools/vds-scripts/research_orchestrator/tests/test_http_client.py +0 -134
  1378. package/tools/vds-scripts/research_orchestrator/tests/test_report_build.py +0 -128
  1379. package/tools/vds-scripts/research_orchestrator/tests/test_report_format.py +0 -91
  1380. package/tools/vds-scripts/research_orchestrator/tests/test_scoring.py +0 -95
  1381. package/tools/vds-scripts/research_orchestrator/tests/vds_research_orchestrator/test_tools/__init__.py +0 -1
  1382. package/tools/vds-scripts/research_orchestrator/tests/vds_research_orchestrator/test_tools/test_health.py +0 -139
  1383. package/tools/vds-scripts/research_orchestrator/tests/vds_research_orchestrator/test_tools/test_registry.py +0 -135
  1384. package/tools/vds-scripts/research_orchestrator/tests/vds_research_orchestrator/test_tools/test_search.py +0 -238
  1385. package/tools/vds-scripts/run-history.json +0 -26
  1386. package/tools/vds-scripts/schema_converter/README.md +0 -109
  1387. package/tools/vds-scripts/schema_converter/pyproject.toml +0 -37
  1388. package/tools/vds-scripts/schema_converter/src/vds_schema_converter/__init__.py +0 -3
  1389. package/tools/vds-scripts/schema_converter/src/vds_schema_converter/cli.py +0 -50
  1390. package/tools/vds-scripts/schema_converter/tests/__init__.py +0 -0
  1391. package/tools/vds-scripts/schema_converter/tests/test_json_schema_generator.py +0 -115
  1392. package/tools/vds-scripts/schema_converter/tests/test_mermaid_generator.py +0 -112
  1393. package/tools/vds-scripts/schema_converter/tests/test_parser.py +0 -111
  1394. package/tools/vds-scripts/schema_converter/tests/test_plantuml_generator.py +0 -112
  1395. package/tools/vds-scripts/schema_converter/tests/test_plantuml_validator.py +0 -69
  1396. package/tools/vds-scripts/schema_converter/tests/test_prisma_generator.py +0 -113
  1397. package/tools/vds-scripts/schema_converter/tests/test_sql_generator.py +0 -138
  1398. package/tools/vds-scripts/schema_converter/tests/test_typeorm_generator.py +0 -110
  1399. package/tools/vds-scripts/schema_converter/tests/test_validators.py +0 -96
  1400. package/tools/vds-scripts/spec_orchestrator/README.md +0 -13
  1401. package/tools/vds-scripts/spec_orchestrator/pyproject.toml +0 -40
  1402. package/tools/vds-scripts/spec_orchestrator/src/vds_spec_orchestrator/__init__.py +0 -5
  1403. package/tools/vds-scripts/spec_orchestrator/src/vds_spec_orchestrator/cli.py +0 -162
  1404. package/tools/vds-scripts/spec_orchestrator/src/vds_spec_orchestrator/core.py +0 -575
  1405. package/tools/vds-scripts/spec_orchestrator/src/vds_spec_orchestrator/sync.py +0 -306
  1406. package/tools/vds-scripts/spec_orchestrator/tests/__init__.py +0 -0
  1407. package/tools/vds-scripts/spec_orchestrator/tests/test_frontmatter_drift.py +0 -243
  1408. package/tools/vds-scripts/spec_orchestrator/tests/test_sync.py +0 -342
  1409. package/tools/vds-scripts/structure_orchestrator/README.md +0 -60
  1410. package/tools/vds-scripts/structure_orchestrator/pyproject.toml +0 -103
  1411. package/tools/vds-scripts/structure_orchestrator/src/vds_structure_orchestrator/__init__.py +0 -13
  1412. package/tools/vds-scripts/structure_orchestrator/src/vds_structure_orchestrator/cli.py +0 -308
  1413. package/tools/vds-scripts/structure_orchestrator/src/vds_structure_orchestrator/validator.py +0 -257
  1414. package/tools/vds-scripts/structure_orchestrator/tests/__init__.py +0 -0
  1415. package/tools/vds-scripts/structure_orchestrator/tests/test_cli.py +0 -161
  1416. package/tools/vds-scripts/structure_orchestrator/tests/test_helpers.py +0 -115
  1417. package/tools/vds-scripts/structure_orchestrator/tests/test_validator.py +0 -104
  1418. package/tools/vds-scripts/task_orchestrator/README.md +0 -50
  1419. package/tools/vds-scripts/task_orchestrator/__init__.py +0 -18
  1420. package/tools/vds-scripts/task_orchestrator/pyproject.toml +0 -43
  1421. package/tools/vds-scripts/task_orchestrator/scripts/run_excel_sync.py +0 -36
  1422. package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/__init__.py +0 -13
  1423. package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/audit.py +0 -134
  1424. package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/cli.py +0 -127
  1425. package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/debug.py +0 -133
  1426. package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/normalize.py +0 -113
  1427. package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/refine.py +0 -201
  1428. package/tools/vds-scripts/task_orchestrator/tests/__init__.py +0 -0
  1429. package/tools/vds-scripts/task_orchestrator/tests/test_task_orchestrator.py +0 -84
  1430. package/tools/vds-scripts/temp_query_projects.py +0 -2
  1431. package/tools/vds-scripts/test_small.md +0 -1
  1432. package/tools/vds-scripts/text_utils_orchestrator/pyproject.toml +0 -20
  1433. package/tools/vds-scripts/text_utils_orchestrator/src/vds_text_utils/__init__.py +0 -7
  1434. package/tools/vds-scripts/text_utils_orchestrator/src/vds_text_utils/i18n.py +0 -143
  1435. package/tools/vds-scripts/text_utils_orchestrator/tests/__init__.py +0 -0
  1436. package/tools/vds-scripts/text_utils_orchestrator/tests/test_i18n.py +0 -53
  1437. package/tools/vds-scripts/upgrade_major.py +0 -61
  1438. package/tools/vds-scripts/upgrade_major_v2.py +0 -64
  1439. package/tools/vds-scripts/verify_violations.py +0 -57
  1440. package/tools/vds-scripts/workflow-summary.json +0 -325
  1441. package/tools/vds-scripts/workflow-summary.md +0 -8
@@ -1,4776 +0,0 @@
1
- """Batch Row Processor - Processes checklist rows in configurable batches.
2
-
3
- Provides:
4
- - Configurable batch sizes (FR-3.1)
5
- - Per-row and per-batch timeouts (FR-3.2)
6
- - Checkpoint/resume with full row results (FR-3.3)
7
- - Progress logging
8
- - Target filtering for dynamic analysis (FR-25)
9
- """
10
-
11
- from __future__ import annotations
12
-
13
- import asyncio
14
- import contextlib
15
- import copy
16
- import inspect
17
- import json
18
- import math
19
- import os
20
- from collections.abc import Awaitable, Callable
21
- from dataclasses import dataclass, field
22
- from datetime import UTC, datetime
23
- from pathlib import Path
24
-
25
- # Import GroundingValidator and TargetSelection only for typing, avoid circular if possible
26
- from typing import TYPE_CHECKING, Any, cast
27
-
28
- from structlog import get_logger
29
- from vds_agent_core.llm.budget import BudgetExceededError
30
- from vds_agent_core.profiles import resolve_default_failover_profiles
31
-
32
- from vds_audit_orchestrator.engine.provider_failure_classifier import (
33
- ProviderFailureClass,
34
- ProviderFailureClassification,
35
- ProviderHealthMemory,
36
- RowFailoverContext,
37
- TimeoutKind,
38
- )
39
- from vds_audit_orchestrator.engine.row_evaluator import RowEvaluator
40
- from vds_audit_orchestrator.engine.row_evaluator_types import RowEvaluationResult, requires_app_config_only
41
- from vds_audit_orchestrator.errors import AUDIT_ERROR_CODES
42
- from vds_audit_orchestrator.evidence.matcher import MatcherProtocol, RowEvidenceContext
43
- from vds_audit_orchestrator.models.checklist import (
44
- VERIFICATION_REASON_EXCERPT_VERIFIED_IN_CONTEXT,
45
- VERIFICATION_REASON_FALLBACK_REF_INHERITED,
46
- EvidenceAnchor,
47
- RowProvenance,
48
- RowStatus,
49
- ScoreBreakdown,
50
- normalize_verification_reason,
51
- )
52
- from vds_audit_orchestrator.runtime_profiles import inherit_runtime_llm_policy
53
-
54
- if TYPE_CHECKING:
55
- from vds_audit_orchestrator.engine.grounding_validator import GroundingValidator
56
- from vds_audit_orchestrator.engine.target_selector import TargetSelection
57
- from vds_audit_orchestrator.models.template import AuditCheck, AuditTemplate
58
-
59
- logger = get_logger()
60
- _TIMEOUT_PROGRESS_COUNTER_KEYS: tuple[str, ...] = (
61
- "tool_calls",
62
- "skill_calls",
63
- "skill_execution_calls",
64
- "skill_effective_calls",
65
- )
66
-
67
-
68
- def _convert_datetimes(obj: Any) -> Any:
69
- """Recursively convert datetime objects to ISO strings for JSON serialization."""
70
- if isinstance(obj, datetime):
71
- return obj.isoformat()
72
- if isinstance(obj, dict):
73
- return {k: _convert_datetimes(v) for k, v in obj.items()}
74
- if isinstance(obj, list):
75
- return [_convert_datetimes(item) for item in obj]
76
- return obj
77
-
78
-
79
- def _sanitize_retrieval_trace(trace: Any) -> dict[str, Any] | None:
80
- """Return JSON-serializable retrieval trace dict or None."""
81
- if not isinstance(trace, dict):
82
- return None
83
- normalized = _convert_datetimes(trace)
84
- try:
85
- json.dumps(normalized, ensure_ascii=False)
86
- except TypeError:
87
- return None
88
- return normalized
89
-
90
-
91
- def _merge_retrieval_trace_payloads(
92
- matcher_trace: dict[str, Any] | None,
93
- row_trace: dict[str, Any] | None,
94
- ) -> dict[str, Any] | None:
95
- """Merge matcher + row retrieval traces without losing non-null matcher context."""
96
- base = dict(matcher_trace or {})
97
- overlay = dict(row_trace or {})
98
- if not base and not overlay:
99
- return None
100
- if not base:
101
- return overlay
102
- if not overlay:
103
- return base
104
-
105
- merged = dict(base)
106
- preserve_empty_overrides = bool(
107
- (
108
- overlay.get("app_config_only_enforced") if isinstance(overlay.get("app_config_only_enforced"), dict) else {}
109
- ).get("applied")
110
- ) or RowEvaluator._is_app_config_only_requirement(retrieval_trace=overlay)
111
- for key, value in overlay.items():
112
- if value is None:
113
- continue
114
- existing = merged.get(key)
115
- if isinstance(value, list):
116
- if not value and isinstance(existing, list) and existing and not preserve_empty_overrides:
117
- continue
118
- merged[key] = value
119
- continue
120
- if isinstance(value, dict):
121
- if not value and isinstance(existing, dict) and existing and not preserve_empty_overrides:
122
- continue
123
- if not value and preserve_empty_overrides:
124
- merged[key] = value
125
- continue
126
- if isinstance(existing, dict):
127
- nested = dict(existing)
128
- for nested_key, nested_value in value.items():
129
- if nested_value is None:
130
- continue
131
- prior_nested = nested.get(nested_key)
132
- if (
133
- isinstance(nested_value, list)
134
- and not nested_value
135
- and isinstance(prior_nested, list)
136
- and prior_nested
137
- and not preserve_empty_overrides
138
- ):
139
- continue
140
- if (
141
- isinstance(nested_value, dict)
142
- and not nested_value
143
- and isinstance(prior_nested, dict)
144
- and prior_nested
145
- and not preserve_empty_overrides
146
- ):
147
- continue
148
- if isinstance(nested_value, dict) and not nested_value and preserve_empty_overrides:
149
- nested[nested_key] = nested_value
150
- continue
151
- nested[nested_key] = nested_value
152
- merged[key] = nested
153
- continue
154
- merged[key] = value
155
- continue
156
- merged[key] = value
157
- return merged
158
-
159
-
160
- def _default_batch_error_retry_limit() -> int:
161
- """Return batch-level error retry limit from env, defaulting to 1 (FR-145.2)."""
162
- try:
163
- return max(0, int(os.environ.get("VDS_AUDIT_BATCH_ERROR_RETRY_LIMIT", "2")))
164
- except (ValueError, TypeError):
165
- return 1
166
-
167
-
168
- # ---------------------------------------------------------------------------
169
- # Phase 146: Quota-aware recovery configuration (FR-146.6)
170
- # ---------------------------------------------------------------------------
171
-
172
-
173
- def _quota_wait_max_seconds() -> float:
174
- """Return the maximum seconds to wait when all providers are exhausted (AC-146.6.3).
175
-
176
- Env: VDS_AUDIT_QUOTA_WAIT_MAX_SECONDS, default 30.0.
177
- Set to 0 to disable bounded wait-and-resume entirely.
178
- """
179
- try:
180
- return max(0.0, float(os.environ.get("VDS_AUDIT_QUOTA_WAIT_MAX_SECONDS", "30")))
181
- except (ValueError, TypeError):
182
- return 30.0
183
-
184
-
185
- def _exhausted_provider_verification_limit() -> int:
186
- """Return max verification retries for a provider already known to be exhausted (AC-146.5.3).
187
-
188
- Env: VDS_AUDIT_EXHAUSTED_PROVIDER_RETRIES, default 0.
189
- When 0, known-exhausted providers are skipped entirely during retry sweeps.
190
- """
191
- try:
192
- return max(0, int(os.environ.get("VDS_AUDIT_EXHAUSTED_PROVIDER_RETRIES", "0")))
193
- except (ValueError, TypeError):
194
- return 0
195
-
196
-
197
- def _all_providers_exhausted_reason(
198
- health_memory: ProviderHealthMemory,
199
- *,
200
- failover_profiles: list[str],
201
- ) -> str | None:
202
- """Return an exhaustion reason code if all eligible providers are unusable (AC-146.6.4).
203
-
204
- Returns:
205
- ``quota_all_providers_exhausted`` when at least one provider is in
206
- cooldown/constrained/degraded state (temporary), ``None`` when at
207
- least one provider is still dispatchable, or
208
- ``provider_all_auth_blocked`` when every provider is auth-blocked
209
- (permanent for the current run).
210
- """
211
- if not failover_profiles:
212
- return None
213
-
214
- any_dispatchable = False
215
- any_temporary = False
216
- for profile in failover_profiles:
217
- state = health_memory.get_state(profile)
218
- if state.is_auth_blocked():
219
- continue
220
- if state.is_in_cooldown() or state.should_skip_dispatch():
221
- any_temporary = True
222
- continue
223
- any_dispatchable = True
224
- break
225
-
226
- if any_dispatchable:
227
- return None
228
- if any_temporary:
229
- return "quota_all_providers_exhausted"
230
- # All auth-blocked — permanent for this run
231
- if failover_profiles:
232
- return "provider_all_auth_blocked"
233
- return None
234
-
235
-
236
- @dataclass
237
- class BatchConfig:
238
- """Configuration for batch processing (FR-3.1, FR-3.2, FR-25, FR-188, FR-145.2).
239
-
240
- Attributes:
241
- batch_size: Number of rows per batch (default 5).
242
- row_timeout_ms: Timeout per row in milliseconds (default 45s).
243
- row_progress_lease_seconds: Renewable liveness lease window in seconds.
244
- Default 0 keeps legacy timeout-extension semantics.
245
- row_stall_detection_seconds: No-progress stall threshold in seconds when
246
- lease mode is enabled.
247
- row_absolute_timeout_ms: Hard safety cap per row when lease mode is enabled.
248
- batch_timeout_ms: Optional batch timeout (default: batch_size * effective row timeout ceiling + overhead).
249
- batch_overhead_ms: Slack time for formatting + bookkeeping (default 15s).
250
- batch_error_retry_limit: Max post-pass retry attempts for ERROR rows (FR-145.2).
251
- Env: VDS_AUDIT_BATCH_ERROR_RETRY_LIMIT, default 2. Set 0 to disable.
252
- checkpoint_dir: Directory for checkpoint files.
253
- resume_from_checkpoint: Whether to resume from existing checkpoint.
254
- target_selection: Optional target selection for dynamic analysis (FR-25).
255
- force_refresh_targets: Re-evaluate targeted rows even if checkpointed (FR-25).
256
- row_concurrency: Max rows dispatched in parallel within a batch (FR-188).
257
- Default 1 (sequential, safe). Values >1 enable asyncio.gather dispatch
258
- with a semaphore-bounded concurrency limit.
259
- """
260
-
261
- batch_size: int = 5 # FR-3.1: Default 5-10 rows
262
- row_timeout_ms: int = 360_000 # Generous: 6 minutes per row (was 120s; profile YAML may override to 600s+)
263
- row_progress_lease_seconds: int = 0 # FR-112.1: 0 preserves legacy timeout-extension mode
264
- row_stall_detection_seconds: int = 60 # FR-112.1: stall threshold (was 30s)
265
- row_absolute_timeout_ms: int = 1_200_000 # Generous: 20-minute hard safety cap (was 600s)
266
- row_timeout_progress_extension_enabled: bool = True # FR-72/73 follow-up: adaptive extension on effective progress
267
- row_timeout_progress_retry_attempts: int = 5 # Generous: 5 extension attempts (was 2)
268
- row_timeout_progress_extension_ms: int = 60_000 # Generous: 60s per extension (was 30s)
269
- row_timeout_progress_max_ms: int = 600_000 # Generous: 10-minute ceiling after extensions (was 240s)
270
- batch_timeout_ms: int | None = None # Default: batch_size * effective row timeout ceiling + overhead
271
- batch_overhead_ms: int = 15_000 # Slack for formatting + bookkeeping
272
- batch_error_retry_limit: int = field(default_factory=_default_batch_error_retry_limit) # FR-145.2
273
- checkpoint_dir: Path | None = None
274
- resume_from_checkpoint: bool = False
275
- # FR-25: Dynamic Analysis Support - Target filtering
276
- target_selection: TargetSelection | None = None
277
- run_context: dict[str, Any] = field(default_factory=dict)
278
- force_refresh_targets: bool = True # Re-evaluate targeted rows even if checkpointed
279
- # FR-185: Repo-type scoped N/A indices — skip LLM calls entirely for these rows
280
- scoped_na_indices: set[int] = field(default_factory=set)
281
- # FR-188: Parallel row dispatch within a batch
282
- row_concurrency: int = 4 # Phase 158 default; >1 enables asyncio.gather dispatch
283
- # FR-128.3 / Phase 158: adaptive concurrency is enabled by default.
284
- adaptive_row_concurrency: bool = True
285
- adaptive_row_concurrency_min: int = 2
286
- adaptive_row_concurrency_max: int = 8
287
- adaptive_row_concurrency_increase_threshold_ms: int = 1000
288
- adaptive_row_concurrency_decrease_threshold_ms: int = 5000
289
-
290
-
291
- # ---------------------------------------------------------------------------
292
- # FR-145.2: Resilience budget enforcement
293
- # ---------------------------------------------------------------------------
294
-
295
- # Reason codes in retry_metadata that indicate a non-provider failure.
296
- # These rows will not benefit from retrying with a different provider.
297
- _NON_FAILOVERABLE_REASONS: frozenset[str] = frozenset(
298
- {
299
- ProviderFailureClass.TERMINAL_AUTH.value,
300
- ProviderFailureClass.NON_PROVIDER_BUG.value,
301
- "terminal_auth",
302
- "non_provider_bug",
303
- "schema_validation",
304
- "template_mismatch",
305
- "row_backend_invalid_env_value",
306
- "target_resolution",
307
- }
308
- )
309
-
310
-
311
- @dataclass
312
- class ResilienceBudget:
313
- """Bounded retry budget shared across post-pass sweeps (FR-145.2, NFR-145.2).
314
-
315
- The budget is generous and error-driven with a generous floor:
316
- total = max(error_count * 3, max(15, ceil(total_rows * 0.35)))
317
-
318
- For a 55-row batch with 12 ERRORs: max(36, max(15, 20)) = 36 retries.
319
-
320
- Args:
321
- total_rows: Total rows in the primary pass.
322
- error_count: Number of ERROR rows from the primary pass.
323
- """
324
-
325
- total_rows: int
326
- error_count: int
327
- calls_used: int = 0
328
-
329
- @property
330
- def total(self) -> int:
331
- """Return total resilience budget calls allowed."""
332
- return max(self.error_count * 3, 15, math.ceil(self.total_rows * 0.35))
333
-
334
- @property
335
- def remaining(self) -> int:
336
- return max(0, self.total - self.calls_used)
337
-
338
- def consume(self) -> bool:
339
- """Consume one budget slot. Returns False if budget exhausted."""
340
- if self.calls_used >= self.total:
341
- return False
342
- self.calls_used += 1
343
- return True
344
-
345
-
346
- @dataclass
347
- class _ResilienceRetryStats:
348
- """Mutable accumulator for retry sweep statistics (FR-145.7).
349
-
350
- Passed by reference into ``_retry_error_rows`` so the caller can read
351
- the final counts without the method returning a tuple.
352
- """
353
-
354
- error_rows_before_retry: int = 0
355
- retry_attempts: int = 0
356
- retry_successes: int = 0
357
- budget_used: int = 0
358
- budget_total: int = 0
359
- failover_hops: int = 0
360
- providers_used: list[str] = field(default_factory=list)
361
- quota_exhausted_rows: int = 0
362
- quota_wait_attempted_rows: int = 0
363
- quota_wait_recovered_rows: int = 0
364
- # Phase 166: Prompt-level retry/failover telemetry
365
- prompt_retry_attempts: int = 0
366
- prompt_retry_recoveries: int = 0
367
- prompt_failover_attempts: int = 0
368
- prompt_failover_recoveries: int = 0
369
- prompt_failover_exhausted: int = 0
370
- synthesis_fallback_count: int = 0
371
-
372
-
373
- @dataclass
374
- class BatchResult:
375
- """Result of processing a single batch."""
376
-
377
- batch_index: int
378
- start_row: int
379
- end_row: int
380
- results: list[RowEvaluationResult]
381
- duration_ms: int
382
- success_count: int
383
- error_count: int
384
- timed_out: bool = False
385
- skipped_count: int = 0 # FR-25: Rows skipped due to targeting
386
- postproc_overlap_ms: int = 0 # FR-193: Post-processing streaming overlap
387
-
388
-
389
- class BatchBudgetExceededError(RuntimeError):
390
- """Raised when strict budget mode aborts a batch mid-execution."""
391
-
392
- def __init__(
393
- self,
394
- *,
395
- message: str,
396
- context: dict[str, Any],
397
- partial_results: list[RowEvaluationResult],
398
- success_count: int,
399
- error_count: int,
400
- skipped_count: int,
401
- ) -> None:
402
- super().__init__(message)
403
- self.context = context
404
- self.partial_results = partial_results
405
- self.success_count = success_count
406
- self.error_count = error_count
407
- self.skipped_count = skipped_count
408
-
409
-
410
- @dataclass(frozen=True)
411
- class BatchProgress:
412
- """Progress snapshot emitted after a processed batch."""
413
-
414
- batch_index: int
415
- batch_count: int
416
- start_row: int
417
- end_row: int
418
- total_rows: int
419
- completed_rows: int
420
- processed_batches: int
421
- skipped_batches: int
422
- success_count: int
423
- error_count: int
424
- skipped_count: int
425
- duration_ms: int
426
- timed_out: bool
427
- emission_kind: str = "batch"
428
- current_row_id: str | None = None
429
- current_check_id: str | None = None
430
-
431
-
432
- BatchProgressCallback = Callable[[BatchProgress, list[RowEvaluationResult]], Awaitable[None] | None]
433
- RowProgressCallback = Callable[
434
- [int, int, int, list[RowEvaluationResult], int, int, int, RowEvaluationResult | None, str],
435
- Awaitable[None] | None,
436
- ]
437
-
438
-
439
- @dataclass
440
- class BatchCheckpoint:
441
- """Checkpoint for resumable processing (FR-3.3).
442
-
443
- CRITICAL: Stores full row results to enable complete reconstruction on resume.
444
- """
445
-
446
- thread_id: str
447
- total_rows: int
448
- template_hash: str # FR-3.3: For cache invalidation
449
- evidence_hash: str # FR-3.3: For cache invalidation
450
- completed_batches: list[int]
451
- # FR-3.3: Row ID -> serialized RowEvaluationResult (full results, not just status)
452
- results_by_row_id: dict[str, dict[str, Any]]
453
- last_updated: datetime = field(default_factory=lambda: datetime.now(UTC))
454
-
455
- def save(self, path: Path) -> None:
456
- """Save checkpoint to file."""
457
- data = {
458
- "thread_id": self.thread_id,
459
- "total_rows": self.total_rows,
460
- "template_hash": self.template_hash,
461
- "evidence_hash": self.evidence_hash,
462
- "completed_batches": self.completed_batches,
463
- "results_by_row_id": self.results_by_row_id,
464
- "last_updated": self.last_updated.isoformat(),
465
- }
466
- path.parent.mkdir(parents=True, exist_ok=True)
467
- path.write_text(json.dumps(data, indent=2, ensure_ascii=False))
468
-
469
- @classmethod
470
- def load(cls, path: Path) -> BatchCheckpoint | None:
471
- """Load checkpoint from file."""
472
- if not path.exists():
473
- return None
474
- try:
475
- data = json.loads(path.read_text())
476
- return cls(
477
- thread_id=data["thread_id"],
478
- total_rows=data["total_rows"],
479
- template_hash=data.get("template_hash", ""),
480
- evidence_hash=data.get("evidence_hash", ""),
481
- completed_batches=data["completed_batches"],
482
- results_by_row_id=data.get("results_by_row_id", {}),
483
- last_updated=datetime.fromisoformat(data["last_updated"]),
484
- )
485
- except Exception as e:
486
- logger.warning("checkpoint_load_failed", error=str(e))
487
- return None
488
-
489
- @staticmethod
490
- def serialize_row_result(result: RowEvaluationResult) -> dict[str, Any]:
491
- """Serialize a RowEvaluationResult for checkpoint storage (FR-3.3)."""
492
- # Basic serialization - assumes RowEvaluationResult and children have model_dump or similar
493
- # Since RowEvaluationResult is Pydantic model (usually), model_dump is available
494
- # But let's be safe and use json-compatible dict
495
-
496
- # Helper to safely dump models
497
- def safe_dump(obj: Any) -> Any:
498
- if obj is None:
499
- return None
500
- if hasattr(obj, "model_dump"):
501
- dumped = obj.model_dump()
502
- # Convert datetime objects to ISO strings
503
- return _convert_datetimes(dumped)
504
- if hasattr(obj, "dict"):
505
- dumped = obj.dict()
506
- return _convert_datetimes(dumped)
507
- if isinstance(obj, datetime):
508
- return obj.isoformat()
509
- return obj
510
-
511
- retrieval_trace = _sanitize_retrieval_trace(result.retrieval_trace)
512
-
513
- return {
514
- "row_id": result.row_id,
515
- "check_id": result.check_id,
516
- "status": result.status.value if hasattr(result.status, "value") else str(result.status),
517
- "score": result.score,
518
- "score_breakdown": safe_dump(result.score_breakdown),
519
- "reason": result.reason,
520
- "finding": result.finding,
521
- "evidence_anchors": [safe_dump(e) for e in (result.evidence_anchors or [])],
522
- "provenance": safe_dump(result.provenance),
523
- "severity": result.severity,
524
- "priority": result.priority,
525
- "effort": result.effort,
526
- "recommendation": result.recommendation,
527
- "fix_suggestions": result.fix_suggestions,
528
- "score_1_5": result.score_1_5,
529
- "cache_hit": result.cache_hit,
530
- "error_message": result.error_message,
531
- "retry_count": result.retry_count,
532
- "retry_metadata": result.retry_metadata,
533
- "retrieval_trace": retrieval_trace,
534
- "coverage_requirements": result.coverage_requirements,
535
- "coverage_code": result.coverage_code,
536
- "coverage_docs": result.coverage_docs,
537
- "coverage_confidence": result.coverage_confidence,
538
- "coverage_deterministic_downgrade_flag": result.coverage_deterministic_downgrade_flag,
539
- }
540
-
541
- @staticmethod
542
- def deserialize_row_result(data: dict[str, Any]) -> RowEvaluationResult:
543
- """Deserialize a RowEvaluationResult from checkpoint (FR-3.3)."""
544
- # We need to reconstruct the objects. This requires importing the types.
545
- # This is best effort reconstruction for resumption.
546
- from vds_audit_orchestrator.engine.row_evaluator_types import RowEvaluationResult
547
- from vds_audit_orchestrator.models.checklist import (
548
- EvidenceAnchor,
549
- RowProvenance,
550
- RowStatus,
551
- ScoreBreakdown,
552
- )
553
-
554
- # Handle status enum
555
- status_val = data.get("status", "ERROR")
556
- try:
557
- status = RowStatus(status_val)
558
- except ValueError:
559
- status = RowStatus.ERROR
560
-
561
- # Reconstruct complex objects
562
- score_breakdown = (
563
- ScoreBreakdown(**data.get("score_breakdown", {}))
564
- if data.get("score_breakdown")
565
- else ScoreBreakdown.compute(data.get("score", 0.0))
566
- )
567
-
568
- anchors = []
569
- for a_data in data.get("evidence_anchors", []):
570
- anchors.append(EvidenceAnchor(**a_data))
571
-
572
- provenance = RowProvenance(**data.get("provenance", {})) if data.get("provenance") else None
573
-
574
- # Remove keys that are not fields of RowEvaluationResult or handle extra fields
575
- # Ideally verify against RowEvaluationResult.__init__ args
576
-
577
- return RowEvaluationResult(
578
- row_id=data["row_id"],
579
- check_id=data["check_id"],
580
- status=status,
581
- score=data.get("score", 0.0),
582
- score_breakdown=score_breakdown,
583
- reason=data.get("reason") or "",
584
- reasoning=data.get("reasoning") or "",
585
- finding=data.get("finding") or "",
586
- evidence_anchors=anchors,
587
- provenance=provenance, # type: ignore[arg-type]
588
- severity=data.get("severity") or "",
589
- priority=data.get("priority") or "",
590
- effort=data.get("effort") or "",
591
- recommendation=data.get("recommendation") or "",
592
- fix_suggestions=data.get("fix_suggestions") or [],
593
- score_1_5=data.get("score_1_5"),
594
- cache_hit=data.get("cache_hit", False),
595
- error_message=data.get("error_message"),
596
- retry_count=max(0, int(data.get("retry_count", 0))),
597
- retry_metadata=dict(data.get("retry_metadata") or {}),
598
- retrieval_trace=_sanitize_retrieval_trace(data.get("retrieval_trace")),
599
- coverage_requirements=data.get("coverage_requirements"),
600
- coverage_code=data.get("coverage_code"),
601
- coverage_docs=data.get("coverage_docs"),
602
- coverage_confidence=data.get("coverage_confidence"),
603
- coverage_deterministic_downgrade_flag=bool(data.get("coverage_deterministic_downgrade_flag", False)),
604
- )
605
-
606
-
607
- class BatchRowProcessor:
608
- """Processes checklist rows in batches with checkpoint support.
609
-
610
- Supports targeted row execution (FR-25) where only specific rows are
611
- evaluated while preserving checkpoint state for non-targeted rows.
612
- """
613
-
614
- def __init__(
615
- self,
616
- template: AuditTemplate,
617
- evaluator: RowEvaluator,
618
- evidence_matcher: MatcherProtocol,
619
- config: BatchConfig,
620
- *,
621
- grounding_validator: GroundingValidator | None = None,
622
- ):
623
- """Initialize batch processor.
624
-
625
- Args:
626
- template: Audit template with checks.
627
- evaluator: Row evaluator instance.
628
- evidence_matcher: Evidence matcher for per-row context.
629
- config: Batch processing configuration.
630
- grounding_validator: Optional validator for FR-7.
631
- """
632
- self.template = template
633
- self.evaluator = evaluator
634
- self.evidence_matcher = evidence_matcher
635
- self.config = config
636
- self.grounding_validator = grounding_validator
637
-
638
- # Flatten checks for easier batch processing
639
- self._checks: list[tuple[str, AuditCheck]] = []
640
- for section in template.sections:
641
- for check in section.checks:
642
- self._checks.append((section.id, check))
643
- self.last_progress: BatchProgress | None = None
644
- self.last_execution_summary: dict[str, int] = {
645
- "processed_batches": 0,
646
- "skipped_batches": 0,
647
- "total_results": 0,
648
- "batch_count": 0,
649
- }
650
- # FR-145.7: Per-run resilience telemetry; reset at process_all start.
651
- self.last_resilience_summary: dict[str, Any] | None = None
652
- self._resilience_stats_accumulator: list[_ResilienceRetryStats] = []
653
- self._batch_match_cache: dict[tuple[str, str | None, str, bool], RowEvidenceContext] = {}
654
- self._batch_match_inflight: dict[tuple[str, str | None, str, bool], asyncio.Future[RowEvidenceContext]] = {}
655
- self._batch_match_lock = asyncio.Lock()
656
- self._adaptive_row_concurrency_current = max(1, int(self.config.row_concurrency or 1))
657
-
658
- @staticmethod
659
- def _preflight_provider_checks_from_run_context(run_context: dict[str, Any] | None) -> dict[str, dict[str, Any]]:
660
- if not isinstance(run_context, dict):
661
- return {}
662
- raw_checks = run_context.get("profile_availability_checks")
663
- if not isinstance(raw_checks, list):
664
- return {}
665
-
666
- normalized: dict[str, dict[str, Any]] = {}
667
- for item in raw_checks:
668
- if not isinstance(item, dict):
669
- continue
670
- profile_name = str(item.get("profile") or "").strip()
671
- if not profile_name:
672
- continue
673
- normalized[profile_name] = dict(item)
674
- return normalized
675
-
676
- async def _seed_batch_health_memory_from_preflight(self) -> None:
677
- runtime_context = self.config.run_context if isinstance(self.config.run_context, dict) else {}
678
- preflight_checks = self._preflight_provider_checks_from_run_context(runtime_context)
679
- if not preflight_checks:
680
- return
681
-
682
- for provider_name, probe in preflight_checks.items():
683
- await self._batch_health_memory.apply_preflight_probe(provider_name, probe)
684
-
685
- @staticmethod
686
- async def _record_runtime_provider_result(
687
- health_memory: ProviderHealthMemory | None,
688
- *,
689
- provider_name: str | None,
690
- result: RowEvaluationResult,
691
- ) -> None:
692
- if health_memory is None:
693
- return
694
-
695
- normalized_provider = str(provider_name or "").strip()
696
- if not normalized_provider:
697
- return
698
-
699
- retry_metadata = dict(result.retry_metadata or {}) if isinstance(result.retry_metadata, dict) else {}
700
- if result.status == RowStatus.ERROR:
701
- reason_code = str(retry_metadata.get("reason_code") or "").strip().lower()
702
- if not reason_code:
703
- return
704
- failure_class = {
705
- "provider_authentication_failed": ProviderFailureClass.TERMINAL_AUTH,
706
- "provider_authorization_failed": ProviderFailureClass.TERMINAL_AUTH,
707
- "provider_rate_limited": ProviderFailureClass.QUOTA_OR_CAPACITY,
708
- "provider_server_error": ProviderFailureClass.RETRYABLE_TRANSIENT,
709
- "provider_transient_error": ProviderFailureClass.RETRYABLE_TRANSIENT,
710
- "provider_http_error": ProviderFailureClass.RETRYABLE_TRANSIENT,
711
- }.get(reason_code)
712
- if failure_class is None:
713
- return
714
- retry_after_raw = retry_metadata.get("retry_after_seconds")
715
- retry_after_seconds: float | None
716
- try:
717
- retry_after_seconds = float(retry_after_raw) if retry_after_raw is not None else None
718
- except (TypeError, ValueError):
719
- retry_after_seconds = None
720
-
721
- await health_memory.record_failure(
722
- normalized_provider,
723
- classification=ProviderFailureClassification(
724
- failure_class=failure_class,
725
- is_failoverable=failure_class != ProviderFailureClass.TERMINAL_AUTH,
726
- retry_after_seconds=retry_after_seconds,
727
- raw_status_code=None,
728
- raw_message=reason_code,
729
- classification_reason=reason_code,
730
- ),
731
- )
732
- return
733
-
734
- await health_memory.record_success(normalized_provider)
735
-
736
- # ------------------------------------------------------------------
737
- # Phase 146: Bounded all-providers-exhausted recovery (FR-146.6)
738
- # ------------------------------------------------------------------
739
-
740
- @staticmethod
741
- async def _bounded_wait_for_provider_recovery(
742
- health_memory: ProviderHealthMemory,
743
- *,
744
- failover_profiles: list[str],
745
- max_wait_seconds: float,
746
- poll_interval_seconds: float = 2.0,
747
- row_id: str | None = None,
748
- check_id: str | None = None,
749
- ) -> str | None:
750
- """Wait bounded time for a provider to recover from cooldown/exhaustion (AC-146.6.1).
751
-
752
- Uses ``nearest_recovery_seconds()`` from the shared provider health state
753
- to estimate the earliest possible recovery. The wait is capped by
754
- ``max_wait_seconds`` (from ``VDS_AUDIT_QUOTA_WAIT_MAX_SECONDS``).
755
-
756
- Returns:
757
- A recovered profile name, or ``None`` if no provider became eligible
758
- within the cap.
759
-
760
- Telemetry:
761
- Emits structured log events for wait-start, provider-recovered, and
762
- wait-expired boundaries so operators can diagnose quota timing.
763
- """
764
- import time as _time
765
-
766
- if max_wait_seconds <= 0 or not failover_profiles:
767
- return None
768
-
769
- # Check if any provider is only temporarily blocked (not auth-blocked).
770
- has_temporary_blockage = any(
771
- not health_memory.get_state(p).is_auth_blocked() and health_memory.get_state(p).should_skip_dispatch()
772
- for p in failover_profiles
773
- )
774
- if not has_temporary_blockage:
775
- return None
776
-
777
- # Determine how long to wait: min of configured cap and nearest recovery hint.
778
- recovery_hint = health_memory.nearest_recovery_seconds()
779
- if recovery_hint is not None and recovery_hint > 0:
780
- wait_target = min(max_wait_seconds, recovery_hint + 1.0)
781
- else:
782
- wait_target = max_wait_seconds
783
-
784
- logger.info(
785
- "quota_bounded_wait_started",
786
- row_id=row_id,
787
- check_id=check_id,
788
- max_wait_seconds=max_wait_seconds,
789
- recovery_hint_seconds=recovery_hint,
790
- wait_target_seconds=wait_target,
791
- failover_profiles=failover_profiles,
792
- )
793
-
794
- deadline = _time.monotonic() + wait_target
795
- recovered_profile: str | None = None
796
-
797
- while _time.monotonic() < deadline:
798
- remaining = deadline - _time.monotonic()
799
- if remaining <= 0:
800
- break
801
- sleep_seconds = min(poll_interval_seconds, remaining)
802
- await asyncio.sleep(sleep_seconds)
803
-
804
- # Check if any provider has become eligible.
805
- for candidate in failover_profiles:
806
- state = health_memory.get_state(candidate)
807
- if not state.is_auth_blocked() and not state.should_skip_dispatch():
808
- recovered_profile = candidate
809
- break
810
- if recovered_profile is not None:
811
- break
812
-
813
- if recovered_profile is not None:
814
- logger.info(
815
- "quota_bounded_wait_provider_recovered",
816
- row_id=row_id,
817
- check_id=check_id,
818
- recovered_provider=recovered_profile,
819
- elapsed_seconds=wait_target - (deadline - _time.monotonic()),
820
- )
821
- else:
822
- logger.warning(
823
- "quota_bounded_wait_expired",
824
- row_id=row_id,
825
- check_id=check_id,
826
- max_wait_seconds=max_wait_seconds,
827
- failover_profiles=failover_profiles,
828
- )
829
-
830
- return recovered_profile
831
-
832
- @staticmethod
833
- def _annotate_quota_exhaustion(
834
- result: RowEvaluationResult,
835
- *,
836
- health_memory: ProviderHealthMemory,
837
- failover_profiles: list[str],
838
- wait_attempted: bool = False,
839
- wait_expired: bool = False,
840
- ) -> RowEvaluationResult:
841
- """Annotate a row result with quota-exhaustion metadata (AC-146.6.4).
842
-
843
- Mutates ``retry_metadata`` in-place and returns the same result.
844
- """
845
- reason = _all_providers_exhausted_reason(health_memory, failover_profiles=failover_profiles)
846
- if reason is None:
847
- return result
848
-
849
- metadata = dict(result.retry_metadata or {})
850
- metadata["quota_all_providers_exhausted"] = True
851
- metadata["quota_exhaustion_reason"] = reason
852
- metadata["quota_exhaustion_wait_attempted"] = wait_attempted
853
- metadata["quota_exhaustion_wait_expired"] = wait_expired
854
-
855
- # Attach per-provider skip reasons for telemetry clarity (AC-146.7.2).
856
- provider_skip_reasons: dict[str, str] = {}
857
- for profile in failover_profiles:
858
- state = health_memory.get_state(profile)
859
- if state.is_auth_blocked():
860
- provider_skip_reasons[profile] = "auth_blocked"
861
- elif state.is_in_cooldown():
862
- provider_skip_reasons[profile] = "cooldown"
863
- elif state.rate_limit.request_capacity_known_empty():
864
- provider_skip_reasons[profile] = "request_quota_empty"
865
- elif state.rate_limit.token_capacity_known_empty():
866
- provider_skip_reasons[profile] = "token_quota_empty"
867
- elif state.should_skip_dispatch():
868
- provider_skip_reasons[profile] = "degraded"
869
- else:
870
- provider_skip_reasons[profile] = "eligible"
871
- metadata["quota_provider_skip_reasons"] = provider_skip_reasons
872
- result.retry_metadata = metadata
873
- return result
874
-
875
- @staticmethod
876
- def _build_match_requirement_text(check: AuditCheck) -> str:
877
- """Augment matcher query with canonical checklist hints."""
878
- base = (check.description or check.name or "").strip()
879
- config = check.check_config if isinstance(check.check_config, dict) else {}
880
- extras = [
881
- str(config.get("confluence_rule") or "").strip(),
882
- str(config.get("confluence_main") or "").strip(),
883
- str(config.get("confluence_eval_guide") or "").strip(),
884
- str(config.get("confluence_evidence_hint") or "").strip(),
885
- str(config.get("evidence_required") or "").strip(),
886
- ]
887
- suffix = " ".join(part for part in extras if part)
888
- if base and suffix:
889
- return f"{base} {suffix}"
890
- return base or suffix
891
-
892
- @staticmethod
893
- def _row_requires_app_config_only(check: AuditCheck) -> bool:
894
- """Return True when row guidance explicitly restricts retrieval to app-config."""
895
- config = check.check_config if isinstance(check.check_config, dict) else {}
896
- return requires_app_config_only(
897
- check.description or check.name or "",
898
- config.get("confluence_rule"),
899
- config.get("confluence_main"),
900
- config.get("confluence_eval_guide"),
901
- config.get("confluence_evidence_hint"),
902
- config.get("detailed_guidance"),
903
- config.get("confluence_notes"),
904
- config.get("evidence_required"),
905
- )
906
-
907
- @staticmethod
908
- def _empty_evidence_context(*, row_id: str, requirement_text: str) -> RowEvidenceContext:
909
- """Return an empty evidence context for rows that must bypass matcher retrieval."""
910
- return RowEvidenceContext(
911
- row_id=row_id,
912
- requirement_text=requirement_text,
913
- matched_docs=[],
914
- matched_code=[],
915
- evidence_refs=[],
916
- total_chars=0,
917
- truncated=False,
918
- retrieval_trace=None,
919
- )
920
-
921
- @staticmethod
922
- def _clone_evidence_context(
923
- *, context: RowEvidenceContext, row_id: str, requirement_text: str
924
- ) -> RowEvidenceContext:
925
- """Clone matcher context so cached retrieval can be reused safely per row."""
926
- return RowEvidenceContext(
927
- row_id=row_id,
928
- requirement_text=requirement_text,
929
- matched_docs=copy.deepcopy(getattr(context, "matched_docs", []) or []),
930
- matched_code=copy.deepcopy(getattr(context, "matched_code", []) or []),
931
- evidence_refs=list(getattr(context, "evidence_refs", []) or []),
932
- total_chars=int(getattr(context, "total_chars", 0) or 0),
933
- truncated=bool(getattr(context, "truncated", False)),
934
- retrieval_trace=copy.deepcopy(getattr(context, "retrieval_trace", None)),
935
- )
936
-
937
- async def _get_or_match_evidence_context(
938
- self,
939
- *,
940
- row_id: str,
941
- requirement_text: str,
942
- section_id: str | None,
943
- app_config_only: bool,
944
- ) -> RowEvidenceContext:
945
- """Return row evidence context with in-batch dedup for parallel rows."""
946
- if app_config_only:
947
- return self._empty_evidence_context(row_id=row_id, requirement_text=requirement_text)
948
-
949
- cache_key = (
950
- requirement_text,
951
- str(section_id) if section_id is not None else None,
952
- str(getattr(self.evidence_matcher, "retrieval_mode", "unknown") or "unknown"),
953
- False,
954
- )
955
-
956
- async with self._batch_match_lock:
957
- cached = self._batch_match_cache.get(cache_key)
958
- if cached is not None:
959
- return self._clone_evidence_context(
960
- context=cached,
961
- row_id=row_id,
962
- requirement_text=requirement_text,
963
- )
964
- inflight = self._batch_match_inflight.get(cache_key)
965
- if inflight is None:
966
- loop = asyncio.get_running_loop()
967
- inflight = loop.create_future()
968
- self._batch_match_inflight[cache_key] = inflight
969
- owner = True
970
- else:
971
- owner = False
972
-
973
- if owner:
974
- try:
975
- matched = await asyncio.to_thread(
976
- self.evidence_matcher.match_row,
977
- row_id=row_id,
978
- requirement_text=requirement_text,
979
- section_id=section_id,
980
- )
981
- canonical = self._clone_evidence_context(
982
- context=matched,
983
- row_id="__shared__",
984
- requirement_text=requirement_text,
985
- )
986
- async with self._batch_match_lock:
987
- self._batch_match_cache[cache_key] = canonical
988
- pending = self._batch_match_inflight.pop(cache_key, None)
989
- if pending is not None and not pending.done():
990
- pending.set_result(canonical)
991
- return self._clone_evidence_context(
992
- context=canonical,
993
- row_id=row_id,
994
- requirement_text=requirement_text,
995
- )
996
- except Exception as exc:
997
- async with self._batch_match_lock:
998
- pending = self._batch_match_inflight.pop(cache_key, None)
999
- if pending is not None and not pending.done():
1000
- pending.set_exception(exc)
1001
- raise
1002
-
1003
- shared_context = await inflight
1004
- return self._clone_evidence_context(
1005
- context=shared_context,
1006
- row_id=row_id,
1007
- requirement_text=requirement_text,
1008
- )
1009
-
1010
- def _effective_row_concurrency(self) -> int:
1011
- """Return current row concurrency after optional adaptive adjustment."""
1012
- if not self.config.adaptive_row_concurrency:
1013
- return max(1, int(self.config.row_concurrency or 1))
1014
- configured = max(1, int(self.config.row_concurrency or 1))
1015
- lower = max(1, int(self.config.adaptive_row_concurrency_min or 1))
1016
- upper = max(lower, int(self.config.adaptive_row_concurrency_max or configured))
1017
- return max(lower, min(upper, int(self._adaptive_row_concurrency_current or configured)))
1018
-
1019
- def _repo_row_distribution_profiles(self) -> list[str]:
1020
- runtime_context = self.config.run_context if isinstance(self.config.run_context, dict) else {}
1021
- raw_profiles = runtime_context.get("repo_distribution_profiles")
1022
- if not isinstance(raw_profiles, (list, tuple)):
1023
- return []
1024
- ordered: list[str] = []
1025
- seen: set[str] = set()
1026
- for item in raw_profiles:
1027
- normalized = str(item or "").strip()
1028
- if not normalized or normalized in seen:
1029
- continue
1030
- seen.add(normalized)
1031
- ordered.append(normalized)
1032
- return ordered
1033
-
1034
- def _repo_row_distribution_enabled(self) -> bool:
1035
- runtime_context = self.config.run_context if isinstance(self.config.run_context, dict) else {}
1036
- mode = str(runtime_context.get("repo_profile_execution_mode") or "single").strip().lower()
1037
- return mode == "distributed" and len(self._repo_row_distribution_profiles()) > 1
1038
-
1039
- def _assigned_repo_profile_for_row(self, row_index: int) -> str | None:
1040
- profiles = self._repo_row_distribution_profiles()
1041
- if not self._repo_row_distribution_enabled() or not profiles:
1042
- return None
1043
- return profiles[row_index % len(profiles)]
1044
-
1045
- def _update_adaptive_row_concurrency(self, batch_result: BatchResult) -> None:
1046
- """Adjust opt-in row concurrency between batches based on observed batch health."""
1047
- if not self.config.adaptive_row_concurrency:
1048
- return
1049
-
1050
- current = self._effective_row_concurrency()
1051
- lower = max(1, int(self.config.adaptive_row_concurrency_min or 1))
1052
- upper = max(lower, int(self.config.adaptive_row_concurrency_max or current))
1053
- increase_threshold_ms = max(1, int(self.config.adaptive_row_concurrency_increase_threshold_ms or 1000))
1054
- decrease_threshold_ms = max(
1055
- increase_threshold_ms, int(self.config.adaptive_row_concurrency_decrease_threshold_ms or 5000)
1056
- )
1057
-
1058
- next_value = current
1059
- reason = None
1060
- if batch_result.timed_out or batch_result.error_count > 0 or batch_result.duration_ms >= decrease_threshold_ms:
1061
- if current > lower:
1062
- next_value = current - 1
1063
- reason = "batch_pressure"
1064
- elif (
1065
- batch_result.duration_ms <= increase_threshold_ms
1066
- and batch_result.error_count == 0
1067
- and not batch_result.timed_out
1068
- ) and current < upper:
1069
- next_value = current + 1
1070
- reason = "batch_healthy"
1071
-
1072
- self._adaptive_row_concurrency_current = next_value
1073
- if reason is not None and next_value != current:
1074
- logger.info(
1075
- "adaptive_row_concurrency_adjusted",
1076
- previous=current,
1077
- current=next_value,
1078
- reason=reason,
1079
- batch_index=batch_result.batch_index,
1080
- batch_duration_ms=batch_result.duration_ms,
1081
- batch_error_count=batch_result.error_count,
1082
- batch_timed_out=batch_result.timed_out,
1083
- **self.config.run_context,
1084
- )
1085
-
1086
- def _is_row_targeted(self, row_index: int, check_id: str) -> bool:
1087
- """Check if a row is targeted for evaluation (FR-25).
1088
-
1089
- Args:
1090
- row_index: 0-based row index.
1091
- check_id: The check ID for this row.
1092
-
1093
- Returns:
1094
- True if the row should be evaluated, False if it should be skipped.
1095
- Returns True if no target selection is configured (process all rows).
1096
- """
1097
- if self.config.target_selection is None:
1098
- return True
1099
-
1100
- # Check if row index is in target set
1101
- if self.config.target_selection.matches_row_index(row_index):
1102
- return True
1103
-
1104
- # Check if check ID is in target set (for CHECK_IDS type)
1105
- return bool(self.config.target_selection.matches_check_id(check_id.upper()))
1106
-
1107
- def _batch_has_targeted_rows(self, start_idx: int, end_idx: int) -> bool:
1108
- """Check if a batch contains any targeted rows (FR-25.2).
1109
-
1110
- Args:
1111
- start_idx: Start index of the batch (inclusive).
1112
- end_idx: End index of the batch (exclusive).
1113
-
1114
- Returns:
1115
- True if the batch has at least one targeted row.
1116
- Returns True if no target selection is configured.
1117
- """
1118
- if self.config.target_selection is None:
1119
- return True
1120
-
1121
- for idx in range(start_idx, end_idx):
1122
- _, check = self._checks[idx]
1123
- if self._is_row_targeted(idx, check.id):
1124
- return True
1125
- return False
1126
-
1127
- def _should_emit_row_progress_callback(
1128
- self,
1129
- current_result: RowEvaluationResult | None,
1130
- outcome: str,
1131
- ) -> bool:
1132
- """Suppress noisy row-level progress events for skipped non-target rows."""
1133
- return not (outcome == "skipped" and current_result is None and self.config.target_selection is not None)
1134
-
1135
- @staticmethod
1136
- def _build_inflight_row_progress_result(check: AuditCheck, row_id: str) -> RowEvaluationResult:
1137
- """Create an in-memory placeholder used only for row-start progress telemetry."""
1138
- return RowEvaluationResult(
1139
- row_id=row_id,
1140
- check_id=check.id,
1141
- status=RowStatus.NA,
1142
- score=0.0,
1143
- score_breakdown=ScoreBreakdown.compute(0.0),
1144
- reason="Đang chờ đánh giá theo tiến độ batch.",
1145
- finding="Kết quả sẽ được cập nhật khi batch chứa hàng này hoàn tất.",
1146
- evidence_anchors=[],
1147
- provenance=RowProvenance(
1148
- row_llm_mode="selective",
1149
- protocol=None,
1150
- model=None,
1151
- template_hash="",
1152
- rubric_version="1",
1153
- evidence_hash="",
1154
- evaluated_at=datetime.now(UTC),
1155
- ),
1156
- )
1157
-
1158
- def _should_evaluate_row(
1159
- self,
1160
- row_index: int,
1161
- check_id: str,
1162
- row_id: str,
1163
- checkpoint: BatchCheckpoint,
1164
- ) -> bool:
1165
- """Determine if a row should be evaluated (FR-25.3, FR-25.4, FR-185).
1166
-
1167
- Considers:
1168
- - Whether the row is scoped N/A by repo-type policy (FR-185)
1169
- - Whether the row is targeted
1170
- - Whether the row has prior checkpoint results
1171
- - Whether force_refresh_targets is enabled
1172
-
1173
- Args:
1174
- row_index: 0-based row index.
1175
- check_id: The check ID for this row.
1176
- row_id: The unique row identifier.
1177
- checkpoint: Current checkpoint state.
1178
-
1179
- Returns:
1180
- True if the row should be evaluated, False if it should be skipped
1181
- or checkpoint result should be used.
1182
- """
1183
- # FR-185: Skip rows marked N/A by repo-type scoping policy entirely.
1184
- # This prevents evidence retrieval, prompt construction, and LLM calls
1185
- # for structurally inapplicable rows (e.g., DB rows for frontend repos).
1186
- if row_index in self.config.scoped_na_indices:
1187
- return False
1188
-
1189
- is_targeted = self._is_row_targeted(row_index, check_id)
1190
- has_checkpoint_result = row_id in checkpoint.results_by_row_id
1191
-
1192
- if not is_targeted:
1193
- # Non-targeted rows: never evaluate, just preserve checkpoint if available
1194
- return False
1195
-
1196
- # Targeted rows
1197
- if self.config.force_refresh_targets:
1198
- # FR-25.4: Re-evaluate targeted rows even if checkpointed
1199
- return True
1200
-
1201
- # Only evaluate if no checkpoint result exists
1202
- return not has_checkpoint_result
1203
-
1204
- async def process_all(
1205
- self,
1206
- thread_id: str,
1207
- project_profile: dict[str, Any] | None = None,
1208
- progress_callback: BatchProgressCallback | None = None,
1209
- ) -> list[RowEvaluationResult]:
1210
- """Process all rows in batches with checkpoint/resume (FR-3.3) and targeting (FR-25)."""
1211
- # FR-145.7: Reset resilience accumulator so each run starts fresh.
1212
- self._resilience_stats_accumulator = []
1213
- self.last_resilience_summary = None
1214
- total_rows = len(self._checks)
1215
-
1216
- # Load checkpoint if resuming
1217
- checkpoint_path = self._get_checkpoint_path(thread_id)
1218
- checkpoint: BatchCheckpoint | None = None
1219
- if self.config.resume_from_checkpoint:
1220
- checkpoint = BatchCheckpoint.load(checkpoint_path)
1221
- if checkpoint:
1222
- # Validate checkpoint matches current template/evidence
1223
- current_evidence_hash = self.evaluator.evidence_hash or ""
1224
- if (
1225
- checkpoint.template_hash != self.evaluator.template_hash
1226
- or checkpoint.evidence_hash != current_evidence_hash
1227
- ):
1228
- logger.warning(
1229
- "checkpoint_hash_mismatch_starting_fresh",
1230
- checkpoint_template=checkpoint.template_hash,
1231
- current_template=self.evaluator.template_hash,
1232
- )
1233
- checkpoint = None
1234
- else:
1235
- logger.info(
1236
- "resuming_from_checkpoint",
1237
- completed_rows=len(checkpoint.results_by_row_id),
1238
- total_rows=total_rows,
1239
- )
1240
-
1241
- if not checkpoint:
1242
- checkpoint = BatchCheckpoint(
1243
- thread_id=thread_id,
1244
- total_rows=total_rows,
1245
- template_hash=self.evaluator.template_hash,
1246
- evidence_hash=self.evaluator.evidence_hash or "",
1247
- completed_batches=[],
1248
- results_by_row_id={},
1249
- )
1250
-
1251
- # FR-25: Log targeting info if configured
1252
- if self.config.target_selection:
1253
- target_count = len(self.config.target_selection.row_indices)
1254
- logger.info(
1255
- "targeted_execution_mode",
1256
- target_type=self.config.target_selection.target_type.value,
1257
- target_count=target_count,
1258
- total_rows=total_rows,
1259
- force_refresh=self.config.force_refresh_targets,
1260
- )
1261
-
1262
- # FR-3.3: Seed results from checkpoint for complete result set on resume
1263
- # FR-25.3: For non-targeted rows, preserve checkpoint state
1264
- all_results: list[RowEvaluationResult] = []
1265
- checkpointed_row_ids: set[str] = set()
1266
-
1267
- for row_data in checkpoint.results_by_row_id.values():
1268
- try:
1269
- result = BatchCheckpoint.deserialize_row_result(row_data)
1270
- checkpointed_row_ids.add(result.row_id)
1271
- all_results.append(result)
1272
- except Exception as e:
1273
- logger.warning("failed_to_deserialize_checkpoint_row", error=str(e))
1274
-
1275
- # Calculate batches
1276
- batch_count = (total_rows + self.config.batch_size - 1) // self.config.batch_size
1277
- batches_skipped = 0
1278
- batches_processed = 0
1279
-
1280
- async def _emit_row_progress(
1281
- batch_idx: int,
1282
- start_idx: int,
1283
- end_idx: int,
1284
- batch_results_so_far: list[RowEvaluationResult],
1285
- success_count_so_far: int,
1286
- error_count_so_far: int,
1287
- skipped_count_so_far: int,
1288
- current_result: RowEvaluationResult | None,
1289
- outcome: str,
1290
- ) -> None:
1291
- # Non-targeted rows without checkpoint state return no concrete result.
1292
- # Suppress row-level telemetry for those no-op skips to avoid null-id noise.
1293
- if outcome == "skipped" and current_result is None:
1294
- return
1295
-
1296
- preview_results = list(all_results)
1297
- if outcome != "started":
1298
- for result in batch_results_so_far:
1299
- preview_results = [res for res in preview_results if res.row_id != result.row_id]
1300
- preview_results.append(result)
1301
- checkpoint.results_by_row_id[result.row_id] = BatchCheckpoint.serialize_row_result(result)
1302
-
1303
- checkpoint.last_updated = datetime.now(UTC)
1304
- checkpoint.save(checkpoint_path)
1305
-
1306
- completed_rows = len(preview_results)
1307
- target_row_count = (
1308
- len(self.config.target_selection.row_indices) if self.config.target_selection is not None else None
1309
- )
1310
- targeted_completed_rows = (
1311
- min(completed_rows, target_row_count) if target_row_count is not None else completed_rows
1312
- )
1313
- completion_scope = "targeted" if target_row_count is not None else "template"
1314
- completion_pct = round((completed_rows / total_rows) * 100.0 if total_rows > 0 else 100.0, 2)
1315
- targeted_completion_pct = round(
1316
- (targeted_completed_rows / target_row_count) * 100.0 if target_row_count else completion_pct,
1317
- 2,
1318
- )
1319
- progress = BatchProgress(
1320
- batch_index=batch_idx,
1321
- batch_count=batch_count,
1322
- start_row=start_idx,
1323
- end_row=end_idx,
1324
- total_rows=total_rows,
1325
- completed_rows=completed_rows,
1326
- processed_batches=batches_processed,
1327
- skipped_batches=batches_skipped,
1328
- success_count=success_count_so_far,
1329
- error_count=error_count_so_far,
1330
- skipped_count=skipped_count_so_far,
1331
- duration_ms=0,
1332
- timed_out=False,
1333
- emission_kind="row",
1334
- current_row_id=getattr(current_result, "row_id", None),
1335
- current_check_id=getattr(current_result, "check_id", None),
1336
- )
1337
- self.last_progress = progress
1338
- progress_context = dict(self.config.run_context or {})
1339
- if current_result is not None:
1340
- provenance = current_result.provenance
1341
- retrieval_trace = (
1342
- current_result.retrieval_trace if isinstance(current_result.retrieval_trace, dict) else {}
1343
- )
1344
- row_distribution_profile = str(retrieval_trace.get("row_distribution_profile") or "").strip() or None
1345
- original_provider = (
1346
- str(getattr(provenance, "original_provider", "") or "").strip() if provenance is not None else ""
1347
- ) or None
1348
- final_provider = (
1349
- str(getattr(provenance, "final_provider", "") or "").strip() if provenance is not None else ""
1350
- ) or None
1351
- executed_profile = row_distribution_profile or final_provider or original_provider
1352
- if executed_profile:
1353
- progress_context["executed_profile"] = executed_profile
1354
- progress_context["active_profile"] = executed_profile
1355
- if original_provider:
1356
- progress_context["origin_profile"] = original_provider
1357
- if row_distribution_profile:
1358
- progress_context["row_distribution_profile"] = row_distribution_profile
1359
- logger.info(
1360
- "row_progress",
1361
- batch=f"{progress.batch_index + 1}/{progress.batch_count}",
1362
- completed_rows=progress.completed_rows,
1363
- total_rows=progress.total_rows,
1364
- completion_pct=completion_pct,
1365
- completion_scope=completion_scope,
1366
- targeted_completed_rows=targeted_completed_rows if target_row_count is not None else None,
1367
- targeted_total_rows=target_row_count,
1368
- targeted_completion_pct=targeted_completion_pct if target_row_count is not None else None,
1369
- processed_batches=progress.processed_batches,
1370
- skipped_batches=progress.skipped_batches,
1371
- row_id=progress.current_row_id,
1372
- check_id=progress.current_check_id,
1373
- row_outcome=outcome,
1374
- thread_id=thread_id,
1375
- **progress_context,
1376
- )
1377
- if progress_callback is not None:
1378
- try:
1379
- maybe_awaitable = progress_callback(progress, list(preview_results))
1380
- if inspect.isawaitable(maybe_awaitable):
1381
- await maybe_awaitable
1382
- except Exception as e:
1383
- logger.warning(
1384
- "row_progress_callback_failed",
1385
- batch=progress.batch_index + 1,
1386
- row_id=progress.current_row_id,
1387
- error=str(e),
1388
- )
1389
-
1390
- for batch_idx in range(batch_count):
1391
- start_idx = batch_idx * self.config.batch_size
1392
- end_idx = min(start_idx + self.config.batch_size, total_rows)
1393
-
1394
- # FR-25.2: Skip whole batches when they contain no targeted rows
1395
- if not self._batch_has_targeted_rows(start_idx, end_idx):
1396
- logger.debug(
1397
- "skipping_batch_no_targets",
1398
- batch=batch_idx,
1399
- rows=f"{start_idx + 1}-{end_idx}",
1400
- )
1401
- batches_skipped += 1
1402
- continue
1403
-
1404
- # Skip completed batches (only if not in targeted mode with force_refresh)
1405
- # In targeted mode with force_refresh, we need to re-process targeted rows
1406
- if (batch_idx in checkpoint.completed_batches and self.config.target_selection is None) or not self.config.force_refresh_targets:
1407
- logger.debug("skipping_completed_batch", batch=batch_idx)
1408
- continue
1409
- # In force_refresh mode, we still process the batch but only targeted rows
1410
-
1411
- # FR-3: Progress logging
1412
- logger.info(
1413
- "processing_batch",
1414
- batch=f"{batch_idx + 1}/{batch_count}",
1415
- rows=f"{start_idx + 1}-{end_idx}",
1416
- targeted=self.config.target_selection is not None,
1417
- )
1418
-
1419
- # Process batch with timeout (FR-3.2)
1420
- try:
1421
- batch_result = await self._process_batch(
1422
- batch_idx=batch_idx,
1423
- start_idx=start_idx,
1424
- end_idx=end_idx,
1425
- project_profile=project_profile,
1426
- checkpoint=checkpoint,
1427
- thread_id=thread_id,
1428
- row_progress_callback=_emit_row_progress,
1429
- )
1430
- except BatchBudgetExceededError as exc:
1431
- for r in exc.partial_results:
1432
- all_results = [res for res in all_results if res.row_id != r.row_id]
1433
- all_results.append(r)
1434
- checkpoint.results_by_row_id[r.row_id] = BatchCheckpoint.serialize_row_result(r)
1435
-
1436
- checkpoint.last_updated = datetime.now(UTC)
1437
- checkpoint.save(checkpoint_path)
1438
- exc.context["checkpoint_path"] = str(checkpoint_path)
1439
- exc.context["completed_rows_persisted"] = len(all_results)
1440
- exc.partial_results = list(all_results)
1441
- logger.exception("batch_budget_exceeded", **exc.context)
1442
- raise
1443
-
1444
- # FR-25.3: Merge results - update targeted rows, preserve non-targeted
1445
- for r in batch_result.results:
1446
- # Remove old result if exists (for force_refresh case)
1447
- all_results = [res for res in all_results if res.row_id != r.row_id]
1448
- all_results.append(r)
1449
- # Update checkpoint
1450
- checkpoint.results_by_row_id[r.row_id] = BatchCheckpoint.serialize_row_result(r)
1451
-
1452
- # FR-3.3: Update checkpoint
1453
- if batch_idx not in checkpoint.completed_batches:
1454
- checkpoint.completed_batches.append(batch_idx)
1455
- checkpoint.last_updated = datetime.now(UTC)
1456
- checkpoint.save(checkpoint_path)
1457
-
1458
- batches_processed += 1
1459
-
1460
- progress = BatchProgress(
1461
- batch_index=batch_idx,
1462
- batch_count=batch_count,
1463
- start_row=start_idx,
1464
- end_row=end_idx,
1465
- total_rows=total_rows,
1466
- completed_rows=len(all_results),
1467
- processed_batches=batches_processed,
1468
- skipped_batches=batches_skipped,
1469
- success_count=batch_result.success_count,
1470
- error_count=batch_result.error_count,
1471
- skipped_count=batch_result.skipped_count,
1472
- duration_ms=batch_result.duration_ms,
1473
- timed_out=batch_result.timed_out,
1474
- )
1475
- self.last_progress = progress
1476
- target_row_count = (
1477
- len(self.config.target_selection.row_indices) if self.config.target_selection is not None else None
1478
- )
1479
- targeted_completed_rows = (
1480
- min(progress.completed_rows, target_row_count)
1481
- if target_row_count is not None
1482
- else progress.completed_rows
1483
- )
1484
- completion_scope = "targeted" if target_row_count is not None else "template"
1485
- targeted_completion_pct = round(
1486
- (targeted_completed_rows / target_row_count) * 100.0 if target_row_count else 100.0,
1487
- 2,
1488
- )
1489
- logger.info(
1490
- "batch_progress",
1491
- batch=f"{progress.batch_index + 1}/{progress.batch_count}",
1492
- completed_rows=progress.completed_rows,
1493
- total_rows=progress.total_rows,
1494
- completion_pct=round(
1495
- (progress.completed_rows / progress.total_rows) * 100.0 if progress.total_rows > 0 else 100.0,
1496
- 2,
1497
- ),
1498
- completion_scope=completion_scope,
1499
- targeted_completed_rows=targeted_completed_rows if target_row_count is not None else None,
1500
- targeted_total_rows=target_row_count,
1501
- targeted_completion_pct=targeted_completion_pct if target_row_count is not None else None,
1502
- processed_batches=progress.processed_batches,
1503
- skipped_batches=progress.skipped_batches,
1504
- thread_id=thread_id,
1505
- **self.config.run_context,
1506
- )
1507
-
1508
- if progress_callback is not None:
1509
- try:
1510
- maybe_awaitable = progress_callback(progress, list(all_results))
1511
- if inspect.isawaitable(maybe_awaitable):
1512
- await maybe_awaitable
1513
- except Exception as e:
1514
- logger.warning(
1515
- "batch_progress_callback_failed",
1516
- batch=progress.batch_index + 1,
1517
- error=str(e),
1518
- )
1519
-
1520
- logger.info(
1521
- "batch_complete",
1522
- batch=batch_idx + 1,
1523
- success=batch_result.success_count,
1524
- errors=batch_result.error_count,
1525
- skipped=batch_result.skipped_count,
1526
- duration_ms=batch_result.duration_ms,
1527
- timed_out=batch_result.timed_out,
1528
- )
1529
-
1530
- # FR-25: Log summary
1531
- if self.config.target_selection:
1532
- target_row_count = len(self.config.target_selection.row_indices)
1533
- logger.info(
1534
- "targeted_execution_complete",
1535
- batches_processed=batches_processed,
1536
- batches_skipped=batches_skipped,
1537
- total_results=len(all_results),
1538
- completion_scope="targeted",
1539
- targeted_completed_rows=len(all_results),
1540
- targeted_total_rows=target_row_count,
1541
- targeted_completion_pct=round(
1542
- (len(all_results) / target_row_count) * 100.0 if target_row_count else 100.0, 2
1543
- ),
1544
- thread_id=thread_id,
1545
- **self.config.run_context,
1546
- )
1547
- self.last_execution_summary = {
1548
- "processed_batches": batches_processed,
1549
- "skipped_batches": batches_skipped,
1550
- "total_results": len(all_results),
1551
- "batch_count": batch_count,
1552
- }
1553
-
1554
- # Phase 166: Accumulate prompt-level retry/failover telemetry from row results.
1555
- _prompt_stats = _ResilienceRetryStats()
1556
- for row_result in all_results:
1557
- tel = self._extract_prompt_level_telemetry(row_result)
1558
- _prompt_stats.prompt_retry_attempts += tel["prompt_retry_attempts"]
1559
- _prompt_stats.prompt_retry_recoveries += tel["prompt_retry_recoveries"]
1560
- _prompt_stats.prompt_failover_attempts += tel["prompt_failover_attempts"]
1561
- _prompt_stats.prompt_failover_recoveries += tel["prompt_failover_recoveries"]
1562
- _prompt_stats.prompt_failover_exhausted += tel["prompt_failover_exhausted"]
1563
- _prompt_stats.synthesis_fallback_count += tel["synthesis_fallback_count"]
1564
- self._resilience_stats_accumulator.append(_prompt_stats)
1565
-
1566
- # FR-145.7: Build and emit full resilience_summary at batch completion.
1567
- # Always build, regardless of whether retries ran — callers rely on the dict.
1568
- final_error_count = sum(1 for r in all_results if r.status == RowStatus.ERROR)
1569
- # error_rows_before_retry: sum of "before" snapshots across all batch stats.
1570
- error_rows_before_retry = sum(s.error_rows_before_retry for s in self._resilience_stats_accumulator)
1571
- retry_attempts = sum(s.retry_attempts for s in self._resilience_stats_accumulator)
1572
- retry_successes = sum(s.retry_successes for s in self._resilience_stats_accumulator)
1573
- retry_budget_used = sum(s.budget_used for s in self._resilience_stats_accumulator)
1574
- retry_budget_total = sum(s.budget_total for s in self._resilience_stats_accumulator)
1575
- failover_hops_total = sum(s.failover_hops for s in self._resilience_stats_accumulator)
1576
- quota_exhausted_rows = sum(s.quota_exhausted_rows for s in self._resilience_stats_accumulator)
1577
- quota_wait_attempted_rows = sum(s.quota_wait_attempted_rows for s in self._resilience_stats_accumulator)
1578
- quota_wait_recovered_rows = sum(s.quota_wait_recovered_rows for s in self._resilience_stats_accumulator)
1579
- # Phase 166: Aggregate prompt-level retry/failover telemetry.
1580
- prompt_retry_attempts = sum(s.prompt_retry_attempts for s in self._resilience_stats_accumulator)
1581
- prompt_retry_recoveries = sum(s.prompt_retry_recoveries for s in self._resilience_stats_accumulator)
1582
- prompt_failover_attempts = sum(s.prompt_failover_attempts for s in self._resilience_stats_accumulator)
1583
- prompt_failover_recoveries = sum(s.prompt_failover_recoveries for s in self._resilience_stats_accumulator)
1584
- prompt_failover_exhausted = sum(s.prompt_failover_exhausted for s in self._resilience_stats_accumulator)
1585
- synthesis_fallback_count = sum(s.synthesis_fallback_count for s in self._resilience_stats_accumulator)
1586
- # Deduplicate providers used across batches.
1587
- providers_used: list[str] = []
1588
- for s in self._resilience_stats_accumulator:
1589
- for p in s.providers_used:
1590
- if p not in providers_used:
1591
- providers_used.append(p)
1592
- # Build provider_health_summary from shared health memory if available.
1593
- health_memory: ProviderHealthMemory | None = getattr(self, "_batch_health_memory", None)
1594
- provider_health_summary: dict[str, dict[str, Any]] = {}
1595
- if health_memory is not None:
1596
- all_providers = (
1597
- set(health_memory.consecutive_failures)
1598
- | set(health_memory.total_retries)
1599
- | set(health_memory.cooldown_until)
1600
- | set(health_memory.states)
1601
- )
1602
- for provider in sorted(all_providers):
1603
- state = health_memory.get_state(provider)
1604
- provider_health_summary[provider] = {
1605
- "failures": health_memory.consecutive_failures.get(provider, 0),
1606
- "cooldowns": 1 if health_memory.is_in_cooldown(provider) else 0,
1607
- "retries": health_memory.total_retries.get(provider, 0),
1608
- "quota_status": state.quota_status.value,
1609
- "last_reason_code": state.last_reason_code,
1610
- "retry_after_seconds": state.rate_limit.retry_after_seconds,
1611
- "remaining_requests": state.rate_limit.remaining_requests,
1612
- "remaining_tokens": state.rate_limit.remaining_tokens,
1613
- }
1614
- self.last_resilience_summary = {
1615
- "total_rows": total_rows,
1616
- "error_rows_before_retry": error_rows_before_retry,
1617
- "error_rows_after_retry": final_error_count,
1618
- "retry_attempts": retry_attempts,
1619
- "retry_successes": retry_successes,
1620
- "retry_budget_used": retry_budget_used,
1621
- "retry_budget_total": retry_budget_total,
1622
- "failover_hops_total": failover_hops_total,
1623
- "providers_used": providers_used,
1624
- "provider_health_summary": provider_health_summary,
1625
- # Phase 146 quota-exhaustion telemetry (AC-146.7.3)
1626
- "quota_exhausted_rows": quota_exhausted_rows,
1627
- "quota_wait_attempted_rows": quota_wait_attempted_rows,
1628
- "quota_wait_recovered_rows": quota_wait_recovered_rows,
1629
- # Phase 166: Prompt-level retry/failover telemetry
1630
- "prompt_retry_attempts": prompt_retry_attempts,
1631
- "prompt_retry_recoveries": prompt_retry_recoveries,
1632
- "prompt_failover_attempts": prompt_failover_attempts,
1633
- "prompt_failover_recoveries": prompt_failover_recoveries,
1634
- "prompt_failover_exhausted": prompt_failover_exhausted,
1635
- "synthesis_fallback_count": synthesis_fallback_count,
1636
- }
1637
- logger.info(
1638
- "resilience_summary",
1639
- **self.last_resilience_summary,
1640
- thread_id=thread_id,
1641
- )
1642
-
1643
- return all_results
1644
-
1645
- async def _process_batch(
1646
- self,
1647
- batch_idx: int,
1648
- start_idx: int,
1649
- end_idx: int,
1650
- project_profile: dict[str, Any] | None,
1651
- checkpoint: BatchCheckpoint,
1652
- thread_id: str,
1653
- row_progress_callback: RowProgressCallback | None = None,
1654
- ) -> BatchResult:
1655
- """Process a single batch of rows with per-row timeout (FR-3.2) and targeting (FR-25).
1656
-
1657
- In mixed batches (some targeted, some not), only targeted rows are evaluated.
1658
- Non-targeted rows preserve their checkpoint state (FR-25.3).
1659
-
1660
- When row_concurrency > 1 (FR-188), rows are dispatched in parallel via
1661
- asyncio.gather with a semaphore-bounded concurrency limit.
1662
- """
1663
- self._batch_match_cache = {}
1664
- self._batch_match_inflight = {}
1665
- inline_batch_stats = _ResilienceRetryStats()
1666
- # FR-145.4 (AC-145.4.1): Create one shared ProviderHealthMemory per batch run.
1667
- # Stored as an instance attribute so _process_single_row (parallel path) and
1668
- # the serial loop below both share the same instance without extra arg threading.
1669
- self._batch_health_memory = ProviderHealthMemory()
1670
- await self._seed_batch_health_memory_from_preflight()
1671
- # FR-145.1 (AC-145.1.1): Resolve default failover profiles for this batch.
1672
- # When the operator has not explicitly configured row_failover_profiles, auto-derive
1673
- # from all configured runtime profiles minus the active profile.
1674
- import os as _os
1675
-
1676
- _failover_env = _os.getenv("VDS_AUDIT_LLM__ROW_FAILOVER_PROFILES")
1677
- if _failover_env is None:
1678
- _active = str(_os.getenv("VDS_AUDIT_ACTIVE_PROFILE") or "").strip() or None
1679
- self._batch_failover_profiles: list[str] = resolve_default_failover_profiles(_active)
1680
- if self._batch_failover_profiles:
1681
- logger.info(
1682
- "provider_failover_auto_enabled",
1683
- active_profile=_active,
1684
- failover_profiles=self._batch_failover_profiles,
1685
- source="auto_derived",
1686
- )
1687
- else:
1688
- import json as _json
1689
-
1690
- try:
1691
- _raw = _json.loads(_failover_env)
1692
- self._batch_failover_profiles = (
1693
- [str(p).strip() for p in _raw if str(p).strip()] if isinstance(_raw, list) else []
1694
- )
1695
- except Exception:
1696
- self._batch_failover_profiles = [p.strip() for p in _failover_env.split(",") if p.strip()]
1697
-
1698
- # FR-188: Dispatch to parallel path when concurrency > 1
1699
- if self.config.row_concurrency > 1:
1700
- return await self._process_batch_parallel(
1701
- batch_idx=batch_idx,
1702
- start_idx=start_idx,
1703
- end_idx=end_idx,
1704
- project_profile=project_profile,
1705
- checkpoint=checkpoint,
1706
- thread_id=thread_id,
1707
- row_progress_callback=row_progress_callback,
1708
- batch_stats=inline_batch_stats,
1709
- )
1710
- import time
1711
-
1712
- start_time = time.monotonic()
1713
- results: list[RowEvaluationResult] = []
1714
- success_count = 0
1715
- error_count = 0
1716
- skipped_count = 0
1717
- timed_out = False
1718
- next_row_index = start_idx
1719
-
1720
- try:
1721
- effective_batch_timeout_ms = self.effective_batch_timeout_ms()
1722
- async with asyncio.timeout(effective_batch_timeout_ms / 1000):
1723
- for idx in range(start_idx, end_idx):
1724
- next_row_index = idx
1725
- section_id, check = self._checks[idx]
1726
- row_id = f"{check.id}:row_{idx}"
1727
-
1728
- # FR-25.3, FR-25.4: Check if row should be evaluated
1729
- if not self._should_evaluate_row(idx, check.id, row_id, checkpoint):
1730
- # Preserve checkpoint state for non-targeted rows
1731
- preserved_result: RowEvaluationResult | None = None
1732
- if row_id in checkpoint.results_by_row_id:
1733
- try:
1734
- preserved_result = BatchCheckpoint.deserialize_row_result(
1735
- checkpoint.results_by_row_id[row_id]
1736
- )
1737
- results.append(preserved_result)
1738
- logger.debug(
1739
- "preserving_checkpoint_result",
1740
- row_id=row_id,
1741
- row_index=idx,
1742
- )
1743
- except Exception as e:
1744
- logger.warning(
1745
- "failed_to_preserve_checkpoint_result",
1746
- row_id=row_id,
1747
- error=str(e),
1748
- )
1749
- skipped_count += 1
1750
- if row_progress_callback is not None and self._should_emit_row_progress_callback(
1751
- preserved_result,
1752
- "skipped",
1753
- ):
1754
- maybe_awaitable = row_progress_callback(
1755
- batch_idx,
1756
- start_idx,
1757
- end_idx,
1758
- list(results),
1759
- success_count,
1760
- error_count,
1761
- skipped_count,
1762
- preserved_result,
1763
- "skipped",
1764
- )
1765
- if inspect.isawaitable(maybe_awaitable):
1766
- await maybe_awaitable
1767
- next_row_index = idx + 1
1768
- continue
1769
-
1770
- if row_progress_callback is not None:
1771
- inflight_result = self._build_inflight_row_progress_result(check, row_id)
1772
- maybe_awaitable = row_progress_callback(
1773
- batch_idx,
1774
- start_idx,
1775
- end_idx,
1776
- list(results),
1777
- success_count,
1778
- error_count,
1779
- skipped_count,
1780
- inflight_result,
1781
- "started",
1782
- )
1783
- if inspect.isawaitable(maybe_awaitable):
1784
- await maybe_awaitable
1785
-
1786
- match_requirement_text = self._build_match_requirement_text(check)
1787
- app_config_only = self._row_requires_app_config_only(check)
1788
-
1789
- # App-config-only rows must bypass generic matcher retrieval entirely.
1790
- evidence_context = await self._get_or_match_evidence_context(
1791
- row_id=row_id,
1792
- requirement_text=match_requirement_text,
1793
- section_id=section_id,
1794
- app_config_only=app_config_only,
1795
- )
1796
-
1797
- formatted_evidence = "" if app_config_only else evidence_context.format_for_llm()
1798
- evidence_refs = evidence_context.evidence_refs # FR-2.4
1799
-
1800
- try:
1801
- result = await self._evaluate_row_with_timeout_mode(
1802
- check=check,
1803
- row_id=row_id,
1804
- row_index=idx,
1805
- evidence_context=formatted_evidence,
1806
- evidence_refs=evidence_refs,
1807
- project_profile=project_profile,
1808
- thread_id=thread_id,
1809
- matcher_retrieval_trace=getattr(evidence_context, "retrieval_trace", None),
1810
- provider_health_memory=self._batch_health_memory,
1811
- )
1812
- except BudgetExceededError as exc:
1813
- usage = exc.usage
1814
- context = {
1815
- "kind": "strict_budget_exceeded",
1816
- "audit_error_key": "LLM_BUDGET_EXCEEDED",
1817
- "audit_error_code": AUDIT_ERROR_CODES["LLM_BUDGET_EXCEEDED"].code,
1818
- "batch_index": batch_idx + 1,
1819
- "row_index": idx + 1,
1820
- "row_id": row_id,
1821
- "check_id": check.id,
1822
- "scope": usage.scope.value,
1823
- "scope_id": usage.scope_id,
1824
- "used_dollars": usage.used_dollars,
1825
- "limit_dollars": usage.limit_dollars,
1826
- "status": usage.status.value,
1827
- "error_context": getattr(exc, "error_context", None),
1828
- }
1829
- raise BatchBudgetExceededError(
1830
- message=str(exc),
1831
- context=context,
1832
- partial_results=list(results),
1833
- success_count=success_count,
1834
- error_count=error_count,
1835
- skipped_count=skipped_count,
1836
- ) from exc
1837
- finally:
1838
- self._clear_row_runtime_progress(row_id)
1839
-
1840
- matcher_trace = _sanitize_retrieval_trace(getattr(evidence_context, "retrieval_trace", None))
1841
- row_trace = _sanitize_retrieval_trace(result.retrieval_trace)
1842
- merged_trace = _merge_retrieval_trace_payloads(matcher_trace, row_trace)
1843
- if isinstance(merged_trace, dict):
1844
- # Preserve matcher retrieval context (docs/code candidates, backend mode)
1845
- # while allowing row-evaluator trace keys to take precedence.
1846
- result.retrieval_trace = _sanitize_retrieval_trace(merged_trace)
1847
-
1848
- # TSK-145.13/14: Timeout-aware failover — attempt ONE failover
1849
- # evaluation for STALL/NO_PROGRESS/CHURN_DETECTED timeouts before
1850
- # finalising ERROR. TIMEOUT_WITH_GROUNDING rows are excluded.
1851
- if result.status == RowStatus.ERROR:
1852
- timeout_kind_in_trace = str((result.retrieval_trace or {}).get("timeout_kind") or "").strip()
1853
- if self._is_timeout_failoverable(timeout_kind_in_trace) and self._batch_failover_profiles:
1854
- result = await self._attempt_timeout_failover(
1855
- timeout_result=result,
1856
- check=check,
1857
- row_index=idx,
1858
- evidence_context=formatted_evidence,
1859
- evidence_refs=evidence_refs,
1860
- project_profile=project_profile,
1861
- health_memory=self._batch_health_memory,
1862
- failover_profiles=self._batch_failover_profiles,
1863
- stats=inline_batch_stats,
1864
- )
1865
-
1866
- # FR-7: Validate grounding if validator configured
1867
- if self.grounding_validator:
1868
- result = self.grounding_validator.validate(
1869
- result,
1870
- allowed_refs=evidence_refs,
1871
- evidence_context=formatted_evidence,
1872
- )
1873
-
1874
- results.append(result)
1875
-
1876
- if result.status == RowStatus.ERROR:
1877
- error_count += 1
1878
- else:
1879
- success_count += 1
1880
- if row_progress_callback is not None:
1881
- maybe_awaitable = row_progress_callback(
1882
- batch_idx,
1883
- start_idx,
1884
- end_idx,
1885
- list(results),
1886
- success_count,
1887
- error_count,
1888
- skipped_count,
1889
- result,
1890
- "error" if result.status == RowStatus.ERROR else "success",
1891
- )
1892
- if inspect.isawaitable(maybe_awaitable):
1893
- await maybe_awaitable
1894
- next_row_index = idx + 1
1895
-
1896
- except TimeoutError:
1897
- logger.warning(
1898
- "batch_timeout",
1899
- batch=batch_idx,
1900
- completed=len(results),
1901
- expected=end_idx - start_idx,
1902
- )
1903
- timed_out = True
1904
-
1905
- # Mark remaining rows as ERROR (FR-3.2: graceful degradation)
1906
- for idx in range(next_row_index, end_idx):
1907
- section_id, check = self._checks[idx]
1908
- row_id = f"{check.id}:row_{idx}"
1909
-
1910
- # FR-25: Only create error for targeted rows, preserve checkpoint for others
1911
- if self._should_evaluate_row(idx, check.id, row_id, checkpoint):
1912
- progress = self._normalize_timeout_progress_snapshot(self._get_row_runtime_progress(row_id))
1913
- degraded_timeout_finalize = self._should_degrade_timeout_finalize(progress)
1914
- timeout_result = self._create_timeout_result(
1915
- row_id,
1916
- check.id,
1917
- "Batch timeout exceeded",
1918
- degraded_timeout_finalize=degraded_timeout_finalize,
1919
- progress=progress,
1920
- )
1921
- timeout_trace = {
1922
- "timeout_retry_attempts": 0,
1923
- "timeout_progress_snapshot": progress,
1924
- "timeout_extended": False,
1925
- "timeout_degraded_finalize": degraded_timeout_finalize,
1926
- "timeout_kind": self._derive_timeout_kind(
1927
- progress=progress,
1928
- degraded_timeout_finalize=degraded_timeout_finalize,
1929
- batch_timeout_exceeded=True,
1930
- ),
1931
- "timeout_terminal_status": timeout_result.status.value,
1932
- "batch_timeout_exceeded": True,
1933
- }
1934
- self._attach_timeout_progress_telemetry(
1935
- timeout_trace=timeout_trace,
1936
- progress=progress,
1937
- row_id=row_id,
1938
- check_id=check.id,
1939
- )
1940
- timeout_result.retrieval_trace = _sanitize_retrieval_trace(
1941
- self._sanitize_timeout_trace_for_app_config_only(
1942
- timeout_trace,
1943
- progress=progress,
1944
- matcher_retrieval_trace=None,
1945
- )
1946
- )
1947
- timeout_result = RowEvaluator._sanitize_app_config_only_result(timeout_result)
1948
- timeout_result = RowEvaluator._salvage_app_config_only_timeout_result(timeout_result)
1949
- results.append(timeout_result)
1950
- error_count += 1
1951
- elif row_id in checkpoint.results_by_row_id:
1952
- try:
1953
- preserved_result = BatchCheckpoint.deserialize_row_result(checkpoint.results_by_row_id[row_id])
1954
- results.append(preserved_result)
1955
- except Exception:
1956
- pass
1957
- skipped_count += 1
1958
-
1959
- duration_ms = int((time.monotonic() - start_time) * 1000)
1960
-
1961
- # FR-145.2: Post-pass ERROR retry sweep.
1962
- # Only runs when batch_error_retry_limit > 0 and there are ERROR rows.
1963
- # Requires _batch_health_memory and _batch_failover_profiles to be set
1964
- # (threaded by the batch loop — see TSK-145.1 / TSK-145.3).
1965
- if not timed_out and error_count > 0 and self.config.batch_error_retry_limit > 0:
1966
- health_memory: ProviderHealthMemory | None = getattr(self, "_batch_health_memory", None)
1967
- failover_profiles: list[str] = list(getattr(self, "_batch_failover_profiles", None) or [])
1968
- if health_memory is not None and failover_profiles:
1969
- budget = ResilienceBudget(
1970
- total_rows=len(results),
1971
- error_count=error_count,
1972
- )
1973
- retried = await self._retry_error_rows(
1974
- results=results,
1975
- health_memory=health_memory,
1976
- budget=budget,
1977
- failover_profiles=failover_profiles,
1978
- project_profile=project_profile,
1979
- stats=inline_batch_stats,
1980
- )
1981
- # Recount after retry pass.
1982
- new_error_count = sum(1 for r in retried if r.status == RowStatus.ERROR)
1983
- new_success_count = sum(
1984
- 1
1985
- for r in retried
1986
- if r.status != RowStatus.ERROR
1987
- and r.row_id in {orig.row_id for orig in results if orig.status == RowStatus.ERROR}
1988
- )
1989
- if budget.calls_used > 0:
1990
- logger.info(
1991
- "resilience_retry_sweep_complete",
1992
- batch_index=batch_idx,
1993
- errors_before=error_count,
1994
- errors_after=new_error_count,
1995
- retries_attempted=budget.calls_used,
1996
- budget_total=budget.total,
1997
- )
1998
- results = retried
1999
- error_count = new_error_count
2000
- success_count += new_success_count
2001
-
2002
- # TSK-145.9: Low-confidence re-evaluation sweep.
2003
- # Shares the same budget instance — any budget consumed by ERROR
2004
- # retries above reduces what is available here.
2005
- reevaled = await self._reevaluate_low_confidence_rows(
2006
- results=results,
2007
- health_memory=health_memory,
2008
- budget=budget,
2009
- failover_profiles=failover_profiles,
2010
- project_profile=project_profile,
2011
- )
2012
- reeval_improved = sum(
2013
- 1
2014
- for orig, new in zip(results, reevaled, strict=False)
2015
- if (new.score_1_5 or 0) > (orig.score_1_5 or 0)
2016
- )
2017
- if reeval_improved > 0:
2018
- logger.info(
2019
- "low_confidence_reeval_sweep_complete",
2020
- batch_index=batch_idx,
2021
- rows_improved=reeval_improved,
2022
- budget_calls_used=budget.calls_used,
2023
- budget_total=budget.total,
2024
- )
2025
- results = reevaled
2026
-
2027
- self._resilience_stats_accumulator.append(inline_batch_stats)
2028
- return BatchResult(
2029
- batch_index=batch_idx,
2030
- start_row=start_idx,
2031
- end_row=end_idx,
2032
- results=results,
2033
- duration_ms=duration_ms,
2034
- success_count=success_count,
2035
- error_count=error_count,
2036
- timed_out=timed_out,
2037
- skipped_count=skipped_count,
2038
- )
2039
-
2040
- async def _process_single_row(
2041
- self,
2042
- idx: int,
2043
- batch_idx: int,
2044
- project_profile: dict[str, Any] | None,
2045
- checkpoint: BatchCheckpoint,
2046
- thread_id: str,
2047
- semaphore: asyncio.Semaphore,
2048
- checkpoint_lock: asyncio.Lock,
2049
- batch_stats: _ResilienceRetryStats | None = None,
2050
- ) -> tuple[RowEvaluationResult | None, str]:
2051
- """Process a single row under semaphore guard (FR-188).
2052
-
2053
- Returns (result, outcome) where outcome is 'success', 'error', or 'skipped'.
2054
- Budget exceptions propagate to the caller.
2055
- """
2056
- section_id, check = self._checks[idx]
2057
- row_id = f"{check.id}:row_{idx}"
2058
-
2059
- # FR-25.3, FR-25.4: Check if row should be processed
2060
- if not self._should_evaluate_row(idx, check.id, row_id, checkpoint):
2061
- async with checkpoint_lock:
2062
- if row_id in checkpoint.results_by_row_id:
2063
- try:
2064
- preserved_result = BatchCheckpoint.deserialize_row_result(checkpoint.results_by_row_id[row_id])
2065
- logger.debug(
2066
- "preserving_checkpoint_result",
2067
- row_id=row_id,
2068
- row_index=idx,
2069
- )
2070
- return preserved_result, "skipped"
2071
- except Exception as e:
2072
- logger.warning(
2073
- "failed_to_preserve_checkpoint_result",
2074
- row_id=row_id,
2075
- error=str(e),
2076
- )
2077
- return None, "skipped"
2078
-
2079
- async with semaphore:
2080
- match_requirement_text = self._build_match_requirement_text(check)
2081
- app_config_only = self._row_requires_app_config_only(check)
2082
-
2083
- evidence_context = await self._get_or_match_evidence_context(
2084
- row_id=row_id,
2085
- requirement_text=match_requirement_text,
2086
- section_id=section_id,
2087
- app_config_only=app_config_only,
2088
- )
2089
-
2090
- formatted_evidence = "" if app_config_only else evidence_context.format_for_llm()
2091
- evidence_refs = evidence_context.evidence_refs
2092
-
2093
- result: RowEvaluationResult
2094
- try:
2095
- result = await self._evaluate_row_with_timeout_mode(
2096
- check=check,
2097
- row_id=row_id,
2098
- row_index=idx,
2099
- evidence_context=formatted_evidence,
2100
- evidence_refs=evidence_refs,
2101
- project_profile=project_profile,
2102
- thread_id=thread_id,
2103
- matcher_retrieval_trace=getattr(evidence_context, "retrieval_trace", None),
2104
- provider_health_memory=getattr(self, "_batch_health_memory", None),
2105
- )
2106
- except BudgetExceededError:
2107
- raise
2108
- finally:
2109
- self._clear_row_runtime_progress(row_id)
2110
-
2111
- matcher_trace = _sanitize_retrieval_trace(getattr(evidence_context, "retrieval_trace", None))
2112
- row_trace = _sanitize_retrieval_trace(result.retrieval_trace)
2113
- merged_trace = _merge_retrieval_trace_payloads(matcher_trace, row_trace)
2114
- if isinstance(merged_trace, dict):
2115
- result.retrieval_trace = _sanitize_retrieval_trace(merged_trace)
2116
- result = RowEvaluator._sanitize_app_config_only_result(result)
2117
-
2118
- # TSK-145.13/14: Timeout-aware failover — attempt ONE failover
2119
- # evaluation for STALL/NO_PROGRESS timeouts before finalising ERROR.
2120
- # TIMEOUT_WITH_GROUNDING rows are excluded (already have grounding).
2121
- if result.status == RowStatus.ERROR:
2122
- timeout_kind_in_trace = str((result.retrieval_trace or {}).get("timeout_kind") or "").strip()
2123
- if self._is_timeout_failoverable(timeout_kind_in_trace):
2124
- health_memory_for_failover: ProviderHealthMemory | None = getattr(
2125
- self, "_batch_health_memory", None
2126
- )
2127
- failover_profiles_for_timeout: list[str] = list(
2128
- getattr(self, "_batch_failover_profiles", None) or []
2129
- )
2130
- if health_memory_for_failover is not None and failover_profiles_for_timeout:
2131
- result = await self._attempt_timeout_failover(
2132
- timeout_result=result,
2133
- check=check,
2134
- row_index=idx,
2135
- evidence_context=formatted_evidence,
2136
- evidence_refs=evidence_refs,
2137
- project_profile=project_profile,
2138
- health_memory=health_memory_for_failover,
2139
- failover_profiles=failover_profiles_for_timeout,
2140
- )
2141
-
2142
- if self.grounding_validator:
2143
- result = self.grounding_validator.validate(
2144
- result,
2145
- allowed_refs=evidence_refs,
2146
- evidence_context=formatted_evidence,
2147
- )
2148
-
2149
- outcome = "error" if result.status == RowStatus.ERROR else "success"
2150
- return result, outcome
2151
-
2152
- async def _evaluate_row_with_timeout_mode(
2153
- self,
2154
- *,
2155
- check: AuditCheck,
2156
- row_id: str,
2157
- row_index: int,
2158
- evidence_context: str,
2159
- evidence_refs: list[str],
2160
- project_profile: dict[str, Any] | None,
2161
- thread_id: str,
2162
- matcher_retrieval_trace: dict[str, Any] | None,
2163
- provider_health_memory: Any | None = None,
2164
- ) -> RowEvaluationResult:
2165
- if self._lease_timeout_mode_enabled():
2166
- return await self._evaluate_row_with_lease_timeout(
2167
- check=check,
2168
- row_id=row_id,
2169
- row_index=row_index,
2170
- evidence_context=evidence_context,
2171
- evidence_refs=evidence_refs,
2172
- project_profile=project_profile,
2173
- thread_id=thread_id,
2174
- matcher_retrieval_trace=matcher_retrieval_trace,
2175
- provider_health_memory=provider_health_memory,
2176
- )
2177
- return await self._evaluate_row_with_legacy_timeout(
2178
- check=check,
2179
- row_id=row_id,
2180
- row_index=row_index,
2181
- evidence_context=evidence_context,
2182
- evidence_refs=evidence_refs,
2183
- project_profile=project_profile,
2184
- thread_id=thread_id,
2185
- matcher_retrieval_trace=matcher_retrieval_trace,
2186
- provider_health_memory=provider_health_memory,
2187
- )
2188
-
2189
- def _build_row_assigned_evaluator(self, assigned_profile: str) -> RowEvaluator:
2190
- runtime_context = self.config.run_context if isinstance(self.config.run_context, dict) else {}
2191
- cloned_config = copy.deepcopy(self.evaluator.config)
2192
- cloned_runtime_context = dict(getattr(cloned_config, "runtime_context", {}) or {})
2193
- source_llm = getattr(self.evaluator, "config", None)
2194
- source_llm = getattr(source_llm, "llm", None) if source_llm is not None else None
2195
- inherited_llm = inherit_runtime_llm_policy(assigned_profile, source_llm=source_llm)
2196
- cloned_runtime_context["repo_row_distribution_enabled"] = True
2197
- cloned_runtime_context["repo_distribution_profiles"] = list(self._repo_row_distribution_profiles())
2198
- cloned_runtime_context["row_distribution_profile"] = assigned_profile
2199
- cloned_runtime_context["active_profile"] = assigned_profile
2200
- cloned_runtime_context["repo_primary_profile"] = (
2201
- str(runtime_context.get("repo_primary_profile") or runtime_context.get("active_profile") or "").strip()
2202
- or assigned_profile
2203
- )
2204
- cloned_config.runtime_context = cloned_runtime_context
2205
- cloned_config.protocol = (
2206
- str(
2207
- getattr(getattr(inherited_llm, "protocol", None), "value", getattr(inherited_llm, "protocol", None))
2208
- or cloned_config.protocol
2209
- or ""
2210
- )
2211
- or None
2212
- )
2213
- cloned_config.model = str(getattr(inherited_llm, "model_standard", "") or cloned_config.model or "") or None
2214
- cloned_config.llm = inherited_llm
2215
- return RowEvaluator(
2216
- config=cloned_config,
2217
- template=self.template,
2218
- evidence_bundle=self.evaluator.evidence_bundle,
2219
- )
2220
-
2221
- @staticmethod
2222
- def _apply_assigned_profile_provenance(
2223
- result: RowEvaluationResult,
2224
- *,
2225
- assigned_profile: str,
2226
- ) -> RowEvaluationResult:
2227
- provenance = (
2228
- result.provenance.model_copy(deep=True)
2229
- if result.provenance is not None
2230
- else RowProvenance(
2231
- row_llm_mode="unknown",
2232
- template_hash="unknown",
2233
- evidence_hash="unknown",
2234
- )
2235
- )
2236
- if not provenance.original_provider:
2237
- provenance.original_provider = assigned_profile
2238
- if not provenance.final_provider:
2239
- provenance.final_provider = assigned_profile
2240
- if not provenance.failover_chain:
2241
- provenance.failover_chain = [assigned_profile]
2242
- result.provenance = provenance
2243
-
2244
- trace = dict(result.retrieval_trace or {}) if isinstance(result.retrieval_trace, dict) else {}
2245
- trace.setdefault("row_distribution_profile", assigned_profile)
2246
- trace.setdefault("provider_failover_chain", [assigned_profile])
2247
- trace.setdefault("provider_failover_final_provider", assigned_profile)
2248
- result.retrieval_trace = trace
2249
- return result
2250
-
2251
- async def _invoke_row_evaluator(
2252
- self,
2253
- *,
2254
- check: AuditCheck,
2255
- row_id: str,
2256
- row_index: int,
2257
- evidence_context: str,
2258
- evidence_refs: list[str],
2259
- project_profile: dict[str, Any] | None,
2260
- provider_health_memory: Any | None = None,
2261
- ) -> RowEvaluationResult:
2262
- assigned_profile = self._assigned_repo_profile_for_row(row_index)
2263
- evaluator = self.evaluator
2264
- if assigned_profile is not None:
2265
- evaluator = self._build_row_assigned_evaluator(assigned_profile)
2266
-
2267
- result = await evaluator.aevaluate_row(
2268
- check=check,
2269
- evidence=None,
2270
- row_id=row_id,
2271
- row_index=row_index,
2272
- evidence_context=evidence_context,
2273
- evidence_refs=evidence_refs,
2274
- project_profile=project_profile,
2275
- provider_health_memory=provider_health_memory,
2276
- )
2277
- if assigned_profile is not None:
2278
- result = self._apply_assigned_profile_provenance(result, assigned_profile=assigned_profile)
2279
- provider_name = str(getattr(getattr(result, "provenance", None), "final_provider", None) or "").strip()
2280
- if not provider_name:
2281
- provider_name = str(getattr(getattr(result, "provenance", None), "original_provider", None) or "").strip()
2282
- if not provider_name:
2283
- provider_name = assigned_profile
2284
- await self._record_runtime_provider_result(
2285
- cast("ProviderHealthMemory | None", provider_health_memory),
2286
- provider_name=provider_name,
2287
- result=result,
2288
- )
2289
- return result
2290
-
2291
- # ---------------------------------------------------------------------------
2292
- # FR-145.2: Post-pass ERROR retry sweep
2293
- # ---------------------------------------------------------------------------
2294
-
2295
- def _select_healthy_provider(
2296
- self,
2297
- failover_profiles: list[str],
2298
- health_memory: ProviderHealthMemory,
2299
- *,
2300
- exclude: set[str],
2301
- ) -> str | None:
2302
- """Select the next healthy provider, skipping cooled-down and excluded ones.
2303
-
2304
- Args:
2305
- failover_profiles: Ordered list of candidate profile names.
2306
- health_memory: Shared health state accumulated during the primary pass.
2307
- exclude: Provider names to skip (original + already tried).
2308
-
2309
- Returns:
2310
- A profile name to retry with, or None if all are blocked/cooled down.
2311
- """
2312
- for candidate in failover_profiles:
2313
- if candidate in exclude:
2314
- continue
2315
- if health_memory.should_skip_provider(candidate):
2316
- continue
2317
- return candidate
2318
- return None
2319
-
2320
- def _build_retry_evaluator(self, profile: str) -> RowEvaluator:
2321
- """Build a RowEvaluator configured to use the given profile for retry."""
2322
- return self._build_row_assigned_evaluator(profile)
2323
-
2324
- @staticmethod
2325
- def _is_timeout_failoverable(timeout_kind: str) -> bool:
2326
- """Return True if the timeout kind should trigger failover (TSK-145.13).
2327
-
2328
- TIMEOUT_WITH_GROUNDING must NEVER trigger failover — it already has
2329
- partial grounding and a FAIL result. STALL, NO_PROGRESS, and
2330
- CHURN_DETECTED indicate that the primary provider was unable to make
2331
- durable forward progress, so a second provider may succeed.
2332
- """
2333
- return timeout_kind in {
2334
- TimeoutKind.TIMEOUT_PROVIDER_STALL.value,
2335
- TimeoutKind.TIMEOUT_NO_PROGRESS.value,
2336
- TimeoutKind.TIMEOUT_CHURN_DETECTED.value,
2337
- }
2338
-
2339
- async def _attempt_timeout_failover(
2340
- self,
2341
- *,
2342
- timeout_result: RowEvaluationResult,
2343
- check: AuditCheck,
2344
- row_index: int,
2345
- evidence_context: str,
2346
- evidence_refs: list[str],
2347
- project_profile: dict[str, Any] | None,
2348
- health_memory: ProviderHealthMemory,
2349
- failover_profiles: list[str],
2350
- stats: _ResilienceRetryStats | None = None,
2351
- ) -> RowEvaluationResult:
2352
- """Attempt ONE failover evaluation for a timed-out row (TSK-145.13/14).
2353
-
2354
- Called BEFORE the timeout result is finalised as ERROR. Returns the
2355
- failover result on success, or the original timeout_result unchanged if
2356
- failover is not possible or also fails.
2357
-
2358
- Rules:
2359
- - Only TIMEOUT_PROVIDER_STALL and TIMEOUT_NO_PROGRESS are eligible.
2360
- - TIMEOUT_WITH_GROUNDING is never retried (has partial grounding).
2361
- - Exactly one failover attempt is made (no retry loop).
2362
- - Providers already in the failover chain are excluded.
2363
- """
2364
- # Extract the timeout_kind from the retrieval trace.
2365
- timeout_trace = dict(timeout_result.retrieval_trace or {})
2366
- timeout_kind = str(timeout_trace.get("timeout_kind") or "").strip()
2367
-
2368
- if not timeout_kind or not self._is_timeout_failoverable(timeout_kind):
2369
- return timeout_result
2370
-
2371
- if not failover_profiles:
2372
- return timeout_result
2373
-
2374
- # Determine providers to exclude: original provider + any prior chain.
2375
- original_provider = str(
2376
- getattr(getattr(timeout_result, "provenance", None), "original_provider", None) or ""
2377
- ).strip()
2378
- chain = list(getattr(getattr(timeout_result, "provenance", None), "failover_chain", None) or [])
2379
- exclude: set[str] = set(filter(None, [original_provider, *chain]))
2380
-
2381
- next_provider = self._select_healthy_provider(
2382
- failover_profiles,
2383
- health_memory,
2384
- exclude=exclude,
2385
- )
2386
-
2387
- # Phase 146 (FR-146.6): Bounded wait-and-resume when all providers are
2388
- # temporarily exhausted during timeout failover (TSK-146.10).
2389
- if next_provider is None:
2390
- exhaustion_reason = _all_providers_exhausted_reason(
2391
- health_memory,
2392
- failover_profiles=failover_profiles,
2393
- )
2394
- if exhaustion_reason == "quota_all_providers_exhausted":
2395
- quota_wait_max = _quota_wait_max_seconds()
2396
- if quota_wait_max > 0:
2397
- recovered = await self._bounded_wait_for_provider_recovery(
2398
- health_memory,
2399
- failover_profiles=failover_profiles,
2400
- max_wait_seconds=quota_wait_max,
2401
- row_id=timeout_result.row_id,
2402
- check_id=timeout_result.check_id,
2403
- )
2404
- if recovered is not None and recovered not in exclude:
2405
- next_provider = recovered
2406
-
2407
- if next_provider is None:
2408
- # Annotate timeout result with exhaustion metadata (AC-146.6.4 / TSK-146.11).
2409
- self._annotate_quota_exhaustion(
2410
- timeout_result,
2411
- health_memory=health_memory,
2412
- failover_profiles=failover_profiles,
2413
- wait_attempted=exhaustion_reason == "quota_all_providers_exhausted"
2414
- and _quota_wait_max_seconds() > 0,
2415
- wait_expired=True,
2416
- )
2417
- logger.debug(
2418
- "timeout_failover_no_healthy_provider",
2419
- row_id=timeout_result.row_id,
2420
- check_id=timeout_result.check_id,
2421
- timeout_kind=timeout_kind,
2422
- exclude=sorted(exclude),
2423
- exhaustion_reason=exhaustion_reason,
2424
- )
2425
- return timeout_result
2426
-
2427
- # Build RowFailoverContext with partial evidence from the timed-out result (TSK-145.14).
2428
- progress_snapshot = timeout_trace.get("timeout_progress_snapshot")
2429
- partial_evidence_refs: list[dict[str, Any]] = []
2430
- if isinstance(progress_snapshot, dict):
2431
- raw_refs = progress_snapshot.get("evidence_refs")
2432
- if isinstance(raw_refs, list):
2433
- partial_evidence_refs = [{"ref": str(r)} for r in raw_refs if r]
2434
- failover_context = RowFailoverContext(
2435
- row_id=timeout_result.row_id,
2436
- check_id=timeout_result.check_id,
2437
- evidence_refs=partial_evidence_refs,
2438
- route_state={},
2439
- partial_progress={
2440
- "timeout_kind": timeout_kind,
2441
- "timeout_snapshot": dict(progress_snapshot) if isinstance(progress_snapshot, dict) else {},
2442
- },
2443
- original_provider=original_provider or None,
2444
- failover_count=len(chain),
2445
- failover_chain=chain + ([original_provider] if original_provider else []),
2446
- timeout_telemetry_snapshot={
2447
- k: v
2448
- for k, v in timeout_trace.items()
2449
- if k in {"timeout_kind", "timeout_scope", "stall_duration_seconds", "stall_reason"}
2450
- },
2451
- )
2452
-
2453
- if stats is not None and next_provider not in stats.providers_used:
2454
- stats.providers_used.append(next_provider)
2455
- if stats is not None:
2456
- stats.failover_hops += 1
2457
-
2458
- # Evidence refs for the re-evaluation call.
2459
- evidence_refs_list: list[str] = list(
2460
- (timeout_result.retry_metadata or {}).get("evidence_refs", []) or evidence_refs or []
2461
- )
2462
- evidence_context_str = str(timeout_trace.get("evidence_context_str", "") or evidence_context)
2463
-
2464
- logger.info(
2465
- "timeout_failover_attempt",
2466
- row_id=timeout_result.row_id,
2467
- check_id=timeout_result.check_id,
2468
- timeout_kind=timeout_kind,
2469
- original_provider=original_provider or "unknown",
2470
- failover_provider=next_provider,
2471
- failover_context_partial_refs=len(failover_context.evidence_refs),
2472
- )
2473
-
2474
- try:
2475
- failover_evaluator = self._build_retry_evaluator(next_provider)
2476
- failover_result = await failover_evaluator.aevaluate_row(
2477
- check=check,
2478
- evidence=None,
2479
- row_id=timeout_result.row_id,
2480
- row_index=row_index,
2481
- evidence_context=evidence_context_str,
2482
- evidence_refs=evidence_refs_list,
2483
- project_profile=project_profile,
2484
- )
2485
- failover_result = self._apply_assigned_profile_provenance(
2486
- failover_result,
2487
- assigned_profile=next_provider,
2488
- )
2489
- except Exception as exc:
2490
- logger.warning(
2491
- "timeout_failover_failed",
2492
- row_id=timeout_result.row_id,
2493
- check_id=timeout_result.check_id,
2494
- failover_provider=next_provider,
2495
- error=str(exc),
2496
- )
2497
- return timeout_result
2498
-
2499
- if failover_result.status == RowStatus.ERROR:
2500
- logger.debug(
2501
- "timeout_failover_still_error",
2502
- row_id=timeout_result.row_id,
2503
- check_id=timeout_result.check_id,
2504
- failover_provider=next_provider,
2505
- )
2506
- return timeout_result
2507
-
2508
- # Failover succeeded — annotate the result with failover provenance.
2509
- failover_result.retry_count = timeout_result.retry_count + 1
2510
- failover_result.retry_metadata = {
2511
- **(failover_result.retry_metadata or {}),
2512
- "timeout_failover_pass": True,
2513
- "timeout_failover_original_provider": original_provider or "unknown",
2514
- "timeout_failover_provider": next_provider,
2515
- "timeout_failover_kind": timeout_kind,
2516
- "timeout_failover_context": {
2517
- "failover_count": failover_context.failover_count,
2518
- "failover_chain": failover_context.failover_chain,
2519
- "partial_progress": failover_context.partial_progress,
2520
- },
2521
- }
2522
- if stats is not None:
2523
- stats.retry_successes += 1
2524
-
2525
- logger.info(
2526
- "timeout_failover_succeeded",
2527
- row_id=timeout_result.row_id,
2528
- check_id=timeout_result.check_id,
2529
- timeout_kind=timeout_kind,
2530
- original_provider=original_provider or "unknown",
2531
- failover_provider=next_provider,
2532
- new_status=failover_result.status.value,
2533
- )
2534
- return failover_result
2535
-
2536
- async def _retry_error_rows(
2537
- self,
2538
- results: list[RowEvaluationResult],
2539
- health_memory: ProviderHealthMemory,
2540
- budget: ResilienceBudget,
2541
- failover_profiles: list[str],
2542
- project_profile: dict[str, Any] | None,
2543
- stats: _ResilienceRetryStats | None = None,
2544
- ) -> list[RowEvaluationResult]:
2545
- """Post-pass retry sweep for failoverable ERROR rows (FR-145.2).
2546
-
2547
- Iterates results from the primary pass. For each ERROR row that is
2548
- failoverable and within budget, re-evaluates using a healthy alternative
2549
- provider. Replaces the original result only on success.
2550
-
2551
- The ``retry_count`` on the replacement result is incremented to signal
2552
- that a retry occurred. The ``retry_metadata`` carries provenance of the
2553
- retry (``resilience_retry_pass``, original provider, new provider).
2554
-
2555
- Args:
2556
- results: Primary-pass results (not mutated; returns a new list).
2557
- health_memory: Shared ProviderHealthMemory from the primary pass.
2558
- budget: ResilienceBudget instance (mutated in place via consume()).
2559
- failover_profiles: Ordered list of alternative provider names.
2560
- project_profile: Project-level profile dict passed to the evaluator.
2561
- stats: Optional accumulator for resilience telemetry (FR-145.7).
2562
-
2563
- Returns:
2564
- New list with ERROR rows replaced where retry succeeded.
2565
- """
2566
- if not failover_profiles or budget.remaining <= 0:
2567
- return list(results)
2568
-
2569
- updated = list(results)
2570
-
2571
- # Seed stats with pre-retry snapshot so callers get before/after counts.
2572
- if stats is not None:
2573
- stats.error_rows_before_retry = sum(1 for r in results if r.status == RowStatus.ERROR)
2574
- stats.budget_total = budget.total
2575
-
2576
- for i, result in enumerate(results):
2577
- if result.status != RowStatus.ERROR:
2578
- continue
2579
-
2580
- # Determine if this error is failoverable via reason_code in retry_metadata.
2581
- classification_reason = str((result.retry_metadata or {}).get("reason_code", "")).strip().lower()
2582
- if classification_reason in _NON_FAILOVERABLE_REASONS:
2583
- logger.debug(
2584
- "resilience_retry_skipped_non_failoverable",
2585
- row_id=result.row_id,
2586
- check_id=result.check_id,
2587
- reason_code=classification_reason,
2588
- )
2589
- continue
2590
-
2591
- # Check budget before attempting retry.
2592
- if not budget.consume():
2593
- logger.info(
2594
- "resilience_budget_exhausted",
2595
- remaining_errors=sum(1 for r in results[i:] if r.status == RowStatus.ERROR),
2596
- calls_used=budget.calls_used,
2597
- budget_total=budget.total,
2598
- )
2599
- break
2600
-
2601
- if stats is not None:
2602
- stats.retry_attempts += 1
2603
- stats.budget_used = budget.calls_used
2604
-
2605
- # Determine which providers to exclude: original + any already tried.
2606
- original_provider = str(getattr(result.provenance, "original_provider", None) or "").strip()
2607
- chain = list(getattr(result.provenance, "failover_chain", None) or [])
2608
- exclude: set[str] = set(filter(None, [original_provider, *chain]))
2609
-
2610
- next_provider = self._select_healthy_provider(
2611
- failover_profiles,
2612
- health_memory,
2613
- exclude=exclude,
2614
- )
2615
-
2616
- # Phase 146 (FR-146.6): Bounded wait-and-resume when all providers are
2617
- # temporarily exhausted but not permanently blocked (TSK-146.10).
2618
- wait_attempted = False
2619
- wait_expired = False
2620
- if next_provider is None:
2621
- exhaustion_reason = _all_providers_exhausted_reason(
2622
- health_memory,
2623
- failover_profiles=failover_profiles,
2624
- )
2625
- if exhaustion_reason == "quota_all_providers_exhausted":
2626
- # All providers are in temporary cooldown — attempt bounded wait.
2627
- quota_wait_max = _quota_wait_max_seconds()
2628
- if quota_wait_max > 0:
2629
- wait_attempted = True
2630
- recovered = await self._bounded_wait_for_provider_recovery(
2631
- health_memory,
2632
- failover_profiles=failover_profiles,
2633
- max_wait_seconds=quota_wait_max,
2634
- row_id=result.row_id,
2635
- check_id=result.check_id,
2636
- )
2637
- if recovered is not None and recovered not in exclude:
2638
- next_provider = recovered
2639
- else:
2640
- wait_expired = True
2641
- else:
2642
- wait_expired = True
2643
-
2644
- if next_provider is None:
2645
- # Annotate with exhaustion metadata (AC-146.6.4 / TSK-146.11).
2646
- self._annotate_quota_exhaustion(
2647
- result,
2648
- health_memory=health_memory,
2649
- failover_profiles=failover_profiles,
2650
- wait_attempted=wait_attempted,
2651
- wait_expired=wait_expired,
2652
- )
2653
- logger.debug(
2654
- "resilience_retry_no_healthy_provider",
2655
- row_id=result.row_id,
2656
- check_id=result.check_id,
2657
- exclude=sorted(exclude),
2658
- exhaustion_reason=exhaustion_reason,
2659
- wait_attempted=wait_attempted,
2660
- wait_expired=wait_expired,
2661
- )
2662
- continue
2663
-
2664
- # Build RowFailoverContext carrying forward evidence from the original result.
2665
- failover_context = RowFailoverContext(
2666
- row_id=result.row_id,
2667
- check_id=result.check_id,
2668
- evidence_refs=list(
2669
- (result.retry_metadata or {}).get("evidence_refs", [])
2670
- or (getattr(result, "evidence_anchors", None) and [str(a) for a in (result.evidence_anchors or [])])
2671
- or []
2672
- ),
2673
- route_state=dict((result.retry_metadata or {}).get("route_state", {})),
2674
- partial_progress=dict((result.retry_metadata or {}).get("partial_progress", {})),
2675
- original_provider=original_provider or None,
2676
- failover_count=len(chain),
2677
- failover_chain=chain + ([original_provider] if original_provider else []),
2678
- timeout_telemetry_snapshot={},
2679
- )
2680
-
2681
- retry_evaluator = self._build_retry_evaluator(next_provider)
2682
- if stats is not None and next_provider not in stats.providers_used:
2683
- stats.providers_used.append(next_provider)
2684
- if stats is not None:
2685
- stats.failover_hops += 1
2686
-
2687
- # Reconstruct evidence for the row from the original retrieval trace.
2688
- evidence_context_str = str((result.retrieval_trace or {}).get("evidence_context_str", ""))
2689
- evidence_refs_list: list[str] = list((result.retry_metadata or {}).get("evidence_refs", []) or [])
2690
-
2691
- # Determine row_index: extract from row_id "check_id:row_N" pattern.
2692
- try:
2693
- row_index = int(result.row_id.split(":row_")[-1])
2694
- except (ValueError, IndexError):
2695
- row_index = 0
2696
-
2697
- # Find the original AuditCheck for this result.
2698
- check_match: AuditCheck | None = None
2699
- for _section_id, check in self._checks:
2700
- if check.id == result.check_id:
2701
- check_match = check
2702
- break
2703
- if check_match is None:
2704
- logger.debug(
2705
- "resilience_retry_check_not_found",
2706
- row_id=result.row_id,
2707
- check_id=result.check_id,
2708
- )
2709
- continue
2710
-
2711
- logger.info(
2712
- "resilience_retry_attempt",
2713
- row_id=result.row_id,
2714
- check_id=result.check_id,
2715
- original_provider=original_provider or "unknown",
2716
- retry_provider=next_provider,
2717
- budget_calls_used=budget.calls_used,
2718
- budget_total=budget.total,
2719
- )
2720
-
2721
- try:
2722
- retry_result = await retry_evaluator.aevaluate_row(
2723
- check=check_match,
2724
- evidence=None,
2725
- row_id=result.row_id,
2726
- row_index=row_index,
2727
- evidence_context=evidence_context_str,
2728
- evidence_refs=evidence_refs_list,
2729
- project_profile=project_profile,
2730
- )
2731
- retry_result = self._apply_assigned_profile_provenance(
2732
- retry_result,
2733
- assigned_profile=next_provider,
2734
- )
2735
- except Exception as exc:
2736
- logger.warning(
2737
- "resilience_retry_failed",
2738
- row_id=result.row_id,
2739
- check_id=result.check_id,
2740
- retry_provider=next_provider,
2741
- error=str(exc),
2742
- )
2743
- continue
2744
-
2745
- if retry_result.status == RowStatus.ERROR:
2746
- logger.debug(
2747
- "resilience_retry_still_error",
2748
- row_id=result.row_id,
2749
- check_id=result.check_id,
2750
- retry_provider=next_provider,
2751
- )
2752
- continue
2753
-
2754
- # Retry succeeded — replace the original result and annotate.
2755
- retry_result.retry_count = result.retry_count + 1
2756
- retry_result.retry_metadata = {
2757
- **(retry_result.retry_metadata or {}),
2758
- "resilience_retry_pass": True,
2759
- "resilience_original_provider": original_provider or "unknown",
2760
- "resilience_retry_provider": next_provider,
2761
- "resilience_failover_context": {
2762
- "failover_count": failover_context.failover_count,
2763
- "failover_chain": failover_context.failover_chain,
2764
- },
2765
- }
2766
- updated[i] = retry_result
2767
- if stats is not None:
2768
- stats.retry_successes += 1
2769
- logger.info(
2770
- "resilience_retry_succeeded",
2771
- row_id=result.row_id,
2772
- check_id=result.check_id,
2773
- original_provider=original_provider or "unknown",
2774
- retry_provider=next_provider,
2775
- new_status=retry_result.status.value,
2776
- )
2777
-
2778
- # Sync final budget_used after the loop (some budget slots may be consumed
2779
- # without a matching attempt when budget is already 0 on entry).
2780
- if stats is not None:
2781
- stats.budget_used = budget.calls_used
2782
- # Phase 146 telemetry: count rows with quota-exhaustion annotation.
2783
- stats.quota_exhausted_rows = sum(
2784
- 1
2785
- for r in updated
2786
- if r.status == RowStatus.ERROR
2787
- and isinstance(r.retry_metadata, dict)
2788
- and r.retry_metadata.get("quota_all_providers_exhausted")
2789
- )
2790
- stats.quota_wait_attempted_rows = sum(
2791
- 1
2792
- for r in updated
2793
- if isinstance(r.retry_metadata, dict) and r.retry_metadata.get("quota_exhaustion_wait_attempted")
2794
- )
2795
- stats.quota_wait_recovered_rows = sum(
2796
- 1
2797
- for r in updated
2798
- if isinstance(r.retry_metadata, dict) and r.retry_metadata.get("quota_exhaustion_wait_recovered")
2799
- )
2800
-
2801
- return updated
2802
-
2803
- # ---------------------------------------------------------------------------
2804
- # TSK-145.9/145.10/145.11: Post-pass low-confidence re-evaluation sweep
2805
- # ---------------------------------------------------------------------------
2806
-
2807
- async def _reevaluate_low_confidence_rows(
2808
- self,
2809
- results: list[RowEvaluationResult],
2810
- health_memory: ProviderHealthMemory,
2811
- budget: ResilienceBudget,
2812
- failover_profiles: list[str],
2813
- project_profile: dict[str, Any] | None,
2814
- ) -> list[RowEvaluationResult]:
2815
- """Post-pass re-evaluation sweep for PARTIAL or low-score rows (TSK-145.9).
2816
-
2817
- Runs AFTER ``_retry_error_rows``, sharing the same ``ResilienceBudget``
2818
- instance. If the ERROR retry sweep exhausted the budget, no re-evals
2819
- happen (budget.remaining == 0).
2820
-
2821
- Eligible rows:
2822
- - status == PARTIAL, OR
2823
- - score_1_5 is not None and score_1_5 <= threshold
2824
- (default threshold: 2; override via
2825
- ``VDS_AUDIT_LOW_CONFIDENCE_REEVAL_THRESHOLD`` env var).
2826
-
2827
- For each eligible row the method:
2828
- 1. Consumes one budget slot (skips if exhausted).
2829
- 2. Selects a healthy provider, preferring one different from the
2830
- original.
2831
- 3. Re-evaluates using the same ``aevaluate_row`` interface but with a
2832
- ``prior_result_context`` appended to the evidence so the model is
2833
- instructed to critically re-examine rather than anchor on the prior
2834
- assessment (TSK-145.10).
2835
- 4. Replaces the result ONLY if ``reeval_score_1_5 > original_score_1_5``
2836
- (TSK-145.11); otherwise keeps the original.
2837
-
2838
- Args:
2839
- results: Primary-pass results (after ERROR retry sweep); not
2840
- mutated — returns a new list.
2841
- health_memory: Shared ProviderHealthMemory.
2842
- budget: ResilienceBudget instance shared with ERROR retry sweep;
2843
- mutated in place via consume().
2844
- failover_profiles: Ordered list of alternative provider names.
2845
- project_profile: Project-level profile dict passed to evaluator.
2846
-
2847
- Returns:
2848
- New list with low-confidence rows replaced where re-eval improved
2849
- the score.
2850
- """
2851
- import os as _os
2852
-
2853
- if budget.remaining <= 0:
2854
- return list(results)
2855
-
2856
- # Parse threshold from env (default 2 → score_1_5 in {1, 2} are eligible).
2857
- try:
2858
- threshold = int((_os.getenv("VDS_AUDIT_LOW_CONFIDENCE_REEVAL_THRESHOLD") or "2").strip())
2859
- except ValueError:
2860
- threshold = 2
2861
-
2862
- updated = list(results)
2863
-
2864
- for i, result in enumerate(results):
2865
- # Eligibility: PARTIAL status OR low score_1_5.
2866
- is_partial = result.status == RowStatus.PARTIAL
2867
- score_1_5 = result.score_1_5
2868
- is_low_score = score_1_5 is not None and score_1_5 <= threshold
2869
-
2870
- if not (is_partial or is_low_score):
2871
- continue
2872
-
2873
- # Check budget before attempting re-eval.
2874
- if not budget.consume():
2875
- logger.info(
2876
- "low_confidence_reeval_budget_exhausted",
2877
- remaining_eligible=sum(
2878
- 1
2879
- for r in results[i:]
2880
- if r.status == RowStatus.PARTIAL or (r.score_1_5 is not None and r.score_1_5 <= threshold)
2881
- ),
2882
- calls_used=budget.calls_used,
2883
- budget_total=budget.total,
2884
- )
2885
- break
2886
-
2887
- # Prefer a provider different from the original.
2888
- original_provider = str(getattr(result.provenance, "original_provider", None) or "").strip()
2889
- chain = list(getattr(result.provenance, "failover_chain", None) or [])
2890
- exclude: set[str] = set(filter(None, [original_provider, *chain]))
2891
-
2892
- next_provider = self._select_healthy_provider(
2893
- failover_profiles,
2894
- health_memory,
2895
- exclude=exclude,
2896
- )
2897
- # Fall back to any provider (including original) if all are excluded.
2898
- if next_provider is None and failover_profiles:
2899
- next_provider = self._select_healthy_provider(
2900
- failover_profiles,
2901
- health_memory,
2902
- exclude=set(),
2903
- )
2904
- if next_provider is None:
2905
- logger.debug(
2906
- "low_confidence_reeval_no_healthy_provider",
2907
- row_id=result.row_id,
2908
- check_id=result.check_id,
2909
- )
2910
- continue
2911
-
2912
- # Find the original AuditCheck for this result.
2913
- check_match = None
2914
- for _section_id, check in self._checks:
2915
- if check.id == result.check_id:
2916
- check_match = check
2917
- break
2918
- if check_match is None:
2919
- logger.debug(
2920
- "low_confidence_reeval_check_not_found",
2921
- row_id=result.row_id,
2922
- check_id=result.check_id,
2923
- )
2924
- continue
2925
-
2926
- # Determine row_index from row_id "check_id:row_N" pattern.
2927
- try:
2928
- row_index = int(result.row_id.split(":row_")[-1])
2929
- except (ValueError, IndexError):
2930
- row_index = 0
2931
-
2932
- # Reconstruct evidence context from the original retrieval trace.
2933
- evidence_context_str = str((result.retrieval_trace or {}).get("evidence_context_str", ""))
2934
- evidence_refs_list: list[str] = list((result.retry_metadata or {}).get("evidence_refs", []) or [])
2935
-
2936
- # Build prior_result_context to instruct the model not to anchor
2937
- # on the prior assessment (TSK-145.10).
2938
- prior_result_context: dict[str, Any] = {
2939
- "prior_score_1_5": score_1_5,
2940
- "prior_status": result.status.value,
2941
- "prior_reason": result.reason or "",
2942
- "prior_evidence_refs": evidence_refs_list[:20],
2943
- "reeval_instruction": (
2944
- "Critically re-examine the evidence. "
2945
- "Do not simply agree with the prior assessment. "
2946
- "The previous evaluation may have been incomplete or anchored incorrectly."
2947
- ),
2948
- }
2949
-
2950
- # Append prior context to evidence_context so the evaluator prompt
2951
- # carries re-eval framing without requiring interface changes.
2952
- reeval_evidence_context = (
2953
- f"{evidence_context_str}\n\n"
2954
- "[Re-evaluation context]\n"
2955
- f"Prior score (1-5): {prior_result_context['prior_score_1_5']}\n"
2956
- f"Prior status: {prior_result_context['prior_status']}\n"
2957
- f"Prior reason: {prior_result_context['prior_reason']}\n"
2958
- f"{prior_result_context['reeval_instruction']}"
2959
- )
2960
-
2961
- reeval_evaluator = self._build_retry_evaluator(next_provider)
2962
-
2963
- logger.info(
2964
- "low_confidence_reeval_attempted",
2965
- row_id=result.row_id,
2966
- check_id=result.check_id,
2967
- original_provider=original_provider or "unknown",
2968
- reeval_provider=next_provider,
2969
- prior_score_1_5=score_1_5,
2970
- prior_status=result.status.value,
2971
- budget_calls_used=budget.calls_used,
2972
- budget_total=budget.total,
2973
- )
2974
-
2975
- try:
2976
- reeval_result = await reeval_evaluator.aevaluate_row(
2977
- check=check_match,
2978
- evidence=None,
2979
- row_id=result.row_id,
2980
- row_index=row_index,
2981
- evidence_context=reeval_evidence_context,
2982
- evidence_refs=evidence_refs_list,
2983
- project_profile=project_profile,
2984
- )
2985
- reeval_result = self._apply_assigned_profile_provenance(
2986
- reeval_result,
2987
- assigned_profile=next_provider,
2988
- )
2989
- except Exception as exc:
2990
- logger.warning(
2991
- "low_confidence_reeval_failed",
2992
- row_id=result.row_id,
2993
- check_id=result.check_id,
2994
- reeval_provider=next_provider,
2995
- error=str(exc),
2996
- )
2997
- continue
2998
-
2999
- # TSK-145.11: Replace only if re-eval score is strictly higher.
3000
- original_score = result.score_1_5 or 0
3001
- reeval_score = reeval_result.score_1_5 or 0
3002
-
3003
- if reeval_score > original_score:
3004
- reeval_result.retry_count = result.retry_count + 1
3005
- reeval_result.retry_metadata = {
3006
- **(reeval_result.retry_metadata or {}),
3007
- "low_confidence_reeval_pass": True,
3008
- "low_confidence_original_provider": original_provider or "unknown",
3009
- "low_confidence_reeval_provider": next_provider,
3010
- "low_confidence_prior_score_1_5": original_score,
3011
- "low_confidence_prior_result_context": prior_result_context,
3012
- }
3013
- updated[i] = reeval_result
3014
- logger.info(
3015
- "low_confidence_reeval_improved",
3016
- row_id=result.row_id,
3017
- check_id=result.check_id,
3018
- original_score=original_score,
3019
- new_score=reeval_score,
3020
- reeval_provider=next_provider,
3021
- )
3022
- else:
3023
- logger.info(
3024
- "low_confidence_reeval_kept_original",
3025
- row_id=result.row_id,
3026
- check_id=result.check_id,
3027
- original_score=original_score,
3028
- reeval_score=reeval_score,
3029
- )
3030
-
3031
- return updated
3032
-
3033
- def _build_timeout_result_with_trace(
3034
- self,
3035
- *,
3036
- row_id: str,
3037
- check_id: str,
3038
- message: str,
3039
- progress: dict[str, Any] | None,
3040
- timeout_trace: dict[str, Any],
3041
- matcher_retrieval_trace: dict[str, Any] | None,
3042
- ) -> RowEvaluationResult:
3043
- progress = self._sanitize_timeout_progress_snapshot_for_app_config_only(
3044
- progress,
3045
- matcher_retrieval_trace=matcher_retrieval_trace,
3046
- )
3047
- timeout_trace = self._sanitize_timeout_trace_for_app_config_only(
3048
- timeout_trace,
3049
- progress=progress,
3050
- matcher_retrieval_trace=matcher_retrieval_trace,
3051
- )
3052
- degraded_timeout_finalize = bool(timeout_trace.get("timeout_degraded_finalize"))
3053
- result = self._create_timeout_result(
3054
- row_id,
3055
- check_id,
3056
- message,
3057
- degraded_timeout_finalize=degraded_timeout_finalize,
3058
- progress=progress,
3059
- )
3060
- self._attach_timeout_progress_telemetry(
3061
- timeout_trace=timeout_trace,
3062
- progress=progress,
3063
- row_id=row_id,
3064
- check_id=check_id,
3065
- )
3066
- base_trace = _sanitize_retrieval_trace(matcher_retrieval_trace) or {}
3067
- result.retrieval_trace = _sanitize_retrieval_trace({**base_trace, **timeout_trace})
3068
- result = RowEvaluator._sanitize_app_config_only_result(result)
3069
- return RowEvaluator._salvage_app_config_only_timeout_result(result)
3070
-
3071
- @staticmethod
3072
- def _build_timeout_progress_config_rows(
3073
- *,
3074
- progress: dict[str, Any] | None,
3075
- matcher_retrieval_trace: dict[str, Any] | None,
3076
- ) -> list[dict[str, Any]]:
3077
- config_rows: list[dict[str, Any]] = []
3078
- for container in (
3079
- matcher_retrieval_trace,
3080
- (matcher_retrieval_trace or {}).get("tool_first_loop")
3081
- if isinstance(matcher_retrieval_trace, dict)
3082
- else None,
3083
- progress,
3084
- ):
3085
- if not isinstance(container, dict):
3086
- continue
3087
- raw_rows = container.get("config_repo_companion_refs")
3088
- if not isinstance(raw_rows, list):
3089
- continue
3090
- for row in raw_rows:
3091
- if isinstance(row, dict):
3092
- config_rows.append(dict(row))
3093
- if config_rows:
3094
- return config_rows
3095
-
3096
- fallback_rows: list[dict[str, Any]] = []
3097
- raw_refs = progress.get("evidence_refs") if isinstance(progress, dict) else None
3098
- for ref in raw_refs if isinstance(raw_refs, list) else []:
3099
- ref_value = RowEvaluator._normalize_trace_ref(ref)
3100
- if not RowEvaluator._is_config_ref_value(ref_value):
3101
- continue
3102
- parts = Path(ref_value).parts
3103
- env_name = str(parts[0]).strip().lower() if len(parts) >= 2 else ""
3104
- fallback_rows.append(
3105
- {
3106
- "ref_value": ref_value,
3107
- "ref": ref_value,
3108
- "source_repo": "app-config",
3109
- "metadata": {
3110
- "env": env_name,
3111
- "source_repo_slug": "app-config",
3112
- "config_root": "app-config",
3113
- },
3114
- }
3115
- )
3116
- return fallback_rows
3117
-
3118
- @classmethod
3119
- def _compute_timeout_app_config_sanitization(
3120
- cls,
3121
- *,
3122
- progress: dict[str, Any] | None,
3123
- matcher_retrieval_trace: dict[str, Any] | None,
3124
- ) -> tuple[dict[str, Any] | None, list[dict[str, Any]], set[str]]:
3125
- if not isinstance(progress, dict):
3126
- return None, [], set()
3127
- interpretation = (
3128
- progress.get("requirement_interpretation")
3129
- if isinstance(progress.get("requirement_interpretation"), dict)
3130
- else {}
3131
- )
3132
- sanitized_interpretation = RowEvaluator._sanitize_requirement_interpretation_for_app_config_only(interpretation)
3133
- if not RowEvaluator._is_app_config_only_requirement(
3134
- requirement_interpretation=sanitized_interpretation,
3135
- ):
3136
- return None, [], set()
3137
-
3138
- raw_refs = progress.get("evidence_refs") if isinstance(progress.get("evidence_refs"), list) else []
3139
- requirement_text = str(
3140
- sanitized_interpretation.get("intent") or progress.get("requirement_intent") or ""
3141
- ).strip()
3142
- requirement_guidance = str(sanitized_interpretation.get("detailed_guidance") or "").strip() or None
3143
- config_rows = cls._build_timeout_progress_config_rows(
3144
- progress=progress,
3145
- matcher_retrieval_trace=matcher_retrieval_trace,
3146
- )
3147
- selected_rows = RowEvaluator._select_app_config_only_rows(
3148
- requirement_text=requirement_text,
3149
- requirement_guidance=requirement_guidance,
3150
- requirement_interpretation=sanitized_interpretation,
3151
- config_rows=config_rows,
3152
- )
3153
- allowed_ref_values = RowEvaluator._allowed_app_config_only_ref_values(
3154
- requirement_text=requirement_text,
3155
- requirement_guidance=requirement_guidance,
3156
- requirement_interpretation=sanitized_interpretation,
3157
- config_rows=config_rows,
3158
- fallback_refs=raw_refs,
3159
- )
3160
- return sanitized_interpretation, selected_rows, allowed_ref_values
3161
-
3162
- @classmethod
3163
- def _sanitize_timeout_progress_snapshot_for_app_config_only(
3164
- cls,
3165
- progress: dict[str, Any] | None,
3166
- *,
3167
- matcher_retrieval_trace: dict[str, Any] | None,
3168
- ) -> dict[str, Any] | None:
3169
- if not isinstance(progress, dict):
3170
- return progress
3171
- sanitized_interpretation, selected_rows, allowed_ref_values = cls._compute_timeout_app_config_sanitization(
3172
- progress=progress,
3173
- matcher_retrieval_trace=matcher_retrieval_trace,
3174
- )
3175
- if sanitized_interpretation is None:
3176
- return progress
3177
-
3178
- normalized = dict(progress)
3179
- normalized["requirement_interpretation"] = sanitized_interpretation
3180
- normalized["evidence_refs"] = RowEvaluator._filter_refs_for_app_config_only(
3181
- normalized.get("evidence_refs"),
3182
- allowed_ref_values=allowed_ref_values,
3183
- )
3184
- normalized["config_repo_companion_refs"] = selected_rows
3185
- return normalized
3186
-
3187
- @classmethod
3188
- def _sanitize_timeout_trace_for_app_config_only(
3189
- cls,
3190
- timeout_trace: dict[str, Any],
3191
- *,
3192
- progress: dict[str, Any] | None,
3193
- matcher_retrieval_trace: dict[str, Any] | None,
3194
- ) -> dict[str, Any]:
3195
- normalized = dict(timeout_trace)
3196
- sanitized_progress = cls._sanitize_timeout_progress_snapshot_for_app_config_only(
3197
- progress,
3198
- matcher_retrieval_trace=matcher_retrieval_trace,
3199
- )
3200
- normalized["timeout_progress_snapshot"] = sanitized_progress
3201
- sanitized_interpretation, selected_rows, allowed_ref_values = cls._compute_timeout_app_config_sanitization(
3202
- progress=sanitized_progress,
3203
- matcher_retrieval_trace=matcher_retrieval_trace,
3204
- )
3205
- if sanitized_interpretation is None:
3206
- return normalized
3207
-
3208
- filtered_refs = (
3209
- RowEvaluator._filter_refs_for_app_config_only(
3210
- sanitized_progress.get("evidence_refs") if isinstance(sanitized_progress, dict) else [],
3211
- allowed_ref_values=allowed_ref_values,
3212
- )
3213
- if isinstance(sanitized_progress, dict)
3214
- else []
3215
- )
3216
- preserved_trace_steps: list[dict[str, Any]] = []
3217
- progress_loop_trace = (
3218
- sanitized_progress.get("tool_first_loop")
3219
- if isinstance(sanitized_progress, dict) and isinstance(sanitized_progress.get("tool_first_loop"), dict)
3220
- else {}
3221
- )
3222
- raw_trace_steps = progress_loop_trace.get("trace_steps") if isinstance(progress_loop_trace, dict) else None
3223
- if isinstance(raw_trace_steps, list):
3224
- for step in raw_trace_steps:
3225
- if not isinstance(step, dict):
3226
- continue
3227
- tool_name = str(step.get("tool") or "").strip()
3228
- output = step.get("output")
3229
- updated_step = dict(step)
3230
- if tool_name == "read_code_file" and isinstance(output, dict):
3231
- path_value = RowEvaluator._normalize_trace_ref(
3232
- output.get("path") or output.get("file_path") or output.get("source_path")
3233
- )
3234
- if not RowEvaluator._is_config_ref_value(path_value):
3235
- continue
3236
- if allowed_ref_values and path_value not in allowed_ref_values:
3237
- continue
3238
- elif tool_name == "record_evidence_refs" and isinstance(output, dict):
3239
- sanitized_output = dict(output)
3240
- for key in ("refs", "evidence_refs"):
3241
- if isinstance(output.get(key), list):
3242
- sanitized_output[key] = RowEvaluator._filter_trace_entries_for_app_config_only(
3243
- output.get(key),
3244
- allowed_ref_values=allowed_ref_values,
3245
- )
3246
- updated_step["output"] = sanitized_output
3247
- preserved_trace_steps.append(updated_step)
3248
- normalized["requirement_interpretation"] = sanitized_interpretation
3249
- normalized["requirement_intent"] = str(
3250
- sanitized_interpretation.get("intent") or normalized.get("requirement_intent") or ""
3251
- ).strip()
3252
- normalized["evidence_refs"] = filtered_refs
3253
- normalized["config_repo_companion_refs"] = selected_rows
3254
- normalized["cross_repo_evidence_refs"] = []
3255
- normalized["prior_knowledge_refs"] = []
3256
- normalized.pop("docs", None)
3257
- normalized["code"] = {"top_k": [], "hits": []}
3258
- normalized["tool_first_loop"] = {
3259
- "evidence_refs": filtered_refs,
3260
- "config_repo_companion_refs": selected_rows,
3261
- "cross_repo_evidence_refs": [],
3262
- "prior_knowledge_refs": [],
3263
- "trace_steps": preserved_trace_steps,
3264
- }
3265
- normalized["evidence_ref_sets"] = {
3266
- "final_cited_refs": filtered_refs[:50],
3267
- "final_cited_ref_count": len(filtered_refs),
3268
- "exploratory_refs": [],
3269
- "exploratory_ref_count": 0,
3270
- "dropped_refs": [],
3271
- "dropped_exploratory_ref_count": 0,
3272
- "final_cited_ref_modality": {"docs": False, "code": False},
3273
- }
3274
- normalized["app_config_only_enforced"] = {
3275
- "applied": True,
3276
- "allowed_ref_values": sorted(allowed_ref_values)[:20],
3277
- "final_anchor_count": 0,
3278
- }
3279
- return normalized
3280
-
3281
- async def _evaluate_row_with_legacy_timeout(
3282
- self,
3283
- *,
3284
- check: AuditCheck,
3285
- row_id: str,
3286
- row_index: int,
3287
- evidence_context: str,
3288
- evidence_refs: list[str],
3289
- project_profile: dict[str, Any] | None,
3290
- thread_id: str,
3291
- matcher_retrieval_trace: dict[str, Any] | None,
3292
- provider_health_memory: Any | None = None,
3293
- ) -> RowEvaluationResult:
3294
- row_timeout_ms = int(self.config.row_timeout_ms)
3295
- timeout_retry_attempt = 0
3296
- last_progress_summary: dict[str, int] | None = None
3297
- while True:
3298
- try:
3299
- async with asyncio.timeout(row_timeout_ms / 1000):
3300
- return await self._invoke_row_evaluator(
3301
- check=check,
3302
- row_id=row_id,
3303
- row_index=row_index,
3304
- evidence_context=evidence_context,
3305
- evidence_refs=evidence_refs,
3306
- project_profile=project_profile,
3307
- provider_health_memory=provider_health_memory,
3308
- )
3309
- except TimeoutError:
3310
- raw_progress = self._get_row_runtime_progress(row_id)
3311
- progress = self._normalize_timeout_progress_snapshot(raw_progress)
3312
- extension_decision = self._decide_row_timeout_extension(
3313
- timeout_retry_attempt=timeout_retry_attempt,
3314
- current_timeout_ms=row_timeout_ms,
3315
- progress=raw_progress,
3316
- previous_progress_summary=last_progress_summary,
3317
- )
3318
- if bool(extension_decision.get("allow")):
3319
- if isinstance(extension_decision.get("progress_summary"), dict):
3320
- last_progress_summary = dict(cast("dict[str, int]", extension_decision.get("progress_summary")))
3321
- next_timeout_ms = self._next_row_timeout_ms(row_timeout_ms, timeout_retry_attempt)
3322
- timeout_retry_attempt += 1
3323
- logger.warning(
3324
- "row_timeout_extended_for_effective_progress",
3325
- row_id=row_id,
3326
- check_id=check.id,
3327
- thread_id=thread_id,
3328
- run_id=thread_id,
3329
- audit_id=thread_id,
3330
- timeout_retry_attempt=timeout_retry_attempt,
3331
- previous_timeout_ms=row_timeout_ms,
3332
- next_timeout_ms=next_timeout_ms,
3333
- progress=progress,
3334
- )
3335
- row_timeout_ms = next_timeout_ms
3336
- continue
3337
- degraded_timeout_finalize = self._should_degrade_timeout_finalize(progress)
3338
- timeout_trace = {
3339
- "timeout_retry_attempts": timeout_retry_attempt,
3340
- "timeout_progress_snapshot": progress,
3341
- "timeout_extended": timeout_retry_attempt > 0,
3342
- "timeout_extension_denial_reason": str(extension_decision.get("reason") or "unknown"),
3343
- "timeout_degraded_finalize": degraded_timeout_finalize,
3344
- "timeout_kind": self._derive_timeout_kind(
3345
- progress=progress,
3346
- degraded_timeout_finalize=degraded_timeout_finalize,
3347
- ),
3348
- "timeout_terminal_status": (RowStatus.FAIL if degraded_timeout_finalize else RowStatus.ERROR).value,
3349
- }
3350
- extension_progress_delta = extension_decision.get("progress_delta")
3351
- if isinstance(extension_progress_delta, dict):
3352
- timeout_trace["timeout_extension_progress_delta"] = dict(extension_progress_delta)
3353
- return self._build_timeout_result_with_trace(
3354
- row_id=row_id,
3355
- check_id=check.id,
3356
- message="Row timeout exceeded",
3357
- progress=progress,
3358
- timeout_trace=timeout_trace,
3359
- matcher_retrieval_trace=matcher_retrieval_trace,
3360
- )
3361
-
3362
- def _detect_lease_progress_signal(
3363
- self,
3364
- previous_progress: dict[str, Any] | None,
3365
- current_progress: dict[str, Any] | None,
3366
- ) -> str | None:
3367
- if not isinstance(current_progress, dict):
3368
- return None
3369
- previous = previous_progress if isinstance(previous_progress, dict) else {}
3370
-
3371
- previous_seen = self._coerce_progress_timestamp(previous.get("event_last_seen_at"))
3372
- current_seen = self._coerce_progress_timestamp(current_progress.get("event_last_seen_at"))
3373
- if current_seen > previous_seen:
3374
- return "event_stream"
3375
-
3376
- for key, signal_type in (
3377
- ("event_tool_calls_started", "tool_call_started"),
3378
- ("event_tool_calls_completed", "tool_call_completed"),
3379
- ("event_skill_execution_effective_tool_calls", "skill_effective"),
3380
- ("event_turn_index", "partial_output"),
3381
- ("steps_executed", "route_transition"),
3382
- ("steps_unique_tools", "route_transition"),
3383
- ("evidence_refs_count", "evidence_growth"),
3384
- ):
3385
- if self._coerce_progress_counter(current_progress.get(key)) > self._coerce_progress_counter(
3386
- previous.get(key)
3387
- ):
3388
- return signal_type
3389
-
3390
- current_summary = self._extract_progress_summary(current_progress)
3391
- previous_summary = self._extract_progress_summary(previous)
3392
- progress_delta = self._compute_progress_delta(previous_summary, current_summary)
3393
- if isinstance(progress_delta, dict) and max(progress_delta.values(), default=0) > 0:
3394
- return "tool_activity"
3395
- return None
3396
-
3397
- def _derive_lease_stall_reason(
3398
- self,
3399
- *,
3400
- elapsed_since_progress_seconds: float,
3401
- lease_window_seconds: float,
3402
- stall_detection_seconds: float,
3403
- progress: dict[str, Any] | None,
3404
- ) -> str:
3405
- if elapsed_since_progress_seconds >= lease_window_seconds:
3406
- return "lease_expired"
3407
- termination_reason = str((progress or {}).get("termination_reason") or "").strip().lower()
3408
- if termination_reason in {"idle_after_tool", "post_tool_idle", "idle_post_tool"}:
3409
- return "idle_after_tool"
3410
- if termination_reason in {"provider_stall", "stream_stall"}:
3411
- return "provider_stall"
3412
- if termination_reason in {"tool_churn", "agent_tool_churn", "churn"}:
3413
- return "tool_churn"
3414
- if elapsed_since_progress_seconds >= stall_detection_seconds:
3415
- return "stall_detection_threshold"
3416
- return "no_progress"
3417
-
3418
- async def _evaluate_row_with_lease_timeout(
3419
- self,
3420
- *,
3421
- check: AuditCheck,
3422
- row_id: str,
3423
- row_index: int,
3424
- evidence_context: str,
3425
- evidence_refs: list[str],
3426
- project_profile: dict[str, Any] | None,
3427
- thread_id: str,
3428
- matcher_retrieval_trace: dict[str, Any] | None,
3429
- provider_health_memory: Any | None = None,
3430
- ) -> RowEvaluationResult:
3431
- import time
3432
-
3433
- absolute_timeout_seconds = max(0.05, float(self.config.row_absolute_timeout_ms) / 1000.0)
3434
- lease_window_seconds = max(0.05, float(self.config.row_progress_lease_seconds))
3435
- stall_detection_seconds = max(
3436
- 0.05,
3437
- min(float(self.config.row_stall_detection_seconds), lease_window_seconds),
3438
- )
3439
- poll_interval_seconds = min(1.0, stall_detection_seconds, lease_window_seconds)
3440
-
3441
- task = asyncio.create_task(
3442
- self._invoke_row_evaluator(
3443
- check=check,
3444
- row_id=row_id,
3445
- row_index=row_index,
3446
- evidence_context=evidence_context,
3447
- evidence_refs=evidence_refs,
3448
- project_profile=project_profile,
3449
- provider_health_memory=provider_health_memory,
3450
- )
3451
- )
3452
- started_at = time.monotonic()
3453
- last_progress_at = started_at
3454
- previous_progress: dict[str, Any] | None = None
3455
- previous_progress_summary: dict[str, int] | None = None
3456
- liveness_lease_renewals = 0
3457
- last_progress_signal: float | None = None
3458
- last_progress_signal_type: str | None = None
3459
-
3460
- try:
3461
- while True:
3462
- now = time.monotonic()
3463
- remaining_absolute_seconds = absolute_timeout_seconds - (now - started_at)
3464
- if remaining_absolute_seconds <= 0:
3465
- progress = self._normalize_timeout_progress_snapshot(self._get_row_runtime_progress(row_id))
3466
- degraded_timeout_finalize = self._should_degrade_timeout_finalize(progress)
3467
- stall_duration_seconds = max(0.0, now - last_progress_at)
3468
- timeout_trace = {
3469
- "timeout_retry_attempts": 0,
3470
- "timeout_progress_snapshot": progress,
3471
- "timeout_extended": liveness_lease_renewals > 0,
3472
- "timeout_extension_denial_reason": "absolute_timeout_reached",
3473
- "timeout_degraded_finalize": degraded_timeout_finalize,
3474
- "timeout_kind": self._derive_timeout_kind(
3475
- progress=progress,
3476
- degraded_timeout_finalize=degraded_timeout_finalize,
3477
- absolute_timeout_exceeded=True,
3478
- ),
3479
- "timeout_terminal_status": (
3480
- RowStatus.FAIL if degraded_timeout_finalize else RowStatus.ERROR
3481
- ).value,
3482
- "timeout_scope": "row_absolute_cap",
3483
- "liveness_lease_renewals": liveness_lease_renewals,
3484
- "last_progress_signal": last_progress_signal,
3485
- "last_progress_signal_type": last_progress_signal_type,
3486
- "stall_duration_seconds": round(stall_duration_seconds, 3),
3487
- "stall_reason": "absolute_timeout_reached",
3488
- }
3489
- return self._build_timeout_result_with_trace(
3490
- row_id=row_id,
3491
- check_id=check.id,
3492
- message="Row absolute timeout exceeded",
3493
- progress=progress,
3494
- timeout_trace=timeout_trace,
3495
- matcher_retrieval_trace=matcher_retrieval_trace,
3496
- )
3497
-
3498
- done, _ = await asyncio.wait({task}, timeout=min(poll_interval_seconds, remaining_absolute_seconds))
3499
- if task in done:
3500
- return await task
3501
-
3502
- progress = self._normalize_timeout_progress_snapshot(self._get_row_runtime_progress(row_id))
3503
- signal_type = self._detect_lease_progress_signal(previous_progress, progress)
3504
- extension_decision = self._decide_row_timeout_extension(
3505
- timeout_retry_attempt=liveness_lease_renewals,
3506
- current_timeout_ms=int(self.config.row_timeout_ms),
3507
- progress=progress,
3508
- previous_progress_summary=previous_progress_summary,
3509
- )
3510
- progress_summary = extension_decision.get("progress_summary")
3511
- if not isinstance(progress_summary, dict):
3512
- progress_summary = self._extract_progress_summary(progress)
3513
- if isinstance(progress_summary, dict):
3514
- previous_progress_summary = dict(progress_summary)
3515
- previous_progress = progress
3516
-
3517
- if (
3518
- signal_type is not None
3519
- or bool(extension_decision.get("allow"))
3520
- or self._has_strong_repeat_progress(progress)
3521
- ):
3522
- now = time.monotonic()
3523
- last_progress_at = now
3524
- last_progress_signal = round(now - started_at, 3)
3525
- last_progress_signal_type = signal_type or str(
3526
- extension_decision.get("reason") or "progress_heuristic"
3527
- )
3528
- liveness_lease_renewals += 1
3529
- logger.warning(
3530
- "row_timeout_lease_renewed",
3531
- row_id=row_id,
3532
- check_id=check.id,
3533
- thread_id=thread_id,
3534
- run_id=thread_id,
3535
- audit_id=thread_id,
3536
- liveness_lease_renewals=liveness_lease_renewals,
3537
- last_progress_signal=last_progress_signal,
3538
- last_progress_signal_type=last_progress_signal_type,
3539
- progress=progress,
3540
- )
3541
- continue
3542
-
3543
- now = time.monotonic()
3544
- elapsed_since_progress_seconds = max(0.0, now - last_progress_at)
3545
- if elapsed_since_progress_seconds < min(stall_detection_seconds, lease_window_seconds):
3546
- continue
3547
-
3548
- degraded_timeout_finalize = self._should_degrade_timeout_finalize(progress)
3549
- stall_reason = self._derive_lease_stall_reason(
3550
- elapsed_since_progress_seconds=elapsed_since_progress_seconds,
3551
- lease_window_seconds=lease_window_seconds,
3552
- stall_detection_seconds=stall_detection_seconds,
3553
- progress=progress,
3554
- )
3555
- timeout_trace = {
3556
- "timeout_retry_attempts": 0,
3557
- "timeout_progress_snapshot": progress,
3558
- "timeout_extended": liveness_lease_renewals > 0,
3559
- "timeout_extension_denial_reason": str(extension_decision.get("reason") or stall_reason),
3560
- "timeout_degraded_finalize": degraded_timeout_finalize,
3561
- "timeout_kind": self._derive_timeout_kind(
3562
- progress=progress,
3563
- degraded_timeout_finalize=degraded_timeout_finalize,
3564
- ),
3565
- "timeout_terminal_status": (RowStatus.FAIL if degraded_timeout_finalize else RowStatus.ERROR).value,
3566
- "timeout_scope": "row_progress_lease",
3567
- "liveness_lease_renewals": liveness_lease_renewals,
3568
- "last_progress_signal": last_progress_signal,
3569
- "last_progress_signal_type": last_progress_signal_type,
3570
- "stall_duration_seconds": round(elapsed_since_progress_seconds, 3),
3571
- "stall_reason": stall_reason,
3572
- }
3573
- extension_progress_delta = extension_decision.get("progress_delta")
3574
- if isinstance(extension_progress_delta, dict):
3575
- timeout_trace["timeout_extension_progress_delta"] = dict(extension_progress_delta)
3576
- return self._build_timeout_result_with_trace(
3577
- row_id=row_id,
3578
- check_id=check.id,
3579
- message="Row progress lease expired",
3580
- progress=progress,
3581
- timeout_trace=timeout_trace,
3582
- matcher_retrieval_trace=matcher_retrieval_trace,
3583
- )
3584
- finally:
3585
- if not task.done():
3586
- task.cancel()
3587
- with contextlib.suppress(asyncio.CancelledError):
3588
- await task
3589
-
3590
- async def _process_batch_parallel(
3591
- self,
3592
- batch_idx: int,
3593
- start_idx: int,
3594
- end_idx: int,
3595
- project_profile: dict[str, Any] | None,
3596
- checkpoint: BatchCheckpoint,
3597
- thread_id: str,
3598
- row_progress_callback: RowProgressCallback | None = None,
3599
- batch_stats: _ResilienceRetryStats | None = None,
3600
- ) -> BatchResult:
3601
- """Process rows in parallel with semaphore-bounded concurrency (FR-188).
3602
-
3603
- Checkpoint writes and diagnostics dict access are serialized under a lock
3604
- to preserve correctness under concurrency.
3605
- """
3606
- import time
3607
-
3608
- start_time = time.monotonic()
3609
- effective_concurrency = self._effective_row_concurrency()
3610
- logger.info(
3611
- "row_concurrency_active",
3612
- effective_concurrency=effective_concurrency,
3613
- batch_size=end_idx - start_idx,
3614
- adaptive_mode=bool(self.config.adaptive_row_concurrency),
3615
- profile=str((project_profile or {}).get("profile") or self.config.run_context.get("active_profile") or ""),
3616
- )
3617
- semaphore = asyncio.Semaphore(effective_concurrency)
3618
- checkpoint_lock = asyncio.Lock()
3619
- progress_lock = asyncio.Lock()
3620
- consumer = PostProcessingConsumer()
3621
- consume_task = asyncio.create_task(consumer.consume())
3622
- interim_results: list[RowEvaluationResult] = []
3623
- interim_success_count = 0
3624
- interim_error_count = 0
3625
- interim_skipped_count = 0
3626
-
3627
- async def _guarded_row(idx: int) -> tuple[int, RowEvaluationResult | None, str]:
3628
- """Wrapper that never lets BudgetExceededError escape gather."""
3629
- nonlocal interim_success_count, interim_error_count, interim_skipped_count
3630
- try:
3631
- _section_id, check = self._checks[idx]
3632
- row_id = f"{check.id}:row_{idx}"
3633
- if row_progress_callback is not None:
3634
- async with progress_lock:
3635
- inflight_result = self._build_inflight_row_progress_result(check, row_id)
3636
- maybe_awaitable = row_progress_callback(
3637
- batch_idx,
3638
- start_idx,
3639
- end_idx,
3640
- sorted(interim_results, key=lambda item: item.row_id),
3641
- interim_success_count,
3642
- interim_error_count,
3643
- interim_skipped_count,
3644
- inflight_result,
3645
- "started",
3646
- )
3647
- if inspect.isawaitable(maybe_awaitable):
3648
- await maybe_awaitable
3649
- result, outcome = await self._process_single_row(
3650
- idx=idx,
3651
- batch_idx=batch_idx,
3652
- project_profile=project_profile,
3653
- checkpoint=checkpoint,
3654
- thread_id=thread_id,
3655
- semaphore=semaphore,
3656
- checkpoint_lock=checkpoint_lock,
3657
- batch_stats=batch_stats,
3658
- )
3659
- if result is not None:
3660
- await consumer.put(result)
3661
- if row_progress_callback is not None:
3662
- async with progress_lock:
3663
- if result is not None:
3664
- interim_results[:] = [res for res in interim_results if res.row_id != result.row_id]
3665
- interim_results.append(result)
3666
- if outcome == "error":
3667
- interim_error_count += 1
3668
- elif outcome == "skipped":
3669
- interim_skipped_count += 1
3670
- else:
3671
- interim_success_count += 1
3672
- if self._should_emit_row_progress_callback(result, outcome):
3673
- maybe_awaitable = row_progress_callback(
3674
- batch_idx,
3675
- start_idx,
3676
- end_idx,
3677
- sorted(interim_results, key=lambda item: item.row_id),
3678
- interim_success_count,
3679
- interim_error_count,
3680
- interim_skipped_count,
3681
- result,
3682
- outcome,
3683
- )
3684
- if inspect.isawaitable(maybe_awaitable):
3685
- await maybe_awaitable
3686
- return idx, result, outcome
3687
- except BudgetExceededError as exc:
3688
- # BudgetExceededError escapes _process_single_row -> _guarded_row
3689
- # Convert to error result to allow batch to continue
3690
- logger.warning("parallel_row_budget_exceeded", row_index=idx, error=str(exc))
3691
- _section_id, check = self._checks[idx]
3692
- row_id = f"{check.id}:row_{idx}"
3693
- err_result = self._create_timeout_result(row_id, check.id, f"Budget exceeded: {exc}")
3694
- await consumer.put(err_result)
3695
- return idx, err_result, "error"
3696
- except Exception as exc:
3697
- logger.warning("parallel_row_error", row_index=idx, error=str(exc))
3698
- _section_id, check = self._checks[idx]
3699
- row_id = f"{check.id}:row_{idx}"
3700
- err_result = self._create_timeout_result(row_id, check.id, f"Parallel row error: {exc}")
3701
- await consumer.put(err_result)
3702
- return idx, err_result, "error"
3703
-
3704
- timed_out = False
3705
- # P161-E2 TSK-161.11: Non-targeted row skip for single-row shards.
3706
- # When target_selection specifies a single row index, only create
3707
- # _guarded_row() coroutines for that index. Eliminates 58 N/A
3708
- # iterations per child (60-120 min cumulative waste eliminated).
3709
- _row_indices = range(start_idx, end_idx)
3710
- if (
3711
- self.config.target_selection is not None
3712
- and len(self.config.target_selection.row_indices) == 1
3713
- and os.environ.get("VDS_AUDIT_CANONICAL_CHECKLIST_JSON")
3714
- ):
3715
- _target_idx = next(iter(self.config.target_selection.row_indices))
3716
- if start_idx <= _target_idx < end_idx:
3717
- _row_indices = [_target_idx]
3718
- logger.info(
3719
- "single_row_shard_skip_non_targeted",
3720
- targeted_index=_target_idx,
3721
- original_range=f"{start_idx}-{end_idx}",
3722
- skipped_count=(end_idx - start_idx) - 1,
3723
- )
3724
- try:
3725
- effective_batch_timeout_ms = self.effective_batch_timeout_ms()
3726
- async with asyncio.timeout(effective_batch_timeout_ms / 1000):
3727
- gather_results = await asyncio.gather(
3728
- *[_guarded_row(idx) for idx in _row_indices],
3729
- return_exceptions=False,
3730
- )
3731
- except TimeoutError:
3732
- await consumer.finalize()
3733
- await consume_task
3734
- logger.warning(
3735
- "batch_timeout",
3736
- batch=batch_idx,
3737
- completed=0,
3738
- expected=end_idx - start_idx,
3739
- )
3740
- # Create timeout results for all rows in the batch
3741
- results: list[RowEvaluationResult] = []
3742
- error_count = 0
3743
- skipped_count = 0
3744
- for idx in range(start_idx, end_idx):
3745
- _section_id, check = self._checks[idx]
3746
- row_id = f"{check.id}:row_{idx}"
3747
- if self._should_evaluate_row(idx, check.id, row_id, checkpoint):
3748
- progress = self._normalize_timeout_progress_snapshot(self._get_row_runtime_progress(row_id))
3749
- degraded = self._should_degrade_timeout_finalize(progress)
3750
- timeout_result = self._create_timeout_result(
3751
- row_id,
3752
- check.id,
3753
- "Batch timeout exceeded",
3754
- degraded_timeout_finalize=degraded,
3755
- progress=progress,
3756
- )
3757
- timeout_trace = {
3758
- "timeout_retry_attempts": 0,
3759
- "timeout_progress_snapshot": progress,
3760
- "timeout_kind": self._derive_timeout_kind(
3761
- progress=progress,
3762
- degraded_timeout_finalize=degraded,
3763
- batch_timeout_exceeded=True,
3764
- ),
3765
- "timeout_extended": False,
3766
- "timeout_degraded_finalize": degraded,
3767
- "timeout_terminal_status": timeout_result.status.value,
3768
- "batch_timeout_exceeded": True,
3769
- }
3770
- self._attach_timeout_progress_telemetry(
3771
- timeout_trace=timeout_trace,
3772
- progress=progress,
3773
- row_id=row_id,
3774
- check_id=check.id,
3775
- )
3776
- timeout_result.retrieval_trace = _sanitize_retrieval_trace(
3777
- self._sanitize_timeout_trace_for_app_config_only(
3778
- timeout_trace,
3779
- progress=progress,
3780
- matcher_retrieval_trace=None,
3781
- )
3782
- )
3783
- timeout_result = RowEvaluator._sanitize_app_config_only_result(timeout_result)
3784
- timeout_result = RowEvaluator._salvage_app_config_only_timeout_result(timeout_result)
3785
- results.append(timeout_result)
3786
- error_count += 1
3787
- elif row_id in checkpoint.results_by_row_id:
3788
- try:
3789
- preserved = BatchCheckpoint.deserialize_row_result(checkpoint.results_by_row_id[row_id])
3790
- results.append(preserved)
3791
- except Exception:
3792
- pass
3793
- skipped_count += 1
3794
-
3795
- duration_ms = int((time.monotonic() - start_time) * 1000)
3796
- return BatchResult(
3797
- batch_index=batch_idx,
3798
- start_row=start_idx,
3799
- end_row=end_idx,
3800
- results=results,
3801
- duration_ms=duration_ms,
3802
- success_count=0,
3803
- error_count=error_count,
3804
- timed_out=True,
3805
- skipped_count=skipped_count,
3806
- )
3807
-
3808
- # Finalize consumer and collect overlap diagnostics (FR-193)
3809
- await consumer.finalize()
3810
- postproc_diagnostics = await consume_task
3811
-
3812
- # Assemble results in index order
3813
- results = []
3814
- success_count = 0
3815
- error_count = 0
3816
- skipped_count = 0
3817
- for _, result, outcome in sorted(gather_results, key=lambda x: x[0]):
3818
- if result is not None:
3819
- results.append(result)
3820
- if outcome == "error":
3821
- error_count += 1
3822
- elif outcome == "skipped":
3823
- skipped_count += 1
3824
- else:
3825
- success_count += 1
3826
-
3827
- # FR-145.2: Post-pass ERROR retry sweep (parallel path mirror of serial path).
3828
- # Only runs when batch_error_retry_limit > 0 and there are ERROR rows.
3829
- if not timed_out and error_count > 0 and self.config.batch_error_retry_limit > 0:
3830
- health_memory: ProviderHealthMemory | None = getattr(self, "_batch_health_memory", None)
3831
- failover_profiles: list[str] = list(getattr(self, "_batch_failover_profiles", None) or [])
3832
- if health_memory is not None and failover_profiles:
3833
- budget = ResilienceBudget(
3834
- total_rows=len(results),
3835
- error_count=error_count,
3836
- )
3837
- retried = await self._retry_error_rows(
3838
- results=results,
3839
- health_memory=health_memory,
3840
- budget=budget,
3841
- failover_profiles=failover_profiles,
3842
- project_profile=project_profile,
3843
- stats=batch_stats,
3844
- )
3845
- self._resilience_stats_accumulator.append(batch_stats)
3846
- new_error_count = sum(1 for r in retried if r.status == RowStatus.ERROR)
3847
- new_success_count = sum(
3848
- 1
3849
- for r in retried
3850
- if r.status != RowStatus.ERROR
3851
- and r.row_id in {orig.row_id for orig in results if orig.status == RowStatus.ERROR}
3852
- )
3853
- if budget.calls_used > 0:
3854
- logger.info(
3855
- "resilience_retry_sweep_complete",
3856
- batch_index=batch_idx,
3857
- errors_before=error_count,
3858
- errors_after=new_error_count,
3859
- retries_attempted=budget.calls_used,
3860
- budget_total=budget.total,
3861
- )
3862
- results = retried
3863
- error_count = new_error_count
3864
- success_count += new_success_count
3865
-
3866
- # FR-13.3b: Check for budget errors in parallel results and raise BatchBudgetExceededError
3867
- budget_error_results = [
3868
- r for r in results
3869
- if "Budget exceeded" in (getattr(r, "reason", "") or "")
3870
- or "Budget exceeded" in (getattr(r, "error_message", "") or "")
3871
- ]
3872
- if budget_error_results:
3873
- # Get the budget info from first error result
3874
- budget_result = budget_error_results[0]
3875
- # Extract row details from the error result
3876
- row_id = budget_result.row_id
3877
- check_id = budget_result.check_id
3878
- # Parse row index from row_id (format: "check_id:row_N")
3879
- row_index = None
3880
- if ":row_" in row_id:
3881
- try:
3882
- row_index = int(row_id.split(":row_")[-1]) + 1 # 1-based index
3883
- except ValueError:
3884
- row_index = None
3885
- context = {
3886
- "kind": "strict_budget_exceeded",
3887
- "audit_error_key": "LLM_BUDGET_EXCEEDED",
3888
- "audit_error_code": AUDIT_ERROR_CODES["LLM_BUDGET_EXCEEDED"].code,
3889
- "batch_index": batch_idx + 1,
3890
- "row_index": row_index,
3891
- "check_id": check_id,
3892
- "row_id": row_id,
3893
- "status": "exceeded",
3894
- "scope": "audit",
3895
- }
3896
- raise BatchBudgetExceededError(
3897
- message=str(budget_result.reason or budget_result.error_message),
3898
- context=context,
3899
- partial_results=list(results),
3900
- success_count=success_count,
3901
- error_count=error_count,
3902
- skipped_count=skipped_count,
3903
- )
3904
-
3905
- postproc_overlap_ms = int(postproc_diagnostics.get("overlap_seconds", 0.0) * 1000)
3906
- duration_ms = int((time.monotonic() - start_time) * 1000)
3907
- return BatchResult(
3908
- batch_index=batch_idx,
3909
- start_row=start_idx,
3910
- end_row=end_idx,
3911
- results=results,
3912
- duration_ms=duration_ms,
3913
- success_count=success_count,
3914
- error_count=error_count,
3915
- timed_out=False,
3916
- skipped_count=skipped_count,
3917
- postproc_overlap_ms=postproc_overlap_ms,
3918
- )
3919
-
3920
- def _get_row_runtime_progress(self, row_id: str) -> dict[str, Any] | None:
3921
- getter = getattr(self.evaluator, "get_row_runtime_progress", None)
3922
- if not callable(getter):
3923
- return None
3924
- progress = getter(row_id)
3925
- if not isinstance(progress, dict):
3926
- return None
3927
- return dict(progress)
3928
-
3929
- @staticmethod
3930
- def _attach_timeout_progress_telemetry(
3931
- *,
3932
- timeout_trace: dict[str, Any],
3933
- progress: dict[str, Any] | None,
3934
- row_id: str | None = None,
3935
- check_id: str | None = None,
3936
- ) -> None:
3937
- if not isinstance(timeout_trace, dict) or not isinstance(progress, dict):
3938
- return
3939
-
3940
- prompt_summary = progress.get("prompt_tool_telemetry_summary")
3941
- if isinstance(prompt_summary, dict):
3942
- timeout_trace["prompt_tool_telemetry_summary"] = dict(prompt_summary)
3943
-
3944
- prompt_payload = progress.get("prompt_tool_telemetry")
3945
- if isinstance(prompt_payload, dict):
3946
- timeout_trace["prompt_tool_telemetry"] = dict(prompt_payload)
3947
-
3948
- interpretation = progress.get("requirement_interpretation")
3949
- if isinstance(interpretation, dict):
3950
- timeout_trace["requirement_interpretation"] = dict(interpretation)
3951
-
3952
- for key in (
3953
- "route_id",
3954
- "route_mode",
3955
- "route_reason",
3956
- "selection_blocked_reason",
3957
- ):
3958
- value = progress.get(key)
3959
- if value not in (None, False, ""):
3960
- timeout_trace.setdefault(key, value)
3961
- for key in (
3962
- "route_transition_reasons",
3963
- "project_artifact_provenance_summary",
3964
- "cross_repo_evidence_refs",
3965
- "config_repo_companion_refs",
3966
- ):
3967
- value = progress.get(key)
3968
- if isinstance(value, list) and value:
3969
- timeout_trace.setdefault(key, list(value))
3970
- for key in (
3971
- "docs_intent_utilization",
3972
- "code_ranking_diagnostics",
3973
- "project_artifact_readiness",
3974
- ):
3975
- value = progress.get(key)
3976
- if isinstance(value, dict) and value:
3977
- timeout_trace.setdefault(key, dict(value))
3978
-
3979
- timeout_kind = str(timeout_trace.get("timeout_kind") or "").strip()
3980
- timeout_terminal_status = str(timeout_trace.get("timeout_terminal_status") or "").strip().upper() or "ERROR"
3981
- raw_refs = progress.get("evidence_refs")
3982
- fallback_anchor_count = len(raw_refs) if isinstance(raw_refs, list) else 0
3983
- if "grounding_validation" not in timeout_trace:
3984
- timeout_trace["grounding_validation"] = {
3985
- "complete": False,
3986
- "timeout_incomplete": True,
3987
- "timeout_kind": timeout_kind or False,
3988
- "total_anchors": fallback_anchor_count,
3989
- "valid_count": 0,
3990
- "invalid_count": 0,
3991
- "all_grounded": False,
3992
- "grounding_ratio": 0.0,
3993
- "strict_mode": False,
3994
- "strict_mode_zero_valid_error": False,
3995
- "invalid_ref_values": [],
3996
- "gap_signal": False,
3997
- }
3998
- if "evidence_gap_diagnostics" not in timeout_trace:
3999
- interpretation_mapping = interpretation if isinstance(interpretation, dict) else {}
4000
- readiness_mapping = (
4001
- dict(progress.get("project_artifact_readiness"))
4002
- if isinstance(progress.get("project_artifact_readiness"), dict)
4003
- else {}
4004
- )
4005
- diagnostics: dict[str, Any] = {
4006
- "applied": False,
4007
- "classification": False,
4008
- "gap_type": False,
4009
- "status_considered": timeout_terminal_status,
4010
- "dominant_unverified_reason": False,
4011
- "verified_true_count": 0,
4012
- "verified_false_count": fallback_anchor_count,
4013
- "incomplete_due_to_timeout": True,
4014
- "timeout_kind": timeout_kind or False,
4015
- }
4016
- if bool(interpretation_mapping.get("project_scope_required")):
4017
- authoritative_ready = bool(readiness_mapping.get("authoritative_artifact_ready"))
4018
- missing_artifacts = list(readiness_mapping.get("missing_artifact_types") or [])
4019
- if readiness_mapping and (not authoritative_ready or bool(missing_artifacts)):
4020
- diagnostics.update(
4021
- {
4022
- "applied": True,
4023
- "classification": "confirmed_gap",
4024
- "gap_type": "authoritative_project_scope_artifact_missing",
4025
- }
4026
- )
4027
- timeout_trace["evidence_gap_diagnostics"] = diagnostics
4028
-
4029
- skill_policy_preview = progress.get("skill_policy_preview")
4030
- if not isinstance(skill_policy_preview, dict):
4031
- return
4032
-
4033
- def _safe_int(value: Any) -> int:
4034
- try:
4035
- return int(value or 0)
4036
- except (TypeError, ValueError):
4037
- return 0
4038
-
4039
- skill_policy_timeout = dict(skill_policy_preview)
4040
- skill_policy_timeout.setdefault("incomplete_due_to_timeout", True)
4041
- if isinstance(prompt_summary, dict):
4042
- skill_policy_timeout["observed_skill_calls"] = max(
4043
- _safe_int(skill_policy_timeout.get("observed_skill_calls")),
4044
- _safe_int(prompt_summary.get("skill_calls")),
4045
- )
4046
- skill_policy_timeout["observed_skill_execution_calls"] = max(
4047
- _safe_int(skill_policy_timeout.get("observed_skill_execution_calls")),
4048
- _safe_int(prompt_summary.get("skill_execution_calls")),
4049
- )
4050
- skill_policy_timeout["observed_skill_effective_calls"] = max(
4051
- _safe_int(skill_policy_timeout.get("observed_skill_effective_calls")),
4052
- _safe_int(prompt_summary.get("skill_effective_calls")),
4053
- )
4054
- timeout_trace["skill_policy_retry"] = skill_policy_timeout
4055
- logger.info(
4056
- "row_skill_policy_timeout_snapshot",
4057
- row_id=row_id,
4058
- check_id=check_id,
4059
- skill_metrics_scope="timeout_progress_snapshot",
4060
- required=bool(skill_policy_timeout.get("required")),
4061
- policy_mode=str(skill_policy_timeout.get("policy_mode") or "unknown"),
4062
- strict_require_effective_skill=bool(skill_policy_timeout.get("strict_require_effective_skill")),
4063
- enforcement_enabled=bool(skill_policy_timeout.get("enforcement_enabled")),
4064
- incomplete_due_to_timeout=True,
4065
- observed_skill_calls=_safe_int(skill_policy_timeout.get("observed_skill_calls")),
4066
- observed_skill_execution_calls=_safe_int(skill_policy_timeout.get("observed_skill_execution_calls")),
4067
- observed_skill_effective_calls=_safe_int(skill_policy_timeout.get("observed_skill_effective_calls")),
4068
- )
4069
-
4070
- def effective_row_timeout_ceiling_ms(self) -> int:
4071
- """Return maximum per-attempt row timeout reachable under extension policy."""
4072
- if self._lease_timeout_mode_enabled():
4073
- return max(1, int(self.config.row_absolute_timeout_ms))
4074
- base_timeout_ms = max(1, int(self.config.row_timeout_ms))
4075
- if not bool(self.config.row_timeout_progress_extension_enabled):
4076
- return base_timeout_ms
4077
-
4078
- extension_steps = self._effective_timeout_extension_steps(base_timeout_ms)
4079
- if extension_steps <= 0:
4080
- return base_timeout_ms
4081
-
4082
- timeout_ms = base_timeout_ms
4083
- for attempt in range(extension_steps):
4084
- next_timeout_ms = self._next_row_timeout_ms(timeout_ms, attempt)
4085
- if next_timeout_ms <= timeout_ms:
4086
- break
4087
- timeout_ms = next_timeout_ms
4088
- return timeout_ms
4089
-
4090
- def effective_row_timeout_envelope_ms(self) -> int:
4091
- """Return cumulative per-row timeout envelope across all retry attempts.
4092
-
4093
- Row timeout retries currently re-run row evaluation with progressively larger
4094
- per-attempt timeouts. The total elapsed time can therefore exceed the final
4095
- per-attempt timeout ceiling. Batch timeout budgeting must account for this
4096
- cumulative envelope to avoid preempting rows that are still making progress.
4097
- """
4098
- if self._lease_timeout_mode_enabled():
4099
- return max(1, int(self.config.row_absolute_timeout_ms))
4100
- current_timeout_ms = max(1, int(self.config.row_timeout_ms))
4101
- envelope_ms = current_timeout_ms
4102
-
4103
- if not bool(self.config.row_timeout_progress_extension_enabled):
4104
- return envelope_ms
4105
-
4106
- extension_steps = self._effective_timeout_extension_steps(current_timeout_ms)
4107
- if extension_steps <= 0:
4108
- return envelope_ms
4109
-
4110
- for attempt in range(extension_steps):
4111
- next_timeout_ms = self._next_row_timeout_ms(current_timeout_ms, attempt)
4112
- if next_timeout_ms <= current_timeout_ms:
4113
- break
4114
- envelope_ms += next_timeout_ms
4115
- current_timeout_ms = next_timeout_ms
4116
-
4117
- return envelope_ms
4118
-
4119
- def effective_batch_timeout_ms(self) -> int:
4120
- """Return effective batch timeout with cumulative progress-aware retry headroom."""
4121
- if self.config.batch_timeout_ms is not None:
4122
- return int(self.config.batch_timeout_ms)
4123
- return int(self.config.batch_size * self.effective_row_timeout_envelope_ms() + self.config.batch_overhead_ms)
4124
-
4125
- def _lease_timeout_mode_enabled(self) -> bool:
4126
- return int(self.config.row_progress_lease_seconds or 0) > 0
4127
-
4128
- def _clear_row_runtime_progress(self, row_id: str) -> None:
4129
- clearer = getattr(self.evaluator, "clear_row_runtime_progress", None)
4130
- if callable(clearer):
4131
- clearer(row_id)
4132
-
4133
- def _effective_timeout_extension_steps(self, base_timeout_ms: int) -> int:
4134
- """Return extension steps to budget when progress-based cap override is enabled."""
4135
- retry_attempts = max(0, int(self.config.row_timeout_progress_retry_attempts))
4136
- if retry_attempts <= 0:
4137
- return 0
4138
-
4139
- max_timeout_ms = max(int(self.config.row_timeout_ms), int(self.config.row_timeout_progress_max_ms))
4140
- if max_timeout_ms <= base_timeout_ms:
4141
- return retry_attempts
4142
-
4143
- extension_ms = max(1, int(self.config.row_timeout_progress_extension_ms))
4144
- steps_to_max = math.ceil((max_timeout_ms - base_timeout_ms) / extension_ms)
4145
-
4146
- # Runtime can continue beyond retry cap when telemetry still shows progress;
4147
- # batch budgeting should include that headroom to avoid premature batch timeout.
4148
- return max(retry_attempts, steps_to_max)
4149
-
4150
- def _next_row_timeout_ms(self, current_timeout_ms: int, timeout_retry_attempt: int) -> int:
4151
- max_timeout_ms = max(int(self.config.row_timeout_ms), int(self.config.row_timeout_progress_max_ms))
4152
- base_extension_ms = max(1, int(self.config.row_timeout_progress_extension_ms))
4153
-
4154
- # Keep increment size stable across retries so progressing rows can
4155
- # accumulate enough wall-clock budget before finalization.
4156
- extension_ms = base_extension_ms
4157
-
4158
- return min(max_timeout_ms, current_timeout_ms + extension_ms)
4159
-
4160
- @staticmethod
4161
- def _coerce_progress_counter(value: Any) -> int:
4162
- if isinstance(value, bool):
4163
- return int(value)
4164
- if isinstance(value, int | float):
4165
- return max(0, int(value))
4166
- if isinstance(value, str):
4167
- try:
4168
- return max(0, int(float(value.strip())))
4169
- except ValueError:
4170
- return 0
4171
- return 0
4172
-
4173
- @staticmethod
4174
- def _coerce_progress_timestamp(value: Any) -> float:
4175
- if isinstance(value, bool):
4176
- return 0.0
4177
- if isinstance(value, int | float):
4178
- return float(value)
4179
- if isinstance(value, str):
4180
- try:
4181
- return float(value.strip())
4182
- except ValueError:
4183
- return 0.0
4184
- return 0.0
4185
-
4186
- def _derive_progress_summary_from_snapshot(
4187
- self,
4188
- progress: dict[str, Any] | None,
4189
- *,
4190
- include_step_estimate: bool = True,
4191
- ) -> dict[str, int] | None:
4192
- if not isinstance(progress, dict):
4193
- return None
4194
-
4195
- prompt_summary = progress.get("prompt_tool_telemetry_summary")
4196
- skill_preview = progress.get("skill_policy_preview")
4197
- summary: dict[str, int] = dict.fromkeys(_TIMEOUT_PROGRESS_COUNTER_KEYS, 0)
4198
- signal_detected = False
4199
-
4200
- if isinstance(prompt_summary, dict):
4201
- for key in _TIMEOUT_PROGRESS_COUNTER_KEYS:
4202
- value = self._coerce_progress_counter(prompt_summary.get(key))
4203
- summary[key] = max(summary[key], value)
4204
- signal_detected = signal_detected or value > 0
4205
-
4206
- if isinstance(skill_preview, dict):
4207
- observed_skill_calls = self._coerce_progress_counter(skill_preview.get("observed_skill_calls"))
4208
- observed_skill_execution_calls = self._coerce_progress_counter(
4209
- skill_preview.get("observed_skill_execution_calls")
4210
- )
4211
- observed_skill_effective_calls = self._coerce_progress_counter(
4212
- skill_preview.get("observed_skill_effective_calls")
4213
- )
4214
- summary["skill_calls"] = max(summary["skill_calls"], observed_skill_calls)
4215
- summary["skill_execution_calls"] = max(summary["skill_execution_calls"], observed_skill_execution_calls)
4216
- summary["skill_effective_calls"] = max(summary["skill_effective_calls"], observed_skill_effective_calls)
4217
- signal_detected = signal_detected or any(
4218
- value > 0
4219
- for value in (
4220
- observed_skill_calls,
4221
- observed_skill_execution_calls,
4222
- observed_skill_effective_calls,
4223
- )
4224
- )
4225
-
4226
- if include_step_estimate:
4227
- tool_calls_from_steps = self._coerce_progress_counter(progress.get("steps_executed"))
4228
- summary["tool_calls"] = max(summary["tool_calls"], tool_calls_from_steps)
4229
- signal_detected = signal_detected or tool_calls_from_steps > 0
4230
-
4231
- if signal_detected or isinstance(prompt_summary, dict) or isinstance(skill_preview, dict):
4232
- return summary
4233
- return None
4234
-
4235
- def _normalize_timeout_progress_snapshot(self, progress: dict[str, Any] | None) -> dict[str, Any] | None:
4236
- if not isinstance(progress, dict):
4237
- return progress
4238
-
4239
- normalized = dict(progress)
4240
- original_prompt_summary = progress.get("prompt_tool_telemetry_summary")
4241
- original_prompt_payload = progress.get("prompt_tool_telemetry")
4242
- original_skill_preview = progress.get("skill_policy_preview")
4243
- summary = self._derive_progress_summary_from_snapshot(normalized, include_step_estimate=True)
4244
- if not isinstance(summary, dict):
4245
- return normalized
4246
-
4247
- normalized["prompt_tool_telemetry_summary"] = dict(summary)
4248
- normalized["timeout_progress_summary_source"] = (
4249
- "explicit" if isinstance(original_prompt_summary, dict) else "derived"
4250
- )
4251
- normalized["timeout_progress_has_explicit_prompt_telemetry"] = isinstance(original_prompt_payload, dict)
4252
- normalized["timeout_progress_has_explicit_skill_preview"] = isinstance(original_skill_preview, dict)
4253
-
4254
- prompt_payload = normalized.get("prompt_tool_telemetry")
4255
- if isinstance(prompt_payload, dict):
4256
- merged_payload = dict(prompt_payload)
4257
- merged_payload["event_tool_calls_completed"] = max(
4258
- self._coerce_progress_counter(merged_payload.get("event_tool_calls_completed")),
4259
- self._coerce_progress_counter(summary.get("tool_calls")),
4260
- )
4261
- merged_payload["event_skill_tool_calls"] = max(
4262
- self._coerce_progress_counter(merged_payload.get("event_skill_tool_calls")),
4263
- self._coerce_progress_counter(summary.get("skill_calls")),
4264
- )
4265
- merged_payload["event_skill_execution_tool_calls"] = max(
4266
- self._coerce_progress_counter(merged_payload.get("event_skill_execution_tool_calls")),
4267
- self._coerce_progress_counter(summary.get("skill_execution_calls")),
4268
- )
4269
- merged_payload["event_skill_effective_tool_calls"] = max(
4270
- self._coerce_progress_counter(merged_payload.get("event_skill_effective_tool_calls")),
4271
- self._coerce_progress_counter(summary.get("skill_effective_calls")),
4272
- )
4273
- merged_payload["event_skill_execution_effective_tool_calls"] = max(
4274
- self._coerce_progress_counter(merged_payload.get("event_skill_execution_effective_tool_calls")),
4275
- self._coerce_progress_counter(summary.get("skill_effective_calls")),
4276
- )
4277
- normalized["prompt_tool_telemetry"] = merged_payload
4278
-
4279
- skill_preview = normalized.get("skill_policy_preview")
4280
- if isinstance(skill_preview, dict):
4281
- merged_skill_preview = dict(skill_preview)
4282
- merged_skill_preview["observed_skill_calls"] = max(
4283
- self._coerce_progress_counter(merged_skill_preview.get("observed_skill_calls")),
4284
- self._coerce_progress_counter(summary.get("skill_calls")),
4285
- )
4286
- merged_skill_preview["observed_skill_execution_calls"] = max(
4287
- self._coerce_progress_counter(merged_skill_preview.get("observed_skill_execution_calls")),
4288
- self._coerce_progress_counter(summary.get("skill_execution_calls")),
4289
- )
4290
- merged_skill_preview["observed_skill_effective_calls"] = max(
4291
- self._coerce_progress_counter(merged_skill_preview.get("observed_skill_effective_calls")),
4292
- self._coerce_progress_counter(summary.get("skill_effective_calls")),
4293
- )
4294
- normalized["skill_policy_preview"] = merged_skill_preview
4295
-
4296
- return normalized
4297
-
4298
- def _extract_progress_summary(self, progress: dict[str, Any] | None) -> dict[str, int] | None:
4299
- summary = self._derive_progress_summary_from_snapshot(progress, include_step_estimate=False)
4300
- if isinstance(summary, dict):
4301
- return dict(summary)
4302
- return None
4303
-
4304
- def _has_strong_repeat_progress(self, progress: dict[str, Any] | None) -> bool:
4305
- """Allow bounded repeat extension when repeated snapshots still show strong work."""
4306
- if not isinstance(progress, dict):
4307
- return False
4308
- if not bool(progress.get("effective_progress")) or not self._progress_has_grounding_signal(progress):
4309
- return False
4310
- # Prevent stale pre-LLM "completed" snapshots from repeatedly extending timeout.
4311
- # Strong repeat extension is only valid while tool-first loop itself is still timing out.
4312
- termination_reason = str(progress.get("termination_reason") or "").strip().lower()
4313
- if termination_reason and termination_reason != "timeout":
4314
- return False
4315
- steps_executed = self._coerce_progress_counter(progress.get("steps_executed"))
4316
- steps_unique_tools = self._coerce_progress_counter(progress.get("steps_unique_tools"))
4317
- repetition_raw = progress.get("step_repetition_rate")
4318
- repetition_rate = float(repetition_raw) if repetition_raw is not None else 1.0
4319
- return steps_executed >= 3 and steps_unique_tools >= 2 and repetition_rate <= 0.6
4320
-
4321
- @staticmethod
4322
- def _compute_progress_delta(
4323
- previous_summary: dict[str, int] | None,
4324
- current_summary: dict[str, int] | None,
4325
- ) -> dict[str, int] | None:
4326
- if not isinstance(previous_summary, dict) or not isinstance(current_summary, dict):
4327
- return None
4328
- delta: dict[str, int] = {}
4329
- for key in _TIMEOUT_PROGRESS_COUNTER_KEYS:
4330
- previous_value = max(0, int(previous_summary.get(key, 0)))
4331
- current_value = max(0, int(current_summary.get(key, 0)))
4332
- delta[key] = max(0, current_value - previous_value)
4333
- return delta
4334
-
4335
- def _decide_row_timeout_extension(
4336
- self,
4337
- *,
4338
- timeout_retry_attempt: int,
4339
- current_timeout_ms: int,
4340
- progress: dict[str, Any] | None,
4341
- previous_progress_summary: dict[str, int] | None,
4342
- ) -> dict[str, Any]:
4343
- decision: dict[str, Any] = {
4344
- "allow": False,
4345
- "reason": "not_allowed",
4346
- "progress_summary": None,
4347
- "progress_delta": None,
4348
- }
4349
- if not bool(self.config.row_timeout_progress_extension_enabled):
4350
- decision["reason"] = "extension_disabled"
4351
- return decision
4352
- retry_attempts = max(0, int(self.config.row_timeout_progress_retry_attempts))
4353
- if retry_attempts <= 0:
4354
- decision["reason"] = "attempt_cap_reached"
4355
- return decision
4356
- extension_cap_reached = timeout_retry_attempt >= retry_attempts
4357
- if current_timeout_ms >= max(int(self.config.row_timeout_ms), int(self.config.row_timeout_progress_max_ms)):
4358
- decision["reason"] = "max_timeout_reached"
4359
- return decision
4360
- if not isinstance(progress, dict):
4361
- decision["reason"] = "missing_progress_snapshot"
4362
- return decision
4363
- if not bool(progress.get("effective_progress")):
4364
- decision["reason"] = "ineffective_progress_snapshot"
4365
- return decision
4366
- if not self._progress_has_grounding_signal(progress):
4367
- decision["reason"] = "missing_grounding_signal"
4368
- return decision
4369
-
4370
- termination_reason = str(progress.get("termination_reason") or "").strip().lower()
4371
- if timeout_retry_attempt < 1 and termination_reason and termination_reason != "timeout":
4372
- decision["reason"] = "termination_reason_not_timeout"
4373
- return decision
4374
-
4375
- if timeout_retry_attempt >= 1:
4376
- # Repeat extensions remain bounded, but should continue when
4377
- # telemetry still shows meaningful work.
4378
- repetition_raw = progress.get("step_repetition_rate")
4379
- repetition_rate = float(repetition_raw) if repetition_raw is not None else 1.0
4380
- if repetition_rate >= 0.7:
4381
- decision["reason"] = "high_step_repetition_rate"
4382
- return decision
4383
-
4384
- current_summary = self._extract_progress_summary(progress)
4385
- decision["progress_summary"] = current_summary
4386
- if current_summary is not None and previous_progress_summary is not None:
4387
- progress_delta = self._compute_progress_delta(previous_progress_summary, current_summary)
4388
- decision["progress_delta"] = progress_delta
4389
- if isinstance(progress_delta, dict) and max(progress_delta.values(), default=0) > 0:
4390
- decision["allow"] = True
4391
- decision["reason"] = (
4392
- "repeat_extension_progress_delta_beyond_cap"
4393
- if extension_cap_reached
4394
- else "repeat_extension_progress_delta"
4395
- )
4396
- return decision
4397
-
4398
- # Strong grounded progress may still justify repeat extensions even
4399
- # when prompt telemetry counters remain stationary across retries.
4400
- if self._has_strong_repeat_progress(progress):
4401
- decision["allow"] = True
4402
- if current_summary is None:
4403
- decision["progress_summary"] = {
4404
- "tool_calls": self._coerce_progress_counter(progress.get("steps_executed")),
4405
- "skill_calls": 0,
4406
- "skill_execution_calls": 0,
4407
- "skill_effective_calls": 0,
4408
- }
4409
- decision["reason"] = (
4410
- "repeat_extension_strong_progress_no_prompt_summary_beyond_cap"
4411
- if extension_cap_reached
4412
- else "repeat_extension_strong_progress_no_prompt_summary"
4413
- )
4414
- elif previous_progress_summary is None:
4415
- decision["reason"] = (
4416
- "repeat_extension_strong_progress_missing_previous_summary_beyond_cap"
4417
- if extension_cap_reached
4418
- else "repeat_extension_strong_progress_missing_previous_summary"
4419
- )
4420
- else:
4421
- decision["reason"] = (
4422
- "repeat_extension_strong_progress_stationary_summary_beyond_cap"
4423
- if extension_cap_reached
4424
- else "repeat_extension_strong_progress_stationary_summary"
4425
- )
4426
- return decision
4427
-
4428
- if current_summary is None:
4429
- decision["reason"] = (
4430
- "missing_prompt_telemetry_for_repeat_extension_beyond_cap"
4431
- if extension_cap_reached
4432
- else "missing_prompt_telemetry_for_repeat_extension"
4433
- )
4434
- elif previous_progress_summary is None:
4435
- decision["reason"] = (
4436
- "missing_previous_progress_summary_for_repeat_extension_beyond_cap"
4437
- if extension_cap_reached
4438
- else "missing_previous_progress_summary_for_repeat_extension"
4439
- )
4440
- else:
4441
- decision["reason"] = (
4442
- "no_delta_since_last_timeout_beyond_cap" if extension_cap_reached else "no_delta_since_last_timeout"
4443
- )
4444
- decision["progress_delta"] = self._compute_progress_delta(previous_progress_summary, current_summary)
4445
- return decision
4446
-
4447
- if extension_cap_reached:
4448
- decision["reason"] = "attempt_cap_reached"
4449
- return decision
4450
- decision["allow"] = True
4451
- decision["reason"] = "first_extension_allowed"
4452
- decision["progress_summary"] = self._extract_progress_summary(progress)
4453
- return decision
4454
-
4455
- def _progress_has_grounding_signal(self, progress: dict[str, Any] | None) -> bool:
4456
- if not isinstance(progress, dict):
4457
- return False
4458
- evidence_refs_count = progress.get("evidence_refs_count")
4459
- if isinstance(evidence_refs_count, bool):
4460
- return bool(evidence_refs_count)
4461
- if isinstance(evidence_refs_count, int | float):
4462
- return evidence_refs_count > 0
4463
- if isinstance(evidence_refs_count, str):
4464
- try:
4465
- return float(evidence_refs_count) > 0
4466
- except ValueError:
4467
- return False
4468
- if isinstance(evidence_refs_count, list | tuple | set | dict):
4469
- return len(evidence_refs_count) > 0
4470
- return False
4471
-
4472
- @staticmethod
4473
- def _progress_has_recorded_or_verified_grounding(progress: dict[str, Any] | None) -> bool:
4474
- if not isinstance(progress, dict):
4475
- return False
4476
- if bool(progress.get("record_evidence_refs_contract_met")):
4477
- return True
4478
- raw_payload = progress.get("evidence_ref_verifications")
4479
- entries: list[dict[str, Any]] = []
4480
- if isinstance(raw_payload, dict):
4481
- for ref_value, payload in raw_payload.items():
4482
- if isinstance(payload, dict):
4483
- merged = dict(payload)
4484
- merged.setdefault("ref_value", str(ref_value or "").strip())
4485
- entries.append(merged)
4486
- elif isinstance(raw_payload, list):
4487
- entries = [entry for entry in raw_payload if isinstance(entry, dict)]
4488
- for entry in entries:
4489
- if not bool(entry.get("verified")):
4490
- continue
4491
- excerpt = str(entry.get("excerpt") or "").strip()
4492
- if excerpt:
4493
- return True
4494
- return False
4495
-
4496
- def _should_degrade_timeout_finalize(self, progress: dict[str, Any] | None) -> bool:
4497
- """Return whether timeout should degrade to grounded terminal status (FR-128)."""
4498
- if not isinstance(progress, dict):
4499
- return False
4500
- if not bool(progress.get("effective_progress")):
4501
- return False
4502
-
4503
- has_grounding_signal = self._progress_has_grounding_signal(progress)
4504
- if not has_grounding_signal:
4505
- return False
4506
-
4507
- termination_reason = str(progress.get("termination_reason") or "").strip().lower()
4508
- if termination_reason == "completed":
4509
- if self._progress_has_recorded_or_verified_grounding(progress):
4510
- return True
4511
-
4512
- explicit_prompt_summary = progress.get("prompt_tool_telemetry_summary")
4513
- has_explicit_prompt_summary = progress.get("timeout_progress_summary_source") == "explicit" and isinstance(
4514
- explicit_prompt_summary, dict
4515
- )
4516
- if has_explicit_prompt_summary and any(
4517
- self._coerce_progress_counter(explicit_prompt_summary.get(key)) > 0
4518
- for key in _TIMEOUT_PROGRESS_COUNTER_KEYS
4519
- ):
4520
- return True
4521
-
4522
- explicit_prompt_payload = progress.get("prompt_tool_telemetry")
4523
- if (
4524
- bool(progress.get("timeout_progress_has_explicit_prompt_telemetry"))
4525
- and isinstance(explicit_prompt_payload, dict)
4526
- and any(
4527
- self._coerce_progress_counter(explicit_prompt_payload.get(key)) > 0
4528
- for key in (
4529
- "event_tool_calls_completed",
4530
- "event_skill_tool_calls",
4531
- "event_skill_execution_tool_calls",
4532
- "event_skill_effective_tool_calls",
4533
- "event_skill_execution_effective_tool_calls",
4534
- )
4535
- )
4536
- ):
4537
- return True
4538
-
4539
- explicit_skill_preview = progress.get("skill_policy_preview")
4540
- if (
4541
- bool(progress.get("timeout_progress_has_explicit_skill_preview"))
4542
- and isinstance(explicit_skill_preview, dict)
4543
- and any(
4544
- self._coerce_progress_counter(explicit_skill_preview.get(key)) > 0
4545
- for key in (
4546
- "observed_skill_calls",
4547
- "observed_skill_execution_calls",
4548
- "observed_skill_effective_calls",
4549
- )
4550
- )
4551
- ):
4552
- return True
4553
-
4554
- # Phase 130: when the operator explicitly granted additional retry
4555
- # budget but the tool loop already reports a completed snapshot,
4556
- # finalize as grounded FAIL instead of a generic ERROR.
4557
- return max(0, int(self.config.row_timeout_progress_retry_attempts)) > 1
4558
-
4559
- return True
4560
-
4561
- @staticmethod
4562
- def _derive_timeout_kind(
4563
- *,
4564
- progress: dict[str, Any] | None,
4565
- degraded_timeout_finalize: bool,
4566
- batch_timeout_exceeded: bool = False,
4567
- absolute_timeout_exceeded: bool = False,
4568
- ) -> str:
4569
- if degraded_timeout_finalize:
4570
- return TimeoutKind.TIMEOUT_WITH_GROUNDING.value
4571
- if not isinstance(progress, dict):
4572
- return TimeoutKind.TIMEOUT_NO_PROGRESS.value
4573
- termination_reason = str(progress.get("termination_reason") or "").strip().lower()
4574
- if batch_timeout_exceeded:
4575
- return TimeoutKind.TIMEOUT_ABSOLUTE_CAP.value
4576
- if absolute_timeout_exceeded:
4577
- return TimeoutKind.TIMEOUT_ABSOLUTE_CAP.value
4578
- if termination_reason in {"idle_after_tool", "post_tool_idle", "idle_post_tool"}:
4579
- return TimeoutKind.TIMEOUT_IDLE_AFTER_TOOL.value
4580
- if termination_reason in {"tool_churn", "agent_tool_churn", "churn", "stagnation"}:
4581
- return TimeoutKind.TIMEOUT_CHURN_DETECTED.value
4582
- if termination_reason in {"provider_stall", "stream_stall"}:
4583
- return TimeoutKind.TIMEOUT_PROVIDER_STALL.value
4584
- return TimeoutKind.TIMEOUT_NO_PROGRESS.value
4585
-
4586
- @staticmethod
4587
- def _build_timeout_fallback_verification_index(progress: dict[str, Any] | None) -> dict[str, dict[str, Any]]:
4588
- if not isinstance(progress, dict):
4589
- return {}
4590
- raw_payload = progress.get("evidence_ref_verifications")
4591
- verification_index: dict[str, dict[str, Any]] = {}
4592
- if isinstance(raw_payload, dict):
4593
- for key, value in raw_payload.items():
4594
- ref_value = str(key or "").strip()
4595
- if not ref_value:
4596
- continue
4597
- verification_index[ref_value] = value if isinstance(value, dict) else {"verified": bool(value)}
4598
- return verification_index
4599
- if not isinstance(raw_payload, list):
4600
- return {}
4601
- for entry in raw_payload:
4602
- if not isinstance(entry, dict):
4603
- continue
4604
- ref_value = str(entry.get("ref_value") or entry.get("ref") or entry.get("evidence_ref") or "").strip()
4605
- if not ref_value:
4606
- continue
4607
- verification_index[ref_value] = dict(entry)
4608
- return verification_index
4609
-
4610
- def _create_timeout_result(
4611
- self,
4612
- row_id: str,
4613
- check_id: str,
4614
- message: str,
4615
- *,
4616
- degraded_timeout_finalize: bool = False,
4617
- progress: dict[str, Any] | None = None,
4618
- ) -> RowEvaluationResult:
4619
- """Create timeout result (ERROR default, degraded FAIL when grounded progress exists)."""
4620
- degraded = bool(degraded_timeout_finalize)
4621
- evidence_anchors: list[EvidenceAnchor] = []
4622
- if degraded and isinstance(progress, dict):
4623
- verification_index = self._build_timeout_fallback_verification_index(progress)
4624
- raw_refs = progress.get("evidence_refs")
4625
- if isinstance(raw_refs, list):
4626
- for ref in raw_refs[:20]:
4627
- ref_value = str(ref or "").strip()
4628
- if not ref_value:
4629
- continue
4630
- verification_payload = verification_index.get(ref_value, {})
4631
- excerpt = str(verification_payload.get("excerpt") or "").strip()
4632
- verified = bool(verification_payload.get("verified")) and bool(excerpt)
4633
- verification_reason = VERIFICATION_REASON_FALLBACK_REF_INHERITED
4634
- if verified:
4635
- raw_reason = str(verification_payload.get("verification_reason") or "").strip()
4636
- verification_reason = normalize_verification_reason(
4637
- raw_reason or VERIFICATION_REASON_EXCERPT_VERIFIED_IN_CONTEXT,
4638
- verified=True,
4639
- excerpt=excerpt,
4640
- )
4641
- evidence_anchors.append(
4642
- EvidenceAnchor(
4643
- ref_type=(
4644
- "url"
4645
- if "://" in ref_value
4646
- else "config"
4647
- if RowEvaluator._is_config_ref_value(ref_value)
4648
- else "doc_path"
4649
- ),
4650
- ref_value=ref_value,
4651
- excerpt=excerpt if verified else "",
4652
- verified=verified,
4653
- verification_reason=verification_reason,
4654
- )
4655
- )
4656
- return RowEvaluationResult(
4657
- row_id=row_id,
4658
- check_id=check_id,
4659
- status=RowStatus.FAIL if degraded else RowStatus.ERROR,
4660
- score=0.0,
4661
- score_breakdown=ScoreBreakdown.compute(0.0),
4662
- reason=(
4663
- "Đánh giá kết thúc suy giảm sau timeout có tiến triển hiệu quả." if degraded else "Đánh giá bị timeout."
4664
- ),
4665
- reasoning="",
4666
- finding=(
4667
- "Có tín hiệu grounding tối thiểu trước timeout; trả về kết quả FAIL suy giảm."
4668
- if degraded
4669
- else "Không thể hoàn thành đánh giá do timeout."
4670
- ),
4671
- evidence_anchors=evidence_anchors,
4672
- provenance=RowProvenance(
4673
- row_llm_mode=self.evaluator.config.mode.value,
4674
- protocol=None,
4675
- model=None,
4676
- template_hash=self.evaluator.template_hash,
4677
- rubric_version="",
4678
- evidence_hash=self.evaluator.evidence_hash or "",
4679
- evaluated_at=datetime.now(UTC),
4680
- cache_hit=False,
4681
- ),
4682
- error_message=message,
4683
- )
4684
-
4685
- def _get_checkpoint_path(self, thread_id: str) -> Path:
4686
- """Get checkpoint file path."""
4687
- if self.config.checkpoint_dir:
4688
- return self.config.checkpoint_dir / f"batch-checkpoint-{thread_id}.json"
4689
- return Path(f"/tmp/vds-audit-checkpoint-{thread_id}.json")
4690
-
4691
- def get_checkpoint_path(self, thread_id: str) -> Path:
4692
- """Return the checkpoint file path for a given thread ID (FR-278).
4693
-
4694
- Public accessor for callers that need to bind checkpoint location
4695
- into workflow-summary.json and run-history.json entries.
4696
- """
4697
- return self._get_checkpoint_path(thread_id)
4698
-
4699
- @staticmethod
4700
- def _extract_prompt_level_telemetry(result: Any) -> dict[str, int]:
4701
- """Phase 166: Extract prompt-level retry/failover counts from a row result."""
4702
- counts: dict[str, int] = {
4703
- "prompt_retry_attempts": 0,
4704
- "prompt_retry_recoveries": 0,
4705
- "prompt_failover_attempts": 0,
4706
- "prompt_failover_recoveries": 0,
4707
- "prompt_failover_exhausted": 0,
4708
- "synthesis_fallback_count": 0,
4709
- }
4710
- if result is None:
4711
- return counts
4712
- provenance = getattr(result, "provenance", None) or {}
4713
- if isinstance(provenance, dict):
4714
- retry_meta = provenance.get("retry_metadata") or {}
4715
- if isinstance(retry_meta, dict):
4716
- provider_retry = retry_meta.get("provider_retry") or {}
4717
- if isinstance(provider_retry, dict):
4718
- counts["prompt_retry_attempts"] += max(0, int(provider_retry.get("attempts_executed", 0) or 0))
4719
- if provider_retry.get("recovered"):
4720
- counts["prompt_retry_recoveries"] += 1
4721
- failover_tel = retry_meta.get("prompt_failover_telemetry") or {}
4722
- if isinstance(failover_tel, dict) and failover_tel.get("provider_failover_attempted"):
4723
- counts["prompt_failover_attempts"] += 1
4724
- timeout_kind = str(failover_tel.get("timeout_kind") or "")
4725
- if timeout_kind == "timeout_failover_exhausted":
4726
- counts["prompt_failover_exhausted"] += 1
4727
- elif failover_tel.get("provider_failover_final_provider"):
4728
- counts["prompt_failover_recoveries"] += 1
4729
- # Check for synthesis fallback
4730
- fallback_cause = retry_meta.get("fallback_cause") or provenance.get("fallback_cause")
4731
- if fallback_cause:
4732
- counts["synthesis_fallback_count"] += 1
4733
- return counts
4734
-
4735
-
4736
- class PostProcessingConsumer:
4737
- """Incremental row result consumer for streaming post-processing (FR-193).
4738
-
4739
- Consumes ``RowEvaluationResult`` items from an asyncio queue as they arrive,
4740
- accumulating partial scores and computing overlap timing diagnostics. A
4741
- ``None`` sentinel signals the end of the stream.
4742
- """
4743
-
4744
- def __init__(self) -> None:
4745
- self._queue: asyncio.Queue[RowEvaluationResult | None] = asyncio.Queue()
4746
- self._partial_scores: list[float] = []
4747
- self._processed_count: int = 0
4748
- self._start_time: float = 0.0
4749
- self._overlap_seconds: float = 0.0
4750
-
4751
- async def put(self, result: RowEvaluationResult) -> None:
4752
- """Enqueue a completed row result for incremental processing."""
4753
- await self._queue.put(result)
4754
-
4755
- async def finalize(self) -> None:
4756
- """Signal end-of-stream by enqueuing a ``None`` sentinel."""
4757
- await self._queue.put(None)
4758
-
4759
- async def consume(self) -> dict[str, Any]:
4760
- """Consume results until sentinel, return timing diagnostics."""
4761
- import time
4762
-
4763
- self._start_time = time.monotonic()
4764
- while True:
4765
- item = await self._queue.get()
4766
- if item is None:
4767
- break
4768
- self._processed_count += 1
4769
- self._partial_scores.append(item.score)
4770
- end_time = time.monotonic()
4771
- self._overlap_seconds = end_time - self._start_time if self._start_time else 0.0
4772
- return {
4773
- "overlap_seconds": self._overlap_seconds,
4774
- "processed_count": self._processed_count,
4775
- "partial_scores": list(self._partial_scores),
4776
- }