agentic-graphrag 0.0.7__tar.gz → 0.0.8__tar.gz
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.
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/PKG-INFO +2 -2
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/build.py +6 -2
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/middleware.py +20 -2
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/model.py +13 -4
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/settings.py +4 -0
- agentic_graphrag-0.0.8/agrag/common/_asyncio_locks.py +29 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/graph_schema.py +3 -2
- agentic_graphrag-0.0.8/agrag/cypher/_job_fence.py +51 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/cutover_job_read.py +4 -5
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/cutover_job_write.py +75 -28
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/documents.py +10 -2
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/entities.py +15 -4
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/relations.py +14 -4
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/entities.py +1 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/rerank.py +40 -16
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/graphdb/base.py +20 -2
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/graphdb/cypher_store.py +60 -5
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/graphdb/errors.py +19 -2
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/graphdb/falkordb.py +15 -2
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/graphdb/neo4j.py +38 -9
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/graphdb/serialize.py +1 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_cutover.py +230 -68
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_deferred.py +9 -1
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_ingest.py +287 -144
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_ingest_pipeline.py +15 -7
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_merge_stage.py +26 -2
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_resume.py +19 -43
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_storage.py +12 -3
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/community.py +5 -1
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/extract.py +3 -1
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/graph.py +45 -3
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/merge.py +27 -10
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/reports/update_result.py +3 -1
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/resolve/resolver.py +3 -1
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/resolved_embeddings.py +8 -3
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/resolved_entities.py +90 -20
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/vector_sync.py +92 -23
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/client_config.py +3 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/client_registry.py +23 -1
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/walk.py +153 -12
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/vectordb/base.py +24 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/vectordb/milvus.py +9 -6
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/vectordb/qdrant.py +9 -3
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/vectordb/weaviate.py +47 -37
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/pyproject.toml +4 -4
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/pyproject.toml.orig +4 -4
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/LICENSE +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/README.md +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/errors.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/harness.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/ledger.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/prompts.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/result.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/tools/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/tools/core.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/tracing.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/agents/verification.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/candidates/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/candidates/errors.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/candidates/patch.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/candidates/review.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/candidates/search.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/chunking/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/chunking/_edge_orders.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/chunking/_tables.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/chunking/chunker.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/agent_answer.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/candidate.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/candidate_review.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/chunk.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/community.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/cutover_job.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/data_point.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/decision.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/default_schema.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/document.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/dropped.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/entity.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/entity_search.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/evidence.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/extraction.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/graph_record.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/index_record.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/navigation.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/normalization.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/presets.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/provenance.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/relation.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/resolved_entity.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/retention.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/search_result.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/stage_failure.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/structure.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/task.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/theme_search.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/update_decision.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/vector_record.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/data_models/write_result.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/fingerprint.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/graph_rows.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/schema_fingerprint.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/text.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/common/validation.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/_pending_filter.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/candidate_conversion.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/candidate_review.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/candidate_search.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/candidates.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/community_read.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/community_write.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/decision_review.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/evidence.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/history.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/resolution_read.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/resolution_write.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/retention.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/schema.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/vector_cleanup.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/vector_hits.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/vector_placement.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/cypher/vector_targets.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/decisions.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/embedding/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/embedding/base.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/embedding/cached.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/embedding/errors.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/embedding/fastembed_dense.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/embedding/sentence_transformers.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/embedding/settings.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/eval/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/eval/adapter.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/eval/answer.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/eval/extraction.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/eval/judge.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/eval/resolution.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/eval/settings.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/eval/trajectory.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/eval/verifier.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/_shared.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/citation.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/contract.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/fetch.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/ids.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/navigate.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/render.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/search.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/source_status.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/evidence/themes.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/graphdb/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/graphdb/entities.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/graphdb/settings.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/history/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/history/retention.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/history/tasks.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_candidate_conversion.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_candidate_stage.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_clustering.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_document_lifecycle.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_escalation.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_gliner_decode.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_job_cleanup.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_lexical_backbone.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_mentions.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_pending_rows.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_resolution_maintenance.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_resolve_stage.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_stage_context.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_structure.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/_walk.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/reports/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/reports/add_result.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/reports/community_detection_report.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/reports/consolidation_report.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/reports/conversion_report.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/reports/escalation_report.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/reports/reevaluation_report.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/resolve/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/resolve/batch_validation.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/resolve/candidate_source.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/resolve/comparators.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/resolve/exact_groups.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/resolve/resolution.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/resolve/zone_classifier.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/settings.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/stats/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/stats/chunking.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/stats/dropped.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/stats/extraction.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/stats/ingest.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/stats/merge.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/stats/resolution.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/ingestion/stats/storage.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/async_client.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/config.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/globals.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/inlinedbaml.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/parser.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/runtime.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/stream_types.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/sync_client.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/tracing.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/type_builder.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/type_map.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/types.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_client/watchers.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_src/community.baml +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_src/extraction.baml +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_src/generators.baml +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_src/merge.baml +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/baml_src/resolution.baml +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/retry.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/llm/tracing.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/base.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/chat.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/common.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/decode.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/defaults.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/docling/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/docling/_converters.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/docling/_sections.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/docling/loader.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/errors.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/loader_registry.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/prose.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/records.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/loaders/types.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/mcp_server/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/mcp_server/__main__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/mcp_server/errors.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/mcp_server/read_tools.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/mcp_server/results.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/mcp_server/server.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/mcp_server/settings.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/mcp_server/write_tools.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/observability.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/py.typed +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/retrieval/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/retrieval/chunking.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/retrieval/filters.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/retrieval/methods/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/retrieval/methods/vector.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/retrieval/settings.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/retrieval/tracing.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/canonical.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/errors.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/formats/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/formats/_iri.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/formats/dispatch.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/formats/errors.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/formats/json_schema.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/formats/jsonld.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/formats/owl.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/formats/pydantic_models.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/formats/result.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/formats/shacl.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/loader.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/schema/shorthand.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/vectordb/__init__.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/vectordb/errors.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/vectordb/kinds.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/vectordb/placement.py +0 -0
- {agentic_graphrag-0.0.7 → agentic_graphrag-0.0.8}/agrag/vectordb/settings.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentic-graphrag
|
|
3
|
-
Version: 0.0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.0.8
|
|
4
|
+
Summary: Agentic GraphRAG is an open source framework that builds a graph connecting your enterprise knowledge to the conversations your agents have and the decisions they make. Each decision links back to the passages and task events behind it, so agents can look up earlier decisions with their evidence, and resume work across sessions.
|
|
5
5
|
Keywords: conversation-history,decision-traces,context-graph,knowledge-graph,graphrag,ai-agents,mcp,neo4j,provenance
|
|
6
6
|
Author: Ashwin Mathur, Varun Mathur
|
|
7
7
|
Author-email: Ashwin Mathur <ashwinm400@gmail.com>, Varun Mathur <varunm500@gmail.com>
|
|
@@ -77,7 +77,9 @@ def build_agent(
|
|
|
77
77
|
history = ConversationHistory(graph_store, project_id=project_id, agent_id=agent_id)
|
|
78
78
|
decisions = DecisionTraces(graph_store, project_id=project_id, agent_id=agent_id)
|
|
79
79
|
middleware = build_model_middleware(
|
|
80
|
-
llm_settings.clients,
|
|
80
|
+
llm_settings.clients,
|
|
81
|
+
strategy=llm_settings.strategy,
|
|
82
|
+
max_retries=llm_settings.max_retries,
|
|
81
83
|
)
|
|
82
84
|
return _TaskAgent(
|
|
83
85
|
graph_store=graph_store,
|
|
@@ -85,7 +87,9 @@ def build_agent(
|
|
|
85
87
|
scope=scope,
|
|
86
88
|
history=history,
|
|
87
89
|
decisions=decisions,
|
|
88
|
-
model=build_chat_model(
|
|
90
|
+
model=build_chat_model(
|
|
91
|
+
llm_settings.clients[0], max_retries=llm_settings.max_retries
|
|
92
|
+
),
|
|
89
93
|
settings=settings,
|
|
90
94
|
middleware=middleware,
|
|
91
95
|
provider=model_provider_key(llm_settings.clients[0].provider),
|
|
@@ -11,12 +11,18 @@ from langchain.agents.middleware.types import (
|
|
|
11
11
|
ModelRequest,
|
|
12
12
|
ModelResponse,
|
|
13
13
|
)
|
|
14
|
-
from langchain_core.messages import ToolMessage
|
|
14
|
+
from langchain_core.messages import HumanMessage, ToolMessage
|
|
15
15
|
from langgraph.errors import GraphBubbleUp
|
|
16
16
|
|
|
17
17
|
from agrag.common.data_models.task import EventKind, StepKind, StepState
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
_BUDGET_SPENT_NOTE = (
|
|
21
|
+
"The tool budget is spent, so no more evidence tools are available. "
|
|
22
|
+
"Answer now with the answer tool, using only the evidence already gathered."
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
20
26
|
@dataclass
|
|
21
27
|
class RunState:
|
|
22
28
|
"""Mutable facts accumulated by tools and middleware during one run.
|
|
@@ -151,7 +157,19 @@ class TaskEventMiddleware(AgentMiddleware):
|
|
|
151
157
|
request: ModelRequest,
|
|
152
158
|
handler: Callable[[ModelRequest], Awaitable[ModelResponse]],
|
|
153
159
|
) -> ModelResponse:
|
|
154
|
-
"""Record the assistant response before any tool it requests runs.
|
|
160
|
+
"""Record the assistant response before any tool it requests runs.
|
|
161
|
+
|
|
162
|
+
Once the tool budget is spent, the model gets no tools except the
|
|
163
|
+
structured answer tool, which the agent binds from its response format.
|
|
164
|
+
"""
|
|
165
|
+
# Every tool call is refused after the budget is spent, so a model that
|
|
166
|
+
# still sees tools keeps requesting them until the recursion limit ends
|
|
167
|
+
# the run without an answer.
|
|
168
|
+
if self._run_state.budget_exhausted:
|
|
169
|
+
request = request.override(
|
|
170
|
+
tools=[],
|
|
171
|
+
messages=[*request.messages, HumanMessage(content=_BUDGET_SPENT_NOTE)],
|
|
172
|
+
)
|
|
155
173
|
response = await handler(request)
|
|
156
174
|
for message in response.result:
|
|
157
175
|
await record_event_or_flag(
|
|
@@ -14,7 +14,7 @@ _UNSUPPORTED_PROVIDERS = frozenset(
|
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
def build_chat_model(config: LLMClientConfig) -> Any:
|
|
17
|
+
def build_chat_model(config: LLMClientConfig, *, max_retries: int | None = None) -> Any:
|
|
18
18
|
"""Translate one LLMClientConfig into a LangChain chat model.
|
|
19
19
|
|
|
20
20
|
Covers anthropic, openai, openai-generic (mapped to ChatOpenAI
|
|
@@ -23,6 +23,8 @@ def build_chat_model(config: LLMClientConfig) -> Any:
|
|
|
23
23
|
|
|
24
24
|
Args:
|
|
25
25
|
config: The provider, model, api_key, and base_url to use.
|
|
26
|
+
max_retries: Retries of one model call after a failed attempt.
|
|
27
|
+
``None`` keeps the provider library's default.
|
|
26
28
|
|
|
27
29
|
Returns:
|
|
28
30
|
A constructed, ready-to-call BaseChatModel.
|
|
@@ -39,6 +41,9 @@ def build_chat_model(config: LLMClientConfig) -> Any:
|
|
|
39
41
|
)
|
|
40
42
|
|
|
41
43
|
api_key = config.api_key.get_secret_value() if config.api_key else None
|
|
44
|
+
retry_kwargs: dict[str, Any] = (
|
|
45
|
+
{} if max_retries is None else {"max_retries": max_retries}
|
|
46
|
+
)
|
|
42
47
|
|
|
43
48
|
if config.provider == "anthropic":
|
|
44
49
|
from langchain_anthropic import ( # noqa: PLC0415
|
|
@@ -48,6 +53,7 @@ def build_chat_model(config: LLMClientConfig) -> Any:
|
|
|
48
53
|
return ChatAnthropic(
|
|
49
54
|
model=config.model,
|
|
50
55
|
api_key=api_key,
|
|
56
|
+
**retry_kwargs,
|
|
51
57
|
)
|
|
52
58
|
|
|
53
59
|
if config.provider == "openai":
|
|
@@ -56,7 +62,7 @@ def build_chat_model(config: LLMClientConfig) -> Any:
|
|
|
56
62
|
kwargs: dict[str, Any] = {"model": config.model}
|
|
57
63
|
if api_key:
|
|
58
64
|
kwargs["api_key"] = api_key
|
|
59
|
-
return ChatOpenAI(**kwargs)
|
|
65
|
+
return ChatOpenAI(**kwargs, **retry_kwargs)
|
|
60
66
|
|
|
61
67
|
if config.provider == "openai-generic":
|
|
62
68
|
from langchain_openai import ChatOpenAI # noqa: PLC0415
|
|
@@ -66,7 +72,7 @@ def build_chat_model(config: LLMClientConfig) -> Any:
|
|
|
66
72
|
generic_kwargs["base_url"] = config.base_url
|
|
67
73
|
if api_key:
|
|
68
74
|
generic_kwargs["api_key"] = api_key
|
|
69
|
-
return ChatOpenAI(**generic_kwargs)
|
|
75
|
+
return ChatOpenAI(**generic_kwargs, **retry_kwargs)
|
|
70
76
|
|
|
71
77
|
if config.provider == "google-ai":
|
|
72
78
|
from langchain_google_genai import ( # noqa: PLC0415
|
|
@@ -76,6 +82,7 @@ def build_chat_model(config: LLMClientConfig) -> Any:
|
|
|
76
82
|
return ChatGoogleGenerativeAI(
|
|
77
83
|
model=config.model,
|
|
78
84
|
google_api_key=api_key,
|
|
85
|
+
**retry_kwargs,
|
|
79
86
|
)
|
|
80
87
|
|
|
81
88
|
raise UnsupportedAgentProviderError(
|
|
@@ -87,6 +94,7 @@ def build_model_middleware(
|
|
|
87
94
|
clients: list[LLMClientConfig],
|
|
88
95
|
*,
|
|
89
96
|
strategy: Literal["single", "fallback", "round_robin"] = "single",
|
|
97
|
+
max_retries: int | None = None,
|
|
90
98
|
) -> list[Any]:
|
|
91
99
|
"""Build agent middleware composing multiple clients per strategy.
|
|
92
100
|
|
|
@@ -100,6 +108,7 @@ def build_model_middleware(
|
|
|
100
108
|
clients: The configured clients, in priority order.
|
|
101
109
|
strategy: How to compose ``clients``. ``"single"`` ignores all
|
|
102
110
|
but the first client.
|
|
111
|
+
max_retries: Passed to ``build_chat_model`` for every client.
|
|
103
112
|
|
|
104
113
|
Returns:
|
|
105
114
|
Middleware for create_deep_agent/create_agent; empty when there
|
|
@@ -112,7 +121,7 @@ def build_model_middleware(
|
|
|
112
121
|
if strategy == "single" or len(clients) <= 1:
|
|
113
122
|
return []
|
|
114
123
|
|
|
115
|
-
models = [build_chat_model(client) for client in clients]
|
|
124
|
+
models = [build_chat_model(client, max_retries=max_retries) for client in clients]
|
|
116
125
|
if strategy == "fallback":
|
|
117
126
|
from langchain.agents.middleware import ( # noqa: PLC0415
|
|
118
127
|
ModelFallbackMiddleware,
|
|
@@ -26,6 +26,9 @@ class AgentLLMSettings(BaseSettings):
|
|
|
26
26
|
tries the other clients in order when a model call fails;
|
|
27
27
|
``"round_robin"`` rotates across all clients per call.
|
|
28
28
|
Ignored with one client.
|
|
29
|
+
max_retries: Retries of one agent model call after a failed attempt,
|
|
30
|
+
such as HTTP 429 or a connection error. ``None`` keeps the
|
|
31
|
+
provider library's default. Env: ``AGENT_LLM_MAX_RETRIES``.
|
|
29
32
|
|
|
30
33
|
Env prefix: ``AGENT_LLM_``.
|
|
31
34
|
"""
|
|
@@ -39,6 +42,7 @@ class AgentLLMSettings(BaseSettings):
|
|
|
39
42
|
|
|
40
43
|
clients: list[LLMClientConfig]
|
|
41
44
|
strategy: Literal["single", "fallback", "round_robin"] = "single"
|
|
45
|
+
max_retries: int | None = Field(default=None, ge=0)
|
|
42
46
|
|
|
43
47
|
@classmethod
|
|
44
48
|
def from_openai_compatible_env(cls) -> "AgentLLMSettings":
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Loop-scoped async locks shared by internal callers."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
from collections.abc import Hashable
|
|
5
|
+
from threading import Lock
|
|
6
|
+
from weakref import WeakKeyDictionary, WeakValueDictionary
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
_LoopLockRegistry = WeakKeyDictionary[
|
|
10
|
+
asyncio.AbstractEventLoop,
|
|
11
|
+
WeakValueDictionary[Hashable, asyncio.Lock],
|
|
12
|
+
]
|
|
13
|
+
# Different event loops can use these registries from different threads.
|
|
14
|
+
_registry_lock = Lock()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _get_loop_lock(registry: _LoopLockRegistry, key: Hashable) -> asyncio.Lock:
|
|
18
|
+
"""Return the shared lock for a key on the running event loop."""
|
|
19
|
+
loop = asyncio.get_running_loop()
|
|
20
|
+
with _registry_lock:
|
|
21
|
+
locks = registry.get(loop)
|
|
22
|
+
if locks is None:
|
|
23
|
+
locks = WeakValueDictionary()
|
|
24
|
+
registry[loop] = locks
|
|
25
|
+
lock = locks.get(key)
|
|
26
|
+
if lock is None:
|
|
27
|
+
lock = asyncio.Lock()
|
|
28
|
+
locks[key] = lock
|
|
29
|
+
return lock
|
|
@@ -35,6 +35,7 @@ _RESERVED_ENTITY_PROPERTY_NAMES = frozenset(
|
|
|
35
35
|
"name",
|
|
36
36
|
"merge_key",
|
|
37
37
|
"merge_count",
|
|
38
|
+
"merge_write_id",
|
|
38
39
|
"source_chunk_ids",
|
|
39
40
|
"created_at",
|
|
40
41
|
"embedding",
|
|
@@ -236,8 +237,8 @@ class EntityType(BaseModel):
|
|
|
236
237
|
properties: Property names mapped to their ``PropertySpec``. Properties
|
|
237
238
|
are not inherited from parents. ``label``, ``text`` and the keys
|
|
238
239
|
the graph writes itself (``id``, ``name``, ``merge_key``,
|
|
239
|
-
``merge_count``, ``
|
|
240
|
-
``embedding``) are rejected as names.
|
|
240
|
+
``merge_count``, ``merge_write_id``, ``source_chunk_ids``,
|
|
241
|
+
``created_at``, ``embedding``) are rejected as names.
|
|
241
242
|
"""
|
|
242
243
|
|
|
243
244
|
model_config = ConfigDict(extra="forbid")
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Cutover Job lock and the fence that stops a lost job's pending writes."""
|
|
2
|
+
|
|
3
|
+
from agrag.common.data_models.cutover_job import CUTOVER_JOB_LABEL
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def job_lock_clause(alias: str = "job") -> str:
|
|
7
|
+
"""Build Cypher that locks a job before its fencing guard runs."""
|
|
8
|
+
return f"SET {alias}.lease_token = {alias}.lease_token + '' WITH {alias} "
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _live_pending(alias: str) -> str:
|
|
12
|
+
"""Return the predicate that holds while a job may still write pending rows."""
|
|
13
|
+
return f"{alias}.status = 'pending' AND {alias}.lease_expires_at >= timestamp()"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def fenced_write_query(query: str) -> str:
|
|
17
|
+
"""Prefix a pending write with a guard on its Cutover Job.
|
|
18
|
+
|
|
19
|
+
The guard takes the job's lock, the same lock that recovery takes before
|
|
20
|
+
it claims an expired job, and lets the write run only while the job is
|
|
21
|
+
pending with a live lease. A worker whose job was claimed, rolled back or
|
|
22
|
+
replaced therefore writes nothing, so no row is left tagged with an id
|
|
23
|
+
that no rollback will ever look for.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
query: A write query. It must not use the ``fence_job`` variable.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
The guarded query. It expects ``$pending_job_id`` in addition to the
|
|
30
|
+
parameters of ``query``.
|
|
31
|
+
"""
|
|
32
|
+
return (
|
|
33
|
+
f"MATCH (fence_job:{CUTOVER_JOB_LABEL} {{id: $pending_job_id}}) "
|
|
34
|
+
f"{job_lock_clause('fence_job')}"
|
|
35
|
+
f"WHERE {_live_pending('fence_job')} "
|
|
36
|
+
f"{query}"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def job_live_query() -> str:
|
|
41
|
+
"""Build Cypher reading whether a Cutover Job may still write pending rows.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
Parameterized Cypher expecting ``$pending_job_id``. Returns the job id
|
|
45
|
+
while the job is pending with a live lease, no row otherwise.
|
|
46
|
+
"""
|
|
47
|
+
return (
|
|
48
|
+
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $pending_job_id}}) "
|
|
49
|
+
f"WHERE {_live_pending('job')} "
|
|
50
|
+
"RETURN job.id AS id"
|
|
51
|
+
)
|
|
@@ -19,11 +19,10 @@ def find_incomplete_jobs_query() -> str:
|
|
|
19
19
|
Returns:
|
|
20
20
|
Parameterized Cypher expecting no parameters. Returns each
|
|
21
21
|
incomplete job's id, status, lease token, affected-entity snapshot,
|
|
22
|
-
component seed ids and created entity ids (both set
|
|
23
|
-
|
|
24
|
-
applied, the stored commit plan, how many deferred-write steps
|
|
25
|
-
|
|
26
|
-
lapsed. The lease token is
|
|
22
|
+
component seed ids and created entity ids (both set when the commit
|
|
23
|
+
started), whether its commit had started, whether its document writes
|
|
24
|
+
were applied, the stored commit plan, how many deferred-write steps it
|
|
25
|
+
had replayed, and whether its lease has lapsed. The lease token is
|
|
27
26
|
required to fence the subsequent recovery claim.
|
|
28
27
|
"""
|
|
29
28
|
return (
|
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
from agrag.common.data_models.cutover_job import CUTOVER_JOB_LABEL
|
|
4
4
|
from agrag.common.data_models.graph_record import PENDING_JOB_ID_PROPERTY
|
|
5
|
+
from agrag.cypher._job_fence import job_lock_clause
|
|
5
6
|
from agrag.cypher.entities import validate_identifier, validate_identifier_syntax
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
def _job_lock_clause() -> str:
|
|
9
|
-
"""Build Cypher that locks a job before its fencing guard runs."""
|
|
10
|
-
return "SET job.lease_token = job.lease_token + '' WITH job "
|
|
11
|
-
|
|
12
|
-
|
|
13
9
|
def acquire_lease_query() -> str:
|
|
14
10
|
"""Build Cypher tentatively creating a job node and returning its lease.
|
|
15
11
|
|
|
@@ -67,7 +63,7 @@ def steal_terminal_job_query() -> str:
|
|
|
67
63
|
"""
|
|
68
64
|
return (
|
|
69
65
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{document_key: $document_key}}) "
|
|
70
|
-
f"{
|
|
66
|
+
f"{job_lock_clause()}"
|
|
71
67
|
"WHERE job.lease_token = $expected_lease_token "
|
|
72
68
|
"AND job.status IN ['done', 'rolled_back'] "
|
|
73
69
|
"SET job.id = $job_id, job.status = 'pending', job.verb = $verb, "
|
|
@@ -76,7 +72,7 @@ def steal_terminal_job_query() -> str:
|
|
|
76
72
|
"job.affected_entity_ids = $affected_entity_ids, "
|
|
77
73
|
"job.created_at = $created_at, job.commit_started = false, "
|
|
78
74
|
"job.commit_docs_applied = false, job.commit_plan = null, "
|
|
79
|
-
"job.commit_replayed = 0 "
|
|
75
|
+
"job.commit_replayed = 0, job.parts_closed = null "
|
|
80
76
|
"RETURN job.lease_token AS lease_token"
|
|
81
77
|
)
|
|
82
78
|
|
|
@@ -104,7 +100,7 @@ def claim_job_query() -> str:
|
|
|
104
100
|
"""
|
|
105
101
|
return (
|
|
106
102
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
107
|
-
f"{
|
|
103
|
+
f"{job_lock_clause()}"
|
|
108
104
|
"WHERE job.status IN ['committed', 'cleaning'] "
|
|
109
105
|
"AND job.lease_token = $expected_lease_token "
|
|
110
106
|
"AND job.lease_expires_at < timestamp() "
|
|
@@ -130,7 +126,7 @@ def claim_pending_job_query() -> str:
|
|
|
130
126
|
"""
|
|
131
127
|
return (
|
|
132
128
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
133
|
-
f"{
|
|
129
|
+
f"{job_lock_clause()}"
|
|
134
130
|
"WHERE job.status IN ['pending', 'rolling_back'] "
|
|
135
131
|
"AND coalesce(job.commit_started, false) = false "
|
|
136
132
|
"AND job.lease_token = $expected_lease_token "
|
|
@@ -150,7 +146,7 @@ def begin_rollback_query() -> str:
|
|
|
150
146
|
"""
|
|
151
147
|
return (
|
|
152
148
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
153
|
-
f"{
|
|
149
|
+
f"{job_lock_clause()}"
|
|
154
150
|
"WHERE job.lease_token = $lease_token AND job.status = 'pending' "
|
|
155
151
|
"AND coalesce(job.commit_started, false) = false "
|
|
156
152
|
"SET job.status = 'rolling_back' "
|
|
@@ -158,24 +154,70 @@ def begin_rollback_query() -> str:
|
|
|
158
154
|
)
|
|
159
155
|
|
|
160
156
|
|
|
157
|
+
def job_owner_live_query() -> str:
|
|
158
|
+
"""Check whether a Cutover Job can still commit or roll back its rows.
|
|
159
|
+
|
|
160
|
+
A pending or rolling-back job whose lease has expired can no longer commit,
|
|
161
|
+
so it reads as not live. A missing job node also reads as not live.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
Parameterized Cypher expecting $job_id. Returns one row with the boolean
|
|
165
|
+
``live``.
|
|
166
|
+
"""
|
|
167
|
+
return (
|
|
168
|
+
f"OPTIONAL MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
169
|
+
"RETURN coalesce(job.status IN ['pending', 'rolling_back'] "
|
|
170
|
+
"AND job.lease_expires_at >= timestamp(), false) AS live"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
|
|
161
174
|
def job_status_query() -> str:
|
|
162
|
-
"""Read a job's status, lease token,
|
|
175
|
+
"""Read a job's status, lease token, closed-edge count and commit progress.
|
|
176
|
+
|
|
177
|
+
The commit fields tell a retry whether the commit mark persisted and how
|
|
178
|
+
far the commit got. A missing mark reads as false and zero.
|
|
179
|
+
"""
|
|
163
180
|
return (
|
|
164
181
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
165
182
|
"RETURN job.status AS status, job.lease_token AS lease_token, "
|
|
166
|
-
"job.parts_closed AS parts_closed"
|
|
183
|
+
"job.parts_closed AS parts_closed, "
|
|
184
|
+
"coalesce(job.commit_started, false) AS commit_started, "
|
|
185
|
+
"coalesce(job.commit_replayed, 0) AS commit_replayed, "
|
|
186
|
+
"coalesce(job.commit_docs_applied, false) AS commit_docs_applied"
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def resume_commit_fence_query() -> str:
|
|
191
|
+
"""Build Cypher confirming a started commit still belongs to this worker.
|
|
192
|
+
|
|
193
|
+
A resumed commit keeps the mark its first attempt set, so the fence
|
|
194
|
+
checks the lease and the pending state without writing to the job.
|
|
195
|
+
|
|
196
|
+
Returns:
|
|
197
|
+
Parameterized Cypher expecting $job_id and $lease_token. Returns the
|
|
198
|
+
job id when the lease is live and the commit has started, no row
|
|
199
|
+
otherwise.
|
|
200
|
+
"""
|
|
201
|
+
return (
|
|
202
|
+
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
203
|
+
f"{job_lock_clause()}"
|
|
204
|
+
"WHERE job.lease_token = $lease_token "
|
|
205
|
+
"AND job.lease_expires_at >= timestamp() "
|
|
206
|
+
"AND job.status = 'pending' AND job.commit_started = true "
|
|
207
|
+
"RETURN job.id AS id"
|
|
167
208
|
)
|
|
168
209
|
|
|
169
210
|
|
|
170
211
|
def record_parts_closed_query() -> str:
|
|
171
|
-
"""
|
|
212
|
+
"""Mark a job's document writes applied.
|
|
172
213
|
|
|
173
|
-
This is the last of the commit's document writes
|
|
174
|
-
|
|
214
|
+
This is the last of the commit's document writes. Crash recovery skips the
|
|
215
|
+
document writes of a job that has the mark. The closed-edge count is
|
|
216
|
+
recorded by the close statement itself.
|
|
175
217
|
"""
|
|
176
218
|
return (
|
|
177
219
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
178
|
-
"SET job.
|
|
220
|
+
"SET job.commit_docs_applied = true"
|
|
179
221
|
)
|
|
180
222
|
|
|
181
223
|
|
|
@@ -201,21 +243,26 @@ def begin_commit_query() -> str:
|
|
|
201
243
|
(roll it back) from one that died part way through the commit (finish it).
|
|
202
244
|
It applies only under the same fence as ``commit_job_query``. It also
|
|
203
245
|
stores ``$commit_plan``, the serialized document writes of the commit, so
|
|
204
|
-
recovery can repeat the ones that had not finished.
|
|
246
|
+
recovery can repeat the ones that had not finished. The component seeds
|
|
247
|
+
and created entities are stored here too, so recovery can run the same
|
|
248
|
+
cleanup when the worker dies before the flip.
|
|
205
249
|
|
|
206
250
|
Returns:
|
|
207
|
-
Parameterized Cypher expecting $job_id, $lease_token
|
|
208
|
-
(a JSON string)
|
|
209
|
-
job id when the mark was set, no row on
|
|
251
|
+
Parameterized Cypher expecting $job_id, $lease_token, $commit_plan
|
|
252
|
+
(a JSON string), $component_seed_ids and $created_entity_ids (lists
|
|
253
|
+
of string ids). Returns the job id when the mark was set, no row on
|
|
254
|
+
fencing failure.
|
|
210
255
|
"""
|
|
211
256
|
return (
|
|
212
257
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
213
|
-
f"{
|
|
258
|
+
f"{job_lock_clause()}"
|
|
214
259
|
"WHERE job.lease_token = $lease_token "
|
|
215
260
|
"AND job.lease_expires_at >= timestamp() "
|
|
216
261
|
"AND job.status = 'pending' "
|
|
217
262
|
"SET job.commit_started = true, job.commit_plan = $commit_plan, "
|
|
218
|
-
"job.commit_replayed = 0 "
|
|
263
|
+
"job.commit_replayed = 0, "
|
|
264
|
+
"job.component_seed_ids = $component_seed_ids, "
|
|
265
|
+
"job.created_entity_ids = $created_entity_ids "
|
|
219
266
|
"RETURN job.id AS id"
|
|
220
267
|
)
|
|
221
268
|
|
|
@@ -235,7 +282,7 @@ def claim_commit_query() -> str:
|
|
|
235
282
|
"""
|
|
236
283
|
return (
|
|
237
284
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
238
|
-
f"{
|
|
285
|
+
f"{job_lock_clause()}"
|
|
239
286
|
"WHERE job.status = 'pending' AND job.commit_started = true "
|
|
240
287
|
"AND job.lease_token = $expected_lease_token "
|
|
241
288
|
"AND job.lease_expires_at < timestamp() "
|
|
@@ -268,7 +315,7 @@ def commit_job_query() -> str:
|
|
|
268
315
|
"""
|
|
269
316
|
return (
|
|
270
317
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
271
|
-
f"{
|
|
318
|
+
f"{job_lock_clause()}"
|
|
272
319
|
"WHERE job.lease_token = $lease_token "
|
|
273
320
|
"AND job.lease_expires_at >= timestamp() "
|
|
274
321
|
"AND job.status = 'pending' "
|
|
@@ -458,7 +505,7 @@ def start_cleaning_query() -> str:
|
|
|
458
505
|
"""
|
|
459
506
|
return (
|
|
460
507
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
461
|
-
f"{
|
|
508
|
+
f"{job_lock_clause()}"
|
|
462
509
|
"WHERE job.lease_token = $lease_token "
|
|
463
510
|
"AND job.lease_expires_at >= timestamp() "
|
|
464
511
|
"AND job.status = 'committed' "
|
|
@@ -482,7 +529,7 @@ def renew_lease_query() -> str:
|
|
|
482
529
|
"""
|
|
483
530
|
return (
|
|
484
531
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
485
|
-
f"{
|
|
532
|
+
f"{job_lock_clause()}"
|
|
486
533
|
"WHERE job.lease_token = $lease_token "
|
|
487
534
|
"AND job.lease_expires_at >= timestamp() "
|
|
488
535
|
"AND job.status IN ['pending', 'rolling_back', 'committed', 'cleaning'] "
|
|
@@ -503,7 +550,7 @@ def finish_cleaning_query() -> str:
|
|
|
503
550
|
"""
|
|
504
551
|
return (
|
|
505
552
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
506
|
-
f"{
|
|
553
|
+
f"{job_lock_clause()}"
|
|
507
554
|
"WHERE job.lease_token = $lease_token "
|
|
508
555
|
"AND job.lease_expires_at >= timestamp() "
|
|
509
556
|
"AND job.status = 'cleaning' "
|
|
@@ -526,7 +573,7 @@ def lock_rolling_back_job_query() -> str:
|
|
|
526
573
|
"""
|
|
527
574
|
return (
|
|
528
575
|
f"MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
529
|
-
f"{
|
|
576
|
+
f"{job_lock_clause()}"
|
|
530
577
|
"WHERE job.lease_token = $lease_token AND job.status = 'rolling_back' "
|
|
531
578
|
"RETURN job.id AS id"
|
|
532
579
|
)
|
|
@@ -137,7 +137,12 @@ def record_activation_query() -> str:
|
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
def flag_decisions_for_activation_query() -> str:
|
|
140
|
-
"""Build a project-independent direct flag for one committed activation.
|
|
140
|
+
"""Build a project-independent direct flag for one committed activation.
|
|
141
|
+
|
|
142
|
+
Each decision records the activation that flagged it, and its project's
|
|
143
|
+
review epoch moves only on the first flag from that activation. A repeated
|
|
144
|
+
run therefore leaves the epoch as the first run left it.
|
|
145
|
+
"""
|
|
141
146
|
return (
|
|
142
147
|
f"MATCH (doc:Document)-[:{HAS_ACTIVATION}]->"
|
|
143
148
|
f"(a:{DOCUMENT_ACTIVATION_LABEL} {{id: $activation_id}}) "
|
|
@@ -153,8 +158,11 @@ def flag_decisions_for_activation_query() -> str:
|
|
|
153
158
|
f"MATCH (t:Task {{{HISTORY_RECORD_PROPERTY}: true}})-[:MADE]->(d) "
|
|
154
159
|
f"MATCH (p:Project {{{HISTORY_RECORD_PROPERTY}: true, "
|
|
155
160
|
"project_id: t.project_id}) "
|
|
161
|
+
"WITH d, a, p, coalesce(d.review_activation_id, '') <> a.id AS first_flag "
|
|
156
162
|
"SET p.review_incomplete = true, "
|
|
157
|
-
"p.review_epoch = coalesce(p.review_epoch, 0) +
|
|
163
|
+
"p.review_epoch = coalesce(p.review_epoch, 0) + CASE WHEN first_flag "
|
|
164
|
+
"THEN 1 ELSE 0 END, "
|
|
165
|
+
"d.review_activation_id = a.id, "
|
|
158
166
|
"d.review_pending = true, d.review_state = 'needs_review', "
|
|
159
167
|
"d.review_reason = CASE WHEN a.verb IN ['delete', 'purge'] "
|
|
160
168
|
"THEN 'source_removed' ELSE 'source_changed' END "
|
|
@@ -234,14 +234,16 @@ def upsert_merge_alias_query() -> str:
|
|
|
234
234
|
outside a job — null sets no property). Returns each merge_key
|
|
235
235
|
alongside the entity_id that now owns it -- $entity_id when this
|
|
236
236
|
call claimed or already owned it, another entity's id when a
|
|
237
|
-
different one claimed it first
|
|
237
|
+
different one claimed it first -- and ``owner_job_id``, the pending
|
|
238
|
+
job that wrote the alias, or null once that job has committed.
|
|
238
239
|
"""
|
|
239
240
|
return (
|
|
240
241
|
f"UNWIND $merge_keys AS merge_key "
|
|
241
242
|
f"MERGE (a:{MERGE_ALIAS_LABEL} {{merge_key: merge_key}}) "
|
|
242
243
|
f"ON CREATE SET a.entity_id = $entity_id, "
|
|
243
244
|
f"a.{PENDING_JOB_ID_PROPERTY} = $pending_job_id "
|
|
244
|
-
f"RETURN merge_key, a.entity_id AS entity_id"
|
|
245
|
+
f"RETURN merge_key, a.entity_id AS entity_id, "
|
|
246
|
+
f"a.{PENDING_JOB_ID_PROPERTY} AS owner_job_id"
|
|
245
247
|
)
|
|
246
248
|
|
|
247
249
|
|
|
@@ -260,6 +262,11 @@ def upsert_survivor_query(labels: Sequence[str], *, extra_set: str = "") -> str:
|
|
|
260
262
|
values, which only a Python-side read can gather, so making that
|
|
261
263
|
atomic too is out of scope here.
|
|
262
264
|
|
|
265
|
+
A record's ``merge_write_id`` identifies one merge write. The node keeps the
|
|
266
|
+
last id it applied, and a record with that id adds no delta, so a repeated
|
|
267
|
+
write of the same merge changes the count once. A record without an id always
|
|
268
|
+
adds its delta.
|
|
269
|
+
|
|
263
270
|
The Cutover Job tag is set only when the ``MERGE`` creates the node. A
|
|
264
271
|
write over a row the job did not create is not applied: the row reports
|
|
265
272
|
``written`` false, and the store defers the write to the job's commit
|
|
@@ -293,14 +300,18 @@ def upsert_survivor_query(labels: Sequence[str], *, extra_set: str = "") -> str:
|
|
|
293
300
|
f"ON CREATE SET n.{PENDING_JOB_ID_PROPERTY} = record.pending_job_id "
|
|
294
301
|
f"WITH n, record, {own} AS own, "
|
|
295
302
|
f"coalesce(n.source_chunk_ids, []) AS existing_source_chunk_ids, "
|
|
296
|
-
f"coalesce(n.merge_count, 0) AS existing_merge_count "
|
|
303
|
+
f"coalesce(n.merge_count, 0) AS existing_merge_count, "
|
|
304
|
+
f"record.merge_write_id IS NOT NULL "
|
|
305
|
+
f"AND n.merge_write_id = record.merge_write_id AS already_merged "
|
|
297
306
|
f"FOREACH (_ IN CASE WHEN own THEN [1] ELSE [] END | "
|
|
298
307
|
f"SET n:{label_expr} "
|
|
299
308
|
f"SET n += record.properties "
|
|
300
309
|
f"SET n.source_chunk_ids = [x IN existing_source_chunk_ids "
|
|
301
310
|
f"WHERE NOT x IN record.new_source_chunk_ids] "
|
|
302
311
|
f"+ record.new_source_chunk_ids "
|
|
303
|
-
f"SET n.merge_count = existing_merge_count
|
|
312
|
+
f"SET n.merge_count = existing_merge_count "
|
|
313
|
+
f"+ CASE WHEN already_merged THEN 0 ELSE record.merge_count_delta END "
|
|
314
|
+
f"SET n.merge_write_id = coalesce(record.merge_write_id, n.merge_write_id) "
|
|
304
315
|
f"{extra_set + ' ' if extra_set else ''}"
|
|
305
316
|
f"SET n.id = record.id) "
|
|
306
317
|
f"RETURN record.id AS id, own AS written"
|
|
@@ -8,6 +8,7 @@ from collections.abc import Sequence
|
|
|
8
8
|
from typing import Any, Literal
|
|
9
9
|
|
|
10
10
|
from agrag.common.data_models.candidate import CANDIDATE_EDGE_TYPES
|
|
11
|
+
from agrag.common.data_models.cutover_job import CUTOVER_JOB_LABEL
|
|
11
12
|
from agrag.common.data_models.graph_record import PENDING_JOB_ID_PROPERTY
|
|
12
13
|
from agrag.common.data_models.structure import (
|
|
13
14
|
DOCUMENT_ACTIVATION_LABEL,
|
|
@@ -91,11 +92,15 @@ def close_has_part_query() -> str:
|
|
|
91
92
|
figure with the id of a committed one reuses its edge without tagging it,
|
|
92
93
|
and the edge must outlive the close.
|
|
93
94
|
|
|
95
|
+
The first run that closes edges also records the count on the job, in the
|
|
96
|
+
same statement. A repeated run closes nothing, so it returns the recorded
|
|
97
|
+
count instead of zero.
|
|
98
|
+
|
|
94
99
|
Returns:
|
|
95
100
|
Parameterized Cypher expecting $document_node_id, $keep_node_ids
|
|
96
|
-
(a list of node id strings)
|
|
97
|
-
becomes each closed edge's ``invalid_at``). Returns the
|
|
98
|
-
|
|
101
|
+
(a list of node id strings), $closed_at (an ISO-8601 string that
|
|
102
|
+
becomes each closed edge's ``invalid_at``) and $job_id. Returns the
|
|
103
|
+
number of edges closed by the first run, or the recorded count.
|
|
99
104
|
"""
|
|
100
105
|
# The caller supplies the close time so the query does not depend on a
|
|
101
106
|
# server-side clock function.
|
|
@@ -104,7 +109,12 @@ def close_has_part_query() -> str:
|
|
|
104
109
|
f"-[r:{HAS_PART}]->(c) "
|
|
105
110
|
f"WHERE r.invalid_at IS NULL AND {pending_filter_clause('r')} "
|
|
106
111
|
"AND NOT c.id IN $keep_node_ids "
|
|
107
|
-
"SET r.invalid_at = $closed_at
|
|
112
|
+
"SET r.invalid_at = $closed_at "
|
|
113
|
+
"WITH count(r) AS closed "
|
|
114
|
+
f"OPTIONAL MATCH (job:{CUTOVER_JOB_LABEL} {{id: $job_id}}) "
|
|
115
|
+
"FOREACH (_ IN CASE WHEN job IS NULL OR job.parts_closed IS NOT NULL "
|
|
116
|
+
"THEN [] ELSE [1] END | SET job.parts_closed = closed) "
|
|
117
|
+
"RETURN coalesce(job.parts_closed, closed) AS closed"
|
|
108
118
|
)
|
|
109
119
|
|
|
110
120
|
|