Add meta field to ModelMeasure and Aggregation#83
Conversation
`Column` and `SlayerModel` already carry `meta: Optional[Dict[str, Any]]` for caller bookkeeping (linking entities back to their source, owner tags, etc). `ModelMeasure` and `Aggregation` did not, which means a downstream caller (e.g. the bird-interact-agents translate-kb skill) that wants to stamp every encoded entity uniformly couldn't. Add the same `meta: Optional[Dict[str, Any]] = None` field to both classes. Default None preserves backward compat — existing YAML loads unchanged. Update `mcp.create_model` and `mcp.edit_model` docstrings to mention the new optional `meta` key on `measures` / `aggregations` dicts. No test changes needed — existing tests construct these classes positionally / by-kwarg and don't pass `meta`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughTwo optional ChangesMeta Field Support for Measures and Aggregations
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@slayer/mcp/server.py`:
- Around line 1562-1567: The create_model parameter annotation restricts
measures to Dict[str, str] but the docstring allows an opaque meta dict with
non-string values; update the annotation on create_model (the measures parameter
and any related local vars/returns) from List[Dict[str, str]] (or Dict[str,
str]) to List[Dict[str, Any]] or List[Mapping[str, Any]] and import Any from
typing so callers can pass arbitrary values in the measure["meta"] dict; ensure
any helper functions or type aliases that reference the old Dict[str, str] are
likewise widened to use Any.
🪄 Autofix (Beta)
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: CHILL
Plan: Pro
Run ID: 9188ac3c-e442-4ae8-b49a-187b5a9e7222
📒 Files selected for processing (2)
slayer/core/models.pyslayer/mcp/server.py
… review) The MCP create_model tool documents `meta` as an opaque dict on each measure, but the parameter annotation restricted measures to Dict[str, str], so FastMCP's generated schema would reject any caller passing a dict-valued `meta`. Match the already-correct edit_model annotation by widening to Dict[str, Any]. Pinned by tests/test_mcp_server.py::TestCreateModel::test_create_with_measure_meta_dict. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|



Summary
ColumnandSlayerModelalready carrymeta: Optional[Dict[str, Any]]for caller bookkeeping (linking entities back to their source, owner tags, etc).ModelMeasureandAggregationdid not, which means a downstream caller (e.g. the bird-interact-agents translate-kb skill) that wants to stamp every encoded entity uniformly with a source identifier couldn't.This PR adds the same field to both classes:
Default
Nonepreserves backward compat — existing YAML loads unchanged. The MCPcreate_model/edit_modeldocstrings are updated to mention the new optionalmetakey onmeasures/aggregationsdicts.Concrete motivation: the BIRD-Interact translation skill (DEV-1318) stamps
meta={"kb_id": <id>}on every entity it creates from a KB entry, so a downstream verifier can confirm every KB id is accounted for and a HARD-8 task-time preprocessor can mask entities bykb_id. Without this field, KB entries that produce a ModelMeasure (R-MEASURE recipe) or a custom Aggregation (R-AGG recipe) have no place to carry the link.Test plan
poetry run pytest— 1696 passed (45 Postgres integration errors are environmental, unrelated)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests
Chores