igel-qe-core 1.0.0
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/dist/cli/index.js +38 -0
- package/dist/mcp/server.js +104 -0
- package/knowledge_base/__init__.py +3 -0
- package/knowledge_base/__pycache__/__init__.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/__pycache__/confidence.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/config.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/config.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/config.cpython-38.pyc +0 -0
- package/knowledge_base/__pycache__/context_fusion.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/context_fusion.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/feedback_analytics.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/feedback_applier.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/feedback_cli.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/feedback_curator.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/feedback_handler.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/generate.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/generate_qcapps134.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/input_classifier.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/input_classifier.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/kg_extractor.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/knowledge_graph.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/knowledge_graph.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/manual_tc_parser.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/manual_tc_parser.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/precedence.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/prompts.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/prompts.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/reranker.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/reranker.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/retrieval_debug.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/retrieval_debug.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/retriever.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/retriever.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/server.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/tc_transformer.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/tc_transformer.cpython-37.pyc +0 -0
- package/knowledge_base/__pycache__/test_generator.cpython-314.pyc +0 -0
- package/knowledge_base/__pycache__/test_generator.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__init__.py +6 -0
- package/knowledge_base/agents/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/agents/__pycache__/fusion_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/fusion_agent.cpython-38.pyc +0 -0
- package/knowledge_base/agents/__pycache__/graph.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/graph.cpython-38.pyc +0 -0
- package/knowledge_base/agents/__pycache__/healing_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/intent_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/intent_agent.cpython-38.pyc +0 -0
- package/knowledge_base/agents/__pycache__/kg_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/kg_agent.cpython-38.pyc +0 -0
- package/knowledge_base/agents/__pycache__/memory_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/memory_agent.cpython-38.pyc +0 -0
- package/knowledge_base/agents/__pycache__/rca_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/reflection_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/reflection_agent.cpython-38.pyc +0 -0
- package/knowledge_base/agents/__pycache__/regression_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/retrieval_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/retrieval_agent.cpython-38.pyc +0 -0
- package/knowledge_base/agents/__pycache__/script_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/script_agent.cpython-38.pyc +0 -0
- package/knowledge_base/agents/__pycache__/state.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/state.cpython-38.pyc +0 -0
- package/knowledge_base/agents/__pycache__/temporal_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/temporal_agent.cpython-38.pyc +0 -0
- package/knowledge_base/agents/__pycache__/validation_agent.cpython-37.pyc +0 -0
- package/knowledge_base/agents/__pycache__/validation_agent.cpython-38.pyc +0 -0
- package/knowledge_base/agents/automation_design_agent.py +123 -0
- package/knowledge_base/agents/code_intelligence_agent.py +147 -0
- package/knowledge_base/agents/confidence_agent.py +94 -0
- package/knowledge_base/agents/execution_validation_agent.py +129 -0
- package/knowledge_base/agents/feedback_agent.py +56 -0
- package/knowledge_base/agents/fusion_agent.py +113 -0
- package/knowledge_base/agents/graph.py +152 -0
- package/knowledge_base/agents/healing_agent.py +62 -0
- package/knowledge_base/agents/intent_agent.py +76 -0
- package/knowledge_base/agents/kg_agent.py +91 -0
- package/knowledge_base/agents/memory_agent.py +62 -0
- package/knowledge_base/agents/rca_agent.py +53 -0
- package/knowledge_base/agents/reflection_agent.py +62 -0
- package/knowledge_base/agents/regression_agent.py +81 -0
- package/knowledge_base/agents/requirement_agent.py +71 -0
- package/knowledge_base/agents/retrieval_agent.py +66 -0
- package/knowledge_base/agents/scenario_agent.py +81 -0
- package/knowledge_base/agents/script_agent.py +121 -0
- package/knowledge_base/agents/script_generator_agent.py +77 -0
- package/knowledge_base/agents/state.py +53 -0
- package/knowledge_base/agents/temporal_agent.py +48 -0
- package/knowledge_base/agents/testcase_agent.py +111 -0
- package/knowledge_base/agents/validation_agent.py +49 -0
- package/knowledge_base/agents/workflow_engine.py +87 -0
- package/knowledge_base/alembic/README.md +104 -0
- package/knowledge_base/alembic/__pycache__/env.cpython-37.pyc +0 -0
- package/knowledge_base/alembic/__pycache__/env.cpython-38.pyc +0 -0
- package/knowledge_base/alembic/env.py +76 -0
- package/knowledge_base/alembic/script.py.mako +5 -0
- package/knowledge_base/alembic/versions/.gitkeep +26 -0
- package/knowledge_base/alembic/versions/001_phase0_feedback.py +122 -0
- package/knowledge_base/alembic/versions/002_feedback_promotions.py +60 -0
- package/knowledge_base/alembic/versions/003_enterprise_hardening.py +74 -0
- package/knowledge_base/alembic/versions/__pycache__/001_phase0_feedback.cpython-37.pyc +0 -0
- package/knowledge_base/alembic/versions/__pycache__/001_phase0_feedback.cpython-38.pyc +0 -0
- package/knowledge_base/alembic/versions/__pycache__/002_feedback_promotions.cpython-37.pyc +0 -0
- package/knowledge_base/alembic/versions/__pycache__/002_feedback_promotions.cpython-38.pyc +0 -0
- package/knowledge_base/api/__init__.py +1 -0
- package/knowledge_base/api/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/api/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/api/__pycache__/middleware.cpython-38.pyc +0 -0
- package/knowledge_base/api/__pycache__/server.cpython-37.pyc +0 -0
- package/knowledge_base/api/__pycache__/server.cpython-38.pyc +0 -0
- package/knowledge_base/api/middleware.py +78 -0
- package/knowledge_base/api/server.py +778 -0
- package/knowledge_base/chunking/__init__.py +0 -0
- package/knowledge_base/chunking/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/chunking/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/chunking/__pycache__/chunker.cpython-37.pyc +0 -0
- package/knowledge_base/chunking/__pycache__/chunker.cpython-38.pyc +0 -0
- package/knowledge_base/chunking/__pycache__/validators.cpython-37.pyc +0 -0
- package/knowledge_base/chunking/__pycache__/validators.cpython-38.pyc +0 -0
- package/knowledge_base/chunking/chunker.py +402 -0
- package/knowledge_base/chunking/validators.py +144 -0
- package/knowledge_base/cli/__init__.py +1 -0
- package/knowledge_base/cli/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/cli/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/cli/__pycache__/feedback_cli.cpython-37.pyc +0 -0
- package/knowledge_base/cli/__pycache__/feedback_cli.cpython-38.pyc +0 -0
- package/knowledge_base/cli/__pycache__/generate.cpython-37.pyc +0 -0
- package/knowledge_base/cli/__pycache__/generate.cpython-38.pyc +0 -0
- package/knowledge_base/cli/__pycache__/generate_qcapps134.cpython-37.pyc +0 -0
- package/knowledge_base/cli/feedback_cli.py +121 -0
- package/knowledge_base/cli/generate.py +308 -0
- package/knowledge_base/cli/generate_qcapps134.py +391 -0
- package/knowledge_base/config/.env +100 -0
- package/knowledge_base/config/.env.example +75 -0
- package/knowledge_base/config/__init__.py +5 -0
- package/knowledge_base/config/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/config/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/config/__pycache__/settings.cpython-37.pyc +0 -0
- package/knowledge_base/config/__pycache__/settings.cpython-38.pyc +0 -0
- package/knowledge_base/config/settings.py +280 -0
- package/knowledge_base/connectors/__init__.py +5 -0
- package/knowledge_base/connectors/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/base.cpython-37.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/base.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/bitbucket_connector.cpython-37.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/bitbucket_connector.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/community_connector.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/confluence_connector.cpython-37.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/confluence_connector.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/jira_connector.cpython-37.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/jira_connector.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/kb_igel_connector.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/playwright_fetcher.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/query_bridge.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/search_backends.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/serviceNow_connector.cpython-37.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/serviceNow_connector.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/sync_scheduler.cpython-37.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/sync_scheduler.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/teamcity_connector.cpython-37.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/teamcity_connector.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/testRail_connector.cpython-37.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/testRail_connector.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/__pycache__/web_fetcher.cpython-38.pyc +0 -0
- package/knowledge_base/connectors/base.py +44 -0
- package/knowledge_base/connectors/bitbucket_connector.py +25 -0
- package/knowledge_base/connectors/community_connector.py +112 -0
- package/knowledge_base/connectors/confluence_connector.py +165 -0
- package/knowledge_base/connectors/jira_connector.py +174 -0
- package/knowledge_base/connectors/kb_igel_connector.py +145 -0
- package/knowledge_base/connectors/playwright_fetcher.py +50 -0
- package/knowledge_base/connectors/query_bridge.py +170 -0
- package/knowledge_base/connectors/search_backends.py +368 -0
- package/knowledge_base/connectors/serviceNow_connector.py +25 -0
- package/knowledge_base/connectors/sync_scheduler.py +111 -0
- package/knowledge_base/connectors/teamcity_connector.py +25 -0
- package/knowledge_base/connectors/testRail_connector.py +25 -0
- package/knowledge_base/connectors/web_fetcher.py +280 -0
- package/knowledge_base/core/__init__.py +8 -0
- package/knowledge_base/core/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/core/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/core/__pycache__/cache.cpython-38.pyc +0 -0
- package/knowledge_base/core/__pycache__/circuit_breaker.cpython-38.pyc +0 -0
- package/knowledge_base/core/__pycache__/confidence.cpython-37.pyc +0 -0
- package/knowledge_base/core/__pycache__/confidence.cpython-38.pyc +0 -0
- package/knowledge_base/core/__pycache__/logging_setup.cpython-38.pyc +0 -0
- package/knowledge_base/core/__pycache__/metrics.cpython-38.pyc +0 -0
- package/knowledge_base/core/__pycache__/precedence.cpython-37.pyc +0 -0
- package/knowledge_base/core/__pycache__/precedence.cpython-38.pyc +0 -0
- package/knowledge_base/core/__pycache__/request_context.cpython-38.pyc +0 -0
- package/knowledge_base/core/cache.py +98 -0
- package/knowledge_base/core/circuit_breaker.py +33 -0
- package/knowledge_base/core/confidence.py +254 -0
- package/knowledge_base/core/logging_setup.py +39 -0
- package/knowledge_base/core/metrics.py +63 -0
- package/knowledge_base/core/precedence.py +354 -0
- package/knowledge_base/core/request_context.py +54 -0
- package/knowledge_base/db/__init__.py +0 -0
- package/knowledge_base/db/__pycache__/__init__.cpython-314.pyc +0 -0
- package/knowledge_base/db/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/db/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/db/__pycache__/client.cpython-314.pyc +0 -0
- package/knowledge_base/db/__pycache__/client.cpython-37.pyc +0 -0
- package/knowledge_base/db/__pycache__/client.cpython-38.pyc +0 -0
- package/knowledge_base/db/__pycache__/connector_sync.cpython-38.pyc +0 -0
- package/knowledge_base/db/__pycache__/feedback_schema.cpython-37.pyc +0 -0
- package/knowledge_base/db/__pycache__/feedback_schema.cpython-38.pyc +0 -0
- package/knowledge_base/db/__pycache__/kg_introspect.cpython-314.pyc +0 -0
- package/knowledge_base/db/__pycache__/kg_introspect.cpython-37.pyc +0 -0
- package/knowledge_base/db/__pycache__/kg_introspect.cpython-38.pyc +0 -0
- package/knowledge_base/db/__pycache__/schema.cpython-37.pyc +0 -0
- package/knowledge_base/db/__pycache__/schema.cpython-38.pyc +0 -0
- package/knowledge_base/db/client.py +100 -0
- package/knowledge_base/db/connector_sync.py +43 -0
- package/knowledge_base/db/feedback_schema.py +548 -0
- package/knowledge_base/db/igel_schema.py +150 -0
- package/knowledge_base/db/kg_introspect.py +116 -0
- package/knowledge_base/db/migrations.py +22 -0
- package/knowledge_base/db/schema.py +649 -0
- package/knowledge_base/deploy/Dockerfile +23 -0
- package/knowledge_base/deploy/feedback_automation.sh +18 -0
- package/knowledge_base/deploy/firecrawl-docker.sh +50 -0
- package/knowledge_base/deploy/igel-testgen.service +26 -0
- package/knowledge_base/deploy/install_reranker.sh +92 -0
- package/knowledge_base/deploy/requirements.txt +68 -0
- package/knowledge_base/deploy/run_server.sh +35 -0
- package/knowledge_base/docs/TEST_GENERATION_GUIDE.md +174 -0
- package/knowledge_base/embeddings/__init__.py +0 -0
- package/knowledge_base/embeddings/__pycache__/__init__.cpython-314.pyc +0 -0
- package/knowledge_base/embeddings/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/embeddings/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/embeddings/__pycache__/azure_embedder.cpython-314.pyc +0 -0
- package/knowledge_base/embeddings/__pycache__/azure_embedder.cpython-37.pyc +0 -0
- package/knowledge_base/embeddings/__pycache__/azure_embedder.cpython-38.pyc +0 -0
- package/knowledge_base/embeddings/azure_embedder.py +99 -0
- package/knowledge_base/eval/__init__.py +33 -0
- package/knowledge_base/eval/__main__.py +172 -0
- package/knowledge_base/eval/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/eval/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/eval/__pycache__/__main__.cpython-37.pyc +0 -0
- package/knowledge_base/eval/__pycache__/baseline.cpython-37.pyc +0 -0
- package/knowledge_base/eval/__pycache__/baseline.cpython-38.pyc +0 -0
- package/knowledge_base/eval/__pycache__/harness.cpython-37.pyc +0 -0
- package/knowledge_base/eval/__pycache__/harness.cpython-38.pyc +0 -0
- package/knowledge_base/eval/__pycache__/scorers.cpython-37.pyc +0 -0
- package/knowledge_base/eval/__pycache__/scorers.cpython-38.pyc +0 -0
- package/knowledge_base/eval/baseline.py +213 -0
- package/knowledge_base/eval/harness.py +400 -0
- package/knowledge_base/eval/queries_50.json +302 -0
- package/knowledge_base/eval/scorers.py +494 -0
- package/knowledge_base/exemplars/README.md +7 -0
- package/knowledge_base/exemplars/__pycache__/pytest_reference_snippet.cpython-37.pyc +0 -0
- package/knowledge_base/exemplars/gold_manual_concise_snippet.md +8 -0
- package/knowledge_base/exemplars/gold_manual_detailed_snippet.md +7 -0
- package/knowledge_base/exemplars/pytest_reference_snippet.py +37 -0
- package/knowledge_base/feedback/__init__.py +10 -0
- package/knowledge_base/feedback/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/feedback/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/feedback/__pycache__/analytics.cpython-37.pyc +0 -0
- package/knowledge_base/feedback/__pycache__/analytics.cpython-38.pyc +0 -0
- package/knowledge_base/feedback/__pycache__/applier.cpython-37.pyc +0 -0
- package/knowledge_base/feedback/__pycache__/applier.cpython-38.pyc +0 -0
- package/knowledge_base/feedback/__pycache__/curator.cpython-37.pyc +0 -0
- package/knowledge_base/feedback/__pycache__/curator.cpython-38.pyc +0 -0
- package/knowledge_base/feedback/__pycache__/handler.cpython-37.pyc +0 -0
- package/knowledge_base/feedback/__pycache__/handler.cpython-38.pyc +0 -0
- package/knowledge_base/feedback/analytics.py +72 -0
- package/knowledge_base/feedback/applier.py +93 -0
- package/knowledge_base/feedback/curator.py +49 -0
- package/knowledge_base/feedback/handler.py +151 -0
- package/knowledge_base/generation/__init__.py +5 -0
- package/knowledge_base/generation/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/generation/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/generation/__pycache__/input_classifier.cpython-37.pyc +0 -0
- package/knowledge_base/generation/__pycache__/input_classifier.cpython-38.pyc +0 -0
- package/knowledge_base/generation/__pycache__/manual_tc_parser.cpython-37.pyc +0 -0
- package/knowledge_base/generation/__pycache__/manual_tc_parser.cpython-38.pyc +0 -0
- package/knowledge_base/generation/__pycache__/prompts.cpython-37.pyc +0 -0
- package/knowledge_base/generation/__pycache__/prompts.cpython-38.pyc +0 -0
- package/knowledge_base/generation/__pycache__/tc_transformer.cpython-37.pyc +0 -0
- package/knowledge_base/generation/__pycache__/test_generator.cpython-37.pyc +0 -0
- package/knowledge_base/generation/__pycache__/test_generator.cpython-38.pyc +0 -0
- package/knowledge_base/generation/input_classifier.py +148 -0
- package/knowledge_base/generation/manual_tc_parser.py +180 -0
- package/knowledge_base/generation/prompts.py +755 -0
- package/knowledge_base/generation/tc_transformer.py +368 -0
- package/knowledge_base/generation/test_generator.py +553 -0
- package/knowledge_base/graph_db/__init__.py +5 -0
- package/knowledge_base/graph_db/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/graph_db/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/graph_db/__pycache__/graphiti_client.cpython-37.pyc +0 -0
- package/knowledge_base/graph_db/__pycache__/kg_traversal.cpython-37.pyc +0 -0
- package/knowledge_base/graph_db/__pycache__/migrate_kg.cpython-37.pyc +0 -0
- package/knowledge_base/graph_db/__pycache__/neo4j_client.cpython-37.pyc +0 -0
- package/knowledge_base/graph_db/__pycache__/neo4j_client.cpython-38.pyc +0 -0
- package/knowledge_base/graph_db/__pycache__/schema.cpython-37.pyc +0 -0
- package/knowledge_base/graph_db/__pycache__/temporal_ingest.cpython-37.pyc +0 -0
- package/knowledge_base/graph_db/graphiti_client.py +127 -0
- package/knowledge_base/graph_db/kg_traversal.py +192 -0
- package/knowledge_base/graph_db/migrate_kg.py +93 -0
- package/knowledge_base/graph_db/neo4j_client.py +116 -0
- package/knowledge_base/graph_db/schema.py +22 -0
- package/knowledge_base/graph_db/temporal_ingest.py +59 -0
- package/knowledge_base/ingestion/__init__.py +1 -0
- package/knowledge_base/ingestion/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/ingestion/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/ingestion/__pycache__/ingest.cpython-37.pyc +0 -0
- package/knowledge_base/ingestion/__pycache__/ingest.cpython-38.pyc +0 -0
- package/knowledge_base/ingestion/__pycache__/ingest_images.cpython-37.pyc +0 -0
- package/knowledge_base/ingestion/__pycache__/ingest_images.cpython-38.pyc +0 -0
- package/knowledge_base/ingestion/__pycache__/kg_extractor.cpython-37.pyc +0 -0
- package/knowledge_base/ingestion/__pycache__/kg_extractor.cpython-38.pyc +0 -0
- package/knowledge_base/ingestion/__pycache__/web_ingest.cpython-38.pyc +0 -0
- package/knowledge_base/ingestion/ingest.py +346 -0
- package/knowledge_base/ingestion/ingest_images.py +330 -0
- package/knowledge_base/ingestion/kg_extractor.py +358 -0
- package/knowledge_base/ingestion/web_ingest.py +83 -0
- package/knowledge_base/intelligence/__init__.py +1 -0
- package/knowledge_base/intelligence/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/intelligence/__pycache__/execution_ingest.cpython-37.pyc +0 -0
- package/knowledge_base/intelligence/__pycache__/predictive_engine.cpython-37.pyc +0 -0
- package/knowledge_base/intelligence/__pycache__/risk_scorer.cpython-37.pyc +0 -0
- package/knowledge_base/intelligence/execution_ingest.py +34 -0
- package/knowledge_base/intelligence/predictive_engine.py +7 -0
- package/knowledge_base/intelligence/risk_scorer.py +8 -0
- package/knowledge_base/memory/__init__.py +6 -0
- package/knowledge_base/memory/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/memory/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/memory/__pycache__/cognee_client.cpython-37.pyc +0 -0
- package/knowledge_base/memory/__pycache__/cognee_client.cpython-38.pyc +0 -0
- package/knowledge_base/memory/__pycache__/ingest_memory.cpython-37.pyc +0 -0
- package/knowledge_base/memory/__pycache__/memory_types.cpython-37.pyc +0 -0
- package/knowledge_base/memory/__pycache__/memory_types.cpython-38.pyc +0 -0
- package/knowledge_base/memory/cognee_client.py +164 -0
- package/knowledge_base/memory/ingest_memory.py +60 -0
- package/knowledge_base/memory/memory_types.py +23 -0
- package/knowledge_base/models/test_requirement.py +84 -0
- package/knowledge_base/parsers/__init__.py +0 -0
- package/knowledge_base/parsers/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/csv_parser.cpython-37.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/csv_parser.cpython-38.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/doc_parser.cpython-37.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/doc_parser.cpython-38.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/html_parser.cpython-38.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/image_extractor.cpython-37.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/image_extractor.cpython-38.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/markdown_parser.cpython-37.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/markdown_parser.cpython-38.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/pdf_parser.cpython-37.pyc +0 -0
- package/knowledge_base/parsers/__pycache__/pdf_parser.cpython-38.pyc +0 -0
- package/knowledge_base/parsers/csv_parser.py +126 -0
- package/knowledge_base/parsers/doc_parser.py +176 -0
- package/knowledge_base/parsers/html_parser.py +151 -0
- package/knowledge_base/parsers/image_extractor.py +370 -0
- package/knowledge_base/parsers/markdown_parser.py +116 -0
- package/knowledge_base/parsers/pdf_parser.py +178 -0
- package/knowledge_base/retrieval/__init__.py +1 -0
- package/knowledge_base/retrieval/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/context_fusion.cpython-37.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/context_fusion.cpython-38.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/knowledge_graph.cpython-37.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/knowledge_graph.cpython-38.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/reranker.cpython-37.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/reranker.cpython-38.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/retrieval_debug.cpython-37.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/retrieval_debug.cpython-38.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/retriever.cpython-37.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/retriever.cpython-38.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/unified_query.cpython-38.pyc +0 -0
- package/knowledge_base/retrieval/__pycache__/web_retriever.cpython-38.pyc +0 -0
- package/knowledge_base/retrieval/context_fusion.py +264 -0
- package/knowledge_base/retrieval/knowledge_graph.py +267 -0
- package/knowledge_base/retrieval/reranker.py +308 -0
- package/knowledge_base/retrieval/retrieval_debug.py +69 -0
- package/knowledge_base/retrieval/retriever.py +885 -0
- package/knowledge_base/retrieval/unified_query.py +189 -0
- package/knowledge_base/retrieval/web_retriever.py +337 -0
- package/knowledge_base/validators/__init__.py +1 -0
- package/knowledge_base/validators/__pycache__/__init__.cpython-314.pyc +0 -0
- package/knowledge_base/validators/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/validators/__pycache__/step_fidelity.cpython-314.pyc +0 -0
- package/knowledge_base/validators/__pycache__/step_fidelity.cpython-37.pyc +0 -0
- package/knowledge_base/validators/step_fidelity.py +88 -0
- package/knowledge_base/vision/__init__.py +0 -0
- package/knowledge_base/vision/__pycache__/__init__.cpython-37.pyc +0 -0
- package/knowledge_base/vision/__pycache__/__init__.cpython-38.pyc +0 -0
- package/knowledge_base/vision/__pycache__/image_describer.cpython-37.pyc +0 -0
- package/knowledge_base/vision/__pycache__/image_describer.cpython-38.pyc +0 -0
- package/knowledge_base/vision/image_describer.py +202 -0
- package/package.json +31 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Extract registry keys / TC Setup paths from kb_parent_chunks into knowledge_graph_*.
|
|
3
|
+
|
|
4
|
+
Targets schema from ensure_knowledge_graph_tables(): UNIQUE(node_type,normalized) on nodes,
|
|
5
|
+
UNIQUE(source_node_id,target_node_id,relation) on edges.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import logging
|
|
12
|
+
import re
|
|
13
|
+
|
|
14
|
+
from knowledge_base.config import cfg
|
|
15
|
+
from knowledge_base.db.client import close_pool, get_conn, init_pool
|
|
16
|
+
from knowledge_base.db.kg_introspect import clear_kg_layout_cache
|
|
17
|
+
from knowledge_base.db.schema import ensure_knowledge_graph_tables
|
|
18
|
+
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
_REGISTRY_RE = re.compile(r"\b(app\.[a-z0-9]+(?:\.[a-z0-9_]+)+)", re.IGNORECASE)
|
|
22
|
+
_TC_SETUP_RE = re.compile(
|
|
23
|
+
r"(?:TC\s*)?Setup\s*[>:]\s*((?:[^\n=]+)(?:\s*>\s*[^\n=]+)*(?:\s*=\s*[^\n]+)?)",
|
|
24
|
+
re.IGNORECASE,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _upsert_node(cur, *, node_type: str, value: str, normalized: str, parent_chunk_id: str) -> str | None:
|
|
29
|
+
sql_ins = """
|
|
30
|
+
INSERT INTO knowledge_graph_nodes (node_type, value, normalized, parent_chunk_id)
|
|
31
|
+
VALUES (%s, %s, %s, %s::uuid)
|
|
32
|
+
ON CONFLICT (node_type, normalized) DO UPDATE SET
|
|
33
|
+
value = EXCLUDED.value,
|
|
34
|
+
parent_chunk_id = COALESCE(EXCLUDED.parent_chunk_id, knowledge_graph_nodes.parent_chunk_id)
|
|
35
|
+
RETURNING id::text
|
|
36
|
+
"""
|
|
37
|
+
try:
|
|
38
|
+
cur.execute(
|
|
39
|
+
sql_ins,
|
|
40
|
+
(node_type, value[:4000], normalized[:2000], parent_chunk_id),
|
|
41
|
+
)
|
|
42
|
+
row = cur.fetchone()
|
|
43
|
+
return str(row[0]) if row else None
|
|
44
|
+
except Exception:
|
|
45
|
+
sel = """
|
|
46
|
+
SELECT id::text FROM knowledge_graph_nodes
|
|
47
|
+
WHERE node_type = %s AND normalized = %s LIMIT 1
|
|
48
|
+
"""
|
|
49
|
+
cur.execute(sel, (node_type, normalized[:2000]))
|
|
50
|
+
found = cur.fetchone()
|
|
51
|
+
if found:
|
|
52
|
+
return str(found[0])
|
|
53
|
+
sql_plain = """
|
|
54
|
+
INSERT INTO knowledge_graph_nodes (node_type, value, normalized, parent_chunk_id)
|
|
55
|
+
VALUES (%s, %s, %s, %s::uuid) RETURNING id::text
|
|
56
|
+
"""
|
|
57
|
+
cur.execute(
|
|
58
|
+
sql_plain,
|
|
59
|
+
(node_type, value[:4000], normalized[:2000], parent_chunk_id),
|
|
60
|
+
)
|
|
61
|
+
row = cur.fetchone()
|
|
62
|
+
return str(row[0]) if row else None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _link_edge(cur, src: str | None, tgt: str | None, relation: str) -> bool:
|
|
66
|
+
if not src or not tgt or src == tgt:
|
|
67
|
+
return False
|
|
68
|
+
sql = """
|
|
69
|
+
INSERT INTO knowledge_graph_edges (source_node_id, target_node_id, relation)
|
|
70
|
+
VALUES (%s::uuid, %s::uuid, %s)
|
|
71
|
+
ON CONFLICT (source_node_id, target_node_id, relation) DO NOTHING
|
|
72
|
+
"""
|
|
73
|
+
try:
|
|
74
|
+
cur.execute(sql, (src, tgt, relation[:200]))
|
|
75
|
+
return cur.rowcount > 0
|
|
76
|
+
except Exception:
|
|
77
|
+
return False
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def extract_from_parents(
|
|
81
|
+
limit: int | None = None,
|
|
82
|
+
offset: int = 0,
|
|
83
|
+
document_ids: list[str] | None = None,
|
|
84
|
+
) -> tuple[int, int]:
|
|
85
|
+
"""Extract KG entities from parent chunks.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
limit/offset: pagination for full-table scans.
|
|
89
|
+
document_ids: if provided, only process parent chunks belonging to
|
|
90
|
+
these documents (incremental mode for ingest integration).
|
|
91
|
+
Returns:
|
|
92
|
+
(node_upsert_count, edge_insert_count)
|
|
93
|
+
"""
|
|
94
|
+
ensure_knowledge_graph_tables()
|
|
95
|
+
clear_kg_layout_cache()
|
|
96
|
+
|
|
97
|
+
if document_ids:
|
|
98
|
+
sql = """
|
|
99
|
+
SELECT id::text, content, section_title FROM kb_parent_chunks
|
|
100
|
+
WHERE document_id = ANY(%s::uuid[])
|
|
101
|
+
ORDER BY created_at NULLS LAST, id
|
|
102
|
+
"""
|
|
103
|
+
params: list = [document_ids]
|
|
104
|
+
else:
|
|
105
|
+
sql = """
|
|
106
|
+
SELECT id::text, content, section_title FROM kb_parent_chunks
|
|
107
|
+
ORDER BY created_at NULLS LAST, id
|
|
108
|
+
"""
|
|
109
|
+
params = []
|
|
110
|
+
if limit is not None:
|
|
111
|
+
sql += " LIMIT %s OFFSET %s"
|
|
112
|
+
params.extend([limit, offset])
|
|
113
|
+
|
|
114
|
+
node_ops = 0
|
|
115
|
+
edges_ok = 0
|
|
116
|
+
|
|
117
|
+
with get_conn() as connection:
|
|
118
|
+
with connection.cursor() as cur:
|
|
119
|
+
cur.execute(sql, tuple(params))
|
|
120
|
+
rows = cur.fetchall()
|
|
121
|
+
|
|
122
|
+
for pid, content, title in rows:
|
|
123
|
+
n, e = _extract_single_parent(cur, pid, content, title)
|
|
124
|
+
node_ops += n
|
|
125
|
+
edges_ok += e
|
|
126
|
+
|
|
127
|
+
return node_ops, edges_ok
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def extract_for_document(document_id: str) -> tuple[int, int]:
|
|
131
|
+
"""Extract KG entities for a single document (called during ingest)."""
|
|
132
|
+
return extract_from_parents(document_ids=[document_id])
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
_VERSION_RE = re.compile(r"\b(?:IGEL OS|UMS|ICG|COSMOS|IMI)\s*[\d.]+(?:\s*[A-Z]{2})?\b", re.IGNORECASE)
|
|
136
|
+
_ERROR_RE = re.compile(r"\b(?:ERR|ERROR|DEFECT|BUG)[-_ ]?\d{3,8}\b", re.IGNORECASE)
|
|
137
|
+
_CLI_RE = re.compile(r"(?:^|\n)\s*(?:igel\s+)?(?:[a-z][a-z0-9_-]+\s+){1,6}[a-z0-9_-]+\s+(?:--[\w-]+(?:=\S+)?\s*)+", re.IGNORECASE)
|
|
138
|
+
_CROSS_REF_RE = re.compile(r"(?:see|refer to|documented in|depends on)\s+([^\n.]{5,80})", re.IGNORECASE)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _llm_extract_entities(content: str, title: str | None) -> dict:
|
|
142
|
+
"""LLM-assisted entity extraction for orphan parent chunks."""
|
|
143
|
+
try:
|
|
144
|
+
from knowledge_base.generation.test_generator import _call_gpt
|
|
145
|
+
prompt = f"""Extract structured entities from this IGEL documentation section.
|
|
146
|
+
Return JSON only with keys: registry_keys (list), ui_paths (list), products (list),
|
|
147
|
+
versions (list), error_codes (list), cli_commands (list), related_features (list).
|
|
148
|
+
|
|
149
|
+
Section title: {title or 'unknown'}
|
|
150
|
+
Content:
|
|
151
|
+
{content[:3500]}"""
|
|
152
|
+
raw = _call_gpt(
|
|
153
|
+
"You extract IGEL test automation entities. Return valid JSON only.",
|
|
154
|
+
prompt,
|
|
155
|
+
max_tokens=800,
|
|
156
|
+
temperature=0.0,
|
|
157
|
+
)
|
|
158
|
+
import json
|
|
159
|
+
start = raw.find("{")
|
|
160
|
+
end = raw.rfind("}") + 1
|
|
161
|
+
if start >= 0 and end > start:
|
|
162
|
+
return json.loads(raw[start:end])
|
|
163
|
+
except Exception as exc:
|
|
164
|
+
logger.debug("LLM KG extraction failed: %s", exc)
|
|
165
|
+
return {}
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def enrich_orphan_parents(*, limit: int = 500) -> tuple[int, int]:
|
|
169
|
+
"""Run LLM extraction on parent chunks with no KG entity."""
|
|
170
|
+
ensure_knowledge_graph_tables()
|
|
171
|
+
sql = """
|
|
172
|
+
SELECT p.id::text, p.content, p.section_title
|
|
173
|
+
FROM kb_parent_chunks p
|
|
174
|
+
WHERE NOT EXISTS (
|
|
175
|
+
SELECT 1 FROM knowledge_graph_nodes n WHERE n.parent_chunk_id = p.id
|
|
176
|
+
)
|
|
177
|
+
ORDER BY p.created_at NULLS LAST
|
|
178
|
+
LIMIT %s
|
|
179
|
+
"""
|
|
180
|
+
node_ops = edges_ok = 0
|
|
181
|
+
with get_conn() as conn:
|
|
182
|
+
with conn.cursor() as cur:
|
|
183
|
+
cur.execute(sql, (limit,))
|
|
184
|
+
rows = cur.fetchall()
|
|
185
|
+
for pid, content, title in rows:
|
|
186
|
+
n, e = _extract_single_parent(cur, pid, content, title)
|
|
187
|
+
node_ops += n
|
|
188
|
+
edges_ok += e
|
|
189
|
+
if n == 0:
|
|
190
|
+
entities = _llm_extract_entities(content, title)
|
|
191
|
+
n2, e2 = _apply_llm_entities(cur, pid, title, entities)
|
|
192
|
+
node_ops += n2
|
|
193
|
+
edges_ok += e2
|
|
194
|
+
return node_ops, edges_ok
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _apply_llm_entities(cur, pid: str, title: str | None, entities: dict) -> tuple[int, int]:
|
|
198
|
+
node_ops = edges_ok = 0
|
|
199
|
+
feature_name = (title or "").strip()[:240] or ("section_" + pid[:8])
|
|
200
|
+
fid = _upsert_node(
|
|
201
|
+
cur, node_type="feature", value=feature_name,
|
|
202
|
+
normalized=feature_name.lower()[:2000], parent_chunk_id=pid,
|
|
203
|
+
)
|
|
204
|
+
if fid:
|
|
205
|
+
node_ops += 1
|
|
206
|
+
|
|
207
|
+
mapping = [
|
|
208
|
+
("registry_keys", "registry_key", "uses"),
|
|
209
|
+
("ui_paths", "ui_path", "configured_via"),
|
|
210
|
+
("products", "product", "documented_in"),
|
|
211
|
+
("versions", "version", "documented_in"),
|
|
212
|
+
("error_codes", "error_code", "related_to"),
|
|
213
|
+
("cli_commands", "cli_command", "uses"),
|
|
214
|
+
("related_features", "feature", "depends_on"),
|
|
215
|
+
]
|
|
216
|
+
for key, node_type, relation in mapping:
|
|
217
|
+
for val in entities.get(key) or []:
|
|
218
|
+
if not val or not str(val).strip():
|
|
219
|
+
continue
|
|
220
|
+
val_s = str(val).strip()[:2000]
|
|
221
|
+
nid = _upsert_node(
|
|
222
|
+
cur, node_type=node_type, value=val_s,
|
|
223
|
+
normalized=val_s.lower()[:2000], parent_chunk_id=pid,
|
|
224
|
+
)
|
|
225
|
+
if nid:
|
|
226
|
+
node_ops += 1
|
|
227
|
+
if fid and _link_edge(cur, fid, nid, relation):
|
|
228
|
+
edges_ok += 1
|
|
229
|
+
return node_ops, edges_ok
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def _extract_single_parent(cur, pid: str, content: str, title: str | None) -> tuple[int, int]:
|
|
233
|
+
"""Process one parent chunk: create feature node + registry/ui_path nodes + edges."""
|
|
234
|
+
node_ops = 0
|
|
235
|
+
edges_ok = 0
|
|
236
|
+
|
|
237
|
+
blob = f"{title or ''}\n{content}"
|
|
238
|
+
feature_name = (title or "").strip()[:240] or ("section_" + pid[:8])
|
|
239
|
+
|
|
240
|
+
fid = _upsert_node(
|
|
241
|
+
cur,
|
|
242
|
+
node_type="feature",
|
|
243
|
+
value=feature_name,
|
|
244
|
+
normalized=feature_name.lower()[:2000],
|
|
245
|
+
parent_chunk_id=pid,
|
|
246
|
+
)
|
|
247
|
+
if fid:
|
|
248
|
+
node_ops += 1
|
|
249
|
+
|
|
250
|
+
for m in _REGISTRY_RE.findall(blob):
|
|
251
|
+
val = m.strip()
|
|
252
|
+
rid = _upsert_node(
|
|
253
|
+
cur,
|
|
254
|
+
node_type="registry_key",
|
|
255
|
+
value=val,
|
|
256
|
+
normalized=val.lower(),
|
|
257
|
+
parent_chunk_id=pid,
|
|
258
|
+
)
|
|
259
|
+
if rid:
|
|
260
|
+
node_ops += 1
|
|
261
|
+
if fid and _link_edge(cur, fid, rid, "uses"):
|
|
262
|
+
edges_ok += 1
|
|
263
|
+
|
|
264
|
+
for m in _TC_SETUP_RE.findall(blob):
|
|
265
|
+
path = m.strip()[:2000]
|
|
266
|
+
if len(path) < 8:
|
|
267
|
+
continue
|
|
268
|
+
uid = _upsert_node(
|
|
269
|
+
cur,
|
|
270
|
+
node_type="ui_path",
|
|
271
|
+
value=path,
|
|
272
|
+
normalized=path.lower()[:2000],
|
|
273
|
+
parent_chunk_id=pid,
|
|
274
|
+
)
|
|
275
|
+
if uid:
|
|
276
|
+
node_ops += 1
|
|
277
|
+
if fid and _link_edge(cur, fid, uid, "configured_via"):
|
|
278
|
+
edges_ok += 1
|
|
279
|
+
|
|
280
|
+
for m in _VERSION_RE.findall(blob):
|
|
281
|
+
val = m.strip()
|
|
282
|
+
vid = _upsert_node(cur, node_type="version", value=val, normalized=val.lower(), parent_chunk_id=pid)
|
|
283
|
+
if vid and fid and _link_edge(cur, fid, vid, "documented_in"):
|
|
284
|
+
node_ops += 1
|
|
285
|
+
edges_ok += 1
|
|
286
|
+
|
|
287
|
+
for m in _ERROR_RE.findall(blob):
|
|
288
|
+
val = m.strip()
|
|
289
|
+
eid = _upsert_node(cur, node_type="error_code", value=val, normalized=val.lower(), parent_chunk_id=pid)
|
|
290
|
+
if eid:
|
|
291
|
+
node_ops += 1
|
|
292
|
+
if fid and _link_edge(cur, fid, eid, "related_to"):
|
|
293
|
+
edges_ok += 1
|
|
294
|
+
|
|
295
|
+
for m in _CROSS_REF_RE.findall(blob):
|
|
296
|
+
ref = m.strip()[:2000]
|
|
297
|
+
rid = _upsert_node(cur, node_type="feature", value=ref, normalized=ref.lower()[:2000], parent_chunk_id=pid)
|
|
298
|
+
if rid and fid and _link_edge(cur, fid, rid, "depends_on"):
|
|
299
|
+
node_ops += 1
|
|
300
|
+
edges_ok += 1
|
|
301
|
+
|
|
302
|
+
_shadow_write_neo4j(feature_name, blob)
|
|
303
|
+
|
|
304
|
+
return node_ops, edges_ok
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def _shadow_write_neo4j(feature_name: str, blob: str) -> None:
|
|
308
|
+
"""Dual-write extracted entities to Neo4j when shadow mode is enabled (Phase 3)."""
|
|
309
|
+
try:
|
|
310
|
+
from knowledge_base.graph_db.neo4j_client import get_neo4j_client, should_write_neo4j
|
|
311
|
+
|
|
312
|
+
if not should_write_neo4j():
|
|
313
|
+
return
|
|
314
|
+
|
|
315
|
+
client = get_neo4j_client()
|
|
316
|
+
if not client.available:
|
|
317
|
+
return
|
|
318
|
+
|
|
319
|
+
client.upsert_entity("Feature", "name", feature_name, {"source": "kg_extractor"})
|
|
320
|
+
|
|
321
|
+
for m in _REGISTRY_RE.findall(blob):
|
|
322
|
+
key = m.strip()
|
|
323
|
+
client.upsert_entity("RegistryKey", "key", key, {})
|
|
324
|
+
client.upsert_relationship(
|
|
325
|
+
"Feature", "name", feature_name,
|
|
326
|
+
"USES",
|
|
327
|
+
"RegistryKey", "key", key,
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
for m in _TC_SETUP_RE.findall(blob):
|
|
331
|
+
path = m.strip()[:2000]
|
|
332
|
+
if len(path) < 8:
|
|
333
|
+
continue
|
|
334
|
+
client.upsert_entity("UIPath", "path", path, {})
|
|
335
|
+
client.upsert_relationship(
|
|
336
|
+
"Feature", "name", feature_name,
|
|
337
|
+
"CONFIGURED_VIA",
|
|
338
|
+
"UIPath", "path", path,
|
|
339
|
+
)
|
|
340
|
+
except Exception as e:
|
|
341
|
+
logger.debug("Neo4j shadow write skipped: %s", e)
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def main() -> None:
|
|
345
|
+
logging.basicConfig(level=getattr(logging, cfg.LOG_LEVEL.upper(), logging.INFO))
|
|
346
|
+
parser = argparse.ArgumentParser(description="Extract KG entities from kb_parent_chunks.")
|
|
347
|
+
parser.add_argument("--limit", type=int, default=None)
|
|
348
|
+
parser.add_argument("--offset", type=int, default=0)
|
|
349
|
+
args = parser.parse_args()
|
|
350
|
+
|
|
351
|
+
init_pool()
|
|
352
|
+
n, e = extract_from_parents(limit=args.limit, offset=args.offset)
|
|
353
|
+
print(f"Done. Node upserts / inserts touched ≈ {n}, new edges inserted ≈ {e}")
|
|
354
|
+
close_pool()
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
if __name__ == "__main__":
|
|
358
|
+
main()
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Ingest web-fetched pages into PostgreSQL vector store."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
import logging
|
|
7
|
+
|
|
8
|
+
from knowledge_base.chunking.chunker import chunk_sections
|
|
9
|
+
from knowledge_base.config import cfg
|
|
10
|
+
from knowledge_base.db.client import init_pool
|
|
11
|
+
from knowledge_base.db.schema import (
|
|
12
|
+
clear_document_chunks,
|
|
13
|
+
document_exists,
|
|
14
|
+
document_has_chunks,
|
|
15
|
+
ingest_document_atomic,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def ingest_web_items(items: list[dict], *, source_label: str = "web") -> int:
|
|
22
|
+
"""Chunk and embed web pages into kb_documents/kb_chunks with dedup + atomic writes."""
|
|
23
|
+
if not items:
|
|
24
|
+
return 0
|
|
25
|
+
|
|
26
|
+
init_pool()
|
|
27
|
+
total_children = 0
|
|
28
|
+
|
|
29
|
+
for item in items:
|
|
30
|
+
url = item.get("url", "")
|
|
31
|
+
title = item.get("title", url)
|
|
32
|
+
sections = item.get("sections") or []
|
|
33
|
+
source_type = item.get("source_type", "kb_web")
|
|
34
|
+
product = item.get("product", "IGEL")
|
|
35
|
+
|
|
36
|
+
if not sections and item.get("raw_text"):
|
|
37
|
+
from knowledge_base.parsers.markdown_parser import Section
|
|
38
|
+
|
|
39
|
+
sections = [
|
|
40
|
+
Section(
|
|
41
|
+
title=title,
|
|
42
|
+
level=1,
|
|
43
|
+
content=item["raw_text"],
|
|
44
|
+
metadata={"canonical_url": url, "source_type": source_type},
|
|
45
|
+
)
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
file_name = f"web:{source_label}:{hashlib.sha256(url.encode()).hexdigest()[:12]}"
|
|
49
|
+
file_hash = hashlib.sha256((url + title).encode()).hexdigest()
|
|
50
|
+
|
|
51
|
+
existing_id = document_exists(file_hash)
|
|
52
|
+
if existing_id and document_has_chunks(existing_id):
|
|
53
|
+
logger.debug("web_ingest skip duplicate: %s", url)
|
|
54
|
+
continue
|
|
55
|
+
|
|
56
|
+
parents, warnings = chunk_sections(sections, file_name, product)
|
|
57
|
+
for w in warnings[:5]:
|
|
58
|
+
logger.debug("web_ingest warning: %s", w)
|
|
59
|
+
|
|
60
|
+
from knowledge_base.embeddings.azure_embedder import embed_texts, format_for_pgvector
|
|
61
|
+
|
|
62
|
+
_, _, doc_children, _ = ingest_document_atomic(
|
|
63
|
+
file_name=file_name,
|
|
64
|
+
file_path=url,
|
|
65
|
+
file_type="html",
|
|
66
|
+
file_hash=file_hash,
|
|
67
|
+
product=product,
|
|
68
|
+
doc_metadata={
|
|
69
|
+
"source_type": source_type,
|
|
70
|
+
"canonical_url": url,
|
|
71
|
+
"title": title,
|
|
72
|
+
"web_source": source_label,
|
|
73
|
+
},
|
|
74
|
+
parents=parents,
|
|
75
|
+
existing_id=existing_id,
|
|
76
|
+
embed_fn=embed_texts,
|
|
77
|
+
format_fn=format_for_pgvector,
|
|
78
|
+
batch_size=cfg.BATCH_SIZE,
|
|
79
|
+
)
|
|
80
|
+
total_children += doc_children
|
|
81
|
+
|
|
82
|
+
logger.info("web_ingest: ingested %d child chunks from %d pages", total_children, len(items))
|
|
83
|
+
return total_children
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Execution intelligence package — Phase 7."""
|
|
Binary file
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Execution memory ingestion — Phase 7."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
from knowledge_base.config import cfg
|
|
7
|
+
from knowledge_base.memory.cognee_client import get_cognee_client
|
|
8
|
+
from knowledge_base.memory.memory_types import MemoryType
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def ingest_execution_results(results: list[dict], *, dry_run: bool = False) -> dict:
|
|
14
|
+
"""
|
|
15
|
+
Parse CI results and store failure patterns in operational memory.
|
|
16
|
+
Each result: {test_id, status, failure_log, feature_area}
|
|
17
|
+
"""
|
|
18
|
+
if not cfg.COGNEE_ENABLED:
|
|
19
|
+
return {"ingested": 0, "skipped": len(results), "reason": "COGNEE_ENABLED=false"}
|
|
20
|
+
|
|
21
|
+
client = get_cognee_client()
|
|
22
|
+
ingested = 0
|
|
23
|
+
for r in results:
|
|
24
|
+
if r.get("status") != "failed":
|
|
25
|
+
continue
|
|
26
|
+
content = f"Test {r.get('test_id')} failed: {(r.get('failure_log') or '')[:500]}"
|
|
27
|
+
feature = r.get("feature_area", "IGEL OS General")
|
|
28
|
+
if dry_run:
|
|
29
|
+
ingested += 1
|
|
30
|
+
continue
|
|
31
|
+
client.add_memory(content, MemoryType.EXECUTION, feature_area=feature)
|
|
32
|
+
ingested += 1
|
|
33
|
+
|
|
34
|
+
return {"ingested": ingested, "total": len(results)}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""Test risk scoring — Phase 7."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def score_test_risk(test_id: str, *, failure_rate: float = 0.0, recency_days: int = 30) -> float:
|
|
6
|
+
"""Score a test case by failure rate and recency (0.0–1.0)."""
|
|
7
|
+
recency_factor = max(0.1, 1.0 - (recency_days / 365))
|
|
8
|
+
return min(1.0, failure_rate * 0.7 + recency_factor * 0.3)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Operational memory layer — Phase 4 Cognee integration."""
|
|
2
|
+
|
|
3
|
+
from knowledge_base.memory.cognee_client import CogneeClient, get_cognee_client
|
|
4
|
+
from knowledge_base.memory.memory_types import MemoryType
|
|
5
|
+
|
|
6
|
+
__all__ = ["CogneeClient", "get_cognee_client", "MemoryType"]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|