Repository navigation
fix(v7): repair end-to-end runtime and dashboard failures #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f98aa79
3fc2618
3771ad5
4a88b2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| from pathlib import Path | ||
|
|
||
| from ..similarity import TFIDFIndex | ||
| from ..storage_activation import PointerValidationError, resolve_active_database | ||
| from ._client import ( | ||
| block, | ||
| find_project_root, | ||
|
|
@@ -63,26 +64,10 @@ def _resolve_db_file(project_path: str) -> Path | None: | |
| storage_dir = Path(project_path) / ".daem0nmcp" / "storage" | ||
| if not storage_dir.is_dir(): | ||
| return None | ||
| pointer_path = storage_dir / "active.json" | ||
| if pointer_path.is_file(): | ||
| try: | ||
| pointer = json.loads(pointer_path.read_text(encoding="utf-8")) | ||
| candidate = ( | ||
| pointer.get("active_generation") if isinstance(pointer, dict) else None | ||
| ) | ||
| if ( | ||
| isinstance(candidate, str) | ||
| and candidate | ||
| and "/" not in candidate | ||
| and "\\" not in candidate | ||
| ): | ||
| candidate_path = storage_dir / candidate | ||
| if candidate_path.is_file(): | ||
| return candidate_path | ||
| except (OSError, ValueError): | ||
| pass | ||
| default_db = storage_dir / "daem0nmcp.db" | ||
| return default_db if default_db.is_file() else None | ||
| try: | ||
| return resolve_active_database(storage_dir).path | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: The resolved v7 database is WAL-mode, and the connect below opens it with a bare
The repo already has the correct helper in the module this file imports: use |
||
| except (OSError, PointerValidationError): | ||
| return None | ||
|
|
||
|
|
||
| def _load_active_rules(project_path: str) -> list[_RuleCandidate]: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,36 +4,143 @@ | |
| FastMCP 3.0 has native OpenTelemetry support. This module provides | ||
| configuration and helper utilities for Daem0n-specific tracing. | ||
|
|
||
| Enable by setting: | ||
| Install the observability extra and enable by setting: | ||
| OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 | ||
| OTEL_SERVICE_NAME=daem0nmcp | ||
|
|
||
| The default OTLP protocol is grpc; set OTEL_EXPORTER_OTLP_PROTOCOL to | ||
| http/protobuf for an HTTP collector. Configuration failures warn on stderr | ||
| and leave the core server available. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| import os | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| if TYPE_CHECKING: | ||
| from opentelemetry.sdk.trace import TracerProvider | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| _TRACING_ENABLED: bool | None = None | ||
|
|
||
|
|
||
| def is_tracing_enabled() -> bool: | ||
| """Check if tracing is configured.""" | ||
| """Return whether startup installed or found an active tracing provider.""" | ||
| return _TRACING_ENABLED is True | ||
|
|
||
|
|
||
| def get_service_name() -> str: | ||
| """Get the service name for tracing.""" | ||
| return os.environ.get("OTEL_SERVICE_NAME", "daem0nmcp") | ||
|
|
||
|
|
||
| def configure_tracing() -> TracerProvider | None: | ||
| """Configure requested OTLP export and return only a provider we own.""" | ||
| global _TRACING_ENABLED | ||
| _TRACING_ENABLED = False | ||
| endpoint = os.environ.get("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") or os.environ.get( | ||
| "OTEL_EXPORTER_OTLP_ENDPOINT" | ||
| ) | ||
| if not endpoint or os.environ.get("OTEL_SDK_DISABLED", "").lower() == "true": | ||
| return None | ||
|
|
||
| if _TRACING_ENABLED is not None: | ||
| return _TRACING_ENABLED | ||
| from .capabilities import CapabilityRegistry | ||
|
|
||
| # Check for OTLP endpoint configuration | ||
| endpoint = os.environ.get("OTEL_EXPORTER_OTLP_ENDPOINT") | ||
| _TRACING_ENABLED = endpoint is not None and len(endpoint) > 0 | ||
| capability = CapabilityRegistry().get("observability") | ||
| if ( | ||
| capability["status"] == "disabled" | ||
| and capability["remediation"]["action"] == "enable_configuration" | ||
| ): | ||
| return None | ||
| try: | ||
| from opentelemetry import trace | ||
| except ImportError: | ||
| logger.warning( | ||
| 'OpenTelemetry tracing unavailable; install "daem0nmcp[observability]".' | ||
| ) | ||
| return None | ||
| try: | ||
| existing_provider = trace.get_tracer_provider() | ||
| except Exception: | ||
| logger.warning( | ||
| "OpenTelemetry tracing unavailable; check the configured tracing provider." | ||
| ) | ||
| return None | ||
| if not isinstance(existing_provider, trace.ProxyTracerProvider): | ||
| _TRACING_ENABLED = True | ||
| return None | ||
| protocol = ( | ||
| ( | ||
| os.environ.get("OTEL_EXPORTER_OTLP_TRACES_PROTOCOL") | ||
| or os.environ.get("OTEL_EXPORTER_OTLP_PROTOCOL") | ||
| or "grpc" | ||
| ) | ||
| .strip() | ||
| .lower() | ||
| ) | ||
| if protocol not in {"grpc", "http/protobuf"}: | ||
| logger.warning( | ||
| "OpenTelemetry tracing unavailable; set OTEL_EXPORTER_OTLP_PROTOCOL " | ||
| "or OTEL_EXPORTER_OTLP_TRACES_PROTOCOL to grpc or http/protobuf." | ||
| ) | ||
| return None | ||
| if capability["status"] != "ready": | ||
| logger.warning( | ||
| "OpenTelemetry tracing unavailable; enable the observability profile " | ||
| 'and install "daem0nmcp[observability]".' | ||
| ) | ||
| return None | ||
|
|
||
| if _TRACING_ENABLED: | ||
| logger.info(f"OpenTelemetry tracing enabled: {endpoint}") | ||
| provider = None | ||
| try: | ||
| from opentelemetry.sdk.resources import OTELResourceDetector, Resource | ||
| from opentelemetry.sdk.trace import TracerProvider | ||
| from opentelemetry.sdk.trace.export import BatchSpanProcessor | ||
|
|
||
| return _TRACING_ENABLED | ||
| if protocol == "http/protobuf": | ||
| from opentelemetry.exporter.otlp.proto.http.trace_exporter import ( | ||
| OTLPSpanExporter, | ||
| ) | ||
| else: | ||
| from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import ( | ||
| OTLPSpanExporter, | ||
| ) | ||
| resource = Resource.create({"service.name": "daem0nmcp"}).merge( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: Reuse This module already resolves the service name in one place ( |
||
| OTELResourceDetector().detect() | ||
| ) | ||
| provider = TracerProvider(resource=resource, shutdown_on_exit=False) | ||
| provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter())) | ||
| trace.set_tracer_provider(provider) | ||
| if trace.get_tracer_provider() is not provider: | ||
| shutdown_tracing(provider) | ||
| return None | ||
| except Exception: | ||
| shutdown_tracing(provider) | ||
| logger.warning( | ||
| "OpenTelemetry tracing unavailable; check the observability " | ||
| "installation and OTLP exporter configuration." | ||
| ) | ||
| return None | ||
| _TRACING_ENABLED = True | ||
| logger.info("OpenTelemetry tracing enabled.") | ||
| return provider | ||
|
|
||
|
|
||
| def get_service_name() -> str: | ||
| """Get the service name for tracing.""" | ||
| return os.environ.get("OTEL_SERVICE_NAME", "daem0nmcp") | ||
| def shutdown_tracing(provider: TracerProvider | None) -> None: | ||
| """Flush owned spans without allowing telemetry errors to mask shutdown.""" | ||
| global _TRACING_ENABLED | ||
| if provider is None: | ||
| return | ||
| _TRACING_ENABLED = False | ||
| try: | ||
| if not provider.force_flush(timeout_millis=5000): | ||
| logger.warning("OpenTelemetry trace flush timed out.") | ||
| except Exception: | ||
| logger.warning("OpenTelemetry trace flush failed.") | ||
| try: | ||
| provider.shutdown() | ||
| except Exception: | ||
| logger.warning("OpenTelemetry tracing shutdown failed.") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,9 +85,9 @@ | |
| svg.setAttribute("aria-label", "Memory communities"); | ||
| const details = ui.element("aside", "community-details", "Select a community for details."); | ||
| details.hidden = true; | ||
| if (data.communities.length && globalThis.D3) { | ||
| const root = globalThis.D3.hierarchy(hierarchy(data)).sum(value => value.value || 0); | ||
| globalThis.D3.treemap().size([960, 540]).padding(3)(root); | ||
| if (data.communities.length && globalThis.d3) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: A missing D3 bundle now renders "No communities found." After this fix the |
||
| const root = globalThis.d3.hierarchy(hierarchy(data)).sum(value => value.value || 0); | ||
| globalThis.d3.treemap().size([960, 540]).padding(3)(root); | ||
| for (const leaf of root.leaves()) { | ||
| const item = leaf.data.item; | ||
| if (!item) continue; | ||
|
|
@@ -121,7 +121,9 @@ | |
| message.setAttribute("x", "480"); | ||
| message.setAttribute("y", "270"); | ||
| message.setAttribute("text-anchor", "middle"); | ||
| message.textContent = "No communities found."; | ||
| message.textContent = data.communities.length | ||
| ? "Community map is unavailable." | ||
| : "No communities found."; | ||
| svg.append(message); | ||
| } | ||
| frame.append(svg, details); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUGGESTION:
numpyis not declared by thelocalextra or byPROFILES["local"], so readiness and the preload now disagreePROFILES["local"].distributionsis("qdrant-client",)(daem0nmcp/capabilities.py:36) and thelocalextra installs onlyqdrant-client, yet this tuple now requiresnumpyto import. The capability registry therefore reportslocal: readywhile the Windows preload additionally demands a working numpy, so the same install reports two different capability states depending on the platform.Either declare numpy in the
localextra and inPROFILES["local"].distributionsso both sources agree, or dropnumpyfrom thelocaltuple and rely onmodels-local/late-interaction, whose extras do declare it.