@ngocsangairvds/vsaf 3.2.14 → 3.2.16
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.
- package/bin/vsaf.js +18 -4
- package/package.json +1 -1
- package/src/config.js +167 -0
- package/src/global.js +1 -48
- package/src/project.js +1 -0
- package/src/utils.js +44 -1
- package/tools/vds-scripts/Makefile +9 -31
- package/tools/vds-scripts/docker/docker-compose.cli.yml +1 -117
- package/tools/vds-scripts/docker/docker-compose.services.yml +1 -40
- package/tools/vds-scripts/docker/infrastructure/init-schemas.sql +0 -34
- package/tools/vds-scripts/docker/infrastructure/pgbouncer/pgbouncer.ini +2 -6
- package/tools/vds-scripts/pyproject.toml +1 -33
- package/tools/vds-scripts/uv.lock +80 -1651
- package/tools/vds-scripts/vds_cli/pyproject.toml +3 -0
- package/tools/vds-scripts/vds_cli/src/vds_cli/cli.py +1 -127
- package/tools/vds-scripts/vds_cli/src/vds_cli/commands/lint_cli.py +1 -20
- package/tools/vds-scripts/vds_cli/src/vds_cli/router.py +0 -100
- package/tools/vds-scripts/vds_cli/tests/conftest.py +0 -2
- package/tools/vds-scripts/vds_cli/tests/unit/test_cli.py +0 -25
- package/tools/vds-scripts/vds_cli/tests/unit/test_lint_cli.py +2 -2
- package/tools/vds-scripts/vds_cli/tests/unit/test_router.py +0 -2
- package/tools/vds-scripts/CLOSURE.md +0 -340
- package/tools/vds-scripts/ECOSYSTEM-CHANGELOG.md +0 -52
- package/tools/vds-scripts/ECOSYSTEM-DOCS.md +0 -602
- package/tools/vds-scripts/ECOSYSTEM_ALIGNMENT.md +0 -133
- package/tools/vds-scripts/ENV-HYGIENE-OPS-NOTE.md +0 -65
- package/tools/vds-scripts/INVESTIGATION-cloud-401.md +0 -103
- package/tools/vds-scripts/MEM0_2.0_API_REFERENCE.md +0 -238
- package/tools/vds-scripts/PACKAGE_P125B_IMPLEMENTATION_SUMMARY.md +0 -131
- package/tools/vds-scripts/PHASE-MERGE-SUMMARY.md +0 -121
- package/tools/vds-scripts/PHASES-3-ARCHIVE.md +0 -59
- package/tools/vds-scripts/PROJECT_COMPLETION_SUMMARY.md +0 -45
- package/tools/vds-scripts/SEARCH-CRASH-REPRO.md +0 -51
- package/tools/vds-scripts/analyze_hexagonal.py +0 -217
- package/tools/vds-scripts/analyze_profiles.py +0 -60
- package/tools/vds-scripts/audit-checklist.xlsx +0 -0
- package/tools/vds-scripts/audit_orchestrator/.audit_approvals/approvals_index.json +0 -1
- package/tools/vds-scripts/audit_orchestrator/.env.example +0 -85
- package/tools/vds-scripts/audit_orchestrator/.github/workflows/audit.yml +0 -47
- package/tools/vds-scripts/audit_orchestrator/Dockerfile +0 -92
- package/tools/vds-scripts/audit_orchestrator/GOOGLE_SHEETS_IMPLEMENTATION_SUMMARY.md +0 -218
- package/tools/vds-scripts/audit_orchestrator/PHASE3_INTEGRATION_SUMMARY.md +0 -268
- package/tools/vds-scripts/audit_orchestrator/PHASE7-MERGE-SUMMARY.md +0 -174
- package/tools/vds-scripts/audit_orchestrator/README.md +0 -1573
- package/tools/vds-scripts/audit_orchestrator/TSK-168-IMPLEMENTATION-SUMMARY.md +0 -191
- package/tools/vds-scripts/audit_orchestrator/TSK-196-IMPLEMENTATION-SUMMARY.md +0 -201
- package/tools/vds-scripts/audit_orchestrator/alembic/env.py +0 -37
- package/tools/vds-scripts/audit_orchestrator/alembic/script.py.mako +0 -28
- package/tools/vds-scripts/audit_orchestrator/alembic/versions/0001_initial_audit_state_schema.py +0 -1260
- package/tools/vds-scripts/audit_orchestrator/alembic.ini +0 -68
- package/tools/vds-scripts/audit_orchestrator/config/category-mapping.json +0 -81
- package/tools/vds-scripts/audit_orchestrator/config/profile-timeouts.yaml +0 -17
- package/tools/vds-scripts/audit_orchestrator/create_sample.py +0 -55
- package/tools/vds-scripts/audit_orchestrator/data/corpus_accuracy_report.json +0 -17
- package/tools/vds-scripts/audit_orchestrator/data/exemplar_quality_report.json +0 -1606
- package/tools/vds-scripts/audit_orchestrator/data/instruction_plan_fixtures.json +0 -163
- package/tools/vds-scripts/audit_orchestrator/data/requirement_exemplars.json +0 -3443
- package/tools/vds-scripts/audit_orchestrator/data/requirement_scope_fixtures.json +0 -172
- package/tools/vds-scripts/audit_orchestrator/debug_rg.py +0 -46
- package/tools/vds-scripts/audit_orchestrator/demo_code_pack.py +0 -127
- package/tools/vds-scripts/audit_orchestrator/docs/AGENT_SDK_SELECTION_SPEC.md +0 -720
- package/tools/vds-scripts/audit_orchestrator/docs/API.md +0 -804
- package/tools/vds-scripts/audit_orchestrator/docs/CONTENT_ANALYSIS_APPROACH.md +0 -1041
- package/tools/vds-scripts/audit_orchestrator/docs/CONTENT_SCORING_EVOLUTION_SPEC.md +0 -868
- package/tools/vds-scripts/audit_orchestrator/docs/DEPLOYMENT.md +0 -778
- package/tools/vds-scripts/audit_orchestrator/docs/LLM_AGENT_AUDIT_SPEC.md +0 -721
- package/tools/vds-scripts/audit_orchestrator/docs/LLM_CONTENT_ANALYSIS_SPEC.md +0 -1143
- package/tools/vds-scripts/audit_orchestrator/docs/LSP_SETUP_GUIDE.md +0 -221
- package/tools/vds-scripts/audit_orchestrator/docs/MULTI_REPO_AUDIT_SPEC.md +0 -951
- package/tools/vds-scripts/audit_orchestrator/docs/OLLAMA_EMBEDDINGS_SETUP.md +0 -119
- package/tools/vds-scripts/audit_orchestrator/docs/PHASE32_REAL_BENCHMARK_2026-02-08.md +0 -66
- package/tools/vds-scripts/audit_orchestrator/docs/PHASE_64_TO_92_HISTORICAL_SPEC.md +0 -1772
- package/tools/vds-scripts/audit_orchestrator/docs/TSK-193-flow-trace.md +0 -201
- package/tools/vds-scripts/audit_orchestrator/docs/TSK-193-verification.md +0 -124
- package/tools/vds-scripts/audit_orchestrator/docs/phase152-hierarchical-query-surface.md +0 -46
- package/tools/vds-scripts/audit_orchestrator/examples/bitbucket_metadata_example.json +0 -50
- package/tools/vds-scripts/audit_orchestrator/legacy/migrations/README.md +0 -68
- package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase117_phase118_shared_state.sql +0 -64
- package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase154_published_pages.sql +0 -28
- package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase157_dispatch_tables.sql +0 -94
- package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase157_events.sql +0 -91
- package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase157_scope_snapshots.sql +0 -24
- package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase157_status_view.sql +0 -22
- package/tools/vds-scripts/audit_orchestrator/legacy/migrations/phase169_dispatch_observability.sql +0 -55
- package/tools/vds-scripts/audit_orchestrator/legacy/migrations/state_repair_hardening.sql +0 -24
- package/tools/vds-scripts/audit_orchestrator/pyproject.toml +0 -211
- package/tools/vds-scripts/audit_orchestrator/pyrightconfig.json +0 -51
- package/tools/vds-scripts/audit_orchestrator/pytest.ini +0 -37
- package/tools/vds-scripts/audit_orchestrator/reproduce_scanner.py +0 -40
- package/tools/vds-scripts/audit_orchestrator/scripts/README.md +0 -116
- package/tools/vds-scripts/audit_orchestrator/scripts/benchmark_crawl_modes.py +0 -455
- package/tools/vds-scripts/audit_orchestrator/scripts/benchmark_dspy.py +0 -513
- package/tools/vds-scripts/audit_orchestrator/scripts/benchmark_nlp_accuracy.py +0 -138
- package/tools/vds-scripts/audit_orchestrator/scripts/benchmark_retrieval_modes.py +0 -176
- package/tools/vds-scripts/audit_orchestrator/scripts/benchmark_upload_update_mode.py +0 -167
- package/tools/vds-scripts/audit_orchestrator/scripts/build_check.py +0 -76
- package/tools/vds-scripts/audit_orchestrator/scripts/check_live_progress.py +0 -61
- package/tools/vds-scripts/audit_orchestrator/scripts/cli_integration_test.py +0 -400
- package/tools/vds-scripts/audit_orchestrator/scripts/index_workspace.py +0 -178
- package/tools/vds-scripts/audit_orchestrator/scripts/inspect_route_conformance.py +0 -196
- package/tools/vds-scripts/audit_orchestrator/scripts/monitor_postgres.py +0 -145
- package/tools/vds-scripts/audit_orchestrator/scripts/optimize_audit.py +0 -462
- package/tools/vds-scripts/audit_orchestrator/scripts/verify.py +0 -673
- package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase111_requirement_analysis.py +0 -375
- package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase117_cross_repo_evidence.py +0 -77
- package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase121_short_circuit.py +0 -680
- package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase122_instruction_handling.py +0 -478
- package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase125_skill_integration.py +0 -832
- package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase_36.py +0 -394
- package/tools/vds-scripts/audit_orchestrator/scripts/verify_phase_37.py +0 -58
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/__init__.py +0 -17
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/__init__.py +0 -29
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/_langchain_warnings.py +0 -17
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/agentic_investigator.py +0 -4130
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/approval.py +0 -490
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/audit_loop_hooks.py +0 -107
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/audit_state.py +0 -50
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/base.py +0 -4035
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/code_agent.py +0 -667
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/code_analysis_helpers.py +0 -236
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/code_analysis_prompts.py +0 -146
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/docs_agent.py +0 -1234
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/langgraph_workflow.py +0 -2002
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/pydantic_base.py +0 -1227
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/requirement_analysis_agent.py +0 -593
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/security_agent.py +0 -1829
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/security_scanner.py +0 -686
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/skill_tools.py +0 -204
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/synthesis_agent.py +0 -1463
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/tool_efficiency_guard.py +0 -609
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/tool_registry.py +0 -3822
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/__init__.py +0 -52
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/evidence_corpus.py +0 -385
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/filesystem.py +0 -1134
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/lsp.py +0 -458
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/mcp_toolset.py +0 -491
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/skills_toolset.py +0 -997
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/toolsets/vector_evidence.py +0 -842
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/usage_tracker.py +0 -682
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/agents/visualization.py +0 -303
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/analyze_cmds.py +0 -892
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checklist_query/__init__.py +0 -15
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checklist_query/service.py +0 -171
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/__init__.py +0 -20
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/base.py +0 -60
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/bitbucket/__init__.py +0 -6
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/bitbucket/checks.py +0 -257
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/confluence/__init__.py +0 -10
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/confluence/checks.py +0 -78
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/git/__init__.py +0 -6
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/git/file_checks.py +0 -133
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/llm_checks/__init__.py +0 -17
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/llm_checks/api_docs_check.py +0 -80
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/llm_checks/readme_check.py +0 -76
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/llm_checks/security_docs_check.py +0 -78
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/registry.py +0 -402
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/sonarqube/__init__.py +0 -10
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/checks/sonarqube/checks.py +0 -276
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/cli.py +0 -12
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/cli_common.py +0 -128
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/cli_impl.py +0 -9826
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/clients/bitbucket_cli_client.py +0 -187
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/clients/confluence_cli_client.py +0 -977
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/clients/sonarqube_cli_client.py +0 -28
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/__init__.py +0 -21
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/base.py +0 -25
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/bitbucket_downloader.py +0 -644
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/bitbucket_metadata.py +0 -133
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/checklist_parser.py +0 -180
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/completeness/__init__.py +0 -31
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/completeness/bitbucket_probe.py +0 -443
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/completeness/confluence_probe.py +0 -365
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/completeness/freshness_evaluator.py +0 -330
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/completeness/material_completeness_service.py +0 -1079
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/confluence_collector.py +0 -259
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/diagram_extractor.py +0 -280
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/enrichment_extractor.py +0 -200
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/evidence_cache.py +0 -35
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/git_collector.py +0 -148
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/graphify_collector.py +0 -171
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/image_extractor.py +0 -359
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/linked_page_tracker.py +0 -120
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/markdown_converter.py +0 -344
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/material_cache.py +0 -1252
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/material_downloader.py +0 -1165
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/orchestrator.py +0 -168
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/registry_parser.py +0 -3063
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/requirements.py +0 -70
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/runner.py +0 -119
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/collectors/sonarqube_collector.py +0 -113
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config.py +0 -1943
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/__init__.py +0 -23
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/discovery.py +0 -90
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/environment_resolver.py +0 -56
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/evidence.py +0 -78
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/models.py +0 -73
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/precedence.py +0 -10
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/config_resolution/redaction.py +0 -20
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/confluence_connectivity.py +0 -140
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/corpus_cmds.py +0 -278
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/db/__init__.py +0 -7
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/db/alembic_filters.py +0 -57
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/docs/__init__.py +0 -29
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/docs/diataxis_validator.py +0 -687
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/doctor_cmds.py +0 -3295
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/dspy_modules/__init__.py +0 -5
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/dspy_modules/evaluation.py +0 -301
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/dspy_modules/modules.py +0 -172
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/dspy_modules/runtime.py +0 -836
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/dspy_modules/signatures.py +0 -406
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/__init__.py +0 -192
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/ad_hoc_analyzer.py +0 -399
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/aggregator.py +0 -220
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/auditor.py +0 -504
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/batch_evidence_cache.py +0 -111
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/batch_processor.py +0 -4776
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/calibration.py +0 -217
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/checklist_generator.py +0 -1201
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/checklist_projection.py +0 -192
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/checklist_scoping.py +0 -221
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/checkpoint.py +0 -159
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/cl003_shared_lib_guard.py +0 -194
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/companion_context_service.py +0 -445
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/confluence_checklist_contract.py +0 -7425
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/cross_check_rules.py +0 -213
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/deterministic_evaluator.py +0 -237
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/drift_detector.py +0 -157
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/dspy_requirement_classifier.py +0 -640
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/evidence_assembler.py +0 -407
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/evidence_collector.py +0 -119
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/evidence_diversity.py +0 -101
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/gap_analyzer.py +0 -549
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/graduated.py +0 -185
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/grounding_validator.py +0 -287
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/instruction_analyzer.py +0 -882
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/instruction_compliance.py +0 -172
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/llm_row_evaluator.py +0 -9270
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/loader.py +0 -1070
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/manual_check_config.py +0 -136
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/mapping.py +0 -269
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/multi_judge.py +0 -65
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/phase120_checklist_update.py +0 -416
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/profile_scorer.py +0 -427
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/project_evidence_context.py +0 -449
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/project_knowledge_query_service.py +0 -155
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/project_knowledge_store.py +0 -383
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/project_topology.py +0 -1920
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/provider_failure_classifier.py +0 -778
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/readiness_cli_helpers.py +0 -341
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/readiness_extractor.py +0 -303
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/readiness_synthesizer.py +0 -730
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/regression_guard.py +0 -138
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/repo_type_classifier.py +0 -297
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/requirement_analysis.py +0 -1433
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/requirement_classification.py +0 -1725
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/result_merger.py +0 -814
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/route_matrix.py +0 -267
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/row_evaluator.py +0 -9437
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/row_evaluator_runtime.py +0 -1270
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/row_evaluator_types.py +0 -2102
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/rubric.py +0 -592
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/scorer.py +0 -1239
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/section_packs.py +0 -645
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/skill_recommendation.py +0 -1183
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/stability_harness.py +0 -207
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/target_selector.py +0 -841
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/telemetry.py +0 -347
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/template_analyzer.py +0 -469
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/token_tracker.py +0 -111
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/tool_first_planner.py +0 -7905
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/topology_query_service.py +0 -80
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/validator.py +0 -449
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/engine/weight_policy.py +0 -464
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/errors.py +0 -430
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/extract_cmds.py +0 -4887
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/identity.py +0 -146
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/incremental/__init__.py +0 -52
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/incremental/baseline.py +0 -378
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/incremental/change_analyzer.py +0 -407
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/incremental/delta_report.py +0 -189
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/incremental/diff_detector.py +0 -301
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/integrations/__init__.py +0 -3
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/__init__.py +0 -50
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/audit_schemas.py +0 -459
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/codex_oauth.py +0 -340
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/cost_tracker.py +0 -288
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/engine.py +0 -751
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/evaluator.py +0 -245
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/__init__.py +0 -32
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/api_docs_evaluation.py +0 -25
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/gap_analysis.py +0 -31
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/instruction_templates.py +0 -634
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/readme_evaluation.py +0 -25
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/row_evaluation.py +0 -247
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/security_docs_evaluation.py +0 -25
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts/template_analysis.py +0 -25
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/prompts.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/llm/provider.py +0 -626
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/logging_config.py +0 -577
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/mappings/__init__.py +0 -58
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/mappings/default_checklist_mapping.json +0 -18
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/mappings/vietnamese_checklist_mapping.json +0 -38
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/misc_cmds.py +0 -4689
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/__init__.py +0 -153
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/calibration.py +0 -98
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/checklist.py +0 -921
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/completeness.py +0 -309
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/enrichment.py +0 -58
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/enums.py +0 -97
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/evidence.py +0 -351
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/findings.py +0 -381
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/gaps.py +0 -299
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/graph.py +0 -42
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/multi_judge.py +0 -50
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/readiness.py +0 -309
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/registry.py +0 -386
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/reporting.py +0 -32
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/task.py +0 -549
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/models/template.py +0 -477
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/observability/__init__.py +0 -31
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/observability/metrics.py +0 -404
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/parse_cmds.py +0 -608
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/pdf_cmds.py +0 -208
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/performance_gates.py +0 -224
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/phase151_projection.py +0 -84
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/profiles/__init__.py +0 -65
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/profiles/detection.py +0 -842
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/profiles/models.py +0 -474
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/__init__.py +0 -1
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/_confluence_macros.py +0 -145
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/_field_sanitizer.py +0 -25
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/_table_builder.py +0 -63
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/_vietnamese_templates.py +0 -103
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/bitbucket_link_resolver.py +0 -34
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/checklist_renderer.py +0 -483
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/confluence_publisher.py +0 -3048
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/hierarchy_publisher.py +0 -213
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/live_data_injector.py +0 -152
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/macro_builder.py +0 -101
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/markdown_converter.py +0 -154
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/priority_renderer.py +0 -133
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/project_aggregate_renderer.py +0 -423
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/readiness_renderer.py +0 -186
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/system_doc_hierarchy_renderer.py +0 -382
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/publishers/system_doc_renderer.py +0 -683
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/report_cmds.py +0 -788
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/__init__.py +0 -13
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/aggregation_report.py +0 -86
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/checklist_generator.py +0 -425
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/excel_generator.py +0 -599
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/gap_report.py +0 -131
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/json_generator.py +0 -188
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/markdown_generator.py +0 -595
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/__init__.py +0 -154
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/collector.py +0 -61
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/department_builder.py +0 -77
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/errors.py +0 -9
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/md_renderer.py +0 -386
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/pdf_models.py +0 -95
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/pdf_writer.py +0 -27
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/pdf/repo_project_builders.py +0 -274
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/readiness_report.py +0 -447
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/reporting.py +0 -94
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/reports/sarif_generator.py +0 -519
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/runtime_profiles.py +0 -98
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/seed/__init__.py +0 -29
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/seed/seed_loader.py +0 -561
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/skills/__init__.py +0 -5
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/skills/skill_routing.py +0 -312
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/base.py +0 -110
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/bitbucket.py +0 -129
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/git_url.py +0 -60
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/github.py +0 -75
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sources/local.py +0 -58
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/spec_sync_validator.py +0 -15
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/state/__init__.py +0 -6285
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/state/readiness_helpers.py +0 -74
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/state/skill_readiness.py +0 -487
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/state/store.py +0 -12927
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/state_cmds.py +0 -1868
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sync/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sync/repo_sync.py +0 -409
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/sync_cmds.py +0 -1247
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/utils/__init__.py +0 -3
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/utils/debug_bundle.py +0 -214
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/validators/checklist_validator.py +0 -342
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflow_cmds.py +0 -19147
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/__init__.py +0 -9
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/_test_audit_daily_batch.py +0 -192
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/audit_daily_batch.py +0 -308
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/audit_deep_monthly.py +0 -193
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/audit_drift_scan.py +0 -178
- package/tools/vds-scripts/audit_orchestrator/src/vds_audit_orchestrator/workflows/audit_security_daily.py +0 -183
- package/tools/vds-scripts/audit_orchestrator/templates/sample_audit_template.xlsx +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/_helpers.py +0 -32
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/completeness/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/completeness/test_bitbucket_probe.py +0 -403
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/completeness/test_confluence_probe.py +0 -423
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_bitbucket_downloader.py +0 -289
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_image_extractor.py +0 -260
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_markdown_converter.py +0 -57
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_material_cache.py +0 -197
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_material_downloader.py +0 -550
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_registry_parser.py +0 -3514
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_registry_parser_department_entry.py +0 -214
- package/tools/vds-scripts/audit_orchestrator/tests/collectors/test_registry_parser_flow.py +0 -200
- package/tools/vds-scripts/audit_orchestrator/tests/conftest.py +0 -988
- package/tools/vds-scripts/audit_orchestrator/tests/engine/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/engine/test_calibration.py +0 -48
- package/tools/vds-scripts/audit_orchestrator/tests/engine/test_confluence_checklist_phase22_helpers.py +0 -6065
- package/tools/vds-scripts/audit_orchestrator/tests/engine/test_multi_judge.py +0 -62
- package/tools/vds-scripts/audit_orchestrator/tests/engine/test_stability_harness.py +0 -61
- package/tools/vds-scripts/audit_orchestrator/tests/engine/test_structured_metadata.py +0 -419
- package/tools/vds-scripts/audit_orchestrator/tests/factories/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/factories/models.py +0 -534
- package/tools/vds-scripts/audit_orchestrator/tests/factories/templates.py +0 -241
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/diagrams/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/diagrams/compressed.drawio +0 -2
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/diagrams/mockup.bmpr +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/diagrams/simple.drawio +0 -26
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/bitbucket/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/bitbucket/branch_permissions_cli.json +0 -26
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/bitbucket/branch_permissions_direct.json +0 -24
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/bitbucket/repo_conditions_cli.json +0 -14
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/bitbucket/repo_conditions_direct.json +0 -12
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/confluence/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/confluence/page_cli.json +0 -7
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/confluence/page_direct.json +0 -7
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/confluence/search_cli.json +0 -11
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/confluence/search_direct.json +0 -7
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/sonarqube/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/sonarqube/quality_gate_cli.json +0 -12
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/golden/sonarqube/quality_gate_direct.json +0 -12
- package/tools/vds-scripts/audit_orchestrator/tests/fixtures/requirement_strategy_phase115.json +0 -118
- package/tools/vds-scripts/audit_orchestrator/tests/integration/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/integration/conftest.py +0 -107
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/expected_outcomes.md +0 -50
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/auth.py +0 -27
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/config.py +0 -16
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/db.py +0 -24
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/main.py +0 -18
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/src/__init__.py +0 -1
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_audit_repo/src/utils.py +0 -22
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_checklist_template.json +0 -110
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/code_evidence_pack.json +0 -40
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/manifest.json +0 -49
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/brd.md +0 -19
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/design.md +0 -32
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/security.md +0 -23
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/srs.md +0 -25
- package/tools/vds-scripts/audit_orchestrator/tests/integration/fixtures/mock_evidence/projects/mock-audit-project/test.md +0 -30
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_checkpoint_merge.py +0 -1371
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_decoupling_route_p149.py +0 -176
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_gap_analyzer_batch_p149.py +0 -151
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_hybrid_search.py +0 -799
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_mcp_integration.py +0 -741
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_merge_ranking_p149.py +0 -98
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_modality_mismatch_p149.py +0 -171
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_phase117_118_storage.py +0 -350
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_phase121_short_circuit.py +0 -732
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_phase18_workflow.py +0 -223
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_phase48_e2e_verification.py +0 -763
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_phase81_doc_anchor_regression.py +0 -252
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_provider_failure_finding_p149.py +0 -339
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_readiness_e2e.py +0 -430
- package/tools/vds-scripts/audit_orchestrator/tests/integration/test_refined_workflow.py +0 -1180
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/snapshots/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/snapshots/department_renderer.md +0 -24
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/snapshots/project_renderer.md +0 -8
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/snapshots/repo_renderer.md +0 -10
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_department_pdf.py +0 -112
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_e2e_pdf.py +0 -135
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_idempotency.py +0 -45
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_md_renderer.py +0 -46
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_pdf_cmds.py +0 -97
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_pdf_snapshot.py +0 -77
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_pdf_writer.py +0 -65
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_project_builder.py +0 -199
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_public_api.py +0 -135
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_repo_builder.py +0 -246
- package/tools/vds-scripts/audit_orchestrator/tests/pdf/test_workflow_pdf_flags.py +0 -36
- package/tools/vds-scripts/audit_orchestrator/tests/property/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/property/test_properties.py +0 -807
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_agent_error_compat.py +0 -38
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_agentic_skill_policy_skip.py +0 -234
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_base_event_stream_logging.py +0 -785
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_base_timeout_policy.py +0 -277
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_base_trace_payload_sanitization.py +0 -92
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_code_agent.py +0 -2311
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_code_agent_re_exports.py +0 -25
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_code_analysis_helpers.py +0 -94
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_create_audit_agent_reasoning_effort.py +0 -69
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_docs_agent.py +0 -2044
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_langgraph_workflow_efficiency_metrics.py +0 -71
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_output_validators.py +0 -317
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_phase41_toolsets.py +0 -6427
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_pydantic_ai_models.py +0 -1219
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_pydantic_base_url_resolution.py +0 -84
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_security_agent.py +0 -2069
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_skill_manager_focus.py +0 -439
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_synthesis_agent.py +0 -1195
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_tool_efficiency_guard_fr120.py +0 -683
- package/tools/vds-scripts/audit_orchestrator/tests/test_agents/test_toolsets.py +0 -716
- package/tools/vds-scripts/audit_orchestrator/tests/test_aggregator_p149.py +0 -171
- package/tools/vds-scripts/audit_orchestrator/tests/test_alembic_migrations.py +0 -287
- package/tools/vds-scripts/audit_orchestrator/tests/test_anchor_allowlist_p149.py +0 -273
- package/tools/vds-scripts/audit_orchestrator/tests/test_audit_otel.py +0 -283
- package/tools/vds-scripts/audit_orchestrator/tests/test_checklist_models.py +0 -583
- package/tools/vds-scripts/audit_orchestrator/tests/test_checks/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_checks/test_base_check.py +0 -211
- package/tools/vds-scripts/audit_orchestrator/tests/test_checks/test_llm_checks.py +0 -126
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_analyze_command.py +0 -400
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_archive_stale_page_cli.py +0 -217
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_bitbucket_metadata_cli.py +0 -354
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_cli_impl_profile_availability.py +0 -114
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_codex_profile.py +0 -174
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_compare_backends_cli.py +0 -449
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_confluence_parent_auto_resolve.py +0 -451
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_corpus_purge_cli.py +0 -290
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_credentials_preflight.py +0 -106
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_debug_bundle.py +0 -37
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_deprecation_phase157.py +0 -484
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_dispatch_concurrency_diagnostics.py +0 -758
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_check_confluence_cli.py +0 -320
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_codex.py +0 -187
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_corpus_status_cli.py +0 -236
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_correlation_cli.py +0 -128
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_crawl_status_cli.py +0 -192
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_credentials_cli.py +0 -86
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_dispatch_status_cli.py +0 -421
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_heartbeat_phase169.py +0 -173
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_hierarchy_status_cli.py +0 -199
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_locks_cli.py +0 -134
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_logs_follow_cli.py +0 -305
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_migration.py +0 -333
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_profile_availability_cli.py +0 -151
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_doctor_skills_policy_cli.py +0 -153
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_evidence_quality_cli.py +0 -307
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_export_debug_bundle_phase36.py +0 -60
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_export_git_manifest_cli.py +0 -172
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_file_removal_phase157e.py +0 -770
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_grounding_classifier.py +0 -226
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_logging.py +0 -49
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_materials_cli.py +0 -9127
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_metadata_completeness_phase92.py +0 -364
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_parent_dispatch_finalization_phase168f.py +0 -111
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_parse_cli.py +0 -590
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_phase117_118_feature_flags.py +0 -219
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_phase164_control_plane.py +0 -718
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_phase165_runner_scripts.py +0 -230
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_preparation_classifications.py +0 -146
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_prepare_cli.py +0 -398
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_publication_quality_gate.py +0 -126
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_publish_system_doc_cli.py +0 -158
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_query_checklist_cli.py +0 -219
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_readiness_cli.py +0 -673
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_readiness_cli_integration.py +0 -689
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_removed_flags_phase92.py +0 -36
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_report_cmds.py +0 -1317
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_run_history_index.py +0 -57
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_run_management.py +0 -1194
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_runtime_profiles_cli.py +0 -1658
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_smart_run_selection.py +0 -1562
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_state_cli.py +0 -2467
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_state_migration.py +0 -339
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_sync_repos_debug_artifacts.py +0 -1109
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_upload_results_cli.py +0 -809
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_validate_checklist.py +0 -178
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_validate_checklist_cli.py +0 -110
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_validate_spec_sync_cli.py +0 -519
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_default_parameters_baseline.py +0 -101
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_options.py +0 -7896
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_project_db_modes.py +0 -6516
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_project_project_scope.py +0 -831
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_project_target.py +0 -611
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_projects_phase131_lifecycle.py +0 -2488
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_projects_phase131_scaffolding.py +0 -96
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_row_key_guard.py +0 -78
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli/test_workflow_summary_artifacts.py +0 -1872
- package/tools/vds-scripts/audit_orchestrator/tests/test_cli_paths_phase2.py +0 -45
- package/tools/vds-scripts/audit_orchestrator/tests/test_clients/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_clients/test_bitbucket_cli_client.py +0 -124
- package/tools/vds-scripts/audit_orchestrator/tests/test_clients/test_cli_parity.py +0 -110
- package/tools/vds-scripts/audit_orchestrator/tests/test_clients/test_confluence_cli_client.py +0 -1149
- package/tools/vds-scripts/audit_orchestrator/tests/test_clients/test_sonarqube_cli_client.py +0 -19
- package/tools/vds-scripts/audit_orchestrator/tests/test_collectors/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_collectors/test_linked_page_tracker.py +0 -118
- package/tools/vds-scripts/audit_orchestrator/tests/test_companion_context_service.py +0 -230
- package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/conftest.py +0 -11
- package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_compile_artifact.py +0 -465
- package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_cross_provider_critique.py +0 -120
- package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_cross_provider_critique_e2e.py +0 -75
- package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_evaluation.py +0 -515
- package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_runtime_loader.py +0 -537
- package/tools/vds-scripts/audit_orchestrator/tests/test_dspy_modules/test_signatures_normalization.py +0 -172
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_auditor_applicability.py +0 -68
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_checklist_generator.py +0 -1252
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_checklist_projection.py +0 -54
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_confluence_checklist_projection_consistency.py +0 -1696
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_critique_merger_matrix.py +0 -120
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_cross_check_rules.py +0 -459
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_cross_provider_critique.py +0 -55
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_doc_loader.py +0 -73
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_drift_detector.py +0 -34
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_evidence_collectors.py +0 -93
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_lease_timeout.py +0 -114
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_loader.py +0 -350
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_loader_parity.py +0 -179
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_low_confidence_reeval.py +0 -691
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_phase145a_completion.py +0 -209
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_phase31_row_consistency_retry_benchmark.py +0 -150
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_profile_detector.py +0 -286
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_regression_guard.py +0 -53
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_result_merger.py +0 -619
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_row_evaluator.py +0 -15783
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_row_failover.py +0 -215
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_scorer.py +0 -597
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_skill_breakdown_telemetry_fr137.py +0 -421
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_targeted_auto_merge.py +0 -229
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_timeout_failover.py +0 -488
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_timeout_telemetry.py +0 -73
- package/tools/vds-scripts/audit_orchestrator/tests/test_engine/test_validator.py +0 -419
- package/tools/vds-scripts/audit_orchestrator/tests/test_incremental/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_incremental/test_diff_detector.py +0 -111
- package/tools/vds-scripts/audit_orchestrator/tests/test_infra_persistence.py +0 -291
- package/tools/vds-scripts/audit_orchestrator/tests/test_integration/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_integration/test_phase3_integration.py +0 -516
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_cache.py +0 -670
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_codex_model_builder.py +0 -281
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_codex_oauth.py +0 -330
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_codex_streaming.py +0 -433
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_cost_tracker.py +0 -27
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_engine.py +0 -876
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_evaluator.py +0 -212
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_instruction_templates.py +0 -639
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_prompt_metadata.py +0 -97
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_prompts.py +0 -660
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_provider.py +0 -330
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_provider_contract_sync.py +0 -18
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_reasoning_effort_validation.py +0 -565
- package/tools/vds-scripts/audit_orchestrator/tests/test_llm/test_schemas.py +0 -827
- package/tools/vds-scripts/audit_orchestrator/tests/test_logging_config.py +0 -297
- package/tools/vds-scripts/audit_orchestrator/tests/test_models/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_models/test_enums.py +0 -185
- package/tools/vds-scripts/audit_orchestrator/tests/test_models/test_findings.py +0 -1159
- package/tools/vds-scripts/audit_orchestrator/tests/test_models/test_project_profile.py +0 -307
- package/tools/vds-scripts/audit_orchestrator/tests/test_models/test_registry.py +0 -532
- package/tools/vds-scripts/audit_orchestrator/tests/test_models/test_template.py +0 -708
- package/tools/vds-scripts/audit_orchestrator/tests/test_observability/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_observability/test_metrics.py +0 -60
- package/tools/vds-scripts/audit_orchestrator/tests/test_paths_config_phase2.py +0 -21
- package/tools/vds-scripts/audit_orchestrator/tests/test_performance/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_performance/test_fr79_performance_guardrails.py +0 -199
- package/tools/vds-scripts/audit_orchestrator/tests/test_phase156_hardening.py +0 -498
- package/tools/vds-scripts/audit_orchestrator/tests/test_phase93_regression_guards.py +0 -123
- package/tools/vds-scripts/audit_orchestrator/tests/test_pipeline_integration.py +0 -517
- package/tools/vds-scripts/audit_orchestrator/tests/test_profiles/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_profiles/test_detection.py +0 -146
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_bitbucket_link_resolver.py +0 -55
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_checklist_renderer.py +0 -84
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_checklist_renderer_projection.py +0 -97
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_confluence_macros.py +0 -58
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_confluence_publisher.py +0 -2171
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_evidence_links.py +0 -129
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_field_sanitizer.py +0 -108
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_hierarchy_publisher.py +0 -134
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_incremental_plan_parser.py +0 -62
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_live_data_injector.py +0 -48
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_macro_builder.py +0 -22
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_p161_confluence_optimization.py +0 -168
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_priority_renderer.py +0 -96
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_project_aggregate_renderer.py +0 -364
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_storage_validation.py +0 -273
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_summary_refactor.py +0 -118
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_system_doc_hierarchy.py +0 -50
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_table_builder.py +0 -23
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_vietnamese_templates.py +0 -37
- package/tools/vds-scripts/audit_orchestrator/tests/test_publishers/test_wiring_integration.py +0 -290
- package/tools/vds-scripts/audit_orchestrator/tests/test_reports/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_reports/test_aggregation_report.py +0 -181
- package/tools/vds-scripts/audit_orchestrator/tests/test_reports/test_checklist_generator.py +0 -258
- package/tools/vds-scripts/audit_orchestrator/tests/test_reports/test_gap_report.py +0 -73
- package/tools/vds-scripts/audit_orchestrator/tests/test_reports/test_json_generator.py +0 -317
- package/tools/vds-scripts/audit_orchestrator/tests/test_result_merger_p149.py +0 -347
- package/tools/vds-scripts/audit_orchestrator/tests/test_route_mode_p149.py +0 -178
- package/tools/vds-scripts/audit_orchestrator/tests/test_rubric_parser.py +0 -179
- package/tools/vds-scripts/audit_orchestrator/tests/test_scorer.py +0 -110
- package/tools/vds-scripts/audit_orchestrator/tests/test_state/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_state/test_sparse_coverage.py +0 -117
- package/tools/vds-scripts/audit_orchestrator/tests/test_workflow/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/test_workflow/test_langgraph_workflow.py +0 -2072
- package/tools/vds-scripts/audit_orchestrator/tests/test_workflow/test_p161_runtime_hardening.py +0 -341
- package/tools/vds-scripts/audit_orchestrator/tests/test_workflow_cmds_p149.py +0 -112
- package/tools/vds-scripts/audit_orchestrator/tests/test_workflow_cmds_p172.py +0 -126
- package/tools/vds-scripts/audit_orchestrator/tests/test_workflow_guidance_p150.py +0 -95
- package/tools/vds-scripts/audit_orchestrator/tests/unit/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_agentic_investigator_phase115.py +0 -42
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_requirement_analysis_agent.py +0 -412
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_security_agent_updates.py +0 -131
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_security_scanner.py +0 -397
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_skill_executor.py +0 -316
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_skill_fallback.py +0 -299
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_skill_policy.py +0 -520
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_skill_telemetry.py +0 -306
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_synthesis_fixes.py +0 -761
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_argument_robustness.py +0 -272
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_registry.py +0 -2548
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_registry_ast_grep.py +0 -87
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_registry_phase123_scoping.py +0 -353
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_registry_phase94_ff.py +0 -445
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_tool_registry_vector_search_phase115.py +0 -35
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_utils.py +0 -1007
- package/tools/vds-scripts/audit_orchestrator/tests/unit/agents/test_vector_evidence_toolset.py +0 -622
- package/tools/vds-scripts/audit_orchestrator/tests/unit/cli/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/cli/test_workflow_cli.py +0 -123
- package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/test_cache_guard.py +0 -479
- package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/test_checklist_parser_phase120.py +0 -55
- package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/test_diagram_extractor.py +0 -467
- package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/test_enrichment_extractor.py +0 -59
- package/tools/vds-scripts/audit_orchestrator/tests/unit/collectors/test_graphify_collector.py +0 -158
- package/tools/vds-scripts/audit_orchestrator/tests/unit/completeness/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/completeness/test_completeness.py +0 -563
- package/tools/vds-scripts/audit_orchestrator/tests/unit/completeness/test_freshness_evaluator.py +0 -493
- package/tools/vds-scripts/audit_orchestrator/tests/unit/completeness/test_material_cache_metrics.py +0 -365
- package/tools/vds-scripts/audit_orchestrator/tests/unit/completeness/test_material_completeness_service.py +0 -2736
- package/tools/vds-scripts/audit_orchestrator/tests/unit/config_resolution/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/config_resolution/test_discovery.py +0 -47
- package/tools/vds-scripts/audit_orchestrator/tests/unit/config_resolution/test_redaction.py +0 -15
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_ad_hoc_analyzer.py +0 -576
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_agent_loop.py +0 -1896
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_anchor_filter_cl003.py +0 -181
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_batch_evidence_cache.py +0 -155
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_batch_processor.py +0 -3608
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_checklist_contract.py +0 -55
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_checklist_scoping.py +0 -371
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_config_companion_phase123.py +0 -142
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_config_evidence_phase123.py +0 -249
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_confluence_checklist_contract_export_parity.py +0 -813
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_cross_repo_config_phase122.py +0 -613
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_dspy_requirement_classifier.py +0 -517
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_evidence_diversity.py +0 -144
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_evidence_truncation.py +0 -108
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_grounding_validator.py +0 -127
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_guidance_injection_phase120.py +0 -105
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_instruction_analysis_phase122.py +0 -761
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_instruction_pre_filter_phase167.py +0 -334
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_llm_row_evaluator_retries.py +0 -3684
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_loader_phase123.py +0 -345
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_manual_check_gating_phase122.py +0 -474
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_parallel_eval.py +0 -263
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_phase122_verifier_phase122.py +0 -169
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_phase166_route_failover.py +0 -437
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_post_eval_cl003_shared_lib.py +0 -267
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_postproc_streaming.py +0 -194
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_pre_eval_gating_phase122.py +0 -362
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_prepare_topology_coverage.py +0 -247
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_private_dns_sanitization_phase104.py +0 -397
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_project_evidence_context.py +0 -450
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_project_knowledge_store.py +0 -487
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_project_topology.py +0 -1142
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_provider_failure_classifier.py +0 -195
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_readiness_extractor.py +0 -496
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_readiness_synthesizer.py +0 -653
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_repo_type_classifier.py +0 -303
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_analysis.py +0 -508
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_analysis_execution_scope.py +0 -239
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_analysis_phase114.py +0 -919
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_analysis_phase115.py +0 -97
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_analysis_shared_lib.py +0 -340
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_classification_drift.py +0 -729
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_classification_nlp.py +0 -670
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_requirement_scope_phase122.py +0 -615
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_route_matrix.py +0 -258
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_route_override.py +0 -141
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_routing_precision.py +0 -650
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_row_evaluator_dual_evidence.py +0 -2987
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_row_evaluator_instruction_runtime_phase122.py +0 -365
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_row_evaluator_runtime.py +0 -830
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_runtime_hardening_phase122.py +0 -225
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_scoped_na_skip.py +0 -107
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_scoring_enhancements.py +0 -404
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_shared_library_retrieval_phase123.py +0 -441
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_shared_library_routing_phase123.py +0 -279
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_shared_resource_indexing_phase122.py +0 -188
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_skill_recommendation.py +0 -225
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_skill_routing_cl003_shared_lib.py +0 -338
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_skills_toolset.py +0 -319
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_stability_metric.py +0 -60
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_target_selector.py +0 -958
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_token_tracker.py +0 -121
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_token_wiring.py +0 -119
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_tool_first_planner.py +0 -7103
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_topology_knowledge_persistence.py +0 -332
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_topology_query_service.py +0 -55
- package/tools/vds-scripts/audit_orchestrator/tests/unit/engine/test_unverified_ref_retry.py +0 -909
- package/tools/vds-scripts/audit_orchestrator/tests/unit/models/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/models/test_evidence.py +0 -515
- package/tools/vds-scripts/audit_orchestrator/tests/unit/models/test_gaps.py +0 -422
- package/tools/vds-scripts/audit_orchestrator/tests/unit/models/test_readiness.py +0 -428
- package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_confluence_hierarchy.py +0 -227
- package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_project_title_generation.py +0 -335
- package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_publisher_registry_helpers.py +0 -290
- package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_publisher_registry_integration.py +0 -557
- package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_readiness_renderer.py +0 -381
- package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_repo_title_consistency.py +0 -266
- package/tools/vds-scripts/audit_orchestrator/tests/unit/publishers/test_upload_hierarchy_integration.py +0 -470
- package/tools/vds-scripts/audit_orchestrator/tests/unit/scripts/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/scripts/test_benchmark_dspy.py +0 -177
- package/tools/vds-scripts/audit_orchestrator/tests/unit/scripts/test_benchmark_nlp_accuracy.py +0 -72
- package/tools/vds-scripts/audit_orchestrator/tests/unit/scripts/test_benchmark_retrieval_modes.py +0 -123
- package/tools/vds-scripts/audit_orchestrator/tests/unit/scripts/test_verify_phase111_requirement_analysis.py +0 -409
- package/tools/vds-scripts/audit_orchestrator/tests/unit/seed/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/seed/test_seed_chain_cli.py +0 -277
- package/tools/vds-scripts/audit_orchestrator/tests/unit/seed/test_seed_loader.py +0 -502
- package/tools/vds-scripts/audit_orchestrator/tests/unit/skills/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/skills/test_skill_routing.py +0 -209
- package/tools/vds-scripts/audit_orchestrator/tests/unit/sources/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/sources/test_bitbucket_source.py +0 -66
- package/tools/vds-scripts/audit_orchestrator/tests/unit/sources/test_non_retryable_markers.py +0 -88
- package/tools/vds-scripts/audit_orchestrator/tests/unit/sources/test_repo_info.py +0 -212
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_completeness.py +0 -598
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_dispatch_events_contract_phase169.py +0 -100
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_dispatch_hardening_phase158.py +0 -392
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_dispatch_persistence_phase157.py +0 -914
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_embedding_client.py +0 -64
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_get_latest_completed_run.py +0 -313
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_heartbeat_phase169.py +0 -109
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_hybrid_search.py +0 -398
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_normalize_url.py +0 -262
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_phase152_query_surface.py +0 -59
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_phase98_confluence_document_model.py +0 -202
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_published_pages.py +0 -754
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_readiness_helpers.py +0 -193
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_run_ledger.py +0 -522
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_run_management.py +0 -378
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_schema_contract_phase170.py +0 -755
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_state_cmds.py +0 -231
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_state_loaders.py +0 -2151
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_state_run_api.py +0 -2226
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_store.py +0 -1435
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_store_dispatch.py +0 -646
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_store_dispatch_status_view.py +0 -181
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_store_scope.py +0 -213
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_utilization_persist_phase169.py +0 -77
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_vds_search.py +0 -263
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_vector_index_api.py +0 -319
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_vector_index_runtime.py +0 -175
- package/tools/vds-scripts/audit_orchestrator/tests/unit/state/test_vector_index_store.py +0 -1756
- package/tools/vds-scripts/audit_orchestrator/tests/unit/sync/__init__.py +0 -0
- package/tools/vds-scripts/audit_orchestrator/tests/unit/sync/test_repo_sync.py +0 -257
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_artifact_exclusion.py +0 -119
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_auto_promote_phase158.py +0 -337
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_carry_forward_artifact_filtering.py +0 -317
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_checklist_precache_p160a.py +0 -416
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_cli_decomposition_fr219.py +0 -269
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_code_chunk_carry_forward.py +0 -203
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_config_coherence.py +0 -180
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_config_secret_policy.py +0 -522
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_corpus_project_id_migration.py +0 -318
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_corpus_status_diagnostics.py +0 -239
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_department_priority_ordering.py +0 -131
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_dispatch_coordinator_phase158.py +0 -402
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_dispatch_job_identity_p167a.py +0 -238
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_dispatch_ramp_up_phase171.py +0 -434
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_dispatcher.py +0 -911
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_doc_type_en_inference.py +0 -246
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_early_exit_unchunked_repos.py +0 -111
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_errors.py +0 -237
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_errors_taxonomy.py +0 -83
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_extract_chunking_config_phase98.py +0 -73
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_extract_cmds_state_helpers.py +0 -33
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_extract_docs_code_chunking.py +0 -260
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_finalize_dispatch_run_phase168.py +0 -341
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_identity.py +0 -221
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_infrastructure_detection.py +0 -441
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_junction_table_phase95.py +0 -259
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_late_binding_assignment_p167c.py +0 -286
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_misc_cmds_fr224_225_hardening.py +0 -194
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_p172_integration.py +0 -306
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_parent_provider_preflight.py +0 -118
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_performance_gates_phase92.py +0 -141
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_performance_gates_phase93.py +0 -50
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase115_search_strategy.py +0 -106
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase154_title_consistency.py +0 -117
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase155_param_forwarding.py +0 -304
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase158_concurrency_defaults.py +0 -207
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase170_doctor_schema.py +0 -319
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase170_regression.py +0 -334
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase94_corpus_lifecycle.py +0 -307
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_phase96_repo_key_migration.py +0 -305
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_pipelined_scheduling.py +0 -130
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_profile_availability_probe.py +0 -616
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_profile_aware_row_timeout.py +0 -102
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_profile_timeout_stagger_p160cd.py +0 -205
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_progress_summary_phase169.py +0 -96
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_registry_checklist_diagnostics.py +0 -124
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_resume_manifest_p167b.py +0 -268
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_risk_mitigations_p160e1.py +0 -348
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_single_row_shards_p160b.py +0 -357
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_state_repo_discovery.py +0 -504
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_sync_metadata_entries.py +0 -57
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_task_models.py +0 -1796
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_utilization_telemetry_p167e.py +0 -259
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_vietnamese_fts_hardening.py +0 -160
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_workflow_phase98_enrichment.py +0 -92
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_workflow_project_merge_materialization.py +0 -322
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_workflow_row_key_migration_guard.py +0 -88
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_workflow_short_circuit_phase121.py +0 -564
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_workflow_single_target_row_context.py +0 -49
- package/tools/vds-scripts/audit_orchestrator/tests/unit/test_zero_result_messaging.py +0 -76
- package/tools/vds-scripts/bandit-report.json +0 -2974
- package/tools/vds-scripts/brd_orchestrator/README.md +0 -29
- package/tools/vds-scripts/brd_orchestrator/pyproject.toml +0 -63
- package/tools/vds-scripts/brd_orchestrator/src/vds_brd_orchestrator/__init__.py +0 -17
- package/tools/vds-scripts/brd_orchestrator/src/vds_brd_orchestrator/cli.py +0 -187
- package/tools/vds-scripts/brd_orchestrator/src/vds_brd_orchestrator/validator.py +0 -121
- package/tools/vds-scripts/brd_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/brd_orchestrator/tests/test_cli.py +0 -62
- package/tools/vds-scripts/brd_orchestrator/tests/test_validator.py +0 -33
- package/tools/vds-scripts/circular_dependency_orchestrator/README.md +0 -30
- package/tools/vds-scripts/circular_dependency_orchestrator/pyproject.toml +0 -43
- package/tools/vds-scripts/circular_dependency_orchestrator/src/vds_circular_dependency_orchestrator/__init__.py +0 -16
- package/tools/vds-scripts/circular_dependency_orchestrator/src/vds_circular_dependency_orchestrator/cli.py +0 -904
- package/tools/vds-scripts/circular_dependency_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/circular_dependency_orchestrator/tests/unit/__init__.py +0 -0
- package/tools/vds-scripts/circular_dependency_orchestrator/tests/unit/test_cli.py +0 -354
- package/tools/vds-scripts/coverage.json +0 -1
- package/tools/vds-scripts/create_pr.py +0 -57
- package/tools/vds-scripts/diagram_generator/README.md +0 -663
- package/tools/vds-scripts/diagram_generator/ci_validate.sh +0 -16
- package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-component.png +0 -0
- package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-component.puml +0 -23
- package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-sequence.png +0 -0
- package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-sequence.puml +0 -21
- package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-usecase.png +0 -0
- package/tools/vds-scripts/diagram_generator/docs-nttc/projects/INSURANCE/analysis/current-state/insurance-claim-business/insurance-claim-business-usecase.puml +0 -14
- package/tools/vds-scripts/diagram_generator/examples/github-actions-validate.yml +0 -39
- package/tools/vds-scripts/diagram_generator/generate_all_diagrams.py +0 -827
- package/tools/vds-scripts/diagram_generator/generate_insurance_c4_diagrams.py +0 -261
- package/tools/vds-scripts/diagram_generator/generate_insurance_c4_quick.py +0 -486
- package/tools/vds-scripts/diagram_generator/pyproject.toml +0 -28
- package/tools/vds-scripts/diagram_generator/render_png.py +0 -59
- package/tools/vds-scripts/diagram_generator/src/vds_diagram_generator/__init__.py +0 -3
- package/tools/vds-scripts/diagram_generator/src/vds_diagram_generator/cli.py +0 -50
- package/tools/vds-scripts/diagram_generator/test_c4_hierarchical.py +0 -142
- package/tools/vds-scripts/diagram_generator/test_c4_quick.py +0 -131
- package/tools/vds-scripts/diagram_generator/tests/__init__.py +0 -0
- package/tools/vds-scripts/diagram_generator/tests/test_analyzer_completeness.py +0 -260
- package/tools/vds-scripts/diagram_generator/tests/test_c4_syntax_correctness.py +0 -138
- package/tools/vds-scripts/diagram_generator/tests/test_component_coverage.py +0 -182
- package/tools/vds-scripts/diagram_generator/tests/test_mermaid_output.py +0 -80
- package/tools/vds-scripts/diagram_generator/tests/test_png_generation.py +0 -112
- package/tools/vds-scripts/diagram_generator/tests/test_scenario_templates.py +0 -15
- package/tools/vds-scripts/diagram_generator/tests/test_sequence_accuracy.py +0 -93
- package/tools/vds-scripts/diagram_generator/tests/test_structurizr_export.py +0 -177
- package/tools/vds-scripts/diagram_generator/tests/test_style_consistency.py +0 -174
- package/tools/vds-scripts/diagram_generator/tests/test_usecase_generator.py +0 -201
- package/tools/vds-scripts/diagram_generator/tests/test_usecase_integration.py +0 -124
- package/tools/vds-scripts/docker/compose.phase2-verification.yml +0 -31
- package/tools/vds-scripts/docker-compose.openapi-validator.yml +0 -14
- package/tools/vds-scripts/excel_orchestrator/README.md +0 -288
- package/tools/vds-scripts/excel_orchestrator/RESEARCH_BASED_UPDATES_REPORT.md +0 -261
- package/tools/vds-scripts/excel_orchestrator/add_essential_missing_effort.py +0 -255
- package/tools/vds-scripts/excel_orchestrator/adjust_effort_complexity.py +0 -184
- package/tools/vds-scripts/excel_orchestrator/brd_analysis_and_task_breakdown.py +0 -632
- package/tools/vds-scripts/excel_orchestrator/brd_analysis_comprehensive.py +0 -1029
- package/tools/vds-scripts/excel_orchestrator/check_overlaps_and_brd_coverage.py +0 -570
- package/tools/vds-scripts/excel_orchestrator/clean_remarks_column.py +0 -127
- package/tools/vds-scripts/excel_orchestrator/comprehensive_brd_check.py +0 -322
- package/tools/vds-scripts/excel_orchestrator/create_buffered_summary.py +0 -119
- package/tools/vds-scripts/excel_orchestrator/create_service_totals_sheet.py +0 -118
- package/tools/vds-scripts/excel_orchestrator/examples/basic_operations.py +0 -85
- package/tools/vds-scripts/excel_orchestrator/expand_all_tasks.py +0 -341
- package/tools/vds-scripts/excel_orchestrator/expand_tasks.py +0 -304
- package/tools/vds-scripts/excel_orchestrator/fill_brd_references.py +0 -347
- package/tools/vds-scripts/excel_orchestrator/fill_remarks_and_colors.py +0 -132
- package/tools/vds-scripts/excel_orchestrator/finalize_brd_and_cleanup.py +0 -295
- package/tools/vds-scripts/excel_orchestrator/finalize_brd_coverage.py +0 -327
- package/tools/vds-scripts/excel_orchestrator/fix_all_formulas.py +0 -99
- package/tools/vds-scripts/excel_orchestrator/fix_detail_presentation.py +0 -113
- package/tools/vds-scripts/excel_orchestrator/fix_presentation_and_effort.py +0 -116
- package/tools/vds-scripts/excel_orchestrator/fix_presentation_consistency.py +0 -231
- package/tools/vds-scripts/excel_orchestrator/fix_remarks_matching.py +0 -179
- package/tools/vds-scripts/excel_orchestrator/group_tasks_by_service_id.py +0 -210
- package/tools/vds-scripts/excel_orchestrator/increase_brd_coverage.py +0 -497
- package/tools/vds-scripts/excel_orchestrator/increase_effort_complexity.py +0 -155
- package/tools/vds-scripts/excel_orchestrator/organize_and_deduplicate.py +0 -273
- package/tools/vds-scripts/excel_orchestrator/pyproject.toml +0 -64
- package/tools/vds-scripts/excel_orchestrator/rebuild_all_formulas.py +0 -146
- package/tools/vds-scripts/excel_orchestrator/remove_base_multiplier_and_check_duplicates.py +0 -310
- package/tools/vds-scripts/excel_orchestrator/remove_duplicate_brd_tasks.py +0 -137
- package/tools/vds-scripts/excel_orchestrator/research_based_updates.py +0 -457
- package/tools/vds-scripts/excel_orchestrator/restore_e_values.py +0 -172
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/__init__.py +0 -5
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/cli.py +0 -746
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/config.py +0 -74
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/converters.py +0 -226
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/errors.py +0 -88
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/excel_client.py +0 -443
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/formatters.py +0 -211
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/logging.py +0 -57
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/source_contract.py +0 -29
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/target_state_status.py +0 -837
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/ulnc_alignment.py +0 -1291
- package/tools/vds-scripts/excel_orchestrator/src/vds_excel_orchestrator/validators.py +0 -164
- package/tools/vds-scripts/excel_orchestrator/sync_detail_and_total_sheets.py +0 -211
- package/tools/vds-scripts/excel_orchestrator/tests/__init__.py +0 -1
- package/tools/vds-scripts/excel_orchestrator/tests/conftest.py +0 -36
- package/tools/vds-scripts/excel_orchestrator/tests/test_cli.py +0 -383
- package/tools/vds-scripts/excel_orchestrator/tests/test_excel_client.py +0 -129
- package/tools/vds-scripts/excel_orchestrator/tests/test_ulnc_alignment.py +0 -373
- package/tools/vds-scripts/excel_orchestrator/tests/test_validators.py +0 -64
- package/tools/vds-scripts/excel_orchestrator/update_api_database_effort.py +0 -261
- package/tools/vds-scripts/excel_orchestrator/update_buffers_inline.py +0 -115
- package/tools/vds-scripts/excel_orchestrator/update_complex_services_and_add_new.py +0 -336
- package/tools/vds-scripts/excel_orchestrator/update_responsibility_and_fix_rows.py +0 -208
- package/tools/vds-scripts/excel_orchestrator/update_task_breakdown_vietnamese.py +0 -309
- package/tools/vds-scripts/excel_orchestrator/update_vietnamese_and_responsibility.py +0 -415
- package/tools/vds-scripts/excel_orchestrator/verify_brd_coverage_comprehensive.py +0 -401
- package/tools/vds-scripts/hexagonal_orchestrator/README.md +0 -530
- package/tools/vds-scripts/hexagonal_orchestrator/pyproject.toml +0 -48
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/__init__.py +0 -39
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/analyzers/__init__.py +0 -19
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/analyzers/base.py +0 -95
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/analyzers/fallback.py +0 -614
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/analyzers/java.py +0 -372
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/analyzers/python.py +0 -437
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/cache.py +0 -331
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/classifier.py +0 -263
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/cli.py +0 -554
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/config.py +0 -577
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/models.py +0 -159
- package/tools/vds-scripts/hexagonal_orchestrator/src/vds_hexagonal_orchestrator/profiler.py +0 -451
- package/tools/vds-scripts/hexagonal_orchestrator/test-config.yaml +0 -38
- package/tools/vds-scripts/hexagonal_orchestrator/tests/__init__.py +0 -1
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/__init__.py +0 -1
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/adapter/driven/persistence/InMemoryUserRepository.java +0 -62
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/adapter/driving/api/UserController.java +0 -101
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/application/port/EmailService.java +0 -33
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/application/port/UserRepository.java +0 -45
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/application/usecase/CreateUser.java +0 -58
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/domain/entity/Email.java +0 -80
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-compliant/domain/entity/User.java +0 -98
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-noncompliant/domain/User.java +0 -64
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-with-frameworks/domain/Menu.java +0 -13
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/java-with-frameworks/domain/Product.java +0 -16
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/__init__.py +0 -1
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/application/__init__.py +0 -1
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/application/ports/__init__.py +0 -1
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/application/ports/email_service.py +0 -60
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/application/ports/user_repository.py +0 -78
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/domain/__init__.py +0 -1
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/domain/entities/__init__.py +0 -1
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/domain/entities/user.py +0 -56
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/domain/value_objects/__init__.py +0 -1
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-compliant/domain/value_objects/email.py +0 -63
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-noncompliant/application/user_service.py +0 -1837
- package/tools/vds-scripts/hexagonal_orchestrator/tests/fixtures/python-noncompliant/domain/user.py +0 -43
- package/tools/vds-scripts/hexagonal_orchestrator/tests/test_cache.py +0 -458
- package/tools/vds-scripts/hexagonal_orchestrator/tests/test_cli_integration.py +0 -942
- package/tools/vds-scripts/hexagonal_orchestrator/tests/test_cli_unit.py +0 -557
- package/tools/vds-scripts/hexagonal_orchestrator/tests/test_cross_repo_pollution.py +0 -275
- package/tools/vds-scripts/hexagonal_orchestrator/tests/test_foundation.py +0 -129
- package/tools/vds-scripts/hexagonal_orchestrator/tests/test_integration.py +0 -1524
- package/tools/vds-scripts/hexagonal_orchestrator/tests/test_java_analyzer.py +0 -642
- package/tools/vds-scripts/hexagonal_orchestrator/tests/test_timing_unit.py +0 -60
- package/tools/vds-scripts/intellij_orchestrator/README.md +0 -55
- package/tools/vds-scripts/intellij_orchestrator/pyproject.toml +0 -64
- package/tools/vds-scripts/intellij_orchestrator/src/vds_intellij_orchestrator/__init__.py +0 -17
- package/tools/vds-scripts/intellij_orchestrator/src/vds_intellij_orchestrator/cli.py +0 -210
- package/tools/vds-scripts/intellij_orchestrator/src/vds_intellij_orchestrator/core.py +0 -260
- package/tools/vds-scripts/intellij_orchestrator/tests/__init__.py +0 -1
- package/tools/vds-scripts/intellij_orchestrator/tests/test_cli.py +0 -112
- package/tools/vds-scripts/intellij_orchestrator/tests/test_core.py +0 -83
- package/tools/vds-scripts/links_orchestrator/README.md +0 -63
- package/tools/vds-scripts/links_orchestrator/pyproject.toml +0 -64
- package/tools/vds-scripts/links_orchestrator/src/vds_links_orchestrator/__init__.py +0 -10
- package/tools/vds-scripts/links_orchestrator/src/vds_links_orchestrator/cli.py +0 -254
- package/tools/vds-scripts/links_orchestrator/src/vds_links_orchestrator/validator.py +0 -244
- package/tools/vds-scripts/links_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/links_orchestrator/tests/test_cli.py +0 -128
- package/tools/vds-scripts/links_orchestrator/tests/test_validator.py +0 -76
- package/tools/vds-scripts/lsp_orchestrator/.dockerignore +0 -69
- package/tools/vds-scripts/lsp_orchestrator/ARCHITECTURE.md +0 -383
- package/tools/vds-scripts/lsp_orchestrator/CODE_QUALITY_IMPROVEMENTS.md +0 -196
- package/tools/vds-scripts/lsp_orchestrator/COMMANDS.md +0 -870
- package/tools/vds-scripts/lsp_orchestrator/Dockerfile +0 -59
- package/tools/vds-scripts/lsp_orchestrator/IMPLEMENTATION_SUMMARY.md +0 -490
- package/tools/vds-scripts/lsp_orchestrator/LSP_ISSUES_AND_FINDINGS.md +0 -380
- package/tools/vds-scripts/lsp_orchestrator/README.md +0 -616
- package/tools/vds-scripts/lsp_orchestrator/SETUP.md +0 -143
- package/tools/vds-scripts/lsp_orchestrator/TEST_COVERAGE_SUMMARY.md +0 -255
- package/tools/vds-scripts/lsp_orchestrator/VERIFICATION_CHECKLIST.md +0 -814
- package/tools/vds-scripts/lsp_orchestrator/docker-compose.yml +0 -102
- package/tools/vds-scripts/lsp_orchestrator/docs/FOR_LLMS.md +0 -401
- package/tools/vds-scripts/lsp_orchestrator/docs/explanation/lsp-response-matching.md +0 -79
- package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/automate-with-json.md +0 -159
- package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/docker-mode.md +0 -256
- package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/navigate-code.md +0 -116
- package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/parallel-processing.md +0 -179
- package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/project-tool-detection.md +0 -320
- package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/type-check-code.md +0 -46
- package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/use-daemon-mode.md +0 -78
- package/tools/vds-scripts/lsp_orchestrator/docs/how-to-guides/wsl2-optimization.md +0 -227
- package/tools/vds-scripts/lsp_orchestrator/docs/index.md +0 -88
- package/tools/vds-scripts/lsp_orchestrator/docs/operator-hover-definition.md +0 -143
- package/tools/vds-scripts/lsp_orchestrator/docs/reference/commands.md +0 -581
- package/tools/vds-scripts/lsp_orchestrator/docs/reference/configuration.md +0 -422
- package/tools/vds-scripts/lsp_orchestrator/docs/tutorials/00-quick-start.md +0 -169
- package/tools/vds-scripts/lsp_orchestrator/pyproject.toml +0 -63
- package/tools/vds-scripts/lsp_orchestrator/src/test_file.py +0 -5
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/__init__.py +0 -3
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/aggregator.py +0 -340
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/basedpyright_runner.py +0 -167
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/cli.py +0 -3370
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/code_actions.py +0 -79
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/core.py +0 -3295
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/daemon_client.py +0 -672
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/daemon_manager.py +0 -577
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/daemon_server.py +0 -1040
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/detectors/__init__.py +0 -9
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/detectors/project_detector.py +0 -537
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/formatters.py +0 -141
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/ipc_protocol.py +0 -225
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/lsp_client.py +0 -957
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/lsp_router.py +0 -335
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/mcp_server.py +0 -181
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/models/__init__.py +0 -201
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/models/project_detector.py +0 -646
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/models/project_tools.py +0 -114
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/models.py +0 -399
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/mypy_runner.py +0 -209
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/protocols.py +0 -52
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/ruff_lsp_client.py +0 -109
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/ruff_runner.py +0 -44
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/utils.py +0 -959
- package/tools/vds-scripts/lsp_orchestrator/src/vds_lsp_orchestrator/workspace_indexer.py +0 -1037
- package/tools/vds-scripts/lsp_orchestrator/test_workspace_lsp.py +0 -6
- package/tools/vds-scripts/lsp_orchestrator/tests/__init__.py +0 -1
- package/tools/vds-scripts/lsp_orchestrator/tests/conftest.py +0 -6
- package/tools/vds-scripts/lsp_orchestrator/tests/test_aggregator.py +0 -59
- package/tools/vds-scripts/lsp_orchestrator/tests/test_cli.py +0 -111
- package/tools/vds-scripts/lsp_orchestrator/tests/test_detect_tools_command.py +0 -186
- package/tools/vds-scripts/lsp_orchestrator/tests/test_formatter_linter_detection.py +0 -519
- package/tools/vds-scripts/lsp_orchestrator/tests/test_integration_phase9_10_11.py +0 -367
- package/tools/vds-scripts/lsp_orchestrator/tests/test_mypy_runner.py +0 -482
- package/tools/vds-scripts/lsp_orchestrator/tests/test_package_manager_detection.py +0 -399
- package/tools/vds-scripts/lsp_orchestrator/tests/test_phase10.py +0 -389
- package/tools/vds-scripts/lsp_orchestrator/tests/test_phase11.py +0 -327
- package/tools/vds-scripts/lsp_orchestrator/tests/test_phase12_integration.py +0 -634
- package/tools/vds-scripts/lsp_orchestrator/tests/test_phase9.py +0 -196
- package/tools/vds-scripts/lsp_orchestrator/tests/test_project_detector.py +0 -377
- package/tools/vds-scripts/lsp_orchestrator/tests/test_test_runner_detection.py +0 -549
- package/tools/vds-scripts/lsp_orchestrator/tests/test_type_checker_routing.py +0 -362
- package/tools/vds-scripts/lsp_orchestrator/tests/test_workspace_indexer.py +0 -144
- package/tools/vds-scripts/markdown_orchestrator/README.md +0 -72
- package/tools/vds-scripts/markdown_orchestrator/pyproject.toml +0 -39
- package/tools/vds-scripts/markdown_orchestrator/src/vds_markdown_orchestrator/__init__.py +0 -5
- package/tools/vds-scripts/markdown_orchestrator/src/vds_markdown_orchestrator/cli.py +0 -102
- package/tools/vds-scripts/multi_agent_orchestrator/Dockerfile +0 -65
- package/tools/vds-scripts/multi_agent_orchestrator/README.md +0 -306
- package/tools/vds-scripts/multi_agent_orchestrator/postman/README.md +0 -264
- package/tools/vds-scripts/multi_agent_orchestrator/postman/TEST_RESULTS_SUMMARY.md +0 -197
- package/tools/vds-scripts/multi_agent_orchestrator/postman/VDS-Multi-Agent-Orchestrator-API.postman_collection.json +0 -1010
- package/tools/vds-scripts/multi_agent_orchestrator/postman/environments/local-development.postman_environment.json +0 -55
- package/tools/vds-scripts/multi_agent_orchestrator/postman/test-results.json +0 -24146
- package/tools/vds-scripts/multi_agent_orchestrator/pyproject.toml +0 -63
- package/tools/vds-scripts/multi_agent_orchestrator/run_api.py +0 -9
- package/tools/vds-scripts/multi_agent_orchestrator/run_mock_api.py +0 -9
- package/tools/vds-scripts/multi_agent_orchestrator/simple_test.py +0 -53
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/__init__.py +0 -25
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/agent_pool.py +0 -433
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/api/__init__.py +0 -5
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/api/main.py +0 -722
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/api/mock_main.py +0 -812
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/change_log.py +0 -515
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/cli.py +0 -424
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/config.py +0 -220
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/conflict_resolver.py +0 -462
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/coordinator.py +0 -627
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/models.py +0 -389
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/progress_dashboard.py +0 -380
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/redis_client.py +0 -245
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/scheduler_subscriber.py +0 -272
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/task_manager.py +0 -536
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/task_tracking.py +0 -550
- package/tools/vds-scripts/multi_agent_orchestrator/src/vds_multi_agent_orchestrator/vds_ai_memory_client.py +0 -352
- package/tools/vds-scripts/multi_agent_orchestrator/test_complete_system.py +0 -149
- package/tools/vds-scripts/multi_agent_orchestrator/test_infrastructure_only.py +0 -194
- package/tools/vds-scripts/multi_agent_orchestrator/test_integration.py +0 -108
- package/tools/vds-scripts/multi_agent_orchestrator/tests/__init__.py +0 -1
- package/tools/vds-scripts/multi_agent_orchestrator/tests/test_agent_registration_credential_validator.py +0 -223
- package/tools/vds-scripts/multi_agent_orchestrator/tests/test_config.py +0 -210
- package/tools/vds-scripts/multi_agent_orchestrator/tests/test_models.py +0 -195
- package/tools/vds-scripts/multi_agent_orchestrator/tests/test_w9_agent_routes.py +0 -321
- package/tools/vds-scripts/openapi_orchestrator/README.md +0 -197
- package/tools/vds-scripts/openapi_orchestrator/pyproject.toml +0 -106
- package/tools/vds-scripts/openapi_orchestrator/src/vds_openapi_orchestrator/__init__.py +0 -29
- package/tools/vds-scripts/openapi_orchestrator/src/vds_openapi_orchestrator/cli.py +0 -345
- package/tools/vds-scripts/openapi_orchestrator/src/vds_openapi_orchestrator/full_validator.py +0 -183
- package/tools/vds-scripts/openapi_orchestrator/src/vds_openapi_orchestrator/spec_validator.py +0 -197
- package/tools/vds-scripts/openapi_orchestrator/tests/__init__.py +0 -1
- package/tools/vds-scripts/openapi_orchestrator/tests/test_cli.py +0 -234
- package/tools/vds-scripts/openapi_orchestrator/tests/test_full_validator.py +0 -203
- package/tools/vds-scripts/openapi_orchestrator/tests/test_spec_validator.py +0 -295
- package/tools/vds-scripts/pdf_orchestrator/.dockerignore +0 -93
- package/tools/vds-scripts/pdf_orchestrator/.env.example +0 -40
- package/tools/vds-scripts/pdf_orchestrator/.ruff_rules.py +0 -350
- package/tools/vds-scripts/pdf_orchestrator/.yamllint.yml +0 -43
- package/tools/vds-scripts/pdf_orchestrator/DEVELOPMENT_PLAN.md +0 -80
- package/tools/vds-scripts/pdf_orchestrator/Dockerfile +0 -87
- package/tools/vds-scripts/pdf_orchestrator/README.md +0 -608
- package/tools/vds-scripts/pdf_orchestrator/cli_verification_test/test.md +0 -6
- package/tools/vds-scripts/pdf_orchestrator/cli_verification_test/test.pdf +0 -0
- package/tools/vds-scripts/pdf_orchestrator/config/alertmanager.yml +0 -83
- package/tools/vds-scripts/pdf_orchestrator/config/prometheus.prod.yml +0 -98
- package/tools/vds-scripts/pdf_orchestrator/config/prometheus.yml +0 -40
- package/tools/vds-scripts/pdf_orchestrator/config/redis.conf +0 -78
- package/tools/vds-scripts/pdf_orchestrator/docs/COMPETITIVE_ANALYSIS_REPORT.md +0 -309
- package/tools/vds-scripts/pdf_orchestrator/docs/FEATURES_GUIDE.md +0 -518
- package/tools/vds-scripts/pdf_orchestrator/docs/MULTI_USER_DEPLOYMENT_GUIDE.md +0 -615
- package/tools/vds-scripts/pdf_orchestrator/docs/USER_GUIDE.md +0 -829
- package/tools/vds-scripts/pdf_orchestrator/pyproject.toml +0 -87
- package/tools/vds-scripts/pdf_orchestrator/pytest.ini +0 -71
- package/tools/vds-scripts/pdf_orchestrator/ruff.toml +0 -6
- package/tools/vds-scripts/pdf_orchestrator/scripts/debug_security_report.py +0 -59
- package/tools/vds-scripts/pdf_orchestrator/scripts/demo_library_selector.py +0 -109
- package/tools/vds-scripts/pdf_orchestrator/scripts/generate_project_stats.py +0 -52
- package/tools/vds-scripts/pdf_orchestrator/scripts/generate_styled_pdf.py +0 -95
- package/tools/vds-scripts/pdf_orchestrator/scripts/migrate_render_pdfs.py +0 -285
- package/tools/vds-scripts/pdf_orchestrator/scripts/setup_team.bat +0 -283
- package/tools/vds-scripts/pdf_orchestrator/scripts/setup_team.sh +0 -324
- package/tools/vds-scripts/pdf_orchestrator/src/vds_pdf_orchestrator/__init__.py +0 -5
- package/tools/vds-scripts/pdf_orchestrator/src/vds_pdf_orchestrator/cli.py +0 -542
- package/tools/vds-scripts/pdf_orchestrator/src/vds_pdf_orchestrator/config.py +0 -33
- package/tools/vds-scripts/pdf_orchestrator/tests/README.md +0 -650
- package/tools/vds-scripts/pdf_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/pdf_orchestrator/tests/conftest.py +0 -520
- package/tools/vds-scripts/pdf_orchestrator/tests/requirements.txt +0 -51
- package/tools/vds-scripts/pdf_orchestrator/tests/run_tests.py +0 -659
- package/tools/vds-scripts/pdf_orchestrator/tests/test_config.py +0 -36
- package/tools/vds-scripts/progress_report_orchestrator/Dockerfile +0 -77
- package/tools/vds-scripts/progress_report_orchestrator/README.md +0 -39
- package/tools/vds-scripts/progress_report_orchestrator/alembic/env.py +0 -42
- package/tools/vds-scripts/progress_report_orchestrator/alembic/script.py.mako +0 -28
- package/tools/vds-scripts/progress_report_orchestrator/alembic/versions/0001_initial_progress_schema.py +0 -180
- package/tools/vds-scripts/progress_report_orchestrator/alembic.ini +0 -67
- package/tools/vds-scripts/progress_report_orchestrator/pyproject.toml +0 -67
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/__init__.py +0 -3
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/analyzers/__init__.py +0 -1
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/analyzers/endpoint_scanner.py +0 -238
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/analyzers/git_activity.py +0 -159
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/analyzers/hexagonal.py +0 -100
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/analyzers/test_scanner.py +0 -136
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/cli.py +0 -743
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/config.py +0 -50
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/db/__init__.py +0 -12
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/db/alembic_filters.py +0 -64
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/memory.py +0 -82
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/models/__init__.py +0 -1
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/models/analysis.py +0 -84
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/models/report.py +0 -117
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/models/topology.py +0 -101
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/parsers/__init__.py +0 -1
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/parsers/kg_parser.py +0 -252
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/parsers/uc_reader.py +0 -159
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/__init__.py +0 -1
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/concurrency.py +0 -39
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/llm_eval.py +0 -570
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/report.py +0 -1256
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/structural.py +0 -384
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/pipeline/sync.py +0 -143
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/recommendations/__init__.py +0 -5
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/recommendations/engine.py +0 -105
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/recommendations/templates.py +0 -236
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/scheduler_subscriber.py +0 -238
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/skills/README.md +0 -56
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/skills/__init__.py +0 -1
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/skills/srs-architecture-reviewer/SKILL.md +0 -67
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/skills/srs-endpoint-matcher/SKILL.md +0 -67
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/state/__init__.py +0 -1
- package/tools/vds-scripts/progress_report_orchestrator/src/progress_report_orchestrator/state/schema.py +0 -625
- package/tools/vds-scripts/progress_report_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/__init__.py +0 -0
- package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/.gitkeep +0 -0
- package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/__init__.py +0 -0
- package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/doc-dependencies.yaml +0 -79
- package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/fr-to-docs.yaml +0 -478
- package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/fr-to-services.yaml +0 -18
- package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/kg/registry.yaml +0 -346
- package/tools/vds-scripts/progress_report_orchestrator/tests/fixtures/phase3_baseline_standard.md +0 -564
- package/tools/vds-scripts/progress_report_orchestrator/tests/integration/__init__.py +0 -0
- package/tools/vds-scripts/progress_report_orchestrator/tests/integration/test_checkpoint.py +0 -276
- package/tools/vds-scripts/progress_report_orchestrator/tests/test_alembic_migrations.py +0 -265
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/__init__.py +0 -0
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_analyzers.py +0 -267
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_bounded_gather.py +0 -176
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_cli_phase_report.py +0 -119
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_delta.py +0 -169
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_error_handling.py +0 -150
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_gate_exit_codes.py +0 -230
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_git_activity.py +0 -215
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_kg_parser.py +0 -267
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_llm_autodetect.py +0 -183
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_llm_eval.py +0 -529
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_memory_integration.py +0 -151
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_migration_contract.py +0 -254
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_mode_rendering.py +0 -576
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_models.py +0 -251
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_progress_llm_config.py +0 -67
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_recommendations.py +0 -480
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_report_enhancements.py +0 -415
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_resume_reload.py +0 -343
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_trend_regression.py +0 -294
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_uc_reader.py +0 -169
- package/tools/vds-scripts/progress_report_orchestrator/tests/unit/test_valence_gap.py +0 -293
- package/tools/vds-scripts/project-cycle-report.json +0 -14
- package/tools/vds-scripts/project-dependency-graph.json +0 -11361
- package/tools/vds-scripts/project-topology.json +0 -99
- package/tools/vds-scripts/public_interface_boundary_orchestrator/pyproject.toml +0 -18
- package/tools/vds-scripts/public_interface_boundary_orchestrator/src/vds_public_interface_boundary_orchestrator/__init__.py +0 -0
- package/tools/vds-scripts/public_interface_boundary_orchestrator/src/vds_public_interface_boundary_orchestrator/cli.py +0 -232
- package/tools/vds-scripts/public_interface_boundary_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/public_interface_boundary_orchestrator/tests/test_cli.py +0 -108
- package/tools/vds-scripts/research_orchestrator/README.md +0 -68
- package/tools/vds-scripts/research_orchestrator/py.typed +0 -0
- package/tools/vds-scripts/research_orchestrator/pyproject.toml +0 -95
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/__init__.py +0 -3
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/_env.py +0 -11
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/cli.py +0 -335
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/config.py +0 -43
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/evidence/__init__.py +0 -0
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/evidence/models.py +0 -89
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/evidence/scoring.py +0 -102
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/exceptions.py +0 -78
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/http_client.py +0 -160
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/logging.py +0 -49
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/output/__init__.py +0 -0
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/output/formatters.py +0 -93
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/py.typed +0 -1
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/report/__init__.py +0 -0
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/report/build.py +0 -156
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/report/format.py +0 -147
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/tools/__init__.py +0 -0
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/tools/health.py +0 -66
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/tools/health_graph.py +0 -52
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/tools/registry.py +0 -127
- package/tools/vds-scripts/research_orchestrator/src/vds_research_orchestrator/tools/search.py +0 -230
- package/tools/vds-scripts/research_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/research_orchestrator/tests/conftest.py +0 -53
- package/tools/vds-scripts/research_orchestrator/tests/test_cli.py +0 -222
- package/tools/vds-scripts/research_orchestrator/tests/test_config.py +0 -23
- package/tools/vds-scripts/research_orchestrator/tests/test_exceptions.py +0 -62
- package/tools/vds-scripts/research_orchestrator/tests/test_formatters.py +0 -89
- package/tools/vds-scripts/research_orchestrator/tests/test_graph_integration.py +0 -149
- package/tools/vds-scripts/research_orchestrator/tests/test_http_client.py +0 -134
- package/tools/vds-scripts/research_orchestrator/tests/test_report_build.py +0 -128
- package/tools/vds-scripts/research_orchestrator/tests/test_report_format.py +0 -91
- package/tools/vds-scripts/research_orchestrator/tests/test_scoring.py +0 -95
- package/tools/vds-scripts/research_orchestrator/tests/vds_research_orchestrator/test_tools/__init__.py +0 -1
- package/tools/vds-scripts/research_orchestrator/tests/vds_research_orchestrator/test_tools/test_health.py +0 -139
- package/tools/vds-scripts/research_orchestrator/tests/vds_research_orchestrator/test_tools/test_registry.py +0 -135
- package/tools/vds-scripts/research_orchestrator/tests/vds_research_orchestrator/test_tools/test_search.py +0 -238
- package/tools/vds-scripts/run-history.json +0 -26
- package/tools/vds-scripts/schema_converter/README.md +0 -109
- package/tools/vds-scripts/schema_converter/pyproject.toml +0 -37
- package/tools/vds-scripts/schema_converter/src/vds_schema_converter/__init__.py +0 -3
- package/tools/vds-scripts/schema_converter/src/vds_schema_converter/cli.py +0 -50
- package/tools/vds-scripts/schema_converter/tests/__init__.py +0 -0
- package/tools/vds-scripts/schema_converter/tests/test_json_schema_generator.py +0 -115
- package/tools/vds-scripts/schema_converter/tests/test_mermaid_generator.py +0 -112
- package/tools/vds-scripts/schema_converter/tests/test_parser.py +0 -111
- package/tools/vds-scripts/schema_converter/tests/test_plantuml_generator.py +0 -112
- package/tools/vds-scripts/schema_converter/tests/test_plantuml_validator.py +0 -69
- package/tools/vds-scripts/schema_converter/tests/test_prisma_generator.py +0 -113
- package/tools/vds-scripts/schema_converter/tests/test_sql_generator.py +0 -138
- package/tools/vds-scripts/schema_converter/tests/test_typeorm_generator.py +0 -110
- package/tools/vds-scripts/schema_converter/tests/test_validators.py +0 -96
- package/tools/vds-scripts/spec_orchestrator/README.md +0 -13
- package/tools/vds-scripts/spec_orchestrator/pyproject.toml +0 -40
- package/tools/vds-scripts/spec_orchestrator/src/vds_spec_orchestrator/__init__.py +0 -5
- package/tools/vds-scripts/spec_orchestrator/src/vds_spec_orchestrator/cli.py +0 -162
- package/tools/vds-scripts/spec_orchestrator/src/vds_spec_orchestrator/core.py +0 -575
- package/tools/vds-scripts/spec_orchestrator/src/vds_spec_orchestrator/sync.py +0 -306
- package/tools/vds-scripts/spec_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/spec_orchestrator/tests/test_frontmatter_drift.py +0 -243
- package/tools/vds-scripts/spec_orchestrator/tests/test_sync.py +0 -342
- package/tools/vds-scripts/structure_orchestrator/README.md +0 -60
- package/tools/vds-scripts/structure_orchestrator/pyproject.toml +0 -103
- package/tools/vds-scripts/structure_orchestrator/src/vds_structure_orchestrator/__init__.py +0 -13
- package/tools/vds-scripts/structure_orchestrator/src/vds_structure_orchestrator/cli.py +0 -308
- package/tools/vds-scripts/structure_orchestrator/src/vds_structure_orchestrator/validator.py +0 -257
- package/tools/vds-scripts/structure_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/structure_orchestrator/tests/test_cli.py +0 -161
- package/tools/vds-scripts/structure_orchestrator/tests/test_helpers.py +0 -115
- package/tools/vds-scripts/structure_orchestrator/tests/test_validator.py +0 -104
- package/tools/vds-scripts/task_orchestrator/README.md +0 -50
- package/tools/vds-scripts/task_orchestrator/__init__.py +0 -18
- package/tools/vds-scripts/task_orchestrator/pyproject.toml +0 -43
- package/tools/vds-scripts/task_orchestrator/scripts/run_excel_sync.py +0 -36
- package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/__init__.py +0 -13
- package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/audit.py +0 -134
- package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/cli.py +0 -127
- package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/debug.py +0 -133
- package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/normalize.py +0 -113
- package/tools/vds-scripts/task_orchestrator/src/vds_task_orchestrator/refine.py +0 -201
- package/tools/vds-scripts/task_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/task_orchestrator/tests/test_task_orchestrator.py +0 -84
- package/tools/vds-scripts/temp_query_projects.py +0 -2
- package/tools/vds-scripts/test_small.md +0 -1
- package/tools/vds-scripts/text_utils_orchestrator/pyproject.toml +0 -20
- package/tools/vds-scripts/text_utils_orchestrator/src/vds_text_utils/__init__.py +0 -7
- package/tools/vds-scripts/text_utils_orchestrator/src/vds_text_utils/i18n.py +0 -143
- package/tools/vds-scripts/text_utils_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/text_utils_orchestrator/tests/test_i18n.py +0 -53
- package/tools/vds-scripts/upgrade_major.py +0 -61
- package/tools/vds-scripts/upgrade_major_v2.py +0 -64
- package/tools/vds-scripts/verify_violations.py +0 -57
- package/tools/vds-scripts/workflow-summary.json +0 -325
- package/tools/vds-scripts/workflow-summary.md +0 -8
|
@@ -1,4035 +0,0 @@
|
|
|
1
|
-
"""Base Agent Architecture (Phase 6)."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import abc
|
|
6
|
-
import asyncio
|
|
7
|
-
import contextlib
|
|
8
|
-
import json
|
|
9
|
-
import os
|
|
10
|
-
import random
|
|
11
|
-
import re
|
|
12
|
-
from collections.abc import Coroutine
|
|
13
|
-
from dataclasses import dataclass, field
|
|
14
|
-
from typing import TYPE_CHECKING, Any, TypeVar
|
|
15
|
-
from urllib.parse import urlparse
|
|
16
|
-
from uuid import uuid4
|
|
17
|
-
|
|
18
|
-
from pydantic_ai.settings import ModelSettings
|
|
19
|
-
from structlog import get_logger
|
|
20
|
-
from vds_agent_core.profiles import resolve_default_failover_profiles
|
|
21
|
-
|
|
22
|
-
from vds_audit_orchestrator.engine.provider_failure_classifier import (
|
|
23
|
-
ProviderFailureClass,
|
|
24
|
-
ProviderFailureClassifier,
|
|
25
|
-
ProviderHealthMemory,
|
|
26
|
-
RowFailoverContext,
|
|
27
|
-
TimeoutKind,
|
|
28
|
-
truncate_failover_profiles_considered,
|
|
29
|
-
truncate_row_failover_context,
|
|
30
|
-
)
|
|
31
|
-
from vds_audit_orchestrator.errors import AuditError
|
|
32
|
-
from vds_audit_orchestrator.llm.cost_tracker import global_tracker
|
|
33
|
-
from vds_audit_orchestrator.llm.provider import (
|
|
34
|
-
LLMProtocolType,
|
|
35
|
-
LLMSettings,
|
|
36
|
-
build_structured_output_extra_body,
|
|
37
|
-
resolve_openai_protocol_api_key,
|
|
38
|
-
resolve_protocol_api_key,
|
|
39
|
-
resolve_protocol_base_url,
|
|
40
|
-
should_suppress_anthropic_tool_choice,
|
|
41
|
-
should_suppress_openai_tool_choice,
|
|
42
|
-
)
|
|
43
|
-
from vds_audit_orchestrator.logging_config import log_context
|
|
44
|
-
from vds_audit_orchestrator.observability.metrics import record_llm_usage
|
|
45
|
-
from vds_audit_orchestrator.runtime_profiles import inherit_runtime_llm_policy
|
|
46
|
-
|
|
47
|
-
if TYPE_CHECKING:
|
|
48
|
-
from vds_audit_orchestrator.models.evidence import EvidenceBundle
|
|
49
|
-
from vds_audit_orchestrator.models.task import AuditTask
|
|
50
|
-
|
|
51
|
-
logger = get_logger()
|
|
52
|
-
|
|
53
|
-
ResultType = TypeVar("ResultType")
|
|
54
|
-
|
|
55
|
-
OPENAI_CODEX_PROTOCOL = "openai-codex"
|
|
56
|
-
OPENAI_CODEX_BASELINE_MODELS: frozenset[str] = frozenset({"gpt-5.4", "gpt-5.3-codex", "gpt-5.2-codex"})
|
|
57
|
-
PYDANTIC_AI_MODEL_SUPPORTED_PROTOCOLS: frozenset[LLMProtocolType] = frozenset(LLMProtocolType)
|
|
58
|
-
PYDANTIC_AI_MODEL_SUPPORTED_PROTOCOL_VALUES: frozenset[str] = frozenset(
|
|
59
|
-
{item.value for item in PYDANTIC_AI_MODEL_SUPPORTED_PROTOCOLS}.union({OPENAI_CODEX_PROTOCOL})
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
@dataclass
|
|
64
|
-
class AgentResult:
|
|
65
|
-
"""Standard output from an agent."""
|
|
66
|
-
|
|
67
|
-
agent_name: str
|
|
68
|
-
success: bool
|
|
69
|
-
findings: list[dict[str, Any]] = field(default_factory=list)
|
|
70
|
-
metadata: dict[str, Any] = field(default_factory=dict)
|
|
71
|
-
error: AuditError | str | None = None
|
|
72
|
-
spawned_tasks: list[dict[str, Any]] = field(default_factory=list)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
@dataclass(frozen=True, slots=True)
|
|
76
|
-
class AgentTimeoutPolicy:
|
|
77
|
-
"""Runtime timeout budget and extension policy for agent model calls."""
|
|
78
|
-
|
|
79
|
-
initial_timeout_seconds: float
|
|
80
|
-
max_timeout_seconds: float
|
|
81
|
-
extension_seconds: float
|
|
82
|
-
extension_attempts: int
|
|
83
|
-
heartbeat_seconds: float
|
|
84
|
-
idle_post_tool_seconds: float
|
|
85
|
-
lease_window_seconds: float = 0.0
|
|
86
|
-
stall_detection_seconds: float = 30.0
|
|
87
|
-
absolute_timeout_seconds: float = 0.0
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
@dataclass(frozen=True, slots=True)
|
|
91
|
-
class _AgentRuntimeSnapshot:
|
|
92
|
-
settings: LLMSettings
|
|
93
|
-
pydantic_model: Any | None
|
|
94
|
-
model_settings: ModelSettings | None
|
|
95
|
-
client: Any | None
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
@dataclass(slots=True)
|
|
99
|
-
class _PydanticStreamResultWrapper:
|
|
100
|
-
"""Expose stream results with RunResult-compatible accessors."""
|
|
101
|
-
|
|
102
|
-
output: Any
|
|
103
|
-
streamed_result: Any
|
|
104
|
-
|
|
105
|
-
def usage(self) -> Any:
|
|
106
|
-
return self.streamed_result.usage()
|
|
107
|
-
|
|
108
|
-
def all_messages(self, *, output_tool_return_content: str | None = None) -> list[Any]:
|
|
109
|
-
return self.streamed_result.all_messages(output_tool_return_content=output_tool_return_content)
|
|
110
|
-
|
|
111
|
-
def all_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes:
|
|
112
|
-
return self.streamed_result.all_messages_json(output_tool_return_content=output_tool_return_content)
|
|
113
|
-
|
|
114
|
-
def new_messages(self, *, output_tool_return_content: str | None = None) -> list[Any]:
|
|
115
|
-
return self.streamed_result.new_messages(output_tool_return_content=output_tool_return_content)
|
|
116
|
-
|
|
117
|
-
def __getattr__(self, name: str) -> Any:
|
|
118
|
-
return getattr(self.streamed_result, name)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
class BaseAgent(abc.ABC):
|
|
122
|
-
"""Abstract base class for analysis agents."""
|
|
123
|
-
|
|
124
|
-
def __init__(self, settings: LLMSettings | None = None, model_override: Any | None = None):
|
|
125
|
-
self.settings = settings or LLMSettings()
|
|
126
|
-
self.logger = logger.bind(agent=self.__class__.__name__)
|
|
127
|
-
self._pydantic_model: Any | None = None
|
|
128
|
-
self._model_settings: ModelSettings | None = None
|
|
129
|
-
self._last_agent_run_telemetry: dict[str, Any] = {}
|
|
130
|
-
self.client = None
|
|
131
|
-
|
|
132
|
-
settings_model = getattr(self.settings, "pydantic_model", None)
|
|
133
|
-
use_pydantic_ai = bool(getattr(self.settings, "use_pydantic_ai", False))
|
|
134
|
-
if settings_model is not None:
|
|
135
|
-
use_pydantic_ai = True
|
|
136
|
-
|
|
137
|
-
if self.settings.enabled:
|
|
138
|
-
if use_pydantic_ai:
|
|
139
|
-
try:
|
|
140
|
-
self._model_settings = self._build_model_settings()
|
|
141
|
-
self._pydantic_model = (
|
|
142
|
-
model_override or settings_model or self._build_pydantic_ai_model(self.settings.model_standard)
|
|
143
|
-
)
|
|
144
|
-
except Exception as e:
|
|
145
|
-
self.logger.warning("pydantic_ai_init_failed", error=str(e))
|
|
146
|
-
|
|
147
|
-
if self._pydantic_model is None:
|
|
148
|
-
try:
|
|
149
|
-
self.client = self.settings.get_client()
|
|
150
|
-
except Exception as e:
|
|
151
|
-
self.logger.warning("agent_llm_init_failed", error=str(e))
|
|
152
|
-
self.client = None
|
|
153
|
-
|
|
154
|
-
@staticmethod
|
|
155
|
-
def _normalize_profile_names(raw_profiles: Any) -> list[str]:
|
|
156
|
-
if isinstance(raw_profiles, str):
|
|
157
|
-
return [item.strip() for item in raw_profiles.split(",") if item.strip()]
|
|
158
|
-
if isinstance(raw_profiles, (list, tuple)):
|
|
159
|
-
names: list[str] = []
|
|
160
|
-
for item in raw_profiles:
|
|
161
|
-
normalized = str(item or "").strip()
|
|
162
|
-
if normalized:
|
|
163
|
-
names.append(normalized)
|
|
164
|
-
return names
|
|
165
|
-
return []
|
|
166
|
-
|
|
167
|
-
def _resolve_active_runtime_profile_name(self) -> str | None:
|
|
168
|
-
value = str(os.getenv("VDS_AUDIT_ACTIVE_PROFILE") or "").strip()
|
|
169
|
-
return value or None
|
|
170
|
-
|
|
171
|
-
def _resolve_row_failover_profiles(self) -> list[str]:
|
|
172
|
-
# AC-145.1.1 / AC-145.1.3: Auto-derive failover profiles when the operator
|
|
173
|
-
# has NOT explicitly configured row_failover_profiles (env var absent).
|
|
174
|
-
# If the env var IS present (even as "[]"), respect the explicit setting.
|
|
175
|
-
failover_env_raw = os.getenv("VDS_AUDIT_LLM__ROW_FAILOVER_PROFILES")
|
|
176
|
-
active_profile = self._resolve_active_runtime_profile_name()
|
|
177
|
-
if failover_env_raw is None:
|
|
178
|
-
# Not explicitly configured — auto-derive from all runtime profiles.
|
|
179
|
-
auto_derived = resolve_default_failover_profiles(active_profile)
|
|
180
|
-
configured = auto_derived
|
|
181
|
-
else:
|
|
182
|
-
configured = self._normalize_profile_names(getattr(self.settings, "row_failover_profiles", []))
|
|
183
|
-
allowed = self._normalize_profile_names(os.getenv("VDS_AUDIT_ROW_FAILOVER_AVAILABLE_PROFILES"))
|
|
184
|
-
deduped: list[str] = []
|
|
185
|
-
seen: set[str] = set()
|
|
186
|
-
for candidate in configured:
|
|
187
|
-
if candidate == active_profile or candidate in seen:
|
|
188
|
-
continue
|
|
189
|
-
if allowed and candidate not in allowed:
|
|
190
|
-
continue
|
|
191
|
-
seen.add(candidate)
|
|
192
|
-
deduped.append(candidate)
|
|
193
|
-
return deduped
|
|
194
|
-
|
|
195
|
-
def _provider_identity(self, settings: LLMSettings | None = None) -> str:
|
|
196
|
-
effective = settings or self.settings
|
|
197
|
-
active_profile = self._resolve_active_runtime_profile_name()
|
|
198
|
-
if active_profile:
|
|
199
|
-
return active_profile
|
|
200
|
-
protocol = str(getattr(effective, "protocol", "") or "").strip()
|
|
201
|
-
model = str(getattr(effective, "model_standard", "") or "").strip()
|
|
202
|
-
base_url = str(getattr(effective, "base_url", "") or "").strip()
|
|
203
|
-
return ":".join(part for part in (protocol, model, base_url) if part) or "unknown"
|
|
204
|
-
|
|
205
|
-
@contextlib.contextmanager
|
|
206
|
-
def _temporary_agent_settings(self, settings: LLMSettings):
|
|
207
|
-
snapshot = _AgentRuntimeSnapshot(
|
|
208
|
-
settings=self.settings,
|
|
209
|
-
pydantic_model=self._pydantic_model,
|
|
210
|
-
model_settings=self._model_settings,
|
|
211
|
-
client=self.client,
|
|
212
|
-
)
|
|
213
|
-
self.settings = settings
|
|
214
|
-
self._model_settings = None
|
|
215
|
-
self._pydantic_model = None
|
|
216
|
-
self.client = None
|
|
217
|
-
if self.settings.enabled:
|
|
218
|
-
settings_model = getattr(self.settings, "pydantic_model", None)
|
|
219
|
-
use_pydantic_ai = bool(getattr(self.settings, "use_pydantic_ai", False))
|
|
220
|
-
if settings_model is not None:
|
|
221
|
-
use_pydantic_ai = True
|
|
222
|
-
if use_pydantic_ai:
|
|
223
|
-
try:
|
|
224
|
-
self._model_settings = self._build_model_settings()
|
|
225
|
-
self._pydantic_model = settings_model or self._build_pydantic_ai_model(self.settings.model_standard)
|
|
226
|
-
except Exception as exc:
|
|
227
|
-
self.logger.warning("pydantic_ai_failover_init_failed", error=str(exc))
|
|
228
|
-
self._pydantic_model = None
|
|
229
|
-
if self._pydantic_model is None:
|
|
230
|
-
try:
|
|
231
|
-
self.client = self.settings.get_client()
|
|
232
|
-
except Exception as exc:
|
|
233
|
-
self.logger.warning("agent_failover_llm_init_failed", error=str(exc))
|
|
234
|
-
self.client = None
|
|
235
|
-
try:
|
|
236
|
-
yield
|
|
237
|
-
finally:
|
|
238
|
-
self.settings = snapshot.settings
|
|
239
|
-
self._pydantic_model = snapshot.pydantic_model
|
|
240
|
-
self._model_settings = snapshot.model_settings
|
|
241
|
-
self.client = snapshot.client
|
|
242
|
-
|
|
243
|
-
@abc.abstractmethod
|
|
244
|
-
async def analyze(self, evidence: EvidenceBundle | dict[str, Any] | AuditTask) -> AgentResult:
|
|
245
|
-
"""Perform analysis on the evidence bundle."""
|
|
246
|
-
pass
|
|
247
|
-
|
|
248
|
-
@staticmethod
|
|
249
|
-
def _extract_json_object_candidates(raw: str) -> list[str]:
|
|
250
|
-
"""Extract top-level JSON object substrings from a potentially concatenated payload."""
|
|
251
|
-
text = str(raw or "")
|
|
252
|
-
if not text:
|
|
253
|
-
return []
|
|
254
|
-
candidates: list[str] = []
|
|
255
|
-
in_string = False
|
|
256
|
-
escape = False
|
|
257
|
-
depth = 0
|
|
258
|
-
start_idx: int | None = None
|
|
259
|
-
for idx, ch in enumerate(text):
|
|
260
|
-
if in_string:
|
|
261
|
-
if escape:
|
|
262
|
-
escape = False
|
|
263
|
-
elif ch == "\\":
|
|
264
|
-
escape = True
|
|
265
|
-
elif ch == '"':
|
|
266
|
-
in_string = False
|
|
267
|
-
continue
|
|
268
|
-
if ch == '"':
|
|
269
|
-
in_string = True
|
|
270
|
-
continue
|
|
271
|
-
if ch == "{":
|
|
272
|
-
if depth == 0:
|
|
273
|
-
start_idx = idx
|
|
274
|
-
depth += 1
|
|
275
|
-
continue
|
|
276
|
-
if ch == "}" and depth > 0:
|
|
277
|
-
depth -= 1
|
|
278
|
-
if depth == 0 and start_idx is not None:
|
|
279
|
-
candidates.append(text[start_idx : idx + 1])
|
|
280
|
-
start_idx = None
|
|
281
|
-
return candidates
|
|
282
|
-
|
|
283
|
-
def _recover_output_from_final_result_validation_error(
|
|
284
|
-
self,
|
|
285
|
-
*,
|
|
286
|
-
result_type: type[Any],
|
|
287
|
-
exc: Exception,
|
|
288
|
-
telemetry: dict[str, Any] | None,
|
|
289
|
-
) -> Any | None:
|
|
290
|
-
"""Recover structured output from invalid final_result payloads.
|
|
291
|
-
|
|
292
|
-
This path is intentionally broader than trailing-character JSON errors.
|
|
293
|
-
Some providers surface schema-shape validation failures even when the
|
|
294
|
-
raw final payload is recoverable and the target model can normalize it
|
|
295
|
-
via `model_validate(...)`.
|
|
296
|
-
"""
|
|
297
|
-
|
|
298
|
-
raw_candidates: list[str] = []
|
|
299
|
-
if isinstance(telemetry, dict):
|
|
300
|
-
raw_invalid_input = telemetry.get("event_final_result_invalid_input")
|
|
301
|
-
if isinstance(raw_invalid_input, str) and raw_invalid_input.strip():
|
|
302
|
-
raw_candidates.append(raw_invalid_input)
|
|
303
|
-
elif isinstance(raw_invalid_input, (dict, list)):
|
|
304
|
-
with contextlib.suppress(Exception):
|
|
305
|
-
raw_candidates.append(json.dumps(raw_invalid_input, ensure_ascii=False))
|
|
306
|
-
|
|
307
|
-
for attr_name in ("body", "response"):
|
|
308
|
-
raw_value = getattr(exc, attr_name, None)
|
|
309
|
-
if isinstance(raw_value, str) and raw_value.strip():
|
|
310
|
-
raw_candidates.append(raw_value)
|
|
311
|
-
elif isinstance(raw_value, (dict, list)):
|
|
312
|
-
with contextlib.suppress(Exception):
|
|
313
|
-
raw_candidates.append(json.dumps(raw_value, ensure_ascii=False))
|
|
314
|
-
for arg in getattr(exc, "args", ()) or ():
|
|
315
|
-
if isinstance(arg, str) and ("{" in arg and "}" in arg):
|
|
316
|
-
raw_candidates.append(arg)
|
|
317
|
-
elif isinstance(arg, (dict, list)):
|
|
318
|
-
with contextlib.suppress(Exception):
|
|
319
|
-
raw_candidates.append(json.dumps(arg, ensure_ascii=False))
|
|
320
|
-
cause = getattr(exc, "__cause__", None)
|
|
321
|
-
if cause is not None:
|
|
322
|
-
for attr_name in ("body", "response"):
|
|
323
|
-
raw_value = getattr(cause, attr_name, None)
|
|
324
|
-
if isinstance(raw_value, str) and raw_value.strip():
|
|
325
|
-
raw_candidates.append(raw_value)
|
|
326
|
-
elif isinstance(raw_value, (dict, list)):
|
|
327
|
-
with contextlib.suppress(Exception):
|
|
328
|
-
raw_candidates.append(json.dumps(raw_value, ensure_ascii=False))
|
|
329
|
-
for arg in getattr(cause, "args", ()) or ():
|
|
330
|
-
if isinstance(arg, str) and ("{" in arg and "}" in arg):
|
|
331
|
-
raw_candidates.append(arg)
|
|
332
|
-
elif isinstance(arg, (dict, list)):
|
|
333
|
-
with contextlib.suppress(Exception):
|
|
334
|
-
raw_candidates.append(json.dumps(arg, ensure_ascii=False))
|
|
335
|
-
|
|
336
|
-
seen: set[str] = set()
|
|
337
|
-
all_json_objects: list[str] = []
|
|
338
|
-
for raw in raw_candidates:
|
|
339
|
-
for candidate in self._extract_json_object_candidates(raw):
|
|
340
|
-
normalized = candidate.strip()
|
|
341
|
-
if not normalized or normalized in seen:
|
|
342
|
-
continue
|
|
343
|
-
seen.add(normalized)
|
|
344
|
-
all_json_objects.append(normalized)
|
|
345
|
-
|
|
346
|
-
for candidate in reversed(all_json_objects):
|
|
347
|
-
try:
|
|
348
|
-
parsed = json.loads(candidate)
|
|
349
|
-
except Exception:
|
|
350
|
-
continue
|
|
351
|
-
validator = getattr(result_type, "model_validate", None)
|
|
352
|
-
if not callable(validator):
|
|
353
|
-
continue
|
|
354
|
-
try:
|
|
355
|
-
return validator(parsed)
|
|
356
|
-
except Exception:
|
|
357
|
-
continue
|
|
358
|
-
return None
|
|
359
|
-
|
|
360
|
-
def _resolve_agent_timeout_policy(self, complexity: str) -> AgentTimeoutPolicy:
|
|
361
|
-
"""Resolve timeout policy from config/settings with complexity-aware scaling."""
|
|
362
|
-
|
|
363
|
-
def _to_float(raw: Any, default: float, minimum: float) -> float:
|
|
364
|
-
try:
|
|
365
|
-
value = float(raw)
|
|
366
|
-
except (TypeError, ValueError):
|
|
367
|
-
value = default
|
|
368
|
-
return max(value, minimum)
|
|
369
|
-
|
|
370
|
-
def _to_int(raw: Any, default: int, minimum: int) -> int:
|
|
371
|
-
try:
|
|
372
|
-
value = int(raw)
|
|
373
|
-
except (TypeError, ValueError):
|
|
374
|
-
value = default
|
|
375
|
-
return max(value, minimum)
|
|
376
|
-
|
|
377
|
-
factor = self._complexity_timeout_factor(complexity)
|
|
378
|
-
base_timeout = _to_float(getattr(self.settings, "agent_timeout_seconds", 600.0), 600.0, 30.0)
|
|
379
|
-
max_timeout = _to_float(getattr(self.settings, "agent_timeout_max_seconds", 1800.0), 1800.0, 60.0)
|
|
380
|
-
extension_seconds = _to_float(
|
|
381
|
-
getattr(self.settings, "agent_timeout_extension_seconds", 300.0),
|
|
382
|
-
300.0,
|
|
383
|
-
0.0,
|
|
384
|
-
)
|
|
385
|
-
extension_attempts = _to_int(
|
|
386
|
-
getattr(self.settings, "agent_timeout_extension_attempts", 3),
|
|
387
|
-
3,
|
|
388
|
-
0,
|
|
389
|
-
)
|
|
390
|
-
heartbeat_seconds = _to_float(
|
|
391
|
-
getattr(self.settings, "agent_timeout_heartbeat_seconds", 30.0),
|
|
392
|
-
30.0,
|
|
393
|
-
5.0,
|
|
394
|
-
)
|
|
395
|
-
idle_post_tool_seconds = _to_float(
|
|
396
|
-
getattr(self.settings, "agent_idle_timeout_seconds", 180.0),
|
|
397
|
-
180.0,
|
|
398
|
-
30.0,
|
|
399
|
-
)
|
|
400
|
-
lease_window_seconds = _to_float(
|
|
401
|
-
getattr(self.settings, "row_progress_lease_seconds", 0.0),
|
|
402
|
-
0.0,
|
|
403
|
-
0.0,
|
|
404
|
-
)
|
|
405
|
-
stall_detection_seconds = _to_float(
|
|
406
|
-
getattr(self.settings, "row_stall_detection_seconds", idle_post_tool_seconds),
|
|
407
|
-
idle_post_tool_seconds,
|
|
408
|
-
1.0,
|
|
409
|
-
)
|
|
410
|
-
absolute_timeout_seconds = _to_float(
|
|
411
|
-
float(getattr(self.settings, "row_absolute_timeout_ms", 600_000)) / 1000.0,
|
|
412
|
-
600.0,
|
|
413
|
-
1.0,
|
|
414
|
-
)
|
|
415
|
-
|
|
416
|
-
initial_timeout = max(30.0, base_timeout * factor)
|
|
417
|
-
max_timeout = max(max_timeout, initial_timeout)
|
|
418
|
-
if lease_window_seconds > 0:
|
|
419
|
-
initial_timeout = min(initial_timeout, lease_window_seconds)
|
|
420
|
-
max_timeout = min(max_timeout, absolute_timeout_seconds)
|
|
421
|
-
max_timeout = max(max_timeout, initial_timeout)
|
|
422
|
-
stall_detection_seconds = min(stall_detection_seconds, lease_window_seconds)
|
|
423
|
-
return AgentTimeoutPolicy(
|
|
424
|
-
initial_timeout_seconds=initial_timeout,
|
|
425
|
-
max_timeout_seconds=max_timeout,
|
|
426
|
-
extension_seconds=extension_seconds,
|
|
427
|
-
extension_attempts=extension_attempts,
|
|
428
|
-
heartbeat_seconds=heartbeat_seconds,
|
|
429
|
-
idle_post_tool_seconds=idle_post_tool_seconds,
|
|
430
|
-
lease_window_seconds=lease_window_seconds,
|
|
431
|
-
stall_detection_seconds=stall_detection_seconds,
|
|
432
|
-
absolute_timeout_seconds=absolute_timeout_seconds,
|
|
433
|
-
)
|
|
434
|
-
|
|
435
|
-
def _resolve_pydantic_usage_limits(
|
|
436
|
-
self,
|
|
437
|
-
*,
|
|
438
|
-
max_turns: int | None,
|
|
439
|
-
max_tool_calls: int | None,
|
|
440
|
-
) -> tuple[int | None, int | None]:
|
|
441
|
-
"""Resolve request/tool usage limits for PydanticAI runs.
|
|
442
|
-
|
|
443
|
-
Request limit must not be lower than the tool-call budget, otherwise
|
|
444
|
-
heavily agentic runs may hit `request_limit` before consuming
|
|
445
|
-
`tool_calls_limit`.
|
|
446
|
-
"""
|
|
447
|
-
normalized_tool_calls = max_tool_calls
|
|
448
|
-
if normalized_tool_calls is not None:
|
|
449
|
-
normalized_tool_calls = int(normalized_tool_calls)
|
|
450
|
-
# Preserve explicit zero-tool mode (`max_tool_calls=0`) so
|
|
451
|
-
# synthesis retries cannot accidentally invoke tools again.
|
|
452
|
-
if normalized_tool_calls < 0:
|
|
453
|
-
normalized_tool_calls = None
|
|
454
|
-
|
|
455
|
-
# Zero-tool mode is used by docs/security prompt-fed execution paths to
|
|
456
|
-
# explicitly disallow tools. In this mode, applying a tiny request_limit
|
|
457
|
-
# floor (2) can preempt normal output validation retries and causes
|
|
458
|
-
# avoidable "request_limit exceeded" failures.
|
|
459
|
-
if max_turns is None and normalized_tool_calls is None:
|
|
460
|
-
return None, None
|
|
461
|
-
|
|
462
|
-
request_limit = max_turns
|
|
463
|
-
if normalized_tool_calls is not None and normalized_tool_calls > 0:
|
|
464
|
-
tool_driven_request_floor = normalized_tool_calls + 2
|
|
465
|
-
request_limit = max(request_limit or 0, tool_driven_request_floor)
|
|
466
|
-
|
|
467
|
-
return request_limit, normalized_tool_calls
|
|
468
|
-
|
|
469
|
-
def _is_trace_payload_enabled(self) -> bool:
|
|
470
|
-
"""Return True when payload-level diagnostics should be emitted."""
|
|
471
|
-
if bool(getattr(self.settings, "agent_trace_payload_enabled", False)):
|
|
472
|
-
return True
|
|
473
|
-
try:
|
|
474
|
-
from vds_audit_orchestrator.logging_config import is_trace_mode_enabled
|
|
475
|
-
|
|
476
|
-
return bool(is_trace_mode_enabled())
|
|
477
|
-
except Exception:
|
|
478
|
-
return False
|
|
479
|
-
|
|
480
|
-
def _trace_payload_max_chars(self) -> int:
|
|
481
|
-
raw = getattr(self.settings, "agent_trace_payload_max_chars", 20_000)
|
|
482
|
-
try:
|
|
483
|
-
value = int(raw)
|
|
484
|
-
except (TypeError, ValueError):
|
|
485
|
-
value = 20_000
|
|
486
|
-
return max(1, min(value, 200_000))
|
|
487
|
-
|
|
488
|
-
@staticmethod
|
|
489
|
-
def _redact_trace_text(value: str) -> str:
|
|
490
|
-
redacted = re.sub(r"(?i)(api[_-]?key|token|password|secret)\s*[:=]\s*([^\s,;]+)", r"\1=[REDACTED]", value)
|
|
491
|
-
redacted = re.sub(r"(?i)(authorization)\s*[:=]\s*(bearer\s+)?[^\s,;]+", r"\1=[REDACTED]", redacted)
|
|
492
|
-
return redacted
|
|
493
|
-
|
|
494
|
-
def _sanitize_trace_payload(self, payload: Any, *, depth: int = 0) -> Any:
|
|
495
|
-
"""Return bounded trace payload data safe for structured logs."""
|
|
496
|
-
max_chars = self._trace_payload_max_chars()
|
|
497
|
-
if depth > 10:
|
|
498
|
-
return "...(trace-depth-limit)"
|
|
499
|
-
if isinstance(payload, str):
|
|
500
|
-
text = self._redact_trace_text(payload)
|
|
501
|
-
return text[:max_chars] + "...(truncated)" if len(text) > max_chars else text
|
|
502
|
-
if isinstance(payload, (int, float, bool)) or payload is None:
|
|
503
|
-
return payload
|
|
504
|
-
if isinstance(payload, list):
|
|
505
|
-
trimmed = payload[:100]
|
|
506
|
-
result = [self._sanitize_trace_payload(item, depth=depth + 1) for item in trimmed]
|
|
507
|
-
if len(payload) > len(trimmed):
|
|
508
|
-
result.append(f"...(truncated {len(payload) - len(trimmed)} items)")
|
|
509
|
-
return result
|
|
510
|
-
if isinstance(payload, tuple):
|
|
511
|
-
return self._sanitize_trace_payload(list(payload), depth=depth + 1)
|
|
512
|
-
if isinstance(payload, dict):
|
|
513
|
-
result: dict[str, Any] = {}
|
|
514
|
-
items = list(payload.items())
|
|
515
|
-
for key, value in items[:100]:
|
|
516
|
-
key_text = str(key)
|
|
517
|
-
if re.search(r"(?i)(password|secret|token|api[_-]?key|authorization)", key_text):
|
|
518
|
-
result[key_text] = "[REDACTED]"
|
|
519
|
-
else:
|
|
520
|
-
result[key_text] = self._sanitize_trace_payload(value, depth=depth + 1)
|
|
521
|
-
if len(items) > 100:
|
|
522
|
-
result["__truncated_items__"] = len(items) - 100
|
|
523
|
-
return result
|
|
524
|
-
return self._sanitize_trace_payload(str(payload), depth=depth + 1)
|
|
525
|
-
|
|
526
|
-
@staticmethod
|
|
527
|
-
def _serialize_skill_policy_drop(item: Any) -> dict[str, Any] | None:
|
|
528
|
-
skill_name = str(getattr(item, "skill_name", "") or "").strip()
|
|
529
|
-
reason = str(getattr(item, "reason", "") or "").strip()
|
|
530
|
-
if not skill_name and not reason:
|
|
531
|
-
return None
|
|
532
|
-
payload: dict[str, Any] = {
|
|
533
|
-
"skill_name": skill_name or "unknown",
|
|
534
|
-
"reason": reason or "unknown",
|
|
535
|
-
}
|
|
536
|
-
for field_name in ("metadata_name", "frontmatter_name", "runtime_name", "detail"):
|
|
537
|
-
raw_value = getattr(item, field_name, None)
|
|
538
|
-
if isinstance(raw_value, str):
|
|
539
|
-
value = raw_value.strip()
|
|
540
|
-
if value:
|
|
541
|
-
payload[field_name] = value
|
|
542
|
-
elif raw_value is not None:
|
|
543
|
-
payload[field_name] = str(raw_value)
|
|
544
|
-
return payload
|
|
545
|
-
|
|
546
|
-
def _collect_skill_policy_diagnostics(self, toolsets: list[Any] | None) -> dict[str, Any] | None:
|
|
547
|
-
"""Collect operator-facing skill-policy diagnostics from attached toolsets."""
|
|
548
|
-
if not toolsets:
|
|
549
|
-
return None
|
|
550
|
-
try:
|
|
551
|
-
from vds_audit_orchestrator.agents.toolsets.skills_toolset import get_toolset_policy_diagnostics
|
|
552
|
-
except Exception:
|
|
553
|
-
return None
|
|
554
|
-
|
|
555
|
-
metadata_count = 0
|
|
556
|
-
policy_eligible_count = 0
|
|
557
|
-
runtime_loaded_count = 0
|
|
558
|
-
blocked_tools: list[str] = []
|
|
559
|
-
drop_reasons: list[dict[str, Any]] = []
|
|
560
|
-
toolset_details: list[dict[str, Any]] = []
|
|
561
|
-
|
|
562
|
-
for index, toolset in enumerate(toolsets):
|
|
563
|
-
diagnostics = get_toolset_policy_diagnostics(toolset)
|
|
564
|
-
if diagnostics is None:
|
|
565
|
-
continue
|
|
566
|
-
|
|
567
|
-
toolset_metadata_count = int(getattr(diagnostics, "metadata_count", 0) or 0)
|
|
568
|
-
toolset_policy_eligible_count = int(getattr(diagnostics, "policy_eligible_count", 0) or 0)
|
|
569
|
-
toolset_runtime_loaded_count = int(getattr(diagnostics, "runtime_loaded_count", 0) or 0)
|
|
570
|
-
toolset_blocked_tools = [
|
|
571
|
-
str(name).strip() for name in (getattr(diagnostics, "blocked_tools", []) or []) if str(name).strip()
|
|
572
|
-
]
|
|
573
|
-
toolset_drop_reasons: list[dict[str, Any]] = []
|
|
574
|
-
for drop in getattr(diagnostics, "dropped", []) or []:
|
|
575
|
-
serialized = self._serialize_skill_policy_drop(drop)
|
|
576
|
-
if serialized is None:
|
|
577
|
-
continue
|
|
578
|
-
toolset_drop_reasons.append(serialized)
|
|
579
|
-
drop_reasons.append(dict(serialized))
|
|
580
|
-
|
|
581
|
-
metadata_count += toolset_metadata_count
|
|
582
|
-
policy_eligible_count += toolset_policy_eligible_count
|
|
583
|
-
runtime_loaded_count += toolset_runtime_loaded_count
|
|
584
|
-
for blocked in toolset_blocked_tools:
|
|
585
|
-
if blocked not in blocked_tools:
|
|
586
|
-
blocked_tools.append(blocked)
|
|
587
|
-
toolset_details.append(
|
|
588
|
-
{
|
|
589
|
-
"toolset_index": index,
|
|
590
|
-
"metadata_count": toolset_metadata_count,
|
|
591
|
-
"policy_eligible_count": toolset_policy_eligible_count,
|
|
592
|
-
"runtime_loaded_count": toolset_runtime_loaded_count,
|
|
593
|
-
"blocked_tools": toolset_blocked_tools,
|
|
594
|
-
"drop_reasons": toolset_drop_reasons,
|
|
595
|
-
}
|
|
596
|
-
)
|
|
597
|
-
|
|
598
|
-
if not toolset_details:
|
|
599
|
-
return None
|
|
600
|
-
return {
|
|
601
|
-
"toolset_count": len(toolset_details),
|
|
602
|
-
"metadata_count": metadata_count,
|
|
603
|
-
"policy_eligible_count": policy_eligible_count,
|
|
604
|
-
"runtime_loaded_count": runtime_loaded_count,
|
|
605
|
-
"blocked_tools": blocked_tools,
|
|
606
|
-
"drop_reasons": drop_reasons,
|
|
607
|
-
"toolsets": toolset_details,
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
@staticmethod
|
|
611
|
-
def _create_skill_policy_enforcer(
|
|
612
|
-
*,
|
|
613
|
-
skills_needed: bool | None = None,
|
|
614
|
-
mode_override: str | None = None,
|
|
615
|
-
interpretation: dict[str, Any] | None = None,
|
|
616
|
-
) -> Any:
|
|
617
|
-
"""Create a SkillPolicyEnforcer from row-level inputs (FR-194..FR-198).
|
|
618
|
-
|
|
619
|
-
Returns the enforcer instance or None if the module is unavailable.
|
|
620
|
-
"""
|
|
621
|
-
try:
|
|
622
|
-
from vds_agent_core.skills.policy import (
|
|
623
|
-
SkillPolicyEnforcer,
|
|
624
|
-
resolve_skill_policy_mode,
|
|
625
|
-
)
|
|
626
|
-
except Exception:
|
|
627
|
-
return None
|
|
628
|
-
|
|
629
|
-
mode = resolve_skill_policy_mode(
|
|
630
|
-
skills_needed=skills_needed,
|
|
631
|
-
mode_override=mode_override,
|
|
632
|
-
interpretation=interpretation,
|
|
633
|
-
)
|
|
634
|
-
effective_skills_needed = skills_needed if skills_needed is not None else True
|
|
635
|
-
if isinstance(interpretation, dict) and interpretation.get("skills_needed") is False:
|
|
636
|
-
effective_skills_needed = False
|
|
637
|
-
return SkillPolicyEnforcer(mode=mode, skills_needed=effective_skills_needed)
|
|
638
|
-
|
|
639
|
-
def _log_trace_payload(
|
|
640
|
-
self,
|
|
641
|
-
*,
|
|
642
|
-
event_name: str,
|
|
643
|
-
elapsed_sec: float,
|
|
644
|
-
payload: dict[str, Any],
|
|
645
|
-
) -> None:
|
|
646
|
-
"""Log payload-level diagnostics when trace mode is enabled."""
|
|
647
|
-
if not self._is_trace_payload_enabled():
|
|
648
|
-
return
|
|
649
|
-
self.logger.info(
|
|
650
|
-
event_name,
|
|
651
|
-
elapsed_sec=round(elapsed_sec, 2),
|
|
652
|
-
payload=self._sanitize_trace_payload(payload),
|
|
653
|
-
)
|
|
654
|
-
|
|
655
|
-
def _exception_diagnostics(self, exc: Exception) -> dict[str, Any]:
|
|
656
|
-
"""Extract compact diagnostics for model/runtime exceptions."""
|
|
657
|
-
details: dict[str, Any] = {
|
|
658
|
-
"error_type": type(exc).__name__,
|
|
659
|
-
"error": str(exc),
|
|
660
|
-
}
|
|
661
|
-
body = getattr(exc, "body", None)
|
|
662
|
-
if isinstance(body, str) and body.strip():
|
|
663
|
-
details["error_body_preview"] = body[:4000]
|
|
664
|
-
|
|
665
|
-
cause = getattr(exc, "__cause__", None)
|
|
666
|
-
if cause is not None:
|
|
667
|
-
details["cause_type"] = type(cause).__name__
|
|
668
|
-
details["cause_message"] = str(cause)[:2000]
|
|
669
|
-
cause_body = getattr(cause, "body", None)
|
|
670
|
-
if isinstance(cause_body, str) and cause_body.strip():
|
|
671
|
-
details["cause_body_preview"] = cause_body[:4000]
|
|
672
|
-
return details
|
|
673
|
-
|
|
674
|
-
@staticmethod
|
|
675
|
-
def _complexity_timeout_factor(complexity: str) -> float:
|
|
676
|
-
"""Map request complexity to timeout multiplier."""
|
|
677
|
-
normalized = complexity.strip().lower()
|
|
678
|
-
if normalized in {"simple", "low"}:
|
|
679
|
-
return 0.75
|
|
680
|
-
if normalized in {"complex", "high"}:
|
|
681
|
-
return 1.5
|
|
682
|
-
if normalized in {"critical"}:
|
|
683
|
-
return 2.0
|
|
684
|
-
return 1.0
|
|
685
|
-
|
|
686
|
-
@staticmethod
|
|
687
|
-
def _timeout_progress_snapshot(run_telemetry: dict[str, Any] | None) -> dict[str, float]:
|
|
688
|
-
"""Extract a compact timeout-progress snapshot from runtime telemetry."""
|
|
689
|
-
snapshot: dict[str, float] = {
|
|
690
|
-
"event_last_seen_at": 0.0,
|
|
691
|
-
"event_tool_calls_started": 0.0,
|
|
692
|
-
"event_tool_calls_completed": 0.0,
|
|
693
|
-
"event_tool_effective_calls": 0.0,
|
|
694
|
-
"event_skill_execution_effective_tool_calls": 0.0,
|
|
695
|
-
"event_turn_index": 0.0,
|
|
696
|
-
"evidence_refs_count": 0.0,
|
|
697
|
-
"steps_executed": 0.0,
|
|
698
|
-
"steps_unique_tools": 0.0,
|
|
699
|
-
}
|
|
700
|
-
if not isinstance(run_telemetry, dict):
|
|
701
|
-
return snapshot
|
|
702
|
-
|
|
703
|
-
for key in ("event_last_seen_at",):
|
|
704
|
-
raw = run_telemetry.get(key)
|
|
705
|
-
if isinstance(raw, int | float):
|
|
706
|
-
snapshot[key] = float(raw)
|
|
707
|
-
|
|
708
|
-
for key in (
|
|
709
|
-
"event_tool_calls_started",
|
|
710
|
-
"event_tool_calls_completed",
|
|
711
|
-
"event_tool_effective_calls",
|
|
712
|
-
"event_skill_execution_effective_tool_calls",
|
|
713
|
-
"event_turn_index",
|
|
714
|
-
"evidence_refs_count",
|
|
715
|
-
"steps_executed",
|
|
716
|
-
"steps_unique_tools",
|
|
717
|
-
):
|
|
718
|
-
raw = run_telemetry.get(key, 0)
|
|
719
|
-
if isinstance(raw, int | float):
|
|
720
|
-
snapshot[key] = float(max(0, int(raw)))
|
|
721
|
-
return snapshot
|
|
722
|
-
|
|
723
|
-
@staticmethod
|
|
724
|
-
def _timeout_progress_signal_type(
|
|
725
|
-
previous_snapshot: dict[str, float] | None,
|
|
726
|
-
current_snapshot: dict[str, float] | None,
|
|
727
|
-
) -> str | None:
|
|
728
|
-
"""Return the dominant progress signal since the previous snapshot."""
|
|
729
|
-
if not isinstance(previous_snapshot, dict) or not isinstance(current_snapshot, dict):
|
|
730
|
-
return None
|
|
731
|
-
if current_snapshot.get("event_last_seen_at", 0.0) > previous_snapshot.get("event_last_seen_at", 0.0):
|
|
732
|
-
return "event_stream"
|
|
733
|
-
for key, signal_type in (
|
|
734
|
-
("event_tool_calls_started", "tool_call_started"),
|
|
735
|
-
("event_tool_calls_completed", "tool_call_completed"),
|
|
736
|
-
("event_tool_effective_calls", "tool_effective"),
|
|
737
|
-
("event_skill_execution_effective_tool_calls", "skill_effective"),
|
|
738
|
-
("event_turn_index", "partial_output"),
|
|
739
|
-
("evidence_refs_count", "evidence_growth"),
|
|
740
|
-
("steps_executed", "route_transition"),
|
|
741
|
-
("steps_unique_tools", "route_transition"),
|
|
742
|
-
):
|
|
743
|
-
if current_snapshot.get(key, 0.0) > previous_snapshot.get(key, 0.0):
|
|
744
|
-
return signal_type
|
|
745
|
-
return None
|
|
746
|
-
|
|
747
|
-
@staticmethod
|
|
748
|
-
def _timeout_progress_observed_since(
|
|
749
|
-
previous_snapshot: dict[str, float] | None,
|
|
750
|
-
current_snapshot: dict[str, float] | None,
|
|
751
|
-
) -> bool:
|
|
752
|
-
"""Return True when runtime telemetry shows forward progress since snapshot."""
|
|
753
|
-
if not isinstance(previous_snapshot, dict) or not isinstance(current_snapshot, dict):
|
|
754
|
-
return False
|
|
755
|
-
|
|
756
|
-
if current_snapshot.get("event_last_seen_at", 0.0) > previous_snapshot.get("event_last_seen_at", 0.0):
|
|
757
|
-
return True
|
|
758
|
-
|
|
759
|
-
for key in (
|
|
760
|
-
"event_tool_calls_started",
|
|
761
|
-
"event_tool_calls_completed",
|
|
762
|
-
"event_tool_effective_calls",
|
|
763
|
-
"event_skill_execution_effective_tool_calls",
|
|
764
|
-
"event_turn_index",
|
|
765
|
-
):
|
|
766
|
-
if current_snapshot.get(key, 0.0) > previous_snapshot.get(key, 0.0):
|
|
767
|
-
return True
|
|
768
|
-
return False
|
|
769
|
-
|
|
770
|
-
async def _run_with_timeout_policy(
|
|
771
|
-
self,
|
|
772
|
-
*,
|
|
773
|
-
operation: Coroutine[Any, Any, ResultType],
|
|
774
|
-
timeout_policy: AgentTimeoutPolicy,
|
|
775
|
-
result_type_name: str,
|
|
776
|
-
run_telemetry: dict[str, Any] | None = None,
|
|
777
|
-
) -> ResultType:
|
|
778
|
-
"""Run awaitable with heartbeat + bounded timeout extensions."""
|
|
779
|
-
import time
|
|
780
|
-
|
|
781
|
-
start_time = time.monotonic()
|
|
782
|
-
timeout_budget = timeout_policy.initial_timeout_seconds
|
|
783
|
-
lease_mode_enabled = timeout_policy.lease_window_seconds > 0
|
|
784
|
-
extensions_used = 0
|
|
785
|
-
last_extension_progress_snapshot = self._timeout_progress_snapshot(run_telemetry)
|
|
786
|
-
previous_heartbeat_snapshot = dict(last_extension_progress_snapshot)
|
|
787
|
-
last_progress_at = start_time
|
|
788
|
-
last_progress_signal_type: str | None = None
|
|
789
|
-
task = asyncio.create_task(operation)
|
|
790
|
-
try:
|
|
791
|
-
while True:
|
|
792
|
-
elapsed = time.monotonic() - start_time
|
|
793
|
-
remaining = timeout_budget - elapsed
|
|
794
|
-
if remaining <= 0:
|
|
795
|
-
current_progress_snapshot = self._timeout_progress_snapshot(run_telemetry)
|
|
796
|
-
progress_since_last_extension = self._timeout_progress_observed_since(
|
|
797
|
-
last_extension_progress_snapshot,
|
|
798
|
-
current_progress_snapshot,
|
|
799
|
-
)
|
|
800
|
-
extension_cap_reached = extensions_used >= timeout_policy.extension_attempts
|
|
801
|
-
if lease_mode_enabled:
|
|
802
|
-
can_extend = (
|
|
803
|
-
progress_since_last_extension and timeout_budget < timeout_policy.max_timeout_seconds
|
|
804
|
-
)
|
|
805
|
-
else:
|
|
806
|
-
can_extend = (
|
|
807
|
-
timeout_policy.extension_seconds > 0
|
|
808
|
-
and (not extension_cap_reached or progress_since_last_extension)
|
|
809
|
-
and timeout_budget < timeout_policy.max_timeout_seconds
|
|
810
|
-
)
|
|
811
|
-
if can_extend:
|
|
812
|
-
increment = min(
|
|
813
|
-
timeout_policy.lease_window_seconds
|
|
814
|
-
if lease_mode_enabled
|
|
815
|
-
else timeout_policy.extension_seconds,
|
|
816
|
-
timeout_policy.max_timeout_seconds - timeout_budget,
|
|
817
|
-
)
|
|
818
|
-
timeout_budget += increment
|
|
819
|
-
extensions_used += 1
|
|
820
|
-
extension_reason = (
|
|
821
|
-
"lease_progress_renewal"
|
|
822
|
-
if lease_mode_enabled
|
|
823
|
-
else (
|
|
824
|
-
"progress_override_extension_cap"
|
|
825
|
-
if extension_cap_reached and progress_since_last_extension
|
|
826
|
-
else "within_extension_cap"
|
|
827
|
-
)
|
|
828
|
-
)
|
|
829
|
-
self.logger.warning(
|
|
830
|
-
"pydantic_agent_timeout_extended",
|
|
831
|
-
result_type=result_type_name,
|
|
832
|
-
timeout_budget_seconds=round(timeout_budget, 2),
|
|
833
|
-
extension_seconds=round(increment, 2),
|
|
834
|
-
extensions_used=extensions_used,
|
|
835
|
-
max_extensions=timeout_policy.extension_attempts,
|
|
836
|
-
extension_cap_reached=extension_cap_reached,
|
|
837
|
-
progress_since_last_extension=progress_since_last_extension,
|
|
838
|
-
extension_reason=extension_reason,
|
|
839
|
-
lease_mode_enabled=lease_mode_enabled,
|
|
840
|
-
)
|
|
841
|
-
last_extension_progress_snapshot = current_progress_snapshot
|
|
842
|
-
last_progress_at = time.monotonic()
|
|
843
|
-
last_progress_signal_type = (
|
|
844
|
-
self._timeout_progress_signal_type(
|
|
845
|
-
previous_heartbeat_snapshot,
|
|
846
|
-
current_progress_snapshot,
|
|
847
|
-
)
|
|
848
|
-
or "lease_renewal"
|
|
849
|
-
)
|
|
850
|
-
continue
|
|
851
|
-
|
|
852
|
-
task.cancel()
|
|
853
|
-
with contextlib.suppress(asyncio.CancelledError):
|
|
854
|
-
await task
|
|
855
|
-
self.logger.error(
|
|
856
|
-
"pydantic_agent_call_timeout",
|
|
857
|
-
result_type=result_type_name,
|
|
858
|
-
timeout_budget_seconds=round(timeout_budget, 2),
|
|
859
|
-
max_timeout_seconds=round(timeout_policy.max_timeout_seconds, 2),
|
|
860
|
-
extensions_used=extensions_used,
|
|
861
|
-
lease_mode_enabled=lease_mode_enabled,
|
|
862
|
-
last_progress_signal_type=last_progress_signal_type,
|
|
863
|
-
)
|
|
864
|
-
raise RuntimeError(
|
|
865
|
-
"PydanticAI agent timed out after "
|
|
866
|
-
f"{timeout_budget:.0f}s (max budget {timeout_policy.max_timeout_seconds:.0f}s)"
|
|
867
|
-
)
|
|
868
|
-
|
|
869
|
-
wait_timeout = min(remaining, timeout_policy.heartbeat_seconds)
|
|
870
|
-
done, _ = await asyncio.wait({task}, timeout=wait_timeout)
|
|
871
|
-
if task in done:
|
|
872
|
-
return await task
|
|
873
|
-
|
|
874
|
-
if isinstance(run_telemetry, dict):
|
|
875
|
-
current_progress_snapshot = self._timeout_progress_snapshot(run_telemetry)
|
|
876
|
-
signal_type = self._timeout_progress_signal_type(
|
|
877
|
-
previous_heartbeat_snapshot, current_progress_snapshot
|
|
878
|
-
)
|
|
879
|
-
if signal_type is not None:
|
|
880
|
-
last_progress_at = time.monotonic()
|
|
881
|
-
last_progress_signal_type = signal_type
|
|
882
|
-
previous_heartbeat_snapshot = current_progress_snapshot
|
|
883
|
-
|
|
884
|
-
if lease_mode_enabled:
|
|
885
|
-
lease_stall_elapsed = time.monotonic() - last_progress_at
|
|
886
|
-
if lease_stall_elapsed >= timeout_policy.stall_detection_seconds:
|
|
887
|
-
task.cancel()
|
|
888
|
-
with contextlib.suppress(asyncio.CancelledError):
|
|
889
|
-
await task
|
|
890
|
-
self.logger.error(
|
|
891
|
-
"pydantic_agent_progress_lease_expired",
|
|
892
|
-
result_type=result_type_name,
|
|
893
|
-
timeout_budget_seconds=round(timeout_budget, 2),
|
|
894
|
-
lease_window_seconds=round(timeout_policy.lease_window_seconds, 2),
|
|
895
|
-
stall_detection_seconds=round(timeout_policy.stall_detection_seconds, 2),
|
|
896
|
-
stall_elapsed_seconds=round(lease_stall_elapsed, 2),
|
|
897
|
-
last_progress_signal_type=last_progress_signal_type,
|
|
898
|
-
)
|
|
899
|
-
raise RuntimeError(
|
|
900
|
-
"PydanticAI agent progress lease expired after "
|
|
901
|
-
f"{lease_stall_elapsed:.0f}s without progress"
|
|
902
|
-
)
|
|
903
|
-
|
|
904
|
-
tool_calls_started = int(run_telemetry.get("event_tool_calls_started", 0) or 0)
|
|
905
|
-
tool_calls_completed = int(
|
|
906
|
-
run_telemetry.get("event_tool_calls_completed", run_telemetry.get("event_tool_calls", 0)) or 0
|
|
907
|
-
)
|
|
908
|
-
tool_activity_count = max(tool_calls_started, tool_calls_completed)
|
|
909
|
-
last_tool_activity_at = run_telemetry.get("event_last_tool_activity_at")
|
|
910
|
-
last_seen_at = run_telemetry.get("event_last_seen_at")
|
|
911
|
-
latest_activity_at: float | None = None
|
|
912
|
-
activity_source = "tool"
|
|
913
|
-
if isinstance(last_tool_activity_at, (int, float)):
|
|
914
|
-
latest_activity_at = float(last_tool_activity_at)
|
|
915
|
-
if isinstance(last_seen_at, (int, float)) and (
|
|
916
|
-
latest_activity_at is None or float(last_seen_at) > latest_activity_at
|
|
917
|
-
):
|
|
918
|
-
latest_activity_at = float(last_seen_at)
|
|
919
|
-
activity_source = "event"
|
|
920
|
-
|
|
921
|
-
if tool_activity_count > 0 and isinstance(latest_activity_at, float):
|
|
922
|
-
stall_elapsed = time.monotonic() - latest_activity_at
|
|
923
|
-
if stall_elapsed >= timeout_policy.idle_post_tool_seconds:
|
|
924
|
-
task.cancel()
|
|
925
|
-
with contextlib.suppress(asyncio.CancelledError):
|
|
926
|
-
await task
|
|
927
|
-
self.logger.error(
|
|
928
|
-
"pydantic_agent_call_stalled",
|
|
929
|
-
result_type=result_type_name,
|
|
930
|
-
timeout_budget_seconds=round(timeout_budget, 2),
|
|
931
|
-
idle_post_tool_seconds=round(timeout_policy.idle_post_tool_seconds, 2),
|
|
932
|
-
stall_elapsed_seconds=round(stall_elapsed, 2),
|
|
933
|
-
tool_calls_started=tool_calls_started,
|
|
934
|
-
tool_calls_completed=tool_calls_completed,
|
|
935
|
-
observed_tool_names=run_telemetry.get("event_tool_names"),
|
|
936
|
-
activity_source=activity_source,
|
|
937
|
-
)
|
|
938
|
-
raise RuntimeError(
|
|
939
|
-
"PydanticAI agent stalled after tool activity "
|
|
940
|
-
f"for {stall_elapsed:.0f}s (idle limit {timeout_policy.idle_post_tool_seconds:.0f}s)"
|
|
941
|
-
)
|
|
942
|
-
tool_count_by_name = run_telemetry.get("event_tool_count_by_name")
|
|
943
|
-
if isinstance(tool_count_by_name, dict) and tool_calls_completed >= 20:
|
|
944
|
-
list_directory_calls = int(tool_count_by_name.get("list_directory", 0) or 0)
|
|
945
|
-
unique_tools = len(tool_count_by_name)
|
|
946
|
-
if list_directory_calls >= 14 and unique_tools <= 3:
|
|
947
|
-
repetition_ratio = list_directory_calls / max(1, tool_calls_completed)
|
|
948
|
-
if repetition_ratio >= 0.7:
|
|
949
|
-
task.cancel()
|
|
950
|
-
with contextlib.suppress(asyncio.CancelledError):
|
|
951
|
-
await task
|
|
952
|
-
self.logger.error(
|
|
953
|
-
"pydantic_agent_list_directory_churn",
|
|
954
|
-
result_type=result_type_name,
|
|
955
|
-
timeout_budget_seconds=round(timeout_budget, 2),
|
|
956
|
-
tool_calls_completed=tool_calls_completed,
|
|
957
|
-
list_directory_calls=list_directory_calls,
|
|
958
|
-
unique_tools=unique_tools,
|
|
959
|
-
repetition_ratio=round(repetition_ratio, 3),
|
|
960
|
-
observed_tool_names=run_telemetry.get("event_tool_names"),
|
|
961
|
-
)
|
|
962
|
-
raise RuntimeError(
|
|
963
|
-
"PydanticAI agent detected list_directory churn "
|
|
964
|
-
f"({list_directory_calls}/{tool_calls_completed} calls)"
|
|
965
|
-
)
|
|
966
|
-
|
|
967
|
-
self.logger.info(
|
|
968
|
-
"pydantic_agent_call_heartbeat",
|
|
969
|
-
result_type=result_type_name,
|
|
970
|
-
elapsed_seconds=round(time.monotonic() - start_time, 2),
|
|
971
|
-
remaining_seconds=round(max(0.0, timeout_budget - (time.monotonic() - start_time)), 2),
|
|
972
|
-
timeout_budget_seconds=round(timeout_budget, 2),
|
|
973
|
-
extensions_used=extensions_used,
|
|
974
|
-
lease_mode_enabled=lease_mode_enabled,
|
|
975
|
-
lease_window_seconds=round(timeout_policy.lease_window_seconds, 2) if lease_mode_enabled else 0.0,
|
|
976
|
-
last_progress_signal_type=last_progress_signal_type,
|
|
977
|
-
)
|
|
978
|
-
except asyncio.CancelledError:
|
|
979
|
-
task.cancel()
|
|
980
|
-
with contextlib.suppress(asyncio.CancelledError):
|
|
981
|
-
await task
|
|
982
|
-
raise
|
|
983
|
-
|
|
984
|
-
def _merge_failover_telemetry(
|
|
985
|
-
self,
|
|
986
|
-
primary: dict[str, Any] | None,
|
|
987
|
-
secondary: dict[str, Any] | None,
|
|
988
|
-
) -> dict[str, Any]:
|
|
989
|
-
merged = dict(primary or {})
|
|
990
|
-
fallback = dict(secondary or {})
|
|
991
|
-
if not merged:
|
|
992
|
-
return fallback
|
|
993
|
-
for key in (
|
|
994
|
-
"provider_failover_attempted",
|
|
995
|
-
"provider_failover_reason",
|
|
996
|
-
"provider_failover_final_provider",
|
|
997
|
-
"provider_failover_original_provider",
|
|
998
|
-
"provider_failover_profiles_considered",
|
|
999
|
-
"provider_retry_class",
|
|
1000
|
-
"provider_retry_reason",
|
|
1001
|
-
"retry_after_honored",
|
|
1002
|
-
"retry_after_seconds",
|
|
1003
|
-
"timeout_kind",
|
|
1004
|
-
):
|
|
1005
|
-
if key in fallback:
|
|
1006
|
-
merged[key] = fallback[key]
|
|
1007
|
-
primary_chain = list(merged.get("provider_failover_chain") or [])
|
|
1008
|
-
for item in list(fallback.get("provider_failover_chain") or []):
|
|
1009
|
-
normalized = str(item or "").strip()
|
|
1010
|
-
if normalized and normalized not in primary_chain:
|
|
1011
|
-
primary_chain.append(normalized)
|
|
1012
|
-
if primary_chain:
|
|
1013
|
-
merged["provider_failover_chain"] = primary_chain
|
|
1014
|
-
merged["provider_transient_retry_count"] = max(
|
|
1015
|
-
int(merged.get("provider_transient_retry_count", 0) or 0),
|
|
1016
|
-
int(fallback.get("provider_transient_retry_count", 0) or 0),
|
|
1017
|
-
)
|
|
1018
|
-
merged["provider_failover_hops"] = max(
|
|
1019
|
-
int(merged.get("provider_failover_hops", 0) or 0),
|
|
1020
|
-
int(fallback.get("provider_failover_hops", 0) or 0),
|
|
1021
|
-
)
|
|
1022
|
-
if "provider_failover_profiles_considered" in merged:
|
|
1023
|
-
max_provider_hops = max(0, int(getattr(self.settings, "row_failover_max_provider_hops", 2) or 0))
|
|
1024
|
-
merged["provider_failover_profiles_considered"] = truncate_failover_profiles_considered(
|
|
1025
|
-
merged.get("provider_failover_profiles_considered"),
|
|
1026
|
-
max_provider_hops=max_provider_hops,
|
|
1027
|
-
)
|
|
1028
|
-
return merged
|
|
1029
|
-
|
|
1030
|
-
async def _attempt_row_provider_failover(
|
|
1031
|
-
self,
|
|
1032
|
-
*,
|
|
1033
|
-
exc: Exception,
|
|
1034
|
-
system_prompt: str,
|
|
1035
|
-
user_prompt: str,
|
|
1036
|
-
result_type: type[ResultType],
|
|
1037
|
-
complexity: str,
|
|
1038
|
-
max_tokens: int,
|
|
1039
|
-
prompt_type: str,
|
|
1040
|
-
deps: Any | None,
|
|
1041
|
-
toolsets: list[Any] | None,
|
|
1042
|
-
max_turns: int | None,
|
|
1043
|
-
max_tool_calls: int | None,
|
|
1044
|
-
pre_retry_telemetry: dict[str, Any] | None,
|
|
1045
|
-
current_run_telemetry: dict[str, Any] | None,
|
|
1046
|
-
row_failover_context: RowFailoverContext | None,
|
|
1047
|
-
provider_health_memory: ProviderHealthMemory,
|
|
1048
|
-
) -> ResultType | None:
|
|
1049
|
-
classification = ProviderFailureClassifier.classify(exc)
|
|
1050
|
-
if not classification.is_failoverable:
|
|
1051
|
-
return None
|
|
1052
|
-
|
|
1053
|
-
configured_profiles = self._resolve_row_failover_profiles()
|
|
1054
|
-
if not configured_profiles:
|
|
1055
|
-
return None
|
|
1056
|
-
|
|
1057
|
-
max_hops = max(0, int(getattr(self.settings, "row_failover_max_provider_hops", 2) or 0))
|
|
1058
|
-
if max_hops <= 0:
|
|
1059
|
-
return None
|
|
1060
|
-
|
|
1061
|
-
current_provider = self._provider_identity()
|
|
1062
|
-
failover_context = row_failover_context or RowFailoverContext(
|
|
1063
|
-
row_id=str(getattr(deps, "project_id", "") or ""),
|
|
1064
|
-
check_id=prompt_type,
|
|
1065
|
-
original_provider=current_provider,
|
|
1066
|
-
failover_chain=[current_provider],
|
|
1067
|
-
)
|
|
1068
|
-
failover_context = truncate_row_failover_context(
|
|
1069
|
-
failover_context,
|
|
1070
|
-
max_provider_hops=max_hops,
|
|
1071
|
-
)
|
|
1072
|
-
considered_profiles = truncate_failover_profiles_considered(
|
|
1073
|
-
configured_profiles,
|
|
1074
|
-
max_provider_hops=max_hops,
|
|
1075
|
-
)
|
|
1076
|
-
if failover_context.failover_count >= max_hops:
|
|
1077
|
-
if current_run_telemetry is not None:
|
|
1078
|
-
current_run_telemetry["provider_failover_attempted"] = True
|
|
1079
|
-
current_run_telemetry["provider_failover_chain"] = list(failover_context.failover_chain or [])
|
|
1080
|
-
current_run_telemetry["provider_failover_final_provider"] = current_provider
|
|
1081
|
-
current_run_telemetry["provider_failover_original_provider"] = (
|
|
1082
|
-
failover_context.original_provider or current_provider
|
|
1083
|
-
)
|
|
1084
|
-
current_run_telemetry["provider_failover_profiles_considered"] = list(considered_profiles)
|
|
1085
|
-
current_run_telemetry["provider_failover_reason"] = classification.classification_reason
|
|
1086
|
-
current_run_telemetry["provider_failover_hops"] = int(failover_context.failover_count)
|
|
1087
|
-
current_run_telemetry["timeout_kind"] = TimeoutKind.TIMEOUT_FAILOVER_EXHAUSTED.value
|
|
1088
|
-
return None
|
|
1089
|
-
|
|
1090
|
-
next_profile: str | None = None
|
|
1091
|
-
for candidate in configured_profiles:
|
|
1092
|
-
if candidate == current_provider or candidate in failover_context.failover_chain:
|
|
1093
|
-
continue
|
|
1094
|
-
if provider_health_memory.should_skip_provider(candidate):
|
|
1095
|
-
continue
|
|
1096
|
-
next_profile = candidate
|
|
1097
|
-
break
|
|
1098
|
-
if next_profile is None:
|
|
1099
|
-
if current_run_telemetry is not None:
|
|
1100
|
-
current_run_telemetry["provider_failover_attempted"] = True
|
|
1101
|
-
current_run_telemetry["provider_failover_chain"] = list(failover_context.failover_chain or [])
|
|
1102
|
-
current_run_telemetry["provider_failover_final_provider"] = current_provider
|
|
1103
|
-
current_run_telemetry["provider_failover_original_provider"] = (
|
|
1104
|
-
failover_context.original_provider or current_provider
|
|
1105
|
-
)
|
|
1106
|
-
current_run_telemetry["provider_failover_profiles_considered"] = list(considered_profiles)
|
|
1107
|
-
current_run_telemetry["provider_failover_reason"] = classification.classification_reason
|
|
1108
|
-
current_run_telemetry["provider_failover_hops"] = int(failover_context.failover_count)
|
|
1109
|
-
current_run_telemetry["timeout_kind"] = TimeoutKind.TIMEOUT_FAILOVER_EXHAUSTED.value
|
|
1110
|
-
return None
|
|
1111
|
-
|
|
1112
|
-
provider_health_memory.total_hops += 1
|
|
1113
|
-
next_context = RowFailoverContext(
|
|
1114
|
-
row_id=failover_context.row_id,
|
|
1115
|
-
check_id=failover_context.check_id,
|
|
1116
|
-
evidence_refs=list(failover_context.evidence_refs or []),
|
|
1117
|
-
route_state=dict(failover_context.route_state or {}),
|
|
1118
|
-
partial_progress=dict(failover_context.partial_progress or {}),
|
|
1119
|
-
original_provider=failover_context.original_provider or current_provider,
|
|
1120
|
-
failover_count=int(failover_context.failover_count) + 1,
|
|
1121
|
-
failover_chain=[*list(failover_context.failover_chain or []), next_profile],
|
|
1122
|
-
timeout_telemetry_snapshot=dict(failover_context.timeout_telemetry_snapshot or {}),
|
|
1123
|
-
)
|
|
1124
|
-
next_context = truncate_row_failover_context(next_context, max_provider_hops=max_hops)
|
|
1125
|
-
|
|
1126
|
-
if current_run_telemetry is not None:
|
|
1127
|
-
current_run_telemetry["provider_failover_attempted"] = True
|
|
1128
|
-
current_run_telemetry["provider_failover_chain"] = list(next_context.failover_chain)
|
|
1129
|
-
current_run_telemetry["provider_failover_final_provider"] = next_profile
|
|
1130
|
-
current_run_telemetry["provider_failover_original_provider"] = (
|
|
1131
|
-
next_context.original_provider or current_provider
|
|
1132
|
-
)
|
|
1133
|
-
current_run_telemetry["provider_failover_profiles_considered"] = list(considered_profiles)
|
|
1134
|
-
current_run_telemetry["provider_failover_reason"] = classification.classification_reason
|
|
1135
|
-
current_run_telemetry["provider_failover_hops"] = int(next_context.failover_count)
|
|
1136
|
-
|
|
1137
|
-
self.logger.warning(
|
|
1138
|
-
"pydantic_agent_provider_failover_started",
|
|
1139
|
-
result_type=result_type.__name__,
|
|
1140
|
-
current_provider=current_provider,
|
|
1141
|
-
next_provider=next_profile,
|
|
1142
|
-
failure_class=classification.failure_class.value,
|
|
1143
|
-
reason=classification.classification_reason,
|
|
1144
|
-
failover_count=next_context.failover_count,
|
|
1145
|
-
max_provider_hops=max_hops,
|
|
1146
|
-
)
|
|
1147
|
-
|
|
1148
|
-
fallback_settings = inherit_runtime_llm_policy(next_profile, source_llm=self.settings)
|
|
1149
|
-
with self._temporary_agent_settings(fallback_settings):
|
|
1150
|
-
return await self._run_pydantic_agent(
|
|
1151
|
-
system_prompt=system_prompt,
|
|
1152
|
-
user_prompt=user_prompt,
|
|
1153
|
-
result_type=result_type,
|
|
1154
|
-
complexity=complexity,
|
|
1155
|
-
max_tokens=max_tokens,
|
|
1156
|
-
prompt_type=prompt_type,
|
|
1157
|
-
deps=deps,
|
|
1158
|
-
toolsets=toolsets,
|
|
1159
|
-
max_turns=max_turns,
|
|
1160
|
-
max_tool_calls=max_tool_calls,
|
|
1161
|
-
pre_retry_telemetry=self._merge_failover_telemetry(pre_retry_telemetry, current_run_telemetry),
|
|
1162
|
-
row_failover_context=next_context,
|
|
1163
|
-
provider_health_memory=provider_health_memory,
|
|
1164
|
-
)
|
|
1165
|
-
|
|
1166
|
-
@property
|
|
1167
|
-
def llm_available(self) -> bool:
|
|
1168
|
-
"""Check if an LLM client/model is available."""
|
|
1169
|
-
return self._pydantic_model is not None or self.client is not None
|
|
1170
|
-
|
|
1171
|
-
async def _call_llm(self, system: str, user: str) -> str:
|
|
1172
|
-
"""Helper to call LLM."""
|
|
1173
|
-
if self._pydantic_model is not None:
|
|
1174
|
-
result = await self._run_pydantic_agent(
|
|
1175
|
-
system_prompt=system,
|
|
1176
|
-
user_prompt=user,
|
|
1177
|
-
result_type=str,
|
|
1178
|
-
complexity="standard",
|
|
1179
|
-
max_tokens=4096,
|
|
1180
|
-
prompt_type="agent_call",
|
|
1181
|
-
)
|
|
1182
|
-
return result
|
|
1183
|
-
|
|
1184
|
-
if not self.client:
|
|
1185
|
-
raise RuntimeError("LLM client not available")
|
|
1186
|
-
|
|
1187
|
-
stream_enabled = bool(getattr(self.settings, "stream", False))
|
|
1188
|
-
|
|
1189
|
-
def _create_message():
|
|
1190
|
-
request_payload: dict[str, Any] = {
|
|
1191
|
-
"model": self.settings.model_standard,
|
|
1192
|
-
"max_tokens": 4096,
|
|
1193
|
-
"temperature": 0.0,
|
|
1194
|
-
"system": system,
|
|
1195
|
-
"messages": [{"role": "user", "content": user}],
|
|
1196
|
-
}
|
|
1197
|
-
if self.settings.protocol == LLMProtocolType.ANTHROPIC and stream_enabled:
|
|
1198
|
-
request_payload["stream"] = True
|
|
1199
|
-
return self.client.messages.create(**request_payload) # type: ignore[union-attr]
|
|
1200
|
-
|
|
1201
|
-
message = await asyncio.to_thread(_create_message)
|
|
1202
|
-
if self.settings.protocol == LLMProtocolType.ANTHROPIC:
|
|
1203
|
-
try:
|
|
1204
|
-
response_text, used_sse_adapter = await asyncio.to_thread(
|
|
1205
|
-
self._extract_anthropic_response_text_with_metadata,
|
|
1206
|
-
message,
|
|
1207
|
-
)
|
|
1208
|
-
except Exception as exc:
|
|
1209
|
-
if not stream_enabled and self._is_anthropic_sse_parse_error(exc):
|
|
1210
|
-
self.logger.warning(
|
|
1211
|
-
"anthropic_non_stream_sse_parse_failed_no_fallback",
|
|
1212
|
-
protocol=self.settings.protocol.value,
|
|
1213
|
-
configured_stream=stream_enabled,
|
|
1214
|
-
fallback_allowed=False,
|
|
1215
|
-
adapter_path="anthropic_sse_stream_adapter",
|
|
1216
|
-
error_type=type(exc).__name__,
|
|
1217
|
-
error=str(exc),
|
|
1218
|
-
)
|
|
1219
|
-
raise
|
|
1220
|
-
if not stream_enabled and used_sse_adapter:
|
|
1221
|
-
self.logger.info(
|
|
1222
|
-
"anthropic_non_stream_sse_adapter_used",
|
|
1223
|
-
protocol=self.settings.protocol.value,
|
|
1224
|
-
configured_stream=stream_enabled,
|
|
1225
|
-
adapter_path="anthropic_sse_stream_adapter",
|
|
1226
|
-
)
|
|
1227
|
-
return response_text
|
|
1228
|
-
|
|
1229
|
-
content_parts = []
|
|
1230
|
-
for block in message.content:
|
|
1231
|
-
text = getattr(block, "text", None)
|
|
1232
|
-
if text:
|
|
1233
|
-
content_parts.append(text)
|
|
1234
|
-
|
|
1235
|
-
return "\n".join(content_parts)
|
|
1236
|
-
|
|
1237
|
-
@staticmethod
|
|
1238
|
-
def _is_anthropic_sse_parse_error(exc: Exception) -> bool:
|
|
1239
|
-
message = str(exc).lower()
|
|
1240
|
-
return "sse" in message or "event-stream" in message
|
|
1241
|
-
|
|
1242
|
-
def _normalize_anthropic_text_payload_with_diagnostics(self, raw: str, *, source: str) -> str:
|
|
1243
|
-
payload = str(raw or "")
|
|
1244
|
-
configured_stream = bool(getattr(self.settings, "stream", False))
|
|
1245
|
-
adapter_used = (not configured_stream) and self._looks_like_sse_payload(payload)
|
|
1246
|
-
if adapter_used:
|
|
1247
|
-
self.logger.info(
|
|
1248
|
-
"anthropic_non_stream_sse_adapter_used",
|
|
1249
|
-
protocol=self.settings.protocol.value,
|
|
1250
|
-
configured_stream=configured_stream,
|
|
1251
|
-
adapter_path="anthropic_sse_stream_adapter",
|
|
1252
|
-
source=source,
|
|
1253
|
-
)
|
|
1254
|
-
try:
|
|
1255
|
-
return self._normalize_anthropic_text_payload(payload)
|
|
1256
|
-
except Exception as exc:
|
|
1257
|
-
if (not configured_stream) and self._is_anthropic_sse_parse_error(exc):
|
|
1258
|
-
self.logger.warning(
|
|
1259
|
-
"anthropic_non_stream_sse_parse_failed_no_fallback",
|
|
1260
|
-
protocol=self.settings.protocol.value,
|
|
1261
|
-
configured_stream=configured_stream,
|
|
1262
|
-
fallback_allowed=False,
|
|
1263
|
-
adapter_path="anthropic_sse_stream_adapter",
|
|
1264
|
-
source=source,
|
|
1265
|
-
error_type=type(exc).__name__,
|
|
1266
|
-
error=str(exc),
|
|
1267
|
-
)
|
|
1268
|
-
raise
|
|
1269
|
-
|
|
1270
|
-
@staticmethod
|
|
1271
|
-
def _looks_like_sse_payload(raw: str) -> bool:
|
|
1272
|
-
lines = [line.strip() for line in str(raw or "").splitlines() if line.strip()]
|
|
1273
|
-
if not lines:
|
|
1274
|
-
return False
|
|
1275
|
-
markers = ("event:", "data:", "id:", "retry:", ":")
|
|
1276
|
-
return all(line.startswith(markers) for line in lines[: min(3, len(lines))])
|
|
1277
|
-
|
|
1278
|
-
@classmethod
|
|
1279
|
-
def _parse_sse_data_payloads(cls, raw: str) -> list[str]:
|
|
1280
|
-
payloads: list[str] = []
|
|
1281
|
-
data_lines: list[str] = []
|
|
1282
|
-
saw_sse_marker = False
|
|
1283
|
-
|
|
1284
|
-
def _flush() -> None:
|
|
1285
|
-
if not data_lines:
|
|
1286
|
-
return
|
|
1287
|
-
data_payload = "\n".join(data_lines).strip()
|
|
1288
|
-
data_lines.clear()
|
|
1289
|
-
if not data_payload or data_payload == "[DONE]":
|
|
1290
|
-
return
|
|
1291
|
-
payloads.append(data_payload)
|
|
1292
|
-
|
|
1293
|
-
for line in str(raw or "").splitlines():
|
|
1294
|
-
stripped = line.strip()
|
|
1295
|
-
if not stripped:
|
|
1296
|
-
_flush()
|
|
1297
|
-
continue
|
|
1298
|
-
if stripped == "[DONE]":
|
|
1299
|
-
saw_sse_marker = True
|
|
1300
|
-
_flush()
|
|
1301
|
-
continue
|
|
1302
|
-
if stripped.startswith(":"):
|
|
1303
|
-
saw_sse_marker = True
|
|
1304
|
-
continue
|
|
1305
|
-
if stripped.startswith("data:"):
|
|
1306
|
-
saw_sse_marker = True
|
|
1307
|
-
data_lines.append(stripped[5:].lstrip())
|
|
1308
|
-
continue
|
|
1309
|
-
if stripped.startswith("event:") or stripped.startswith("id:") or stripped.startswith("retry:"):
|
|
1310
|
-
saw_sse_marker = True
|
|
1311
|
-
continue
|
|
1312
|
-
raise RuntimeError(f"Unsupported SSE line format: {stripped!r}")
|
|
1313
|
-
|
|
1314
|
-
_flush()
|
|
1315
|
-
if not saw_sse_marker:
|
|
1316
|
-
raise RuntimeError("Payload is not SSE-formatted")
|
|
1317
|
-
return payloads
|
|
1318
|
-
|
|
1319
|
-
@staticmethod
|
|
1320
|
-
def _extract_text_from_content_blocks(content: Any) -> list[str]:
|
|
1321
|
-
text_parts: list[str] = []
|
|
1322
|
-
if isinstance(content, str):
|
|
1323
|
-
if content:
|
|
1324
|
-
text_parts.append(content)
|
|
1325
|
-
return text_parts
|
|
1326
|
-
if not isinstance(content, list):
|
|
1327
|
-
return text_parts
|
|
1328
|
-
for block in content:
|
|
1329
|
-
if isinstance(block, str):
|
|
1330
|
-
if block:
|
|
1331
|
-
text_parts.append(block)
|
|
1332
|
-
continue
|
|
1333
|
-
if isinstance(block, dict):
|
|
1334
|
-
block_text = block.get("text")
|
|
1335
|
-
if isinstance(block_text, str) and block_text:
|
|
1336
|
-
text_parts.append(block_text)
|
|
1337
|
-
continue
|
|
1338
|
-
block_text = getattr(block, "text", None)
|
|
1339
|
-
if isinstance(block_text, str) and block_text:
|
|
1340
|
-
text_parts.append(block_text)
|
|
1341
|
-
return text_parts
|
|
1342
|
-
|
|
1343
|
-
@classmethod
|
|
1344
|
-
def _extract_text_from_anthropic_payload(cls, payload: dict[str, Any]) -> list[str]:
|
|
1345
|
-
text_parts: list[str] = []
|
|
1346
|
-
direct_text = payload.get("text")
|
|
1347
|
-
if isinstance(direct_text, str) and direct_text:
|
|
1348
|
-
text_parts.append(direct_text)
|
|
1349
|
-
|
|
1350
|
-
event_type = str(payload.get("type") or "").strip().lower()
|
|
1351
|
-
if event_type == "content_block_delta":
|
|
1352
|
-
delta = payload.get("delta")
|
|
1353
|
-
if isinstance(delta, dict):
|
|
1354
|
-
delta_text = delta.get("text") or delta.get("content_delta") or delta.get("delta")
|
|
1355
|
-
if isinstance(delta_text, str) and delta_text:
|
|
1356
|
-
text_parts.append(delta_text)
|
|
1357
|
-
elif event_type == "content_block_start":
|
|
1358
|
-
content_block = payload.get("content_block")
|
|
1359
|
-
if isinstance(content_block, dict):
|
|
1360
|
-
block_text = content_block.get("text")
|
|
1361
|
-
if isinstance(block_text, str) and block_text:
|
|
1362
|
-
text_parts.append(block_text)
|
|
1363
|
-
elif event_type == "message_start":
|
|
1364
|
-
message = payload.get("message")
|
|
1365
|
-
if isinstance(message, dict):
|
|
1366
|
-
text_parts.extend(cls._extract_text_from_content_blocks(message.get("content")))
|
|
1367
|
-
|
|
1368
|
-
choices = payload.get("choices")
|
|
1369
|
-
if isinstance(choices, list):
|
|
1370
|
-
for choice in choices:
|
|
1371
|
-
if not isinstance(choice, dict):
|
|
1372
|
-
continue
|
|
1373
|
-
delta = choice.get("delta")
|
|
1374
|
-
if isinstance(delta, dict):
|
|
1375
|
-
delta_content = delta.get("content")
|
|
1376
|
-
if isinstance(delta_content, str) and delta_content:
|
|
1377
|
-
text_parts.append(delta_content)
|
|
1378
|
-
return text_parts
|
|
1379
|
-
|
|
1380
|
-
@classmethod
|
|
1381
|
-
def _normalize_strict_anthropic_sse_payload(cls, raw: str) -> str:
|
|
1382
|
-
text_parts: list[str] = []
|
|
1383
|
-
for data_payload in cls._parse_sse_data_payloads(raw):
|
|
1384
|
-
try:
|
|
1385
|
-
parsed = json.loads(data_payload)
|
|
1386
|
-
except json.JSONDecodeError as exc:
|
|
1387
|
-
raise RuntimeError(f"Invalid SSE JSON payload: {data_payload!r}") from exc
|
|
1388
|
-
|
|
1389
|
-
if isinstance(parsed, dict):
|
|
1390
|
-
text_parts.extend(cls._extract_text_from_anthropic_payload(parsed))
|
|
1391
|
-
elif isinstance(parsed, str):
|
|
1392
|
-
stripped = parsed.strip()
|
|
1393
|
-
if stripped and stripped != "[DONE]":
|
|
1394
|
-
text_parts.append(stripped)
|
|
1395
|
-
else:
|
|
1396
|
-
raise RuntimeError(f"Unsupported SSE payload type: {type(parsed).__name__}")
|
|
1397
|
-
|
|
1398
|
-
if not text_parts:
|
|
1399
|
-
raise RuntimeError("Anthropic SSE payload did not contain text deltas")
|
|
1400
|
-
return "".join(text_parts)
|
|
1401
|
-
|
|
1402
|
-
@classmethod
|
|
1403
|
-
def _normalize_anthropic_text_payload(cls, raw: str) -> str:
|
|
1404
|
-
text = str(raw or "")
|
|
1405
|
-
if not text.strip():
|
|
1406
|
-
return ""
|
|
1407
|
-
if cls._looks_like_sse_payload(text):
|
|
1408
|
-
return cls._normalize_strict_anthropic_sse_payload(text)
|
|
1409
|
-
return text
|
|
1410
|
-
|
|
1411
|
-
@classmethod
|
|
1412
|
-
def _extract_anthropic_text_from_stream_event(cls, event: Any) -> list[str]:
|
|
1413
|
-
if event is None:
|
|
1414
|
-
return []
|
|
1415
|
-
if isinstance(event, bytes):
|
|
1416
|
-
event = event.decode("utf-8", errors="replace")
|
|
1417
|
-
if isinstance(event, str):
|
|
1418
|
-
stripped = event.strip()
|
|
1419
|
-
if not stripped:
|
|
1420
|
-
return []
|
|
1421
|
-
if cls._looks_like_sse_payload(stripped):
|
|
1422
|
-
return [cls._normalize_strict_anthropic_sse_payload(stripped)]
|
|
1423
|
-
if stripped.startswith("{") and stripped.endswith("}"):
|
|
1424
|
-
try:
|
|
1425
|
-
decoded = json.loads(stripped)
|
|
1426
|
-
except json.JSONDecodeError:
|
|
1427
|
-
return [stripped]
|
|
1428
|
-
if isinstance(decoded, dict):
|
|
1429
|
-
extracted = cls._extract_text_from_anthropic_payload(decoded)
|
|
1430
|
-
return extracted or [stripped]
|
|
1431
|
-
return [stripped]
|
|
1432
|
-
return [stripped]
|
|
1433
|
-
if isinstance(event, dict):
|
|
1434
|
-
return cls._extract_text_from_anthropic_payload(event)
|
|
1435
|
-
|
|
1436
|
-
text_parts: list[str] = []
|
|
1437
|
-
event_type = str(getattr(event, "type", "") or "").strip().lower()
|
|
1438
|
-
if event_type == "content_block_delta":
|
|
1439
|
-
delta = getattr(event, "delta", None)
|
|
1440
|
-
delta_text = getattr(delta, "text", None) or getattr(delta, "content_delta", None)
|
|
1441
|
-
if isinstance(delta_text, str) and delta_text:
|
|
1442
|
-
text_parts.append(delta_text)
|
|
1443
|
-
elif event_type == "content_block_start":
|
|
1444
|
-
content_block = getattr(event, "content_block", None)
|
|
1445
|
-
block_text = getattr(content_block, "text", None)
|
|
1446
|
-
if isinstance(block_text, str) and block_text:
|
|
1447
|
-
text_parts.append(block_text)
|
|
1448
|
-
elif event_type == "message_start":
|
|
1449
|
-
message = getattr(event, "message", None)
|
|
1450
|
-
content = getattr(message, "content", None) if message is not None else None
|
|
1451
|
-
text_parts.extend(cls._extract_text_from_content_blocks(content))
|
|
1452
|
-
|
|
1453
|
-
direct_text = getattr(event, "text", None)
|
|
1454
|
-
if isinstance(direct_text, str) and direct_text:
|
|
1455
|
-
text_parts.append(direct_text)
|
|
1456
|
-
return text_parts
|
|
1457
|
-
|
|
1458
|
-
@classmethod
|
|
1459
|
-
def _consume_anthropic_stream_text(cls, stream_response: Any) -> str:
|
|
1460
|
-
text_parts: list[str] = []
|
|
1461
|
-
consumed_events = False
|
|
1462
|
-
|
|
1463
|
-
text_stream = getattr(stream_response, "text_stream", None)
|
|
1464
|
-
if text_stream is not None:
|
|
1465
|
-
for chunk in text_stream:
|
|
1466
|
-
consumed_events = True
|
|
1467
|
-
normalized = cls._normalize_anthropic_text_payload(str(chunk))
|
|
1468
|
-
if normalized:
|
|
1469
|
-
text_parts.append(normalized)
|
|
1470
|
-
elif hasattr(stream_response, "__iter__"):
|
|
1471
|
-
for event in stream_response:
|
|
1472
|
-
consumed_events = True
|
|
1473
|
-
text_parts.extend(cls._extract_anthropic_text_from_stream_event(event))
|
|
1474
|
-
|
|
1475
|
-
if not consumed_events:
|
|
1476
|
-
raise RuntimeError("Anthropic stream response was not iterable")
|
|
1477
|
-
if not text_parts:
|
|
1478
|
-
raise RuntimeError("Anthropic stream response did not contain text")
|
|
1479
|
-
return "".join(text_parts)
|
|
1480
|
-
|
|
1481
|
-
@classmethod
|
|
1482
|
-
def _extract_anthropic_response_text(cls, response: Any) -> str:
|
|
1483
|
-
text, _used_sse_adapter = cls._extract_anthropic_response_text_with_metadata(response)
|
|
1484
|
-
return text
|
|
1485
|
-
|
|
1486
|
-
@classmethod
|
|
1487
|
-
def _extract_anthropic_response_text_with_metadata(cls, response: Any) -> tuple[str, bool]:
|
|
1488
|
-
if response is None:
|
|
1489
|
-
raise RuntimeError("Anthropic response is empty")
|
|
1490
|
-
|
|
1491
|
-
if isinstance(response, (str, bytes)):
|
|
1492
|
-
raw_response = response.decode("utf-8", errors="replace") if isinstance(response, bytes) else response
|
|
1493
|
-
normalized = cls._normalize_anthropic_text_payload(raw_response)
|
|
1494
|
-
if not normalized:
|
|
1495
|
-
raise RuntimeError("Anthropic response text is empty")
|
|
1496
|
-
return normalized, cls._looks_like_sse_payload(raw_response)
|
|
1497
|
-
|
|
1498
|
-
content = getattr(response, "content", None)
|
|
1499
|
-
if isinstance(content, list):
|
|
1500
|
-
parts: list[str] = []
|
|
1501
|
-
for block in content:
|
|
1502
|
-
block_text = getattr(block, "text", None)
|
|
1503
|
-
if isinstance(block_text, str) and block_text:
|
|
1504
|
-
parts.append(cls._normalize_anthropic_text_payload(block_text))
|
|
1505
|
-
if parts:
|
|
1506
|
-
return "\n".join(part for part in parts if part).strip(), False
|
|
1507
|
-
|
|
1508
|
-
if hasattr(response, "__enter__") and hasattr(response, "__exit__"):
|
|
1509
|
-
with response as managed:
|
|
1510
|
-
return cls._consume_anthropic_stream_text(managed), True
|
|
1511
|
-
|
|
1512
|
-
return cls._consume_anthropic_stream_text(response), True
|
|
1513
|
-
|
|
1514
|
-
def _build_pydantic_ai_model(self, model_name: str):
|
|
1515
|
-
"""Create a PydanticAI model wrapper based on LLM settings."""
|
|
1516
|
-
from pydantic_ai.models.anthropic import AnthropicModel
|
|
1517
|
-
from pydantic_ai.models.openai import OpenAIChatModel, OpenAIResponsesModel
|
|
1518
|
-
from pydantic_ai.providers.openai import OpenAIProvider
|
|
1519
|
-
|
|
1520
|
-
protocol = self.settings.protocol
|
|
1521
|
-
protocol_value = self._protocol_value(protocol)
|
|
1522
|
-
if protocol_value not in PYDANTIC_AI_MODEL_SUPPORTED_PROTOCOL_VALUES:
|
|
1523
|
-
raise ValueError(f"Unsupported protocol for PydanticAI model builder: {protocol_value}")
|
|
1524
|
-
|
|
1525
|
-
if protocol == LLMProtocolType.GEMINI:
|
|
1526
|
-
from pydantic_ai.models.google import GoogleModel
|
|
1527
|
-
from pydantic_ai.providers.google import GoogleProvider
|
|
1528
|
-
|
|
1529
|
-
api_key = resolve_protocol_api_key(self.settings, protocol, allow_openai_dummy=False)
|
|
1530
|
-
provider = GoogleProvider(
|
|
1531
|
-
api_key=api_key,
|
|
1532
|
-
base_url=resolve_protocol_base_url(self.settings, protocol),
|
|
1533
|
-
)
|
|
1534
|
-
return GoogleModel(model_name, provider=provider, settings=self._model_settings)
|
|
1535
|
-
|
|
1536
|
-
if protocol == LLMProtocolType.ANTHROPIC:
|
|
1537
|
-
api_key = resolve_protocol_api_key(self.settings, protocol, allow_openai_dummy=False)
|
|
1538
|
-
provider = "anthropic"
|
|
1539
|
-
base_url = resolve_protocol_base_url(self.settings, protocol)
|
|
1540
|
-
if api_key or base_url:
|
|
1541
|
-
from vds_audit_orchestrator.llm.provider import build_pydantic_anthropic_provider
|
|
1542
|
-
|
|
1543
|
-
provider = build_pydantic_anthropic_provider(
|
|
1544
|
-
api_key=api_key,
|
|
1545
|
-
base_url=base_url,
|
|
1546
|
-
)
|
|
1547
|
-
return AnthropicModel(model_name, provider=provider, settings=self._model_settings)
|
|
1548
|
-
|
|
1549
|
-
if self._is_openai_codex_protocol(protocol):
|
|
1550
|
-
from openai import AsyncOpenAI
|
|
1551
|
-
|
|
1552
|
-
try:
|
|
1553
|
-
from vds_audit_orchestrator.llm.codex_oauth import get_codex_credentials
|
|
1554
|
-
except ImportError as exc: # pragma: no cover - guarded by protocol path
|
|
1555
|
-
raise RuntimeError("openai-codex protocol requires llm.codex_oauth.get_codex_credentials") from exc
|
|
1556
|
-
|
|
1557
|
-
credentials = get_codex_credentials()
|
|
1558
|
-
access_token = self._resolve_codex_access_token(credentials)
|
|
1559
|
-
chatgpt_account_id = self._resolve_codex_account_id(credentials)
|
|
1560
|
-
self._warn_if_unvalidated_codex_model(model_name)
|
|
1561
|
-
base_url = resolve_protocol_base_url(self.settings, protocol)
|
|
1562
|
-
if not base_url:
|
|
1563
|
-
raise ValueError("openai-codex protocol requires VDS_AUDIT_LLM__BASE_URL")
|
|
1564
|
-
default_headers = {"ChatGPT-Account-Id": chatgpt_account_id} if chatgpt_account_id else None
|
|
1565
|
-
openai_client = AsyncOpenAI(
|
|
1566
|
-
api_key=access_token,
|
|
1567
|
-
base_url=base_url,
|
|
1568
|
-
default_headers=default_headers,
|
|
1569
|
-
)
|
|
1570
|
-
provider = OpenAIProvider(openai_client=openai_client)
|
|
1571
|
-
model_settings = self._build_openai_codex_model_settings(self._model_settings)
|
|
1572
|
-
return OpenAIResponsesModel(
|
|
1573
|
-
model_name,
|
|
1574
|
-
provider=provider,
|
|
1575
|
-
settings=model_settings,
|
|
1576
|
-
)
|
|
1577
|
-
|
|
1578
|
-
base_url = resolve_protocol_base_url(self.settings, protocol)
|
|
1579
|
-
api_key = resolve_openai_protocol_api_key(self.settings)
|
|
1580
|
-
provider = OpenAIProvider(api_key=api_key, base_url=base_url)
|
|
1581
|
-
return OpenAIChatModel(model_name, provider=provider, settings=self._model_settings)
|
|
1582
|
-
|
|
1583
|
-
@staticmethod
|
|
1584
|
-
def _protocol_value(protocol: Any) -> str:
|
|
1585
|
-
return str(getattr(protocol, "value", protocol) or "").strip().lower()
|
|
1586
|
-
|
|
1587
|
-
@classmethod
|
|
1588
|
-
def _is_openai_codex_protocol(cls, protocol: Any | None = None) -> bool:
|
|
1589
|
-
return cls._protocol_value(protocol) == OPENAI_CODEX_PROTOCOL
|
|
1590
|
-
|
|
1591
|
-
@staticmethod
|
|
1592
|
-
def _read_credential_field(credentials: Any, *field_names: str) -> str | None:
|
|
1593
|
-
for field_name in field_names:
|
|
1594
|
-
if isinstance(credentials, dict):
|
|
1595
|
-
raw_value = credentials.get(field_name)
|
|
1596
|
-
else:
|
|
1597
|
-
raw_value = getattr(credentials, field_name, None)
|
|
1598
|
-
value = str(raw_value or "").strip()
|
|
1599
|
-
if value:
|
|
1600
|
-
return value
|
|
1601
|
-
return None
|
|
1602
|
-
|
|
1603
|
-
@classmethod
|
|
1604
|
-
def _resolve_codex_access_token(cls, credentials: Any) -> str:
|
|
1605
|
-
access_token = cls._read_credential_field(credentials, "access_token", "token")
|
|
1606
|
-
if not access_token:
|
|
1607
|
-
raise ValueError("Codex OAuth credentials missing access token")
|
|
1608
|
-
return access_token
|
|
1609
|
-
|
|
1610
|
-
@classmethod
|
|
1611
|
-
def _resolve_codex_account_id(cls, credentials: Any) -> str | None:
|
|
1612
|
-
return cls._read_credential_field(credentials, "chatgpt_account_id", "account_id")
|
|
1613
|
-
|
|
1614
|
-
@staticmethod
|
|
1615
|
-
def _build_openai_codex_model_settings(settings: ModelSettings | None) -> ModelSettings:
|
|
1616
|
-
merged: dict[str, Any] = {}
|
|
1617
|
-
if isinstance(settings, dict):
|
|
1618
|
-
merged.update(settings)
|
|
1619
|
-
elif settings is not None:
|
|
1620
|
-
model_dump = getattr(settings, "model_dump", None)
|
|
1621
|
-
if callable(model_dump):
|
|
1622
|
-
dumped = model_dump()
|
|
1623
|
-
if isinstance(dumped, dict):
|
|
1624
|
-
merged.update(dumped)
|
|
1625
|
-
merged["openai_store"] = False
|
|
1626
|
-
return ModelSettings(**merged)
|
|
1627
|
-
|
|
1628
|
-
async def _run_streaming_pydantic_operation(
|
|
1629
|
-
self,
|
|
1630
|
-
*,
|
|
1631
|
-
agent: Any,
|
|
1632
|
-
user_prompt: str,
|
|
1633
|
-
run_kwargs: dict[str, Any],
|
|
1634
|
-
) -> _PydanticStreamResultWrapper:
|
|
1635
|
-
stream_result: Any | None = None
|
|
1636
|
-
try:
|
|
1637
|
-
async with agent.run_stream(user_prompt, **run_kwargs) as active_stream_result:
|
|
1638
|
-
stream_result = active_stream_result
|
|
1639
|
-
output = await stream_result.get_output()
|
|
1640
|
-
return _PydanticStreamResultWrapper(output=output, streamed_result=stream_result)
|
|
1641
|
-
except Exception as exc:
|
|
1642
|
-
self._attach_streamed_output_payload(exc, stream_result)
|
|
1643
|
-
if self._is_codex_streaming_requirement_error(exc):
|
|
1644
|
-
raise RuntimeError(
|
|
1645
|
-
"Codex subscription provider requires streaming mode; use openai-codex with run_stream() semantics."
|
|
1646
|
-
) from exc
|
|
1647
|
-
raise
|
|
1648
|
-
|
|
1649
|
-
@staticmethod
|
|
1650
|
-
def _extract_streamed_output_payload(stream_result: Any | None) -> dict[str, Any] | str | None:
|
|
1651
|
-
response = getattr(stream_result, "response", None)
|
|
1652
|
-
tool_calls = getattr(response, "tool_calls", None)
|
|
1653
|
-
if isinstance(tool_calls, list):
|
|
1654
|
-
for tool_call in reversed(tool_calls):
|
|
1655
|
-
args_as_dict = getattr(tool_call, "args_as_dict", None)
|
|
1656
|
-
if callable(args_as_dict):
|
|
1657
|
-
try:
|
|
1658
|
-
payload = args_as_dict()
|
|
1659
|
-
except Exception:
|
|
1660
|
-
payload = None
|
|
1661
|
-
if isinstance(payload, dict) and payload:
|
|
1662
|
-
return payload
|
|
1663
|
-
args_as_json_str = getattr(tool_call, "args_as_json_str", None)
|
|
1664
|
-
if callable(args_as_json_str):
|
|
1665
|
-
try:
|
|
1666
|
-
payload = args_as_json_str()
|
|
1667
|
-
except Exception:
|
|
1668
|
-
payload = None
|
|
1669
|
-
if isinstance(payload, str) and payload.strip():
|
|
1670
|
-
return payload
|
|
1671
|
-
payload = getattr(tool_call, "args", None)
|
|
1672
|
-
if isinstance(payload, dict) and payload:
|
|
1673
|
-
return payload
|
|
1674
|
-
if isinstance(payload, str) and payload.strip():
|
|
1675
|
-
return payload
|
|
1676
|
-
return None
|
|
1677
|
-
|
|
1678
|
-
@classmethod
|
|
1679
|
-
def _attach_streamed_output_payload(cls, exc: Exception, stream_result: Any | None) -> None:
|
|
1680
|
-
payload = cls._extract_streamed_output_payload(stream_result)
|
|
1681
|
-
if payload is None:
|
|
1682
|
-
return
|
|
1683
|
-
with contextlib.suppress(Exception):
|
|
1684
|
-
exc.streamed_output_payload = payload
|
|
1685
|
-
if getattr(exc, "body", None) is None:
|
|
1686
|
-
with contextlib.suppress(Exception):
|
|
1687
|
-
exc.body = payload
|
|
1688
|
-
if getattr(exc, "response", None) is None:
|
|
1689
|
-
with contextlib.suppress(Exception):
|
|
1690
|
-
exc.response = payload
|
|
1691
|
-
|
|
1692
|
-
def _resolve_agent_stream_mode(self) -> tuple[bool, str]:
|
|
1693
|
-
if self._is_openai_codex_protocol(self.settings.protocol):
|
|
1694
|
-
return True, "protocol_override"
|
|
1695
|
-
if bool(getattr(self.settings, "agent_stream", True)):
|
|
1696
|
-
return True, "profile"
|
|
1697
|
-
if bool(getattr(self.settings, "stream", False)):
|
|
1698
|
-
return True, "transport_floor"
|
|
1699
|
-
return False, "profile"
|
|
1700
|
-
|
|
1701
|
-
def _build_agent_operation(
|
|
1702
|
-
self,
|
|
1703
|
-
*,
|
|
1704
|
-
agent: Any,
|
|
1705
|
-
user_prompt: str,
|
|
1706
|
-
run_kwargs: dict[str, Any],
|
|
1707
|
-
) -> Coroutine[Any, Any, Any]:
|
|
1708
|
-
use_streaming, source = self._resolve_agent_stream_mode()
|
|
1709
|
-
self.logger.info(
|
|
1710
|
-
"pydantic_agent_stream_mode",
|
|
1711
|
-
mode="stream" if use_streaming else "non_stream",
|
|
1712
|
-
source=source,
|
|
1713
|
-
protocol=self._protocol_value(self.settings.protocol),
|
|
1714
|
-
model_name=getattr(self.settings, "model_standard", None),
|
|
1715
|
-
)
|
|
1716
|
-
if use_streaming:
|
|
1717
|
-
return self._run_streaming_pydantic_operation(
|
|
1718
|
-
agent=agent,
|
|
1719
|
-
user_prompt=user_prompt,
|
|
1720
|
-
run_kwargs=dict(run_kwargs),
|
|
1721
|
-
)
|
|
1722
|
-
return agent.run(user_prompt, **run_kwargs)
|
|
1723
|
-
|
|
1724
|
-
@staticmethod
|
|
1725
|
-
def _is_codex_streaming_requirement_error(exc: Exception) -> bool:
|
|
1726
|
-
message = str(exc).lower()
|
|
1727
|
-
return "stream must be set to true" in message or "stream=true" in message or "streaming required" in message
|
|
1728
|
-
|
|
1729
|
-
def _warn_if_unvalidated_codex_model(self, model_name: str) -> None:
|
|
1730
|
-
if str(model_name).strip().lower() in OPENAI_CODEX_BASELINE_MODELS:
|
|
1731
|
-
return
|
|
1732
|
-
self.logger.warning(
|
|
1733
|
-
"codex_unsupported_model_name",
|
|
1734
|
-
model_name=model_name,
|
|
1735
|
-
baseline_models=sorted(OPENAI_CODEX_BASELINE_MODELS),
|
|
1736
|
-
)
|
|
1737
|
-
|
|
1738
|
-
async def _run_pydantic_agent(
|
|
1739
|
-
self,
|
|
1740
|
-
*,
|
|
1741
|
-
system_prompt: str,
|
|
1742
|
-
user_prompt: str,
|
|
1743
|
-
result_type: type[ResultType],
|
|
1744
|
-
complexity: str = "standard",
|
|
1745
|
-
max_tokens: int = 4096,
|
|
1746
|
-
prompt_type: str = "agent",
|
|
1747
|
-
deps: Any | None = None,
|
|
1748
|
-
toolsets: list[Any] | None = None,
|
|
1749
|
-
max_turns: int | None = None,
|
|
1750
|
-
max_tool_calls: int | None = None,
|
|
1751
|
-
pre_retry_telemetry: dict[str, Any] | None = None,
|
|
1752
|
-
row_failover_context: RowFailoverContext | None = None,
|
|
1753
|
-
provider_health_memory: ProviderHealthMemory | None = None,
|
|
1754
|
-
) -> ResultType:
|
|
1755
|
-
"""Run a PydanticAI agent and return typed output.
|
|
1756
|
-
|
|
1757
|
-
Args:
|
|
1758
|
-
toolsets: Optional list of PydanticAI toolsets (Phase 41).
|
|
1759
|
-
When provided, the agent is created with tool-use capabilities
|
|
1760
|
-
for multi-turn agentic investigation.
|
|
1761
|
-
max_turns: Optional max request/turn limit for bounded agentic runs.
|
|
1762
|
-
max_tool_calls: Optional max tool call limit for bounded agentic runs.
|
|
1763
|
-
"""
|
|
1764
|
-
import time
|
|
1765
|
-
|
|
1766
|
-
if not self.settings.enabled:
|
|
1767
|
-
raise RuntimeError("LLM is disabled")
|
|
1768
|
-
|
|
1769
|
-
operation_state: dict[str, Any] = {
|
|
1770
|
-
"operation_id": uuid4().hex,
|
|
1771
|
-
"operation_kind": "pydantic_agent_run",
|
|
1772
|
-
"operation_status": "started",
|
|
1773
|
-
"operation_outcome": "started",
|
|
1774
|
-
"operation_started_at": time.monotonic(),
|
|
1775
|
-
"model_name": self.settings.model_standard,
|
|
1776
|
-
"event_stream_enabled": False,
|
|
1777
|
-
"rate_limit_retry_attempts": 0,
|
|
1778
|
-
"tool_call_retry_attempts": 0,
|
|
1779
|
-
"codex_auth_retry_attempts": 0,
|
|
1780
|
-
"run_telemetry": None,
|
|
1781
|
-
"error": None,
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
@contextlib.contextmanager
|
|
1785
|
-
def _operation_lifecycle_scope():
|
|
1786
|
-
self.logger.info(
|
|
1787
|
-
"agent_operation_lifecycle",
|
|
1788
|
-
operation_id=operation_state["operation_id"],
|
|
1789
|
-
operation_kind=operation_state["operation_kind"],
|
|
1790
|
-
operation_status="started",
|
|
1791
|
-
operation_outcome=operation_state["operation_outcome"],
|
|
1792
|
-
result_type=result_type.__name__,
|
|
1793
|
-
prompt_type=prompt_type,
|
|
1794
|
-
protocol=self.settings.protocol.value,
|
|
1795
|
-
model_name=operation_state.get("model_name"),
|
|
1796
|
-
)
|
|
1797
|
-
try:
|
|
1798
|
-
yield
|
|
1799
|
-
except Exception as exc:
|
|
1800
|
-
operation_state["operation_status"] = "failed"
|
|
1801
|
-
operation_state["operation_outcome"] = "error"
|
|
1802
|
-
operation_state["error"] = str(exc)
|
|
1803
|
-
raise
|
|
1804
|
-
finally:
|
|
1805
|
-
elapsed_sec = max(0.0, time.monotonic() - float(operation_state["operation_started_at"]))
|
|
1806
|
-
run_telemetry = operation_state.get("run_telemetry")
|
|
1807
|
-
event_tool_calls_started = 0
|
|
1808
|
-
event_tool_calls_completed = 0
|
|
1809
|
-
event_skill_tool_calls = 0
|
|
1810
|
-
event_skill_effective_tool_calls = 0
|
|
1811
|
-
observed_tool_names: list[str] | None = None
|
|
1812
|
-
if isinstance(run_telemetry, dict):
|
|
1813
|
-
event_tool_calls_started = int(run_telemetry.get("event_tool_calls_started", 0) or 0)
|
|
1814
|
-
event_tool_calls_completed = int(
|
|
1815
|
-
run_telemetry.get("event_tool_calls_completed", run_telemetry.get("event_tool_calls", 0)) or 0
|
|
1816
|
-
)
|
|
1817
|
-
event_skill_tool_calls = int(run_telemetry.get("event_skill_tool_calls", 0) or 0)
|
|
1818
|
-
event_skill_effective_tool_calls = int(
|
|
1819
|
-
run_telemetry.get("event_skill_effective_tool_calls", 0) or 0
|
|
1820
|
-
)
|
|
1821
|
-
observed_tool_names = list(run_telemetry.get("event_tool_names") or [])
|
|
1822
|
-
run_telemetry["operation_id"] = operation_state["operation_id"]
|
|
1823
|
-
run_telemetry["operation_kind"] = operation_state["operation_kind"]
|
|
1824
|
-
run_telemetry["operation_status"] = operation_state["operation_status"]
|
|
1825
|
-
run_telemetry["operation_outcome"] = operation_state["operation_outcome"]
|
|
1826
|
-
run_telemetry["operation_elapsed_sec"] = round(elapsed_sec, 3)
|
|
1827
|
-
run_telemetry["operation_rate_limit_retry_attempts"] = int(
|
|
1828
|
-
operation_state.get("rate_limit_retry_attempts", 0) or 0
|
|
1829
|
-
)
|
|
1830
|
-
run_telemetry["operation_tool_call_retry_attempts"] = int(
|
|
1831
|
-
operation_state.get("tool_call_retry_attempts", 0) or 0
|
|
1832
|
-
)
|
|
1833
|
-
run_telemetry["operation_codex_auth_retry_attempts"] = int(
|
|
1834
|
-
operation_state.get("codex_auth_retry_attempts", 0) or 0
|
|
1835
|
-
)
|
|
1836
|
-
if operation_state.get("error"):
|
|
1837
|
-
run_telemetry["operation_error"] = str(operation_state["error"])
|
|
1838
|
-
|
|
1839
|
-
log_method = (
|
|
1840
|
-
self.logger.warning if operation_state["operation_status"] == "failed" else self.logger.info
|
|
1841
|
-
)
|
|
1842
|
-
log_method(
|
|
1843
|
-
"agent_operation_lifecycle",
|
|
1844
|
-
operation_id=operation_state["operation_id"],
|
|
1845
|
-
operation_kind=operation_state["operation_kind"],
|
|
1846
|
-
operation_status=operation_state["operation_status"],
|
|
1847
|
-
operation_outcome=operation_state["operation_outcome"],
|
|
1848
|
-
elapsed_sec=round(elapsed_sec, 2),
|
|
1849
|
-
result_type=result_type.__name__,
|
|
1850
|
-
prompt_type=prompt_type,
|
|
1851
|
-
protocol=self.settings.protocol.value,
|
|
1852
|
-
model_name=operation_state.get("model_name"),
|
|
1853
|
-
event_stream_enabled=bool(operation_state.get("event_stream_enabled", False)),
|
|
1854
|
-
rate_limit_retry_attempts=int(operation_state.get("rate_limit_retry_attempts", 0) or 0),
|
|
1855
|
-
tool_call_retry_attempts=int(operation_state.get("tool_call_retry_attempts", 0) or 0),
|
|
1856
|
-
codex_auth_retry_attempts=int(operation_state.get("codex_auth_retry_attempts", 0) or 0),
|
|
1857
|
-
event_tool_calls_started=event_tool_calls_started,
|
|
1858
|
-
event_tool_calls_completed=event_tool_calls_completed,
|
|
1859
|
-
event_skill_tool_calls=event_skill_tool_calls,
|
|
1860
|
-
event_skill_effective_tool_calls=event_skill_effective_tool_calls,
|
|
1861
|
-
observed_tool_names=observed_tool_names,
|
|
1862
|
-
error=operation_state.get("error"),
|
|
1863
|
-
)
|
|
1864
|
-
|
|
1865
|
-
with log_context(agent=self.__class__.__name__, phase="agent"), _operation_lifecycle_scope():
|
|
1866
|
-
provider_health_memory = provider_health_memory or ProviderHealthMemory()
|
|
1867
|
-
self.logger.info(
|
|
1868
|
-
"pydantic_agent_call_started",
|
|
1869
|
-
result_type=result_type.__name__,
|
|
1870
|
-
complexity=complexity,
|
|
1871
|
-
protocol=self.settings.protocol.value,
|
|
1872
|
-
operation_id=operation_state["operation_id"],
|
|
1873
|
-
operation_kind=operation_state["operation_kind"],
|
|
1874
|
-
)
|
|
1875
|
-
start_time = time.monotonic()
|
|
1876
|
-
system_prompt_chars = len(system_prompt)
|
|
1877
|
-
user_prompt_chars = len(user_prompt)
|
|
1878
|
-
total_prompt_chars = system_prompt_chars + user_prompt_chars
|
|
1879
|
-
approx_prompt_tokens = max(1, total_prompt_chars // 4)
|
|
1880
|
-
self._log_trace_payload(
|
|
1881
|
-
event_name="pydantic_agent_trace_prompt",
|
|
1882
|
-
elapsed_sec=0.0,
|
|
1883
|
-
payload={
|
|
1884
|
-
"operation_id": operation_state["operation_id"],
|
|
1885
|
-
"result_type": result_type.__name__,
|
|
1886
|
-
"complexity": complexity,
|
|
1887
|
-
"protocol": self.settings.protocol.value,
|
|
1888
|
-
"system_prompt": system_prompt,
|
|
1889
|
-
"user_prompt": user_prompt,
|
|
1890
|
-
"max_turns": max_turns,
|
|
1891
|
-
"max_tool_calls": max_tool_calls,
|
|
1892
|
-
},
|
|
1893
|
-
)
|
|
1894
|
-
|
|
1895
|
-
if self._pydantic_model is None and self.client is not None:
|
|
1896
|
-
response = await self._call_llm(system_prompt, user_prompt)
|
|
1897
|
-
payload = self._strip_json_fence(response)
|
|
1898
|
-
elapsed = time.monotonic() - start_time
|
|
1899
|
-
operation_state["operation_status"] = "completed"
|
|
1900
|
-
operation_state["operation_outcome"] = "direct_call"
|
|
1901
|
-
self.logger.info(
|
|
1902
|
-
"pydantic_agent_call_complete",
|
|
1903
|
-
elapsed_sec=round(elapsed, 2),
|
|
1904
|
-
mode="direct_call",
|
|
1905
|
-
operation_id=operation_state["operation_id"],
|
|
1906
|
-
)
|
|
1907
|
-
return result_type.model_validate_json(payload) # type: ignore[return-value]
|
|
1908
|
-
|
|
1909
|
-
from vds_audit_orchestrator.logging_config import audit_otel_span as trace_span
|
|
1910
|
-
|
|
1911
|
-
# Select model based on complexity
|
|
1912
|
-
model_name = self.settings.select_model(complexity) if hasattr(self.settings, "select_model") else None
|
|
1913
|
-
selected_model = model_name or self.settings.model_standard
|
|
1914
|
-
operation_state["model_name"] = selected_model
|
|
1915
|
-
|
|
1916
|
-
self.logger.debug(
|
|
1917
|
-
"pydantic_agent_created",
|
|
1918
|
-
model_name=selected_model,
|
|
1919
|
-
output_type=result_type.__name__,
|
|
1920
|
-
)
|
|
1921
|
-
self.logger.info(
|
|
1922
|
-
"pydantic_agent_prompt_metrics",
|
|
1923
|
-
result_type=result_type.__name__,
|
|
1924
|
-
model_name=selected_model,
|
|
1925
|
-
system_prompt_chars=system_prompt_chars,
|
|
1926
|
-
user_prompt_chars=user_prompt_chars,
|
|
1927
|
-
total_prompt_chars=total_prompt_chars,
|
|
1928
|
-
approx_prompt_tokens=approx_prompt_tokens,
|
|
1929
|
-
max_tokens=max_tokens or self.settings.max_tokens_per_request,
|
|
1930
|
-
toolset_count=len(toolsets or []),
|
|
1931
|
-
has_deps=deps is not None,
|
|
1932
|
-
max_turns=max_turns,
|
|
1933
|
-
max_tool_calls=max_tool_calls,
|
|
1934
|
-
)
|
|
1935
|
-
|
|
1936
|
-
# Use direct Agent creation with the selected model for test compatibility
|
|
1937
|
-
from pydantic_ai import Agent
|
|
1938
|
-
from pydantic_ai.settings import ModelSettings
|
|
1939
|
-
from pydantic_ai.usage import UsageLimits
|
|
1940
|
-
|
|
1941
|
-
# Build the model - use cached or build new
|
|
1942
|
-
model = self._pydantic_model or self._build_pydantic_ai_model(selected_model)
|
|
1943
|
-
|
|
1944
|
-
agent_retries, output_retries = self._resolve_agent_retry_policy()
|
|
1945
|
-
agent_kwargs: dict[str, Any] = {
|
|
1946
|
-
"model": model,
|
|
1947
|
-
"name": self.__class__.__name__,
|
|
1948
|
-
"output_type": result_type,
|
|
1949
|
-
"instructions": system_prompt,
|
|
1950
|
-
"retries": agent_retries,
|
|
1951
|
-
"output_retries": output_retries,
|
|
1952
|
-
"model_settings": ModelSettings(
|
|
1953
|
-
**self._build_run_model_settings(max_tokens or self.settings.max_tokens_per_request)
|
|
1954
|
-
),
|
|
1955
|
-
}
|
|
1956
|
-
self.logger.debug(
|
|
1957
|
-
"pydantic_agent_retry_policy",
|
|
1958
|
-
retries=agent_retries,
|
|
1959
|
-
output_retries=output_retries,
|
|
1960
|
-
configured_retries=getattr(self.settings, "agent_retries", None),
|
|
1961
|
-
configured_output_retries=getattr(self.settings, "output_retries", None),
|
|
1962
|
-
protocol=self.settings.protocol.value,
|
|
1963
|
-
)
|
|
1964
|
-
skill_policy_diagnostics = self._collect_skill_policy_diagnostics(toolsets)
|
|
1965
|
-
if toolsets:
|
|
1966
|
-
agent_kwargs["toolsets"] = toolsets
|
|
1967
|
-
self.logger.info(
|
|
1968
|
-
"pydantic_agent_toolsets_attached",
|
|
1969
|
-
toolset_count=len(toolsets),
|
|
1970
|
-
)
|
|
1971
|
-
if skill_policy_diagnostics:
|
|
1972
|
-
self.logger.info("pydantic_agent_skill_policy_diagnostics", **skill_policy_diagnostics)
|
|
1973
|
-
|
|
1974
|
-
agent: Agent[Any, Any] = Agent(**agent_kwargs)
|
|
1975
|
-
usage_limits: UsageLimits | None = None
|
|
1976
|
-
request_limit, tool_calls_limit = self._resolve_pydantic_usage_limits(
|
|
1977
|
-
max_turns=max_turns,
|
|
1978
|
-
max_tool_calls=max_tool_calls,
|
|
1979
|
-
)
|
|
1980
|
-
if request_limit is not None or tool_calls_limit is not None:
|
|
1981
|
-
usage_limits = UsageLimits(
|
|
1982
|
-
request_limit=request_limit,
|
|
1983
|
-
tool_calls_limit=tool_calls_limit,
|
|
1984
|
-
)
|
|
1985
|
-
self.logger.info(
|
|
1986
|
-
"pydantic_agent_usage_limits_applied",
|
|
1987
|
-
max_turns=max_turns,
|
|
1988
|
-
max_tool_calls=max_tool_calls,
|
|
1989
|
-
request_limit=request_limit,
|
|
1990
|
-
tool_calls_limit=tool_calls_limit,
|
|
1991
|
-
)
|
|
1992
|
-
|
|
1993
|
-
with trace_span(
|
|
1994
|
-
"llm.call",
|
|
1995
|
-
{
|
|
1996
|
-
"llm.model": model_name or self.settings.model_standard,
|
|
1997
|
-
"llm.protocol": self.settings.protocol.value,
|
|
1998
|
-
},
|
|
1999
|
-
):
|
|
2000
|
-
run_telemetry: dict[str, Any] = {
|
|
2001
|
-
"operation_id": operation_state["operation_id"],
|
|
2002
|
-
"operation_kind": operation_state["operation_kind"],
|
|
2003
|
-
"result_type": result_type.__name__,
|
|
2004
|
-
"protocol": self.settings.protocol.value,
|
|
2005
|
-
"model_name": selected_model,
|
|
2006
|
-
"event_tool_calls": 0,
|
|
2007
|
-
"event_tool_calls_started": 0,
|
|
2008
|
-
"event_tool_effective_calls": 0,
|
|
2009
|
-
"event_skill_tool_calls": 0,
|
|
2010
|
-
"event_skill_discovery_tool_calls": 0,
|
|
2011
|
-
"event_skill_bootstrap_tool_calls": 0,
|
|
2012
|
-
"event_skill_execution_tool_calls": 0,
|
|
2013
|
-
"event_skill_execution_effective_tool_calls": 0,
|
|
2014
|
-
"event_tool_calls_completed": 0,
|
|
2015
|
-
"event_skill_effective_tool_calls": 0,
|
|
2016
|
-
"event_tool_names": [],
|
|
2017
|
-
"event_tool_signatures": [],
|
|
2018
|
-
"event_tool_count_by_name": {},
|
|
2019
|
-
"event_tool_effective_count_by_name": {},
|
|
2020
|
-
"event_skill_tool_count_by_name": {},
|
|
2021
|
-
"event_tool_latencies_ms": [],
|
|
2022
|
-
"_tool_call_started_at": {},
|
|
2023
|
-
"event_last_seen_at": time.monotonic(),
|
|
2024
|
-
"event_last_tool_activity_at": None,
|
|
2025
|
-
}
|
|
2026
|
-
operation_state["run_telemetry"] = run_telemetry
|
|
2027
|
-
if skill_policy_diagnostics:
|
|
2028
|
-
run_telemetry["skill_policy_diagnostics"] = skill_policy_diagnostics
|
|
2029
|
-
# Keep latest telemetry available even when the run fails (e.g., request_limit),
|
|
2030
|
-
# so higher-level retry/guard logic can inspect partial tool usage.
|
|
2031
|
-
self._last_agent_run_telemetry = run_telemetry
|
|
2032
|
-
run_kwargs: dict[str, Any] = {}
|
|
2033
|
-
if deps is not None:
|
|
2034
|
-
run_kwargs["deps"] = deps
|
|
2035
|
-
if usage_limits is not None:
|
|
2036
|
-
run_kwargs["usage_limits"] = usage_limits
|
|
2037
|
-
event_stream_requested = bool(getattr(self.settings, "agent_event_stream_enabled", True))
|
|
2038
|
-
suppress_event_stream_for_endpoint = (
|
|
2039
|
-
event_stream_requested and self._should_suppress_anthropic_tool_choice()
|
|
2040
|
-
)
|
|
2041
|
-
if event_stream_requested and not suppress_event_stream_for_endpoint:
|
|
2042
|
-
run_kwargs["event_stream_handler"] = self._build_event_stream_handler(start_time, run_telemetry)
|
|
2043
|
-
elif suppress_event_stream_for_endpoint:
|
|
2044
|
-
self.logger.info(
|
|
2045
|
-
"anthropic_proxy_event_stream_disabled",
|
|
2046
|
-
base_url=self.settings.base_url,
|
|
2047
|
-
protocol=self.settings.protocol.value,
|
|
2048
|
-
)
|
|
2049
|
-
timeout_policy = self._resolve_agent_timeout_policy(complexity)
|
|
2050
|
-
self.logger.info(
|
|
2051
|
-
"pydantic_agent_timeout_policy",
|
|
2052
|
-
result_type=result_type.__name__,
|
|
2053
|
-
initial_timeout_seconds=round(timeout_policy.initial_timeout_seconds, 2),
|
|
2054
|
-
max_timeout_seconds=round(timeout_policy.max_timeout_seconds, 2),
|
|
2055
|
-
extension_seconds=round(timeout_policy.extension_seconds, 2),
|
|
2056
|
-
extension_attempts=timeout_policy.extension_attempts,
|
|
2057
|
-
heartbeat_seconds=round(timeout_policy.heartbeat_seconds, 2),
|
|
2058
|
-
idle_post_tool_seconds=round(timeout_policy.idle_post_tool_seconds, 2),
|
|
2059
|
-
)
|
|
2060
|
-
event_stream_enabled = "event_stream_handler" in run_kwargs
|
|
2061
|
-
operation_state["event_stream_enabled"] = event_stream_enabled
|
|
2062
|
-
rate_limit_retry_attempt = 0
|
|
2063
|
-
max_rate_limit_retries = max(0, int(getattr(self.settings, "agent_rate_limit_retry_attempts", 2) or 0))
|
|
2064
|
-
base_rate_limit_backoff = float(
|
|
2065
|
-
getattr(self.settings, "agent_rate_limit_retry_backoff_seconds", 2.0) or 2.0
|
|
2066
|
-
)
|
|
2067
|
-
max_retry_after_seconds = 120.0
|
|
2068
|
-
tool_call_retry_attempt = 0
|
|
2069
|
-
max_tool_call_retries = max(0, int(getattr(self.settings, "agent_tool_call_retry_attempts", 2) or 0))
|
|
2070
|
-
base_tool_call_backoff = float(
|
|
2071
|
-
getattr(self.settings, "agent_tool_call_retry_backoff_seconds", 1.0) or 1.0
|
|
2072
|
-
)
|
|
2073
|
-
codex_auth_retry_attempt = 0
|
|
2074
|
-
max_codex_auth_retries = 1
|
|
2075
|
-
try:
|
|
2076
|
-
result = await self._run_with_timeout_policy(
|
|
2077
|
-
operation=self._build_agent_operation(
|
|
2078
|
-
agent=agent, user_prompt=user_prompt, run_kwargs=run_kwargs
|
|
2079
|
-
),
|
|
2080
|
-
timeout_policy=timeout_policy,
|
|
2081
|
-
result_type_name=result_type.__name__,
|
|
2082
|
-
run_telemetry=run_telemetry,
|
|
2083
|
-
)
|
|
2084
|
-
except Exception as exc:
|
|
2085
|
-
recovered_output = self._recover_output_from_final_result_validation_error(
|
|
2086
|
-
result_type=result_type,
|
|
2087
|
-
exc=exc,
|
|
2088
|
-
telemetry=run_telemetry,
|
|
2089
|
-
)
|
|
2090
|
-
if recovered_output is not None:
|
|
2091
|
-
self.logger.warning(
|
|
2092
|
-
"pydantic_agent_output_recovered_from_final_result_payload",
|
|
2093
|
-
result_type=result_type.__name__,
|
|
2094
|
-
)
|
|
2095
|
-
run_telemetry["output_recovered_from_final_result_payload"] = True
|
|
2096
|
-
run_telemetry.pop("_tool_call_started_at", None)
|
|
2097
|
-
self._last_agent_run_telemetry = run_telemetry
|
|
2098
|
-
operation_state["operation_status"] = "completed"
|
|
2099
|
-
operation_state["operation_outcome"] = "recovered_output"
|
|
2100
|
-
return recovered_output
|
|
2101
|
-
if (
|
|
2102
|
-
self.settings.protocol == LLMProtocolType.ANTHROPIC
|
|
2103
|
-
and bool(getattr(self.settings, "base_url", ""))
|
|
2104
|
-
and self._is_tool_choice_protocol_mismatch(exc)
|
|
2105
|
-
):
|
|
2106
|
-
raise RuntimeError(
|
|
2107
|
-
"anthropic protocol mismatch: endpoint rejected tool_choice/function payload. "
|
|
2108
|
-
"Use an Anthropic Messages-compatible proxy."
|
|
2109
|
-
) from exc
|
|
2110
|
-
auth_recovered = False
|
|
2111
|
-
while (
|
|
2112
|
-
self._is_openai_codex_protocol(self.settings.protocol)
|
|
2113
|
-
and self._is_auth_error(exc)
|
|
2114
|
-
and codex_auth_retry_attempt < max_codex_auth_retries
|
|
2115
|
-
):
|
|
2116
|
-
codex_auth_retry_attempt += 1
|
|
2117
|
-
operation_state["codex_auth_retry_attempts"] = codex_auth_retry_attempt
|
|
2118
|
-
self.logger.warning(
|
|
2119
|
-
"pydantic_agent_codex_auth_retry",
|
|
2120
|
-
result_type=result_type.__name__,
|
|
2121
|
-
retry_attempt=codex_auth_retry_attempt,
|
|
2122
|
-
retry_attempts=max_codex_auth_retries,
|
|
2123
|
-
error=str(exc),
|
|
2124
|
-
)
|
|
2125
|
-
try:
|
|
2126
|
-
from vds_audit_orchestrator.llm.codex_oauth import force_refresh_codex_credentials
|
|
2127
|
-
|
|
2128
|
-
force_refresh_codex_credentials()
|
|
2129
|
-
refreshed_model = self._build_pydantic_ai_model(selected_model)
|
|
2130
|
-
self._pydantic_model = refreshed_model
|
|
2131
|
-
refreshed_agent_kwargs = dict(agent_kwargs)
|
|
2132
|
-
refreshed_agent_kwargs["model"] = refreshed_model
|
|
2133
|
-
agent = Agent(**refreshed_agent_kwargs)
|
|
2134
|
-
result = await self._run_with_timeout_policy(
|
|
2135
|
-
operation=self._build_agent_operation(
|
|
2136
|
-
agent=agent, user_prompt=user_prompt, run_kwargs=run_kwargs
|
|
2137
|
-
),
|
|
2138
|
-
timeout_policy=timeout_policy,
|
|
2139
|
-
result_type_name=result_type.__name__,
|
|
2140
|
-
run_telemetry=run_telemetry,
|
|
2141
|
-
)
|
|
2142
|
-
auth_recovered = True
|
|
2143
|
-
self.logger.info(
|
|
2144
|
-
"pydantic_agent_codex_auth_recovered",
|
|
2145
|
-
result_type=result_type.__name__,
|
|
2146
|
-
retry_attempt=codex_auth_retry_attempt,
|
|
2147
|
-
)
|
|
2148
|
-
break
|
|
2149
|
-
except Exception as auth_retry_exc:
|
|
2150
|
-
exc = auth_retry_exc
|
|
2151
|
-
rate_limit_recovered = False
|
|
2152
|
-
if auth_recovered:
|
|
2153
|
-
rate_limit_recovered = True
|
|
2154
|
-
while self._is_rate_limit_error(exc) and rate_limit_retry_attempt < max_rate_limit_retries:
|
|
2155
|
-
rate_limit_retry_attempt += 1
|
|
2156
|
-
operation_state["rate_limit_retry_attempts"] = rate_limit_retry_attempt
|
|
2157
|
-
classification = ProviderFailureClassifier.classify(exc)
|
|
2158
|
-
retry_backoff = classification.retry_after_seconds
|
|
2159
|
-
if retry_backoff is not None:
|
|
2160
|
-
retry_backoff = min(max_retry_after_seconds, max(0.0, retry_backoff))
|
|
2161
|
-
if retry_backoff is None:
|
|
2162
|
-
retry_backoff = min(
|
|
2163
|
-
30.0,
|
|
2164
|
-
base_rate_limit_backoff * (2 ** (rate_limit_retry_attempt - 1)),
|
|
2165
|
-
)
|
|
2166
|
-
# Keep tiny jitter to reduce synchronized retry bursts from parallel agents.
|
|
2167
|
-
retry_backoff += random.uniform(0.0, min(1.0, retry_backoff * 0.2))
|
|
2168
|
-
run_telemetry["provider_transient_retry_count"] = rate_limit_retry_attempt
|
|
2169
|
-
run_telemetry["retry_after_honored"] = classification.retry_after_seconds is not None
|
|
2170
|
-
run_telemetry["retry_after_seconds"] = (
|
|
2171
|
-
round(retry_backoff, 2) if classification.retry_after_seconds is not None else 0.0
|
|
2172
|
-
)
|
|
2173
|
-
run_telemetry["provider_retry_class"] = classification.failure_class.value
|
|
2174
|
-
run_telemetry["provider_retry_reason"] = classification.classification_reason
|
|
2175
|
-
self.logger.warning(
|
|
2176
|
-
"pydantic_agent_rate_limit_retry",
|
|
2177
|
-
result_type=result_type.__name__,
|
|
2178
|
-
retry_attempt=rate_limit_retry_attempt,
|
|
2179
|
-
retry_attempts=max_rate_limit_retries,
|
|
2180
|
-
backoff_seconds=round(retry_backoff, 2),
|
|
2181
|
-
retry_after_honored=classification.retry_after_seconds is not None,
|
|
2182
|
-
provider_failure_class=classification.failure_class.value,
|
|
2183
|
-
retry_reason=classification.classification_reason,
|
|
2184
|
-
error=str(exc),
|
|
2185
|
-
)
|
|
2186
|
-
await asyncio.sleep(retry_backoff)
|
|
2187
|
-
try:
|
|
2188
|
-
result = await self._run_with_timeout_policy(
|
|
2189
|
-
operation=self._build_agent_operation(
|
|
2190
|
-
agent=agent, user_prompt=user_prompt, run_kwargs=run_kwargs
|
|
2191
|
-
),
|
|
2192
|
-
timeout_policy=timeout_policy,
|
|
2193
|
-
result_type_name=result_type.__name__,
|
|
2194
|
-
run_telemetry=run_telemetry,
|
|
2195
|
-
)
|
|
2196
|
-
rate_limit_recovered = True
|
|
2197
|
-
self.logger.info(
|
|
2198
|
-
"pydantic_agent_rate_limit_recovered",
|
|
2199
|
-
result_type=result_type.__name__,
|
|
2200
|
-
retry_attempt=rate_limit_retry_attempt,
|
|
2201
|
-
provider_failure_class=classification.failure_class.value,
|
|
2202
|
-
)
|
|
2203
|
-
break
|
|
2204
|
-
except Exception as rate_limit_retry_exc:
|
|
2205
|
-
exc = rate_limit_retry_exc
|
|
2206
|
-
tool_call_recovered = False
|
|
2207
|
-
while self._is_tool_call_argument_error(exc) and tool_call_retry_attempt < max_tool_call_retries:
|
|
2208
|
-
tool_call_retry_attempt += 1
|
|
2209
|
-
operation_state["tool_call_retry_attempts"] = tool_call_retry_attempt
|
|
2210
|
-
retry_backoff = min(20.0, base_tool_call_backoff * (2 ** (tool_call_retry_attempt - 1)))
|
|
2211
|
-
retry_backoff += random.uniform(0.0, min(0.5, retry_backoff * 0.2))
|
|
2212
|
-
self.logger.warning(
|
|
2213
|
-
"pydantic_agent_tool_call_retry",
|
|
2214
|
-
result_type=result_type.__name__,
|
|
2215
|
-
retry_attempt=tool_call_retry_attempt,
|
|
2216
|
-
retry_attempts=max_tool_call_retries,
|
|
2217
|
-
backoff_seconds=round(retry_backoff, 2),
|
|
2218
|
-
error=str(exc),
|
|
2219
|
-
)
|
|
2220
|
-
await asyncio.sleep(retry_backoff)
|
|
2221
|
-
try:
|
|
2222
|
-
result = await self._run_with_timeout_policy(
|
|
2223
|
-
operation=self._build_agent_operation(
|
|
2224
|
-
agent=agent, user_prompt=user_prompt, run_kwargs=run_kwargs
|
|
2225
|
-
),
|
|
2226
|
-
timeout_policy=timeout_policy,
|
|
2227
|
-
result_type_name=result_type.__name__,
|
|
2228
|
-
run_telemetry=run_telemetry,
|
|
2229
|
-
)
|
|
2230
|
-
tool_call_recovered = True
|
|
2231
|
-
self.logger.info(
|
|
2232
|
-
"pydantic_agent_tool_call_recovered",
|
|
2233
|
-
result_type=result_type.__name__,
|
|
2234
|
-
retry_attempt=tool_call_retry_attempt,
|
|
2235
|
-
)
|
|
2236
|
-
break
|
|
2237
|
-
except Exception as tool_call_retry_exc:
|
|
2238
|
-
exc = tool_call_retry_exc
|
|
2239
|
-
if not rate_limit_recovered and not tool_call_recovered:
|
|
2240
|
-
should_retry_without_stream = event_stream_enabled and self._should_retry_without_event_stream(
|
|
2241
|
-
exc
|
|
2242
|
-
)
|
|
2243
|
-
if not should_retry_without_stream:
|
|
2244
|
-
failover_result = await self._attempt_row_provider_failover(
|
|
2245
|
-
exc=exc,
|
|
2246
|
-
system_prompt=system_prompt,
|
|
2247
|
-
user_prompt=user_prompt,
|
|
2248
|
-
result_type=result_type,
|
|
2249
|
-
complexity=complexity,
|
|
2250
|
-
max_tokens=max_tokens,
|
|
2251
|
-
prompt_type=prompt_type,
|
|
2252
|
-
deps=deps,
|
|
2253
|
-
toolsets=toolsets,
|
|
2254
|
-
max_turns=max_turns,
|
|
2255
|
-
max_tool_calls=max_tool_calls,
|
|
2256
|
-
pre_retry_telemetry=pre_retry_telemetry,
|
|
2257
|
-
current_run_telemetry=run_telemetry,
|
|
2258
|
-
row_failover_context=row_failover_context,
|
|
2259
|
-
provider_health_memory=provider_health_memory,
|
|
2260
|
-
)
|
|
2261
|
-
if failover_result is not None:
|
|
2262
|
-
operation_state["operation_status"] = "completed"
|
|
2263
|
-
operation_state["operation_outcome"] = "provider_failover"
|
|
2264
|
-
run_telemetry.pop("_tool_call_started_at", None)
|
|
2265
|
-
self._last_agent_run_telemetry = self._merge_failover_telemetry(
|
|
2266
|
-
pre_retry_telemetry,
|
|
2267
|
-
run_telemetry,
|
|
2268
|
-
)
|
|
2269
|
-
return failover_result
|
|
2270
|
-
elapsed = time.monotonic() - start_time
|
|
2271
|
-
tool_efficiency = self._build_tool_efficiency_summary(run_telemetry)
|
|
2272
|
-
if tool_efficiency:
|
|
2273
|
-
run_telemetry["tool_efficiency"] = tool_efficiency
|
|
2274
|
-
run_telemetry["error"] = str(exc)
|
|
2275
|
-
run_telemetry.pop("_tool_call_started_at", None)
|
|
2276
|
-
self._last_agent_run_telemetry = run_telemetry
|
|
2277
|
-
self.logger.warning(
|
|
2278
|
-
"pydantic_agent_call_failed",
|
|
2279
|
-
elapsed_sec=round(elapsed, 2),
|
|
2280
|
-
mode="pydantic_ai",
|
|
2281
|
-
result_type=result_type.__name__,
|
|
2282
|
-
operation_id=operation_state["operation_id"],
|
|
2283
|
-
event_tool_calls_started=int(run_telemetry.get("event_tool_calls_started", 0) or 0),
|
|
2284
|
-
event_tool_calls_completed=int(
|
|
2285
|
-
run_telemetry.get(
|
|
2286
|
-
"event_tool_calls_completed", run_telemetry.get("event_tool_calls", 0)
|
|
2287
|
-
)
|
|
2288
|
-
or 0
|
|
2289
|
-
),
|
|
2290
|
-
event_skill_tool_calls=int(run_telemetry.get("event_skill_tool_calls", 0) or 0),
|
|
2291
|
-
event_skill_effective_tool_calls=int(
|
|
2292
|
-
run_telemetry.get("event_skill_effective_tool_calls", 0) or 0
|
|
2293
|
-
),
|
|
2294
|
-
observed_tool_names=run_telemetry.get("event_tool_names"),
|
|
2295
|
-
**self._exception_diagnostics(exc),
|
|
2296
|
-
)
|
|
2297
|
-
raise
|
|
2298
|
-
self.logger.warning(
|
|
2299
|
-
"pydantic_agent_event_stream_fallback",
|
|
2300
|
-
error=str(exc),
|
|
2301
|
-
)
|
|
2302
|
-
run_kwargs.pop("event_stream_handler", None)
|
|
2303
|
-
run_telemetry["event_stream_fallback_activated"] = True
|
|
2304
|
-
try:
|
|
2305
|
-
result = await self._run_with_timeout_policy(
|
|
2306
|
-
operation=self._build_agent_operation(
|
|
2307
|
-
agent=agent, user_prompt=user_prompt, run_kwargs=run_kwargs
|
|
2308
|
-
),
|
|
2309
|
-
timeout_policy=timeout_policy,
|
|
2310
|
-
result_type_name=result_type.__name__,
|
|
2311
|
-
run_telemetry=run_telemetry,
|
|
2312
|
-
)
|
|
2313
|
-
# FR-70 / TSK-641.2: Populate telemetry from result when
|
|
2314
|
-
# event stream was removed. Without this the telemetry
|
|
2315
|
-
# dict stays at zeros and post-run guards raise false
|
|
2316
|
-
# RuntimeError("agentic usage guard unsatisfied").
|
|
2317
|
-
self._populate_telemetry_from_result(result, run_telemetry)
|
|
2318
|
-
except Exception as fallback_exc:
|
|
2319
|
-
fallback_tool_call_recovered = False
|
|
2320
|
-
fallback_tool_call_retry_attempt = 0
|
|
2321
|
-
while (
|
|
2322
|
-
self._is_tool_call_argument_error(fallback_exc)
|
|
2323
|
-
and fallback_tool_call_retry_attempt < max_tool_call_retries
|
|
2324
|
-
):
|
|
2325
|
-
fallback_tool_call_retry_attempt += 1
|
|
2326
|
-
operation_state["tool_call_retry_attempts"] = max(
|
|
2327
|
-
int(operation_state.get("tool_call_retry_attempts", 0) or 0),
|
|
2328
|
-
fallback_tool_call_retry_attempt,
|
|
2329
|
-
)
|
|
2330
|
-
retry_backoff = min(
|
|
2331
|
-
20.0,
|
|
2332
|
-
base_tool_call_backoff * (2 ** (fallback_tool_call_retry_attempt - 1)),
|
|
2333
|
-
)
|
|
2334
|
-
retry_backoff += random.uniform(0.0, min(0.5, retry_backoff * 0.2))
|
|
2335
|
-
self.logger.warning(
|
|
2336
|
-
"pydantic_agent_tool_call_retry",
|
|
2337
|
-
result_type=result_type.__name__,
|
|
2338
|
-
retry_attempt=fallback_tool_call_retry_attempt,
|
|
2339
|
-
retry_attempts=max_tool_call_retries,
|
|
2340
|
-
backoff_seconds=round(retry_backoff, 2),
|
|
2341
|
-
error=str(fallback_exc),
|
|
2342
|
-
retry_mode="event_stream_fallback",
|
|
2343
|
-
)
|
|
2344
|
-
await asyncio.sleep(retry_backoff)
|
|
2345
|
-
try:
|
|
2346
|
-
result = await self._run_with_timeout_policy(
|
|
2347
|
-
operation=self._build_agent_operation(
|
|
2348
|
-
agent=agent, user_prompt=user_prompt, run_kwargs=run_kwargs
|
|
2349
|
-
),
|
|
2350
|
-
timeout_policy=timeout_policy,
|
|
2351
|
-
result_type_name=result_type.__name__,
|
|
2352
|
-
run_telemetry=run_telemetry,
|
|
2353
|
-
)
|
|
2354
|
-
fallback_tool_call_recovered = True
|
|
2355
|
-
self.logger.info(
|
|
2356
|
-
"pydantic_agent_tool_call_recovered",
|
|
2357
|
-
result_type=result_type.__name__,
|
|
2358
|
-
retry_attempt=fallback_tool_call_retry_attempt,
|
|
2359
|
-
retry_mode="event_stream_fallback",
|
|
2360
|
-
)
|
|
2361
|
-
break
|
|
2362
|
-
except Exception as fallback_tool_call_retry_exc:
|
|
2363
|
-
fallback_exc = fallback_tool_call_retry_exc
|
|
2364
|
-
|
|
2365
|
-
if fallback_tool_call_recovered:
|
|
2366
|
-
self._populate_telemetry_from_result(result, run_telemetry)
|
|
2367
|
-
elapsed = time.monotonic() - start_time
|
|
2368
|
-
self.logger.info(
|
|
2369
|
-
"pydantic_agent_fallback_recovered",
|
|
2370
|
-
elapsed_sec=round(elapsed, 2),
|
|
2371
|
-
result_type=result_type.__name__,
|
|
2372
|
-
mode="pydantic_ai",
|
|
2373
|
-
)
|
|
2374
|
-
# Continue to normal post-processing with recovered result.
|
|
2375
|
-
pass
|
|
2376
|
-
else:
|
|
2377
|
-
recovered_output = self._recover_output_from_final_result_validation_error(
|
|
2378
|
-
result_type=result_type,
|
|
2379
|
-
exc=fallback_exc,
|
|
2380
|
-
telemetry=run_telemetry,
|
|
2381
|
-
)
|
|
2382
|
-
if recovered_output is not None:
|
|
2383
|
-
self.logger.warning(
|
|
2384
|
-
"pydantic_agent_output_recovered_from_final_result_payload",
|
|
2385
|
-
result_type=result_type.__name__,
|
|
2386
|
-
)
|
|
2387
|
-
run_telemetry["output_recovered_from_final_result_payload"] = True
|
|
2388
|
-
run_telemetry.pop("_tool_call_started_at", None)
|
|
2389
|
-
self._last_agent_run_telemetry = run_telemetry
|
|
2390
|
-
operation_state["operation_status"] = "completed"
|
|
2391
|
-
operation_state["operation_outcome"] = "recovered_output"
|
|
2392
|
-
return recovered_output
|
|
2393
|
-
failover_result = await self._attempt_row_provider_failover(
|
|
2394
|
-
exc=fallback_exc,
|
|
2395
|
-
system_prompt=system_prompt,
|
|
2396
|
-
user_prompt=user_prompt,
|
|
2397
|
-
result_type=result_type,
|
|
2398
|
-
complexity=complexity,
|
|
2399
|
-
max_tokens=max_tokens,
|
|
2400
|
-
prompt_type=prompt_type,
|
|
2401
|
-
deps=deps,
|
|
2402
|
-
toolsets=toolsets,
|
|
2403
|
-
max_turns=max_turns,
|
|
2404
|
-
max_tool_calls=max_tool_calls,
|
|
2405
|
-
pre_retry_telemetry=pre_retry_telemetry,
|
|
2406
|
-
current_run_telemetry=run_telemetry,
|
|
2407
|
-
row_failover_context=row_failover_context,
|
|
2408
|
-
provider_health_memory=provider_health_memory,
|
|
2409
|
-
)
|
|
2410
|
-
if failover_result is not None:
|
|
2411
|
-
operation_state["operation_status"] = "completed"
|
|
2412
|
-
operation_state["operation_outcome"] = "provider_failover"
|
|
2413
|
-
run_telemetry.pop("_tool_call_started_at", None)
|
|
2414
|
-
self._last_agent_run_telemetry = self._merge_failover_telemetry(
|
|
2415
|
-
pre_retry_telemetry,
|
|
2416
|
-
run_telemetry,
|
|
2417
|
-
)
|
|
2418
|
-
return failover_result
|
|
2419
|
-
elapsed = time.monotonic() - start_time
|
|
2420
|
-
tool_efficiency = self._build_tool_efficiency_summary(run_telemetry)
|
|
2421
|
-
if tool_efficiency:
|
|
2422
|
-
run_telemetry["tool_efficiency"] = tool_efficiency
|
|
2423
|
-
run_telemetry["error"] = str(fallback_exc)
|
|
2424
|
-
run_telemetry.pop("_tool_call_started_at", None)
|
|
2425
|
-
self._last_agent_run_telemetry = run_telemetry
|
|
2426
|
-
self.logger.warning(
|
|
2427
|
-
"pydantic_agent_call_failed",
|
|
2428
|
-
elapsed_sec=round(elapsed, 2),
|
|
2429
|
-
mode="pydantic_ai",
|
|
2430
|
-
result_type=result_type.__name__,
|
|
2431
|
-
operation_id=operation_state["operation_id"],
|
|
2432
|
-
event_tool_calls_started=int(run_telemetry.get("event_tool_calls_started", 0) or 0),
|
|
2433
|
-
event_tool_calls_completed=int(
|
|
2434
|
-
run_telemetry.get(
|
|
2435
|
-
"event_tool_calls_completed", run_telemetry.get("event_tool_calls", 0)
|
|
2436
|
-
)
|
|
2437
|
-
or 0
|
|
2438
|
-
),
|
|
2439
|
-
event_skill_tool_calls=int(run_telemetry.get("event_skill_tool_calls", 0) or 0),
|
|
2440
|
-
event_skill_effective_tool_calls=int(
|
|
2441
|
-
run_telemetry.get("event_skill_effective_tool_calls", 0) or 0
|
|
2442
|
-
),
|
|
2443
|
-
observed_tool_names=run_telemetry.get("event_tool_names"),
|
|
2444
|
-
**self._exception_diagnostics(fallback_exc),
|
|
2445
|
-
)
|
|
2446
|
-
raise
|
|
2447
|
-
|
|
2448
|
-
elapsed = time.monotonic() - start_time
|
|
2449
|
-
raw_output = result.output if hasattr(result, "output") else getattr(result, "data", None)
|
|
2450
|
-
output = self._normalize_agent_output(raw_output, result_type)
|
|
2451
|
-
if not event_stream_enabled:
|
|
2452
|
-
# Non-stream Anthropic/proxy paths do not emit event callbacks, so
|
|
2453
|
-
# backfill tool/usage telemetry from RunResult to keep grounding
|
|
2454
|
-
# guards and efficiency metrics accurate.
|
|
2455
|
-
self._populate_telemetry_from_result(result, run_telemetry)
|
|
2456
|
-
|
|
2457
|
-
# Log response summary for debugging
|
|
2458
|
-
response_summary = self._summarize_output(output)
|
|
2459
|
-
self.logger.info(
|
|
2460
|
-
"pydantic_agent_call_complete",
|
|
2461
|
-
elapsed_sec=round(elapsed, 2),
|
|
2462
|
-
mode="pydantic_ai",
|
|
2463
|
-
result_type=result_type.__name__,
|
|
2464
|
-
operation_id=operation_state["operation_id"],
|
|
2465
|
-
**response_summary,
|
|
2466
|
-
)
|
|
2467
|
-
|
|
2468
|
-
usage_summary = self._record_pydantic_usage(result, prompt_type=f"{prompt_type}:{self.__class__.__name__}")
|
|
2469
|
-
run_telemetry["usage"] = usage_summary or {}
|
|
2470
|
-
tool_efficiency = self._build_tool_efficiency_summary(run_telemetry)
|
|
2471
|
-
if tool_efficiency:
|
|
2472
|
-
run_telemetry["tool_efficiency"] = tool_efficiency
|
|
2473
|
-
self.logger.info(
|
|
2474
|
-
"pydantic_agent_tool_efficiency",
|
|
2475
|
-
result_type=result_type.__name__,
|
|
2476
|
-
**tool_efficiency,
|
|
2477
|
-
)
|
|
2478
|
-
if pre_retry_telemetry:
|
|
2479
|
-
combined_telemetry = dict(pre_retry_telemetry)
|
|
2480
|
-
for key in [
|
|
2481
|
-
"event_tool_calls",
|
|
2482
|
-
"event_tool_calls_started",
|
|
2483
|
-
"event_tool_calls_completed",
|
|
2484
|
-
"event_tool_effective_calls",
|
|
2485
|
-
"event_skill_tool_calls",
|
|
2486
|
-
"event_skill_discovery_tool_calls",
|
|
2487
|
-
"event_skill_bootstrap_tool_calls",
|
|
2488
|
-
"event_skill_execution_tool_calls",
|
|
2489
|
-
"event_skill_execution_effective_tool_calls",
|
|
2490
|
-
"event_skill_effective_tool_calls",
|
|
2491
|
-
]:
|
|
2492
|
-
combined_telemetry[key] = int(combined_telemetry.get(key, 0) or 0) + int(
|
|
2493
|
-
run_telemetry.get(key, 0) or 0
|
|
2494
|
-
)
|
|
2495
|
-
for dict_key in [
|
|
2496
|
-
"event_tool_count_by_name",
|
|
2497
|
-
"event_tool_effective_count_by_name",
|
|
2498
|
-
"event_skill_tool_count_by_name",
|
|
2499
|
-
]:
|
|
2500
|
-
combined_telemetry[dict_key] = dict(combined_telemetry.get(dict_key, {}))
|
|
2501
|
-
for k, v in (run_telemetry.get(dict_key) or {}).items():
|
|
2502
|
-
combined_telemetry[dict_key][k] = int(combined_telemetry[dict_key].get(k, 0) or 0) + int(v or 0)
|
|
2503
|
-
for list_key in ["event_tool_names", "event_tool_signatures"]:
|
|
2504
|
-
combined_telemetry[list_key] = list(combined_telemetry.get(list_key, [])) + list(
|
|
2505
|
-
run_telemetry.get(list_key) or []
|
|
2506
|
-
)
|
|
2507
|
-
merged_turn_effectiveness: dict[str, dict[str, Any]] = {}
|
|
2508
|
-
merged_turn_index = 0
|
|
2509
|
-
for source in (pre_retry_telemetry, run_telemetry):
|
|
2510
|
-
turn_payloads = source.get("event_turn_effectiveness")
|
|
2511
|
-
if not isinstance(turn_payloads, dict):
|
|
2512
|
-
continue
|
|
2513
|
-
for _, payload in sorted(
|
|
2514
|
-
(
|
|
2515
|
-
(int(str(turn_key)), value)
|
|
2516
|
-
for turn_key, value in turn_payloads.items()
|
|
2517
|
-
if str(turn_key).strip().isdigit() and isinstance(value, dict)
|
|
2518
|
-
),
|
|
2519
|
-
key=lambda item: item[0],
|
|
2520
|
-
):
|
|
2521
|
-
merged_turn_index += 1
|
|
2522
|
-
merged_turn_effectiveness[str(merged_turn_index)] = dict(payload)
|
|
2523
|
-
if merged_turn_effectiveness:
|
|
2524
|
-
combined_telemetry["event_turn_effectiveness"] = merged_turn_effectiveness
|
|
2525
|
-
combined_telemetry["event_turn_index"] = merged_turn_index
|
|
2526
|
-
if isinstance(run_telemetry.get("skill_policy_diagnostics"), dict):
|
|
2527
|
-
combined_telemetry["skill_policy_diagnostics"] = dict(run_telemetry["skill_policy_diagnostics"])
|
|
2528
|
-
combined_telemetry = self._merge_failover_telemetry(combined_telemetry, run_telemetry)
|
|
2529
|
-
quality_summary = self._build_response_quality_summary(output, combined_telemetry)
|
|
2530
|
-
else:
|
|
2531
|
-
combined_telemetry = dict(run_telemetry)
|
|
2532
|
-
quality_summary = self._build_response_quality_summary(output, run_telemetry)
|
|
2533
|
-
quality_log = self.logger.info if bool(quality_summary.get("quality_ok", True)) else self.logger.warning
|
|
2534
|
-
quality_log(
|
|
2535
|
-
"pydantic_agent_response_quality",
|
|
2536
|
-
result_type=result_type.__name__,
|
|
2537
|
-
**quality_summary,
|
|
2538
|
-
)
|
|
2539
|
-
combined_telemetry.pop("_tool_call_started_at", None)
|
|
2540
|
-
combined_telemetry.pop("_tool_call_turn_index", None)
|
|
2541
|
-
self._last_agent_run_telemetry = combined_telemetry
|
|
2542
|
-
self._log_trace_payload(
|
|
2543
|
-
event_name="pydantic_agent_trace_response",
|
|
2544
|
-
elapsed_sec=elapsed,
|
|
2545
|
-
payload={
|
|
2546
|
-
"operation_id": operation_state["operation_id"],
|
|
2547
|
-
"result_type": result_type.__name__,
|
|
2548
|
-
"response_summary": response_summary,
|
|
2549
|
-
"response_quality": quality_summary,
|
|
2550
|
-
"usage": usage_summary or {},
|
|
2551
|
-
"tool_efficiency": tool_efficiency,
|
|
2552
|
-
"skill_policy_diagnostics": combined_telemetry.get("skill_policy_diagnostics"),
|
|
2553
|
-
"output": output,
|
|
2554
|
-
},
|
|
2555
|
-
)
|
|
2556
|
-
operation_state["operation_status"] = "completed"
|
|
2557
|
-
operation_state["operation_outcome"] = "success"
|
|
2558
|
-
return output # type: ignore[return-value]
|
|
2559
|
-
|
|
2560
|
-
def _resolve_agent_retry_policy(self) -> tuple[int, int]:
|
|
2561
|
-
"""Resolve model and output retry policy for PydanticAI runs.
|
|
2562
|
-
|
|
2563
|
-
Uses runtime settings by default. For Anthropic structured output,
|
|
2564
|
-
enforce a small minimum output retry floor to absorb transient shape mismatches.
|
|
2565
|
-
"""
|
|
2566
|
-
configured_retries = int(getattr(self.settings, "agent_retries", 2) or 0)
|
|
2567
|
-
configured_output_retries = int(getattr(self.settings, "output_retries", 2) or 0)
|
|
2568
|
-
|
|
2569
|
-
retries = max(configured_retries, 0)
|
|
2570
|
-
output_retries = max(configured_output_retries, 0)
|
|
2571
|
-
if self._should_suppress_anthropic_tool_choice():
|
|
2572
|
-
# Anthropic-compatible proxy gateways are more likely to emit
|
|
2573
|
-
# transient malformed tool-call JSON. Keep a small retry floor to
|
|
2574
|
-
# allow tool-call correction without manual reruns.
|
|
2575
|
-
retries = max(retries, 3)
|
|
2576
|
-
output_retries = max(output_retries, 2)
|
|
2577
|
-
if self.settings.protocol == LLMProtocolType.ANTHROPIC and str(self.settings.model_standard).lower().startswith(
|
|
2578
|
-
"claude"
|
|
2579
|
-
):
|
|
2580
|
-
# Anthropic-compatible proxies can occasionally append trailing
|
|
2581
|
-
# characters after otherwise-valid structured output; keep a slightly
|
|
2582
|
-
# higher validation retry floor to improve first-pass success.
|
|
2583
|
-
output_retries = max(output_retries, 4)
|
|
2584
|
-
return retries, output_retries
|
|
2585
|
-
|
|
2586
|
-
def _build_event_stream_handler(self, run_started_at: float, telemetry: dict[str, Any] | None = None):
|
|
2587
|
-
"""Build realtime PydanticAI stream handler for observability."""
|
|
2588
|
-
|
|
2589
|
-
async def _event_stream_handler(_run_context: Any, event_stream: Any) -> None:
|
|
2590
|
-
async for event in event_stream:
|
|
2591
|
-
self._log_pydantic_agent_event(event=event, run_started_at=run_started_at, telemetry=telemetry)
|
|
2592
|
-
|
|
2593
|
-
return _event_stream_handler
|
|
2594
|
-
|
|
2595
|
-
@staticmethod
|
|
2596
|
-
def _should_retry_without_event_stream(exc: Exception) -> bool:
|
|
2597
|
-
"""Return True when event streaming is unsupported for the active test/runtime model."""
|
|
2598
|
-
message = str(exc).lower()
|
|
2599
|
-
return (
|
|
2600
|
-
"stream_function" in message
|
|
2601
|
-
or "event_stream_handler" in message
|
|
2602
|
-
# Anthropic-compatible local proxies can emit tool-call deltas that
|
|
2603
|
-
# collide with ThinkingPart accumulation under event stream mode.
|
|
2604
|
-
# Retrying once without event_stream_handler avoids this parser path.
|
|
2605
|
-
or "cannot apply a tool call delta to existing_part=thinkingpart" in message
|
|
2606
|
-
)
|
|
2607
|
-
|
|
2608
|
-
@staticmethod
|
|
2609
|
-
def _is_rate_limit_error(exc: Exception) -> bool:
|
|
2610
|
-
"""Return True when provider failed with a retryable transient/quota class."""
|
|
2611
|
-
classification = ProviderFailureClassifier.classify(exc)
|
|
2612
|
-
return classification.failure_class in {
|
|
2613
|
-
ProviderFailureClass.RETRYABLE_TRANSIENT,
|
|
2614
|
-
ProviderFailureClass.QUOTA_OR_CAPACITY,
|
|
2615
|
-
ProviderFailureClass.PROVIDER_DEGRADED,
|
|
2616
|
-
}
|
|
2617
|
-
|
|
2618
|
-
@staticmethod
|
|
2619
|
-
def _is_auth_error(exc: Exception) -> bool:
|
|
2620
|
-
"""Return True when provider rejected request due to auth/token failure."""
|
|
2621
|
-
return ProviderFailureClassifier.classify(exc).failure_class == ProviderFailureClass.TERMINAL_AUTH
|
|
2622
|
-
|
|
2623
|
-
@staticmethod
|
|
2624
|
-
def _is_tool_call_argument_error(exc: Exception) -> bool:
|
|
2625
|
-
"""Return True when model output contains malformed/missing tool args JSON."""
|
|
2626
|
-
classification = ProviderFailureClassifier.classify(exc)
|
|
2627
|
-
raw_message = str(classification.raw_message or "")
|
|
2628
|
-
normalized = raw_message.lower()
|
|
2629
|
-
|
|
2630
|
-
has_tool_call_signal = (
|
|
2631
|
-
"toolretryerror" in normalized
|
|
2632
|
-
or "tool call" in normalized
|
|
2633
|
-
or "tool_call" in normalized
|
|
2634
|
-
or "tool '" in normalized
|
|
2635
|
-
or "include your response in a tool call" in normalized
|
|
2636
|
-
or "return text or include your response in a tool call" in normalized
|
|
2637
|
-
)
|
|
2638
|
-
has_json_shape_signal = (
|
|
2639
|
-
"jsondecodeerror" in normalized
|
|
2640
|
-
or "eof while parsing an object" in normalized
|
|
2641
|
-
or "expecting value" in normalized
|
|
2642
|
-
or "unterminated string" in normalized
|
|
2643
|
-
)
|
|
2644
|
-
|
|
2645
|
-
return (
|
|
2646
|
-
classification.classification_reason == "tool_call_argument_or_validation_error"
|
|
2647
|
-
or classification.failure_class == ProviderFailureClass.NON_PROVIDER_BUG
|
|
2648
|
-
) and (has_tool_call_signal or has_json_shape_signal)
|
|
2649
|
-
|
|
2650
|
-
@staticmethod
|
|
2651
|
-
def _is_tool_choice_protocol_mismatch(exc: Exception) -> bool:
|
|
2652
|
-
"""Return True when upstream rejects tool_choice/function payload shape."""
|
|
2653
|
-
message = str(exc).lower()
|
|
2654
|
-
cause = getattr(exc, "__cause__", None)
|
|
2655
|
-
cause_message = str(cause).lower() if cause is not None else ""
|
|
2656
|
-
combined = f"{message}\n{cause_message}"
|
|
2657
|
-
has_tool_choice = "tool_choice" in combined
|
|
2658
|
-
invalid_function = (
|
|
2659
|
-
"invalid value for `function`" in combined
|
|
2660
|
-
or "invalid value for function" in combined
|
|
2661
|
-
or '"function": null' in combined
|
|
2662
|
-
)
|
|
2663
|
-
return has_tool_choice and invalid_function
|
|
2664
|
-
|
|
2665
|
-
@staticmethod
|
|
2666
|
-
def _percentile(values: list[float], quantile: float) -> float:
|
|
2667
|
-
if not values:
|
|
2668
|
-
return 0.0
|
|
2669
|
-
sorted_vals = sorted(float(v) for v in values)
|
|
2670
|
-
if len(sorted_vals) == 1:
|
|
2671
|
-
return sorted_vals[0]
|
|
2672
|
-
q = min(1.0, max(0.0, float(quantile)))
|
|
2673
|
-
idx = round((len(sorted_vals) - 1) * q)
|
|
2674
|
-
return sorted_vals[idx]
|
|
2675
|
-
|
|
2676
|
-
@staticmethod
|
|
2677
|
-
def _tool_family_tool_names() -> dict[str, tuple[str, ...]]:
|
|
2678
|
-
return {
|
|
2679
|
-
"lexical": (
|
|
2680
|
-
"grep_search",
|
|
2681
|
-
"rg_search",
|
|
2682
|
-
"search_evidence",
|
|
2683
|
-
"read_evidence_document",
|
|
2684
|
-
),
|
|
2685
|
-
"structural": (
|
|
2686
|
-
"ast_grep_search",
|
|
2687
|
-
"get_definition",
|
|
2688
|
-
"find_references",
|
|
2689
|
-
"workspace_symbol",
|
|
2690
|
-
),
|
|
2691
|
-
"vector_docs": ("search_evidence_vector",),
|
|
2692
|
-
"vector_code": ("search_code_vector",),
|
|
2693
|
-
}
|
|
2694
|
-
|
|
2695
|
-
@classmethod
|
|
2696
|
-
def _resolve_tool_family(cls, tool_name: str) -> str | None:
|
|
2697
|
-
normalized = str(tool_name or "").strip()
|
|
2698
|
-
if not normalized:
|
|
2699
|
-
return None
|
|
2700
|
-
for family_name, tool_names in cls._tool_family_tool_names().items():
|
|
2701
|
-
if normalized in tool_names:
|
|
2702
|
-
return family_name
|
|
2703
|
-
return None
|
|
2704
|
-
|
|
2705
|
-
@staticmethod
|
|
2706
|
-
def _family_coverage_markers(family_name: str) -> dict[str, bool]:
|
|
2707
|
-
if family_name == "vector_docs":
|
|
2708
|
-
return {"requirements": True, "docs": True, "code": False}
|
|
2709
|
-
if family_name == "vector_code":
|
|
2710
|
-
return {"requirements": True, "docs": False, "code": True}
|
|
2711
|
-
if family_name == "structural":
|
|
2712
|
-
return {"requirements": True, "docs": False, "code": True}
|
|
2713
|
-
if family_name == "lexical":
|
|
2714
|
-
return {"requirements": True, "docs": False, "code": False}
|
|
2715
|
-
return {"requirements": False, "docs": False, "code": False}
|
|
2716
|
-
|
|
2717
|
-
@staticmethod
|
|
2718
|
-
def _coverage_contribution_level(markers: dict[str, bool], *, skill_effective_calls: int = 0) -> str:
|
|
2719
|
-
requirements = bool(markers.get("requirements"))
|
|
2720
|
-
docs = bool(markers.get("docs"))
|
|
2721
|
-
code = bool(markers.get("code"))
|
|
2722
|
-
if requirements and docs and code:
|
|
2723
|
-
return "high"
|
|
2724
|
-
if requirements and (docs or code):
|
|
2725
|
-
return "medium"
|
|
2726
|
-
if requirements or skill_effective_calls > 0:
|
|
2727
|
-
return "low"
|
|
2728
|
-
return "none"
|
|
2729
|
-
|
|
2730
|
-
@staticmethod
|
|
2731
|
-
def _is_skill_tool_name(tool_name: str) -> bool:
|
|
2732
|
-
normalized = str(tool_name or "").strip().lower()
|
|
2733
|
-
return normalized in {"list_skills", "load_skill", "read_skill_resource", "run_skill_script"}
|
|
2734
|
-
|
|
2735
|
-
@classmethod
|
|
2736
|
-
def _is_effective_skill_tool_payload(cls, *, tool_name: str, payload: Any) -> bool:
|
|
2737
|
-
"""Skill-specific usefulness guard to avoid discovery/read inflation."""
|
|
2738
|
-
normalized = str(tool_name or "").strip().lower()
|
|
2739
|
-
if normalized in {"list_skills", "load_skill"}:
|
|
2740
|
-
return False
|
|
2741
|
-
if normalized == "run_skill_script":
|
|
2742
|
-
if not isinstance(payload, dict):
|
|
2743
|
-
return False
|
|
2744
|
-
success_value = payload.get("success")
|
|
2745
|
-
stdout_value = payload.get("stdout")
|
|
2746
|
-
if isinstance(success_value, bool) and isinstance(stdout_value, str):
|
|
2747
|
-
return bool(success_value and stdout_value.strip())
|
|
2748
|
-
explicit_effective = payload.get("effective")
|
|
2749
|
-
return bool(explicit_effective) if isinstance(explicit_effective, bool) else False
|
|
2750
|
-
if normalized == "read_skill_resource":
|
|
2751
|
-
if not isinstance(payload, dict):
|
|
2752
|
-
return False
|
|
2753
|
-
if bool(payload.get("benefit_signal")) or bool(payload.get("applied")):
|
|
2754
|
-
return True
|
|
2755
|
-
evidence_refs = payload.get("evidence_refs")
|
|
2756
|
-
if isinstance(evidence_refs, list):
|
|
2757
|
-
return any(str(item).strip() for item in evidence_refs)
|
|
2758
|
-
return False
|
|
2759
|
-
return False
|
|
2760
|
-
|
|
2761
|
-
@classmethod
|
|
2762
|
-
def _is_effective_tool_payload(cls, payload: Any) -> bool:
|
|
2763
|
-
"""Best-effort usefulness check for tool result payloads."""
|
|
2764
|
-
if payload is None:
|
|
2765
|
-
return False
|
|
2766
|
-
if isinstance(payload, bool):
|
|
2767
|
-
return payload
|
|
2768
|
-
if isinstance(payload, (int, float)):
|
|
2769
|
-
return payload > 0
|
|
2770
|
-
if isinstance(payload, str):
|
|
2771
|
-
text = payload.strip()
|
|
2772
|
-
if not text:
|
|
2773
|
-
return False
|
|
2774
|
-
if text[0] in "{[":
|
|
2775
|
-
try:
|
|
2776
|
-
parsed = json.loads(text)
|
|
2777
|
-
except Exception:
|
|
2778
|
-
return True
|
|
2779
|
-
return cls._is_effective_tool_payload(parsed)
|
|
2780
|
-
return True
|
|
2781
|
-
if isinstance(payload, list):
|
|
2782
|
-
if not payload:
|
|
2783
|
-
return False
|
|
2784
|
-
if all(isinstance(item, str) for item in payload):
|
|
2785
|
-
return any(str(item).strip() for item in payload)
|
|
2786
|
-
return True
|
|
2787
|
-
if isinstance(payload, dict):
|
|
2788
|
-
success_value = payload.get("success")
|
|
2789
|
-
if isinstance(success_value, bool) and not success_value:
|
|
2790
|
-
# Explicit failures with no recovery signal should not be counted as effective.
|
|
2791
|
-
if not any(
|
|
2792
|
-
key in payload
|
|
2793
|
-
for key in (
|
|
2794
|
-
"hits",
|
|
2795
|
-
"refs",
|
|
2796
|
-
"accepted_count",
|
|
2797
|
-
"content",
|
|
2798
|
-
"ref",
|
|
2799
|
-
"path",
|
|
2800
|
-
"results",
|
|
2801
|
-
"result",
|
|
2802
|
-
)
|
|
2803
|
-
):
|
|
2804
|
-
return False
|
|
2805
|
-
hits = payload.get("hits")
|
|
2806
|
-
if isinstance(hits, list):
|
|
2807
|
-
return len(hits) > 0
|
|
2808
|
-
refs = payload.get("refs")
|
|
2809
|
-
if isinstance(refs, list):
|
|
2810
|
-
return len(refs) > 0
|
|
2811
|
-
accepted_count = payload.get("accepted_count")
|
|
2812
|
-
if isinstance(accepted_count, int):
|
|
2813
|
-
return accepted_count > 0
|
|
2814
|
-
content = payload.get("content")
|
|
2815
|
-
if isinstance(content, str):
|
|
2816
|
-
return bool(content.strip())
|
|
2817
|
-
results = payload.get("results")
|
|
2818
|
-
if isinstance(results, list):
|
|
2819
|
-
return len(results) > 0
|
|
2820
|
-
result_obj = payload.get("result")
|
|
2821
|
-
if result_obj is not None:
|
|
2822
|
-
return cls._is_effective_tool_payload(result_obj)
|
|
2823
|
-
ref_value = payload.get("ref")
|
|
2824
|
-
if isinstance(ref_value, str):
|
|
2825
|
-
return bool(ref_value.strip())
|
|
2826
|
-
found_value = payload.get("found")
|
|
2827
|
-
if isinstance(found_value, bool):
|
|
2828
|
-
return found_value
|
|
2829
|
-
path_value = payload.get("path")
|
|
2830
|
-
if isinstance(path_value, str) and path_value.strip():
|
|
2831
|
-
return True
|
|
2832
|
-
error_value = payload.get("error")
|
|
2833
|
-
if isinstance(error_value, str) and error_value.strip():
|
|
2834
|
-
return False
|
|
2835
|
-
if isinstance(success_value, bool):
|
|
2836
|
-
return success_value
|
|
2837
|
-
return bool(payload)
|
|
2838
|
-
return bool(payload)
|
|
2839
|
-
|
|
2840
|
-
@classmethod
|
|
2841
|
-
def _is_effective_tool_result_event(cls, result: Any, *, tool_name: str) -> bool:
|
|
2842
|
-
"""Determine whether a tool-result event produced useful output."""
|
|
2843
|
-
normalized_tool_name = str(tool_name or "").strip().lower()
|
|
2844
|
-
# Internal final_result tool events should not contribute to tool usefulness metrics.
|
|
2845
|
-
if normalized_tool_name == "final_result":
|
|
2846
|
-
return False
|
|
2847
|
-
if cls._is_skill_tool_name(normalized_tool_name):
|
|
2848
|
-
for attr in ("output", "content", "result", "data"):
|
|
2849
|
-
if not hasattr(result, attr):
|
|
2850
|
-
continue
|
|
2851
|
-
value = getattr(result, attr, None)
|
|
2852
|
-
if value is None:
|
|
2853
|
-
continue
|
|
2854
|
-
return cls._is_effective_skill_tool_payload(tool_name=normalized_tool_name, payload=value)
|
|
2855
|
-
return False
|
|
2856
|
-
for attr in ("output", "content", "result", "data"):
|
|
2857
|
-
if not hasattr(result, attr):
|
|
2858
|
-
continue
|
|
2859
|
-
value = getattr(result, attr, None)
|
|
2860
|
-
if value is None:
|
|
2861
|
-
continue
|
|
2862
|
-
if cls._is_effective_tool_payload(value):
|
|
2863
|
-
return True
|
|
2864
|
-
success_attr = getattr(result, "success", None)
|
|
2865
|
-
if isinstance(success_attr, bool):
|
|
2866
|
-
return success_attr
|
|
2867
|
-
return False
|
|
2868
|
-
|
|
2869
|
-
@classmethod
|
|
2870
|
-
def _build_tool_efficiency_summary(cls, telemetry: dict[str, Any] | None) -> dict[str, Any]:
|
|
2871
|
-
"""Build compact tool/skill efficiency metrics for monitoring."""
|
|
2872
|
-
if not isinstance(telemetry, dict):
|
|
2873
|
-
return {}
|
|
2874
|
-
usage = telemetry.get("usage")
|
|
2875
|
-
usage_tool_calls = int(usage.get("tool_calls", 0) or 0) if isinstance(usage, dict) else 0
|
|
2876
|
-
started = int(telemetry.get("event_tool_calls_started", 0) or 0)
|
|
2877
|
-
completed = int(telemetry.get("event_tool_calls_completed", telemetry.get("event_tool_calls", 0)) or 0)
|
|
2878
|
-
effective_calls = int(telemetry.get("event_tool_effective_calls", 0) or 0)
|
|
2879
|
-
effective_completed = max(completed, usage_tool_calls)
|
|
2880
|
-
if started <= 0 and effective_completed <= 0:
|
|
2881
|
-
return {}
|
|
2882
|
-
if effective_calls <= 0 and "event_tool_effective_calls" not in telemetry and effective_completed > 0:
|
|
2883
|
-
# Backward-compatible fallback for historical telemetry that only tracked completion.
|
|
2884
|
-
effective_calls = effective_completed
|
|
2885
|
-
tool_count_by_name = telemetry.get("event_tool_count_by_name")
|
|
2886
|
-
if not isinstance(tool_count_by_name, dict):
|
|
2887
|
-
tool_count_by_name = {}
|
|
2888
|
-
unique_tools_by_name = (
|
|
2889
|
-
len(tool_count_by_name) if tool_count_by_name else len(set(telemetry.get("event_tool_names") or []))
|
|
2890
|
-
)
|
|
2891
|
-
tool_signatures_raw = telemetry.get("event_tool_signatures")
|
|
2892
|
-
unique_tools_by_signature = (
|
|
2893
|
-
len({str(sig) for sig in tool_signatures_raw})
|
|
2894
|
-
if isinstance(tool_signatures_raw, list) and tool_signatures_raw
|
|
2895
|
-
else 0
|
|
2896
|
-
)
|
|
2897
|
-
unique_tools = unique_tools_by_signature if unique_tools_by_signature > 0 else unique_tools_by_name
|
|
2898
|
-
repeated_calls = max(0, effective_completed - unique_tools)
|
|
2899
|
-
completion_rate = (effective_completed / started) if started > 0 else 1.0
|
|
2900
|
-
|
|
2901
|
-
skill_count_by_name = telemetry.get("event_skill_tool_count_by_name")
|
|
2902
|
-
if not isinstance(skill_count_by_name, dict):
|
|
2903
|
-
skill_count_by_name = {}
|
|
2904
|
-
if not skill_count_by_name and isinstance(tool_count_by_name, dict):
|
|
2905
|
-
# Fallback: recover skill-class counters from generic tool names when
|
|
2906
|
-
# event-stream skill fields were not populated.
|
|
2907
|
-
recovered_skill_counts = {
|
|
2908
|
-
skill_tool: int(tool_count_by_name.get(skill_tool, 0) or 0)
|
|
2909
|
-
for skill_tool in ("list_skills", "load_skill", "read_skill_resource", "run_skill_script")
|
|
2910
|
-
if int(tool_count_by_name.get(skill_tool, 0) or 0) > 0
|
|
2911
|
-
}
|
|
2912
|
-
if recovered_skill_counts:
|
|
2913
|
-
skill_count_by_name = recovered_skill_counts
|
|
2914
|
-
skill_discovery_calls = int(
|
|
2915
|
-
telemetry.get("event_skill_discovery_tool_calls", skill_count_by_name.get("list_skills", 0)) or 0
|
|
2916
|
-
)
|
|
2917
|
-
skill_bootstrap_calls = int(
|
|
2918
|
-
telemetry.get("event_skill_bootstrap_tool_calls", skill_count_by_name.get("load_skill", 0)) or 0
|
|
2919
|
-
)
|
|
2920
|
-
derived_skill_execution_calls = int(skill_count_by_name.get("read_skill_resource", 0) or 0) + int(
|
|
2921
|
-
skill_count_by_name.get("run_skill_script", 0) or 0
|
|
2922
|
-
)
|
|
2923
|
-
if "event_skill_execution_tool_calls" in telemetry:
|
|
2924
|
-
skill_execution_calls = int(telemetry.get("event_skill_execution_tool_calls", 0) or 0)
|
|
2925
|
-
else:
|
|
2926
|
-
# FR-123: execution effectiveness is derived from execution-class skill tools only.
|
|
2927
|
-
skill_execution_calls = derived_skill_execution_calls
|
|
2928
|
-
legacy_effective_calls = int(telemetry.get("event_skill_effective_tool_calls", 0) or 0)
|
|
2929
|
-
skill_total = int(telemetry.get("event_skill_tool_calls", 0) or 0)
|
|
2930
|
-
if skill_total <= 0:
|
|
2931
|
-
skill_total = skill_discovery_calls + skill_bootstrap_calls + skill_execution_calls
|
|
2932
|
-
if skill_total <= 0 and legacy_effective_calls > 0:
|
|
2933
|
-
# Preserve visibility for legacy telemetry payloads without over-crediting execution usage.
|
|
2934
|
-
skill_total = legacy_effective_calls
|
|
2935
|
-
tool_effective_count_by_name = telemetry.get("event_tool_effective_count_by_name")
|
|
2936
|
-
derived_skill_execution_effective_calls = 0
|
|
2937
|
-
if isinstance(tool_effective_count_by_name, dict):
|
|
2938
|
-
derived_skill_execution_effective_calls = int(
|
|
2939
|
-
tool_effective_count_by_name.get("read_skill_resource", 0) or 0
|
|
2940
|
-
) + int(tool_effective_count_by_name.get("run_skill_script", 0) or 0)
|
|
2941
|
-
if "event_skill_execution_effective_tool_calls" in telemetry:
|
|
2942
|
-
skill_execution_effective_calls = int(telemetry.get("event_skill_execution_effective_tool_calls", 0) or 0)
|
|
2943
|
-
else:
|
|
2944
|
-
skill_execution_effective_calls = derived_skill_execution_effective_calls
|
|
2945
|
-
skill_execution_effective_calls = max(0, min(skill_execution_effective_calls, skill_execution_calls))
|
|
2946
|
-
skill_effective = skill_execution_effective_calls
|
|
2947
|
-
skill_execution_rate = (skill_execution_calls / skill_total) if skill_total > 0 else None
|
|
2948
|
-
skill_effective_rate = (skill_effective / skill_total) if skill_total > 0 else None
|
|
2949
|
-
skill_execution_effective_rate = (
|
|
2950
|
-
(skill_execution_effective_calls / skill_execution_calls) if skill_execution_calls > 0 else None
|
|
2951
|
-
)
|
|
2952
|
-
skill_bootstrap_only_calls = skill_bootstrap_calls if (skill_execution_calls == 0 and skill_total > 0) else 0
|
|
2953
|
-
skill_bootstrap_only_rate = (skill_bootstrap_only_calls / skill_total) if skill_total > 0 else None
|
|
2954
|
-
skill_discovery_ratio = (skill_discovery_calls / skill_total) if skill_total > 0 else None
|
|
2955
|
-
|
|
2956
|
-
latencies_raw = telemetry.get("event_tool_latencies_ms")
|
|
2957
|
-
latency_values = (
|
|
2958
|
-
[float(v) for v in latencies_raw if isinstance(v, (int, float))] if isinstance(latencies_raw, list) else []
|
|
2959
|
-
)
|
|
2960
|
-
avg_latency_ms = (sum(latency_values) / len(latency_values)) if latency_values else None
|
|
2961
|
-
p95_latency_ms = cls._percentile(latency_values, 0.95) if latency_values else None
|
|
2962
|
-
|
|
2963
|
-
summary: dict[str, Any] = {
|
|
2964
|
-
"tool_calls_started": started,
|
|
2965
|
-
"tool_calls_completed": effective_completed,
|
|
2966
|
-
"tool_calls_effective": effective_calls,
|
|
2967
|
-
"tool_calls_unique": unique_tools,
|
|
2968
|
-
"tool_calls_repeated": repeated_calls,
|
|
2969
|
-
"tool_completion_rate": round(completion_rate, 3),
|
|
2970
|
-
}
|
|
2971
|
-
if effective_completed > 0:
|
|
2972
|
-
summary["tool_effective_rate"] = round(effective_calls / effective_completed, 3)
|
|
2973
|
-
if unique_tools_by_signature > 0:
|
|
2974
|
-
summary["tool_name_unique"] = unique_tools_by_name
|
|
2975
|
-
summary["tool_signature_unique"] = unique_tools_by_signature
|
|
2976
|
-
summary["tool_repetition_basis"] = "signature"
|
|
2977
|
-
if effective_completed > 0:
|
|
2978
|
-
summary["tool_repetition_rate"] = round(repeated_calls / effective_completed, 3)
|
|
2979
|
-
summary["skill_calls_total"] = skill_total
|
|
2980
|
-
summary["skill_calls_discovery"] = skill_discovery_calls
|
|
2981
|
-
summary["skill_calls_bootstrap"] = skill_bootstrap_calls
|
|
2982
|
-
summary["skill_calls_execution"] = skill_execution_calls
|
|
2983
|
-
summary["skill_calls_execution_effective"] = skill_execution_effective_calls
|
|
2984
|
-
summary["skill_calls_bootstrap_only"] = skill_bootstrap_only_calls
|
|
2985
|
-
summary["skill_calls_effective"] = skill_effective
|
|
2986
|
-
if legacy_effective_calls > 0 and legacy_effective_calls != skill_effective:
|
|
2987
|
-
summary["legacy_skill_effective_calls_observed"] = legacy_effective_calls
|
|
2988
|
-
if skill_execution_rate is not None:
|
|
2989
|
-
summary["skill_execution_rate"] = round(skill_execution_rate, 3)
|
|
2990
|
-
if skill_execution_effective_rate is not None:
|
|
2991
|
-
summary["skill_execution_effective_rate"] = round(skill_execution_effective_rate, 3)
|
|
2992
|
-
if skill_effective_rate is not None:
|
|
2993
|
-
summary["skill_effective_rate"] = round(skill_effective_rate, 3)
|
|
2994
|
-
if skill_bootstrap_only_rate is not None:
|
|
2995
|
-
summary["skill_bootstrap_only_rate"] = round(skill_bootstrap_only_rate, 3)
|
|
2996
|
-
if skill_discovery_ratio is not None:
|
|
2997
|
-
summary["skill_discovery_ratio"] = round(skill_discovery_ratio, 3)
|
|
2998
|
-
if avg_latency_ms is not None:
|
|
2999
|
-
summary["tool_latency_avg_ms"] = round(avg_latency_ms)
|
|
3000
|
-
if p95_latency_ms is not None:
|
|
3001
|
-
summary["tool_latency_p95_ms"] = round(p95_latency_ms)
|
|
3002
|
-
family_tool_names = cls._tool_family_tool_names()
|
|
3003
|
-
family_calls: dict[str, int] = {}
|
|
3004
|
-
family_effectiveness: dict[str, float] = {}
|
|
3005
|
-
for family_name, tool_names in family_tool_names.items():
|
|
3006
|
-
calls = sum(int(tool_count_by_name.get(tool_name, 0) or 0) for tool_name in tool_names)
|
|
3007
|
-
family_calls[family_name] = calls
|
|
3008
|
-
if effective_completed > 0:
|
|
3009
|
-
family_effectiveness[family_name] = round(calls / effective_completed, 3)
|
|
3010
|
-
else:
|
|
3011
|
-
family_effectiveness[family_name] = 0.0
|
|
3012
|
-
summary["tool_family_calls"] = family_calls
|
|
3013
|
-
summary["tool_family_effectiveness"] = family_effectiveness
|
|
3014
|
-
|
|
3015
|
-
turn_effectiveness_raw = telemetry.get("event_turn_effectiveness")
|
|
3016
|
-
if isinstance(turn_effectiveness_raw, dict) and turn_effectiveness_raw:
|
|
3017
|
-
turn_entries: list[dict[str, Any]] = []
|
|
3018
|
-
turn_effective_count = 0
|
|
3019
|
-
coverage_turn_count = 0
|
|
3020
|
-
aggregate_markers = {"requirements": False, "docs": False, "code": False}
|
|
3021
|
-
ordered_turn_items = sorted(
|
|
3022
|
-
(
|
|
3023
|
-
(int(str(turn_key)), payload)
|
|
3024
|
-
for turn_key, payload in turn_effectiveness_raw.items()
|
|
3025
|
-
if str(turn_key).strip().isdigit() and isinstance(payload, dict)
|
|
3026
|
-
),
|
|
3027
|
-
key=lambda item: item[0],
|
|
3028
|
-
)
|
|
3029
|
-
for turn_index, payload in ordered_turn_items:
|
|
3030
|
-
turn_tool_calls = int(payload.get("tool_calls", 0) or 0)
|
|
3031
|
-
turn_effective_tool_calls = int(payload.get("effective_tool_calls", turn_tool_calls) or 0)
|
|
3032
|
-
turn_skill_discovery_calls = int(payload.get("skill_discovery_calls", 0) or 0)
|
|
3033
|
-
turn_skill_bootstrap_calls = int(payload.get("skill_bootstrap_calls", 0) or 0)
|
|
3034
|
-
turn_skill_execution_calls = int(
|
|
3035
|
-
payload.get("skill_execution_calls", payload.get("skill_effective_calls", 0)) or 0
|
|
3036
|
-
)
|
|
3037
|
-
turn_skill_execution_effective_calls = int(
|
|
3038
|
-
payload.get("skill_execution_effective_calls", payload.get("skill_effective_calls", 0)) or 0
|
|
3039
|
-
)
|
|
3040
|
-
turn_skill_execution_effective_calls = max(
|
|
3041
|
-
0,
|
|
3042
|
-
min(turn_skill_execution_effective_calls, turn_skill_execution_calls),
|
|
3043
|
-
)
|
|
3044
|
-
turn_skill_calls = int(payload.get("skill_calls", 0) or 0)
|
|
3045
|
-
if turn_skill_calls <= 0:
|
|
3046
|
-
turn_skill_calls = (
|
|
3047
|
-
turn_skill_discovery_calls + turn_skill_bootstrap_calls + turn_skill_execution_calls
|
|
3048
|
-
)
|
|
3049
|
-
turn_skill_execution_rate = (
|
|
3050
|
-
round(turn_skill_execution_calls / turn_skill_calls, 3)
|
|
3051
|
-
if turn_skill_calls > 0
|
|
3052
|
-
else (1.0 if turn_skill_execution_calls > 0 else 0.0)
|
|
3053
|
-
)
|
|
3054
|
-
turn_skill_effective_calls = turn_skill_execution_effective_calls
|
|
3055
|
-
turn_skill_effective_rate = (
|
|
3056
|
-
round(turn_skill_effective_calls / turn_skill_calls, 3)
|
|
3057
|
-
if turn_skill_calls > 0
|
|
3058
|
-
else (1.0 if turn_skill_effective_calls > 0 else 0.0)
|
|
3059
|
-
)
|
|
3060
|
-
turn_skill_execution_effective_rate = (
|
|
3061
|
-
round(turn_skill_execution_effective_calls / turn_skill_execution_calls, 3)
|
|
3062
|
-
if turn_skill_execution_calls > 0
|
|
3063
|
-
else 0.0
|
|
3064
|
-
)
|
|
3065
|
-
turn_skill_bootstrap_only_calls = (
|
|
3066
|
-
turn_skill_bootstrap_calls if (turn_skill_effective_calls == 0 and turn_skill_calls > 0) else 0
|
|
3067
|
-
)
|
|
3068
|
-
turn_skill_bootstrap_only_rate = (
|
|
3069
|
-
round(turn_skill_bootstrap_only_calls / turn_skill_calls, 3) if turn_skill_calls > 0 else 0.0
|
|
3070
|
-
)
|
|
3071
|
-
turn_family_calls_raw = payload.get("tool_family_effective_calls")
|
|
3072
|
-
if not isinstance(turn_family_calls_raw, dict):
|
|
3073
|
-
turn_family_calls_raw = payload.get("tool_family_calls")
|
|
3074
|
-
turn_family_calls = {
|
|
3075
|
-
family_name: int((turn_family_calls_raw or {}).get(family_name, 0) or 0)
|
|
3076
|
-
for family_name in family_tool_names
|
|
3077
|
-
}
|
|
3078
|
-
turn_effective_denominator = (
|
|
3079
|
-
turn_effective_tool_calls if turn_effective_tool_calls > 0 else turn_tool_calls
|
|
3080
|
-
)
|
|
3081
|
-
turn_family_effectiveness = {
|
|
3082
|
-
family_name: round((calls / turn_effective_denominator), 3)
|
|
3083
|
-
if turn_effective_denominator > 0
|
|
3084
|
-
else 0.0
|
|
3085
|
-
for family_name, calls in turn_family_calls.items()
|
|
3086
|
-
}
|
|
3087
|
-
raw_markers = payload.get("coverage_contribution_markers")
|
|
3088
|
-
if isinstance(raw_markers, dict):
|
|
3089
|
-
coverage_markers = {
|
|
3090
|
-
"requirements": bool(raw_markers.get("requirements")),
|
|
3091
|
-
"docs": bool(raw_markers.get("docs")),
|
|
3092
|
-
"code": bool(raw_markers.get("code")),
|
|
3093
|
-
}
|
|
3094
|
-
else:
|
|
3095
|
-
coverage_markers = {"requirements": False, "docs": False, "code": False}
|
|
3096
|
-
for family_name, calls in turn_family_calls.items():
|
|
3097
|
-
if calls <= 0:
|
|
3098
|
-
continue
|
|
3099
|
-
family_markers = cls._family_coverage_markers(family_name)
|
|
3100
|
-
for marker_key in coverage_markers:
|
|
3101
|
-
coverage_markers[marker_key] = bool(
|
|
3102
|
-
coverage_markers[marker_key] or family_markers[marker_key]
|
|
3103
|
-
)
|
|
3104
|
-
contribution_level = cls._coverage_contribution_level(
|
|
3105
|
-
coverage_markers,
|
|
3106
|
-
skill_effective_calls=turn_skill_effective_calls,
|
|
3107
|
-
)
|
|
3108
|
-
if turn_effective_tool_calls > 0 and (
|
|
3109
|
-
turn_skill_execution_effective_calls > 0 or any(count > 0 for count in turn_family_calls.values())
|
|
3110
|
-
):
|
|
3111
|
-
turn_effective_count += 1
|
|
3112
|
-
if contribution_level != "none":
|
|
3113
|
-
coverage_turn_count += 1
|
|
3114
|
-
for marker_key in aggregate_markers:
|
|
3115
|
-
aggregate_markers[marker_key] = aggregate_markers[marker_key] or coverage_markers[marker_key]
|
|
3116
|
-
turn_entries.append(
|
|
3117
|
-
{
|
|
3118
|
-
"turn_index": turn_index,
|
|
3119
|
-
"tool_calls": turn_tool_calls,
|
|
3120
|
-
"effective_tool_calls": turn_effective_tool_calls,
|
|
3121
|
-
"skill_calls": turn_skill_calls,
|
|
3122
|
-
"skill_discovery_calls": turn_skill_discovery_calls,
|
|
3123
|
-
"skill_bootstrap_calls": turn_skill_bootstrap_calls,
|
|
3124
|
-
"skill_execution_calls": turn_skill_execution_calls,
|
|
3125
|
-
"skill_execution_effective_calls": turn_skill_execution_effective_calls,
|
|
3126
|
-
"skill_execution_rate": turn_skill_execution_rate,
|
|
3127
|
-
"skill_execution_effective_rate": turn_skill_execution_effective_rate,
|
|
3128
|
-
"skill_bootstrap_only_calls": turn_skill_bootstrap_only_calls,
|
|
3129
|
-
"skill_bootstrap_only_rate": turn_skill_bootstrap_only_rate,
|
|
3130
|
-
"skill_effective_calls": turn_skill_effective_calls,
|
|
3131
|
-
"skill_effective_rate": turn_skill_effective_rate,
|
|
3132
|
-
"tool_family_calls": turn_family_calls,
|
|
3133
|
-
"tool_family_effectiveness": turn_family_effectiveness,
|
|
3134
|
-
"coverage_contribution_markers": coverage_markers,
|
|
3135
|
-
"requirement_coverage_contribution_level": contribution_level,
|
|
3136
|
-
}
|
|
3137
|
-
)
|
|
3138
|
-
if turn_entries:
|
|
3139
|
-
turn_count = len(turn_entries)
|
|
3140
|
-
summary["turn_effectiveness_summary"] = turn_entries
|
|
3141
|
-
summary["turn_effective_rate"] = round(turn_effective_count / turn_count, 3)
|
|
3142
|
-
summary["turn_requirement_coverage_contribution_rate"] = round(coverage_turn_count / turn_count, 3)
|
|
3143
|
-
summary["turn_requirement_coverage_contribution_markers"] = aggregate_markers
|
|
3144
|
-
return summary
|
|
3145
|
-
|
|
3146
|
-
@staticmethod
|
|
3147
|
-
def _extract_tool_names(raw_name: Any) -> list[str]:
|
|
3148
|
-
value = str(raw_name or "").strip()
|
|
3149
|
-
if not value:
|
|
3150
|
-
return []
|
|
3151
|
-
normalized = value.replace("/", " ").replace(",", " ").replace(";", " ")
|
|
3152
|
-
candidates = [part.strip() for part in re.split(r"\s+", normalized) if part.strip()]
|
|
3153
|
-
known = (
|
|
3154
|
-
"list_directory",
|
|
3155
|
-
"read_file",
|
|
3156
|
-
"grep_search",
|
|
3157
|
-
"rg_search",
|
|
3158
|
-
"ast_grep_search",
|
|
3159
|
-
"list_evidence_documents",
|
|
3160
|
-
"search_evidence",
|
|
3161
|
-
"read_evidence_document",
|
|
3162
|
-
"search_evidence_vector",
|
|
3163
|
-
"search_code_vector",
|
|
3164
|
-
"vector_retrieval_status",
|
|
3165
|
-
"get_definition",
|
|
3166
|
-
"find_references",
|
|
3167
|
-
"workspace_symbol",
|
|
3168
|
-
"list_skills",
|
|
3169
|
-
"load_skill",
|
|
3170
|
-
"read_skill_resource",
|
|
3171
|
-
"run_skill_script",
|
|
3172
|
-
)
|
|
3173
|
-
if len(candidates) == 1 and candidates[0] == value:
|
|
3174
|
-
known_sorted = sorted(known, key=len, reverse=True)
|
|
3175
|
-
matched: list[str] = []
|
|
3176
|
-
cursor = 0
|
|
3177
|
-
while cursor < len(value):
|
|
3178
|
-
token = next((name for name in known_sorted if value.startswith(name, cursor)), None)
|
|
3179
|
-
if token is None:
|
|
3180
|
-
matched = []
|
|
3181
|
-
break
|
|
3182
|
-
matched.append(token)
|
|
3183
|
-
cursor += len(token)
|
|
3184
|
-
if matched and cursor == len(value):
|
|
3185
|
-
return matched
|
|
3186
|
-
return candidates
|
|
3187
|
-
|
|
3188
|
-
def _log_pydantic_agent_event(
|
|
3189
|
-
self,
|
|
3190
|
-
*,
|
|
3191
|
-
event: Any,
|
|
3192
|
-
run_started_at: float,
|
|
3193
|
-
telemetry: dict[str, Any] | None = None,
|
|
3194
|
-
) -> None:
|
|
3195
|
-
"""Emit structured logs for PydanticAI runtime events."""
|
|
3196
|
-
import time
|
|
3197
|
-
|
|
3198
|
-
event_name = type(event).__name__
|
|
3199
|
-
elapsed = round(max(0.0, time.monotonic() - run_started_at), 2)
|
|
3200
|
-
if isinstance(telemetry, dict):
|
|
3201
|
-
telemetry["event_last_seen_at"] = time.monotonic()
|
|
3202
|
-
telemetry.setdefault("event_tool_effective_calls", 0)
|
|
3203
|
-
telemetry.setdefault("event_skill_execution_effective_tool_calls", 0)
|
|
3204
|
-
effective_count_by_name = telemetry.get("event_tool_effective_count_by_name")
|
|
3205
|
-
if not isinstance(effective_count_by_name, dict):
|
|
3206
|
-
telemetry["event_tool_effective_count_by_name"] = {}
|
|
3207
|
-
|
|
3208
|
-
if event_name == "FunctionToolCallEvent":
|
|
3209
|
-
part = getattr(event, "part", None)
|
|
3210
|
-
raw_tool_name = getattr(part, "tool_name", None) or getattr(part, "name", None) or "unknown"
|
|
3211
|
-
tool_names = self._extract_tool_names(raw_tool_name)
|
|
3212
|
-
primary_tool_name = tool_names[0] if tool_names else str(raw_tool_name)
|
|
3213
|
-
tool_call_id = getattr(part, "tool_call_id", None)
|
|
3214
|
-
raw_args = getattr(part, "args", None)
|
|
3215
|
-
args_repr = ""
|
|
3216
|
-
if raw_args is not None:
|
|
3217
|
-
try:
|
|
3218
|
-
args_repr = json.dumps(raw_args, sort_keys=True, default=str, ensure_ascii=True)
|
|
3219
|
-
except Exception:
|
|
3220
|
-
args_repr = str(raw_args)
|
|
3221
|
-
self._log_trace_payload(
|
|
3222
|
-
event_name="pydantic_agent_trace_tool_call",
|
|
3223
|
-
elapsed_sec=elapsed,
|
|
3224
|
-
payload={
|
|
3225
|
-
"tool_name": primary_tool_name,
|
|
3226
|
-
"tool_names": tool_names,
|
|
3227
|
-
"tool_call_id": tool_call_id,
|
|
3228
|
-
"args": raw_args,
|
|
3229
|
-
},
|
|
3230
|
-
)
|
|
3231
|
-
if isinstance(telemetry, dict):
|
|
3232
|
-
turn_index = int(telemetry.get("event_turn_index", 0) or 0) + 1
|
|
3233
|
-
telemetry["event_turn_index"] = turn_index
|
|
3234
|
-
telemetry["event_tool_calls_started"] = int(telemetry.get("event_tool_calls_started", 0) or 0) + 1
|
|
3235
|
-
telemetry["event_last_tool_activity_at"] = time.monotonic()
|
|
3236
|
-
signatures = telemetry.get("event_tool_signatures")
|
|
3237
|
-
if not isinstance(signatures, list):
|
|
3238
|
-
signatures = []
|
|
3239
|
-
signatures.append(f"{primary_tool_name}|{args_repr}")
|
|
3240
|
-
telemetry["event_tool_signatures"] = signatures
|
|
3241
|
-
|
|
3242
|
-
if tool_call_id:
|
|
3243
|
-
started_at_map = telemetry.get("_tool_call_started_at")
|
|
3244
|
-
if not isinstance(started_at_map, dict):
|
|
3245
|
-
started_at_map = {}
|
|
3246
|
-
started_at_map[str(tool_call_id)] = time.monotonic()
|
|
3247
|
-
telemetry["_tool_call_started_at"] = started_at_map
|
|
3248
|
-
turn_map = telemetry.get("_tool_call_turn_index")
|
|
3249
|
-
if not isinstance(turn_map, dict):
|
|
3250
|
-
turn_map = {}
|
|
3251
|
-
turn_map[str(tool_call_id)] = turn_index
|
|
3252
|
-
telemetry["_tool_call_turn_index"] = turn_map
|
|
3253
|
-
logged_turn_index = int(telemetry.get("event_turn_index", 0) or 0) if isinstance(telemetry, dict) else None
|
|
3254
|
-
self.logger.info(
|
|
3255
|
-
"pydantic_agent_tool_call_started",
|
|
3256
|
-
elapsed_sec=elapsed,
|
|
3257
|
-
tool_name=primary_tool_name,
|
|
3258
|
-
tool_names=tool_names if len(tool_names) > 1 else None,
|
|
3259
|
-
tool_call_id=tool_call_id,
|
|
3260
|
-
turn_index=logged_turn_index,
|
|
3261
|
-
)
|
|
3262
|
-
return
|
|
3263
|
-
|
|
3264
|
-
if event_name == "FunctionToolResultEvent":
|
|
3265
|
-
result = getattr(event, "result", None)
|
|
3266
|
-
raw_tool_name = getattr(result, "tool_name", None) or getattr(result, "name", None) or "unknown"
|
|
3267
|
-
tool_names = self._extract_tool_names(raw_tool_name)
|
|
3268
|
-
primary_tool_name = tool_names[0] if tool_names else str(raw_tool_name)
|
|
3269
|
-
effective = self._is_effective_tool_result_event(result, tool_name=primary_tool_name)
|
|
3270
|
-
tool_call_id = getattr(result, "tool_call_id", None)
|
|
3271
|
-
turn_index = None
|
|
3272
|
-
if isinstance(telemetry, dict):
|
|
3273
|
-
turn_map = telemetry.get("_tool_call_turn_index")
|
|
3274
|
-
if isinstance(turn_map, dict) and tool_call_id:
|
|
3275
|
-
raw_turn = turn_map.pop(str(tool_call_id), None)
|
|
3276
|
-
if isinstance(raw_turn, int):
|
|
3277
|
-
turn_index = raw_turn
|
|
3278
|
-
telemetry["_tool_call_turn_index"] = turn_map
|
|
3279
|
-
self.logger.info(
|
|
3280
|
-
"pydantic_agent_tool_call_completed",
|
|
3281
|
-
elapsed_sec=elapsed,
|
|
3282
|
-
tool_name=primary_tool_name,
|
|
3283
|
-
tool_names=tool_names if len(tool_names) > 1 else None,
|
|
3284
|
-
tool_call_id=tool_call_id,
|
|
3285
|
-
turn_index=turn_index,
|
|
3286
|
-
effective=effective,
|
|
3287
|
-
)
|
|
3288
|
-
self._log_trace_payload(
|
|
3289
|
-
event_name="pydantic_agent_trace_tool_result",
|
|
3290
|
-
elapsed_sec=elapsed,
|
|
3291
|
-
payload={
|
|
3292
|
-
"tool_name": primary_tool_name,
|
|
3293
|
-
"tool_names": tool_names,
|
|
3294
|
-
"tool_call_id": tool_call_id,
|
|
3295
|
-
"result": {
|
|
3296
|
-
"name": getattr(result, "name", None),
|
|
3297
|
-
"tool_name": getattr(result, "tool_name", None),
|
|
3298
|
-
"content": getattr(result, "content", None),
|
|
3299
|
-
"output": getattr(result, "output", None),
|
|
3300
|
-
},
|
|
3301
|
-
},
|
|
3302
|
-
)
|
|
3303
|
-
if isinstance(telemetry, dict):
|
|
3304
|
-
telemetry["event_tool_calls"] = int(telemetry.get("event_tool_calls", 0) or 0) + 1
|
|
3305
|
-
telemetry["event_tool_calls_completed"] = int(telemetry.get("event_tool_calls_completed", 0) or 0) + 1
|
|
3306
|
-
telemetry["event_last_tool_activity_at"] = time.monotonic()
|
|
3307
|
-
if effective:
|
|
3308
|
-
telemetry["event_tool_effective_calls"] = (
|
|
3309
|
-
int(telemetry.get("event_tool_effective_calls", 0) or 0) + 1
|
|
3310
|
-
)
|
|
3311
|
-
|
|
3312
|
-
seen_tools = telemetry.get("event_tool_names")
|
|
3313
|
-
if not isinstance(seen_tools, list):
|
|
3314
|
-
seen_tools = []
|
|
3315
|
-
if primary_tool_name and primary_tool_name not in seen_tools:
|
|
3316
|
-
seen_tools.append(primary_tool_name)
|
|
3317
|
-
telemetry["event_tool_names"] = seen_tools
|
|
3318
|
-
|
|
3319
|
-
if primary_tool_name == "final_result":
|
|
3320
|
-
result_content = getattr(result, "content", None)
|
|
3321
|
-
if isinstance(result_content, list):
|
|
3322
|
-
for item in result_content:
|
|
3323
|
-
if not isinstance(item, dict):
|
|
3324
|
-
continue
|
|
3325
|
-
if str(item.get("type") or "") != "json_invalid":
|
|
3326
|
-
continue
|
|
3327
|
-
raw_invalid_input = item.get("input")
|
|
3328
|
-
if isinstance(raw_invalid_input, str) and raw_invalid_input.strip():
|
|
3329
|
-
telemetry["event_final_result_invalid_input"] = raw_invalid_input
|
|
3330
|
-
break
|
|
3331
|
-
|
|
3332
|
-
tool_count_by_name = telemetry.get("event_tool_count_by_name")
|
|
3333
|
-
if not isinstance(tool_count_by_name, dict):
|
|
3334
|
-
tool_count_by_name = {}
|
|
3335
|
-
tool_count_by_name[primary_tool_name] = int(tool_count_by_name.get(primary_tool_name, 0) or 0) + 1
|
|
3336
|
-
telemetry["event_tool_count_by_name"] = tool_count_by_name
|
|
3337
|
-
|
|
3338
|
-
if effective:
|
|
3339
|
-
effective_count_by_name = telemetry.get("event_tool_effective_count_by_name")
|
|
3340
|
-
if not isinstance(effective_count_by_name, dict):
|
|
3341
|
-
effective_count_by_name = {}
|
|
3342
|
-
effective_count_by_name[primary_tool_name] = (
|
|
3343
|
-
int(effective_count_by_name.get(primary_tool_name, 0) or 0) + 1
|
|
3344
|
-
)
|
|
3345
|
-
telemetry["event_tool_effective_count_by_name"] = effective_count_by_name
|
|
3346
|
-
|
|
3347
|
-
started_at_map = telemetry.get("_tool_call_started_at")
|
|
3348
|
-
if isinstance(started_at_map, dict) and tool_call_id:
|
|
3349
|
-
started_at = started_at_map.pop(str(tool_call_id), None)
|
|
3350
|
-
if isinstance(started_at, (int, float)):
|
|
3351
|
-
latencies = telemetry.get("event_tool_latencies_ms")
|
|
3352
|
-
if not isinstance(latencies, list):
|
|
3353
|
-
latencies = []
|
|
3354
|
-
latencies.append(int(max(0.0, (time.monotonic() - float(started_at)) * 1000)))
|
|
3355
|
-
telemetry["event_tool_latencies_ms"] = latencies
|
|
3356
|
-
telemetry["_tool_call_started_at"] = started_at_map
|
|
3357
|
-
|
|
3358
|
-
skill_discovery_tools = {"list_skills"}
|
|
3359
|
-
skill_bootstrap_tools = {"load_skill"}
|
|
3360
|
-
skill_execution_tools = {"read_skill_resource", "run_skill_script"}
|
|
3361
|
-
skill_tools = skill_discovery_tools | skill_bootstrap_tools | skill_execution_tools
|
|
3362
|
-
if primary_tool_name in skill_tools:
|
|
3363
|
-
telemetry["event_skill_tool_calls"] = int(telemetry.get("event_skill_tool_calls", 0) or 0) + 1
|
|
3364
|
-
skill_count_by_name = telemetry.get("event_skill_tool_count_by_name")
|
|
3365
|
-
if not isinstance(skill_count_by_name, dict):
|
|
3366
|
-
skill_count_by_name = {}
|
|
3367
|
-
skill_count_by_name[primary_tool_name] = int(skill_count_by_name.get(primary_tool_name, 0) or 0) + 1
|
|
3368
|
-
telemetry["event_skill_tool_count_by_name"] = skill_count_by_name
|
|
3369
|
-
if primary_tool_name in skill_discovery_tools:
|
|
3370
|
-
telemetry["event_skill_discovery_tool_calls"] = (
|
|
3371
|
-
int(telemetry.get("event_skill_discovery_tool_calls", 0) or 0) + 1
|
|
3372
|
-
)
|
|
3373
|
-
if primary_tool_name in skill_bootstrap_tools:
|
|
3374
|
-
telemetry["event_skill_bootstrap_tool_calls"] = (
|
|
3375
|
-
int(telemetry.get("event_skill_bootstrap_tool_calls", 0) or 0) + 1
|
|
3376
|
-
)
|
|
3377
|
-
if primary_tool_name in skill_execution_tools:
|
|
3378
|
-
telemetry["event_skill_execution_tool_calls"] = (
|
|
3379
|
-
int(telemetry.get("event_skill_execution_tool_calls", 0) or 0) + 1
|
|
3380
|
-
)
|
|
3381
|
-
if effective:
|
|
3382
|
-
telemetry["event_skill_execution_effective_tool_calls"] = (
|
|
3383
|
-
int(telemetry.get("event_skill_execution_effective_tool_calls", 0) or 0) + 1
|
|
3384
|
-
)
|
|
3385
|
-
# Legacy field retained for backward-compatible consumers.
|
|
3386
|
-
telemetry["event_skill_effective_tool_calls"] = (
|
|
3387
|
-
int(telemetry.get("event_skill_effective_tool_calls", 0) or 0) + 1
|
|
3388
|
-
)
|
|
3389
|
-
if isinstance(turn_index, int) and turn_index > 0:
|
|
3390
|
-
turn_key = str(turn_index)
|
|
3391
|
-
turn_payloads = telemetry.get("event_turn_effectiveness")
|
|
3392
|
-
if not isinstance(turn_payloads, dict):
|
|
3393
|
-
turn_payloads = {}
|
|
3394
|
-
current_payload = turn_payloads.get(turn_key)
|
|
3395
|
-
if not isinstance(current_payload, dict):
|
|
3396
|
-
current_payload = {}
|
|
3397
|
-
current_payload["tool_calls"] = int(current_payload.get("tool_calls", 0) or 0) + 1
|
|
3398
|
-
if effective:
|
|
3399
|
-
current_payload["effective_tool_calls"] = (
|
|
3400
|
-
int(current_payload.get("effective_tool_calls", 0) or 0) + 1
|
|
3401
|
-
)
|
|
3402
|
-
if primary_tool_name in skill_tools:
|
|
3403
|
-
current_payload["skill_calls"] = int(current_payload.get("skill_calls", 0) or 0) + 1
|
|
3404
|
-
if primary_tool_name in skill_discovery_tools:
|
|
3405
|
-
current_payload["skill_discovery_calls"] = (
|
|
3406
|
-
int(current_payload.get("skill_discovery_calls", 0) or 0) + 1
|
|
3407
|
-
)
|
|
3408
|
-
if primary_tool_name in skill_bootstrap_tools:
|
|
3409
|
-
current_payload["skill_bootstrap_calls"] = (
|
|
3410
|
-
int(current_payload.get("skill_bootstrap_calls", 0) or 0) + 1
|
|
3411
|
-
)
|
|
3412
|
-
if primary_tool_name in skill_execution_tools:
|
|
3413
|
-
current_payload["skill_execution_calls"] = (
|
|
3414
|
-
int(current_payload.get("skill_execution_calls", 0) or 0) + 1
|
|
3415
|
-
)
|
|
3416
|
-
if effective:
|
|
3417
|
-
current_payload["skill_execution_effective_calls"] = (
|
|
3418
|
-
int(current_payload.get("skill_execution_effective_calls", 0) or 0) + 1
|
|
3419
|
-
)
|
|
3420
|
-
# Legacy per-turn field kept in sync with effective execution semantics.
|
|
3421
|
-
current_payload["skill_effective_calls"] = (
|
|
3422
|
-
int(current_payload.get("skill_effective_calls", 0) or 0) + 1
|
|
3423
|
-
)
|
|
3424
|
-
family_name = self._resolve_tool_family(primary_tool_name)
|
|
3425
|
-
family_calls_raw = current_payload.get("tool_family_calls")
|
|
3426
|
-
if not isinstance(family_calls_raw, dict):
|
|
3427
|
-
family_calls_raw = {}
|
|
3428
|
-
for family_key in self._tool_family_tool_names():
|
|
3429
|
-
family_calls_raw[family_key] = int(family_calls_raw.get(family_key, 0) or 0)
|
|
3430
|
-
if family_name:
|
|
3431
|
-
family_calls_raw[family_name] = int(family_calls_raw.get(family_name, 0) or 0) + 1
|
|
3432
|
-
current_payload["tool_family_calls"] = family_calls_raw
|
|
3433
|
-
family_effective_calls_raw = current_payload.get("tool_family_effective_calls")
|
|
3434
|
-
if not isinstance(family_effective_calls_raw, dict):
|
|
3435
|
-
family_effective_calls_raw = {}
|
|
3436
|
-
for family_key in self._tool_family_tool_names():
|
|
3437
|
-
family_effective_calls_raw[family_key] = int(family_effective_calls_raw.get(family_key, 0) or 0)
|
|
3438
|
-
if family_name and effective:
|
|
3439
|
-
family_effective_calls_raw[family_name] = (
|
|
3440
|
-
int(family_effective_calls_raw.get(family_name, 0) or 0) + 1
|
|
3441
|
-
)
|
|
3442
|
-
current_payload["tool_family_effective_calls"] = family_effective_calls_raw
|
|
3443
|
-
raw_markers = current_payload.get("coverage_contribution_markers")
|
|
3444
|
-
markers = {
|
|
3445
|
-
"requirements": bool((raw_markers or {}).get("requirements"))
|
|
3446
|
-
if isinstance(raw_markers, dict)
|
|
3447
|
-
else False,
|
|
3448
|
-
"docs": bool((raw_markers or {}).get("docs")) if isinstance(raw_markers, dict) else False,
|
|
3449
|
-
"code": bool((raw_markers or {}).get("code")) if isinstance(raw_markers, dict) else False,
|
|
3450
|
-
}
|
|
3451
|
-
if family_name and effective:
|
|
3452
|
-
family_markers = self._family_coverage_markers(family_name)
|
|
3453
|
-
for marker_key in markers:
|
|
3454
|
-
markers[marker_key] = bool(markers[marker_key] or family_markers[marker_key])
|
|
3455
|
-
current_payload["coverage_contribution_markers"] = markers
|
|
3456
|
-
turn_payloads[turn_key] = current_payload
|
|
3457
|
-
telemetry["event_turn_effectiveness"] = turn_payloads
|
|
3458
|
-
return
|
|
3459
|
-
|
|
3460
|
-
if event_name == "FinalResultEvent":
|
|
3461
|
-
turn_count = None
|
|
3462
|
-
if isinstance(telemetry, dict):
|
|
3463
|
-
turn_count = int(telemetry.get("event_turn_index", 0) or 0)
|
|
3464
|
-
self.logger.info(
|
|
3465
|
-
"pydantic_agent_final_result_event",
|
|
3466
|
-
elapsed_sec=elapsed,
|
|
3467
|
-
turn_count=turn_count,
|
|
3468
|
-
)
|
|
3469
|
-
return
|
|
3470
|
-
|
|
3471
|
-
if event_name == "PartDeltaEvent" and getattr(self.settings, "agent_event_stream_log_text_deltas", False):
|
|
3472
|
-
delta = getattr(event, "delta", None)
|
|
3473
|
-
delta_text = (
|
|
3474
|
-
getattr(delta, "content_delta", None)
|
|
3475
|
-
or getattr(delta, "text", None)
|
|
3476
|
-
or getattr(delta, "delta", None)
|
|
3477
|
-
or ""
|
|
3478
|
-
)
|
|
3479
|
-
if delta_text:
|
|
3480
|
-
self.logger.info(
|
|
3481
|
-
"pydantic_agent_text_delta",
|
|
3482
|
-
elapsed_sec=elapsed,
|
|
3483
|
-
delta_preview=str(delta_text)[:200],
|
|
3484
|
-
)
|
|
3485
|
-
return
|
|
3486
|
-
|
|
3487
|
-
def _summarize_output(self, output: Any) -> dict[str, Any]:
|
|
3488
|
-
"""Summarize agent output for logging.
|
|
3489
|
-
|
|
3490
|
-
Extracts key metrics from the output without logging full content.
|
|
3491
|
-
"""
|
|
3492
|
-
summary: dict[str, Any] = {}
|
|
3493
|
-
|
|
3494
|
-
# Common fields across output models
|
|
3495
|
-
if hasattr(output, "confidence"):
|
|
3496
|
-
summary["confidence"] = round(output.confidence, 2)
|
|
3497
|
-
if hasattr(output, "score"):
|
|
3498
|
-
summary["score"] = output.score
|
|
3499
|
-
if hasattr(output, "score_missing"):
|
|
3500
|
-
summary["score_missing"] = bool(getattr(output, "score_missing", False))
|
|
3501
|
-
if hasattr(output, "posture_score"):
|
|
3502
|
-
summary["posture_score"] = output.posture_score
|
|
3503
|
-
|
|
3504
|
-
# Count findings/vulnerabilities
|
|
3505
|
-
if hasattr(output, "issues") and output.issues:
|
|
3506
|
-
summary["issues_count"] = len(output.issues)
|
|
3507
|
-
if hasattr(output, "vulnerabilities") and output.vulnerabilities:
|
|
3508
|
-
summary["vulnerabilities_count"] = len(output.vulnerabilities)
|
|
3509
|
-
if hasattr(output, "assessments") and output.assessments:
|
|
3510
|
-
summary["assessments_count"] = len(output.assessments)
|
|
3511
|
-
|
|
3512
|
-
# Tech stack if available
|
|
3513
|
-
if hasattr(output, "tech_stack") and output.tech_stack:
|
|
3514
|
-
summary["tech_stack"] = output.tech_stack[:3] # First 3 items
|
|
3515
|
-
|
|
3516
|
-
return summary
|
|
3517
|
-
|
|
3518
|
-
def _normalize_agent_output(self, output: Any, result_type: type[ResultType]) -> Any:
|
|
3519
|
-
"""Normalize stream/text payloads into expected result type shape."""
|
|
3520
|
-
if result_type is str:
|
|
3521
|
-
if isinstance(output, str):
|
|
3522
|
-
if self.settings.protocol == LLMProtocolType.ANTHROPIC:
|
|
3523
|
-
return self._normalize_anthropic_text_payload_with_diagnostics(
|
|
3524
|
-
output,
|
|
3525
|
-
source="normalize_agent_output:str",
|
|
3526
|
-
)
|
|
3527
|
-
return output
|
|
3528
|
-
if output is None:
|
|
3529
|
-
return ""
|
|
3530
|
-
if isinstance(output, bytes):
|
|
3531
|
-
decoded = output.decode("utf-8", errors="replace")
|
|
3532
|
-
if self.settings.protocol == LLMProtocolType.ANTHROPIC:
|
|
3533
|
-
return self._normalize_anthropic_text_payload_with_diagnostics(
|
|
3534
|
-
decoded,
|
|
3535
|
-
source="normalize_agent_output:bytes",
|
|
3536
|
-
)
|
|
3537
|
-
return decoded
|
|
3538
|
-
if isinstance(output, (dict, list)):
|
|
3539
|
-
return json.dumps(output, ensure_ascii=False)
|
|
3540
|
-
return str(output)
|
|
3541
|
-
|
|
3542
|
-
if isinstance(output, result_type):
|
|
3543
|
-
return output
|
|
3544
|
-
|
|
3545
|
-
validator_json = getattr(result_type, "model_validate_json", None)
|
|
3546
|
-
validator_obj = getattr(result_type, "model_validate", None)
|
|
3547
|
-
|
|
3548
|
-
if isinstance(output, str):
|
|
3549
|
-
text_payload = output
|
|
3550
|
-
if self.settings.protocol == LLMProtocolType.ANTHROPIC:
|
|
3551
|
-
text_payload = self._normalize_anthropic_text_payload_with_diagnostics(
|
|
3552
|
-
text_payload,
|
|
3553
|
-
source="normalize_agent_output:model",
|
|
3554
|
-
)
|
|
3555
|
-
normalized_payload = self._strip_json_fence(text_payload)
|
|
3556
|
-
|
|
3557
|
-
if callable(validator_json):
|
|
3558
|
-
try:
|
|
3559
|
-
return validator_json(normalized_payload)
|
|
3560
|
-
except Exception:
|
|
3561
|
-
for candidate in reversed(self._extract_json_object_candidates(normalized_payload)):
|
|
3562
|
-
try:
|
|
3563
|
-
return validator_json(candidate)
|
|
3564
|
-
except Exception:
|
|
3565
|
-
continue
|
|
3566
|
-
|
|
3567
|
-
if callable(validator_obj):
|
|
3568
|
-
try:
|
|
3569
|
-
decoded = json.loads(normalized_payload)
|
|
3570
|
-
except Exception:
|
|
3571
|
-
decoded = None
|
|
3572
|
-
if decoded is not None:
|
|
3573
|
-
try:
|
|
3574
|
-
return validator_obj(decoded)
|
|
3575
|
-
except Exception:
|
|
3576
|
-
pass
|
|
3577
|
-
return output
|
|
3578
|
-
|
|
3579
|
-
if callable(validator_obj) and isinstance(output, (dict, list)):
|
|
3580
|
-
try:
|
|
3581
|
-
return validator_obj(output)
|
|
3582
|
-
except Exception:
|
|
3583
|
-
return output
|
|
3584
|
-
|
|
3585
|
-
return output
|
|
3586
|
-
|
|
3587
|
-
def _build_response_quality_summary(self, output: Any, telemetry: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
3588
|
-
"""Build response-quality diagnostics from output + observed tool activity."""
|
|
3589
|
-
summary = self._summarize_output(output)
|
|
3590
|
-
quality: dict[str, Any] = {}
|
|
3591
|
-
quality["score"] = summary.get("score")
|
|
3592
|
-
quality["score_missing"] = bool(summary.get("score_missing", False))
|
|
3593
|
-
quality["confidence"] = summary.get("confidence")
|
|
3594
|
-
quality["issues_count"] = summary.get("issues_count", 0)
|
|
3595
|
-
quality["vulnerabilities_count"] = summary.get("vulnerabilities_count", 0)
|
|
3596
|
-
quality["assessments_count"] = summary.get("assessments_count", 0)
|
|
3597
|
-
has_reasoning_field = hasattr(output, "reasoning")
|
|
3598
|
-
quality["reasoning_chars"] = len(str(getattr(output, "reasoning", "") or "")) if has_reasoning_field else 0
|
|
3599
|
-
quality["files_analyzed"] = summary.get("files_analyzed", 0)
|
|
3600
|
-
tech_stack = summary.get("tech_stack")
|
|
3601
|
-
quality["tech_stack"] = tech_stack
|
|
3602
|
-
tool_count_by_name = telemetry.get("event_tool_count_by_name") if isinstance(telemetry, dict) else {}
|
|
3603
|
-
if not isinstance(tool_count_by_name, dict):
|
|
3604
|
-
tool_count_by_name = {}
|
|
3605
|
-
observed_tool_calls = int(
|
|
3606
|
-
(telemetry or {}).get("event_tool_calls_completed", (telemetry or {}).get("event_tool_calls", 0)) or 0
|
|
3607
|
-
)
|
|
3608
|
-
quality["observed_tool_calls"] = observed_tool_calls
|
|
3609
|
-
has_effective_counter = isinstance(telemetry, dict) and "event_tool_effective_calls" in telemetry
|
|
3610
|
-
observed_tool_effective_calls = int(
|
|
3611
|
-
(telemetry or {}).get("event_tool_effective_calls", observed_tool_calls) or 0
|
|
3612
|
-
)
|
|
3613
|
-
quality["observed_tool_effective_calls"] = observed_tool_effective_calls
|
|
3614
|
-
quality["observed_read_file_calls"] = int(tool_count_by_name.get("read_file", 0) or 0)
|
|
3615
|
-
observed_skill_execution_calls = int(
|
|
3616
|
-
(telemetry or {}).get(
|
|
3617
|
-
"event_skill_execution_tool_calls", (telemetry or {}).get("event_skill_effective_tool_calls", 0)
|
|
3618
|
-
)
|
|
3619
|
-
or 0
|
|
3620
|
-
)
|
|
3621
|
-
observed_skill_effective_calls = int(
|
|
3622
|
-
(telemetry or {}).get(
|
|
3623
|
-
"event_skill_execution_effective_tool_calls",
|
|
3624
|
-
(telemetry or {}).get("event_skill_effective_tool_calls", 0),
|
|
3625
|
-
)
|
|
3626
|
-
or 0
|
|
3627
|
-
)
|
|
3628
|
-
quality["observed_skill_execution_calls"] = observed_skill_execution_calls
|
|
3629
|
-
quality["observed_skill_effective_calls"] = observed_skill_effective_calls
|
|
3630
|
-
efficiency_summary = self._build_tool_efficiency_summary(telemetry if isinstance(telemetry, dict) else None)
|
|
3631
|
-
turn_effectiveness_summary = efficiency_summary.get("turn_effectiveness_summary")
|
|
3632
|
-
if isinstance(turn_effectiveness_summary, list):
|
|
3633
|
-
quality["turn_effectiveness_summary"] = turn_effectiveness_summary
|
|
3634
|
-
quality["observed_turn_count"] = len(turn_effectiveness_summary)
|
|
3635
|
-
requirement_markers = efficiency_summary.get("turn_requirement_coverage_contribution_markers")
|
|
3636
|
-
if isinstance(requirement_markers, dict):
|
|
3637
|
-
quality["requirement_coverage_contribution_markers"] = {
|
|
3638
|
-
"requirements": bool(requirement_markers.get("requirements")),
|
|
3639
|
-
"docs": bool(requirement_markers.get("docs")),
|
|
3640
|
-
"code": bool(requirement_markers.get("code")),
|
|
3641
|
-
}
|
|
3642
|
-
requirement_rate = efficiency_summary.get("turn_requirement_coverage_contribution_rate")
|
|
3643
|
-
if isinstance(requirement_rate, (int, float)):
|
|
3644
|
-
quality["requirement_coverage_contribution_rate"] = round(float(requirement_rate), 3)
|
|
3645
|
-
turn_effective_rate = efficiency_summary.get("turn_effective_rate")
|
|
3646
|
-
if isinstance(turn_effective_rate, (int, float)):
|
|
3647
|
-
quality["turn_effective_rate"] = round(float(turn_effective_rate), 3)
|
|
3648
|
-
|
|
3649
|
-
flags: list[str] = []
|
|
3650
|
-
if has_reasoning_field and quality["reasoning_chars"] < 80:
|
|
3651
|
-
flags.append("reasoning_too_short")
|
|
3652
|
-
if quality["observed_read_file_calls"] >= 3 and isinstance(tech_stack, list):
|
|
3653
|
-
normalized_stack = [str(item).strip().lower() for item in tech_stack]
|
|
3654
|
-
if normalized_stack and all(("unknown" in item) for item in normalized_stack):
|
|
3655
|
-
flags.append("unknown_tech_stack_with_code_reads")
|
|
3656
|
-
score = quality.get("score")
|
|
3657
|
-
score_present = not bool(quality.get("score_missing", False))
|
|
3658
|
-
quality["score_present"] = score_present
|
|
3659
|
-
high_activity_calls = observed_tool_effective_calls if has_effective_counter else observed_tool_calls
|
|
3660
|
-
if score_present and isinstance(score, (int, float)) and float(score) <= 2.5 and high_activity_calls >= 8:
|
|
3661
|
-
flags.append("very_low_score_after_high_tool_activity")
|
|
3662
|
-
if hasattr(output, "notes") and hasattr(output, "recommendations"):
|
|
3663
|
-
doc_signal_count = (
|
|
3664
|
-
len(getattr(output, "notes", []) or [])
|
|
3665
|
-
+ len(getattr(output, "recommendations", []) or [])
|
|
3666
|
-
+ len(getattr(output, "missing_sections", []) or [])
|
|
3667
|
-
+ len(getattr(output, "strengths", []) or [])
|
|
3668
|
-
)
|
|
3669
|
-
quality["doc_signal_count"] = doc_signal_count
|
|
3670
|
-
if quality["observed_tool_calls"] >= 1 and doc_signal_count == 0:
|
|
3671
|
-
flags.append("docs_signal_too_thin")
|
|
3672
|
-
if hasattr(output, "vulnerabilities") and hasattr(output, "recommendations"):
|
|
3673
|
-
security_signal_count = (
|
|
3674
|
-
len(getattr(output, "vulnerabilities", []) or [])
|
|
3675
|
-
+ len(getattr(output, "recommendations", []) or [])
|
|
3676
|
-
+ len(getattr(output, "security_controls", []) or [])
|
|
3677
|
-
)
|
|
3678
|
-
quality["security_signal_count"] = security_signal_count
|
|
3679
|
-
if quality["observed_tool_calls"] >= 8 and security_signal_count == 0:
|
|
3680
|
-
flags.append("security_signal_too_thin")
|
|
3681
|
-
quality["quality_flags"] = flags
|
|
3682
|
-
quality["quality_ok"] = len(flags) == 0
|
|
3683
|
-
return quality
|
|
3684
|
-
|
|
3685
|
-
@staticmethod
|
|
3686
|
-
def _strip_json_fence(text: str) -> str:
|
|
3687
|
-
trimmed = text.strip()
|
|
3688
|
-
if trimmed.startswith("```"):
|
|
3689
|
-
lines = trimmed.splitlines()
|
|
3690
|
-
if len(lines) >= 2 and lines[-1].strip() == "```":
|
|
3691
|
-
return "\n".join(lines[1:-1]).strip()
|
|
3692
|
-
return "\n".join(lines[1:]).strip()
|
|
3693
|
-
return trimmed
|
|
3694
|
-
|
|
3695
|
-
def _build_model_settings(self) -> ModelSettings:
|
|
3696
|
-
settings: dict[str, Any] = {
|
|
3697
|
-
"temperature": 0.0,
|
|
3698
|
-
"max_tokens": self.settings.max_tokens_per_request,
|
|
3699
|
-
}
|
|
3700
|
-
from vds_audit_orchestrator.config import inject_reasoning_effort
|
|
3701
|
-
|
|
3702
|
-
inject_reasoning_effort(settings, self.settings.reasoning_effort, self.settings.protocol)
|
|
3703
|
-
if self._should_disable_parallel_tool_calls():
|
|
3704
|
-
# Local OpenAI-compatible gateways often perform better with serialized
|
|
3705
|
-
# tool invocation; this reduces bursty tool-call fan-out and improves
|
|
3706
|
-
# bounded-budget stability.
|
|
3707
|
-
settings["parallel_tool_calls"] = False
|
|
3708
|
-
self.logger.info(
|
|
3709
|
-
"openai_parallel_tool_calls_disabled",
|
|
3710
|
-
base_url=self.settings.base_url,
|
|
3711
|
-
protocol=self.settings.protocol.value,
|
|
3712
|
-
)
|
|
3713
|
-
if self._should_suppress_anthropic_tool_choice():
|
|
3714
|
-
# Some Anthropic-compatible proxy gateways reject tool_choice=auto after
|
|
3715
|
-
# translation to OpenAI-compatible payloads; explicit null suppresses this
|
|
3716
|
-
# field while preserving tool definitions/calls.
|
|
3717
|
-
settings["extra_body"] = build_structured_output_extra_body(
|
|
3718
|
-
self.settings.base_url,
|
|
3719
|
-
self.settings.protocol,
|
|
3720
|
-
)
|
|
3721
|
-
self.logger.info(
|
|
3722
|
-
"anthropic_proxy_tool_choice_suppressed",
|
|
3723
|
-
base_url=self.settings.base_url,
|
|
3724
|
-
protocol=self.settings.protocol.value,
|
|
3725
|
-
)
|
|
3726
|
-
elif self._should_suppress_openai_tool_choice():
|
|
3727
|
-
settings["extra_body"] = build_structured_output_extra_body(
|
|
3728
|
-
self.settings.base_url,
|
|
3729
|
-
self.settings.protocol,
|
|
3730
|
-
)
|
|
3731
|
-
self.logger.info(
|
|
3732
|
-
"openai_proxy_tool_choice_suppressed",
|
|
3733
|
-
base_url=self.settings.base_url,
|
|
3734
|
-
protocol=self.settings.protocol.value,
|
|
3735
|
-
)
|
|
3736
|
-
if self._is_openai_codex_protocol(self.settings.protocol):
|
|
3737
|
-
settings["openai_store"] = False
|
|
3738
|
-
return ModelSettings(
|
|
3739
|
-
**settings,
|
|
3740
|
-
)
|
|
3741
|
-
|
|
3742
|
-
def _build_run_model_settings(self, max_tokens: int) -> dict[str, Any]:
|
|
3743
|
-
"""Build per-run model settings kwargs used by Agent(...)."""
|
|
3744
|
-
settings: dict[str, Any] = {
|
|
3745
|
-
"temperature": 0.0,
|
|
3746
|
-
"max_tokens": max_tokens,
|
|
3747
|
-
}
|
|
3748
|
-
from vds_audit_orchestrator.config import inject_reasoning_effort
|
|
3749
|
-
|
|
3750
|
-
inject_reasoning_effort(settings, self.settings.reasoning_effort, self.settings.protocol)
|
|
3751
|
-
if self._should_disable_parallel_tool_calls():
|
|
3752
|
-
settings["parallel_tool_calls"] = False
|
|
3753
|
-
if self._should_suppress_anthropic_tool_choice() or self._should_suppress_openai_tool_choice():
|
|
3754
|
-
settings["extra_body"] = build_structured_output_extra_body(
|
|
3755
|
-
self.settings.base_url,
|
|
3756
|
-
self.settings.protocol,
|
|
3757
|
-
)
|
|
3758
|
-
if self._is_openai_codex_protocol(self.settings.protocol):
|
|
3759
|
-
settings["openai_store"] = False
|
|
3760
|
-
return settings
|
|
3761
|
-
|
|
3762
|
-
def _should_disable_parallel_tool_calls(self) -> bool:
|
|
3763
|
-
"""Disable parallel tool calls for local OpenAI-compatible endpoints."""
|
|
3764
|
-
if self.settings.protocol != LLMProtocolType.OPENAI:
|
|
3765
|
-
return False
|
|
3766
|
-
endpoint = str(self.settings.base_url or "").strip()
|
|
3767
|
-
if not endpoint:
|
|
3768
|
-
endpoint = "http://127.0.0.1:11434"
|
|
3769
|
-
parsed = urlparse(endpoint)
|
|
3770
|
-
host = (parsed.hostname or "").lower()
|
|
3771
|
-
return host in {"localhost", "127.0.0.1", "0.0.0.0", "::1"}
|
|
3772
|
-
|
|
3773
|
-
def _should_suppress_anthropic_tool_choice(self) -> bool:
|
|
3774
|
-
"""Return True for non-official Anthropic endpoints with tool_choice incompatibility."""
|
|
3775
|
-
return should_suppress_anthropic_tool_choice(self.settings.base_url, self.settings.protocol)
|
|
3776
|
-
|
|
3777
|
-
def _should_suppress_openai_tool_choice(self) -> bool:
|
|
3778
|
-
"""Return True for OpenAI-compatible endpoints with explicit tool_choice incompatibility."""
|
|
3779
|
-
return should_suppress_openai_tool_choice(self.settings.base_url, self.settings.protocol)
|
|
3780
|
-
|
|
3781
|
-
# ------------------------------------------------------------------
|
|
3782
|
-
# FR-70 / TSK-641.2: Event stream telemetry resilience
|
|
3783
|
-
# ------------------------------------------------------------------
|
|
3784
|
-
|
|
3785
|
-
def _populate_telemetry_from_result(
|
|
3786
|
-
self,
|
|
3787
|
-
result: Any,
|
|
3788
|
-
run_telemetry: dict[str, Any],
|
|
3789
|
-
) -> None:
|
|
3790
|
-
"""Populate *run_telemetry* from PydanticAI ``RunResult`` when the event
|
|
3791
|
-
stream handler was removed (fallback path).
|
|
3792
|
-
|
|
3793
|
-
This prevents post-run guards from seeing zeroed-out counters and
|
|
3794
|
-
raising ``RuntimeError("agentic usage guard unsatisfied")`` even though
|
|
3795
|
-
tools actually ran successfully.
|
|
3796
|
-
|
|
3797
|
-
Three fallback data sources are used:
|
|
3798
|
-
1. ``result.usage()`` — request count, token counts, tool_calls count.
|
|
3799
|
-
2. ``result.all_messages()`` — walk message parts to count tool-call
|
|
3800
|
-
and tool-return parts and extract tool names.
|
|
3801
|
-
3. If neither works the dict is left unchanged (guards will still see
|
|
3802
|
-
whatever partial data the event stream captured before failing).
|
|
3803
|
-
"""
|
|
3804
|
-
# -- Fallback 1: result.usage() ---------------------------------
|
|
3805
|
-
try:
|
|
3806
|
-
usage = result.usage()
|
|
3807
|
-
if usage is not None:
|
|
3808
|
-
usage_tool_calls = int(getattr(usage, "tool_calls", 0) or 0)
|
|
3809
|
-
usage_requests = int(getattr(usage, "requests", 0) or 0)
|
|
3810
|
-
# Only backfill when event-stream counters are still at zero.
|
|
3811
|
-
if int(run_telemetry.get("event_tool_calls_completed", 0) or 0) < 1 and usage_tool_calls > 0:
|
|
3812
|
-
run_telemetry["event_tool_calls_completed"] = usage_tool_calls
|
|
3813
|
-
run_telemetry["event_tool_calls_started"] = usage_tool_calls
|
|
3814
|
-
run_telemetry["event_tool_calls"] = usage_tool_calls
|
|
3815
|
-
if int(run_telemetry.get("event_tool_effective_calls", 0) or 0) < 1 and usage_tool_calls > 0:
|
|
3816
|
-
# Usage payload has no per-tool usefulness signal; preserve monotonic counters.
|
|
3817
|
-
run_telemetry["event_tool_effective_calls"] = usage_tool_calls
|
|
3818
|
-
if not run_telemetry.get("usage"):
|
|
3819
|
-
run_telemetry["usage"] = {
|
|
3820
|
-
"requests": usage_requests,
|
|
3821
|
-
"input_tokens": int(getattr(usage, "input_tokens", 0) or 0),
|
|
3822
|
-
"output_tokens": int(getattr(usage, "output_tokens", 0) or 0),
|
|
3823
|
-
"tool_calls": usage_tool_calls,
|
|
3824
|
-
}
|
|
3825
|
-
except Exception:
|
|
3826
|
-
pass # usage() may not be available on all result types
|
|
3827
|
-
|
|
3828
|
-
# -- Fallback 2: result.all_messages() ---------------------------
|
|
3829
|
-
try:
|
|
3830
|
-
messages = result.all_messages() if callable(getattr(result, "all_messages", None)) else []
|
|
3831
|
-
if messages and not run_telemetry.get("event_tool_names"):
|
|
3832
|
-
tool_names: list[str] = []
|
|
3833
|
-
tool_call_count = 0
|
|
3834
|
-
for msg in messages:
|
|
3835
|
-
parts = getattr(msg, "parts", None)
|
|
3836
|
-
if not parts:
|
|
3837
|
-
continue
|
|
3838
|
-
for part in parts:
|
|
3839
|
-
part_kind = getattr(part, "part_kind", "")
|
|
3840
|
-
if part_kind == "tool-call":
|
|
3841
|
-
tool_call_count += 1
|
|
3842
|
-
tool_name = getattr(part, "tool_name", None)
|
|
3843
|
-
if tool_name:
|
|
3844
|
-
tool_names.append(tool_name)
|
|
3845
|
-
if tool_names:
|
|
3846
|
-
run_telemetry["event_tool_names"] = list(set(tool_names))
|
|
3847
|
-
# Build count-by-name
|
|
3848
|
-
count_by_name: dict[str, int] = {}
|
|
3849
|
-
for tn in tool_names:
|
|
3850
|
-
count_by_name[tn] = count_by_name.get(tn, 0) + 1
|
|
3851
|
-
run_telemetry["event_tool_count_by_name"] = count_by_name
|
|
3852
|
-
# Populate skill-class telemetry from generic tool counters when
|
|
3853
|
-
# event-stream skill counters are missing.
|
|
3854
|
-
derived_skill_counts = {
|
|
3855
|
-
name: int(count_by_name.get(name, 0) or 0)
|
|
3856
|
-
for name in ("list_skills", "load_skill", "read_skill_resource", "run_skill_script")
|
|
3857
|
-
if int(count_by_name.get(name, 0) or 0) > 0
|
|
3858
|
-
}
|
|
3859
|
-
if derived_skill_counts:
|
|
3860
|
-
existing_skill_counts = run_telemetry.get("event_skill_tool_count_by_name")
|
|
3861
|
-
merged_skill_counts: dict[str, int] = (
|
|
3862
|
-
{str(k): int(v or 0) for k, v in existing_skill_counts.items() if str(k).strip()}
|
|
3863
|
-
if isinstance(existing_skill_counts, dict)
|
|
3864
|
-
else {}
|
|
3865
|
-
)
|
|
3866
|
-
for skill_tool, count in derived_skill_counts.items():
|
|
3867
|
-
merged_skill_counts[skill_tool] = max(
|
|
3868
|
-
int(merged_skill_counts.get(skill_tool, 0) or 0), count
|
|
3869
|
-
)
|
|
3870
|
-
run_telemetry["event_skill_tool_count_by_name"] = merged_skill_counts
|
|
3871
|
-
derived_discovery = int(merged_skill_counts.get("list_skills", 0) or 0)
|
|
3872
|
-
derived_bootstrap = int(merged_skill_counts.get("load_skill", 0) or 0)
|
|
3873
|
-
derived_execution = int(merged_skill_counts.get("read_skill_resource", 0) or 0) + int(
|
|
3874
|
-
merged_skill_counts.get("run_skill_script", 0) or 0
|
|
3875
|
-
)
|
|
3876
|
-
effective_count_by_name = run_telemetry.get("event_tool_effective_count_by_name")
|
|
3877
|
-
derived_execution_effective = 0
|
|
3878
|
-
if isinstance(effective_count_by_name, dict):
|
|
3879
|
-
derived_execution_effective = int(
|
|
3880
|
-
effective_count_by_name.get("read_skill_resource", 0) or 0
|
|
3881
|
-
) + int(effective_count_by_name.get("run_skill_script", 0) or 0)
|
|
3882
|
-
if (
|
|
3883
|
-
int(run_telemetry.get("event_skill_discovery_tool_calls", 0) or 0) < 1
|
|
3884
|
-
and derived_discovery > 0
|
|
3885
|
-
):
|
|
3886
|
-
run_telemetry["event_skill_discovery_tool_calls"] = derived_discovery
|
|
3887
|
-
if (
|
|
3888
|
-
int(run_telemetry.get("event_skill_bootstrap_tool_calls", 0) or 0) < 1
|
|
3889
|
-
and derived_bootstrap > 0
|
|
3890
|
-
):
|
|
3891
|
-
run_telemetry["event_skill_bootstrap_tool_calls"] = derived_bootstrap
|
|
3892
|
-
if (
|
|
3893
|
-
int(run_telemetry.get("event_skill_execution_tool_calls", 0) or 0) < 1
|
|
3894
|
-
and derived_execution > 0
|
|
3895
|
-
):
|
|
3896
|
-
run_telemetry["event_skill_execution_tool_calls"] = derived_execution
|
|
3897
|
-
if (
|
|
3898
|
-
int(run_telemetry.get("event_skill_execution_effective_tool_calls", 0) or 0) < 1
|
|
3899
|
-
and derived_execution_effective > 0
|
|
3900
|
-
):
|
|
3901
|
-
run_telemetry["event_skill_execution_effective_tool_calls"] = derived_execution_effective
|
|
3902
|
-
if int(run_telemetry.get("event_skill_tool_calls", 0) or 0) < 1:
|
|
3903
|
-
run_telemetry["event_skill_tool_calls"] = sum(merged_skill_counts.values())
|
|
3904
|
-
if (
|
|
3905
|
-
int(run_telemetry.get("event_skill_effective_tool_calls", 0) or 0) < 1
|
|
3906
|
-
and derived_execution_effective > 0
|
|
3907
|
-
):
|
|
3908
|
-
run_telemetry["event_skill_effective_tool_calls"] = derived_execution_effective
|
|
3909
|
-
if tool_call_count > 0 and int(run_telemetry.get("event_tool_calls_completed", 0) or 0) < 1:
|
|
3910
|
-
run_telemetry["event_tool_calls_completed"] = tool_call_count
|
|
3911
|
-
run_telemetry["event_tool_calls_started"] = tool_call_count
|
|
3912
|
-
run_telemetry["event_tool_calls"] = tool_call_count
|
|
3913
|
-
if tool_call_count > 0 and int(run_telemetry.get("event_tool_effective_calls", 0) or 0) < 1:
|
|
3914
|
-
run_telemetry["event_tool_effective_calls"] = tool_call_count
|
|
3915
|
-
except Exception:
|
|
3916
|
-
pass # all_messages() may not be available
|
|
3917
|
-
|
|
3918
|
-
fallback_tool_calls = int(run_telemetry.get("event_tool_calls_completed", 0) or 0)
|
|
3919
|
-
self.logger.info(
|
|
3920
|
-
"event_stream_telemetry_fallback_result",
|
|
3921
|
-
fallback_tool_calls=fallback_tool_calls,
|
|
3922
|
-
fallback_tool_names=run_telemetry.get("event_tool_names"),
|
|
3923
|
-
fallback_source="result.usage+all_messages",
|
|
3924
|
-
)
|
|
3925
|
-
|
|
3926
|
-
def _record_pydantic_usage(self, result: Any, prompt_type: str) -> dict[str, int] | None:
|
|
3927
|
-
"""Record PydanticAI RunResult usage with the global tracker."""
|
|
3928
|
-
try:
|
|
3929
|
-
usage = result.usage()
|
|
3930
|
-
except Exception:
|
|
3931
|
-
return None
|
|
3932
|
-
|
|
3933
|
-
if usage is None:
|
|
3934
|
-
return None
|
|
3935
|
-
|
|
3936
|
-
input_tokens = int(getattr(usage, "input_tokens", 0) or 0)
|
|
3937
|
-
output_tokens = int(getattr(usage, "output_tokens", 0) or 0)
|
|
3938
|
-
request_count = int(getattr(usage, "requests", 0) or 0)
|
|
3939
|
-
tool_calls = int(getattr(usage, "tool_calls", 0) or 0)
|
|
3940
|
-
model_name = self._get_model_name()
|
|
3941
|
-
|
|
3942
|
-
record = global_tracker.record_usage(
|
|
3943
|
-
model=model_name,
|
|
3944
|
-
prompt_type=prompt_type,
|
|
3945
|
-
input_tokens=input_tokens,
|
|
3946
|
-
output_tokens=output_tokens,
|
|
3947
|
-
)
|
|
3948
|
-
self.logger.info(
|
|
3949
|
-
"pydantic_agent_usage_summary",
|
|
3950
|
-
prompt_type=prompt_type,
|
|
3951
|
-
model_name=model_name,
|
|
3952
|
-
input_tokens=input_tokens,
|
|
3953
|
-
output_tokens=output_tokens,
|
|
3954
|
-
request_count=request_count,
|
|
3955
|
-
tool_calls=tool_calls,
|
|
3956
|
-
)
|
|
3957
|
-
record_llm_usage(
|
|
3958
|
-
model=model_name,
|
|
3959
|
-
prompt_tokens=input_tokens,
|
|
3960
|
-
completion_tokens=output_tokens,
|
|
3961
|
-
cost=record.cost,
|
|
3962
|
-
)
|
|
3963
|
-
return {
|
|
3964
|
-
"input_tokens": input_tokens,
|
|
3965
|
-
"output_tokens": output_tokens,
|
|
3966
|
-
"request_count": request_count,
|
|
3967
|
-
"tool_calls": tool_calls,
|
|
3968
|
-
}
|
|
3969
|
-
|
|
3970
|
-
def _get_model_name(self) -> str:
|
|
3971
|
-
if self._pydantic_model is not None and hasattr(self._pydantic_model, "model_name"):
|
|
3972
|
-
return str(self._pydantic_model.model_name)
|
|
3973
|
-
return self.settings.model_standard
|
|
3974
|
-
|
|
3975
|
-
def _result(
|
|
3976
|
-
self,
|
|
3977
|
-
agent_name: str,
|
|
3978
|
-
success: bool,
|
|
3979
|
-
findings: list[dict[str, Any]] | None = None,
|
|
3980
|
-
metadata: dict[str, Any] | None = None,
|
|
3981
|
-
error: str | AuditError | None = None,
|
|
3982
|
-
spawned_tasks: list[dict[str, Any]] | None = None,
|
|
3983
|
-
) -> AgentResult:
|
|
3984
|
-
"""Create an AgentResult with consistent pattern.
|
|
3985
|
-
|
|
3986
|
-
Args:
|
|
3987
|
-
agent_name: Name identifier for this agent
|
|
3988
|
-
success: Whether the analysis succeeded
|
|
3989
|
-
findings: List of finding dictionaries
|
|
3990
|
-
metadata: Additional metadata about the analysis
|
|
3991
|
-
error: Error message if analysis failed
|
|
3992
|
-
spawned_tasks: List of task specs to be spawned by the dispatcher
|
|
3993
|
-
|
|
3994
|
-
Returns:
|
|
3995
|
-
AgentResult instance
|
|
3996
|
-
"""
|
|
3997
|
-
normalized_error: str | None
|
|
3998
|
-
normalized_error = str(error) if isinstance(error, AuditError) else error
|
|
3999
|
-
return AgentResult(
|
|
4000
|
-
agent_name=agent_name,
|
|
4001
|
-
success=success,
|
|
4002
|
-
findings=findings or [],
|
|
4003
|
-
metadata=metadata or {},
|
|
4004
|
-
error=normalized_error,
|
|
4005
|
-
spawned_tasks=spawned_tasks or [],
|
|
4006
|
-
)
|
|
4007
|
-
|
|
4008
|
-
def _spawn_task(
|
|
4009
|
-
self,
|
|
4010
|
-
task_type: str,
|
|
4011
|
-
description: str,
|
|
4012
|
-
assignee: str,
|
|
4013
|
-
input_data: dict[str, Any] | None = None,
|
|
4014
|
-
priority: int = 100,
|
|
4015
|
-
) -> dict[str, Any]:
|
|
4016
|
-
"""Create a task spec to be spawned by the dispatcher.
|
|
4017
|
-
|
|
4018
|
-
Args:
|
|
4019
|
-
task_type: Type of task (e.g., 'api_analysis', 'security_scan')
|
|
4020
|
-
description: Human-readable description of the task
|
|
4021
|
-
assignee: Agent name that should handle this task
|
|
4022
|
-
input_data: Optional input data for the spawned task
|
|
4023
|
-
priority: Task priority (lower = higher priority, default 100)
|
|
4024
|
-
|
|
4025
|
-
Returns:
|
|
4026
|
-
Task specification dictionary for the dispatcher
|
|
4027
|
-
"""
|
|
4028
|
-
return {
|
|
4029
|
-
"type": task_type,
|
|
4030
|
-
"description": description,
|
|
4031
|
-
"assignee": assignee,
|
|
4032
|
-
"input_data": input_data or {},
|
|
4033
|
-
"priority": priority,
|
|
4034
|
-
"created_by": self.__class__.__name__,
|
|
4035
|
-
}
|