Commit 5b2d754
docs(overview): enumerate dismissed_repair_count in fields= description + static drift test (#1411)
* docs(overview): enumerate dismissed_repair_count in fields= description
`dismissed_repair_count` is set on `ha_get_overview`'s response when the
caller omits `include_dismissed_repairs` (default) AND there are
dismissed repairs being hidden — it tells the agent how many were
filtered out so they know to flip the flag to see them. The key has
been emitted since #1309, but when #1225 introduced the comma-separated
``Available keys:`` enumeration in the `fields=` parameter description
the key was missed.
Functionally the key already worked via `fields=["dismissed_repair_count"]`
(project_fields passes it through), so this is a docstring/discoverability
fix — an agent reading the `fields=` description didn't know it could
request the key.
Adds a static regression test
(`tests/src/unit/test_fields_projection_docstring_completeness.py`) that
AST-walks the response builders for each tool with a `fields=` parameter
and asserts the `Available keys:` enumeration matches the keys the code
emits, in both directions:
- emitted but not enumerated — what slipped past on this PR's bug
- enumerated but not assigned — sibling drift in PR #1381 a473e16
where `notifications`/`repairs` were documented but only assigned
conditionally. Static AST catches "never assigned anywhere";
"assigned only under `if x:`" needs runtime checking (which PR
#1381's `TestHaGetOverviewAlwaysEmittedKeys` provides).
Covers 6 tools: ha_get_overview, ha_search_entities, ha_get_history,
ha_config_list_areas, ha_list_services (AST harvest), and ha_get_state
(manifest pin, since its keys come from HA's entity-record schema, not
from code we own).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test(fields-projection): harden scanner, add meta-tests, drop PR refs
Review feedback:
- Rewrite module docstring + dual-check comment to lead with the
substantive failure mode rather than citing PR numbers — PR archeology
rots and the convention says don't reference the current task in
comments.
- Strip parenthesised notes BEFORE the `Available keys:` section
regex so a period inside a note (e.g. `(since v1.2)`) doesn't
truncate the enumeration. The old order ran paren-stripping after
the section match, which can't recover from an early truncation.
- Add `test_harvester_finds_dismissed_repair_count_in_ha_get_overview`:
pins the bug-catch guarantee. Without it the parametrize would still
pass if a refactor moved the assignment somewhere the harvester
doesn't scan — both sides of the diff would shrink in lockstep and
the regression would go silent.
- Add `test_tool_specs_covers_every_fields_using_tool`: AST-discovers
every tool function with a `fields` parameter and asserts TOOL_SPECS
enumerates them. Without it, deleting a spec entry shrinks coverage
silently — remaining cases still pass and the dropped tool gets no
drift coverage.
- Add `test_exclude_internal_keys_actually_appear_in_raw_harvest`:
parametrized over specs with `exclude_internal`. If a listed
internal key stops being emitted (e.g. the wrapper rename it
documents was undone, or the helper was deleted), the exclusion is
dead code masking nothing — surface it instead.
All 9 tests pass; ruff lint+format clean; mypy clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: kingpanther13 <kingpanther13@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f7621d4 commit 5b2d754
2 files changed
Lines changed: 506 additions & 5 deletions
File tree
- src/ha_mcp/tools
- tests/src/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1230 | 1230 | | |
1231 | 1231 | | |
1232 | 1232 | | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
1236 | | - | |
1237 | | - | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
1238 | 1239 | | |
1239 | 1240 | | |
1240 | 1241 | | |
| |||
0 commit comments