Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
or `minder-plugin scaffold <name>`.
2. Add it as `<name>/__init__.py`, importing from `minder_plugin_sdk`. Declare a
`register()` returning `PluginMetadata`, and any of `CONFIG_SCHEMA` / `ACTIONS`
/ `AI_TOOLS` / `DISPLAY` / `REQUIRES` you need.
/ `AI_TOOLS` / `DISPLAY` / `REQUIRES` you need. Every `AI_TOOLS` entry
declares its `effect` (`read` / `write` / `send` / `destructive`), and
`idempotent` / `hosts` / argument `sensitivity` where they apply (see the
SDK README, "Tool effects"). `tests/test_tool_effects.py` fails on a tool
with no effect or one its name, method or arguments contradict.
3. Validate locally:
```bash
pip install -e ".[dev]"
Expand Down
4 changes: 4 additions & 0 deletions arxiv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class ArxivPlugin(PluginBase):
"properties": {
"query": {
"type": "string",
"sensitivity": "free_text",
"description": (
"The research topic or keywords, e.g. "
"'retrieval augmented generation'."
Expand All @@ -95,6 +96,9 @@ class ArxivPlugin(PluginBase):
},
"action": "search_papers",
"method": "GET",
"effect": "read",
"idempotent": True,
"hosts": ["export.arxiv.org"],
},
]

Expand Down
3 changes: 3 additions & 0 deletions crypto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ class CryptoPlugin:
},
"action": "get_price",
"method": "GET",
"effect": "read",
"idempotent": True,
"hosts": ["query1.finance.yahoo.com"],
},
]

Expand Down
5 changes: 4 additions & 1 deletion frankfurter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,17 @@ class FrankfurterPlugin(PluginBase):
"parameters": {
"type": "object",
"properties": {
"amount": {"type": "number"},
"amount": {"type": "number", "sensitivity": "amount"},
"from_currency": {"type": "string"},
"to_currency": {"type": "string"},
},
"required": ["amount", "from_currency", "to_currency"],
},
"action": "convert",
"method": "GET",
"effect": "read",
"idempotent": True,
"hosts": ["api.frankfurter.dev"],
},
]

Expand Down
3 changes: 3 additions & 0 deletions github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class GitHubPlugin(PluginBase):
},
"action": "get_repo_stats",
"method": "GET",
"effect": "read",
"idempotent": True,
"hosts": ["api.github.com"],
},
]

Expand Down
3 changes: 3 additions & 0 deletions hackernews/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class HackerNewsPlugin(PluginBase):
},
"action": "top_stories",
"method": "GET",
"effect": "read",
"idempotent": True,
"hosts": ["hacker-news.firebaseio.com"],
},
]

Expand Down
13 changes: 13 additions & 0 deletions network/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ class NetworkPlugin:
),
"parameters": {"type": "object", "properties": {}, "required": []},
"action": "scan",
# Discover-only: probes the operator-configured targets (nmap/SNMP gets)
# and caches the result in memory; it writes to no store. No `hosts`:
# the targets are config (NETWORK_SCAN_TARGETS), not code.
"effect": "read",
"idempotent": True,
},
{
"name": "network_reconcile",
Expand All @@ -178,6 +183,14 @@ class NetworkPlugin:
),
"parameters": {"type": "object", "properties": {}, "required": []},
"action": "reconcile",
# Rewrites + reloads the telegraf managed region, upserts the
# inventory/graph, publishes change events, and DELETEs stale-down
# inventory rows and prunes graph nodes past the retention window --
# the deletions make it destructive. Not idempotent: change events
# and pruning depend on the previous cycle and the clock. No `hosts`:
# the scan targets and backend URLs are config, not code.
"effect": "destructive",
"idempotent": False,
},
]

Expand Down
4 changes: 4 additions & 0 deletions news/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ class NewsPlugin:
},
"action": "get_news",
"method": "GET",
# No `hosts`: it reads the operator-configured NEWS_FEEDS URLs, so the
# reachable hosts are config, not code (covered by EGRESS = "public").
"effect": "read",
"idempotent": True,
},
]

Expand Down
4 changes: 4 additions & 0 deletions openlibrary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class OpenLibraryPlugin(PluginBase):
"properties": {
"query": {
"type": "string",
"sensitivity": "free_text",
"description": (
"Title, topic, or author, e.g. "
"'distributed systems' or 'Ursula K. Le Guin'."
Expand All @@ -94,6 +95,9 @@ class OpenLibraryPlugin(PluginBase):
},
"action": "search_books",
"method": "GET",
"effect": "read",
"idempotent": True,
"hosts": ["openlibrary.org"],
},
]

Expand Down
5 changes: 5 additions & 0 deletions portfolio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ class PortfolioPlugin:
# from the JWT, never supplied by the model/caller.
"parameters": {"type": "object", "properties": {}, "required": []},
"action": "get_value",
# Reads the caller's own series back from the platform time-series
# store; it makes no outbound connection, hence `hosts: []`.
"effect": "read",
"idempotent": True,
"hosts": [],
},
]

Expand Down
15 changes: 9 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ py-modules = []
[project.optional-dependencies]
dev = [
# Pinned past v0.1.0 to a specific commit (not a new tag -- this repo's
# own CHANGELOG: no routine version bumps pre-1.0). 0861d974 is plugin-sdk
# #43 (platform context, contract v2): self.ctx / bind_context, the
# CONTRACT_VERSION / MANAGES / EGRESS / TIMESERIES declarations and their
# validator rules, FakePlatformContext. It still carries the package-style
# plugin validate/inspect fix `network` needs (plugin-sdk#26).
"minder-plugin-sdk @ git+https://github.com/minderhq/plugin-sdk@0861d974ed16d5ae6f60c5c4a6f5cb875dded374",
# own CHANGELOG: no routine version bumps pre-1.0). f44873fc is plugin-sdk
# #50 (tool effect classes): the AI_TOOLS `effect`, `idempotent`,
# per-argument `sensitivity` and `hosts` fields, which `minder-plugin
# validate` checks (errors on invalid values, warnings on a missing or
# contradicted effect). It builds on plugin-sdk #43 (platform context,
# contract v2: self.ctx / bind_context, the CONTRACT_VERSION / MANAGES /
# EGRESS / TIMESERIES declarations, FakePlatformContext) and still carries
# the package-style plugin validate/inspect fix `network` needs (#26).
"minder-plugin-sdk @ git+https://github.com/minderhq/plugin-sdk@f44873fcada50f17cc38d26089837d4d1a6227ec",
"httpx>=0.27",
"defusedxml>=0.7",
"pytest>=8",
Expand Down
3 changes: 3 additions & 0 deletions tefas_funds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ class TefasPlugin:
},
"action": "get_fund_price",
"method": "GET",
"effect": "read",
"idempotent": True,
"hosts": ["www.tefas.gov.tr"],
},
]

Expand Down
34 changes: 34 additions & 0 deletions tests/test_tool_effects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Every AI tool in the catalog declares its effect class (plugin-sdk#50).

``minder-plugin validate`` only *warns* about a tool with no ``effect`` or a
declaration that the tool's name, method or arguments contradict, so CI would
pass with either. This makes both a failure, and pins the tools that are not
plain reads so a change to them is a deliberate one.
"""

import importlib

import pytest

from minder_plugin_sdk.tool_effects import tool_effect_warnings

from test_catalog import _plugin_class, _plugin_packages

# Every tool not listed here is a pure read.
_NOT_READ = {("network", "network_reconcile"): "destructive"}


@pytest.mark.parametrize("pkg", _plugin_packages())
def test_tools_declare_an_uncontradicted_effect(pkg):
plugin = _plugin_class(importlib.import_module(pkg))()
assert tool_effect_warnings(plugin) == []


@pytest.mark.parametrize("pkg", _plugin_packages())
def test_reads_are_idempotent_and_the_rest_are_pinned(pkg):
cls = _plugin_class(importlib.import_module(pkg))
for tool in getattr(cls, "AI_TOOLS", []) or []:
expected = _NOT_READ.get((pkg, tool["name"]), "read")
assert tool["effect"] == expected, (pkg, tool["name"])
if expected == "read":
assert tool.get("idempotent") is True, (pkg, tool["name"])
6 changes: 6 additions & 0 deletions weather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,19 @@ class WeatherPlugin:
"properties": {
"location": {
"type": "string",
"sensitivity": "free_text",
"description": "City name, e.g. 'Istanbul', 'Tokyo', 'Berlin'.",
},
},
"required": ["location"],
},
"action": "get_weather",
"method": "GET",
# The default hosts; an operator can repoint them with WEATHER_API_BASE /
# WEATHER_GEOCODE_BASE (env only, not a tool argument).
"effect": "read",
"idempotent": True,
"hosts": ["geocoding-api.open-meteo.com", "api.open-meteo.com"],
},
]

Expand Down
4 changes: 4 additions & 0 deletions wikipedia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,17 @@ class WikipediaPlugin(PluginBase):
"properties": {
"topic": {
"type": "string",
"sensitivity": "free_text",
"description": "What to look up, e.g. 'Alan Turing', 'RAG'.",
},
},
"required": ["topic"],
},
"action": "wiki_summary",
"method": "GET",
"effect": "read",
"idempotent": True,
"hosts": ["*.wikipedia.org"],
},
]

Expand Down
Loading