Skip to content

[DAS-Dashboard#1193] Error in metrics overview - #306

Open
levisingularity wants to merge 3 commits into
masterfrom
1093-fix-metrics-overview
Open

[DAS-Dashboard#1193] Error in metrics overview#306
levisingularity wants to merge 3 commits into
masterfrom
1093-fix-metrics-overview

Conversation

@levisingularity

@levisingularity levisingularity commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Fixed an issue where containers not started by DAS-CLI could still appear in the UI:

  • Added container labels to improve filtering and attach useful metadata.
  • Updated the filtering logic to ensure that only containers containing the label "das-cli.managed=true" are displayed, preventing third-party or externally created containers from appearing in the UI.

Quick showcase:
(The service running outside of das-cli's environment was the command-router, as you can see it doesn't show up anymore on the UI)

Screencast.from.2026-08-04.13-47-07.webm

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

  • Filters system status and metrics containers by das-cli.managed=true, which prevents unrelated Docker containers from appearing in the UI.
  • Adds agent.name and command.label metadata to managed containers and reports them as service_name and service_command_label.
  • Updates container factories with service metadata and adds query-engine and qe aliases for the query-agent CLI.
  • Correctness risk: Existing containers without the managed label no longer appear in status or metrics results. Container lifecycle behavior depends on correct label propagation and required metadata. Missing metadata raises KeyError.
  • No Debian, Docker image, or self-hosted runner changes are reported. Matching tests for label filtering, metadata output, and CLI aliases are not reported under das-cli/tests/ or component-specific suites.

Walkthrough

Container manager factories now provide service metadata. Docker containers receive managed and service labels. System container discovery filters by the managed label and returns service names and command labels. The query-agent command adds two aliases.

Changes

Service metadata discovery

Layer / File(s) Summary
Factory service metadata
das-cli/src/common/factory/..., das-cli/src/common/container_manager/metta/...
Factories and the Metta Syntax manager now provide display names and command labels for supported containers. BusNode formats display names while preserving the original command label.
Docker label wiring
das-cli/src/common/docker/container_manager.py
ContainerManager initializes options, validates configured service metadata, and applies it with das-cli.managed=true when containers start.
Managed container status discovery
das-cli/src/common/container_manager/system_containers_manager.py
System container discovery filters by das-cli.managed=true and maps container labels to service_name and service_command_label. Missing labels map to None.

Query-agent aliases

Layer / File(s) Summary
Query-agent command aliases
das-cli/src/commands/query_agent/query_agent_cli.py
QueryAgentCli adds query-engine and qe to the existing qa and query aliases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: andre-senna

Sequence Diagram(s)

sequenceDiagram
  participant Factory as ContainerManagerFactory
  participant Manager as ContainerManager
  participant Docker
  participant Status as SystemContainersManager
  Factory->>Manager: provide service metadata options
  Manager->>Docker: start container with managed and service labels
  Status->>Docker: list containers with das-cli.managed=true
  Docker-->>Status: return labels and container stats
  Status->>Status: map labels to service status fields
Loading

Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Tests For Behavior Changes ❌ Error The PR changes production container filtering, labels, metadata, and CLI aliases, but the base-to-HEAD diff adds no tests and the description gives no test-omission justification. Add or update focused Bats or pytest tests for managed-container filtering, label metadata, and any changed CLI alias behavior.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title identifies the metrics overview issue addressed by the container filtering and labeling changes.
Description check ✅ Passed The description clearly explains the container labeling and filtering changes that prevent unmanaged containers from appearing in the UI.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 1093-fix-metrics-overview

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@das-cli/src/common/container_manager/system_containers_manager.py`:
- Line 23: Add pytest coverage for the managed-container label flow around the
container listing and startup factories: verify name-only “das” containers are
excluded while containers labeled das-cli.managed=true are included, map
agent.name and command.label to service_name and service_command_label, return
None for missing metadata, assert each factory’s display and command labels, and
confirm startup passes all three labels to Docker. Place the tests under
das-cli/tests/agents_integration/ (or use bats under das-cli/tests/integration/)
with concrete cases for each behavior.
- Line 23: Update the container listing logic around the system container
manager’s containers.list call so containers created by earlier CLI versions
remain visible instead of relying exclusively on the das-cli.managed=true label.
Prefer compatibility handling that includes existing containers, or document the
required restart and add an upgrade integration test covering previously started
services.

In `@das-cli/src/common/docker/container_manager.py`:
- Around line 96-101: Ensure every managed container receives service_name and
service_command_label metadata before ContainerManager startup, including
containers created through ContainerManagerFactory and existing ContainerTypes
stubs. Update the relevant constructor/factory initialization so
ContainerManager.labels never raises KeyError, and align
SystemContainersManager’s status filter with the added label metadata.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 26f6b2a7-f8ab-40d9-a775-50caa6ef62a2

📥 Commits

Reviewing files that changed from the base of the PR and between c4429d1 and f6cfcec.

📒 Files selected for processing (9)
  • das-cli/src/common/container_manager/system_containers_manager.py
  • das-cli/src/common/docker/container_manager.py
  • das-cli/src/common/factory/atomdb/mongodb_manager_factory.py
  • das-cli/src/common/factory/atomdb/morkdb_manager_factory.py
  • das-cli/src/common/factory/atomdb/redis_manager_factory.py
  • das-cli/src/common/factory/attention_broker_manager_factory.py
  • das-cli/src/common/factory/busnode_manager_factory.py
  • das-cli/src/common/factory/jupyter_notebook_manager_factory.py
  • das-cli/src/common/factory/metta/database_loader_manager_factory.py

Comment thread das-cli/src/common/container_manager/system_containers_manager.py
Comment thread das-cli/src/common/docker/container_manager.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@das-cli/src/commands/query_agent/query_agent_cli.py`:
- Line 232: Add integration coverage for the aliases defined in
query_agent_cli.py, invoking both query-engine and qe. Extend existing CLI tests
if available, otherwise add bats tests under das-cli/tests/integration/ or
pytest tests under das-cli/tests/agents_integration/ covering at least one valid
subcommand and one error path, with behavior matching qa and query.

In `@das-cli/src/common/docker/container_manager.py`:
- Line 75: Update ContainerManager.__init__ to initialize self._options to an
empty dictionary only when the instance does not already have _options,
preserving subclass assignments made before super().__init__(). Keep the
existing dict[str, Any] annotation and ensure base methods such as labels can
access the attribute.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a435d50c-9217-415c-bab6-6fafc095aedb

📥 Commits

Reviewing files that changed from the base of the PR and between f6cfcec and 4fd6890.

📒 Files selected for processing (7)
  • das-cli/src/commands/query_agent/query_agent_cli.py
  • das-cli/src/common/container_manager/metta/metta_syntax_container_manager.py
  • das-cli/src/common/container_manager/system_containers_manager.py
  • das-cli/src/common/docker/container_manager.py
  • das-cli/src/common/factory/atomdb/morkdb_manager_factory.py
  • das-cli/src/common/factory/busnode_manager_factory.py
  • das-cli/src/common/factory/database_adapter/database_adapter_factory.py
💤 Files with no reviewable changes (1)
  • das-cli/src/common/factory/busnode_manager_factory.py

Comment thread das-cli/src/commands/query_agent/query_agent_cli.py
Comment thread das-cli/src/common/docker/container_manager.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants