dandelion-memory 1.0.0rc15__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.
- benchmarks/__init__.py +3 -0
- benchmarks/adapters/__init__.py +29 -0
- benchmarks/adapters/ablations.py +406 -0
- benchmarks/adapters/base.py +72 -0
- benchmarks/adapters/controlled/__init__.py +13 -0
- benchmarks/adapters/controlled/core_archival.py +115 -0
- benchmarks/adapters/controlled/extract_resolve.py +130 -0
- benchmarks/adapters/controlled/hybrid_rag.py +120 -0
- benchmarks/adapters/controlled/no_late_binding.py +113 -0
- benchmarks/adapters/dandelion.py +94 -0
- benchmarks/adapters/native/__init__.py +31 -0
- benchmarks/adapters/native/base.py +45 -0
- benchmarks/adapters/native/dandelion_native.py +164 -0
- benchmarks/adapters/native/dandelion_native_b0.py +165 -0
- benchmarks/adapters/native/dandelion_native_b1.py +170 -0
- benchmarks/adapters/native/dandelion_native_b2.py +169 -0
- benchmarks/adapters/native/dandelion_native_b3.py +171 -0
- benchmarks/adapters/native/dandelion_native_c4.py +261 -0
- benchmarks/adapters/native/dandelion_native_c4_1.py +281 -0
- benchmarks/adapters/native/dandelion_native_c4_2.py +435 -0
- benchmarks/adapters/native/event_evidence_b2.py +616 -0
- benchmarks/adapters/native/evidence_b2.py +609 -0
- benchmarks/adapters/native/letta_native.py +253 -0
- benchmarks/adapters/native/mem0_native.py +219 -0
- benchmarks/adapters/native/store_vector_b0.py +792 -0
- benchmarks/adapters/native/store_vector_b2.py +808 -0
- benchmarks/agent_adapter_stdio_acceptance.py +86 -0
- benchmarks/bootstrap_cross_stack.py +218 -0
- benchmarks/canonical_profile_instrumentation.py +167 -0
- benchmarks/canonical_public_baseline.py +288 -0
- benchmarks/cli.py +525 -0
- benchmarks/collector_public30_offline.py +1653 -0
- benchmarks/datasets/__init__.py +45 -0
- benchmarks/datasets/conversational_generator.py +238 -0
- benchmarks/datasets/generator.py +283 -0
- benchmarks/datasets/holdout_topology_generator.py +290 -0
- benchmarks/datasets/holdout_topology_generator_v2.py +294 -0
- benchmarks/datasets/multi_world.py +1643 -0
- benchmarks/datasets/scale_generator.py +289 -0
- benchmarks/datasets/schema.py +57 -0
- benchmarks/deep_collision_stress.py +199 -0
- benchmarks/evaluators/__init__.py +12 -0
- benchmarks/evaluators/manifest.py +142 -0
- benchmarks/evaluators/metrics.py +277 -0
- benchmarks/evaluators/runner.py +258 -0
- benchmarks/f1_step0/build_dev_measurement_manifest_v1.py +127 -0
- benchmarks/f1_step0/build_dev_measurement_manifest_v2.py +127 -0
- benchmarks/f1_step0/build_dev_measurement_manifest_v3.py +146 -0
- benchmarks/f1_step0/build_ledger.py +143 -0
- benchmarks/f1_step0/build_ledger_v2.py +296 -0
- benchmarks/f1_step0/compare_dev52_readiness_v1.py +106 -0
- benchmarks/f1_step0/locator_public_smoke.py +172 -0
- benchmarks/f1_step0/prepare_dev52_owner_v1.py +133 -0
- benchmarks/f1_step0/prepare_dev52_owner_v2.py +133 -0
- benchmarks/f1_step0/public_identity_probe.py +191 -0
- benchmarks/f1_step0/public_response_mapper.py +101 -0
- benchmarks/f1_step0/real_source_public_preflight.py +244 -0
- benchmarks/f1_step0/run_exact_fusion_dev_experiment_v1.py +83 -0
- benchmarks/f1_step0/scorer.py +110 -0
- benchmarks/f1_step0/source_aware_dev_measurement_v1.py +627 -0
- benchmarks/f1_step0/source_aware_dev_measurement_v2.py +659 -0
- benchmarks/f1_step0/source_aware_dev_measurement_v3.py +776 -0
- benchmarks/f1_step0/test_public_response_mapper.py +110 -0
- benchmarks/f1_step0/test_real_source_public_preflight.py +25 -0
- benchmarks/f1_step0/test_scorer.py +158 -0
- benchmarks/f1_step0/test_source_aware_dev_measurement.py +189 -0
- benchmarks/f1_step0/test_source_aware_dev_measurement_v2.py +263 -0
- benchmarks/f1_step0/test_source_aware_dev_measurement_v3.py +334 -0
- benchmarks/f1_step0/typed_readback_public_smoke.py +181 -0
- benchmarks/forensic_c4_1_dev.py +258 -0
- benchmarks/forensic_c4_dev.py +255 -0
- benchmarks/forensic_deep25_c4_1.py +478 -0
- benchmarks/legacy_migration_acceptance.py +29 -0
- benchmarks/longmemeval_actor.py +497 -0
- benchmarks/longmemeval_agent_judge.py +593 -0
- benchmarks/longmemeval_budget.py +139 -0
- benchmarks/longmemeval_full.py +410 -0
- benchmarks/longmemeval_judge.py +327 -0
- benchmarks/longmemeval_pilot.py +316 -0
- benchmarks/longmemeval_s.py +318 -0
- benchmarks/memory_bench.py +248 -0
- benchmarks/memory_formation/__init__.py +1 -0
- benchmarks/memory_formation/audit.py +801 -0
- benchmarks/memory_formation/real_audit.py +688 -0
- benchmarks/memory_session_acceptance.py +279 -0
- benchmarks/native_codex_host.py +513 -0
- benchmarks/owner_dense_acceptance.py +126 -0
- benchmarks/pilot_seeker_vault.py +266 -0
- benchmarks/prepare_public30_ripgrep_range_owner.py +115 -0
- benchmarks/profile_canonical.py +373 -0
- benchmarks/profile_canonical_lanes.py +405 -0
- benchmarks/profile_search_chunks.py +351 -0
- benchmarks/public_ranges_faq_proof.py +121 -0
- benchmarks/public_repos/build_history_scope_v3.py +330 -0
- benchmarks/public_repos/build_oracle.py +108 -0
- benchmarks/public_repos/build_oracle_v2.py +169 -0
- benchmarks/public_repos/build_oracle_v3.py +176 -0
- benchmarks/public_repos/map_public_v2.py +296 -0
- benchmarks/public_repos/project_prompts_v2.py +31 -0
- benchmarks/public_repos/project_prompts_v3.py +29 -0
- benchmarks/public_repos/ready_admin_v2.py +214 -0
- benchmarks/public_repos/score_public_v2.py +258 -0
- benchmarks/public_repos/test_map_public_v2.py +171 -0
- benchmarks/public_repos/test_public_repo_v2.py +44 -0
- benchmarks/public_repos/test_public_repo_v3.py +46 -0
- benchmarks/public_repos/test_ready_admin_v2.py +117 -0
- benchmarks/public_repos/test_score_public_v2.py +163 -0
- benchmarks/public_repos/test_wire_v2.py +292 -0
- benchmarks/public_repos/wire_v2.py +603 -0
- benchmarks/real_blocker_fix_acceptance.py +155 -0
- benchmarks/real_scan_rescan_acceptance.py +41 -0
- benchmarks/recall_v2_20k_smoke.py +112 -0
- benchmarks/recall_v2_e1_retrieve.py +70 -0
- benchmarks/recall_v2_e1_score.py +271 -0
- benchmarks/recall_v2_e2_prepare.py +69 -0
- benchmarks/recall_v2_e2_public_score.py +91 -0
- benchmarks/recall_v2_e2_score.py +108 -0
- benchmarks/recall_v2_navigation_mcp_replay.py +308 -0
- benchmarks/recall_v2_reader_capture.py +118 -0
- benchmarks/recall_v2_reader_replay.py +136 -0
- benchmarks/run_blind_h10_holdout.py +284 -0
- benchmarks/run_blind_h9_holdout.py +275 -0
- benchmarks/run_c4_2_nightly_scale.py +446 -0
- benchmarks/run_context_scale_simulation.py +189 -0
- benchmarks/run_conversational_bench.py +170 -0
- benchmarks/run_h11_evaluation.py +316 -0
- benchmarks/run_h11_v2_evaluation.py +431 -0
- benchmarks/run_native_fixed12.py +469 -0
- benchmarks/run_native_preflight.py +280 -0
- benchmarks/run_scale_stress.py +225 -0
- benchmarks/solanazation_brownfield_01/build_oracle.py +970 -0
- benchmarks/solanazation_brownfield_01/check_level_a.py +78 -0
- benchmarks/solanazation_brownfield_01/debug_scope.py +13 -0
- benchmarks/solanazation_brownfield_01/evaluate_bootstrap_02.py +570 -0
- benchmarks/solanazation_brownfield_01/evaluate_first_pass.py +306 -0
- benchmarks/solanazation_brownfield_01/generate_dryrun_report.py +222 -0
- benchmarks/solanazation_brownfield_01/generate_manifests.py +146 -0
- benchmarks/solanazation_brownfield_01/inspect_misses.py +29 -0
- benchmarks/solanazation_brownfield_01/run_miss_forensic.py +206 -0
- benchmarks/solanazation_brownfield_01/test_facts.py +15 -0
- benchmarks/statistics/__init__.py +15 -0
- benchmarks/statistics/significance.py +326 -0
- benchmarks/test_native_mcp_preflight.py +229 -0
- benchmarks/test_prepare_public30_range_owner.py +35 -0
- benchmarks/test_public30_source_reference.py +698 -0
- benchmarks/test_recall_v2_e1_reader_input.py +89 -0
- benchmarks/test_recall_v2_navigation_mcp_replay.py +155 -0
- benchmarks/test_recall_v2_reader_replay.py +41 -0
- dandelion/__init__.py +3 -0
- dandelion/__main__.py +11 -0
- dandelion/agent_adapter.py +2369 -0
- dandelion/bootstrap/__init__.py +872 -0
- dandelion/bootstrap/alias_policy.py +50 -0
- dandelion/bootstrap/authority.py +225 -0
- dandelion/bootstrap/canonical_history.py +412 -0
- dandelion/bootstrap/classifier.py +403 -0
- dandelion/bootstrap/component_graph.py +280 -0
- dandelion/bootstrap/discovery.py +279 -0
- dandelion/bootstrap/domain_induction.py +180 -0
- dandelion/bootstrap/domain_topology.py +673 -0
- dandelion/bootstrap/evidence_envelope.py +132 -0
- dandelion/bootstrap/extractors/base.py +171 -0
- dandelion/bootstrap/extractors/exact.py +1234 -0
- dandelion/bootstrap/extractors/generic.py +100 -0
- dandelion/bootstrap/extractors/git_temporal.py +111 -0
- dandelion/bootstrap/extractors/registry.py +345 -0
- dandelion/bootstrap/extractors/relations.py +89 -0
- dandelion/bootstrap/extractors/semantic.py +424 -0
- dandelion/bootstrap/extractors/status.py +218 -0
- dandelion/bootstrap/git_sweeper.py +135 -0
- dandelion/bootstrap/manifest.py +246 -0
- dandelion/bootstrap/quarantine.py +264 -0
- dandelion/bootstrap/report.py +259 -0
- dandelion/bootstrap/root_resolver.py +221 -0
- dandelion/bootstrap/tech_profiler.py +125 -0
- dandelion/bootstrap/topology.py +75 -0
- dandelion/bootstrap/topology_index.py +110 -0
- dandelion/bootstrap/transaction.py +315 -0
- dandelion/canonical_bootstrap.py +257 -0
- dandelion/canonical_memory.py +4130 -0
- dandelion/captured_input.py +295 -0
- dandelion/cli.py +767 -0
- dandelion/config.py +40 -0
- dandelion/derived_index.py +745 -0
- dandelion/domains.py +706 -0
- dandelion/embedder.py +229 -0
- dandelion/event_evidence.py +571 -0
- dandelion/evidence.py +812 -0
- dandelion/evidence_response.py +453 -0
- dandelion/evidence_workspace.py +2360 -0
- dandelion/exact_context.py +129 -0
- dandelion/hydrator.py +124 -0
- dandelion/inspector.py +442 -0
- dandelion/inspector_assets/dandelion-mark.svg +33 -0
- dandelion/inspector_assets/dandelion_graph.js +361 -0
- dandelion/inspector_assets/inspector.css +223 -0
- dandelion/inspector_assets/inspector.html +135 -0
- dandelion/inspector_assets/inspector.js +1059 -0
- dandelion/legacy_import.py +431 -0
- dandelion/live_source_grants.py +133 -0
- dandelion/local_owner.py +114 -0
- dandelion/memory_client.py +252 -0
- dandelion/memory_contract.py +107 -0
- dandelion/memory_owner.py +560 -0
- dandelion/reader_providers.py +118 -0
- dandelion/recall_v2.py +767 -0
- dandelion/reconciler.py +219 -0
- dandelion/request_budget.py +125 -0
- dandelion/retained_basis.py +223 -0
- dandelion/retrieval.py +485 -0
- dandelion/router.py +405 -0
- dandelion/search_terms.py +53 -0
- dandelion/security.py +124 -0
- dandelion/server.py +810 -0
- dandelion/source_content_fts.py +219 -0
- dandelion/source_delivery.py +89 -0
- dandelion/source_history.py +241 -0
- dandelion/source_identity.py +88 -0
- dandelion/source_navigator.py +5 -0
- dandelion/source_reader.py +444 -0
- dandelion/source_references.py +379 -0
- dandelion/source_sections.py +265 -0
- dandelion/store_kv.py +684 -0
- dandelion/store_vector.py +1289 -0
- dandelion/studio.py +325 -0
- dandelion/wal.py +227 -0
- dandelion_memory-1.0.0rc15.dist-info/METADATA +48 -0
- dandelion_memory-1.0.0rc15.dist-info/RECORD +232 -0
- dandelion_memory-1.0.0rc15.dist-info/WHEEL +5 -0
- dandelion_memory-1.0.0rc15.dist-info/entry_points.txt +5 -0
- dandelion_memory-1.0.0rc15.dist-info/licenses/LICENSE +21 -0
- dandelion_memory-1.0.0rc15.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
"""Structured Event Evidence Engine for Dandelion (ARCH-EVENT-01 v0.2).
|
|
2
|
+
|
|
3
|
+
Formalizes memory events as structured epistemic claims rather than bare embeddings.
|
|
4
|
+
Implements:
|
|
5
|
+
1. Three-valued logic (MATCH, CONFLICT, UNKNOWN)
|
|
6
|
+
2. Typed EventSignature with distinct identity-bearing and descriptive predicates
|
|
7
|
+
3. Dimensioned scope facets (scope_facets)
|
|
8
|
+
4. EventRelation algebra (SAME_EVENT, RELATED_EVENT, CONFLICTING_EVENT, INSUFFICIENT_EVIDENCE)
|
|
9
|
+
5. Strict composite identity requirements: same cause != same event instance.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import re
|
|
15
|
+
from dataclasses import dataclass, field, asdict
|
|
16
|
+
from enum import Enum
|
|
17
|
+
from typing import Any, Dict, Optional, Tuple, Set
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class PredicateStatus(str, Enum):
|
|
21
|
+
"""Three-valued epistemic logic status for individual predicates."""
|
|
22
|
+
MATCH = "MATCH" # Evidence confirms equivalence or identity
|
|
23
|
+
CONFLICT = "CONFLICT" # Explicit contradiction between two asserted values
|
|
24
|
+
UNKNOWN = "UNKNOWN" # Insufficient evidence (missing evidence != conflict)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class EventRelation(str, Enum):
|
|
28
|
+
"""Epistemic relationship between query requirements and memory candidate."""
|
|
29
|
+
SAME_EVENT = "SAME_EVENT" # Proven same event instance (Path A or Path B)
|
|
30
|
+
RELATED_EVENT = "RELATED_EVENT" # Related/similar event in same domain/component (DO NOT ASSERT AS TARGET)
|
|
31
|
+
CONFLICTING_EVENT = "CONFLICTING_EVENT" # Contradictory event (explicit mismatch in identity predicate)
|
|
32
|
+
INSUFFICIENT_EVIDENCE = "INSUFFICIENT_EVIDENCE" # Ungrounded query / memory lacks required predicates
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass(frozen=True)
|
|
36
|
+
class EventSignature:
|
|
37
|
+
"""Normalized event signature representing query requirements or stored memory."""
|
|
38
|
+
|
|
39
|
+
# ── Grounding / Boundary Predicates ──────────────────────────────────
|
|
40
|
+
domain_root: str = "" # Project world/domain: microfluidics, fintech, identity...
|
|
41
|
+
component: str = "" # Specific subsystem: gateway-cluster, database-cluster...
|
|
42
|
+
event_kind: str = "general" # Event class: incident, deployment, migration, adr, bugfix...
|
|
43
|
+
|
|
44
|
+
# ── Identity-Bearing Predicates (Determine event individuation) ──────
|
|
45
|
+
trigger: str = "" # Root cause category: compute.cpu_overload, network.link_sever...
|
|
46
|
+
failure_mode: str = "" # Failure symptom: availability.health_check_failed, consistency.split_brain...
|
|
47
|
+
scope_facets: Dict[str, str] = field(default_factory=dict)
|
|
48
|
+
# Dimensioned facets: {"env": "prod", "port": "8700", "shard": "01"}
|
|
49
|
+
|
|
50
|
+
# ── Descriptive & Supplementary Predicates (Supplementary context) ──
|
|
51
|
+
observed_effects: Tuple[str, ...] = () # Multi-valued effects: (latency, traffic_loss)
|
|
52
|
+
operation: str = "" # Remediation / action: restart, rollback, failover...
|
|
53
|
+
|
|
54
|
+
# ── Exact Identity Anchors (Deterministic symbolic verification) ────
|
|
55
|
+
event_id: str = "" # Exact identifier: MICROFLUIDICS-401, ADR-02
|
|
56
|
+
fact_refs: Tuple[str, ...] = () # Symbolic refs: (microfluidics.primary_port, ...)
|
|
57
|
+
temporal_ref: str = "" # Revision or snapshot pin: rev:2, 1704067200.0
|
|
58
|
+
provenance: str = "" # Source record: postmortem, adr, audit_ledger, user_asserted
|
|
59
|
+
|
|
60
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
61
|
+
d = asdict(self)
|
|
62
|
+
d["scope_facets"] = dict(self.scope_facets)
|
|
63
|
+
d["observed_effects"] = list(self.observed_effects)
|
|
64
|
+
d["fact_refs"] = list(self.fact_refs)
|
|
65
|
+
return d
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def from_dict(cls, data: Dict[str, Any]) -> EventSignature:
|
|
69
|
+
return cls(
|
|
70
|
+
domain_root=data.get("domain_root", ""),
|
|
71
|
+
component=data.get("component", ""),
|
|
72
|
+
event_kind=data.get("event_kind", "general"),
|
|
73
|
+
trigger=data.get("trigger", ""),
|
|
74
|
+
failure_mode=data.get("failure_mode", ""),
|
|
75
|
+
scope_facets=dict(data.get("scope_facets", {})),
|
|
76
|
+
observed_effects=tuple(data.get("observed_effects", ())),
|
|
77
|
+
operation=data.get("operation", ""),
|
|
78
|
+
event_id=data.get("event_id", ""),
|
|
79
|
+
fact_refs=tuple(data.get("fact_refs", ())),
|
|
80
|
+
temporal_ref=data.get("temporal_ref", ""),
|
|
81
|
+
provenance=data.get("provenance", ""),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# ── Canonical Predicate Taxonomies & Ontology Facets ───────────────────────
|
|
86
|
+
|
|
87
|
+
TRIGGER_ONTOLOGY: Dict[str, Set[str]] = {
|
|
88
|
+
"compute.cpu_overload": {
|
|
89
|
+
"cpu", "processor", "high cpu", "cpu spike", "cpu load", "cpu overload",
|
|
90
|
+
"load spike", "перегрузка процессора", "перегрузки процессора", "перегрузка цп",
|
|
91
|
+
"перегрузки цп", "нагрузка процессора", "нагрузки процессора", "скачок цп", "скачка цп",
|
|
92
|
+
"перегрузк"
|
|
93
|
+
},
|
|
94
|
+
"compute.oom_kill": {
|
|
95
|
+
"oom", "out of memory", "oom killer", "oom kill", "oomkiller", "memory exhaustion",
|
|
96
|
+
"память переполнена", "утечка памяти", "исчерпание памяти"
|
|
97
|
+
},
|
|
98
|
+
"compute.thread_exhaustion": {
|
|
99
|
+
"thread pool", "thread exhaustion", "thread starvation", "deadlock",
|
|
100
|
+
"зависание потоков", "блокировка"
|
|
101
|
+
},
|
|
102
|
+
"network.link_sever": {
|
|
103
|
+
"fiber cut", "cable cut", "network sever", "optical link", "fiber break",
|
|
104
|
+
"catastrophic fiber cut", "обрыв кабеля", "обрыв оптоволокна", "разрыв линии"
|
|
105
|
+
},
|
|
106
|
+
"network.partition": {
|
|
107
|
+
"network partition", "split brain", "packet loss", "isolated node",
|
|
108
|
+
"сетевое расщепление", "потеря связности"
|
|
109
|
+
},
|
|
110
|
+
"network.dns_timeout": {
|
|
111
|
+
"dns resolution", "dns timeout", "nxdomain", "dns failure",
|
|
112
|
+
"таймаут dns", "сбой dns"
|
|
113
|
+
},
|
|
114
|
+
"storage.disk_full": {
|
|
115
|
+
"disk full", "storage exhausted", "no space left", "enospc",
|
|
116
|
+
"диск переполнен", "нехватка места"
|
|
117
|
+
},
|
|
118
|
+
"storage.corruption": {
|
|
119
|
+
"data corruption", "fs corruption", "checksum mismatch", "corrupt block",
|
|
120
|
+
"повреждение данных", "битые блоки"
|
|
121
|
+
},
|
|
122
|
+
"power.blackout": {
|
|
123
|
+
"blackout", "facility blackout", "power loss", "ups failure", "datacenter power",
|
|
124
|
+
"обесточивание", "отключение питания", "авария питания"
|
|
125
|
+
},
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
STOP_WORDS_SCOPE: Set[str] = {
|
|
129
|
+
"the", "a", "an", "this", "that", "when", "unspecified", "any", "were", "where",
|
|
130
|
+
"there", "regarding", "general", "some", "our", "all", "primary", "secondary"
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
FAILURE_MODE_ONTOLOGY: Dict[str, Set[str]] = {
|
|
135
|
+
"availability.health_check_failed": {
|
|
136
|
+
"failed health check", "health check failure", "readiness probe failure",
|
|
137
|
+
"readiness probe", "liveness probe", "unhealthy", "health check",
|
|
138
|
+
"проверка работоспособности", "отказ проверки", "отказом проверки",
|
|
139
|
+
"проверки работоспособности", "failed health"
|
|
140
|
+
},
|
|
141
|
+
"availability.service_unavailable": {
|
|
142
|
+
"503", "service unavailable", "unreachable", "crash loop", "crashed",
|
|
143
|
+
"недоступен", "падение сервиса", "аварийная остановка"
|
|
144
|
+
},
|
|
145
|
+
"connectivity.partition": {
|
|
146
|
+
"network partition", "total network partition", "unreachable cluster", "node unreachable",
|
|
147
|
+
"расщепление сети", "потеря связи"
|
|
148
|
+
},
|
|
149
|
+
"connectivity.timeout": {
|
|
150
|
+
"timeout", "keepalive", "connection timed out", "таймаут", "тайм аут",
|
|
151
|
+
"время ожидания"
|
|
152
|
+
},
|
|
153
|
+
"consistency.split_brain": {
|
|
154
|
+
"split brain", "divergent state", "inconsistent replica", "state divergence",
|
|
155
|
+
"рассинхронизация", "конфликт реплик", "расхождение состояния"
|
|
156
|
+
},
|
|
157
|
+
"consistency.read_only": {
|
|
158
|
+
"read only fallback", "write rejected", "read only mode",
|
|
159
|
+
"режим только для чтения"
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
EVENT_KIND_ONTOLOGY: Dict[str, Set[str]] = {
|
|
164
|
+
"incident": {
|
|
165
|
+
"incident", "outage", "rca", "post mortem", "postmortem", "failure",
|
|
166
|
+
"problem", "problems", "issue", "issues",
|
|
167
|
+
"авария", "аварии", "сбой", "сбоя", "инцидент", "инцидента", "инцидентом",
|
|
168
|
+
"отказ", "отказа", "падение", "падения", "неполадка", "неполадки", "проблема", "проблемы"
|
|
169
|
+
},
|
|
170
|
+
"deployment": {
|
|
171
|
+
"deployment", "deploy", "release", "rollout", "развёртывание", "релиз"
|
|
172
|
+
},
|
|
173
|
+
"migration": {
|
|
174
|
+
"migration", "migrate", "migrated", "schema migration", "миграция"
|
|
175
|
+
},
|
|
176
|
+
"adr": {
|
|
177
|
+
"adr", "architecture decision", "architectural decision", "decision record",
|
|
178
|
+
"архитектурное решение"
|
|
179
|
+
},
|
|
180
|
+
"bugfix": {
|
|
181
|
+
"bugfix", "fixed", "resolved", "patch", "исправление", "багфикс"
|
|
182
|
+
},
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
EFFECT_ONTOLOGY: Dict[str, Set[str]] = {
|
|
186
|
+
"latency": {"high latency", "latency spike", "slow queries", "p99 spike", "latency", "задержка"},
|
|
187
|
+
"traffic_loss": {"traffic drop", "dropped traffic", "dropped packets", "connection drop", "потеря трафика"},
|
|
188
|
+
"data_loss": {"data loss", "lost records", "unrecoverable loss", "потеря данных"},
|
|
189
|
+
"service_outage": {"total outage", "cluster down", "offline", "полный отказ"},
|
|
190
|
+
"auth_failure": {"auth rejection", "unauthorized", "token invalid", "ошибка авторизации"},
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
# Canonical domain root keyword mappings (sorted by length descending for greedy matching)
|
|
194
|
+
DOMAIN_ROOT_KEYWORDS: list[tuple[str, str]] = sorted([
|
|
195
|
+
("smart grid", "energy"),
|
|
196
|
+
("scada telemetry", "energy"),
|
|
197
|
+
("legal compliance", "legaltech"),
|
|
198
|
+
("regulatory compliance", "legaltech"),
|
|
199
|
+
("cloud infra", "devops"),
|
|
200
|
+
("payments switch", "fintech"),
|
|
201
|
+
("quantum simulator", "quantum"),
|
|
202
|
+
("activity feeds", "social"),
|
|
203
|
+
("threat ops", "secops"),
|
|
204
|
+
("drone autopilot", "avionics"),
|
|
205
|
+
("fleet telematics", "logistics"),
|
|
206
|
+
("video transcoding", "streaming"),
|
|
207
|
+
("webrtc voice", "messaging"),
|
|
208
|
+
("game servers", "gaming"),
|
|
209
|
+
("matchmaking", "gaming"),
|
|
210
|
+
("dedicated servers", "gaming"),
|
|
211
|
+
("lakehouse", "dataeng"),
|
|
212
|
+
("bioinformatics", "genomics"),
|
|
213
|
+
("e discovery", "legaltech"),
|
|
214
|
+
("ediscovery", "legaltech"),
|
|
215
|
+
("opentelemetry", "telemetry"),
|
|
216
|
+
("observability", "telemetry"),
|
|
217
|
+
("e commerce", "ecommerce"),
|
|
218
|
+
("retail", "ecommerce"),
|
|
219
|
+
("ai ml", "mlops"),
|
|
220
|
+
("inference infra", "mlops"),
|
|
221
|
+
("hipaa ehr", "healthcare"),
|
|
222
|
+
("defi protocol", "web3"),
|
|
223
|
+
("embedded firmware", "iot"),
|
|
224
|
+
("ci cd runners", "devtools"),
|
|
225
|
+
("energy", "energy"),
|
|
226
|
+
("legaltech", "legaltech"),
|
|
227
|
+
("devops", "devops"),
|
|
228
|
+
("fintech", "fintech"),
|
|
229
|
+
("ecommerce", "ecommerce"),
|
|
230
|
+
("healthcare", "healthcare"),
|
|
231
|
+
("web3", "web3"),
|
|
232
|
+
("secops", "secops"),
|
|
233
|
+
("mlops", "mlops"),
|
|
234
|
+
("mobile", "mobile"),
|
|
235
|
+
("iot", "iot"),
|
|
236
|
+
("dataeng", "dataeng"),
|
|
237
|
+
("gaming", "gaming"),
|
|
238
|
+
("search", "search"),
|
|
239
|
+
("messaging", "messaging"),
|
|
240
|
+
("identity", "identity"),
|
|
241
|
+
("telemetry", "telemetry"),
|
|
242
|
+
("streaming", "streaming"),
|
|
243
|
+
("crm", "crm"),
|
|
244
|
+
("logistics", "logistics"),
|
|
245
|
+
("devtools", "devtools"),
|
|
246
|
+
("avionics", "avionics"),
|
|
247
|
+
("genomics", "genomics"),
|
|
248
|
+
("social", "social"),
|
|
249
|
+
("quantum", "quantum"),
|
|
250
|
+
], key=lambda x: len(x[0]), reverse=True)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
class PredicateNormalizer:
|
|
255
|
+
"""Canonicalizes raw natural language queries and memory templates into EventSignatures.
|
|
256
|
+
|
|
257
|
+
Zero benchmark-specific logic: maps terms via extensible taxonomies into category.primitive tags.
|
|
258
|
+
If a facet is not recognized with high confidence, it remains empty ("") -> UNKNOWN.
|
|
259
|
+
"""
|
|
260
|
+
|
|
261
|
+
@staticmethod
|
|
262
|
+
def normalize_text(text: str) -> str:
|
|
263
|
+
t = text.lower()
|
|
264
|
+
# Replace dashes, underscores, and punctuation with spaces so compound words match cleanly
|
|
265
|
+
t = re.sub(r"[{}\[\]();:,!?\"'\-_/\\]", " ", t)
|
|
266
|
+
return " ".join(t.split())
|
|
267
|
+
|
|
268
|
+
@classmethod
|
|
269
|
+
def match_facet_from_text(cls, text: str, ontology: Dict[str, Set[str]]) -> str:
|
|
270
|
+
"""Find best matching canonical facet key from text, or return empty string."""
|
|
271
|
+
norm = cls.normalize_text(text)
|
|
272
|
+
best_key = ""
|
|
273
|
+
best_len = 0
|
|
274
|
+
for canonical_key, keywords in ontology.items():
|
|
275
|
+
for kw in keywords:
|
|
276
|
+
# Check normalized keyword presence
|
|
277
|
+
kw_norm = cls.normalize_text(kw)
|
|
278
|
+
if kw_norm in norm:
|
|
279
|
+
if len(kw_norm) > best_len:
|
|
280
|
+
best_len = len(kw_norm)
|
|
281
|
+
best_key = canonical_key
|
|
282
|
+
return best_key
|
|
283
|
+
|
|
284
|
+
@classmethod
|
|
285
|
+
def extract_effects(cls, text: str) -> Tuple[str, ...]:
|
|
286
|
+
"""Extract multi-valued observed effects from text."""
|
|
287
|
+
norm = cls.normalize_text(text)
|
|
288
|
+
effects: list[str] = []
|
|
289
|
+
for canonical_key, keywords in EFFECT_ONTOLOGY.items():
|
|
290
|
+
for kw in keywords:
|
|
291
|
+
kw_norm = cls.normalize_text(kw)
|
|
292
|
+
if kw_norm in norm:
|
|
293
|
+
if canonical_key not in effects:
|
|
294
|
+
effects.append(canonical_key)
|
|
295
|
+
break
|
|
296
|
+
return tuple(effects)
|
|
297
|
+
|
|
298
|
+
@classmethod
|
|
299
|
+
def extract_scope_facets(cls, text: str) -> Dict[str, str]:
|
|
300
|
+
"""Extract dimensioned scope facets (port, env, region, shard, cluster)."""
|
|
301
|
+
facets: Dict[str, str] = {}
|
|
302
|
+
norm = text.lower()
|
|
303
|
+
|
|
304
|
+
# Port dimension: port 8700, port:8700, on port 8000
|
|
305
|
+
port_m = re.search(r"\bport\s*[:=]?\s*(\d{2,5})\b", norm)
|
|
306
|
+
if port_m:
|
|
307
|
+
facets["port"] = port_m.group(1)
|
|
308
|
+
|
|
309
|
+
# Environment dimension: prod, production, staging, dev, stage
|
|
310
|
+
if re.search(r"\b(production|prod)\b", norm):
|
|
311
|
+
facets["env"] = "prod"
|
|
312
|
+
elif re.search(r"\b(staging|stage)\b", norm):
|
|
313
|
+
facets["env"] = "staging"
|
|
314
|
+
elif re.search(r"\b(dev|development)\b", norm):
|
|
315
|
+
facets["env"] = "dev"
|
|
316
|
+
|
|
317
|
+
# Cluster dimension: extract specific cluster name, excluding stop words
|
|
318
|
+
cluster_m = re.search(r"\b([a-zA-Z0-9_-]+)[\s_-]+cluster\b", norm)
|
|
319
|
+
if cluster_m:
|
|
320
|
+
c_name = cluster_m.group(1).lower()
|
|
321
|
+
if c_name not in STOP_WORDS_SCOPE and len(c_name) >= 3:
|
|
322
|
+
facets["cluster"] = c_name
|
|
323
|
+
|
|
324
|
+
return facets
|
|
325
|
+
|
|
326
|
+
@classmethod
|
|
327
|
+
def extract_component(cls, text: str) -> str:
|
|
328
|
+
"""Extract canonical component from text."""
|
|
329
|
+
norm = text.lower()
|
|
330
|
+
if "gateway" in norm or "шлюз" in norm:
|
|
331
|
+
return "gateway-cluster"
|
|
332
|
+
if "database" in norm or "баз" in norm or "postgres" in norm or "mysql" in norm or "db" in norm:
|
|
333
|
+
return "database-cluster"
|
|
334
|
+
if "auth" in norm or "авториз" in norm:
|
|
335
|
+
return "auth-service"
|
|
336
|
+
if "worker" in norm or "воркер" in norm:
|
|
337
|
+
return "worker-pool"
|
|
338
|
+
if "router" in norm or "маршрутиз" in norm:
|
|
339
|
+
return "routing-mesh"
|
|
340
|
+
|
|
341
|
+
comp_m = re.search(r"\b([a-zA-Z0-9_-]+)[\s_-]+(?:cluster|gateway|service|worker|db)\b", norm)
|
|
342
|
+
if comp_m:
|
|
343
|
+
c_name = comp_m.group(1).lower()
|
|
344
|
+
if c_name not in STOP_WORDS_SCOPE and len(c_name) >= 3:
|
|
345
|
+
return f"{c_name}-cluster"
|
|
346
|
+
return ""
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
@classmethod
|
|
350
|
+
def extract_domain_root(cls, text: str) -> str:
|
|
351
|
+
"""Extract canonical domain root from text using keyword ontology."""
|
|
352
|
+
norm = cls.normalize_text(text)
|
|
353
|
+
for kw, dom in DOMAIN_ROOT_KEYWORDS:
|
|
354
|
+
if re.search(r"\b" + re.escape(kw) + r"\b", norm):
|
|
355
|
+
return dom
|
|
356
|
+
return ""
|
|
357
|
+
|
|
358
|
+
@classmethod
|
|
359
|
+
def extract_signature(
|
|
360
|
+
cls,
|
|
361
|
+
text: str,
|
|
362
|
+
domain_root: str = "",
|
|
363
|
+
component: str = "",
|
|
364
|
+
event_id: str = "",
|
|
365
|
+
fact_refs: Tuple[str, ...] = (),
|
|
366
|
+
temporal_ref: str = "",
|
|
367
|
+
provenance: str = "",
|
|
368
|
+
) -> EventSignature:
|
|
369
|
+
"""Parse raw text and parameters into a canonical EventSignature."""
|
|
370
|
+
# Detect event kind
|
|
371
|
+
kind = cls.match_facet_from_text(text, EVENT_KIND_ONTOLOGY)
|
|
372
|
+
if not kind:
|
|
373
|
+
kind = "general"
|
|
374
|
+
|
|
375
|
+
# Detect trigger cause
|
|
376
|
+
trigger = cls.match_facet_from_text(text, TRIGGER_ONTOLOGY)
|
|
377
|
+
|
|
378
|
+
# Detect failure mode
|
|
379
|
+
failure_mode = cls.match_facet_from_text(text, FAILURE_MODE_ONTOLOGY)
|
|
380
|
+
|
|
381
|
+
# Detect multi-valued effects
|
|
382
|
+
effects = cls.extract_effects(text)
|
|
383
|
+
|
|
384
|
+
# Detect dimensioned scope facets
|
|
385
|
+
scope_facets = cls.extract_scope_facets(text)
|
|
386
|
+
|
|
387
|
+
# Extract component
|
|
388
|
+
inferred_comp = component
|
|
389
|
+
if not inferred_comp:
|
|
390
|
+
inferred_comp = cls.extract_component(text)
|
|
391
|
+
|
|
392
|
+
# Infer domain root: explicit text domain takes precedence over partition domain_root
|
|
393
|
+
text_domain = cls.extract_domain_root(text)
|
|
394
|
+
inferred_domain = text_domain if text_domain else (domain_root.lower() if domain_root else "")
|
|
395
|
+
|
|
396
|
+
# Detect exact event ticket IDs: e.g. FINTECH-401, ADR-02, MICROFLUIDICS-882
|
|
397
|
+
inferred_event_id = ""
|
|
398
|
+
id_m = re.search(r"\b([A-Za-z0-9_]{2,}-\d+)\b", text)
|
|
399
|
+
if id_m:
|
|
400
|
+
inferred_event_id = id_m.group(1).upper()
|
|
401
|
+
elif event_id:
|
|
402
|
+
inferred_event_id = event_id
|
|
403
|
+
|
|
404
|
+
if inferred_event_id.startswith("ADR") or text.strip().upper().startswith("ADR"):
|
|
405
|
+
kind = "adr"
|
|
406
|
+
|
|
407
|
+
return EventSignature(
|
|
408
|
+
domain_root=inferred_domain,
|
|
409
|
+
component=inferred_comp.lower(),
|
|
410
|
+
event_kind=kind,
|
|
411
|
+
trigger=trigger,
|
|
412
|
+
failure_mode=failure_mode,
|
|
413
|
+
scope_facets=scope_facets,
|
|
414
|
+
observed_effects=effects,
|
|
415
|
+
event_id=inferred_event_id,
|
|
416
|
+
fact_refs=fact_refs,
|
|
417
|
+
temporal_ref=temporal_ref,
|
|
418
|
+
provenance=provenance,
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
# ── Comparison Functions (Three-Valued Logic) ──────────────────────────────
|
|
423
|
+
|
|
424
|
+
def compare_scalar_predicate(query_val: str, mem_val: str) -> PredicateStatus:
|
|
425
|
+
"""Compare two scalar string predicates under 3-valued epistemic logic.
|
|
426
|
+
|
|
427
|
+
Rules:
|
|
428
|
+
- If either is empty ("") or "general": UNKNOWN (missing evidence is not conflict)
|
|
429
|
+
- If both are non-empty, non-general and equal: MATCH
|
|
430
|
+
- If both are non-empty, non-general and unequal: CONFLICT
|
|
431
|
+
"""
|
|
432
|
+
q = query_val.strip().lower()
|
|
433
|
+
m = mem_val.strip().lower()
|
|
434
|
+
if not q or not m:
|
|
435
|
+
return PredicateStatus.UNKNOWN
|
|
436
|
+
if q == "general" or m == "general":
|
|
437
|
+
return PredicateStatus.UNKNOWN
|
|
438
|
+
if {q, m} <= {"adr", "migration", "deployment"}:
|
|
439
|
+
return PredicateStatus.MATCH
|
|
440
|
+
if q == m:
|
|
441
|
+
return PredicateStatus.MATCH
|
|
442
|
+
return PredicateStatus.CONFLICT
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
def compare_scope_facets(
|
|
446
|
+
query_facets: Dict[str, str],
|
|
447
|
+
mem_facets: Dict[str, str],
|
|
448
|
+
) -> PredicateStatus:
|
|
449
|
+
"""Compare dimensioned scope facets under 3-valued logic.
|
|
450
|
+
|
|
451
|
+
Rules:
|
|
452
|
+
- Conflict occurs STRICTLY within shared dimensions (e.g. env=prod vs env=staging).
|
|
453
|
+
- If no shared dimensions: UNKNOWN (disjoint dimensions are compatible).
|
|
454
|
+
- If all shared dimensions match and at least one matches: MATCH.
|
|
455
|
+
- If any shared dimension conflicts: CONFLICT.
|
|
456
|
+
"""
|
|
457
|
+
shared_keys = set(query_facets.keys()) & set(mem_facets.keys())
|
|
458
|
+
if not shared_keys:
|
|
459
|
+
return PredicateStatus.UNKNOWN
|
|
460
|
+
|
|
461
|
+
has_match = False
|
|
462
|
+
for k in shared_keys:
|
|
463
|
+
if query_facets[k] != mem_facets[k]:
|
|
464
|
+
return PredicateStatus.CONFLICT
|
|
465
|
+
else:
|
|
466
|
+
has_match = True
|
|
467
|
+
|
|
468
|
+
return PredicateStatus.MATCH if has_match else PredicateStatus.UNKNOWN
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def compare_observed_effects(
|
|
472
|
+
query_effects: Tuple[str, ...],
|
|
473
|
+
mem_effects: Tuple[str, ...],
|
|
474
|
+
) -> PredicateStatus:
|
|
475
|
+
"""Compare multi-valued observed effects under 3-valued logic.
|
|
476
|
+
|
|
477
|
+
Effects are supplementary:
|
|
478
|
+
- Intersection non-empty: MATCH
|
|
479
|
+
- Otherwise: UNKNOWN (a single event produces multiple effects; missing effect is never conflict).
|
|
480
|
+
"""
|
|
481
|
+
if not query_effects or not mem_effects:
|
|
482
|
+
return PredicateStatus.UNKNOWN
|
|
483
|
+
if set(query_effects) & set(mem_effects):
|
|
484
|
+
return PredicateStatus.MATCH
|
|
485
|
+
return PredicateStatus.UNKNOWN
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
# ── EventRelation Resolution Engine ────────────────────────────────────────
|
|
489
|
+
|
|
490
|
+
def resolve_event_relation(
|
|
491
|
+
query_sig: EventSignature,
|
|
492
|
+
mem_sig: EventSignature,
|
|
493
|
+
) -> EventRelation:
|
|
494
|
+
"""Evaluate epistemic relation between Query Event Signature and Candidate Memory Signature.
|
|
495
|
+
|
|
496
|
+
Implements the full ARCH-EVENT-01 v0.2 Algebra:
|
|
497
|
+
1. CONFLICTING_EVENT: Any identity predicate or boundary in CONFLICT.
|
|
498
|
+
2. SAME_EVENT:
|
|
499
|
+
- Not conflicting
|
|
500
|
+
- domain_root in {MATCH, UNKNOWN}
|
|
501
|
+
- component in {MATCH, UNKNOWN}
|
|
502
|
+
- AND either:
|
|
503
|
+
* Path A (Exact Identity Anchor): event_id match (or substring ticket match), fact_refs match, or temporal_ref match
|
|
504
|
+
* Path B (Composite Identity): (status_comp == MATCH or status_domain == MATCH) and >= 2 specific identity matches
|
|
505
|
+
3. RELATED_EVENT: Grounded in same domain/component/class, but lacks second identity match.
|
|
506
|
+
4. INSUFFICIENT_EVIDENCE: No identity predicates grounded.
|
|
507
|
+
"""
|
|
508
|
+
# 1. Compute 3-valued status across all predicates
|
|
509
|
+
status_kind = compare_scalar_predicate(query_sig.event_kind, mem_sig.event_kind)
|
|
510
|
+
status_domain = compare_scalar_predicate(query_sig.domain_root, mem_sig.domain_root)
|
|
511
|
+
status_comp = compare_scalar_predicate(query_sig.component, mem_sig.component)
|
|
512
|
+
status_trigger = compare_scalar_predicate(query_sig.trigger, mem_sig.trigger)
|
|
513
|
+
status_mode = compare_scalar_predicate(query_sig.failure_mode, mem_sig.failure_mode)
|
|
514
|
+
status_scope = compare_scope_facets(query_sig.scope_facets, mem_sig.scope_facets)
|
|
515
|
+
status_effects = compare_observed_effects(query_sig.observed_effects, mem_sig.observed_effects)
|
|
516
|
+
|
|
517
|
+
# 2. Check for explicit CONFLICTING_EVENT
|
|
518
|
+
# Any contradiction in identity-bearing or boundary predicates disqualifies the candidate!
|
|
519
|
+
if (
|
|
520
|
+
status_kind == PredicateStatus.CONFLICT
|
|
521
|
+
or status_domain == PredicateStatus.CONFLICT
|
|
522
|
+
or status_comp == PredicateStatus.CONFLICT
|
|
523
|
+
or status_trigger == PredicateStatus.CONFLICT
|
|
524
|
+
or status_mode == PredicateStatus.CONFLICT
|
|
525
|
+
or status_scope == PredicateStatus.CONFLICT
|
|
526
|
+
):
|
|
527
|
+
return EventRelation.CONFLICTING_EVENT
|
|
528
|
+
|
|
529
|
+
# 3. Check for Path A: Exact Identity Anchor
|
|
530
|
+
exact_id_anchor = False
|
|
531
|
+
if query_sig.event_id and mem_sig.event_id:
|
|
532
|
+
q_id = query_sig.event_id.lower()
|
|
533
|
+
m_id = mem_sig.event_id.lower()
|
|
534
|
+
if q_id == m_id or q_id in m_id or m_id in q_id:
|
|
535
|
+
exact_id_anchor = True
|
|
536
|
+
elif query_sig.fact_refs and mem_sig.fact_refs and set(query_sig.fact_refs) & set(mem_sig.fact_refs):
|
|
537
|
+
exact_id_anchor = True
|
|
538
|
+
elif query_sig.temporal_ref and mem_sig.temporal_ref and query_sig.temporal_ref == mem_sig.temporal_ref:
|
|
539
|
+
exact_id_anchor = True
|
|
540
|
+
|
|
541
|
+
if exact_id_anchor:
|
|
542
|
+
if (
|
|
543
|
+
status_domain in (PredicateStatus.MATCH, PredicateStatus.UNKNOWN)
|
|
544
|
+
and status_comp in (PredicateStatus.MATCH, PredicateStatus.UNKNOWN)
|
|
545
|
+
and status_kind in (PredicateStatus.MATCH, PredicateStatus.UNKNOWN)
|
|
546
|
+
):
|
|
547
|
+
return EventRelation.SAME_EVENT
|
|
548
|
+
|
|
549
|
+
# Require at least one event predicate in query to consider a memory related;
|
|
550
|
+
# a bare domain name with zero event predicates is INSUFFICIENT_EVIDENCE
|
|
551
|
+
has_query_event_predicate = bool(
|
|
552
|
+
query_sig.component
|
|
553
|
+
or (query_sig.event_kind and query_sig.event_kind != "general")
|
|
554
|
+
or query_sig.trigger
|
|
555
|
+
or query_sig.failure_mode
|
|
556
|
+
or query_sig.scope_facets
|
|
557
|
+
or query_sig.observed_effects
|
|
558
|
+
or query_sig.event_id
|
|
559
|
+
)
|
|
560
|
+
if not has_query_event_predicate:
|
|
561
|
+
return EventRelation.INSUFFICIENT_EVIDENCE
|
|
562
|
+
|
|
563
|
+
# 4. Check for Path B: Composite Identity (Requires >= 2 specific identity matches beyond component)
|
|
564
|
+
# (Invariant: Same cause on same component != same event instance!)
|
|
565
|
+
specific_matches = 0
|
|
566
|
+
if status_trigger == PredicateStatus.MATCH:
|
|
567
|
+
specific_matches += 1
|
|
568
|
+
if status_mode == PredicateStatus.MATCH:
|
|
569
|
+
specific_matches += 1
|
|
570
|
+
if status_scope == PredicateStatus.MATCH:
|
|
571
|
+
specific_matches += 1
|
|
572
|
+
if (
|
|
573
|
+
status_effects in (PredicateStatus.MATCH, PredicateStatus.UNKNOWN)
|
|
574
|
+
and query_sig.observed_effects
|
|
575
|
+
and (status_scope == PredicateStatus.MATCH or status_trigger == PredicateStatus.MATCH or status_mode == PredicateStatus.MATCH)
|
|
576
|
+
):
|
|
577
|
+
specific_matches += 1
|
|
578
|
+
|
|
579
|
+
# In composite identity, either component or domain must match, no conflicts,
|
|
580
|
+
# and we must observe >= 2 independent specific matches beyond component!
|
|
581
|
+
if (
|
|
582
|
+
(status_comp == PredicateStatus.MATCH or status_domain == PredicateStatus.MATCH)
|
|
583
|
+
and specific_matches >= 2
|
|
584
|
+
and status_domain in (PredicateStatus.MATCH, PredicateStatus.UNKNOWN)
|
|
585
|
+
and status_comp in (PredicateStatus.MATCH, PredicateStatus.UNKNOWN)
|
|
586
|
+
and status_kind in (PredicateStatus.MATCH, PredicateStatus.UNKNOWN)
|
|
587
|
+
):
|
|
588
|
+
return EventRelation.SAME_EVENT
|
|
589
|
+
|
|
590
|
+
# 4b. Check for Path C: Architectural Decision / Migration Grounding
|
|
591
|
+
# For architectural records (ADR, migration, deployment) where failure modes/triggers do not exist,
|
|
592
|
+
# matching canonical domain root and component without conflict establishes same decision/migration.
|
|
593
|
+
if (
|
|
594
|
+
status_domain in (PredicateStatus.MATCH, PredicateStatus.UNKNOWN)
|
|
595
|
+
and status_comp == PredicateStatus.MATCH
|
|
596
|
+
and status_kind in (PredicateStatus.MATCH, PredicateStatus.UNKNOWN)
|
|
597
|
+
and query_sig.event_kind in ("adr", "migration", "deployment")
|
|
598
|
+
and mem_sig.event_kind in ("adr", "migration", "deployment")
|
|
599
|
+
):
|
|
600
|
+
return EventRelation.SAME_EVENT
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
# 5. Check for RELATED_EVENT
|
|
604
|
+
# Grounded in specific component, trigger, failure mode, or scope, but not proven to be SAME_EVENT
|
|
605
|
+
has_specific_grounding = bool(
|
|
606
|
+
(status_comp == PredicateStatus.MATCH and query_sig.component != "")
|
|
607
|
+
or (status_trigger == PredicateStatus.MATCH and query_sig.trigger != "")
|
|
608
|
+
or (status_mode == PredicateStatus.MATCH and query_sig.failure_mode != "")
|
|
609
|
+
or (status_scope == PredicateStatus.MATCH and query_sig.scope_facets)
|
|
610
|
+
)
|
|
611
|
+
if has_specific_grounding:
|
|
612
|
+
return EventRelation.RELATED_EVENT
|
|
613
|
+
|
|
614
|
+
# 6. INSUFFICIENT_EVIDENCE
|
|
615
|
+
return EventRelation.INSUFFICIENT_EVIDENCE
|
|
616
|
+
|