contextsynapse 1.0.0__py3-none-any.whl
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.
- contextsynapse/__init__.py +107 -0
- contextsynapse/__main__.py +9 -0
- contextsynapse/a2a/__init__.py +28 -0
- contextsynapse/a2a/client.py +120 -0
- contextsynapse/a2a/discovery.py +128 -0
- contextsynapse/a2a/handlers.py +164 -0
- contextsynapse/a2a/models.py +246 -0
- contextsynapse/a2a/streaming.py +92 -0
- contextsynapse/a2a/task_manager.py +275 -0
- contextsynapse/adapters/__init__.py +98 -0
- contextsynapse/adapters/_base.py +298 -0
- contextsynapse/adapters/autogen/__init__.py +4 -0
- contextsynapse/adapters/autogen/tools.py +34 -0
- contextsynapse/adapters/crewai/__init__.py +4 -0
- contextsynapse/adapters/crewai/tools.py +63 -0
- contextsynapse/adapters/langchain/__init__.py +19 -0
- contextsynapse/adapters/langchain/message_history.py +17 -0
- contextsynapse/adapters/langchain/retriever.py +158 -0
- contextsynapse/adapters/langchain/tools.py +43 -0
- contextsynapse/adapters/langgraph/__init__.py +21 -0
- contextsynapse/adapters/langgraph/checkpoint.py +223 -0
- contextsynapse/adapters/langgraph/context_tools.py +341 -0
- contextsynapse/adapters/langgraph/message_history.py +138 -0
- contextsynapse/adapters/langgraph/tools.py +43 -0
- contextsynapse/adapters/llamaindex/__init__.py +4 -0
- contextsynapse/adapters/llamaindex/tools.py +64 -0
- contextsynapse/adapters/openai/__init__.py +24 -0
- contextsynapse/adapters/openai/tools.py +206 -0
- contextsynapse/adapters/pydantic_ai/__init__.py +4 -0
- contextsynapse/adapters/pydantic_ai/tools.py +36 -0
- contextsynapse/adapters/swarm/__init__.py +4 -0
- contextsynapse/adapters/swarm/tools.py +44 -0
- contextsynapse/agents/__init__.py +6 -0
- contextsynapse/agents/auto_capture.py +80 -0
- contextsynapse/agents/dispatcher.py +299 -0
- contextsynapse/agents/notifications.py +112 -0
- contextsynapse/aiql/__init__.py +71 -0
- contextsynapse/aiql/cache.py +341 -0
- contextsynapse/aiql/compiler/__init__.py +62 -0
- contextsynapse/aiql/compiler/optimizer.py +126 -0
- contextsynapse/aiql/compiler/planner.py +366 -0
- contextsynapse/aiql/compiler/statistics.py +235 -0
- contextsynapse/aiql/compiler/validator.py +425 -0
- contextsynapse/aiql/engine/__init__.py +11 -0
- contextsynapse/aiql/engine/chunk_storage.py +2584 -0
- contextsynapse/aiql/engine/executor.py +7737 -0
- contextsynapse/aiql/engine/extraction_integration.py +442 -0
- contextsynapse/aiql/engine/graph_builder.py +405 -0
- contextsynapse/aiql/engine/node_creation_from_normalized.py +691 -0
- contextsynapse/aiql/engine/performance_monitor.py +289 -0
- contextsynapse/aiql/engine/postprocessing.py +365 -0
- contextsynapse/aiql/engine/ray_stage_executors.py +918 -0
- contextsynapse/aiql/engine/redis_cache.py +106 -0
- contextsynapse/aiql/engine/streaming_json.py +366 -0
- contextsynapse/aiql/engine/streaming_parquet.py +568 -0
- contextsynapse/aiql/engine/streaming_ray_chunking.py +419 -0
- contextsynapse/aiql/grammar/__init__.py +14 -0
- contextsynapse/aiql/grammar/aiql_grammar.py +1822 -0
- contextsynapse/aiql/grammar/base.py +71 -0
- contextsynapse/aiql/parser/__init__.py +46 -0
- contextsynapse/aiql/parser/aiql_parser.py +11330 -0
- contextsynapse/aiql/parser/base_parser.py +47 -0
- contextsynapse/api/__init__.py +5 -0
- contextsynapse/api/a2a_router.py +233 -0
- contextsynapse/api/admin_router.py +140 -0
- contextsynapse/api/agent_worker_router.py +978 -0
- contextsynapse/api/algorithms_router.py +317 -0
- contextsynapse/api/api.py +4144 -0
- contextsynapse/api/audit.py +204 -0
- contextsynapse/api/auth.py +441 -0
- contextsynapse/api/auth_router.py +537 -0
- contextsynapse/api/billing.py +261 -0
- contextsynapse/api/billing_router.py +275 -0
- contextsynapse/api/boundary_router.py +452 -0
- contextsynapse/api/cognition_router.py +116 -0
- contextsynapse/api/connector_router.py +237 -0
- contextsynapse/api/context_router.py +1619 -0
- contextsynapse/api/dashboard_router.py +11367 -0
- contextsynapse/api/errors.py +183 -0
- contextsynapse/api/events.py +88 -0
- contextsynapse/api/experiment_bootstrap.py +321 -0
- contextsynapse/api/experiment_orchestrator.py +1078 -0
- contextsynapse/api/experiment_router.py +2089 -0
- contextsynapse/api/feature_gate.py +89 -0
- contextsynapse/api/federation_router.py +108 -0
- contextsynapse/api/integrations.py +567 -0
- contextsynapse/api/integrations_router.py +461 -0
- contextsynapse/api/intelligence_router.py +1028 -0
- contextsynapse/api/metering.py +155 -0
- contextsynapse/api/metrics.py +112 -0
- contextsynapse/api/models.py +38 -0
- contextsynapse/api/monitoring_router.py +174 -0
- contextsynapse/api/pipeline_router.py +1437 -0
- contextsynapse/api/playground_conn.py +116 -0
- contextsynapse/api/projects_router.py +131 -0
- contextsynapse/api/queries_router.py +282 -0
- contextsynapse/api/quota.py +95 -0
- contextsynapse/api/rate_limit.py +64 -0
- contextsynapse/api/search_router.py +261 -0
- contextsynapse/api/shield_router.py +447 -0
- contextsynapse/api/tenant_guard.py +103 -0
- contextsynapse/api/tenant_quotas.py +231 -0
- contextsynapse/api/tenants.py +305 -0
- contextsynapse/api/users.py +646 -0
- contextsynapse/api/v1.py +167 -0
- contextsynapse/api/vertical_builder_router.py +387 -0
- contextsynapse/benchmark/__init__.py +15 -0
- contextsynapse/benchmark/__main__.py +64 -0
- contextsynapse/benchmark/agents.py +338 -0
- contextsynapse/benchmark/live_ab.py +338 -0
- contextsynapse/benchmark/reporter.py +149 -0
- contextsynapse/benchmark/runner.py +264 -0
- contextsynapse/benchmark/savings.py +266 -0
- contextsynapse/benchmark/token_counter.py +212 -0
- contextsynapse/benchmark/workloads.py +289 -0
- contextsynapse/buffer/__init__.py +154 -0
- contextsynapse/buffer/base.py +257 -0
- contextsynapse/buffer/duckdb_buffer.py +246 -0
- contextsynapse/buffer/file_buffer.py +229 -0
- contextsynapse/buffer/lmdb_buffer.py +286 -0
- contextsynapse/buffer/local_buffer.py +154 -0
- contextsynapse/buffer/redis_buffer.py +211 -0
- contextsynapse/buffer/sqlite_buffer.py +266 -0
- contextsynapse/cache.py +2 -0
- contextsynapse/cli/__init__.py +40 -0
- contextsynapse/cli/cli.py +475 -0
- contextsynapse/cli/config_cli.py +177 -0
- contextsynapse/cli/scaffold.py +465 -0
- contextsynapse/cognition/__init__.py +31 -0
- contextsynapse/cognition/derivation.py +55 -0
- contextsynapse/cognition/events.py +135 -0
- contextsynapse/cognition/feedback.py +52 -0
- contextsynapse/cognition/hallucination.py +90 -0
- contextsynapse/cognition/invalidation.py +70 -0
- contextsynapse/cognition/read_tracker.py +50 -0
- contextsynapse/collaboration.py +2 -0
- contextsynapse/comparison.py +2 -0
- contextsynapse/config/__init__.py +10 -0
- contextsynapse/config/connectors/amfi_nav.yaml +18 -0
- contextsynapse/config/connectors/auto_sector.yaml +20 -0
- contextsynapse/config/connectors/banking_sector.yaml +20 -0
- contextsynapse/config/connectors/energy_sector.yaml +20 -0
- contextsynapse/config/connectors/fmcg_sector.yaml +20 -0
- contextsynapse/config/connectors/nsdl_fpi.yaml +9 -0
- contextsynapse/config/connectors/nse_price.yaml +61 -0
- contextsynapse/config/connectors/pharma_sector.yaml +20 -0
- contextsynapse/config/connectors/rbi_dbie.yaml +12 -0
- contextsynapse/config/context_presets/ai_research.json +25 -0
- contextsynapse/config/context_presets/chatgpt_conversations.json +19 -0
- contextsynapse/config/context_presets/claude_conversations.json +19 -0
- contextsynapse/config/context_presets/legal_compliance.json +21 -0
- contextsynapse/config/context_presets/meeting_notes.json +21 -0
- contextsynapse/config/context_presets/slack_engineering.json +21 -0
- contextsynapse/config/context_presets/tech_climate.json +24 -0
- contextsynapse/config/context_presets/toi_politics.json +25 -0
- contextsynapse/config/database_config.py +453 -0
- contextsynapse/config/deployment.py +221 -0
- contextsynapse/config/gpt_action_schema.json +164 -0
- contextsynapse/config/indicators/india_macro.yaml +213 -0
- contextsynapse/config/logging_config.py +88 -0
- contextsynapse/config/mode_config.py +223 -0
- contextsynapse/config/schemas/api_spec.yaml +48 -0
- contextsynapse/config/schemas/architecture_doc.yaml +51 -0
- contextsynapse/config/schemas/chat_history.yaml +90 -0
- contextsynapse/config/schemas/chatgpt_conversation.yaml +101 -0
- contextsynapse/config/schemas/claude_conversation.yaml +148 -0
- contextsynapse/config/schemas/contract.yaml +48 -0
- contextsynapse/config/schemas/conversation.yaml +167 -0
- contextsynapse/config/schemas/database.yaml +74 -0
- contextsynapse/config/schemas/decision.yaml +72 -0
- contextsynapse/config/schemas/ecommerce.yaml +56 -0
- contextsynapse/config/schemas/education.yaml +42 -0
- contextsynapse/config/schemas/healthcare.yaml +133 -0
- contextsynapse/config/schemas/hr_document.yaml +48 -0
- contextsynapse/config/schemas/invoice.yaml +40 -0
- contextsynapse/config/schemas/knowledge_base.yaml +75 -0
- contextsynapse/config/schemas/legal.yaml +42 -0
- contextsynapse/config/schemas/marketing_content.yaml +48 -0
- contextsynapse/config/schemas/meeting_notes.yaml +51 -0
- contextsynapse/config/schemas/news_article.yaml +61 -0
- contextsynapse/config/schemas/real_estate.yaml +49 -0
- contextsynapse/config/schemas/requirements_doc.yaml +48 -0
- contextsynapse/config/schemas/research_paper.yaml +56 -0
- contextsynapse/config/schemas/resume.yaml +49 -0
- contextsynapse/config/schemas/retail.yaml +42 -0
- contextsynapse/config/schemas/rule_meta.yaml +173 -0
- contextsynapse/config/schemas/rules.yaml +72 -0
- contextsynapse/config/schemas/screener_meta.yaml +236 -0
- contextsynapse/config/schemas/sdlc.yaml +103 -0
- contextsynapse/config/schemas/session_graph.yaml +172 -0
- contextsynapse/config/schemas/support_ticket.yaml +48 -0
- contextsynapse/config/schemas/web.yaml +64 -0
- contextsynapse/config/sensors/earnings_calendar.yaml +52 -0
- contextsynapse/config/sensors/global_risk.yaml +53 -0
- contextsynapse/config/sensors/government_policy.yaml +54 -0
- contextsynapse/config/sensors/supply_chain.yaml +50 -0
- contextsynapse/config/sensors/templates/behavioral.yaml +56 -0
- contextsynapse/config/sensors/templates/equity_sentiment.yaml +48 -0
- contextsynapse/config/sensors/templates/global_macro.yaml +47 -0
- contextsynapse/config/sensors/templates/market_data.yaml +118 -0
- contextsynapse/config/sensors/templates/sector_technical.yaml +47 -0
- contextsynapse/config/sensors/weather.yaml +52 -0
- contextsynapse/config/storage_strategy.py +202 -0
- contextsynapse/config/templates/competitive_intel.yaml +39 -0
- contextsynapse/config/templates/geopolitical_risk.yaml +46 -0
- contextsynapse/config/templates/market_analysis.yaml +58 -0
- contextsynapse/connectors/__init__.py +15 -0
- contextsynapse/connectors/api_router.py +121 -0
- contextsynapse/connectors/base.py +357 -0
- contextsynapse/connectors/financial/audio.py +170 -0
- contextsynapse/connectors/financial/youtube.py +272 -0
- contextsynapse/connectors/github.py +164 -0
- contextsynapse/connectors/jira.py +120 -0
- contextsynapse/connectors/kafka_connector.py +124 -0
- contextsynapse/connectors/pipeline_connector.py +747 -0
- contextsynapse/connectors/registry.py +116 -0
- contextsynapse/connectors/scheduler.py +87 -0
- contextsynapse/connectors/universal.py +360 -0
- contextsynapse/context/__init__.py +96 -0
- contextsynapse/context/__main__.py +4 -0
- contextsynapse/context/acl.py +125 -0
- contextsynapse/context/agent_card.py +201 -0
- contextsynapse/context/agent_memory.py +814 -0
- contextsynapse/context/agents.py +472 -0
- contextsynapse/context/agents_redis.py +391 -0
- contextsynapse/context/assembled.py +204 -0
- contextsynapse/context/attribution.py +113 -0
- contextsynapse/context/blob.py +184 -0
- contextsynapse/context/boundaries.py +187 -0
- contextsynapse/context/boundary.py +507 -0
- contextsynapse/context/bundle.py +155 -0
- contextsynapse/context/cli.py +519 -0
- contextsynapse/context/collaboration.py +165 -0
- contextsynapse/context/compiler.py +604 -0
- contextsynapse/context/composite.py +536 -0
- contextsynapse/context/compression.py +147 -0
- contextsynapse/context/context_manager.py +888 -0
- contextsynapse/context/context_schema.py +90 -0
- contextsynapse/context/context_schema.yaml +105 -0
- contextsynapse/context/context_units.py +891 -0
- contextsynapse/context/conversation.py +488 -0
- contextsynapse/context/dedup.py +207 -0
- contextsynapse/context/document_processor.py +698 -0
- contextsynapse/context/embedding_hooks.py +338 -0
- contextsynapse/context/execution_schema.py +274 -0
- contextsynapse/context/fan_out.py +138 -0
- contextsynapse/context/frozen.py +80 -0
- contextsynapse/context/gravity.py +227 -0
- contextsynapse/context/hub.py +1401 -0
- contextsynapse/context/ingest.py +391 -0
- contextsynapse/context/injection.py +226 -0
- contextsynapse/context/interaction_graphifier.py +562 -0
- contextsynapse/context/layers.py +574 -0
- contextsynapse/context/projection.py +1195 -0
- contextsynapse/context/promotion.py +634 -0
- contextsynapse/context/proof.py +131 -0
- contextsynapse/context/propagation.py +577 -0
- contextsynapse/context/pubsub.py +135 -0
- contextsynapse/context/quality.py +1054 -0
- contextsynapse/context/quality_tracker.py +270 -0
- contextsynapse/context/scoping.py +370 -0
- contextsynapse/context/seed.py +992 -0
- contextsynapse/context/session.py +1142 -0
- contextsynapse/context/session_graph.py +593 -0
- contextsynapse/context/session_memory.py +309 -0
- contextsynapse/context/session_resolver.py +111 -0
- contextsynapse/context/skill_learning.py +237 -0
- contextsynapse/context/smart_budget.py +129 -0
- contextsynapse/context/source_policy.py +242 -0
- contextsynapse/context/store_factory.py +53 -0
- contextsynapse/context/sync.py +648 -0
- contextsynapse/context/token.py +236 -0
- contextsynapse/context/vector_integration.py +297 -0
- contextsynapse/context/webhooks.py +194 -0
- contextsynapse/context/working_memory.py +224 -0
- contextsynapse/core/__init__.py +18 -0
- contextsynapse/core/archiver.py +237 -0
- contextsynapse/core/change_stream.py +282 -0
- contextsynapse/core/checkpoint.py +310 -0
- contextsynapse/core/cloud_storage.py +387 -0
- contextsynapse/core/context_state.py +651 -0
- contextsynapse/core/cron.py +324 -0
- contextsynapse/core/datasource.py +643 -0
- contextsynapse/core/db.py +289 -0
- contextsynapse/core/federation.py +283 -0
- contextsynapse/core/graph_coordinator.py +201 -0
- contextsynapse/core/graph_intelligence.py +388 -0
- contextsynapse/core/graph_structures.py +106 -0
- contextsynapse/core/graph_sync.py +157 -0
- contextsynapse/core/hybrid_graph_storage.py +2998 -0
- contextsynapse/core/lifecycle.py +691 -0
- contextsynapse/core/multiworker.py +378 -0
- contextsynapse/core/pruning.py +312 -0
- contextsynapse/core/redis_registry.py +524 -0
- contextsynapse/core/registry.py +1043 -0
- contextsynapse/core/registry_factory.py +51 -0
- contextsynapse/core/registry_metadata.py +294 -0
- contextsynapse/core/replay.py +354 -0
- contextsynapse/core/replication.py +339 -0
- contextsynapse/core/time_travel.py +260 -0
- contextsynapse/core/write_behind.py +152 -0
- contextsynapse/core/write_context.py +39 -0
- contextsynapse/db/__init__.py +1 -0
- contextsynapse/db/postgres.py +267 -0
- contextsynapse/db/profile.py +236 -0
- contextsynapse/db/rules.py +328 -0
- contextsynapse/demo/__init__.py +0 -0
- contextsynapse/demo/report.py +147 -0
- contextsynapse/demo/runner.py +520 -0
- contextsynapse/demo/scenario.py +165 -0
- contextsynapse/demo/session_demo.py +280 -0
- contextsynapse/demo/session_report.py +143 -0
- contextsynapse/demo/universal_runner.py +257 -0
- contextsynapse/engine/__init__.py +15 -0
- contextsynapse/engine/core.py +555 -0
- contextsynapse/extraction/__init__.py +69 -0
- contextsynapse/extraction/cli.py +274 -0
- contextsynapse/extraction/config.py +107 -0
- contextsynapse/extraction/examples/example_usage.py +118 -0
- contextsynapse/extraction/examples/sample_manifest.json +53 -0
- contextsynapse/extraction/examples/sample_normalized.json +185 -0
- contextsynapse/extraction/extract_engine.py +440 -0
- contextsynapse/extraction/extractors/__init__.py +37 -0
- contextsynapse/extraction/extractors/chat_export_extractor.py +189 -0
- contextsynapse/extraction/extractors/csv_extractor.py +83 -0
- contextsynapse/extraction/extractors/docx_extractor.py +129 -0
- contextsynapse/extraction/extractors/excel_extractor.py +152 -0
- contextsynapse/extraction/extractors/html_extractor.py +146 -0
- contextsynapse/extraction/extractors/pdf_extractor.py +635 -0
- contextsynapse/extraction/extractors/pdf_extractor_layoutparser.py +408 -0
- contextsynapse/extraction/extractors/register_extractors.py +63 -0
- contextsynapse/extraction/extractors/text_extractor.py +65 -0
- contextsynapse/extraction/extractors/txt_extractor.py +120 -0
- contextsynapse/extraction/extractors/website_extractor.py +246 -0
- contextsynapse/extraction/fact_extractor.py +236 -0
- contextsynapse/extraction/file_manager.py +353 -0
- contextsynapse/extraction/hierarchy.py +239 -0
- contextsynapse/extraction/id_generator.py +450 -0
- contextsynapse/extraction/layout_detector.py +409 -0
- contextsynapse/extraction/llm_entity_extractor.py +301 -0
- contextsynapse/extraction/normalized_store.py +480 -0
- contextsynapse/extraction/normalizer.py +594 -0
- contextsynapse/extraction/parquet_writer.py +598 -0
- contextsynapse/extraction/post_processors/__init__.py +40 -0
- contextsynapse/extraction/post_processors/column_reorganizer.py +507 -0
- contextsynapse/extraction/ray_normalization.py +233 -0
- contextsynapse/extraction/ray_runner.py +207 -0
- contextsynapse/extraction/redis_schema_registry.py +222 -0
- contextsynapse/extraction/registry.py +204 -0
- contextsynapse/extraction/schema_loader.py +663 -0
- contextsynapse/extraction/schema_registry.py +230 -0
- contextsynapse/extraction/semantic_normalizer.py +245 -0
- contextsynapse/extraction/version_manager.py +314 -0
- contextsynapse/gateway/__init__.py +24 -0
- contextsynapse/gateway/action_emitter.py +212 -0
- contextsynapse/gateway/cost_tracker.py +508 -0
- contextsynapse/gateway/gateway.py +377 -0
- contextsynapse/gateway/policy.py +303 -0
- contextsynapse/governance/__init__.py +13 -0
- contextsynapse/governance/layer.py +513 -0
- contextsynapse/ingestion/__init__.py +15 -0
- contextsynapse/ingestion/amplifier.py +288 -0
- contextsynapse/ingestion/async_ingest.py +463 -0
- contextsynapse/ingestion/chunker.py +303 -0
- contextsynapse/ingestion/chunking.py +58 -0
- contextsynapse/ingestion/cleaner.py +190 -0
- contextsynapse/ingestion/cleanse.py +252 -0
- contextsynapse/ingestion/connectors/__init__.py +38 -0
- contextsynapse/ingestion/connectors/base.py +300 -0
- contextsynapse/ingestion/connectors/chatgpt_memory.py +247 -0
- contextsynapse/ingestion/connectors/claude_memory.py +274 -0
- contextsynapse/ingestion/connectors/sap_ingestor.py +208 -0
- contextsynapse/ingestion/content_detector.py +80 -0
- contextsynapse/ingestion/content_monitor.py +502 -0
- contextsynapse/ingestion/dedup.py +106 -0
- contextsynapse/ingestion/feed.py +640 -0
- contextsynapse/ingestion/filters.py +461 -0
- contextsynapse/ingestion/graph_builder.py +705 -0
- contextsynapse/ingestion/input_classifier.py +307 -0
- contextsynapse/ingestion/job_manager.py +571 -0
- contextsynapse/ingestion/llm_extractor.py +610 -0
- contextsynapse/ingestion/orchestrator.py +116 -0
- contextsynapse/ingestion/parsers/__init__.py +19 -0
- contextsynapse/ingestion/parsers/graph_parser_registry.py +103 -0
- contextsynapse/ingestion/parsers/graphml_parser.py +141 -0
- contextsynapse/ingestion/parsers/jsonld_parser.py +171 -0
- contextsynapse/ingestion/parsers/rdf_parser.py +150 -0
- contextsynapse/ingestion/pipeline_context.py +228 -0
- contextsynapse/ingestion/pipeline_store.py +1195 -0
- contextsynapse/ingestion/queue.py +133 -0
- contextsynapse/ingestion/reprocess.py +179 -0
- contextsynapse/ingestion/scenario_router.py +224 -0
- contextsynapse/ingestion/schema_extractor.py +759 -0
- contextsynapse/ingestion/schema_validator.py +274 -0
- contextsynapse/ingestion/sdlc_ingest.py +87 -0
- contextsynapse/ingestion/smart_ingest.py +2451 -0
- contextsynapse/ingestion/source_connector.py +171 -0
- contextsynapse/ingestion/stage_executor.py +2095 -0
- contextsynapse/ingestion/stages/__init__.py +9 -0
- contextsynapse/ingestion/stages/tabular_to_graph.py +289 -0
- contextsynapse/ingestion/strategies.py +386 -0
- contextsynapse/ingestion/universal/__init__.py +4 -0
- contextsynapse/ingestion/universal/_operator_registry.py +59 -0
- contextsynapse/ingestion/universal/ingest_content.py +32 -0
- contextsynapse/ingestion/universal/operators/__init__.py +1 -0
- contextsynapse/ingestion/universal/operators/base.py +19 -0
- contextsynapse/ingestion/universal/operators/build_edges.py +75 -0
- contextsynapse/ingestion/universal/operators/cluster_topics.py +397 -0
- contextsynapse/ingestion/universal/operators/deduplicate.py +45 -0
- contextsynapse/ingestion/universal/operators/detect_signals.py +90 -0
- contextsynapse/ingestion/universal/operators/embed.py +80 -0
- contextsynapse/ingestion/universal/operators/extract_entities.py +253 -0
- contextsynapse/ingestion/universal/operators/extract_preferences.py +117 -0
- contextsynapse/ingestion/universal/operators/filter_content.py +69 -0
- contextsynapse/ingestion/universal/operators/index_bm25.py +52 -0
- contextsynapse/ingestion/universal/operators/infer_domains.py +69 -0
- contextsynapse/ingestion/universal/operators/link_cross_reference.py +210 -0
- contextsynapse/ingestion/universal/operators/parse_records.py +66 -0
- contextsynapse/ingestion/universal/operators/resolve_entities.py +261 -0
- contextsynapse/ingestion/universal/operators/scanners/__init__.py +16 -0
- contextsynapse/ingestion/universal/operators/scanners/edges.py +173 -0
- contextsynapse/ingestion/universal/operators/scanners/git.py +187 -0
- contextsynapse/ingestion/universal/operators/scanners/github.py +135 -0
- contextsynapse/ingestion/universal/operators/scanners/github_api.py +509 -0
- contextsynapse/ingestion/universal/operators/scanners/helpers.py +67 -0
- contextsynapse/ingestion/universal/operators/scanners/jira.py +65 -0
- contextsynapse/ingestion/universal/operators/scanners/llm_enrichment.py +82 -0
- contextsynapse/ingestion/universal/operators/scanners/repo.py +149 -0
- contextsynapse/ingestion/universal/operators/sdlc_scan.py +213 -0
- contextsynapse/ingestion/universal/operators/spec_scanner.py +149 -0
- contextsynapse/ingestion/universal/operators/store_documents.py +72 -0
- contextsynapse/ingestion/universal/operators/synthesize_cu.py +180 -0
- contextsynapse/ingestion/universal/operators/validate_gate.py +65 -0
- contextsynapse/ingestion/universal/parsers/__init__.py +5 -0
- contextsynapse/ingestion/universal/parsers/record_parser.py +203 -0
- contextsynapse/ingestion/universal/parsers/turn_parser.py +329 -0
- contextsynapse/ingestion/universal/shared_signals.py +161 -0
- contextsynapse/ingestion/universal/stage_executor.py +219 -0
- contextsynapse/ingestion/web_crawler.py +265 -0
- contextsynapse/intelligence/__init__.py +53 -0
- contextsynapse/intelligence/alerts.py +198 -0
- contextsynapse/intelligence/collector.py +655 -0
- contextsynapse/intelligence/comparison.py +198 -0
- contextsynapse/intelligence/config.py +56 -0
- contextsynapse/intelligence/conflict_detector.py +182 -0
- contextsynapse/intelligence/context_gaps.py +192 -0
- contextsynapse/intelligence/context_radar.py +135 -0
- contextsynapse/intelligence/correlation_engine.py +416 -0
- contextsynapse/intelligence/correlation_template.py +120 -0
- contextsynapse/intelligence/dedup.py +296 -0
- contextsynapse/intelligence/event_bus.py +91 -0
- contextsynapse/intelligence/feedback_loop.py +101 -0
- contextsynapse/intelligence/freshness.py +307 -0
- contextsynapse/intelligence/fundamental_feed.py +551 -0
- contextsynapse/intelligence/geo_data.py +170 -0
- contextsynapse/intelligence/geo_reference.py +112 -0
- contextsynapse/intelligence/graph_fusion.py +465 -0
- contextsynapse/intelligence/heuristics.py +176 -0
- contextsynapse/intelligence/impact_tracker.py +336 -0
- contextsynapse/intelligence/macro_indicators.py +319 -0
- contextsynapse/intelligence/ocr.py +104 -0
- contextsynapse/intelligence/persistence.py +267 -0
- contextsynapse/intelligence/pipeline_health.py +130 -0
- contextsynapse/intelligence/price_feed.py +221 -0
- contextsynapse/intelligence/rate_limiter.py +130 -0
- contextsynapse/intelligence/reactive.py +411 -0
- contextsynapse/intelligence/runtime_context.py +390 -0
- contextsynapse/intelligence/sentiment_decay.py +426 -0
- contextsynapse/intelligence/session.py +277 -0
- contextsynapse/intelligence/signal_hierarchy.py +438 -0
- contextsynapse/intelligence/signals.py +185 -0
- contextsynapse/intelligence/source_watcher.py +132 -0
- contextsynapse/intelligence/table_enricher.py +256 -0
- contextsynapse/intelligence/tagger.py +319 -0
- contextsynapse/intelligence/timeseries.py +209 -0
- contextsynapse/intelligence/tracker.py +318 -0
- contextsynapse/intelligence/watchdog.py +392 -0
- contextsynapse/intelligence/watchdog_manager.py +263 -0
- contextsynapse/intelligence/webhook_receiver.py +165 -0
- contextsynapse/intelligence/weight_learner.py +234 -0
- contextsynapse/llm/__init__.py +8 -0
- contextsynapse/llm/client.py +348 -0
- contextsynapse/llm/rate_limiter.py +166 -0
- contextsynapse/logging_config.py +2 -0
- contextsynapse/marketplace/__init__.py +7 -0
- contextsynapse/marketplace/registry.py +173 -0
- contextsynapse/mcp/__init__.py +11 -0
- contextsynapse/mcp/__main__.py +4 -0
- contextsynapse/mcp/auth_middleware.py +212 -0
- contextsynapse/mcp/connection_pool.py +128 -0
- contextsynapse/mcp/server.py +986 -0
- contextsynapse/mcp/session_context.py +67 -0
- contextsynapse/memory/__init__.py +34 -0
- contextsynapse/memory/engine.py +475 -0
- contextsynapse/memory/temporal.py +327 -0
- contextsynapse/metadata/__init__.py +12 -0
- contextsynapse/metadata/metadata_db.py +272 -0
- contextsynapse/metadata/metadata_query_tool.py +300 -0
- contextsynapse/metadata/metadata_tracker.py +425 -0
- contextsynapse/models/__init__.py +27 -0
- contextsynapse/models/embedding_service.py +360 -0
- contextsynapse/models/model_registry.py +228 -0
- contextsynapse/multiworker.py +2 -0
- contextsynapse/pipelines/__init__.py +1 -0
- contextsynapse/pipelines/executor.py +851 -0
- contextsynapse/pipelines/filters.py +189 -0
- contextsynapse/pipelines/models.py +176 -0
- contextsynapse/pipelines/scheduler.py +268 -0
- contextsynapse/playground/__init__.py +1 -0
- contextsynapse/playground/templates.py +85 -0
- contextsynapse/plugins/__init__.py +43 -0
- contextsynapse/plugins/api.py +66 -0
- contextsynapse/plugins/base.py +350 -0
- contextsynapse/plugins/domain_interface.py +508 -0
- contextsynapse/plugins/domain_loader.py +241 -0
- contextsynapse/plugins/loader.py +148 -0
- contextsynapse/plugins/registry.py +265 -0
- contextsynapse/project/__init__.py +11 -0
- contextsynapse/project/code_context.py +807 -0
- contextsynapse/project/connectors/__init__.py +4 -0
- contextsynapse/project/connectors/github_connector.py +113 -0
- contextsynapse/project/connectors/jira_connector.py +160 -0
- contextsynapse/project/graph.py +1023 -0
- contextsynapse/project/project_context.py +545 -0
- contextsynapse/project/scanner_registry.py +61 -0
- contextsynapse/project/schema_manager.py +322 -0
- contextsynapse/project/schemas/knowledge.yaml +59 -0
- contextsynapse/project/schemas/sdlc.yaml +369 -0
- contextsynapse/project/sdlc_schema.py +172 -0
- contextsynapse/project/spec_parser.py +85 -0
- contextsynapse/project/task_lock.py +181 -0
- contextsynapse/project/task_stream.py +203 -0
- contextsynapse/project/team_tools.py +537 -0
- contextsynapse/py.typed +0 -0
- contextsynapse/realtime/__init__.py +6 -0
- contextsynapse/realtime/collaboration.py +147 -0
- contextsynapse/rules/__init__.py +10 -0
- contextsynapse/rules/engine.py +116 -0
- contextsynapse/rules/evaluators/__init__.py +6 -0
- contextsynapse/rules/evaluators/aggregate.py +205 -0
- contextsynapse/rules/evaluators/custom.py +170 -0
- contextsynapse/rules/evaluators/pre_action.py +125 -0
- contextsynapse/rules/evaluators/temporal.py +129 -0
- contextsynapse/rules/loader.py +52 -0
- contextsynapse/rules/models.py +124 -0
- contextsynapse/rules/universal.py +393 -0
- contextsynapse/scheduler.py +229 -0
- contextsynapse/schema/__init__.py +42 -0
- contextsynapse/schema/compiler.py +252 -0
- contextsynapse/schema/composer.py +158 -0
- contextsynapse/schema/dedup.py +73 -0
- contextsynapse/schema/derivation.py +172 -0
- contextsynapse/schema/sdl.py +326 -0
- contextsynapse/schema/validation_gate.py +124 -0
- contextsynapse/sdk/__init__.py +63 -0
- contextsynapse/sdk/agent.py +214 -0
- contextsynapse/sdk/client.py +269 -0
- contextsynapse/sdk/exceptions.py +23 -0
- contextsynapse/sdk/models.py +78 -0
- contextsynapse/sdk/session.py +408 -0
- contextsynapse/sdk/tracked.py +218 -0
- contextsynapse/sdk/worker.py +266 -0
- contextsynapse/sdk/workspace_client.py +98 -0
- contextsynapse/sdk/ws.py +41 -0
- contextsynapse/search/__init__.py +20 -0
- contextsynapse/search/embedding_cache.py +140 -0
- contextsynapse/search/enhanced_search.py +152 -0
- contextsynapse/search/fulltext.py +130 -0
- contextsynapse/search/graph_search.py +634 -0
- contextsynapse/search/lmdb_index.py +1218 -0
- contextsynapse/search/nl_to_aiql.py +199 -0
- contextsynapse/search/rag.py +1346 -0
- contextsynapse/search/rag_cache.py +167 -0
- contextsynapse/search/reasoning_chain.py +231 -0
- contextsynapse/search/redis_search.py +207 -0
- contextsynapse/search/retrieval_quality.py +314 -0
- contextsynapse/search/semantic_query.py +455 -0
- contextsynapse/search/text_resolver.py +159 -0
- contextsynapse/search/whoosh_search.py +373 -0
- contextsynapse/security/__init__.py +17 -0
- contextsynapse/security/audit.py +297 -0
- contextsynapse/security/audit_logger.py +97 -0
- contextsynapse/security/audit_trail.py +270 -0
- contextsynapse/security/auth_unified.py +284 -0
- contextsynapse/security/auto_tagger.py +230 -0
- contextsynapse/security/data_security.py +218 -0
- contextsynapse/security/encryption.py +207 -0
- contextsynapse/security/identity.py +447 -0
- contextsynapse/security/jwt_identity.py +59 -0
- contextsynapse/security/middleware.py +336 -0
- contextsynapse/security/pii.py +233 -0
- contextsynapse/security/rbac.py +96 -0
- contextsynapse/security/rls.py +205 -0
- contextsynapse/security/sanitize.py +233 -0
- contextsynapse/security/scoped_encryption.py +131 -0
- contextsynapse/security/tenant.py +401 -0
- contextsynapse/shield/__init__.py +21 -0
- contextsynapse/shield/anomaly.py +56 -0
- contextsynapse/shield/permissions.py +99 -0
- contextsynapse/shield/profile.py +103 -0
- contextsynapse/shield/shield.py +108 -0
- contextsynapse/shield/trust_engine.py +69 -0
- contextsynapse/skills/__init__.py +14 -0
- contextsynapse/skills/engine.py +233 -0
- contextsynapse/skills/loader.py +59 -0
- contextsynapse/skills/models.py +139 -0
- contextsynapse/storage/__init__.py +7 -0
- contextsynapse/storage/cache.py +208 -0
- contextsynapse/storage/columnar_store_v2.py +178 -0
- contextsynapse/storage/csr_graph_storage.py +587 -0
- contextsynapse/storage/csr_store.py +388 -0
- contextsynapse/storage/document_store.py +491 -0
- contextsynapse/storage/hnsw_index.py +294 -0
- contextsynapse/storage/hybrid_store_v2.py +278 -0
- contextsynapse/storage/lmdb_graph_storage.py +366 -0
- contextsynapse/storage/migration.py +279 -0
- contextsynapse/storage/namespace_store.py +346 -0
- contextsynapse/storage/pure_graph_storage.py +185 -0
- contextsynapse/storage/redis_graph_adapter.py +186 -0
- contextsynapse/storage/redis_graph_storage.py +375 -0
- contextsynapse/storage/router/__init__.py +29 -0
- contextsynapse/storage/router/duckdb_store.py +398 -0
- contextsynapse/storage/router/factory.py +83 -0
- contextsynapse/storage/router/interface.py +125 -0
- contextsynapse/storage/router/postgres_store.py +339 -0
- contextsynapse/storage/router/resolver.py +192 -0
- contextsynapse/storage/router/router.py +300 -0
- contextsynapse/storage/single_file_storage.py +391 -0
- contextsynapse/storage/storage_manager.py +214 -0
- contextsynapse/storage/storage_query_optimizer.py +314 -0
- contextsynapse/storage/wal.py +359 -0
- contextsynapse/temporal/__init__.py +0 -0
- contextsynapse/temporal/storage.py +106 -0
- contextsynapse/tests/__init__.py +11 -0
- contextsynapse/tests/regression/__init__.py +1 -0
- contextsynapse/tests/regression/add_metadata.py +395 -0
- contextsynapse/tests/regression/add_skip_flags.py +85 -0
- contextsynapse/tests/regression/cases/test_basic_create_node.yaml +20 -0
- contextsynapse/tests/regression/cases/test_basic_select.yaml +21 -0
- contextsynapse/tests/regression/cases/test_blockchain_audit_trail.yaml +37 -0
- contextsynapse/tests/regression/cases/test_blockchain_audit_trail_filtered.yaml +39 -0
- contextsynapse/tests/regression/cases/test_blockchain_blocks_range.yaml +39 -0
- contextsynapse/tests/regression/cases/test_blockchain_get_block.yaml +35 -0
- contextsynapse/tests/regression/cases/test_blockchain_latest_block.yaml +35 -0
- contextsynapse/tests/regression/cases/test_blockchain_length.yaml +37 -0
- contextsynapse/tests/regression/cases/test_blockchain_merkle_root.yaml +37 -0
- contextsynapse/tests/regression/cases/test_blockchain_verify.yaml +35 -0
- contextsynapse/tests/regression/cases/test_blockchain_verify_block.yaml +35 -0
- contextsynapse/tests/regression/cases/test_create_edge.yaml +28 -0
- contextsynapse/tests/regression/cases/test_delete_edge_basic.yaml +29 -0
- contextsynapse/tests/regression/cases/test_delete_node_basic.yaml +29 -0
- contextsynapse/tests/regression/cases/test_evaluation_mrr.yaml +40 -0
- contextsynapse/tests/regression/cases/test_evaluation_ndcg.yaml +40 -0
- contextsynapse/tests/regression/cases/test_evaluation_precision.yaml +40 -0
- contextsynapse/tests/regression/cases/test_evaluation_recall.yaml +40 -0
- contextsynapse/tests/regression/cases/test_group_by_basic.yaml +56 -0
- contextsynapse/tests/regression/cases/test_match_node_basic.yaml +29 -0
- contextsynapse/tests/regression/cases/test_match_node_with_order_limit.yaml +31 -0
- contextsynapse/tests/regression/cases/test_namespace_switch.yaml +18 -0
- contextsynapse/tests/regression/cases/test_pipeline_cascaded.yaml +61 -0
- contextsynapse/tests/regression/cases/test_pipeline_fixed_size_chunking.yaml +48 -0
- contextsynapse/tests/regression/cases/test_pipeline_gpt4_chunking.yaml +54 -0
- contextsynapse/tests/regression/cases/test_pipeline_hybrid_indexing.yaml +57 -0
- contextsynapse/tests/regression/cases/test_pipeline_large_embedding.yaml +52 -0
- contextsynapse/tests/regression/cases/test_pipeline_paragraph_chunking.yaml +49 -0
- contextsynapse/tests/regression/cases/test_pipeline_recursive_chunking.yaml +47 -0
- contextsynapse/tests/regression/cases/test_pipeline_run_pipeline.yaml +56 -0
- contextsynapse/tests/regression/cases/test_pipeline_section_based_chunking.yaml +53 -0
- contextsynapse/tests/regression/cases/test_pipeline_semantic_chunking.yaml +51 -0
- contextsynapse/tests/regression/cases/test_pipeline_with_entity_extraction.yaml +57 -0
- contextsynapse/tests/regression/cases/test_pipeline_with_relationships.yaml +62 -0
- contextsynapse/tests/regression/cases/test_rag_evaluation.yaml +38 -0
- contextsynapse/tests/regression/cases/test_rag_graph_bfs_with_eval.yaml +48 -0
- contextsynapse/tests/regression/cases/test_rag_graph_centrality.yaml +40 -0
- contextsynapse/tests/regression/cases/test_rag_graph_centrality_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_graph_community.yaml +40 -0
- contextsynapse/tests/regression/cases/test_rag_graph_community_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_graph_dfs_with_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_graph_multi_hop_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_graph_path.yaml +40 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_basic.yaml +38 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_bfs.yaml +52 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_dfs.yaml +41 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_multi_hop.yaml +43 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_shortest_path.yaml +41 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_weighted.yaml +43 -0
- contextsynapse/tests/regression/cases/test_rag_graph_shortest_path_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_graph_traversal.yaml +30 -0
- contextsynapse/tests/regression/cases/test_rag_graph_weighted_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_hybrid_search.yaml +33 -0
- contextsynapse/tests/regression/cases/test_rag_hybrid_with_prompt_embedding.yaml +44 -0
- contextsynapse/tests/regression/cases/test_rag_keyword_search.yaml +32 -0
- contextsynapse/tests/regression/cases/test_rag_multi_hop_graph.yaml +32 -0
- contextsynapse/tests/regression/cases/test_rag_path_based.yaml +34 -0
- contextsynapse/tests/regression/cases/test_rag_profile_based.yaml +32 -0
- contextsynapse/tests/regression/cases/test_rag_vector_search.yaml +32 -0
- contextsynapse/tests/regression/cases/test_rag_weighted_graph.yaml +34 -0
- contextsynapse/tests/regression/cases/test_rag_weighted_hybrid.yaml +31 -0
- contextsynapse/tests/regression/cases/test_semantic_boundary_chunking.yaml +57 -0
- contextsynapse/tests/regression/cases/test_semantic_boundary_detection.yaml +33 -0
- contextsynapse/tests/regression/cases/test_semantic_hash_function.yaml +30 -0
- contextsynapse/tests/regression/cases/test_semantic_hash_with_model.yaml +31 -0
- contextsynapse/tests/regression/cases/test_tcs_ingestion_fixed_size.yaml +44 -0
- contextsynapse/tests/regression/cases/test_tcs_ingestion_recursive.yaml +46 -0
- contextsynapse/tests/regression/cases/test_tcs_ingestion_section.yaml +46 -0
- contextsynapse/tests/regression/cases/test_tcs_ingestion_semantic.yaml +44 -0
- contextsynapse/tests/regression/cases/test_time_travel_as_of.yaml +35 -0
- contextsynapse/tests/regression/cases/test_time_travel_at_commit.yaml +33 -0
- contextsynapse/tests/regression/cases/test_time_travel_at_timestamp.yaml +33 -0
- contextsynapse/tests/regression/cases/test_time_travel_for_system_time_all.yaml +37 -0
- contextsynapse/tests/regression/cases/test_time_travel_versions_between.yaml +39 -0
- contextsynapse/tests/regression/cases/test_traverse_basic.yaml +31 -0
- contextsynapse/tests/regression/cases/test_traverse_max_depth.yaml +34 -0
- contextsynapse/tests/regression/cases/test_update_edge_basic.yaml +29 -0
- contextsynapse/tests/regression/evaluation_metrics.py +227 -0
- contextsynapse/tests/regression/regression_runner.py +1081 -0
- contextsynapse/tests/regression/setup_regression_data.py +212 -0
- contextsynapse/tests/regression/test_basic_only.py +84 -0
- contextsynapse/tests/regression/test_namespace_creation.py +29 -0
- contextsynapse/tests/regression/test_single_fix.py +61 -0
- contextsynapse/tests/regression/test_single_query.py +20 -0
- contextsynapse/tests/regression/validate_test_syntax.py +179 -0
- contextsynapse/tests/test_advanced_features.py +347 -0
- contextsynapse/tests/test_aiql_summary.py +283 -0
- contextsynapse/tests/test_all_aiql_queries.py +948 -0
- contextsynapse/tests/test_all_create_queries.py +213 -0
- contextsynapse/tests/test_api_vs_native.py +280 -0
- contextsynapse/tests/test_chunking_dedup.py +199 -0
- contextsynapse/tests/test_connectors.py +171 -0
- contextsynapse/tests/test_edges_and_match.py +202 -0
- contextsynapse/tests/test_extraction_pipeline_integration.py +581 -0
- contextsynapse/tests/test_name_property.py +224 -0
- contextsynapse/tests/test_node_edge_metadata.py +250 -0
- contextsynapse/tests/test_playground_conn.py +114 -0
- contextsynapse/tests/test_query_cache.py +213 -0
- contextsynapse/tests/test_source_policy_auth.py +348 -0
- contextsynapse/tests/test_temporal_and_domain.py +224 -0
- contextsynapse/tests/test_time_travel_e2e.py +571 -0
- contextsynapse/tests/test_traversal_and_aggregation.py +275 -0
- contextsynapse/tools/__init__.py +36 -0
- contextsynapse/tools/a2a_tools.py +106 -0
- contextsynapse/tools/cognition_tools.py +118 -0
- contextsynapse/tools/context.py +905 -0
- contextsynapse/tools/formatting.py +92 -0
- contextsynapse/tools/gateway_tools.py +186 -0
- contextsynapse/tools/graph.py +1700 -0
- contextsynapse/tools/intelligence.py +235 -0
- contextsynapse/tools/memory.py +118 -0
- contextsynapse/tools/registry.py +373 -0
- contextsynapse/tools/shield_tools.py +159 -0
- contextsynapse/tools/tasks.py +341 -0
- contextsynapse/tools/workspace_tools.py +124 -0
- contextsynapse/utils/__init__.py +15 -0
- contextsynapse/utils/config_loader.py +198 -0
- contextsynapse/utils/env_loader.py +156 -0
- contextsynapse/utils/file_utils.py +288 -0
- contextsynapse/utils/logging_optimizer.py +119 -0
- contextsynapse/vector/__init__.py +30 -0
- contextsynapse/vector/chroma_vector_store.py +152 -0
- contextsynapse/vector/custom_vector_store.py +537 -0
- contextsynapse/vector/faiss_vector_store.py +296 -0
- contextsynapse/vector/qdrant_vector_store.py +163 -0
- contextsynapse/vector/vector_db.py +953 -0
- contextsynapse/vector/vector_db_manager.py +197 -0
- contextsynapse/workspace/__init__.py +27 -0
- contextsynapse/workspace/base.py +94 -0
- contextsynapse/workspace/git.py +228 -0
- contextsynapse/workspace/github.py +78 -0
- contextsynapse/workspace/local.py +73 -0
- contextsynapse/workspace/tools.py +222 -0
- contextsynapse-1.0.0.dist-info/METADATA +847 -0
- contextsynapse-1.0.0.dist-info/RECORD +776 -0
- contextsynapse-1.0.0.dist-info/WHEEL +5 -0
- contextsynapse-1.0.0.dist-info/entry_points.txt +4 -0
- contextsynapse-1.0.0.dist-info/licenses/LICENSE +200 -0
- contextsynapse-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1822 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AIQL (Quantum Graph Query Language) - EBNF Grammar Definition
|
|
3
|
+
A declarative, SQL-inspired but graph-native query language designed for both:
|
|
4
|
+
1. Pure graph querying and analytics
|
|
5
|
+
2. Hybrid Graph + RAG (retrieval-augmented) search
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# AIQL EBNF Grammar - Lark/PEG Compatible
|
|
9
|
+
|
|
10
|
+
AIQL_GRAMMAR = """
|
|
11
|
+
// AIQL Grammar Definition - Comprehensive Quantum Graph Query Language
|
|
12
|
+
// Supports variable declarations, graph operations, traversal, retrieval, analytics, and generation
|
|
13
|
+
|
|
14
|
+
// Main entry point - Support both unified and legacy queries
|
|
15
|
+
// Order matters! More specific rules first
|
|
16
|
+
start: (top_level_statement) (";" top_level_statement)* (";")?
|
|
17
|
+
|
|
18
|
+
// Top-level statements (standalone, not within pipelines)
|
|
19
|
+
// Separate names to avoid reduce/reduce with pipeline stages
|
|
20
|
+
// Priority: More specific queries first to avoid ambiguity
|
|
21
|
+
?top_level_statement: top_select | top_match | top_update_node | top_delete_node | top_update_edge | top_delete_edge
|
|
22
|
+
| top_create_graph | top_create_graph_as | top_create_graph_with_structure | top_create_graph_from_schema | top_create_node | top_create_edge | top_drop_graph
|
|
23
|
+
| top_create_namespace | top_use_namespace | top_use_graph | top_show_namespaces | top_show_collections | top_show_pipelines | top_show_graphs | top_show_current_graph | top_show_stats
|
|
24
|
+
| top_create_index | top_show_indexes | top_describe
|
|
25
|
+
| top_pagerank | top_hop_query | top_shortest_path | top_community_detection | top_graph_summary
|
|
26
|
+
| top_create_collection | top_use_collection | top_traverse | top_merge_node
|
|
27
|
+
| top_neighbors | top_create_subgraph | top_find_by_uuid
|
|
28
|
+
| create_pipeline | retrieval_pipeline | run_pipeline_cmd | classify_file_cmd | simple_rag_query | rag_generate | rag_query_one_shot
|
|
29
|
+
| pipeline | hybrid_search | search_query | search_query_basic | search_query_collections | graph_search_query | graph_search_from_via_to | aggregate_query | set_mode_statement
|
|
30
|
+
| variable_decl | insert_into | evaluate_rag | update_pipeline | for_loop
|
|
31
|
+
| session_statement | create_function | use_function | agent_statement | memory_statement | operational_statement
|
|
32
|
+
| top_diff_node | top_diff_edges
|
|
33
|
+
| top_read_url | top_read_domain | top_extract_from_raw | top_extract_entities
|
|
34
|
+
| top_create_evalset | top_abtest_rag | top_attach_policy | top_set_guardrails
|
|
35
|
+
| top_pre_guard | top_post_guard | top_create_fine_tune_dataset | top_fine_tune_model
|
|
36
|
+
| top_register_model | top_promote_model | top_rollback_model | top_merge_results | top_rerank | top_reason
|
|
37
|
+
| top_blockchain_verify | top_blockchain_block | top_blockchain_length | top_blockchain_latest
|
|
38
|
+
| top_blockchain_audit | top_blockchain_merkle | top_blockchain_blocks_range | top_blockchain_verify_block
|
|
39
|
+
| top_begin_transaction | top_commit_transaction | top_rollback_transaction
|
|
40
|
+
|
|
41
|
+
// Top-level SELECT (standalone version with aggregation support)
|
|
42
|
+
// Support both: SELECT * FROM Person AND SELECT NODE Person
|
|
43
|
+
top_select: "SELECT" select_target ("AS" identifier)? ("FROM" (node_spec | variable))? (as_of_clause | for_system_time)? ("USE" "INDEX" identifier)? ("WHERE" condition)? ("GROUP" "BY" qualified_identifier_list)? ("ORDER" "BY" order_by_clause)? ("LIMIT" (number | variable))? ("OFFSET" (number | variable))?
|
|
44
|
+
| "SELECT" "NODE" identifier (traverse_path)? ("WHERE" condition)? ("LIMIT" (number | variable))? ("OFFSET" (number | variable))?
|
|
45
|
+
| "SELECT" "EDGE" ("WHERE" condition)? ("LIMIT" (number | variable))? ("OFFSET" (number | variable))?
|
|
46
|
+
select_target: select_item ("," select_item)*
|
|
47
|
+
select_item: aggregation_function ("AS" identifier)? | qualified_identifier ("AS" identifier)? | "*" | "DISTINCT" qualified_identifier ("AS" identifier)?
|
|
48
|
+
qualified_identifier_list: qualified_identifier ("," qualified_identifier)*
|
|
49
|
+
traverse_path: ("->" identifier)+
|
|
50
|
+
|
|
51
|
+
// Top-level MATCH (standalone version)
|
|
52
|
+
top_match: "MATCH" match_pattern (return_clause)? ("ORDER" "BY" order_by_clause)? ("LIMIT" (number | variable))? ("OFFSET" (number | variable))?
|
|
53
|
+
| "MATCH" "NODE" identifier ("AS" identifier)? ("WHERE" condition)? (return_clause)? ("ORDER" "BY" order_by_clause)? ("LIMIT" (number | variable))? ("OFFSET" (number | variable))?
|
|
54
|
+
match_pattern: match_path ("WHERE" condition)?
|
|
55
|
+
match_path: match_node (match_edge_arrow match_node)+
|
|
56
|
+
match_node: "(" identifier (":" identifier)? ("AS" identifier)? ("{" property_list "}")? ")"
|
|
57
|
+
match_edge: "[" (identifier ":")? ":"? identifier ("|" identifier)* ("*" (number ".." number)?)? ("AS" identifier)? ("{" property_list "}")? "]"
|
|
58
|
+
match_edge_arrow: "-" match_edge "->" | "<-" match_edge "-" | "-" match_edge "-"
|
|
59
|
+
|
|
60
|
+
// Top-level DELETE (standalone version)
|
|
61
|
+
top_delete_node: "DELETE" "ALL" "NODES" ("WHERE" condition)? | "DELETE" "NODE" node_spec ("WHERE" condition)?
|
|
62
|
+
|
|
63
|
+
// Top-level MERGE NODE
|
|
64
|
+
top_merge_node: "MERGE" "NODE" node_spec ("SET" "{" update_assignment_list "}")?
|
|
65
|
+
|
|
66
|
+
// Top-level Transaction Control (like Neo4j)
|
|
67
|
+
top_begin_transaction: "BEGIN" "TRANSACTION" | "BEGIN"
|
|
68
|
+
top_commit_transaction: "COMMIT" "TRANSACTION" | "COMMIT"
|
|
69
|
+
top_rollback_transaction: "ROLLBACK" "TRANSACTION" | "ROLLBACK"
|
|
70
|
+
|
|
71
|
+
// Top-level CREATE NAMESPACE (standalone version) - with optional MODE clause
|
|
72
|
+
top_create_namespace: "CREATE" "NAMESPACE" identifier ("MODE" namespace_mode)?
|
|
73
|
+
namespace_mode: "INTERACTIVE" | "PERSISTENT"
|
|
74
|
+
|
|
75
|
+
// Top-level USE NAMESPACE (standalone version) - with optional MODE clause
|
|
76
|
+
top_use_namespace: "USE" "NAMESPACE" identifier ("MODE" namespace_mode)?
|
|
77
|
+
|
|
78
|
+
// Top-level USE GRAPH (standalone version)
|
|
79
|
+
top_use_graph: "USE" "GRAPH" identifier
|
|
80
|
+
|
|
81
|
+
// Top-level SHOW NAMESPACES (standalone version)
|
|
82
|
+
top_show_namespaces: "SHOW" "NAMESPACES"
|
|
83
|
+
|
|
84
|
+
// Top-level SHOW GRAPHS (standalone version)
|
|
85
|
+
top_show_graphs: "SHOW" "GRAPHS"
|
|
86
|
+
|
|
87
|
+
// Top-level SHOW CURRENT GRAPH (standalone version)
|
|
88
|
+
top_show_current_graph: "SHOW" "CURRENT" "GRAPH"
|
|
89
|
+
|
|
90
|
+
// Top-level SHOW COLLECTIONS (standalone version)
|
|
91
|
+
top_show_collections: "SHOW" "COLLECTIONS"
|
|
92
|
+
|
|
93
|
+
// Top-level SHOW PIPELINES (standalone version)
|
|
94
|
+
top_show_pipelines: "SHOW" "PIPELINES"
|
|
95
|
+
|
|
96
|
+
// Top-level CREATE INDEX (standalone version)
|
|
97
|
+
top_create_index: "CREATE" "INDEX" identifier "ON" identifier "(" identifier_list ")" "TYPE" index_type ("MODEL" "=" (string | variable))?
|
|
98
|
+
|
|
99
|
+
// Top-level SHOW INDEXES (standalone version)
|
|
100
|
+
top_show_indexes: "SHOW" "INDEXES" ("IN" "COLLECTION" identifier)?
|
|
101
|
+
|
|
102
|
+
// Top-level SHOW STATS (standalone version)
|
|
103
|
+
top_show_stats: "SHOW" "STATS" | "SHOW" "STATISTICS"
|
|
104
|
+
|
|
105
|
+
// Top-level DESCRIBE (standalone version)
|
|
106
|
+
top_describe: "DESCRIBE" describe_target
|
|
107
|
+
|
|
108
|
+
// Top-level PAGERANK query
|
|
109
|
+
top_pagerank: "PAGERANK" ("ON" identifier)? (("PARAMETERS" "(" parameter_dict ")") | ("ITERATIONS" number)? ("DAMPING_FACTOR" | "DAMPING") number?)? ("RETURN" return_expression ("," return_expression)*)? ("ORDER" "BY" order_by_clause)? ("LIMIT" (number | variable))?
|
|
110
|
+
|
|
111
|
+
// Top-level HOP query
|
|
112
|
+
top_hop_query: "HOP" "FROM" identifier "TO" identifier ("DEPTH" number)?
|
|
113
|
+
|
|
114
|
+
// Top-level SHORTEST PATH query
|
|
115
|
+
top_shortest_path: "SHORTEST_PATH" "FROM" (string | variable | typed_node_ref | identifier) "TO" (string | variable | typed_node_ref | identifier) ("VIA" "EDGES" ("[" (identifier_list | string_list) "]" | "(" (identifier_list | string_list) ")"))? ("MAX_DEPTH" number)? ("WEIGHT_FIELD" identifier)? ("RETURN" return_expression ("," return_expression)*)?
|
|
116
|
+
|
|
117
|
+
// Top-level COMMUNITY DETECTION query
|
|
118
|
+
top_community_detection: "COMMUNITY_DETECTION" ("ON" identifier)? ("USING" "ALGORITHM" (string | identifier))? ("PARAMETERS" "(" parameter_dict ")")? ("RETURN" return_expression ("," return_expression)*)? ("ORDER" "BY" order_by_clause)? ("LIMIT" (number | variable))?
|
|
119
|
+
|
|
120
|
+
// Top-level GRAPH SUMMARY query
|
|
121
|
+
top_graph_summary: "GRAPH" "SUMMARY" ("ON" (identifier | "(" identifier_list ")")?)? ("RETURN" "{" summary_field_list "}")?
|
|
122
|
+
|
|
123
|
+
// Top-level CREATE COLLECTION
|
|
124
|
+
top_create_collection: "CREATE" "COLLECTION" identifier ("{" collection_schema "}")?
|
|
125
|
+
collection_schema: "fields" ":" "[" field_definition ("," field_definition)* "]"
|
|
126
|
+
field_definition: "{" identifier ":" type_spec "}"
|
|
127
|
+
type_spec: "string" | "number" | "float" | "int" | "boolean" | "datetime" | "date" | "time" | "array" | "object"
|
|
128
|
+
|
|
129
|
+
// Top-level USE COLLECTION
|
|
130
|
+
top_use_collection: "USE" "COLLECTION" identifier
|
|
131
|
+
|
|
132
|
+
// INSERT INTO
|
|
133
|
+
insert_into: "INSERT" "INTO" identifier "VALUES" "{" property_list "}"
|
|
134
|
+
|
|
135
|
+
// UPDATE PIPELINE
|
|
136
|
+
update_pipeline: "UPDATE" "PIPELINE" identifier "SET" "{" property_list "}"
|
|
137
|
+
|
|
138
|
+
// FOR loop
|
|
139
|
+
for_loop: "FOR" "each" variable "IN" (variable | top_select) "DO" (top_level_statement | variable_decl)+ "END"
|
|
140
|
+
|
|
141
|
+
// Top-level TRAVERSE
|
|
142
|
+
top_traverse: "TRAVERSE" traverse_spec (where_stage | "WHERE" condition)? return_clause? ("ORDER" "BY" order_by_clause)? ("LIMIT" (number | variable))? (as_of_clause)?
|
|
143
|
+
| "TRAVERSE" "FROM" (identifier | variable) ("WHERE" condition)? ("AT" "TIMESTAMP" (string | variable))? (("VIA" ("(" identifier_list ")" | identifier))? ("TO" identifier)? | ("TO" identifier)? ("VIA" ("(" identifier_list ")" | identifier))?) ("MAX" "DEPTH" number)? ("PARAMETERS" "(" parameter_dict ")")? ("WHERE" condition)? ("ORDER" "BY" order_by_clause)? ("LIMIT" (number | variable))?
|
|
144
|
+
|
|
145
|
+
// Top-level NEIGHBORS
|
|
146
|
+
top_neighbors: "NEIGHBORS" "FROM" node_spec ("WHERE" condition)? ("DEPTH" number)? ("VIA" "(" identifier_list ")")? return_clause? ("LIMIT" (number | variable))?
|
|
147
|
+
|
|
148
|
+
// Top-level FIND BY UUID
|
|
149
|
+
top_find_by_uuid: "FIND_BY_UUID" (string | variable)
|
|
150
|
+
| "FIND" "BY" "UUID" (string | variable)
|
|
151
|
+
|
|
152
|
+
// Top-level CREATE SUBGRAPH
|
|
153
|
+
top_create_subgraph: "CREATE" "SUBGRAPH" identifier "AS" "MATCH" match_pattern return_clause
|
|
154
|
+
|
|
155
|
+
// Web scraping and ingestion
|
|
156
|
+
top_read_url: "READ" "URL" string ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "AS" "RAW" identifier)?
|
|
157
|
+
top_read_domain: "READ" "DOMAIN" string ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "AS" "RAW" identifier)?
|
|
158
|
+
top_extract_from_raw: "EXTRACT" "FROM" "RAW" (identifier | variable) ("AS" extract_target)? ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "AS" node_spec)? ("LINK" link_spec)?
|
|
159
|
+
extract_target: "NODE" "ONLY" "TYPE" identifier | "EDGE" "ONLY" "TYPE" identifier | "NODE" "TYPE" identifier "AND" "EDGE" "TYPE" identifier
|
|
160
|
+
link_spec: "(" node_spec "TO" node_spec ")"
|
|
161
|
+
top_extract_entities: "EXTRACT" "ENTITIES" "FROM" (identifier | "(" identifier_list ")") ("USING" "MODEL" (string | variable) | parameter_dict)? ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "AS" "NODE" "TYPE" identifier)? ("LINK" "TO" identifier "ON" identifier)?
|
|
162
|
+
|
|
163
|
+
// Evaluation
|
|
164
|
+
top_create_evalset: "CREATE" "EVALSET" (identifier | variable) "FROM" "NAMESPACE" (identifier | variable) ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "IN" "COLLECTION" identifier)?
|
|
165
|
+
top_abtest_rag: "ABTEST" "RAG" "ON" (identifier | variable) "VARIANTS" "(" variant_pair ("," variant_pair)* ")" ("PARAMETERS" "(" parameter_dict ")")? ("METRICS" ("[" (identifier | string) ("," (identifier | string))* "]" | "(" (identifier | string) ("," (identifier | string))* ")"))? ("STORE" "IN" "COLLECTION" identifier)?
|
|
166
|
+
variant_pair: identifier ":" (parameter_dict | "{" parameter_dict "}")
|
|
167
|
+
|
|
168
|
+
// Guardrails
|
|
169
|
+
top_attach_policy: "ATTACH" "POLICY" string "TO" ("NAMESPACE" | "PIPELINE") (identifier | variable)
|
|
170
|
+
top_set_guardrails: "SET" "GUARDRAILS" "FOR" ("NAMESPACE" | "PIPELINE") (identifier | variable) "{" parameter_dict "}"
|
|
171
|
+
top_pre_guard: "PRE_GUARD" "CHECK" ("QUERY" | "ANSWER") ("USING" "POLICY" string)? ("ON" string)?
|
|
172
|
+
top_post_guard: "POST_GUARD" "CHECK" ("QUERY" | "ANSWER") ("USING" "POLICY" string)? ("REQUIRE" "{" parameter_dict "}")?
|
|
173
|
+
|
|
174
|
+
// Fine-tuning
|
|
175
|
+
top_create_fine_tune_dataset: "CREATE" "FINE_TUNE_DATASET" string "FROM" "NAMESPACE" (identifier | variable) ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "IN" string)?
|
|
176
|
+
top_fine_tune_model: "FINE_TUNE" "MODEL" (string | variable) "USING" "DATASET" string ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "AS" string)?
|
|
177
|
+
top_register_model: "REGISTER" "MODEL" string "WITH" "{" parameter_dict "}"
|
|
178
|
+
top_promote_model: "PROMOTE" "MODEL" string "TO" string ("IF" condition)?
|
|
179
|
+
top_rollback_model: "ROLLBACK" "MODEL" string "TO" string ("REASON" string)?
|
|
180
|
+
|
|
181
|
+
// Result operations
|
|
182
|
+
top_merge_results: "MERGE" "RESULTS" "(" (identifier | variable) ("," (identifier | variable))* ")" ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "RESULT" ("IN" variable)?)?
|
|
183
|
+
top_rerank: "RERANK" (identifier | variable) ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "RESULT" ("IN" variable)?)?
|
|
184
|
+
top_reason: "REASON" "ON" ("COLLECTION" | identifier) (identifier | variable) ("USING" "MODEL" (string | variable) | parameter_dict)? ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "RESULT" "AS" variable)?
|
|
185
|
+
|
|
186
|
+
// Blockchain/Traceability Operations
|
|
187
|
+
top_blockchain_verify: "VERIFY" "BLOCKCHAIN" ("FOR" identifier)?
|
|
188
|
+
top_blockchain_block: "GET" "BLOCK" number ("FOR" identifier)?
|
|
189
|
+
top_blockchain_length: "GET" "BLOCKCHAIN" "LENGTH" ("FOR" identifier)?
|
|
190
|
+
top_blockchain_latest: "GET" "LATEST" "BLOCK" ("FOR" identifier)?
|
|
191
|
+
top_blockchain_audit: "GET" "AUDIT" "TRAIL" ("FOR" identifier)? ("WHERE" blockchain_audit_filter)?
|
|
192
|
+
top_blockchain_merkle: "GET" "MERKLE" "ROOT" ("FOR" identifier)?
|
|
193
|
+
top_blockchain_blocks_range: "GET" "BLOCKS" "FROM" number "TO" number ("FOR" identifier)?
|
|
194
|
+
top_blockchain_verify_block: "VERIFY" "BLOCK" number ("FOR" identifier)?
|
|
195
|
+
blockchain_audit_filter: blockchain_filter_item ("AND" blockchain_filter_item)*
|
|
196
|
+
blockchain_filter_item: ("entity_id" "=" (string | identifier))
|
|
197
|
+
| ("entity_type" "=" (string | identifier))
|
|
198
|
+
| ("operation_type" "=" (string | identifier))
|
|
199
|
+
| ("start_time" "=" (string | number))
|
|
200
|
+
| ("end_time" "=" (string | number))
|
|
201
|
+
|
|
202
|
+
// Temporal diff operations
|
|
203
|
+
top_diff_node: "DIFF" "NODE" (node_spec | identifier ("id" "=" string)?) "AT" string "VS" string
|
|
204
|
+
top_diff_edges: "DIFF" "EDGES" identifier "FOR" diff_edge_spec "AT" string "VS" string
|
|
205
|
+
diff_edge_spec: "source" "=" string | "target" "=" string | "source" "=" string "AND" "target" "=" string
|
|
206
|
+
|
|
207
|
+
// Top-level versions (aliases for standalone use)
|
|
208
|
+
top_create_graph: "CREATE" "GRAPH" identifier
|
|
209
|
+
top_create_graph_as: "CREATE" "GRAPH" identifier "AS" graph_pipeline
|
|
210
|
+
top_create_graph_with_structure: "CREATE" "GRAPH" identifier ("THEN" create_graph_statement)+
|
|
211
|
+
create_graph_statement: "CREATE" "NODE" node_spec ("UNIQUE" "KEY" "(" identifier_list ")")?
|
|
212
|
+
| "CREATE" "EDGE" identifier edge_spec_with_endpoints ("UNIQUE" "KEY" "(" identifier_list ")")?
|
|
213
|
+
| "CREATE" "EDGE" edge_spec_with_endpoints ("UNIQUE" "KEY" "(" identifier_list ")")?
|
|
214
|
+
top_create_graph_from_schema: "CREATE" "GRAPH" identifier "FROM" "SCHEMA" string
|
|
215
|
+
top_create_node: "CREATE" "NODE" node_spec ("UNIQUE" "KEY" "(" identifier_list ")")?
|
|
216
|
+
top_create_edge: "CREATE" "EDGE" identifier edge_spec_with_endpoints ("UNIQUE" "KEY" "(" identifier_list ")")?
|
|
217
|
+
| "CREATE" "EDGE" edge_spec_with_endpoints ("UNIQUE" "KEY" "(" identifier_list ")")?
|
|
218
|
+
| "CREATE" "EDGE" identifier "->" identifier ("{" property_list? "}")?
|
|
219
|
+
| "CREATE" "EDGE" identifier "->" identifier "->" identifier ("{" property_list? "}")?
|
|
220
|
+
top_drop_graph: "DROP" "GRAPH" identifier ("CASCADE")?
|
|
221
|
+
|
|
222
|
+
// Basic types defined early to avoid forward references
|
|
223
|
+
identifier: IDENTIFIER
|
|
224
|
+
string: STRING
|
|
225
|
+
number: NUMBER
|
|
226
|
+
boolean: "TRUE" | "FALSE"
|
|
227
|
+
list: "[" (value ("," value)*)? "]"
|
|
228
|
+
|
|
229
|
+
// Variable declarations (standalone and within pipelines)
|
|
230
|
+
variable_decl: "LET" variable "=" value ("STORE" "RESULT" ("IN" variable)?)?
|
|
231
|
+
variable: "$" IDENTIFIER
|
|
232
|
+
value: string | number | boolean | identifier | list | variable | subquery | search_query_basic | search_query_collections | graph_search_query | graph_search_from_via_to | rag_generate | rag_query_one_shot | embed_function | semantic_hash_function | now_function | top_traverse
|
|
233
|
+
embed_function: "EMBED" (string | variable) ("USING" "MODEL" (string | variable) | parameter_dict)? ("PARAMETERS" "(" parameter_dict ")")?
|
|
234
|
+
semantic_hash_function: "SEMANTIC_HASH" (string | variable) ("USING" "MODEL" (string | variable))?
|
|
235
|
+
now_function: "NOW" "(" ")"
|
|
236
|
+
|
|
237
|
+
// Multimodal Pipeline Grammar
|
|
238
|
+
multimodal_pipeline: create_multimodal_pipeline | run_pipeline_cmd
|
|
239
|
+
|
|
240
|
+
// Retrieval Pipeline Grammar
|
|
241
|
+
retrieval_pipeline: create_retrieval_pipeline | run_retrieval_query | run_pipeline_with_input
|
|
242
|
+
|
|
243
|
+
// Search Grammar (DENSE, SPARSE, HYBRID, SEMANTIC, GRAPH)
|
|
244
|
+
search_type: "DENSE" | "SPARSE" | "HYBRID" | "SEMANTIC" | "GRAPH"
|
|
245
|
+
search_query_basic: ("DENSE" | "SPARSE" | "HYBRID" | "SEMANTIC" | "GRAPH") "SEARCH" (string | variable) "IN" identifier ("USING" "MODEL" (string | variable) | parameter_dict)? ("PARAMETERS" "(" parameter_dict ")")? ("LIMIT" (number | variable))?
|
|
246
|
+
search_query_with_weights: search_type SEARCH (string | variable) "IN" identifier "WITH" weight_list (LIMIT number)?
|
|
247
|
+
search_query_multimodal: search_type SEARCH (string | variable) "IN" "(" identifier_list ")" ("WITH" weight_list)? (LIMIT number)?
|
|
248
|
+
search_query_namespace: search_type SEARCH (string | variable) "IN" "NAMESPACE" identifier ("USING" "COLLECTION" identifier)? ("MODE" mode_type)? (LIMIT number)?
|
|
249
|
+
// SEMANTIC SEARCH with IN COLLECTIONS
|
|
250
|
+
search_query_collections: "SEMANTIC" "SEARCH" (string | variable) "IN" "COLLECTIONS" ("[" identifier_list "]" | "(" identifier_list ")") ("USING" "MODEL" (string | variable) | parameter_dict)? ("PARAMETERS" "(" parameter_dict ")")? ("LIMIT" (number | variable))?
|
|
251
|
+
// GRAPH SEARCH with VIA and DEPTH
|
|
252
|
+
graph_search_query: "GRAPH" SEARCH (string | variable) "VIA" "(" identifier_list ")" ("DEPTH" number)?
|
|
253
|
+
// GRAPH SEARCH with FROM/VIA/TO
|
|
254
|
+
graph_search_from_via_to: "GRAPH" "SEARCH" ("FROM" identifier ("WHERE" condition)?)? ("VIA" "(" identifier_list ")")? ("TO" identifier)? ("USING" "MODEL" (string | variable) | parameter_dict)? ("PARAMETERS" "(" parameter_dict ")")? ("LIMIT" (number | variable))?
|
|
255
|
+
|
|
256
|
+
// Weight list for search (semantic=0.6, keyword=0.4, graph=0.1, etc.)
|
|
257
|
+
weight_list: weight_item ("," weight_item)*
|
|
258
|
+
weight_item: identifier "=" number
|
|
259
|
+
|
|
260
|
+
// Hybrid Search Grammar
|
|
261
|
+
hybrid_search: hybrid_search_query | hybrid_search_simple | hybrid_search_with_weights | hybrid_search_with_profile | search_query_basic | search_query_with_weights | search_query_multimodal | search_query_namespace
|
|
262
|
+
|
|
263
|
+
// Basic hybrid search query (full syntax with NAMESPACE)
|
|
264
|
+
hybrid_search_query: HYBRID SEARCH string IN NAMESPACE identifier (USING COLLECTION identifier)? (MODE mode_type)? (LIMIT number)?
|
|
265
|
+
|
|
266
|
+
// Simple hybrid search query (simplified syntax: IN node_type)
|
|
267
|
+
hybrid_search_simple: HYBRID SEARCH string "IN" identifier (WITH weight_list)? (USING MODEL string)? (LIMIT number)?
|
|
268
|
+
|
|
269
|
+
// SEARCH Query Grammar (ported from QGQL)
|
|
270
|
+
// Support both: SEARCH 'text' IN NODES AND SEARCH NODE Person 'text'
|
|
271
|
+
search_query: "SEARCH" string "IN" ("NODES" | "EDGES") ("USING" "STRATEGY" search_strategy)? ("WHERE" search_condition)? ("LIMIT" number)?
|
|
272
|
+
| "SEARCH" "NODE" identifier string ("WHERE" search_condition)? ("LIMIT" number)?
|
|
273
|
+
| "SEARCH" "EDGE" string ("WHERE" search_condition)? ("LIMIT" number)?
|
|
274
|
+
search_strategy: "hybrid" | "similarity" | "keyword" | "sparse"
|
|
275
|
+
search_condition: identifier search_operator value
|
|
276
|
+
search_operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "CONTAINS" | "STARTS" "WITH" | "ENDS" "WITH" | "IN" | "NOT" "IN"
|
|
277
|
+
|
|
278
|
+
// AGGREGATE Query Grammar (ported from QGQL)
|
|
279
|
+
aggregate_query: "AGGREGATE" aggregate_function "(" (qualified_identifier | "*") ")" ("FROM" node_spec)? ("WHERE" condition)?
|
|
280
|
+
aggregate_function: "COUNT" | "SUM" | "AVG" | "MIN" | "MAX"
|
|
281
|
+
|
|
282
|
+
// Hybrid search with custom weights
|
|
283
|
+
hybrid_search_with_weights: HYBRID SEARCH string IN NAMESPACE identifier USING COLLECTION identifier WITH WEIGHTS weight_configuration (LIMIT number)?
|
|
284
|
+
|
|
285
|
+
// Hybrid search with predefined profile
|
|
286
|
+
hybrid_search_with_profile: HYBRID SEARCH string IN NAMESPACE identifier USING COLLECTION identifier WITH "PROFILE" identifier (LIMIT number)?
|
|
287
|
+
|
|
288
|
+
// Weight configuration
|
|
289
|
+
weight_configuration: "(" DENSE "=" number "," SPARSE "=" number "," GRAPH "=" number ")"
|
|
290
|
+
|
|
291
|
+
// Mode types
|
|
292
|
+
mode_type: "AUTO" | "DYNAMIC" | "STATIC" | "DEFAULT" | "DECLARATIVE" | "INTERACTIVE" | "PIPELINE"
|
|
293
|
+
|
|
294
|
+
// SET MODE statement for execution context
|
|
295
|
+
set_mode_statement: "SET" "MODE" mode_type
|
|
296
|
+
|
|
297
|
+
// CREATE PIPELINE statement (for retrieval pipelines)
|
|
298
|
+
create_retrieval_pipeline: "CREATE" "PIPELINE" identifier "IN" "NAMESPACE" identifier collection_spec "DESCRIPTION" string ("CHECKPOINT" "POLICY" ("enabled" | "disabled"))? "STAGES" "=" "[" retrieval_stage_list "]"
|
|
299
|
+
collection_spec: "SOURCE" "COLLECTION" identifier | "USING" "COLLECTION" identifier
|
|
300
|
+
|
|
301
|
+
// RUN PIPELINE statement (with query injection)
|
|
302
|
+
run_retrieval_query: RUN QUERY string USING PIPELINE identifier ("AS" "RUN" string)?
|
|
303
|
+
run_pipeline_with_input: "RUN" "PIPELINE" identifier "WITH" "INPUT" value ("AS" "RUN" string)?
|
|
304
|
+
|
|
305
|
+
// Retrieval stage list
|
|
306
|
+
retrieval_stage_list: retrieval_stage ("," retrieval_stage)*
|
|
307
|
+
|
|
308
|
+
// Individual retrieval stages
|
|
309
|
+
retrieval_stage: retrieval_function_stage | retrieval_step_stage
|
|
310
|
+
|
|
311
|
+
// Function-based retrieval stage with STEP syntax
|
|
312
|
+
retrieval_function_stage: "STEP" identifier ("DESCRIPTION" string)? retrieval_function_call
|
|
313
|
+
|
|
314
|
+
// Retrieval step stage (new syntax)
|
|
315
|
+
retrieval_step_stage: "STEP" identifier ("DESCRIPTION" string)? (retrieve_stage | context_stage | reason_stage | evaluate_stage)
|
|
316
|
+
|
|
317
|
+
// Retrieve stage
|
|
318
|
+
retrieve_stage: "RETRIEVE" "USING" ("PROFILE" | "FUNCTION") identifier retrieve_options*
|
|
319
|
+
retrieve_options: ("STRATEGY" identifier) | ("INCLUDE" retrieval_types) | ("TEMPORAL" "POLICY" identifier)
|
|
320
|
+
|
|
321
|
+
// Reason stage
|
|
322
|
+
reason_stage: "REASON" "USING" ("MODEL" | "FUNCTION") identifier reason_options*
|
|
323
|
+
reason_options: ("PROMPT" string) | ("VERIFY" "USING" identifier) | ("PARAMETERS" parameters_block)
|
|
324
|
+
|
|
325
|
+
// Evaluate stage
|
|
326
|
+
evaluate_stage: "EVALUATE" "USING" "SUITE" identifier evaluate_options*
|
|
327
|
+
evaluate_options: ("METRICS" "[" metric_list "]") | ("STORE" "RESULTS" "IN" "COLLECTION" identifier) | ("PARAMETERS" parameters_block)
|
|
328
|
+
|
|
329
|
+
// Context stage
|
|
330
|
+
context_stage: "CONTEXT" "USING" identifier context_options*
|
|
331
|
+
context_options: ("MODE" identifier) | ("WINDOW_SIZE" number) | ("DEDUPLICATE" boolean) | ("MERGE" "NODES" "(" node_type_list ")") | ("GROUP_BY" "ENTITY") | ("MULTIMODAL" boolean)
|
|
332
|
+
|
|
333
|
+
// Retrieval function call
|
|
334
|
+
retrieval_function_call: "USING" "FUNCTION" retrieval_function_name ("PARAMETERS" parameters_block)? (input_output_clauses)?
|
|
335
|
+
retrieval_function_name: identifier ("." identifier)*
|
|
336
|
+
input_output_clauses: ("INPUT" "FROM" collection_name)? ("OUTPUT" "TO" variable_name | "OUTPUT" "TO" "COLLECTION" identifier)
|
|
337
|
+
collection_name: identifier
|
|
338
|
+
variable_name: "$" identifier
|
|
339
|
+
parameters_block: "(" (retrieval_parameter ("," retrieval_parameter)*)? ")"
|
|
340
|
+
retrieval_parameter: identifier ("=" | ":") value
|
|
341
|
+
|
|
342
|
+
// Legacy retrieval stages (kept for backward compatibility, commented out as we use new syntax above)
|
|
343
|
+
// context_stage: CONTEXT USING identifier (WINDOW_SIZE number)? (MODE identifier)? (DEDUPLICATE boolean)? (MERGE NODES "(" node_type_list ")")?
|
|
344
|
+
// reason_stage: REASON USING MODEL identifier (INSTRUCTION string)? (PROMPT string)? (VERIFY USING identifier)?
|
|
345
|
+
verify_stage: "VERIFY" "USING" identifier
|
|
346
|
+
// evaluate_stage: EVALUATE USING SUITE identifier (METRICS "[" metric_list "]")? (STORE RESULTS IN COLLECTION identifier)?
|
|
347
|
+
|
|
348
|
+
// Supporting grammar elements
|
|
349
|
+
retrieval_types: retrieval_type ("," retrieval_type)*
|
|
350
|
+
retrieval_type: "ENTITY" | "RELATIONSHIP" | "TABLE" | "IMAGE" | "CHUNK" | "DOCUMENT"
|
|
351
|
+
|
|
352
|
+
node_type_list: identifier ("," identifier)*
|
|
353
|
+
metric_list: string ("," string)*
|
|
354
|
+
|
|
355
|
+
// CREATE PIPELINE statement (simplified name - works for all pipeline types)
|
|
356
|
+
create_pipeline: "CREATE" "PIPELINE" identifier ("IN" "NAMESPACE" (identifier | variable))? ("SOURCE" "COLLECTION" identifier)? ("TARGET" "COLLECTION" identifier)? ("DESCRIPTION" string)? ("EXECUTION_MODE" identifier)? ("PARAMETERS" "(" parameter_dict ")")? ("STAGES" "=" "[" enhanced_stage_list "]")?
|
|
357
|
+
| "CREATE" "PIPELINE" identifier "IN" "NAMESPACE" identifier "SOURCE" "COLLECTION" identifier "TARGET" "COLLECTION" identifier "DESCRIPTION" string ("EXECUTION_MODE" identifier)? ("CHECKPOINT" "POLICY" ("enabled" | "disabled"))? "STAGES" "=" "[" enhanced_stage_list "]"
|
|
358
|
+
// Legacy alias for backward compatibility
|
|
359
|
+
create_multimodal_pipeline: create_pipeline
|
|
360
|
+
|
|
361
|
+
// RUN PIPELINE statement with enhanced options
|
|
362
|
+
run_pipeline_cmd: "RUN" "PIPELINE" identifier run_pipeline_options*
|
|
363
|
+
run_pipeline_options: "DRY_RUN" | "LAZY" | "STEP_BY_STEP"
|
|
364
|
+
| "FROM" "STEP" identifier
|
|
365
|
+
| "RESTART" "STEP" identifier
|
|
366
|
+
| "STEPS" "[" step_range "]"
|
|
367
|
+
| "OVERRIDE" "PARAMETERS" "(" parameter_dict ")"
|
|
368
|
+
| "PARAMETERS" "(" parameter_dict ")"
|
|
369
|
+
| "FROM" "CHECKPOINT" identifier
|
|
370
|
+
| "WITH" "PARAMETERS" parameters_block
|
|
371
|
+
| "WITH" "INTENT" string
|
|
372
|
+
| "AS" string
|
|
373
|
+
step_range: identifier ("->" identifier)?
|
|
374
|
+
step_list: identifier ("," identifier)*
|
|
375
|
+
|
|
376
|
+
// CLASSIFY FILE command — detect file type and structure
|
|
377
|
+
classify_file_cmd: "CLASSIFY" "FILE" (string | variable)
|
|
378
|
+
|
|
379
|
+
// Enhanced multimodal stage list
|
|
380
|
+
enhanced_stage_list: enhanced_stage ("," enhanced_stage)* (",")?
|
|
381
|
+
|
|
382
|
+
// Individual enhanced multimodal stages with STEP prefix
|
|
383
|
+
enhanced_stage: step_stage | standalone_stage
|
|
384
|
+
|
|
385
|
+
// STEP-prefixed stages
|
|
386
|
+
step_stage: "STEP" identifier ("DESCRIPTION" string)? stage_action
|
|
387
|
+
|
|
388
|
+
// Standalone stages (no STEP prefix)
|
|
389
|
+
standalone_stage: enhanced_connect_stage | enhanced_index_stage
|
|
390
|
+
|
|
391
|
+
// Stage action - enhanced stages with function support and pipeline references
|
|
392
|
+
stage_action: enhanced_extract_stage | enhanced_preprocess_stage | enhanced_chunk_stage
|
|
393
|
+
| enhanced_entity_extract_stage | enhanced_relationship_extract_stage
|
|
394
|
+
| enhanced_embed_stage | enhanced_connect_stage | enhanced_index_stage | function_stage
|
|
395
|
+
| pipeline_reference_stage | extract_from_folder_stage | chunk_by_semantic_stage
|
|
396
|
+
| embed_into_stage | hybrid_search_stage | traverse_stage_pipeline | generate_stage
|
|
397
|
+
| evaluate_rag_stage | insert_into_stage
|
|
398
|
+
|
|
399
|
+
// EXTRACT FROM FOLDER stage
|
|
400
|
+
extract_from_folder_stage: "EXTRACT" "FROM" "FOLDER" string ("DETECT" "(" detect_types ")")? ("STORE" "AS" "NODE" "TYPES" "(" node_types ")")?
|
|
401
|
+
|
|
402
|
+
// CHUNK BY semantic stage
|
|
403
|
+
chunk_by_semantic_stage: "CHUNK" "BY" chunk_method ("PARAMETERS" "(" parameter_dict ")")? ("FROM" identifier)? ("STORE" "AS" "NODE" "TYPE" identifier)? ("LINK" "TO" identifier "ON" identifier)?
|
|
404
|
+
|
|
405
|
+
// EMBED INTO stage
|
|
406
|
+
embed_into_stage: "EMBED" ("USING" "MODEL" (string | variable) | parameter_dict)? ("PARAMETERS" "(" parameter_dict ")")? "INTO" identifier
|
|
407
|
+
|
|
408
|
+
// HYBRID SEARCH stage with STORE RESULT AS
|
|
409
|
+
hybrid_search_stage: "HYBRID" "SEARCH" (string | variable) "IN" identifier ("USING" "MODEL" (string | variable) | parameter_dict)? ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "RESULT" "AS" identifier)?
|
|
410
|
+
|
|
411
|
+
// TRAVERSE stage with STORE RESULT AS (for pipeline context)
|
|
412
|
+
traverse_stage_pipeline: "TRAVERSE" "FROM" (identifier | variable) ("VIA" "(" identifier_list ")")? ("TO" identifier)? ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "RESULT" "AS" identifier)?
|
|
413
|
+
|
|
414
|
+
// GENERATE stage with PROMPT, USER_QUERY, CONTEXT FROM, GUARDRAILS
|
|
415
|
+
generate_stage: "GENERATE" ("USING" "MODEL" (string | variable))? ("PROMPT" string)? ("USER_QUERY" (string | variable))? ("CONTEXT" "FROM" context_sources)? ("PARAMETERS" "(" parameter_dict ")")? ("GUARDRAILS" "{" parameter_dict "}")? ("STORE" "RESULT" "AS" identifier)?
|
|
416
|
+
context_sources: (identifier | variable) ("," (identifier | variable))*
|
|
417
|
+
|
|
418
|
+
// EVALUATE RAG stage with STORE RESULT AS
|
|
419
|
+
evaluate_rag_stage: "EVAL" "RAG" "ON" (identifier | variable) ("USING" "MODEL" (string | variable) | parameter_dict)? ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "RESULT" "AS" identifier)?
|
|
420
|
+
|
|
421
|
+
// INSERT INTO stage
|
|
422
|
+
insert_into_stage: "INSERT" "INTO" identifier "VALUES" "{" property_list "}"
|
|
423
|
+
|
|
424
|
+
// Pipeline reference stage - allows pipelines to reference other pipelines as stages
|
|
425
|
+
pipeline_reference_stage: "RUN" "PIPELINE" identifier (pipeline_ref_option)*
|
|
426
|
+
pipeline_ref_option: "WITH" "PARAMETERS" "(" parameter_dict ")" | "FROM" "CHECKPOINT" identifier | "AS" string
|
|
427
|
+
|
|
428
|
+
function_stage_input: "FROM" "FILE" string ("FORMAT" string)?
|
|
429
|
+
|
|
430
|
+
// Function-based stage (new cleaner syntax) with optional storage/linking clauses
|
|
431
|
+
function_stage: function_stage_input? "USING" "FUNCTION" (identifier | FUNCTION_NAME) ("PARAMETERS" "(" parameter_dict ")")? function_stage_output*
|
|
432
|
+
function_stage_output: ("STORE" "AS" ("NODE" "TYPE" identifier | "NODE" "TYPES" "(" node_types ")" | "EDGE" "TYPE" identifier)
|
|
433
|
+
| "LINK" ("(" link_specs ")" | "TO" identifier "ON" identifier | "USING" identifier)
|
|
434
|
+
| "OUTPUT" "TO" "COLLECTION" identifier
|
|
435
|
+
| "STORE" "INTERMEDIATE" "IN" ("COLLECTION" identifier | "MEMORY")
|
|
436
|
+
| "NORMALIZE" boolean
|
|
437
|
+
| "CONTEXT_POLICY" string
|
|
438
|
+
| "STORE" "EMBEDDING" "IN" identifier "." identifier
|
|
439
|
+
| "BUILD_INDEX" string
|
|
440
|
+
| "STORE" "IN" "COLLECTION" identifier)
|
|
441
|
+
|
|
442
|
+
// Parameter dictionary (key-value pairs)
|
|
443
|
+
parameter_dict: parameter_pair ("," parameter_pair)* | "{" parameter_pair ("," parameter_pair)* "}"
|
|
444
|
+
parameter_pair: (identifier | string) (":" | "=") parameter_value
|
|
445
|
+
parameter_value: string | number | boolean | list | identifier | variable | qualified_variable | "[" (string ("," string)*) "]" | object
|
|
446
|
+
object: "{" parameter_pair ("," parameter_pair)* "}"
|
|
447
|
+
// Qualified variable for parameter references like $params.dense_weight
|
|
448
|
+
qualified_variable: variable ("." identifier)+
|
|
449
|
+
|
|
450
|
+
// Detect types for multimodal extraction
|
|
451
|
+
detect_types: detect_type ("," detect_type)*
|
|
452
|
+
detect_type: IDENTIFIER // TEXT, TABLES, IMAGES, AUDIO, VIDEO are IDENTIFIER tokens
|
|
453
|
+
|
|
454
|
+
// Node types for storage
|
|
455
|
+
node_types: IDENTIFIER ("," IDENTIFIER)*
|
|
456
|
+
|
|
457
|
+
// Link specifications
|
|
458
|
+
link_specs: link_item ("," link_item)*
|
|
459
|
+
link_item: IDENTIFIER "TO" IDENTIFIER
|
|
460
|
+
|
|
461
|
+
// Unified USING clause - supports built-in, LLM, or custom functions
|
|
462
|
+
using_clause: "USING" using_option
|
|
463
|
+
using_option: "READER" string // Built-in reader (e.g., "pdfplumber")
|
|
464
|
+
| "MODEL" string // Built-in model
|
|
465
|
+
| "PROFILE" (string | identifier) // Built-in profile (e.g., embedding profile) - can be string or identifier
|
|
466
|
+
| "LLM" string // LLM model (e.g., "gpt-4", "claude-3-opus")
|
|
467
|
+
| "FUNCTION" function_path // Custom Python function
|
|
468
|
+
| string // Legacy: just a string (backward compatibility)
|
|
469
|
+
|
|
470
|
+
// Function path (supports module.path or file.py:function)
|
|
471
|
+
function_path: (identifier ("." identifier)*) | (string ":" identifier)
|
|
472
|
+
|
|
473
|
+
// Parameter clause (consistent across all stages)
|
|
474
|
+
parameter_clause: "PARAMETERS" "(" parameter_dict ")"
|
|
475
|
+
|
|
476
|
+
// Storage clauses (consistent across all stages)
|
|
477
|
+
storage_clauses: storage_clause*
|
|
478
|
+
storage_clause: "STORE" "AS" ("NODE" "TYPE" identifier | "NODE" "TYPES" "(" node_types ")")
|
|
479
|
+
| "STORE" "AS" "EDGE" "TYPE" identifier
|
|
480
|
+
| "LINK" ("(" link_specs ")" | "TO" identifier "ON" identifier | "USING" identifier)
|
|
481
|
+
| "OUTPUT" "TO" "COLLECTION" identifier
|
|
482
|
+
| "STORE" "INTERMEDIATE" "IN" ("COLLECTION" identifier | "MEMORY")
|
|
483
|
+
| "STORE" "EMBEDDING" "IN" identifier "." identifier
|
|
484
|
+
| "BUILD_INDEX" string
|
|
485
|
+
| "NORMALIZE" boolean
|
|
486
|
+
| "CONTEXT_POLICY" string
|
|
487
|
+
| "STORE_NORMALIZED" boolean // Store normalized JSON output (Stage-1)
|
|
488
|
+
| "OUTPUT_DIR" string // Base directory for extraction output
|
|
489
|
+
|
|
490
|
+
// Enhanced Stage Definitions - Unified Syntax
|
|
491
|
+
// EXTRACT stage - unified syntax for ingestion (Stage-1: Extraction & Normalization)
|
|
492
|
+
// Supports: extraction modes (FULL, RANGE, LIST), page selection, reader selection, detect modalities
|
|
493
|
+
enhanced_extract_stage: "EXTRACT" extract_source? extract_mode? using_clause? detect_clause? parse_metadata_clause? parameter_clause? ("BY" "TOPICS" topic_config)? storage_clauses*
|
|
494
|
+
extract_source: "FROM" "FILE" string ("FORMAT" string)?
|
|
495
|
+
extract_mode: "MODE" extraction_mode | "PAGES" page_spec
|
|
496
|
+
extraction_mode: "FULL" | "RANGE" | "LIST"
|
|
497
|
+
page_spec: page_range | page_list
|
|
498
|
+
page_range: number ".." number | number "-" number
|
|
499
|
+
page_list: "[" number ("," number)* "]"
|
|
500
|
+
detect_clause: "DETECT" "(" detect_types ")"
|
|
501
|
+
parse_metadata_clause: "PARSE_METADATA" boolean
|
|
502
|
+
topic_config: ("MAX_TOPICS" number)? ("MIN_TOPIC_SIZE" number)? ("TOPIC_PROMPT" string)?
|
|
503
|
+
|
|
504
|
+
// PREPROCESS stage - unified syntax
|
|
505
|
+
enhanced_preprocess_stage: "PREPROCESS" using_clause? parameter_clause? storage_clauses*
|
|
506
|
+
|
|
507
|
+
// Preprocessing functions
|
|
508
|
+
preprocessing_functions: preprocessing_function ("PLUS" preprocessing_function)*
|
|
509
|
+
preprocessing_function: identifier ("." identifier)?
|
|
510
|
+
|
|
511
|
+
// CHUNK stage - unified syntax
|
|
512
|
+
enhanced_chunk_stage: "CHUNK" (("BY" chunk_method) | using_clause | parameter_clause | storage_clauses)*
|
|
513
|
+
|
|
514
|
+
// CHUNK stage (legacy)
|
|
515
|
+
chunk_stage_multimodal: "CHUNK" "BY" chunk_method "USING" "MODEL" identifier
|
|
516
|
+
|
|
517
|
+
// Chunking methods
|
|
518
|
+
chunk_method: "semantic" | "layout" | "semantic_plus_layout" | ("semantic" "+" "layout") | "fixed" | "sentence" | "paragraph" | "recursive" | "sliding_window" | "hierarchical" | "parent_child" | "table_aware" | "smart" | "token_based" | "semantic_similarity" | "topic_aware" | "qa_aware" | "code_aware" | "image_aware" | "adaptive" | "entity_aware" | "multilang" | "citation_aware" | "dialogue_aware" | "formula_aware" | "list_aware" | "cross_page"
|
|
519
|
+
|
|
520
|
+
// DETECT TABLES stage
|
|
521
|
+
detect_tables_stage: "DETECT" "TABLES" "USING" "MODEL" string ("EXTRACT" extract_options)? ("STORE" "AS" "NODE" "TYPE" identifier)? ("LINK" "TO" identifier "ON" identifier)?
|
|
522
|
+
|
|
523
|
+
// DETECT IMAGES stage
|
|
524
|
+
detect_images_stage: "DETECT" "IMAGES" "USING" "MODEL" string ("OCR" "USING" string)? ("DESCRIBE" "USING" string)? ("STORE" "AS" "NODE" "TYPE" identifier)? ("LINK" "TO" identifier "ON" identifier)?
|
|
525
|
+
|
|
526
|
+
// DETECT AUDIO stage
|
|
527
|
+
detect_audio_stage: "DETECT" "AUDIO" "USING" "MODEL" string ("EXTRACT" "METADATA" "(" audio_metadata_list ")")? ("STORE" "AS" "NODE" "TYPE" identifier)? ("LINK" "TO" identifier "ON" identifier)?
|
|
528
|
+
|
|
529
|
+
// Audio metadata list
|
|
530
|
+
audio_metadata_list: audio_metadata_item ("," audio_metadata_item)*
|
|
531
|
+
audio_metadata_item: "duration" | "speaker" | "transcript"
|
|
532
|
+
|
|
533
|
+
// OCR stage
|
|
534
|
+
ocr_stage: "OCR" "USING" string
|
|
535
|
+
|
|
536
|
+
// CAPTION stage
|
|
537
|
+
caption_stage: "DESCRIBE" "USING" string
|
|
538
|
+
|
|
539
|
+
// ENTITY EXTRACT stage (enhanced)
|
|
540
|
+
enhanced_entity_extract_stage: "EXTRACT" "ENTITIES" (("FROM" "CHUNKS" "OF" "SOURCE") | ("USING" "LLM" string) | ("PASSES" "(" identifier_list ")") | ("PROMPT" string) | ("STORE" "AS" "NODE" "TYPE" identifier) | ("LINK" "TO" identifier "ON" identifier) | ("OUTPUT" "TO" "COLLECTION" identifier) | ("STORE" "INTERMEDIATE" "IN" ("COLLECTION" identifier | "MEMORY")))*
|
|
541
|
+
|
|
542
|
+
// ENTITY EXTRACT stage (legacy)
|
|
543
|
+
entity_extract_stage: "ENTITY_EXTRACT" "USING" "MODEL" string ("STORE" "AS" "NODE" "TYPE" identifier)? ("LINK" "TO" identifier "ON" identifier)?
|
|
544
|
+
|
|
545
|
+
// RELATIONSHIP EXTRACT stage - unified syntax
|
|
546
|
+
enhanced_relationship_extract_stage: "EXTRACT" "RELATIONSHIPS" (("FROM" "CHUNKS" "OF" "SOURCE") | using_clause | parameter_clause | storage_clauses)*
|
|
547
|
+
|
|
548
|
+
// RELATE stage
|
|
549
|
+
relate_stage: "RELATE" "USING" "MODEL" string ("LINK" "TYPES" "=" "[" link_types_list "]")? ("CONFIDENCE_THRESHOLD" "=" number)?
|
|
550
|
+
|
|
551
|
+
// Link types list
|
|
552
|
+
link_types_list: string ("," string)*
|
|
553
|
+
|
|
554
|
+
// EMBED stage (enhanced)
|
|
555
|
+
enhanced_embed_stage: "EMBED" (("USING" "PROFILE" identifier) | ("PARAMETERS" "(" parameter_list ")") | ("CONTEXT_POLICY" string) | ("PROMPT" string) | ("STORE" "EMBEDDING" "IN" identifier "." identifier) | ("STORE" "INTERMEDIATE" "IN" ("COLLECTION" identifier | "MEMORY")))*
|
|
556
|
+
|
|
557
|
+
// EMBED stage (legacy)
|
|
558
|
+
embed_stage: "EMBED" "USING" "PROFILE" identifier
|
|
559
|
+
|
|
560
|
+
// CONNECT stage (enhanced)
|
|
561
|
+
enhanced_connect_stage: "CONNECT" "AUTO" (("(" identifier ">" number "," identifier ">" number ")") | ("INCLUDE" "EDGES" "[" string_list "]") | ("CONFIDENCE_THRESHOLD" number) | ("TEMPORAL_POLICY" identifier) | ("STORE" "INTERMEDIATE" "IN" ("COLLECTION" identifier | "MEMORY")))*
|
|
562
|
+
| "CONNECT" "FROM" "NORMALIZED" (connect_from_normalized_option)* storage_clauses*
|
|
563
|
+
|
|
564
|
+
// CONNECT FROM NORMALIZED option (can appear multiple times)
|
|
565
|
+
connect_from_normalized_option: "CREATE" "NODES" "(" node_types ")"
|
|
566
|
+
| "LINK" "(" link_specs ")"
|
|
567
|
+
| "LINK" link_specs
|
|
568
|
+
|
|
569
|
+
// CONNECT stage (legacy)
|
|
570
|
+
connect_stage: "CONNECT" "AUTO" ("(" connect_params ")")?
|
|
571
|
+
|
|
572
|
+
// Connect parameters
|
|
573
|
+
connect_params: connect_param ("," connect_param)*
|
|
574
|
+
connect_param: identifier ">" number
|
|
575
|
+
|
|
576
|
+
// INDEX stage (enhanced)
|
|
577
|
+
enhanced_index_stage: "INDEX" (("USING" "{" index_options "}") | ("BUILD_INDEX" string) | ("STORE" "IN" "COLLECTION" identifier) | ("PROMPT" string))*
|
|
578
|
+
|
|
579
|
+
// INDEX stage (legacy)
|
|
580
|
+
index_stage_multimodal: "INDEX" "USING" "{" index_options "}"
|
|
581
|
+
|
|
582
|
+
// Index options
|
|
583
|
+
index_options: index_option ("," index_option)*
|
|
584
|
+
index_option: identifier ":" (boolean | string)
|
|
585
|
+
|
|
586
|
+
// Extract options
|
|
587
|
+
extract_options: extract_option ("," extract_option)*
|
|
588
|
+
extract_option: "CELLS" | "HEADERS" | "CAPTIONS"
|
|
589
|
+
|
|
590
|
+
// Pipeline parameters
|
|
591
|
+
pipeline_params: "{" pipeline_param ("," pipeline_param)* "}"
|
|
592
|
+
pipeline_param: identifier ":" value
|
|
593
|
+
|
|
594
|
+
// Pipeline with THEN sequencing and PARALLEL blocks
|
|
595
|
+
// IMPORTANT: pipeline_without_seed removed - standalone queries shouldn't match pipeline
|
|
596
|
+
// Only explicit PIPELINE SEED {...} syntax matches pipeline
|
|
597
|
+
pipeline: pipeline_with_seed
|
|
598
|
+
pipeline_with_seed: "PIPELINE" "SEED" string "{" pipeline_body "}"
|
|
599
|
+
pipeline_body: pipeline_item ("THEN" pipeline_item | pipeline_item)*
|
|
600
|
+
pipeline_item: variable_decl | stage | parallel_stage
|
|
601
|
+
?stage: create_stage | drop_stage | use_stage | load_stage | chunk_stage | extract_stage | generate_stage_legacy
|
|
602
|
+
| embedding_stage | retrieval_stage | traverse_stage | analytics_stage
|
|
603
|
+
| where_stage | select_stage | index_stage | shard_stage | schema_stage
|
|
604
|
+
| model_stage | prompt_stage | namespace_stage | grant_stage
|
|
605
|
+
| define_node_stage | define_edge_stage | view_stage | materialized_view_stage
|
|
606
|
+
| temporal_stage | temporal_query | stream_stage | udf_stage | transaction_stage | explain_stage
|
|
607
|
+
| delete_stage | update_stage | generation_stage | agent_stage | governance_stage
|
|
608
|
+
| eval_stage | web_stage | rag_pipeline_stage | pipeline_management_stage
|
|
609
|
+
| file_reader_stage | multimodal_extraction_stage | smart_chunking_stage | evaluation_stage
|
|
610
|
+
| retrieval_system_stage | return_stage | match_entity_stage
|
|
611
|
+
|
|
612
|
+
// Parallel execution stage
|
|
613
|
+
parallel_stage: "PARALLEL" stage | "PARALLEL" "(" stage ("," stage)* ")"
|
|
614
|
+
|
|
615
|
+
// Graph creation and mutation
|
|
616
|
+
create_graph: "CREATE" "GRAPH" identifier
|
|
617
|
+
create_graph_as: "CREATE" "GRAPH" identifier "AS" graph_pipeline
|
|
618
|
+
create_stage: create_graph | create_graph_as | create_node | create_edge
|
|
619
|
+
|
|
620
|
+
// Graph deletion
|
|
621
|
+
drop_stage: drop_graph
|
|
622
|
+
drop_graph: "DROP" "GRAPH" identifier ("CASCADE")?
|
|
623
|
+
|
|
624
|
+
// Graph selection
|
|
625
|
+
use_stage: "USE" "GRAPH" identifier
|
|
626
|
+
create_node: "CREATE" "NODE" node_spec ("UNIQUE" "KEY" "(" identifier_list ")")?
|
|
627
|
+
|
|
628
|
+
create_edge: "CREATE" "EDGE" identifier edge_spec_with_endpoints ("UNIQUE" "KEY" "(" identifier_list ")")?
|
|
629
|
+
| "CREATE" "EDGE" edge_spec_with_endpoints ("UNIQUE" "KEY" "(" identifier_list ")")?
|
|
630
|
+
| "CREATE" "EDGE" identifier "->" identifier ("{" property_list? "}")?
|
|
631
|
+
| "CREATE" "EDGE" identifier "->" identifier "->" identifier ("{" property_list? "}")?
|
|
632
|
+
edge_spec_with_endpoints: "(" node_ref ")" edge_spec "(" node_ref ")"
|
|
633
|
+
| "(" node_ref ")" "->" "(" node_ref ")" ("{" property_list? "}")?
|
|
634
|
+
| edge_spec
|
|
635
|
+
| edge_from_to
|
|
636
|
+
edge_from_to: identifier ("AS" identifier)? ("{" property_list? "}")? "SRC" node_selector "DEST" node_selector
|
|
637
|
+
| identifier ("AS" identifier)? "SRC" node_selector "DEST" node_selector ("{" property_list? "}")?
|
|
638
|
+
| identifier "CONNECT" node_selector "DEST" node_selector ("{" property_list? "}")?
|
|
639
|
+
| ("{" property_list? "}")? "SRC" node_selector "DEST" node_selector
|
|
640
|
+
| "SRC" node_selector "DEST" node_selector ("{" property_list? "}")?
|
|
641
|
+
| identifier ("AS" identifier)? ("{" property_list? "}")? "FROM" node_selector "TO" node_selector
|
|
642
|
+
| identifier ("AS" identifier)? "FROM" node_selector "TO" node_selector ("{" property_list? "}")?
|
|
643
|
+
| ("{" property_list? "}")? "FROM" node_selector "TO" node_selector
|
|
644
|
+
| "FROM" node_selector "TO" node_selector ("{" property_list? "}")?
|
|
645
|
+
|
|
646
|
+
// Node selector for CREATE EDGE - supports UUID strings or node type with WHERE clause
|
|
647
|
+
node_selector: string
|
|
648
|
+
| identifier "WHERE" condition
|
|
649
|
+
| identifier
|
|
650
|
+
|
|
651
|
+
// Graph deletion and updates
|
|
652
|
+
delete_stage: delete_node | delete_edge
|
|
653
|
+
delete_node: "DELETE" "ALL" "NODES" ("WHERE" condition)? | "DELETE" "NODE" node_spec ("WHERE" condition)?
|
|
654
|
+
delete_edge: "DELETE" "EDGE" identifier ("WHERE" condition)? | "DELETE" "EDGE" identifier "SRC" node_selector "DEST" node_selector
|
|
655
|
+
|
|
656
|
+
update_stage: update_node | update_edge
|
|
657
|
+
update_node: "UPDATE" "NODE" node_spec "SET" "{" update_assignment_list "}" ("WHERE" condition)?
|
|
658
|
+
update_edge: "UPDATE" "EDGE" identifier ("AS" identifier)? "SET" "{" update_assignment_list "}" ("WHERE" condition)?
|
|
659
|
+
|
|
660
|
+
// Top-level UPDATE (standalone version)
|
|
661
|
+
// Support both: UPDATE NODE Person SET {...} WHERE ... AND UPDATE NODE Person WHERE ... SET {...}
|
|
662
|
+
top_update_node: "UPDATE" "NODE" node_spec ("WHERE" condition)? "SET" "{" update_assignment_list "}"
|
|
663
|
+
| "UPDATE" "NODE" node_spec "SET" "{" update_assignment_list "}" ("WHERE" condition)?
|
|
664
|
+
top_update_edge: "UPDATE" "EDGE" identifier ("AS" identifier)? ("SET" "{" update_assignment_list "}" ("WHERE" condition)? | ("WHERE" condition)? "SET" "{" update_assignment_list "}")
|
|
665
|
+
top_delete_edge: "DELETE" "EDGE" identifier "SRC" node_selector "DEST" node_selector
|
|
666
|
+
| "DELETE" "EDGE" edge_spec ("WHERE" condition)?
|
|
667
|
+
| "DELETE" "EDGE" ("WHERE" condition)?
|
|
668
|
+
|
|
669
|
+
// Property lists for CREATE (use colon)
|
|
670
|
+
node_spec: identifier ("AS" identifier)? ("{" property_list? "}")?
|
|
671
|
+
edge_spec: identifier ("AS" identifier)? ("{" property_list? "}")?
|
|
672
|
+
property_list: property ("," property)*
|
|
673
|
+
property: identifier ":" value
|
|
674
|
+
|
|
675
|
+
// Assignment lists for UPDATE (use equals or colon)
|
|
676
|
+
update_assignment_list: update_assignment ("," update_assignment)*
|
|
677
|
+
update_assignment: identifier ("=" | ":") value
|
|
678
|
+
|
|
679
|
+
// Data ingestion and bulk loading
|
|
680
|
+
load_stage: load_api_source | load_document | load_folder | load_csv | load_excel | load_json | load_xml | load_sql
|
|
681
|
+
load_document: "LOAD" "DOCUMENT" (string | variable) ("INTO" identifier)? ("WITH" "OPTIONS" "{" load_option_list "}" | "WITH" load_options)?
|
|
682
|
+
load_folder: "LOAD" "FOLDER" (string | variable) ("INTO" identifier)? ("WITH" "OPTIONS" "{" load_option_list "}" | "WITH" load_options)? ("FILTER" string)?
|
|
683
|
+
load_csv: "LOAD" "CSV" (string | variable) ("INTO" identifier)? ("HEADER" boolean | "DELIMITER" string | "WITH" "OPTIONS" "{" load_option_list "}" | "WITH" csv_options)?
|
|
684
|
+
load_excel: "LOAD" "EXCEL" (string | variable) ("INTO" identifier)? ("USING" "PIPELINE" identifier)? ("WITH" "OPTIONS" "{" load_option_list "}" | "WITH" load_options)?
|
|
685
|
+
load_json: "LOAD" "JSON" (string | variable) ("INTO" identifier)? ("PATH" string | "WITH" "OPTIONS" "{" load_option_list "}" | "WITH" json_options)?
|
|
686
|
+
load_xml: "LOAD" "XML" (string | variable) ("INTO" identifier)? ("XPATH" string | "WITH" "OPTIONS" "{" load_option_list "}" | "WITH" xml_options)?
|
|
687
|
+
load_sql: "LOAD" "SQL" (string | variable) ("FROM" identifier)? ("INTO" identifier)? ("QUERY" string | "TABLE" string | "WITH" sql_options)?
|
|
688
|
+
load_api_source: "LOAD" "API" (string | variable) ("INTO" identifier)? ("METHOD" string | "HEADERS" "{" property_list "}" | "PARAMS" "{" property_list "}")?
|
|
689
|
+
|
|
690
|
+
// Load option lists
|
|
691
|
+
load_option_list: load_option ("," load_option)*
|
|
692
|
+
|
|
693
|
+
// Bulk loading options
|
|
694
|
+
load_options: load_option ("," load_option)*
|
|
695
|
+
load_option: identifier "=" value
|
|
696
|
+
|
|
697
|
+
csv_options: csv_option ("," csv_option)*
|
|
698
|
+
csv_option: "DELIMITER" "=" string | "HEADER" "=" boolean | "ENCODING" "=" string | "SKIP_ROWS" "=" number
|
|
699
|
+
|
|
700
|
+
json_options: json_option ("," json_option)*
|
|
701
|
+
json_option: "PATH" "=" string | "ARRAY_MODE" "=" boolean | "FLATTEN" "=" boolean
|
|
702
|
+
|
|
703
|
+
xml_options: xml_option ("," xml_option)*
|
|
704
|
+
xml_option: "ROOT_PATH" "=" string | "NAMESPACE" "=" string | "VALIDATE" "=" boolean
|
|
705
|
+
|
|
706
|
+
sql_options: sql_option ("," sql_option)*
|
|
707
|
+
sql_option: "CONNECTION" "=" string | "QUERY" "=" string | "BATCH_SIZE" "=" number
|
|
708
|
+
|
|
709
|
+
api_options: api_option ("," api_option)*
|
|
710
|
+
api_option: "METHOD" "=" string | "HEADERS" "=" string | "AUTH" "=" string | "PAGINATION" "=" boolean
|
|
711
|
+
|
|
712
|
+
// Chunking and model operations
|
|
713
|
+
chunk_stage: "CHUNK" "BY" "USING" chunk_strategy
|
|
714
|
+
chunk_strategy: identifier ("{" parameter_list "}")?
|
|
715
|
+
extract_stage: "EXTRACT" "USING" model_spec
|
|
716
|
+
generate_stage_legacy: "GENERATE" "WITH" "MODEL" identifier "PROMPT" string | "GENERATE" "BY" "USING" model_spec
|
|
717
|
+
embedding_stage: "ADD EMBEDDINGS" "MODEL" identifier "TARGET" identifier | "ADD EMBEDDINGS" "USING" model_spec ("INTO" identifier)?
|
|
718
|
+
|
|
719
|
+
model_spec: identifier ("{" parameter_list "}")?
|
|
720
|
+
parameter_list: parameter ("," parameter)*
|
|
721
|
+
parameter: identifier ("=" | ":") value
|
|
722
|
+
|
|
723
|
+
// Retrieval operators
|
|
724
|
+
// retrieval_stage: advanced_retrieve | sparse_match | dense_match | hybrid_match | rerank_stage | retrieve_query | rag_query
|
|
725
|
+
|
|
726
|
+
// Advanced RAG retrieval syntax
|
|
727
|
+
advanced_retrieve: "RETRIEVE" ("TOP" number)? "FROM" identifier ("USING" hybrid_spec)? (where_stage)? ("ORDER" "BY" order_by_clause)? ("AUGMENT" augment_spec)? ("GROUND" ground_spec)? ("RETURN" return_spec)?
|
|
728
|
+
|
|
729
|
+
// RAG QUERY syntax (alias for RETRIEVE)
|
|
730
|
+
rag_query: "RAG" "QUERY" string ("IN" identifier)? ("USING" hybrid_spec)? ("LIMIT" number)?
|
|
731
|
+
// Simple RAG syntax for natural language questions
|
|
732
|
+
simple_rag_query: "RAG" string ("AT" "NAMESPACE" identifier)?
|
|
733
|
+
|
|
734
|
+
// RAG GENERATE with CONTEXT FROM
|
|
735
|
+
rag_generate: "RAG" "GENERATE" (string | variable) ("USING" "MODEL" (string | variable))? ("CONTEXT" "FROM" variable)? ("PARAMETERS" "(" parameter_dict ")")? ("GUARDRAILS" "{" parameter_dict "}")? ("STORE" "RESULT" ("IN" variable)?)?
|
|
736
|
+
|
|
737
|
+
// RAG QUERY one-shot
|
|
738
|
+
rag_query_one_shot: "RAG" "QUERY" (string | variable) "IN" identifier ("USING" "{" parameter_dict "}")? ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "RESULT" "IN" variable)?
|
|
739
|
+
|
|
740
|
+
// EVALUATE RAG
|
|
741
|
+
evaluate_rag: "EVAL" "RAG" "ON" (variable | identifier) ("USING" ("MODEL" (string | variable) | parameter_dict))? ("PARAMETERS" "(" parameter_dict ")")? ("STORE" "IN" "COLLECTION" identifier)?
|
|
742
|
+
|
|
743
|
+
// Unified AIQL Query Definitions (Placeholder - will be fully implemented after grammar is tested)
|
|
744
|
+
unified_aiql_query: simple_rag_query
|
|
745
|
+
|
|
746
|
+
// Hybrid retrieval parameters
|
|
747
|
+
hybrid_spec: "HYBRID" "(" hybrid_params ")"
|
|
748
|
+
hybrid_params: hybrid_param ("," hybrid_param)*
|
|
749
|
+
hybrid_param: identifier "=" number
|
|
750
|
+
|
|
751
|
+
// Augmentation (entity/claim/citation enrichment)
|
|
752
|
+
augment_spec: "WITH" augment_method "(" augment_params? ")"
|
|
753
|
+
augment_method: "ENTITIES" | "CLAIMS" | "CITATIONS"
|
|
754
|
+
augment_params: augment_param ("," augment_param)*
|
|
755
|
+
augment_param: identifier "=" (number | string)
|
|
756
|
+
|
|
757
|
+
// Grounding (convert to context window)
|
|
758
|
+
ground_spec: "INTO" identifier "(" ground_params? ")"
|
|
759
|
+
ground_params: ground_param ("," ground_param)*
|
|
760
|
+
ground_param: identifier "=" (number | string)
|
|
761
|
+
|
|
762
|
+
// Return specification
|
|
763
|
+
return_spec: identifier_list
|
|
764
|
+
|
|
765
|
+
// Legacy retrieval (maintained for backward compatibility)
|
|
766
|
+
retrieve_query: "RETRIEVE" identifier (where_stage)?
|
|
767
|
+
sparse_match: "SPARSE MATCH" "(" (string | variable) ")" ("IN" identifier | "AS" identifier)? ("LIMIT" number)?
|
|
768
|
+
dense_match: "DENSE MATCH" string ("MODEL" identifier)? ("IN" identifier | "AS" identifier)? ("LIMIT" number)? | "DENSE MATCH" "(" (string | variable) ("," "MODEL" "=" (string | identifier))? ")" ("IN" identifier | "AS" identifier)? ("LIMIT" number)?
|
|
769
|
+
hybrid_match: "HYBRID MATCH" "(" (string | variable) ("," "SPARSE_WEIGHT" "=" number)? ("," "DENSE_WEIGHT" "=" number)? ("," "DENSE_MODEL" "=" identifier)? ")" ("IN" identifier | "AS" identifier)? ("LIMIT" number)?
|
|
770
|
+
rerank_stage: "RERANK" "USING" identifier ("LIMIT" number)?
|
|
771
|
+
|
|
772
|
+
weights: weight_spec ("," weight_spec)*
|
|
773
|
+
weight_spec: identifier "=" number
|
|
774
|
+
|
|
775
|
+
// Generation stages
|
|
776
|
+
// LLM Generation and Prompt Management
|
|
777
|
+
generation_stage: generate_with_llm | generate_with_prompt_template | register_prompt_stmt | list_prompts_stmt
|
|
778
|
+
|
|
779
|
+
// Generate using LLM provider
|
|
780
|
+
generate_with_llm: "GENERATE" "USING" llm_provider llm_spec ("PROMPT" string)? ("SYSTEM" string)? ("WITH" llm_options)?
|
|
781
|
+
|
|
782
|
+
llm_provider: "OPENAI" | "ANTHROPIC" | "GOOGLE" | "OLLAMA" | identifier
|
|
783
|
+
llm_spec: "MODEL" identifier ("TEMPERATURE" number)? ("MAX_TOKENS" number)?
|
|
784
|
+
llm_options: llm_option ("," llm_option)*
|
|
785
|
+
llm_option: identifier "=" value
|
|
786
|
+
|
|
787
|
+
// Generate using named prompt template
|
|
788
|
+
generate_with_prompt_template: "GENERATE" "WITH" "PROMPT" identifier ("VARIABLES" prompt_variables)?
|
|
789
|
+
prompt_variables: "{" prompt_variable ("," prompt_variable)* "}"
|
|
790
|
+
prompt_variable: identifier ":" value
|
|
791
|
+
|
|
792
|
+
// Register new prompt template
|
|
793
|
+
register_prompt_stmt: "REGISTER" "PROMPT" identifier "TYPE" prompt_type "TEMPLATE" string "VARIABLES" "[" identifier_list "]"
|
|
794
|
+
prompt_type: "RAG" | "AGENT" | "EXTRACTION" | "SUMMARIZATION" | "CUSTOM"
|
|
795
|
+
|
|
796
|
+
// List available prompts
|
|
797
|
+
list_prompts_stmt: "LIST" "PROMPTS" ("TYPE" prompt_type)?
|
|
798
|
+
|
|
799
|
+
context_spec: context_assignment ("," context_assignment)*
|
|
800
|
+
context_assignment: identifier "=" (string | variable | identifier)
|
|
801
|
+
|
|
802
|
+
// Agent Orchestration
|
|
803
|
+
agent_stage: plan_agent_legacy | execute_agent_legacy | agent_task | agent_tool_use | call_agent
|
|
804
|
+
plan_agent_legacy: "PLAN" "AGENT" string ("INPUT" agent_input)? ("TOOLS" tool_list_legacy)? ("POLICY" string)?
|
|
805
|
+
agent_input: identifier | variable
|
|
806
|
+
tool_list_legacy: "[" string ("," string)* "]"
|
|
807
|
+
execute_agent_legacy: "EXECUTE" ("RETURN" return_list)?
|
|
808
|
+
return_list: identifier ("," identifier)*
|
|
809
|
+
agent_task: "CREATE" "TASK" string ("FOR" identifier)? ("WITH" task_params)?
|
|
810
|
+
agent_tool_use: "USE" "TOOL" identifier "WITH" tool_params
|
|
811
|
+
call_agent: "CALL" "AGENT" string "WITH" agent_params (upsert_clause)? (provenance_clause)?
|
|
812
|
+
agent_params: "{" agent_param ("," agent_param)* "}"
|
|
813
|
+
agent_param: string ":" (string | number | boolean | variable)
|
|
814
|
+
task_params: task_param ("," task_param)*
|
|
815
|
+
task_param: identifier "=" (string | number | boolean)
|
|
816
|
+
tool_params: tool_param ("," tool_param)*
|
|
817
|
+
tool_param: identifier "=" (string | number | boolean | list)
|
|
818
|
+
|
|
819
|
+
// Upsert and Provenance for agent operations
|
|
820
|
+
upsert_clause: "UPSERT" "INTO" "GRAPH" (upsert_options)?
|
|
821
|
+
upsert_options: identifier "=" (string | variable)
|
|
822
|
+
provenance_clause: "WITH" "PROVENANCE" "(" provenance_params ")"
|
|
823
|
+
provenance_params: provenance_param ("," provenance_param)*
|
|
824
|
+
provenance_param: identifier "=" (string | variable)
|
|
825
|
+
|
|
826
|
+
// Governance and Policy
|
|
827
|
+
governance_stage: set_policy | set_namespace | redact_clause | create_policy | audit_query
|
|
828
|
+
set_policy: "SET" "POLICY" identifier "=" string
|
|
829
|
+
set_namespace: "SET" "NAMESPACE" string
|
|
830
|
+
redact_clause: "WITH" "REDACT" "(" redact_params ")"
|
|
831
|
+
redact_params: redact_param ("," redact_param)*
|
|
832
|
+
redact_param: identifier ("," "mask" "=" string)?
|
|
833
|
+
create_policy: "CREATE" "POLICY" identifier "AS" policy_body
|
|
834
|
+
policy_body: "{" policy_rules "}"
|
|
835
|
+
policy_rules: policy_rule ("," policy_rule)*
|
|
836
|
+
policy_rule: "IF" condition "THEN" policy_action
|
|
837
|
+
policy_action: "ALLOW" | "DENY" | "REDACT" | "LOG"
|
|
838
|
+
audit_query: "SHOW" "AUDIT" "LOG" ("WHERE" condition)? ("LIMIT" number)?
|
|
839
|
+
|
|
840
|
+
// Web Integration - Direct web access for Agentic RAG
|
|
841
|
+
web_stage: web_fetch | web_search | web_api | web_hybrid_retrieve
|
|
842
|
+
web_fetch: "WEB" "(" (string | variable) ")" ("AS" identifier)? (web_options)?
|
|
843
|
+
web_search: "WEB SEARCH" (string | variable) ("OPTIONS" web_search_options)? ("AS" identifier)?
|
|
844
|
+
web_api: "WEB API" (string | variable) ("WITH" web_api_options)? ("AS" identifier)?
|
|
845
|
+
web_hybrid_retrieve: "RETRIEVE" retrieve_sources where_stage? ("GROUND" ground_spec)?
|
|
846
|
+
|
|
847
|
+
// Web search options
|
|
848
|
+
web_search_options: "{" web_search_option ("," web_search_option)* "}"
|
|
849
|
+
web_search_option: identifier ":" (string | number | boolean)
|
|
850
|
+
|
|
851
|
+
// Web API options
|
|
852
|
+
web_api_options: "{" web_api_option ("," web_api_option)* "}"
|
|
853
|
+
web_api_option: identifier ":" (string | number | boolean | web_headers | web_params)
|
|
854
|
+
web_headers: "HEADERS" "{" string ":" string ("," string ":" string)* "}"
|
|
855
|
+
web_params: "PARAMS" "{" string ":" (string | number | boolean) ("," string ":" (string | number | boolean))* "}"
|
|
856
|
+
|
|
857
|
+
// Web options
|
|
858
|
+
web_options: "WITH" "(" web_option_list ")"
|
|
859
|
+
web_option_list: web_option ("," web_option)*
|
|
860
|
+
web_option: identifier "=" (string | number | boolean)
|
|
861
|
+
|
|
862
|
+
// Retrieve from multiple sources (graph + web)
|
|
863
|
+
retrieve_sources: retrieve_source ("," retrieve_source)*
|
|
864
|
+
retrieve_source: "GRAPH" identifier | "WEB" "(" (string | variable) ")" | "WEB API" "(" (string | variable) ")"
|
|
865
|
+
|
|
866
|
+
// Evaluation and Metrics
|
|
867
|
+
eval_stage: "EVAL" ("USING" metric_spec)? ("COMPARE" comparison_spec)? ("SAVE" "AS" string)?
|
|
868
|
+
metric_spec: "METRICS" "(" metric_list ")"
|
|
869
|
+
// metric_list: metric ("," metric)*
|
|
870
|
+
metric: metric_at_k | metric_with_params | identifier
|
|
871
|
+
metric_at_k: identifier "@" number
|
|
872
|
+
metric_with_params: identifier "(" metric_params ")"
|
|
873
|
+
metric_params: metric_param ("," metric_param)*
|
|
874
|
+
metric_param: identifier "=" (number | string | boolean)
|
|
875
|
+
comparison_spec: "WITH" comparison_target
|
|
876
|
+
comparison_target: "RUN" string | "BASELINE" identifier
|
|
877
|
+
|
|
878
|
+
// Graph traversal
|
|
879
|
+
traverse_stage: "TRAVERSE" strategy? traverse_spec strategy_suffix? traversal_options? as_of_clause? where_stage? return_clause? ("ORDER" "BY" order_by_clause)?
|
|
880
|
+
return_clause: "RETURN" return_expression ("," return_expression)*
|
|
881
|
+
return_expression: return_function | qualified_identifier ("AS" identifier)? | variable | "*" | typed_node_ref ("AS" identifier)?
|
|
882
|
+
return_function: "PATH_LENGTH" | "TOTAL_WEIGHT" | "PATH_COST" | "HOP_COUNT"
|
|
883
|
+
|
|
884
|
+
// Simple RETURN stage for pipelines
|
|
885
|
+
return_stage: "RETURN" (variable | "*" | qualified_identifier)
|
|
886
|
+
strategy: DFS | BFS
|
|
887
|
+
strategy_suffix: "STRATEGY" (DFS | BFS)
|
|
888
|
+
traversal_options: traversal_option+
|
|
889
|
+
traversal_option: "MAX DEPTH" number | "MIN DEPTH" number | LIMIT number
|
|
890
|
+
traverse_spec: inline_traversal | verbose_traversal | recursive_traversal | simple_traversal | from_traversal
|
|
891
|
+
|
|
892
|
+
// Inline chain syntax: Node:a -EDGE-> Node:b -EDGE-> Node:c
|
|
893
|
+
inline_traversal: node_ref ("-" edge_ref "->" node_ref)+
|
|
894
|
+
node_ref: (identifier | typed_node_ref) ("AS" identifier)?
|
|
895
|
+
typed_node_ref: identifier ":" identifier
|
|
896
|
+
edge_ref: identifier ("AS" identifier)? | "CONTAINS" ("AS" identifier)? | "RELATIONSHIP" ("AS" identifier)? | "HAS_CHUNK" ("AS" identifier)? | "MENTIONS" ("AS" identifier)? | "SIMILAR" ("AS" identifier)? | "RELATED_TO" ("AS" identifier)?
|
|
897
|
+
|
|
898
|
+
// Verbose syntax: SRC Node AS a OUTGOING EDGE DEST Node AS b OR Node VIA EDGE Edge DEST Node
|
|
899
|
+
// Also support: SRC Node -EDGE-> Node (mixed format)
|
|
900
|
+
// Support both DEST and TO for compatibility
|
|
901
|
+
verbose_traversal: "SRC" node_ref direction edge_ref ("DEST" | "TO") node_ref | "SRC" node_ref direction edge_ref ("DEST" | "TO") node_ref chained_hops | "SRC" node_ref ("-" edge_ref "->" node_ref)+ | node_ref "VIA" "EDGE" traverse_edge_pattern ("DEST" | "TO") node_ref ("STRATEGY" (DFS | BFS))?
|
|
902
|
+
chained_hops: direction edge_ref "DEST" node_ref chained_hops | direction edge_ref "DEST" node_ref
|
|
903
|
+
direction: "OUTGOING" | "INCOMING"
|
|
904
|
+
traverse_edge_pattern: edge_ref | edge_wildcard | recursive_edge_pattern
|
|
905
|
+
edge_wildcard: "*"
|
|
906
|
+
|
|
907
|
+
// Recursive patterns: Node AS p VIA EDGE CITE+ TO Node AS p2
|
|
908
|
+
recursive_traversal: node_ref "VIA" "EDGE" recursive_edge_pattern "TO" node_ref
|
|
909
|
+
recursive_edge_pattern: (identifier | "*") quantifier
|
|
910
|
+
quantifier: "+" | "*" | "?" | range_quantifier
|
|
911
|
+
range_quantifier: "{" number "}" | "{" number "," number "}" | "{" number ",}" | "{," number "}"
|
|
912
|
+
|
|
913
|
+
// Simple traversal syntax: SRC Person WHERE condition DEPTH number
|
|
914
|
+
simple_traversal: "SRC" node_ref where_stage? ("DEPTH" number)?
|
|
915
|
+
|
|
916
|
+
// FROM traversal: FROM NodeType EDGE_TYPE -> NodeType
|
|
917
|
+
from_traversal: "FROM" identifier "TO" identifier where_stage? ("DEPTH" number)?
|
|
918
|
+
| "FROM" identifier "TO" identifier ("DEPTH" number)? where_stage?
|
|
919
|
+
| "FROM" identifier ("DEPTH" number)? where_stage?
|
|
920
|
+
| "FROM" identifier ("MAX" "DEPTH" number)? where_stage?
|
|
921
|
+
| "FROM" identifier edge_ref "->" identifier where_stage? ("DEPTH" number)?
|
|
922
|
+
| "FROM" identifier where_stage edge_ref "->" identifier where_stage? ("DEPTH" number)?
|
|
923
|
+
| "FROM" identifier edge_ref "->" identifier chained_from_traversal
|
|
924
|
+
| "FROM" identifier where_stage edge_ref "->" identifier chained_from_traversal
|
|
925
|
+
chained_from_traversal: edge_ref "->" identifier where_stage? | edge_ref "->" identifier chained_from_traversal
|
|
926
|
+
|
|
927
|
+
// Global strategy declaration
|
|
928
|
+
global_strategy: "STRATEGY" ("DFS" | "BFS")
|
|
929
|
+
|
|
930
|
+
// Filtering and projection
|
|
931
|
+
where_stage: "WHERE" condition
|
|
932
|
+
condition: or_condition
|
|
933
|
+
or_condition: and_condition ("OR" and_condition)*
|
|
934
|
+
and_condition: simple_condition ("AND" simple_condition)*
|
|
935
|
+
simple_condition: "(" condition ")" | "NOT" simple_condition | (qualified_identifier | aggregation_function) operator value | qualified_identifier BETWEEN value "AND" value | qualified_identifier "SIMILAR" "TO" value | aggregation_function operator value
|
|
936
|
+
|
|
937
|
+
// AT temporal clause for time-travel queries (using AT instead of AS OF to avoid ambiguity)
|
|
938
|
+
as_of_clause: "AT" as_of_spec
|
|
939
|
+
as_of_spec: "TIMESTAMP" (string | variable)
|
|
940
|
+
| "COMMIT" (string | variable)
|
|
941
|
+
| "RUN" (string | variable)
|
|
942
|
+
|
|
943
|
+
for_system_time: "FOR" "SYSTEM_TIME" system_time_spec
|
|
944
|
+
system_time_spec: "ALL"
|
|
945
|
+
| "FROM" (string | variable) "TO" (string | variable)
|
|
946
|
+
| "BETWEEN" (string | variable) "AND" (string | variable)
|
|
947
|
+
| "CONTAINED" "IN" "(" (string | variable) "," (string | variable) ")"
|
|
948
|
+
|
|
949
|
+
EQ: "="
|
|
950
|
+
NE: "!="
|
|
951
|
+
LT: "<"
|
|
952
|
+
GT: ">"
|
|
953
|
+
LE: "<="
|
|
954
|
+
GE: ">="
|
|
955
|
+
IN: "IN"
|
|
956
|
+
CONTAINS: "CONTAINS"
|
|
957
|
+
STARTS: "STARTS"
|
|
958
|
+
ENDS: "ENDS"
|
|
959
|
+
|
|
960
|
+
operator: EQ | NE | LT | GT | LE | GE | IN | CONTAINS | "STARTS" "WITH" | "ENDS" "WITH" | STARTS | ENDS | SIMILAR | BETWEEN | "NOT" "IN"
|
|
961
|
+
|
|
962
|
+
// Unified SELECT stage that handles all query types (basic, aggregation, group by, having)
|
|
963
|
+
select_stage: "SELECT" projection_list ("FROM" from_clause)? (as_of_clause | for_system_time)? ("WHERE" where_clause)? ("GROUP" "BY" group_by_clause)? ("HAVING" having_clause)? ("ORDER" "BY" order_by_clause)? ("LIMIT" limit_clause)?
|
|
964
|
+
|
|
965
|
+
having_clause: having_condition ("AND" having_condition | "OR" having_condition)*
|
|
966
|
+
having_condition: (qualified_identifier | aggregation_function) operator value
|
|
967
|
+
projection_list: projection ("," projection)*
|
|
968
|
+
projection: "*"
|
|
969
|
+
| "NODE" qualified_identifier ("AS" identifier)? // Explicit node selection
|
|
970
|
+
| "EDGE" qualified_identifier ("AS" identifier)? // Explicit edge selection
|
|
971
|
+
| "PROPERTY" qualified_identifier ("AS" identifier)? // Explicit property (optional)
|
|
972
|
+
| qualified_identifier ("AS" identifier)? // Property (backward compatible)
|
|
973
|
+
| aggregation_function ("AS" identifier)? // Aggregation
|
|
974
|
+
from_clause: identifier ("AS" identifier)? | "(" identifier ("AS" identifier)? ")"
|
|
975
|
+
where_clause: condition
|
|
976
|
+
select_condition: qualified_identifier operator value
|
|
977
|
+
|
|
978
|
+
// Qualified identifier for property access (e.g., p.name, node.property)
|
|
979
|
+
qualified_identifier: identifier ("." identifier)? | typed_node_ref ("." identifier)?
|
|
980
|
+
|
|
981
|
+
// Aggregation functions with explicit type support
|
|
982
|
+
aggregation_function: COUNT "(" count_target ")"
|
|
983
|
+
| SUM "(" agg_target ")"
|
|
984
|
+
| AVG "(" agg_target ")"
|
|
985
|
+
| MIN "(" agg_target ")"
|
|
986
|
+
| MAX "(" agg_target ")"
|
|
987
|
+
| DISTINCT "(" identifier ")"
|
|
988
|
+
| UNIQUE "(" identifier ")"
|
|
989
|
+
| CONCAT "(" identifier ")"
|
|
990
|
+
| JOIN "(" identifier ")"
|
|
991
|
+
| DEGREE "(" ("*" | identifier)? ")"
|
|
992
|
+
|
|
993
|
+
// Count target - explicit types for clarity
|
|
994
|
+
count_target: "*" // Count all
|
|
995
|
+
| "NODE" qualified_identifier // Count nodes explicitly
|
|
996
|
+
| "EDGE" qualified_identifier // Count edges explicitly
|
|
997
|
+
| "DISTINCT" qualified_identifier // Count distinct values
|
|
998
|
+
| qualified_identifier // Count property values (backward compatible)
|
|
999
|
+
|
|
1000
|
+
// Aggregation target for SUM/AVG/MIN/MAX
|
|
1001
|
+
agg_target: qualified_identifier | graph_native_arg
|
|
1002
|
+
|
|
1003
|
+
// Graph-native arguments
|
|
1004
|
+
graph_native_arg: "OUTGOING" | "INCOMING" | "CONNECTIONS" | "DEGREE" | "OUT" | "INCOMING_DIR" | "CONNECTED"
|
|
1005
|
+
|
|
1006
|
+
// Grouping and ordering
|
|
1007
|
+
group_by_clause: qualified_identifier ("," qualified_identifier)*
|
|
1008
|
+
order_by_clause: order_spec ("," order_spec)* ("LIMIT" number)?
|
|
1009
|
+
order_spec: qualified_identifier ("ASC" | "DESC")?
|
|
1010
|
+
limit_clause: number
|
|
1011
|
+
|
|
1012
|
+
// Analytics stages
|
|
1013
|
+
analytics_stage: pagerank_stage | shortest_path_stage | community_stage | centrality_stage | betweenness_centrality | closeness_centrality | degree_centrality | count_stage | aggregate_stage | graph_summary_stage
|
|
1014
|
+
|
|
1015
|
+
// Graph summary for analytics
|
|
1016
|
+
graph_summary_stage: "GRAPH" "SUMMARY" ("ON" (identifier | "(" identifier_list ")"))? ("RETURN" "{" summary_field_list "}")?
|
|
1017
|
+
summary_field_list: summary_field ("," summary_field)*
|
|
1018
|
+
summary_field: identifier ":" aggregation_expression
|
|
1019
|
+
aggregation_expression: aggregation_function | qualified_identifier "." aggregation_function
|
|
1020
|
+
|
|
1021
|
+
// Simple COUNT operation
|
|
1022
|
+
count_stage: "COUNT" identifier ("WHERE" condition)?
|
|
1023
|
+
aggregate_stage: "AGGREGATE" identifier "BY" identifier ("WHERE" condition)?
|
|
1024
|
+
pagerank_stage: "PAGERANK" ("(" ")")? ("ON" identifier)? ("ITERATIONS" number)?
|
|
1025
|
+
shortest_path_stage: "SHORTEST PATH" "(" "SOURCE" "=" (string | variable) "," "TARGET" "=" (string | variable) ("," "EDGE_TYPES" "=" "[" string_list "]")? ")" | "SHORTEST PATH" "SRC" (string | variable) "DEST" (string | variable) ("MAX_DEPTH" number)? ("WEIGHT_FIELD" identifier)?
|
|
1026
|
+
community_stage: "COMMUNITY DETECTION" ("(" ("METHOD" "=" string | "ALGORITHM" "=" string)? ")")? ("ON" identifier)? | "COMMUNITY DETECTION" "ALGORITHM" (string | identifier) ("ON" identifier)?
|
|
1027
|
+
centrality_stage: "CENTRALITY" ("(" (centrality_param ("," centrality_param)*)? ")")? ("ON" identifier)?
|
|
1028
|
+
betweenness_centrality: "BETWEENNESS CENTRALITY" ("(" (centrality_param ("," centrality_param)*)? ")")? ("ON" identifier)?
|
|
1029
|
+
closeness_centrality: "CLOSENESS CENTRALITY" ("(" (centrality_param ("," centrality_param)*)? ")")? ("ON" identifier)?
|
|
1030
|
+
degree_centrality: "DEGREE CENTRALITY" ("(" (centrality_param ("," centrality_param)*)? ")")? ("ON" identifier)?
|
|
1031
|
+
centrality_param: ("METHOD" | "TYPE") "=" string
|
|
1032
|
+
|
|
1033
|
+
string_list: string ("," string)*
|
|
1034
|
+
|
|
1035
|
+
// Indexing and sharding
|
|
1036
|
+
index_stage: "CREATE" "INDEX" identifier "ON" identifier "(" identifier ")" "TYPE" index_type ("MODEL" "=" string)?
|
|
1037
|
+
index_type: "SPARSE" | "DENSE" | "VECTOR" | "GRAPH" | "TEMPORAL" | "COMPOSITE"
|
|
1038
|
+
|
|
1039
|
+
shard_stage: "SHARD" "GRAPH" identifier "BY" "(" identifier ")"
|
|
1040
|
+
|
|
1041
|
+
// Schema and entity identification
|
|
1042
|
+
schema_stage: match_entity_stage | list_entities_stage | show_stage | describe_stage
|
|
1043
|
+
match_entity_stage: "MATCH" entity_pattern (entity_return_clause | return_clause)?
|
|
1044
|
+
list_entities_stage: "LIST" "ENTITIES" | "SCHEMA"
|
|
1045
|
+
show_stage: "SHOW" show_target ("IN" "NAMESPACE" identifier)? ("IN" "COLLECTION" identifier)?
|
|
1046
|
+
describe_stage: "DESCRIBE" describe_target
|
|
1047
|
+
|
|
1048
|
+
// Entity patterns for MATCH
|
|
1049
|
+
entity_pattern: node_pattern | edge_pattern
|
|
1050
|
+
node_pattern: "NODE" identifier ("AS" identifier)?
|
|
1051
|
+
edge_pattern: "EDGE" identifier ("AS" identifier)?
|
|
1052
|
+
|
|
1053
|
+
// Return clauses for entity information (renamed to avoid conflict)
|
|
1054
|
+
entity_return_clause: "RETURN" entity_return_expression ("AS" identifier)?
|
|
1055
|
+
entity_return_expression: count_expression | properties_expression | schema_expression | wildcard_expression | qualified_identifier
|
|
1056
|
+
count_expression: COUNT_STAR | COUNT_ID identifier ")"
|
|
1057
|
+
properties_expression: "properties"
|
|
1058
|
+
schema_expression: "schema"
|
|
1059
|
+
wildcard_expression: "*"
|
|
1060
|
+
|
|
1061
|
+
// Show and Describe targets
|
|
1062
|
+
show_target: show_graph | show_node | show_edge | show_index | show_model | show_prompt | show_namespaces | show_pipelines | show_collections | show_schema | show_stats
|
|
1063
|
+
show_graph: "GRAPH" | "GRAPHS"
|
|
1064
|
+
show_node: "NODE" | "NODES"
|
|
1065
|
+
show_stats: "STATS" | "STATISTICS"
|
|
1066
|
+
show_edge: "EDGE" | "EDGES"
|
|
1067
|
+
show_index: "INDEX" | "INDEXES"
|
|
1068
|
+
show_model: "MODEL"
|
|
1069
|
+
show_prompt: "PROMPT"
|
|
1070
|
+
show_namespaces: "NAMESPACES"
|
|
1071
|
+
show_pipelines: "PIPELINE" | "PIPELINES"
|
|
1072
|
+
show_collections: "COLLECTION" | "COLLECTIONS"
|
|
1073
|
+
show_schema: "SCHEMA"
|
|
1074
|
+
|
|
1075
|
+
describe_target: describe_graph | describe_node | describe_edge
|
|
1076
|
+
describe_graph: "GRAPH" identifier
|
|
1077
|
+
describe_node: "NODE" identifier | "NODE" "TYPE" identifier | "NODE" "TYPE" identifier
|
|
1078
|
+
describe_edge: "EDGE" identifier | "EDGE" "TYPE" identifier
|
|
1079
|
+
|
|
1080
|
+
// Model and Prompt declarations
|
|
1081
|
+
model_stage: "MODEL" identifier "AS" identifier model_config
|
|
1082
|
+
model_config: model_param+
|
|
1083
|
+
model_param: identifier "=" (string | number | variable)
|
|
1084
|
+
|
|
1085
|
+
prompt_stage: "PROMPT" identifier "AS" string
|
|
1086
|
+
|
|
1087
|
+
// Advanced traversal strategies
|
|
1088
|
+
traversal_strategy: "STRATEGY" ("DFS" | "BFS")
|
|
1089
|
+
|
|
1090
|
+
// Namespace and access control
|
|
1091
|
+
namespace_stage: "CREATE" "NAMESPACE" identifier | "USE" "NAMESPACE" identifier
|
|
1092
|
+
grant_stage: "GRANT" grant_permission "ON" grant_target "TO" identifier
|
|
1093
|
+
grant_permission: "READ" | "WRITE" | "EXECUTE"
|
|
1094
|
+
grant_target: "GRAPH" identifier | "NODE" identifier | "EDGE" identifier
|
|
1095
|
+
|
|
1096
|
+
// Schema definitions
|
|
1097
|
+
define_node_stage: "DEFINE" "NODE" "TYPE" identifier "(" node_field_list ")"
|
|
1098
|
+
define_edge_stage: "DEFINE" "EDGE" "TYPE" identifier "(" edge_field_list ")" "SRC" identifier "DEST" identifier
|
|
1099
|
+
node_field_list: node_field ("," node_field)*
|
|
1100
|
+
edge_field_list: edge_field ("," edge_field)*
|
|
1101
|
+
node_field: identifier field_type field_constraints?
|
|
1102
|
+
edge_field: identifier field_type field_constraints?
|
|
1103
|
+
field_type: "TEXT" | "INT" | "FLOAT" | "BOOLEAN" | "DATE"
|
|
1104
|
+
field_constraints: constraint+
|
|
1105
|
+
constraint: "UNIQUE" | "NOT" "NULL" | "PRIMARY" "KEY"
|
|
1106
|
+
|
|
1107
|
+
// Views and materialized views
|
|
1108
|
+
view_stage: "CREATE" "VIEW" identifier "AS" string
|
|
1109
|
+
// Materialized Context Views - Pre-computed RAG contexts for fast retrieval
|
|
1110
|
+
materialized_view_stage: create_materialized_view | refresh_materialized_view | drop_materialized_view
|
|
1111
|
+
create_materialized_view: "CREATE" "MATERIALIZED" ("CONTEXT")? "VIEW" identifier "AS" materialized_view_body ("REFRESH" refresh_trigger)?
|
|
1112
|
+
materialized_view_body: retrieval_stage ("GROUND" "INTO" "Context" "(" context_params ")")?
|
|
1113
|
+
context_params: context_param ("," context_param)*
|
|
1114
|
+
context_param: identifier "=" (number | string | boolean)
|
|
1115
|
+
refresh_trigger: "ON" refresh_event | "EVERY" time_interval
|
|
1116
|
+
refresh_event: "chunk_insert" | "chunk_update" | "chunk_delete" | "node_change" | "edge_change"
|
|
1117
|
+
time_interval: number time_unit
|
|
1118
|
+
time_unit: "SECOND" | "SECONDS" | "MINUTE" | "MINUTES" | "HOUR" | "HOURS" | "DAY" | "DAYS"
|
|
1119
|
+
refresh_materialized_view: "REFRESH" "MATERIALIZED" "VIEW" identifier
|
|
1120
|
+
drop_materialized_view: "DROP" "MATERIALIZED" "VIEW" identifier
|
|
1121
|
+
|
|
1122
|
+
// Enhanced Sophisticated RAG Pipeline Extensions
|
|
1123
|
+
rag_pipeline_stage: "RAG" "PIPELINE" string "{" rag_pipeline_body "}"
|
|
1124
|
+
rag_pipeline_body: rag_stage ("THEN" rag_stage)*
|
|
1125
|
+
rag_stage: source_ingestion_stage | file_reader_stage | multimodal_extraction_stage | smart_chunking_stage | embedding_stage | graph_construction_stage | indexing_stage | validation_stage | retrieval_system_stage | evaluation_stage | persistence_stage
|
|
1126
|
+
|
|
1127
|
+
// Source Ingestion with File Type Detection
|
|
1128
|
+
source_ingestion_stage: "LOAD" source_type source_path ("INTO" identifier)? ("WITH" file_type_detection)?
|
|
1129
|
+
source_type: "FOLDER" | "WEB" | "API" | "DATABASE" | "STREAM"
|
|
1130
|
+
source_path: string | variable
|
|
1131
|
+
file_type_detection: "AUTO_DETECT" | "SPECIFY" file_types
|
|
1132
|
+
file_types: file_type ("AND" file_type)*
|
|
1133
|
+
file_type: "PDF" | "TXT" | "MD" | "DOCX" | "HTML" | "JSON" | "CSV" | "XML" | "IMAGE" | "AUDIO" | "VIDEO" | "PRESENTATION" | "SPREADSHEET"
|
|
1134
|
+
|
|
1135
|
+
// File-Type-Based Readers
|
|
1136
|
+
file_reader_stage: "READ" "WITH" reader_strategy ("FOR" file_types)?
|
|
1137
|
+
reader_strategy: "PDF_READER" | "IMAGE_READER" | "AUDIO_READER" | "VIDEO_READER" | "TEXT_READER" | "TABLE_READER" | "OCR_READER" | "SPEECH_READER" | "MULTIMODAL_READER"
|
|
1138
|
+
|
|
1139
|
+
// Enhanced Multimodal Extraction
|
|
1140
|
+
multimodal_extraction_stage: "EXTRACT" "MULTIMODAL" extraction_types ("WITH" extraction_config)?
|
|
1141
|
+
extraction_types: extraction_type ("AND" extraction_type)*
|
|
1142
|
+
extraction_type: "ENTITIES" | "TABLES" | "OCR" | "IMAGES" | "AUDIO" | "VIDEO" | "SPEECH" | "OBJECTS" | "FACES" | "SCENES" | "IMAGE_EXPLANATION" | "TABLE_STRUCTURE" | "DOCUMENT_LAYOUT"
|
|
1143
|
+
extraction_config: "{" extraction_param ("," extraction_param)* "}"
|
|
1144
|
+
extraction_param: identifier ("=" | ":") (string | number | boolean)
|
|
1145
|
+
|
|
1146
|
+
// Enhanced Smart Chunking with Strategy Selection
|
|
1147
|
+
smart_chunking_stage: "CHUNK" "USING" chunking_strategy chunking_params? ("WITH" chunking_config)?
|
|
1148
|
+
chunking_strategy: "SMART" | "FIXED_SIZE" | "SEMANTIC" | "SENTENCE" | "PARAGRAPH" | "SECTION" | "TABLE_AWARE" | "SLIDING_WINDOW" | "LLM_TOPIC_AWARE" | "FILE_TYPE_AWARE" | "CONTENT_AWARE"
|
|
1149
|
+
chunking_params: "{" chunking_param ("," chunking_param)* "}"
|
|
1150
|
+
chunking_param: identifier ("=" | ":") (string | number | boolean)
|
|
1151
|
+
chunking_config: "{" chunking_config_param ("," chunking_config_param)* "}"
|
|
1152
|
+
chunking_config_param: identifier ("=" | ":") (string | number | boolean)
|
|
1153
|
+
|
|
1154
|
+
// Enhanced Graph Construction
|
|
1155
|
+
graph_construction_stage: "CREATE" "GRAPH" "RELATIONSHIPS" relationship_specs? ("WITH" relationship_config)?
|
|
1156
|
+
relationship_specs: relationship_spec ("AND" relationship_spec)*
|
|
1157
|
+
relationship_spec: "DOCUMENT_CHUNK" | "CHUNK_ENTITY" | "ENTITY_ENTITY" | "MULTIMODAL" | "SEMANTIC_SIMILARITY" | "TABLE_RELATIONSHIP" | "IMAGE_RELATIONSHIP" | "AUDIO_RELATIONSHIP" | "VIDEO_RELATIONSHIP"
|
|
1158
|
+
relationship_config: "{" relationship_param ("," relationship_param)* "}"
|
|
1159
|
+
relationship_param: identifier ("=" | ":") (string | number | boolean)
|
|
1160
|
+
|
|
1161
|
+
// Enhanced Indexing
|
|
1162
|
+
indexing_stage: "CREATE" "INDEX" "ON" identifier "WHERE" condition "FOR" identifier ("WITH" index_config)?
|
|
1163
|
+
index_config: "{" index_param ("," index_param)* "}"
|
|
1164
|
+
index_param: identifier ("=" | ":") (string | number | boolean)
|
|
1165
|
+
|
|
1166
|
+
// Retrieval System
|
|
1167
|
+
retrieval_system_stage: "RETRIEVAL" "SYSTEM" retrieval_config?
|
|
1168
|
+
retrieval_config: "{" retrieval_param ("," retrieval_param)* "}"
|
|
1169
|
+
retrieval_param: identifier ("=" | ":") (string | number | boolean)
|
|
1170
|
+
|
|
1171
|
+
// Evaluation System
|
|
1172
|
+
evaluation_stage: "EVALUATE" "PIPELINE" evaluation_config?
|
|
1173
|
+
evaluation_config: "{" evaluation_param ("," evaluation_param)* "}"
|
|
1174
|
+
evaluation_param: identifier ("=" | ":") (string | number | boolean)
|
|
1175
|
+
|
|
1176
|
+
// Enhanced Validation
|
|
1177
|
+
validation_stage: "VALIDATE" "PIPELINE" validation_rules? ("WITH" validation_config)?
|
|
1178
|
+
validation_rules: validation_rule ("," validation_rule)*
|
|
1179
|
+
validation_rule: "QUALITY_THRESHOLD" | "CONFIDENCE_THRESHOLD" | "COMPLETENESS_CHECK" | "CONSISTENCY_CHECK" | "ACCURACY_CHECK" | "COVERAGE_CHECK" | "RETRIEVAL_QUALITY" | "EXTRACTION_QUALITY"
|
|
1180
|
+
validation_config: "{" validation_param ("," validation_param)* "}"
|
|
1181
|
+
validation_param: identifier ("=" | ":") (string | number | boolean)
|
|
1182
|
+
|
|
1183
|
+
// Enhanced Persistence
|
|
1184
|
+
persistence_stage: "SAVE" "PIPELINE" persistence_type "AS" string ("WITH" persistence_config)?
|
|
1185
|
+
persistence_type: "STATE" | "CONFIG" | "METADATA" | "RESULTS" | "EVALUATION" | "RETRIEVAL_METRICS"
|
|
1186
|
+
persistence_config: "{" persistence_param ("," persistence_param)* "}"
|
|
1187
|
+
persistence_param: identifier ("=" | ":") (string | number | boolean)
|
|
1188
|
+
|
|
1189
|
+
// Enhanced Pipeline Management
|
|
1190
|
+
pipeline_management_stage: "LOAD" "PIPELINE" string | "REPRODUCE" "PIPELINE" string | "SHOW" "PIPELINE" "METADATA" | "EVALUATE" "PIPELINE" string | "COMPARE" "PIPELINES" string_list
|
|
1191
|
+
|
|
1192
|
+
// Recursive path patterns
|
|
1193
|
+
recursive_pattern: "+" | "{" number ".." number "}"
|
|
1194
|
+
|
|
1195
|
+
// Temporal operations
|
|
1196
|
+
temporal_stage: "AT" "TIME" string
|
|
1197
|
+
temporal_query: "AT" "TIME" string stage
|
|
1198
|
+
|
|
1199
|
+
// Streaming queries
|
|
1200
|
+
stream_stage: "CREATE" "STREAM" identifier "FROM" "GRAPH" identifier "MATCH" entity_pattern where_clause? "EMIT" "ON" ("INSERT" | "UPDATE" | "DELETE")
|
|
1201
|
+
|
|
1202
|
+
// User-defined functions
|
|
1203
|
+
udf_stage: "DEFINE" "FUNCTION" identifier "(" identifier ")" "AS" "RETURN" string
|
|
1204
|
+
|
|
1205
|
+
// Transactions
|
|
1206
|
+
transaction_stage: "BEGIN" | "COMMIT" | "ROLLBACK"
|
|
1207
|
+
|
|
1208
|
+
// Explain query plan
|
|
1209
|
+
explain_stage: "EXPLAIN" pipeline
|
|
1210
|
+
|
|
1211
|
+
// Event-driven operations
|
|
1212
|
+
event_stage: "ON" "EVENT" event_spec agent_stage
|
|
1213
|
+
event_spec: "Drift" "(" identifier ("," drift_params)? ")"
|
|
1214
|
+
drift_params: drift_param ("," drift_param)*
|
|
1215
|
+
drift_param: identifier "=" (number | string)
|
|
1216
|
+
|
|
1217
|
+
// CREATE GRAPH AS Pipeline - Declarative graph construction
|
|
1218
|
+
graph_pipeline: pipeline_source chunk_spec? extract_spec upsert_spec? metadata_spec?
|
|
1219
|
+
|
|
1220
|
+
// Pipeline source (document, web, text, API)
|
|
1221
|
+
pipeline_source: chunk_source | web_source | text_source | api_source
|
|
1222
|
+
chunk_source: "CHUNK" (string | variable)
|
|
1223
|
+
web_source: "WEB" (string | variable)
|
|
1224
|
+
text_source: "TEXT" (string | variable)
|
|
1225
|
+
api_source: web_api
|
|
1226
|
+
|
|
1227
|
+
// Chunking specification
|
|
1228
|
+
chunk_spec: "CHUNK" "USING" chunk_params
|
|
1229
|
+
chunk_params: chunk_param ("," chunk_param)*
|
|
1230
|
+
chunk_param: identifier "=" (string | number)
|
|
1231
|
+
|
|
1232
|
+
// LLM extraction specification
|
|
1233
|
+
extract_spec: "EXTRACT" "GRAPH" "WITH" "LLM" (string | identifier) llm_extraction_config
|
|
1234
|
+
llm_extraction_config: "PASSES" "(" pass_list ")" schema_spec? prompt_spec?
|
|
1235
|
+
pass_list: pass_name ("," pass_name)*
|
|
1236
|
+
pass_name: "entity_extraction" | "relation_induction" | "canonicalization" | "schema_alignment" | identifier
|
|
1237
|
+
schema_spec: "SCHEMA" (string | identifier)
|
|
1238
|
+
prompt_spec: "PROMPT" string
|
|
1239
|
+
|
|
1240
|
+
// Upsert specification
|
|
1241
|
+
upsert_spec: "UPSERT" "INTO" "GRAPH" upsert_params?
|
|
1242
|
+
upsert_params: identifier "=" (string | variable) ("," identifier "=" (string | variable))*
|
|
1243
|
+
|
|
1244
|
+
// Metadata specification
|
|
1245
|
+
metadata_spec: "WITH" "{" metadata_list "}"
|
|
1246
|
+
metadata_list: metadata_item ("," metadata_item)*
|
|
1247
|
+
metadata_item: identifier ":" (string | number | variable | function_call)
|
|
1248
|
+
function_call: identifier "(" ")"
|
|
1249
|
+
|
|
1250
|
+
// Subqueries
|
|
1251
|
+
subquery: "(" pipeline ")"
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
// Basic tokens (defined early at top, kept here for reference)
|
|
1255
|
+
// identifier: IDENTIFIER (moved to top)
|
|
1256
|
+
// string: STRING (moved to top)
|
|
1257
|
+
// number: NUMBER (moved to top)
|
|
1258
|
+
// boolean: "TRUE" | "FALSE" (moved to top)
|
|
1259
|
+
// list: "[" (value ("," value)*)? "]" (moved to top)
|
|
1260
|
+
identifier_list: identifier ("," identifier)*
|
|
1261
|
+
|
|
1262
|
+
// Aggregation function tokens
|
|
1263
|
+
COUNT: "COUNT"
|
|
1264
|
+
SUM: "SUM"
|
|
1265
|
+
AVG: "AVG"
|
|
1266
|
+
MIN: "MIN"
|
|
1267
|
+
MAX: "MAX"
|
|
1268
|
+
DISTINCT: "DISTINCT"
|
|
1269
|
+
UNIQUE: "UNIQUE"
|
|
1270
|
+
CONCAT: "CONCAT"
|
|
1271
|
+
JOIN: "JOIN"
|
|
1272
|
+
BETWEENNESS: "BETWEENNESS"
|
|
1273
|
+
CLOSENESS: "CLOSENESS"
|
|
1274
|
+
DEGREE: "DEGREE"
|
|
1275
|
+
TRUE: "true"
|
|
1276
|
+
FALSE: "false"
|
|
1277
|
+
DAMPING: "DAMPING"
|
|
1278
|
+
DAMPING_FACTOR: "DAMPING_FACTOR"
|
|
1279
|
+
TOLERANCE: "TOLERANCE"
|
|
1280
|
+
RESOLUTION: "RESOLUTION"
|
|
1281
|
+
ITERATIONS: "ITERATIONS"
|
|
1282
|
+
WITH: "WITH"
|
|
1283
|
+
SRC: "SRC"
|
|
1284
|
+
DEST: "DEST"
|
|
1285
|
+
HOP: "HOP"
|
|
1286
|
+
PATHS: "PATHS"
|
|
1287
|
+
CLUSTERS: "CLUSTERS"
|
|
1288
|
+
AS: "AS"
|
|
1289
|
+
|
|
1290
|
+
// Graph-native argument tokens
|
|
1291
|
+
OUTGOING: "OUTGOING"
|
|
1292
|
+
INCOMING: "INCOMING"
|
|
1293
|
+
CONNECTIONS: "CONNECTIONS"
|
|
1294
|
+
OUT: "OUT"
|
|
1295
|
+
CONNECTED: "CONNECTED"
|
|
1296
|
+
|
|
1297
|
+
// Schema tokens
|
|
1298
|
+
MATCH: "MATCH"
|
|
1299
|
+
MERGE: "MERGE"
|
|
1300
|
+
NODE: "NODE"
|
|
1301
|
+
NODES: "NODES"
|
|
1302
|
+
EDGE: "EDGE"
|
|
1303
|
+
EDGES: "EDGES"
|
|
1304
|
+
PROPERTY: "PROPERTY"
|
|
1305
|
+
VIA: "VIA"
|
|
1306
|
+
RETURN: "RETURN"
|
|
1307
|
+
LIST: "LIST"
|
|
1308
|
+
ENTITIES: "ENTITIES"
|
|
1309
|
+
SCHEMA: "SCHEMA"
|
|
1310
|
+
COUNT_SCHEMA: "count"
|
|
1311
|
+
PROPERTIES: "properties"
|
|
1312
|
+
COUNT_STAR: "count(*)"
|
|
1313
|
+
COUNT_ID: "count("
|
|
1314
|
+
|
|
1315
|
+
// Show and Describe tokens
|
|
1316
|
+
SHOW: "SHOW"
|
|
1317
|
+
DESCRIBE: "DESCRIBE"
|
|
1318
|
+
// GRAPH: "GRAPH"
|
|
1319
|
+
|
|
1320
|
+
// Model and Prompt tokens
|
|
1321
|
+
MODEL: "MODEL"
|
|
1322
|
+
PROMPT: "PROMPT"
|
|
1323
|
+
TYPE: "TYPE"
|
|
1324
|
+
PROVIDER: "PROVIDER"
|
|
1325
|
+
API_KEY: "API_KEY"
|
|
1326
|
+
TEMPERATURE: "TEMPERATURE"
|
|
1327
|
+
MAX_TOKENS: "MAX_TOKENS"
|
|
1328
|
+
MODEL_ID: "MODEL_ID"
|
|
1329
|
+
|
|
1330
|
+
// LLM Provider tokens
|
|
1331
|
+
OPENAI: "OPENAI"
|
|
1332
|
+
ANTHROPIC: "ANTHROPIC"
|
|
1333
|
+
GOOGLE: "GOOGLE"
|
|
1334
|
+
OLLAMA: "OLLAMA"
|
|
1335
|
+
REGISTER: "REGISTER"
|
|
1336
|
+
VARIABLES: "VARIABLES"
|
|
1337
|
+
SYSTEM: "SYSTEM"
|
|
1338
|
+
TEMPLATE: "TEMPLATE"
|
|
1339
|
+
|
|
1340
|
+
// Traversal strategy tokens
|
|
1341
|
+
STRATEGY: "STRATEGY"
|
|
1342
|
+
DFS: "DFS"
|
|
1343
|
+
BFS: "BFS"
|
|
1344
|
+
MAX_DEPTH: "MAX_DEPTH"
|
|
1345
|
+
MIN_DEPTH: "MIN_DEPTH"
|
|
1346
|
+
LIMIT: "LIMIT"
|
|
1347
|
+
OFFSET: "OFFSET"
|
|
1348
|
+
|
|
1349
|
+
// Namespace and access control tokens
|
|
1350
|
+
NAMESPACE: "NAMESPACE"
|
|
1351
|
+
NAMESPACES: "NAMESPACES"
|
|
1352
|
+
WITHIN: "WITHIN"
|
|
1353
|
+
COLLECTION: "COLLECTION"
|
|
1354
|
+
DESCRIPTION: "DESCRIPTION"
|
|
1355
|
+
STAGES: "STAGES"
|
|
1356
|
+
CREATE: "CREATE"
|
|
1357
|
+
RETRIEVAL_PIPELINE: "RETRIEVAL_PIPELINE"
|
|
1358
|
+
// PIPELINE: "PIPELINE"
|
|
1359
|
+
// RUN: "RUN"
|
|
1360
|
+
// QUERY: "QUERY"
|
|
1361
|
+
RETRIEVE: "RETRIEVE"
|
|
1362
|
+
// PROFILE: "PROFILE"
|
|
1363
|
+
// STRATEGY: "STRATEGY"
|
|
1364
|
+
INCLUDE: "INCLUDE"
|
|
1365
|
+
TEMPORAL: "TEMPORAL"
|
|
1366
|
+
POLICY: "POLICY"
|
|
1367
|
+
CONTEXT: "CONTEXT"
|
|
1368
|
+
WINDOW_SIZE: "WINDOW_SIZE"
|
|
1369
|
+
MODE: "MODE"
|
|
1370
|
+
DEDUPLICATE: "DEDUPLICATE"
|
|
1371
|
+
// NODES: "NODES"
|
|
1372
|
+
REASON: "REASON"
|
|
1373
|
+
// MODEL: "MODEL"
|
|
1374
|
+
INSTRUCTION: "INSTRUCTION"
|
|
1375
|
+
VERIFY: "VERIFY"
|
|
1376
|
+
// EVALUATE: "EVALUATE"
|
|
1377
|
+
SUITE: "SUITE"
|
|
1378
|
+
// METRICS: "METRICS"
|
|
1379
|
+
STORE: "STORE"
|
|
1380
|
+
// RESULTS: "RESULTS"
|
|
1381
|
+
SIMILAR: "SIMILAR"
|
|
1382
|
+
BETWEEN: "BETWEEN"
|
|
1383
|
+
AGGREGATE: "AGGREGATE"
|
|
1384
|
+
PLUS: "+"
|
|
1385
|
+
GRANT: "GRANT"
|
|
1386
|
+
READ: "READ"
|
|
1387
|
+
WRITE: "WRITE"
|
|
1388
|
+
EXECUTE: "EXECUTE"
|
|
1389
|
+
TO: "TO"
|
|
1390
|
+
CONNECT: "CONNECT"
|
|
1391
|
+
// WITH: "WITH"
|
|
1392
|
+
INPUT: "INPUT"
|
|
1393
|
+
|
|
1394
|
+
// Schema definition tokens
|
|
1395
|
+
DEFINE: "DEFINE"
|
|
1396
|
+
TEXT: "TEXT"
|
|
1397
|
+
INT: "INT"
|
|
1398
|
+
FLOAT: "FLOAT"
|
|
1399
|
+
BOOLEAN: "BOOLEAN"
|
|
1400
|
+
DATE: "DATE"
|
|
1401
|
+
NOT: "NOT"
|
|
1402
|
+
NULL: "NULL"
|
|
1403
|
+
PRIMARY: "PRIMARY"
|
|
1404
|
+
KEY: "KEY"
|
|
1405
|
+
FROM: "FROM"
|
|
1406
|
+
|
|
1407
|
+
// View tokens
|
|
1408
|
+
VIEW: "VIEW"
|
|
1409
|
+
MATERIALIZE: "MATERIALIZE"
|
|
1410
|
+
|
|
1411
|
+
// Temporal tokens
|
|
1412
|
+
AT: "AT"
|
|
1413
|
+
TIME: "TIME"
|
|
1414
|
+
|
|
1415
|
+
// Streaming tokens
|
|
1416
|
+
STREAM: "STREAM"
|
|
1417
|
+
EMIT: "EMIT"
|
|
1418
|
+
ON: "ON"
|
|
1419
|
+
INSERT: "INSERT"
|
|
1420
|
+
UPDATE: "UPDATE"
|
|
1421
|
+
DELETE: "DELETE"
|
|
1422
|
+
|
|
1423
|
+
// Function tokens
|
|
1424
|
+
FUNCTION: "FUNCTION"
|
|
1425
|
+
|
|
1426
|
+
// Transaction tokens
|
|
1427
|
+
BEGIN: "BEGIN"
|
|
1428
|
+
COMMIT: "COMMIT"
|
|
1429
|
+
ROLLBACK: "ROLLBACK"
|
|
1430
|
+
|
|
1431
|
+
// Temporal tokens
|
|
1432
|
+
TIMESTAMP: "TIMESTAMP"
|
|
1433
|
+
RUN: "RUN"
|
|
1434
|
+
|
|
1435
|
+
// Explain token
|
|
1436
|
+
EXPLAIN: "EXPLAIN"
|
|
1437
|
+
|
|
1438
|
+
// Evaluation tokens
|
|
1439
|
+
EVAL: "EVAL"
|
|
1440
|
+
METRICS: "METRICS"
|
|
1441
|
+
COMPARE: "COMPARE"
|
|
1442
|
+
BASELINE: "BASELINE"
|
|
1443
|
+
SAVE: "SAVE"
|
|
1444
|
+
|
|
1445
|
+
// Web integration tokens
|
|
1446
|
+
WEB: "WEB"
|
|
1447
|
+
WEB_SEARCH: "WEB_SEARCH"
|
|
1448
|
+
WEB_API: "WEB_API"
|
|
1449
|
+
ADD_EMBEDDINGS: "ADD_EMBEDDINGS"
|
|
1450
|
+
SPARSE_MATCH: "SPARSE_MATCH"
|
|
1451
|
+
DENSE_MATCH: "DENSE_MATCH"
|
|
1452
|
+
HYBRID_MATCH: "HYBRID_MATCH"
|
|
1453
|
+
SHORTEST_PATH: "SHORTEST_PATH"
|
|
1454
|
+
COMMUNITY_DETECTION: "COMMUNITY_DETECTION"
|
|
1455
|
+
OPTIONS: "OPTIONS"
|
|
1456
|
+
CALL: "CALL"
|
|
1457
|
+
UPSERT: "UPSERT"
|
|
1458
|
+
PROVENANCE: "PROVENANCE"
|
|
1459
|
+
EVENT: "EVENT"
|
|
1460
|
+
DRIFT: "Drift"
|
|
1461
|
+
|
|
1462
|
+
// CREATE GRAPH AS tokens
|
|
1463
|
+
CHUNK: "CHUNK"
|
|
1464
|
+
EXTRACT: "EXTRACT"
|
|
1465
|
+
PASSES: "PASSES"
|
|
1466
|
+
ENTITY_EXTRACTION: "entity_extraction"
|
|
1467
|
+
RELATION_INDUCTION: "relation_induction"
|
|
1468
|
+
CANONICALIZATION: "canonicalization"
|
|
1469
|
+
SCHEMA_ALIGNMENT: "schema_alignment"
|
|
1470
|
+
NOW: "NOW"
|
|
1471
|
+
USING: "USING"
|
|
1472
|
+
|
|
1473
|
+
// New tokens for enhanced features
|
|
1474
|
+
SET: "SET"
|
|
1475
|
+
HAVING: "HAVING"
|
|
1476
|
+
SOURCE: "SOURCE"
|
|
1477
|
+
TARGET: "TARGET"
|
|
1478
|
+
EDGE_TYPES: "EDGE_TYPES"
|
|
1479
|
+
METHOD: "METHOD"
|
|
1480
|
+
VECTOR: "VECTOR"
|
|
1481
|
+
|
|
1482
|
+
// Bulk loading tokens
|
|
1483
|
+
CSV: "CSV"
|
|
1484
|
+
JSON: "JSON"
|
|
1485
|
+
XML: "XML"
|
|
1486
|
+
SQL: "SQL"
|
|
1487
|
+
API_LOAD: "API"
|
|
1488
|
+
DELIMITER: "DELIMITER"
|
|
1489
|
+
HEADER: "HEADER"
|
|
1490
|
+
ENCODING: "ENCODING"
|
|
1491
|
+
SKIP_ROWS: "SKIP_ROWS"
|
|
1492
|
+
PATH: "PATH"
|
|
1493
|
+
ARRAY_MODE: "ARRAY_MODE"
|
|
1494
|
+
FLATTEN: "FLATTEN"
|
|
1495
|
+
ROOT_PATH: "ROOT_PATH"
|
|
1496
|
+
VALIDATE: "VALIDATE"
|
|
1497
|
+
CONNECTION: "CONNECTION"
|
|
1498
|
+
QUERY: "QUERY"
|
|
1499
|
+
BATCH_SIZE: "BATCH_SIZE"
|
|
1500
|
+
HEADERS: "HEADERS"
|
|
1501
|
+
PARAMS: "PARAMS"
|
|
1502
|
+
AUTH: "AUTH"
|
|
1503
|
+
PAGINATION: "PAGINATION"
|
|
1504
|
+
|
|
1505
|
+
// Enhanced RAG Pipeline Tokens
|
|
1506
|
+
MULTIMODAL: "MULTIMODAL"
|
|
1507
|
+
FILE_TYPE_AWARE: "FILE_TYPE_AWARE"
|
|
1508
|
+
CONTENT_AWARE: "CONTENT_AWARE"
|
|
1509
|
+
TABLE_AWARE: "TABLE_AWARE"
|
|
1510
|
+
RETRIEVAL_SYSTEM: "RETRIEVAL_SYSTEM"
|
|
1511
|
+
EVALUATE: "EVALUATE"
|
|
1512
|
+
PIPELINE: "PIPELINE"
|
|
1513
|
+
PDF_READER: "PDF_READER"
|
|
1514
|
+
IMAGE_READER: "IMAGE_READER"
|
|
1515
|
+
AUDIO_READER: "AUDIO_READER"
|
|
1516
|
+
VIDEO_READER: "VIDEO_READER"
|
|
1517
|
+
TEXT_READER: "TEXT_READER"
|
|
1518
|
+
TABLE_READER: "TABLE_READER"
|
|
1519
|
+
OCR_READER: "OCR_READER"
|
|
1520
|
+
SPEECH_READER: "SPEECH_READER"
|
|
1521
|
+
MULTIMODAL_READER: "MULTIMODAL_READER"
|
|
1522
|
+
TABLES: "TABLES"
|
|
1523
|
+
IMAGE_EXPLANATION: "IMAGE_EXPLANATION"
|
|
1524
|
+
TABLE_STRUCTURE: "TABLE_STRUCTURE"
|
|
1525
|
+
DOCUMENT_LAYOUT: "DOCUMENT_LAYOUT"
|
|
1526
|
+
AUDIO_TRANSCRIPT: "AUDIO_TRANSCRIPT"
|
|
1527
|
+
VIDEO_FRAMES: "VIDEO_FRAMES"
|
|
1528
|
+
OBJECT_DETECTION: "OBJECT_DETECTION"
|
|
1529
|
+
SCENE_ANALYSIS: "SCENE_ANALYSIS"
|
|
1530
|
+
SPEECH: "SPEECH"
|
|
1531
|
+
IMAGES: "IMAGES"
|
|
1532
|
+
AUDIO: "AUDIO"
|
|
1533
|
+
VIDEO: "VIDEO"
|
|
1534
|
+
SCENES: "SCENES"
|
|
1535
|
+
OCR: "OCR"
|
|
1536
|
+
OBJECTS: "OBJECTS"
|
|
1537
|
+
FACES: "FACES"
|
|
1538
|
+
PDF: "PDF"
|
|
1539
|
+
TXT: "TXT"
|
|
1540
|
+
MD: "MD"
|
|
1541
|
+
DOCX: "DOCX"
|
|
1542
|
+
HTML: "HTML"
|
|
1543
|
+
PRESENTATION: "PRESENTATION"
|
|
1544
|
+
SPREADSHEET: "SPREADSHEET"
|
|
1545
|
+
SMART: "SMART"
|
|
1546
|
+
FIXED_SIZE: "FIXED_SIZE"
|
|
1547
|
+
SEMANTIC: "SEMANTIC"
|
|
1548
|
+
SENTENCE: "SENTENCE"
|
|
1549
|
+
PARAGRAPH: "PARAGRAPH"
|
|
1550
|
+
SECTION: "SECTION"
|
|
1551
|
+
SLIDING_WINDOW: "SLIDING_WINDOW"
|
|
1552
|
+
LLM_TOPIC_AWARE: "LLM_TOPIC_AWARE"
|
|
1553
|
+
DOCUMENT_CHUNK: "DOCUMENT_CHUNK"
|
|
1554
|
+
CHUNK_ENTITY: "CHUNK_ENTITY"
|
|
1555
|
+
ENTITY_ENTITY: "ENTITY_ENTITY"
|
|
1556
|
+
SEMANTIC_SIMILARITY: "SEMANTIC_SIMILARITY"
|
|
1557
|
+
TABLE_RELATIONSHIP: "TABLE_RELATIONSHIP"
|
|
1558
|
+
IMAGE_RELATIONSHIP: "IMAGE_RELATIONSHIP"
|
|
1559
|
+
AUDIO_RELATIONSHIP: "AUDIO_RELATIONSHIP"
|
|
1560
|
+
VIDEO_RELATIONSHIP: "VIDEO_RELATIONSHIP"
|
|
1561
|
+
QUALITY_THRESHOLD: "QUALITY_THRESHOLD"
|
|
1562
|
+
CONFIDENCE_THRESHOLD: "CONFIDENCE_THRESHOLD"
|
|
1563
|
+
COMPLETENESS_CHECK: "COMPLETENESS_CHECK"
|
|
1564
|
+
CONSISTENCY_CHECK: "CONSISTENCY_CHECK"
|
|
1565
|
+
ACCURACY_CHECK: "ACCURACY_CHECK"
|
|
1566
|
+
COVERAGE_CHECK: "COVERAGE_CHECK"
|
|
1567
|
+
RETRIEVAL_QUALITY: "RETRIEVAL_QUALITY"
|
|
1568
|
+
EXTRACTION_QUALITY: "EXTRACTION_QUALITY"
|
|
1569
|
+
STATE: "STATE"
|
|
1570
|
+
CONFIG: "CONFIG"
|
|
1571
|
+
METADATA: "METADATA"
|
|
1572
|
+
RESULTS: "RESULTS"
|
|
1573
|
+
EVALUATION: "EVALUATION"
|
|
1574
|
+
RETRIEVAL_METRICS: "RETRIEVAL_METRICS"
|
|
1575
|
+
REPRODUCE: "REPRODUCE"
|
|
1576
|
+
AUTO_DETECT: "AUTO_DETECT"
|
|
1577
|
+
SPECIFY: "SPECIFY"
|
|
1578
|
+
|
|
1579
|
+
// Enhanced Pipeline Tokens
|
|
1580
|
+
FILE: "FILE"
|
|
1581
|
+
READER: "READER"
|
|
1582
|
+
DETECT: "DETECT"
|
|
1583
|
+
// TEXT: "TEXT" // Defined earlier
|
|
1584
|
+
// DESCRIBE: "DESCRIBE" // Defined earlier
|
|
1585
|
+
// EXTRACT: "EXTRACT" // Defined earlier
|
|
1586
|
+
// STORE: "STORE" // Defined earlier
|
|
1587
|
+
// AS: "AS" // Defined earlier
|
|
1588
|
+
// NODE: "NODE" // Defined earlier
|
|
1589
|
+
// TYPES: "TYPES" // Need to check if defined
|
|
1590
|
+
// LINK: "LINK" // Need to check if defined
|
|
1591
|
+
PARSE_METADATA: "PARSE_METADATA"
|
|
1592
|
+
NORMALIZE: "NORMALIZE"
|
|
1593
|
+
REMOVE_DUPLICATES: "REMOVE_DUPLICATES"
|
|
1594
|
+
EXPAND_ABBREVIATIONS: "EXPAND_ABBREVIATIONS"
|
|
1595
|
+
INTERMEDIATE: "INTERMEDIATE"
|
|
1596
|
+
ARROW: "->"
|
|
1597
|
+
MINUS: "-"
|
|
1598
|
+
// IN: "IN"
|
|
1599
|
+
// COLLECTION: "COLLECTION"
|
|
1600
|
+
BY: "BY"
|
|
1601
|
+
// MODEL: "MODEL"
|
|
1602
|
+
PARAMETERS: "PARAMETERS"
|
|
1603
|
+
// TO: "TO"
|
|
1604
|
+
// ON: "ON"
|
|
1605
|
+
// PROMPT: "PROMPT"
|
|
1606
|
+
// ENTITIES: "ENTITIES"
|
|
1607
|
+
CHUNKS: "CHUNKS"
|
|
1608
|
+
OF: "OF"
|
|
1609
|
+
// SOURCE: "SOURCE"
|
|
1610
|
+
// USING: "USING"
|
|
1611
|
+
LLM: "LLM"
|
|
1612
|
+
// PASSES: "PASSES"
|
|
1613
|
+
OUTPUT: "OUTPUT"
|
|
1614
|
+
RELATIONSHIPS: "RELATIONSHIPS"
|
|
1615
|
+
RELATIONSHIP_TYPES: "RELATIONSHIP_TYPES"
|
|
1616
|
+
// EDGE: "EDGE"
|
|
1617
|
+
// TYPE: "TYPE"
|
|
1618
|
+
// FROM: "FROM"
|
|
1619
|
+
EMBED: "EMBED"
|
|
1620
|
+
// PROFILE: "PROFILE"
|
|
1621
|
+
CONTEXT_POLICY: "CONTEXT_POLICY"
|
|
1622
|
+
EMBEDDING: "EMBEDDING"
|
|
1623
|
+
// CONNECT: "CONNECT"
|
|
1624
|
+
// AUTO: "AUTO"
|
|
1625
|
+
// INCLUDE: "INCLUDE"
|
|
1626
|
+
// EDGES: "EDGES"
|
|
1627
|
+
TEMPORAL_POLICY: "TEMPORAL_POLICY"
|
|
1628
|
+
INDEX: "INDEX"
|
|
1629
|
+
BUILD_INDEX: "BUILD_INDEX"
|
|
1630
|
+
// IMAGES: "IMAGES"
|
|
1631
|
+
// AUDIO: "AUDIO"
|
|
1632
|
+
// VIDEO: "VIDEO"
|
|
1633
|
+
// TABLES: "TABLES"
|
|
1634
|
+
// OCR: "OCR"
|
|
1635
|
+
// PLUS: "+"
|
|
1636
|
+
|
|
1637
|
+
// Token definitions
|
|
1638
|
+
// Session Management
|
|
1639
|
+
session_statement: begin_session | end_session | save_session | load_session | pause_session | resume_session | show_session | set_session
|
|
1640
|
+
begin_session: ("BEGIN" | "START") "SESSION" (string | identifier) ("OPTIONS" "(" session_options ")")?
|
|
1641
|
+
end_session: "END" "SESSION" ("SAVE")?
|
|
1642
|
+
save_session: "SAVE" "SESSION" ("TO" string)?
|
|
1643
|
+
load_session: "LOAD" "SESSION" "FROM" string
|
|
1644
|
+
pause_session: "PAUSE" "SESSION"
|
|
1645
|
+
resume_session: "RESUME" "SESSION" (string | identifier)
|
|
1646
|
+
show_session: "SHOW" "SESSION"
|
|
1647
|
+
set_session: "SET" "SESSION" session_options
|
|
1648
|
+
session_options: session_option ("," session_option)*
|
|
1649
|
+
session_option: identifier ":" (string | boolean | number)
|
|
1650
|
+
|
|
1651
|
+
// User Functions
|
|
1652
|
+
create_function: "CREATE" "FUNCTION" identifier "{" function_definition "}"
|
|
1653
|
+
function_definition: function_property ("," function_property)*
|
|
1654
|
+
function_property: identifier ":" (string | identifier | list)
|
|
1655
|
+
use_function: "USE" "FUNCTION" identifier ("PARAMETERS" "(" parameter_dict ")")? ("INPUT" "FROM" (identifier | variable))? ("STORE" "RESULT" "AS" identifier)?
|
|
1656
|
+
|
|
1657
|
+
// Agentic Wrapping
|
|
1658
|
+
agent_statement: create_agent | plan_agent | execute_agent
|
|
1659
|
+
create_agent: "CREATE" "AGENT" string "{" agent_definition "}"
|
|
1660
|
+
agent_definition: agent_property ("," agent_property)*
|
|
1661
|
+
agent_property: identifier ":" (string | boolean | list | "{" parameter_dict "}")
|
|
1662
|
+
plan_agent: "PLAN" "AGENT" string ("INPUT" "{" parameter_dict "}")? ("TOOLS" "[" tool_list "]")? ("STRATEGY" "{" parameter_dict "}")?
|
|
1663
|
+
tool_list: tool_spec ("," tool_spec)*
|
|
1664
|
+
tool_spec: string ("{" parameter_dict "}")?
|
|
1665
|
+
execute_agent: "EXECUTE" "AGENT" string ("WITH" execute_options)* ("RETURN" identifier_list)?
|
|
1666
|
+
execute_options: "AUTO_SAVE_FINDINGS" "TO" "GRAPH" | "MEMORY" "CONTEXT" boolean
|
|
1667
|
+
|
|
1668
|
+
// Memory Management
|
|
1669
|
+
memory_statement: store_memory | retrieve_memory
|
|
1670
|
+
store_memory: "STORE" "IN" "MEMORY" "{" property_list "}"
|
|
1671
|
+
retrieve_memory: "RETRIEVE" "FROM" "MEMORY" ("WHERE" condition)? ("LIMIT" number)?
|
|
1672
|
+
|
|
1673
|
+
// Operational Controls
|
|
1674
|
+
operational_statement: explain_plan | optimize_query | cache_statement | attach_policy | set_guardrails | set_logging
|
|
1675
|
+
explain_plan: "EXPLAIN" "PLAN" "FOR" (top_select | search_query_basic | hybrid_search)
|
|
1676
|
+
optimize_query: "OPTIMIZE" "QUERY" (top_select | search_query_basic | hybrid_search) ("RETURN" string)?
|
|
1677
|
+
cache_statement: cache_warmup | cache_stats | cache_clear
|
|
1678
|
+
cache_warmup: "CACHE" "WARMUP" ("FOR" "NAMESPACE" (identifier | variable))?
|
|
1679
|
+
cache_stats: "CACHE" "STATS"
|
|
1680
|
+
cache_clear: "CACHE" "CLEAR"
|
|
1681
|
+
attach_policy: "ATTACH" "POLICY" string "TO" "PIPELINE" identifier
|
|
1682
|
+
set_guardrails: "SET" "GUARDRAILS" "FOR" "PIPELINE" identifier "{" parameter_dict "}"
|
|
1683
|
+
set_logging: "SET" "LOGGING" "ON" "FOR" "PIPELINE" identifier ("WITH" "LEVEL" string)?
|
|
1684
|
+
|
|
1685
|
+
IDENTIFIER: /[a-zA-Z_][a-zA-Z0-9_-]*/
|
|
1686
|
+
FUNCTION_NAME: /[a-zA-Z_][a-zA-Z0-9_.-]+/
|
|
1687
|
+
DOT: "."
|
|
1688
|
+
|
|
1689
|
+
// Hybrid Search Terminals
|
|
1690
|
+
HYBRID: "HYBRID"
|
|
1691
|
+
SEARCH: "SEARCH"
|
|
1692
|
+
WEIGHTS: "WEIGHTS"
|
|
1693
|
+
// PROFILE: "PROFILE"
|
|
1694
|
+
DENSE: "DENSE"
|
|
1695
|
+
SPARSE: "SPARSE"
|
|
1696
|
+
GRAPH: "GRAPH"
|
|
1697
|
+
// AUTO: "AUTO"
|
|
1698
|
+
DYNAMIC: "DYNAMIC"
|
|
1699
|
+
STATIC: "STATIC"
|
|
1700
|
+
DEFAULT: "DEFAULT"
|
|
1701
|
+
// Improved STRING token to handle multi-line strings better
|
|
1702
|
+
STRING: /"([^"\\\\]|\\.|\\\\n)*"/ | /'([^'\\\\]|\\.|\\\\n)*'/
|
|
1703
|
+
NUMBER: /\\d+(\\.\\d+)?([eE][+-]?\\d+)?/
|
|
1704
|
+
|
|
1705
|
+
// Legacy support for backward compatibility
|
|
1706
|
+
legacy_pipeline: pipeline (";" pipeline)* (";")?
|
|
1707
|
+
legacy_retrieval_pipeline: retrieval_pipeline (";" retrieval_pipeline)* (";")?
|
|
1708
|
+
legacy_hybrid_search: hybrid_search (";" hybrid_search)* (";")?
|
|
1709
|
+
|
|
1710
|
+
// Comment handling - lines starting with -- or #
|
|
1711
|
+
_COMMENT: "--" /.*/
|
|
1712
|
+
_WS: /\\s+/
|
|
1713
|
+
|
|
1714
|
+
%ignore _WS
|
|
1715
|
+
%ignore _COMMENT
|
|
1716
|
+
"""
|
|
1717
|
+
|
|
1718
|
+
# Grammar validation and helper functions
|
|
1719
|
+
def validate_grammar():
|
|
1720
|
+
"""Validate the AIQL grammar syntax."""
|
|
1721
|
+
try:
|
|
1722
|
+
import lark
|
|
1723
|
+
parser = lark.Lark(AIQL_GRAMMAR, parser='lalr')
|
|
1724
|
+
return True, "Grammar is valid"
|
|
1725
|
+
except Exception as e:
|
|
1726
|
+
return False, f"Grammar validation failed: {e}"
|
|
1727
|
+
|
|
1728
|
+
def get_grammar():
|
|
1729
|
+
"""Get the AIQL grammar definition."""
|
|
1730
|
+
return AIQL_GRAMMAR
|
|
1731
|
+
|
|
1732
|
+
# Example queries for testing
|
|
1733
|
+
EXAMPLE_QUERIES = {
|
|
1734
|
+
"variable_declaration": """
|
|
1735
|
+
LET $author = "Alice"
|
|
1736
|
+
LET $limit = 10
|
|
1737
|
+
""",
|
|
1738
|
+
|
|
1739
|
+
"graph_creation": """
|
|
1740
|
+
CREATE GRAPH social_graph
|
|
1741
|
+
THEN CREATE NODE Person AS p {name: "Alice", age: 30} UNIQUE KEY(name)
|
|
1742
|
+
THEN CREATE EDGE KNOWS AS k {since: 2020} UNIQUE KEY(since)
|
|
1743
|
+
""",
|
|
1744
|
+
|
|
1745
|
+
"inline_traversal": """
|
|
1746
|
+
TRAVERSE Person:a -KNOWS-> Person:b -KNOWS-> Person:c
|
|
1747
|
+
WHERE a.name = $author
|
|
1748
|
+
SELECT c.name
|
|
1749
|
+
""",
|
|
1750
|
+
|
|
1751
|
+
"verbose_traversal": """
|
|
1752
|
+
TRAVERSE FROM Person AS p OUTGOING KNOWS EDGE TO Person AS f
|
|
1753
|
+
WHERE p.name = $author
|
|
1754
|
+
SELECT f.name
|
|
1755
|
+
""",
|
|
1756
|
+
|
|
1757
|
+
"hybrid_search": """
|
|
1758
|
+
LOAD DOCUMENT "research_paper.pdf" INTO documents
|
|
1759
|
+
THEN CHUNK BY USING semantic {chunk_size: 500}
|
|
1760
|
+
THEN ADD EMBEDDINGS USING sentence-transformers {model: "all-MiniLM-L6-v2"}
|
|
1761
|
+
THEN HYBRID ("machine learning research") IN documents WITH semantic=0.7, keyword=0.3 LIMIT 5
|
|
1762
|
+
THEN TRAVERSE FROM (results) OUTGOING CITED_BY EDGE TO Document AS cited
|
|
1763
|
+
SELECT cited.title
|
|
1764
|
+
""",
|
|
1765
|
+
|
|
1766
|
+
"analytics": """
|
|
1767
|
+
TRAVERSE FROM Person AS p OUTGOING KNOWS EDGE TO Person AS f
|
|
1768
|
+
THEN PAGERANK ON f ITERATIONS 10
|
|
1769
|
+
THEN COMMUNITY DETECTION ALGORITHM louvain
|
|
1770
|
+
""",
|
|
1771
|
+
|
|
1772
|
+
"indexing": """
|
|
1773
|
+
CREATE INDEX DENSE ON documents BY embedding
|
|
1774
|
+
THEN CREATE INDEX SPARSE ON documents BY content
|
|
1775
|
+
THEN SHARD GRAPH social_graph BY (community_id)
|
|
1776
|
+
""",
|
|
1777
|
+
|
|
1778
|
+
"aggregation_basic": """
|
|
1779
|
+
SELECT COUNT(*) FROM Employee
|
|
1780
|
+
""",
|
|
1781
|
+
|
|
1782
|
+
"aggregation_group_by": """
|
|
1783
|
+
SELECT department, COUNT(*) as employee_count
|
|
1784
|
+
FROM Employee
|
|
1785
|
+
GROUP BY department
|
|
1786
|
+
""",
|
|
1787
|
+
|
|
1788
|
+
"aggregation_avg": """
|
|
1789
|
+
SELECT department, AVG(salary) as avg_salary
|
|
1790
|
+
FROM Employee
|
|
1791
|
+
GROUP BY department
|
|
1792
|
+
""",
|
|
1793
|
+
|
|
1794
|
+
"aggregation_order_by": """
|
|
1795
|
+
SELECT name, salary
|
|
1796
|
+
FROM Employee
|
|
1797
|
+
ORDER BY salary DESC
|
|
1798
|
+
LIMIT 3
|
|
1799
|
+
""",
|
|
1800
|
+
|
|
1801
|
+
"aggregation_complex": """
|
|
1802
|
+
SELECT department, COUNT(*) as count, AVG(salary) as avg_salary, MAX(salary) as max_salary
|
|
1803
|
+
FROM Employee
|
|
1804
|
+
WHERE age > 25
|
|
1805
|
+
GROUP BY department
|
|
1806
|
+
ORDER BY avg_salary DESC
|
|
1807
|
+
"""
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
if __name__ == "__main__":
|
|
1811
|
+
# Test grammar validation
|
|
1812
|
+
is_valid, message = validate_grammar()
|
|
1813
|
+
print(f"Grammar validation: {message}")
|
|
1814
|
+
|
|
1815
|
+
if is_valid:
|
|
1816
|
+
print("\nSUCCESS: AIQL Grammar is valid and ready for parser implementation!")
|
|
1817
|
+
print("\nExample queries:")
|
|
1818
|
+
for name, query in EXAMPLE_QUERIES.items():
|
|
1819
|
+
print(f"\n{name.upper()}:")
|
|
1820
|
+
print(query.strip())
|
|
1821
|
+
else:
|
|
1822
|
+
print("FAILURE: Grammar needs fixes before proceeding")
|