[BUG] aimdb-mcp: get_buffer_metrics cannot find a record by its key

Open Beginner friendly
#453 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
api, backend

Research direction

Start with tools/aimdb-mcp/src/tools/buffer_metrics.rs at the filter around line 41, then compare it with the matching logic in tools/aimdb-mcp/src/tools/profiling.rs around line 45. Add or locate a test for a record whose key differs from its Rust type name. Done means get_buffer_metrics finds that record when queried by its key, with the test passing.

Written by the indexing model from the issue text.

Description

bug

Describe the bug
get_buffer_metrics takes a record_key, but it only matches that value against the record's Rust type name. When a record's key differs from its type name, querying by the real key returns found: false, even though the record exists.

The filter is in buffer_metrics.rs:41:

.filter(|r| r.name.contains(&params.record_key))

get_stage_profiling takes the same parameter and already matches both fields (profiling.rs:45).

To Reproduce

  1. Run an instance with a record whose key differs from its type name, for example key motion.policy with type contracts::Policy.
  2. Call the MCP tool get_buffer_metrics with {"record_key": "motion.policy"}.
  3. The tool replies:
{
  "found": false,
  "message": "No records matching this key were found in the running instance.",
  "record_key": "motion.policy"
}

Expected behavior
The tool finds the record by its key, as get_stage_profiling does. The fix is to match r.record_key as well as r.name, with a test where the two differ.

Environment

  • OS: macOS 13 (Darwin 22.6)
  • Rust Version: rustc 1.98.0
  • AimDB Version: main at d9c7be0

Additional context
Seen against a host gateway over a Unix socket. The target instance may also be built without the metrics feature, but the lookup fails before that matters.

Dominant language
Rust
Stars
101
Forks
20
Avg merge
2h 33m
Merged PRs (30d)
90

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aimdb-dev/aimdb

All issues in aimdb-dev/aimdb

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.