Skip to content

fix(query): drop unused device_id parameter from leak_detection template - #92

Merged
codeasier merged 1 commit into
mainfrom
fix/issue-90-leak-detection-device-id
Aug 8, 2026
Merged

codeasier merged 1 commit into
mainfrom
fix/issue-90-leak-detection-device-id

Conversation

@codeasier

Copy link
Copy Markdown
Owner

Fixes #90

Problem

leak_detection advertised a device_id parameter in its YAML, but the
template SQL only references min_size and the executor-injected
device_block_table. QueryService._resolve_device_id() and
QueryExecutor.render() both resolve the target device from explicit
--device, focus, or the first discovered device before rendering, so
params.device_id was a no-op that the CLI, Python API, and MCP all
leaked through template metadata.

Repro

# 1. Inspect metadata
pt-snap query --template-info leak_detection
# -> output includes a device_id parameter row

# 2. Try to use it
pt-snap query /path/to.db --template-use leak_detection \
    --params '{"device_id": 1}'
# -> query still uses the focused device (or first discovered)

Fix

  • Remove parameters.device_id from
    src/pt_snap_cli/query/templates/business/leak_detection.yaml.
  • Synchronize docs/en/querying.md and docs/zh/querying.md.
  • Add CLI/MCP contract regression in
    tests/test_contract_cli_mcp.py plus a registry regression in
    tests/query/test_registry.py asserting that leak_detection only
    exposes min_size.

Device selection continues to flow through --device,
SnapshotAnalyzer.device_id, and focus precedence (verified by the
existing test_query_execution_contract_matches_cli_and_mcp_semantics).

Verification

  • pytest — 587 passed, 1 xfailed.
  • ruff check . — clean.
  • black --check . — clean.

The leak_detection template advertised a device_id parameter, but the
SQL body only references min_size and the executor-injected
device_block_table. QueryService and QueryExecutor resolve the target
device from explicit --device, focus, or the first discovered device
before rendering, so any params.device_id was a no-op leaked through
CLI, Python API, and MCP template metadata.

- Remove parameters.device_id from leak_detection.yaml.
- Sync the en/zh querying.md parameter lists.
- Add regression assertions that the template exposes only min_size
  and that CLI/MCP template-info agree on that surface.

Fixes #90
@codeasier
codeasier force-pushed the fix/issue-90-leak-detection-device-id branch from d22925e to ba7bad9 Compare August 8, 2026 15:12
@codeasier
codeasier merged commit a3611d1 into main Aug 8, 2026
6 checks passed
@codeasier
codeasier deleted the fix/issue-90-leak-detection-device-id branch August 8, 2026 15:24
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.

[BUG] leak_detection advertises a no-op device_id parameter

1 participant