nutria-plugin 0.6.0__tar.gz → 0.6.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/CHANGELOG.md +18 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/PKG-INFO +3 -3
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/README.md +2 -2
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/capability-authoring.md +20 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/index.md +1 -1
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/manifest.md +2 -2
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/python-api.md +1 -1
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/quickstart.md +1 -1
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/pyproject.toml +1 -1
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/__init__.py +8 -1
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/capabilities.py +19 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/domains.py +2 -0
- nutria_plugin-0.6.2/src/nutria_plugin/prepared_preview.py +163 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/test_capability_contracts.py +10 -0
- nutria_plugin-0.6.2/tests/test_prepared_preview.py +86 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/.github/workflows/publish.yml +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/.gitignore +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/admin-extensions.md +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/admin-flows.md +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/cli.md +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/connection-types.md +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/migration-6.0.md +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/reviewable-actions.md +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/security.md +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/docs/skill-format.md +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/examples/my-first-plugin/README.md +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/examples/my-first-plugin/hooks/hooks.json +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/examples/my-first-plugin/plugin.json +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/examples/my-first-plugin/settings.schema.json +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/bundle.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/cli.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/hierarchy.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/manifest.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/mcp_results.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/migrate.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/operation_facts.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/packaging.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/signing.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/src/nutria_plugin/skills.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/__init__.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/test_bundle.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/test_cli.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/test_contract_vnext.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/test_hierarchy.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/test_manifest.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/test_mcp_results.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/test_packaging.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/test_reviewable_actions.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/test_signing.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/tests/test_skill_format_docs.py +0 -0
- {nutria_plugin-0.6.0 → nutria_plugin-0.6.2}/uv.lock +0 -0
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
Additive.
|
|
6
|
+
|
|
7
|
+
- Add the `external` capability domain (label "Servicios externos") for capabilities generated from client-connected
|
|
8
|
+
MCP servers that no plugin describes.
|
|
9
|
+
|
|
10
|
+
## 0.6.1
|
|
11
|
+
|
|
12
|
+
Additive; manifests that do not use the new field are unchanged.
|
|
13
|
+
|
|
14
|
+
- Add optional `provider_default_arguments` on capabilities with a `prepared_action`: optional declared
|
|
15
|
+
inputs that the provider fills with its own default. Validated by `nutria-plugin validate`.
|
|
16
|
+
- Add `check_prepared_preview` and `PREVIEW_CONFORMANCE_VECTORS`: one definition of the exact-preview
|
|
17
|
+
rule (snapshot arguments are declared tool arguments, required ones present, supplied ones echoed)
|
|
18
|
+
for plugin tests and hosts.
|
|
19
|
+
- Document the preview rule and the `x-nutria-host-control` schema key.
|
|
20
|
+
|
|
3
21
|
## 0.6.0
|
|
4
22
|
|
|
5
23
|
Breaking: manifest schema 6.0 (5.0 is rejected). See `docs/migration-6.0.md`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: nutria-plugin
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
4
4
|
Summary: SDK for building, validating, signing, and packaging Nutria plugins
|
|
5
5
|
Project-URL: Homepage, https://github.com/AlRos14/nutria-plugin-sdk
|
|
6
6
|
Project-URL: Repository, https://github.com/AlRos14/nutria-plugin-sdk
|
|
@@ -22,7 +22,7 @@ Description-Content-Type: text/markdown
|
|
|
22
22
|
|
|
23
23
|
SDK for building, validating, signing, and packaging Nutria plugins.
|
|
24
24
|
|
|
25
|
-
Release `0.6.
|
|
25
|
+
Release `0.6.2` accepts only manifest schema `6.0`. Capabilities use their real
|
|
26
26
|
business effect (`read`, `write`, or `external_write`); preparation is expressed
|
|
27
27
|
by producing `prepared_action`, not by a workflow-phase effect. Every parsed
|
|
28
28
|
requirement resolves `task_context` to `required`, `optional`, or `forbidden`,
|
|
@@ -35,7 +35,7 @@ and exact delivery of an approved snapshot.
|
|
|
35
35
|
## Install
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
uv add nutria-plugin==0.6.
|
|
38
|
+
uv add nutria-plugin==0.6.2
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
## Scaffold and validate
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
SDK for building, validating, signing, and packaging Nutria plugins.
|
|
4
4
|
|
|
5
|
-
Release `0.6.
|
|
5
|
+
Release `0.6.2` accepts only manifest schema `6.0`. Capabilities use their real
|
|
6
6
|
business effect (`read`, `write`, or `external_write`); preparation is expressed
|
|
7
7
|
by producing `prepared_action`, not by a workflow-phase effect. Every parsed
|
|
8
8
|
requirement resolves `task_context` to `required`, `optional`, or `forbidden`,
|
|
@@ -15,7 +15,7 @@ and exact delivery of an approved snapshot.
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
uv add nutria-plugin==0.6.
|
|
18
|
+
uv add nutria-plugin==0.6.2
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Scaffold and validate
|
|
@@ -84,6 +84,26 @@ capability, which must be pure and read-only and returns an exact preview. The H
|
|
|
84
84
|
the host-only execution capability only after authorization, with idempotency and the declared receipt.
|
|
85
85
|
Never re-resolve targets at execution time; execute exactly what the preview froze.
|
|
86
86
|
|
|
87
|
+
The preview `arguments` are the re-executable call of the tool, not the provider's wire parameters:
|
|
88
|
+
|
|
89
|
+
* every key is a declared argument of the tool (a Trello `list_id`, never the API's `idList`);
|
|
90
|
+
* every required argument is present;
|
|
91
|
+
* every argument the caller supplied is echoed with the same value, an empty string included. Provider
|
|
92
|
+
normalization may add subfields but never changes what was supplied.
|
|
93
|
+
|
|
94
|
+
A provider may fill an optional argument with its own default (for example today's date). Declare it in
|
|
95
|
+
`provider_default_arguments`: the host then accepts an unset or empty supplied value there and the filled
|
|
96
|
+
value in the preview. A non-empty supplied value stays strict, and the declaration must name an optional
|
|
97
|
+
declared input. Declare it in the manifest, which is signed, not in tool code.
|
|
98
|
+
|
|
99
|
+
`nutria_plugin.check_prepared_preview(capability, input_schema, requested, snapshot)` is the single
|
|
100
|
+
definition of this rule; call it in plugin tests with the schema your server exposes.
|
|
101
|
+
`PREVIEW_CONFORMANCE_VECTORS` are shared cases that plugin tests and hosts both run against their own
|
|
102
|
+
implementation.
|
|
103
|
+
|
|
104
|
+
Schema extension keys the host understands on a tool argument: `x-nutria-host-control` (the host
|
|
105
|
+
supplies the value, for example a state fingerprint). Anything else under `x-nutria-` is host-private.
|
|
106
|
+
|
|
87
107
|
## 6. Hierarchical attribute operations
|
|
88
108
|
|
|
89
109
|
An entity can own child entities (variants of an item, ads of a campaign, establishments of an
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# plugin.json manifest reference
|
|
2
2
|
|
|
3
3
|
`plugin.json` is the single source of truth for plugin identity, runtime,
|
|
4
|
-
capability authority, and provider topology. SDK 0.6.
|
|
5
|
-
`
|
|
4
|
+
capability authority, prepared-action provider defaults, and provider topology. SDK 0.6.2 accepts exactly schema
|
|
5
|
+
`6.0`; older schemas and unknown fields fail validation.
|
|
6
6
|
|
|
7
7
|
## Required top-level fields
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ Signing:
|
|
|
15
15
|
generate_keypair, sign_manifest, verify_manifest, SignatureStatus
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
__version__ = "0.6.
|
|
18
|
+
__version__ = "0.6.2"
|
|
19
19
|
|
|
20
20
|
from .capabilities import (
|
|
21
21
|
CapabilityDescriptor,
|
|
@@ -37,6 +37,10 @@ from .capabilities import (
|
|
|
37
37
|
WorldProjectionDescriptor,
|
|
38
38
|
WorldProviderDescriptor,
|
|
39
39
|
)
|
|
40
|
+
from .prepared_preview import (
|
|
41
|
+
PREVIEW_CONFORMANCE_VECTORS,
|
|
42
|
+
check_prepared_preview,
|
|
43
|
+
)
|
|
40
44
|
from .domains import CapabilityDomain, CAPABILITY_DOMAIN_IDS, DOMAIN_LABELS
|
|
41
45
|
from .hierarchy import (
|
|
42
46
|
AttributeOperation,
|
|
@@ -139,6 +143,9 @@ __all__ = [
|
|
|
139
143
|
"verify_manifest",
|
|
140
144
|
# MCP result contracts
|
|
141
145
|
"MCPResultContractError",
|
|
146
|
+
# Prepared-preview conformance
|
|
147
|
+
"PREVIEW_CONFORMANCE_VECTORS",
|
|
148
|
+
"check_prepared_preview",
|
|
142
149
|
"normalize_mcp_result",
|
|
143
150
|
"project_result_path",
|
|
144
151
|
"validate_capability_result",
|
|
@@ -348,6 +348,7 @@ class CapabilityDescriptor(BaseModel):
|
|
|
348
348
|
non_callable_reason: NonCallableReason | None = None
|
|
349
349
|
prepared_action: PreparedActionDescriptor | None = None
|
|
350
350
|
idempotency: IdempotencyDescriptor | None = None
|
|
351
|
+
provider_default_arguments: list[str] = Field(default_factory=list)
|
|
351
352
|
completion: CompletionDescriptor | None = None
|
|
352
353
|
hierarchical_attributes: list[HierarchicalAttributeDescriptor] = Field(default_factory=list)
|
|
353
354
|
reviewable_action_id: str | None = Field(
|
|
@@ -378,6 +379,24 @@ class CapabilityDescriptor(BaseModel):
|
|
|
378
379
|
and self.exposure == CapabilityExposure.MODEL
|
|
379
380
|
):
|
|
380
381
|
raise ValueError("reviewable delivery capabilities must be host-only")
|
|
382
|
+
if self.provider_default_arguments:
|
|
383
|
+
if self.prepared_action is None:
|
|
384
|
+
raise ValueError("provider_default_arguments require a prepared_action")
|
|
385
|
+
if len(set(self.provider_default_arguments)) != len(self.provider_default_arguments):
|
|
386
|
+
raise ValueError("provider_default_arguments must not repeat an argument")
|
|
387
|
+
optional_inputs = {
|
|
388
|
+
item.argument_name for item in self.inputs if not item.required
|
|
389
|
+
}
|
|
390
|
+
controls = {self.prepared_action.preview_argument}
|
|
391
|
+
if self.idempotency is not None:
|
|
392
|
+
controls.add(self.idempotency.argument_name)
|
|
393
|
+
for argument in self.provider_default_arguments:
|
|
394
|
+
if argument in controls:
|
|
395
|
+
raise ValueError("provider_default_arguments must not name a control argument")
|
|
396
|
+
if argument not in optional_inputs:
|
|
397
|
+
raise ValueError(
|
|
398
|
+
"provider_default_arguments must name optional declared inputs"
|
|
399
|
+
)
|
|
381
400
|
attributes = [item.attribute for item in self.hierarchical_attributes]
|
|
382
401
|
if len(attributes) != len(set(attributes)):
|
|
383
402
|
raise ValueError("hierarchical_attributes must not repeat an attribute")
|
|
@@ -15,6 +15,7 @@ class CapabilityDomain(str, Enum):
|
|
|
15
15
|
MRW = "mrw"
|
|
16
16
|
TRELLO = "trello"
|
|
17
17
|
TASKS = "tasks"
|
|
18
|
+
EXTERNAL = "external"
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
DOMAIN_LABELS: dict[CapabilityDomain, str] = {
|
|
@@ -25,6 +26,7 @@ DOMAIN_LABELS: dict[CapabilityDomain, str] = {
|
|
|
25
26
|
CapabilityDomain.MRW: "MRW",
|
|
26
27
|
CapabilityDomain.TRELLO: "Trello",
|
|
27
28
|
CapabilityDomain.TASKS: "Tareas",
|
|
29
|
+
CapabilityDomain.EXTERNAL: "Servicios externos",
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
CAPABILITY_DOMAIN_IDS = frozenset(domain.value for domain in CapabilityDomain)
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"""Conformance rule for the exact preview a preparation capability returns.
|
|
2
|
+
|
|
3
|
+
A prepared action freezes the preview ``arguments`` and later re-executes exactly that invocation, so
|
|
4
|
+
the preview must be a valid, complete call of the tool that echoes what the caller supplied. This
|
|
5
|
+
module is the single definition of that rule for plugin tests and for hosts: it is pure (no I/O) and
|
|
6
|
+
reports violations as stable codes. ``PREVIEW_CONFORMANCE_VECTORS`` are shared cases both sides run
|
|
7
|
+
against their own implementation so the two cannot drift.
|
|
8
|
+
|
|
9
|
+
Host-only concerns (personal-data restoration, host-resolved targets, risk arguments) stay in the
|
|
10
|
+
host; ``personal_arguments`` only lets a host state which values are checked for presence.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from collections.abc import Collection, Mapping
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
HOST_CONTROL_SCHEMA_KEY = "x-nutria-host-control"
|
|
19
|
+
|
|
20
|
+
UNDECLARED = "undeclared_argument"
|
|
21
|
+
MISSING_REQUIRED = "missing_required_argument"
|
|
22
|
+
OMITTED = "supplied_argument_omitted"
|
|
23
|
+
CONTRADICTED = "supplied_argument_contradicted"
|
|
24
|
+
NOT_A_PREVIEW = "snapshot_is_not_a_preview"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _contains(prepared: Any, explicit: Any) -> bool:
|
|
28
|
+
"""Provider-added subfields are allowed; contradictory supplied data is not."""
|
|
29
|
+
if isinstance(explicit, dict):
|
|
30
|
+
return isinstance(prepared, dict) and all(
|
|
31
|
+
key in prepared and _contains(prepared[key], value) for key, value in explicit.items()
|
|
32
|
+
)
|
|
33
|
+
if isinstance(explicit, list):
|
|
34
|
+
return (
|
|
35
|
+
isinstance(prepared, list)
|
|
36
|
+
and len(prepared) == len(explicit)
|
|
37
|
+
and all(_contains(p, e) for p, e in zip(prepared, explicit, strict=True))
|
|
38
|
+
)
|
|
39
|
+
return prepared == explicit
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _is_unset(value: Any) -> bool:
|
|
43
|
+
return value is None or (isinstance(value, str) and not value.strip())
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def check_prepared_preview(
|
|
47
|
+
capability: Mapping[str, Any],
|
|
48
|
+
input_schema: Mapping[str, Any],
|
|
49
|
+
requested: Mapping[str, Any],
|
|
50
|
+
snapshot: Mapping[str, Any],
|
|
51
|
+
*,
|
|
52
|
+
personal_arguments: Collection[str] = (),
|
|
53
|
+
) -> list[str]:
|
|
54
|
+
"""Return ``"<code>:<argument>"`` violations; an empty list means the preview conforms."""
|
|
55
|
+
properties = input_schema.get("properties") or {}
|
|
56
|
+
prepared = capability.get("prepared_action") or {}
|
|
57
|
+
idempotency = capability.get("idempotency") or {}
|
|
58
|
+
preview_argument = str(prepared.get("preview_argument") or "")
|
|
59
|
+
controls = {preview_argument, str(idempotency.get("argument_name") or "")} - {""}
|
|
60
|
+
controls.update(
|
|
61
|
+
name
|
|
62
|
+
for name, descriptor in properties.items()
|
|
63
|
+
if isinstance(descriptor, Mapping) and descriptor.get(HOST_CONTROL_SCHEMA_KEY)
|
|
64
|
+
)
|
|
65
|
+
provider_defaults = set(capability.get("provider_default_arguments") or ())
|
|
66
|
+
violations: list[str] = []
|
|
67
|
+
if preview_argument and snapshot.get(preview_argument) != prepared.get("preview_value"):
|
|
68
|
+
violations.append(f"{NOT_A_PREVIEW}:{preview_argument}")
|
|
69
|
+
violations += [f"{UNDECLARED}:{name}" for name in sorted(set(snapshot) - set(properties))]
|
|
70
|
+
required = set(input_schema.get("required") or ()) - controls
|
|
71
|
+
violations += [f"{MISSING_REQUIRED}:{name}" for name in sorted(required - set(snapshot))]
|
|
72
|
+
personal = set(personal_arguments)
|
|
73
|
+
for name, explicit in requested.items():
|
|
74
|
+
if name in controls:
|
|
75
|
+
continue
|
|
76
|
+
if name in provider_defaults and _is_unset(explicit):
|
|
77
|
+
continue
|
|
78
|
+
if name not in snapshot:
|
|
79
|
+
violations.append(f"{OMITTED}:{name}")
|
|
80
|
+
elif name not in personal and not _contains(snapshot[name], explicit):
|
|
81
|
+
violations.append(f"{CONTRADICTED}:{name}")
|
|
82
|
+
return violations
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
_CAPABILITY = {
|
|
86
|
+
"prepared_action": {"preview_argument": "preview_only", "preview_value": True},
|
|
87
|
+
"idempotency": {"argument_name": "idempotency_key"},
|
|
88
|
+
"provider_default_arguments": ["fecha"],
|
|
89
|
+
}
|
|
90
|
+
_SCHEMA = {
|
|
91
|
+
"properties": {
|
|
92
|
+
"recipient": {"type": "string"},
|
|
93
|
+
"fecha": {"type": "string"},
|
|
94
|
+
"note": {"type": "string"},
|
|
95
|
+
"preview_only": {"type": "boolean"},
|
|
96
|
+
"idempotency_key": {"type": "string"},
|
|
97
|
+
},
|
|
98
|
+
"required": ["recipient"],
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#: Shared cases: ``violations`` is the exact expected result of ``check_prepared_preview``.
|
|
102
|
+
PREVIEW_CONFORMANCE_VECTORS: tuple[dict[str, Any], ...] = (
|
|
103
|
+
{
|
|
104
|
+
"name": "echoes_supplied_values",
|
|
105
|
+
"capability": _CAPABILITY,
|
|
106
|
+
"schema": _SCHEMA,
|
|
107
|
+
"requested": {"recipient": "Ana", "preview_only": True},
|
|
108
|
+
"snapshot": {"recipient": "Ana", "preview_only": True},
|
|
109
|
+
"violations": [],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "provider_default_fills_an_empty_argument",
|
|
113
|
+
"capability": _CAPABILITY,
|
|
114
|
+
"schema": _SCHEMA,
|
|
115
|
+
"requested": {"recipient": "Ana", "fecha": "", "preview_only": True},
|
|
116
|
+
"snapshot": {"recipient": "Ana", "fecha": "21/10/2026", "preview_only": True},
|
|
117
|
+
"violations": [],
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "provider_default_never_overrides_a_supplied_value",
|
|
121
|
+
"capability": _CAPABILITY,
|
|
122
|
+
"schema": _SCHEMA,
|
|
123
|
+
"requested": {"recipient": "Ana", "fecha": "22/10/2026", "preview_only": True},
|
|
124
|
+
"snapshot": {"recipient": "Ana", "fecha": "21/10/2026", "preview_only": True},
|
|
125
|
+
"violations": ["supplied_argument_contradicted:fecha"],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "undeclared_default_stays_strict_when_empty",
|
|
129
|
+
"capability": _CAPABILITY,
|
|
130
|
+
"schema": _SCHEMA,
|
|
131
|
+
"requested": {"recipient": "Ana", "note": "", "preview_only": True},
|
|
132
|
+
"snapshot": {"recipient": "Ana", "note": "x", "preview_only": True},
|
|
133
|
+
"violations": ["supplied_argument_contradicted:note"],
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "supplied_empty_argument_must_not_vanish",
|
|
137
|
+
"capability": _CAPABILITY,
|
|
138
|
+
"schema": _SCHEMA,
|
|
139
|
+
"requested": {"recipient": "Ana", "note": "", "preview_only": True},
|
|
140
|
+
"snapshot": {"recipient": "Ana", "preview_only": True},
|
|
141
|
+
"violations": ["supplied_argument_omitted:note"],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "api_parameter_names_are_not_tool_arguments",
|
|
145
|
+
"capability": _CAPABILITY,
|
|
146
|
+
"schema": _SCHEMA,
|
|
147
|
+
"requested": {"recipient": "Ana", "preview_only": True},
|
|
148
|
+
"snapshot": {"idRecipient": "Ana", "preview_only": True},
|
|
149
|
+
"violations": [
|
|
150
|
+
"undeclared_argument:idRecipient",
|
|
151
|
+
"missing_required_argument:recipient",
|
|
152
|
+
"supplied_argument_omitted:recipient",
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "snapshot_must_be_a_preview",
|
|
157
|
+
"capability": _CAPABILITY,
|
|
158
|
+
"schema": _SCHEMA,
|
|
159
|
+
"requested": {"recipient": "Ana", "preview_only": True},
|
|
160
|
+
"snapshot": {"recipient": "Ana", "preview_only": False},
|
|
161
|
+
"violations": ["snapshot_is_not_a_preview:preview_only"],
|
|
162
|
+
},
|
|
163
|
+
)
|
|
@@ -284,3 +284,13 @@ def test_resource_input_requires_world_resource_origin():
|
|
|
284
284
|
"accepted_origins": ["current_user"],
|
|
285
285
|
}
|
|
286
286
|
)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def test_external_domain_is_part_of_the_stable_registry() -> None:
|
|
290
|
+
from nutria_plugin import CAPABILITY_DOMAIN_IDS, DOMAIN_LABELS
|
|
291
|
+
|
|
292
|
+
assert "external" in CAPABILITY_DOMAIN_IDS
|
|
293
|
+
assert DOMAIN_LABELS["external"] == "Servicios externos"
|
|
294
|
+
assert CapabilityDescriptor.model_validate(_capability(domains=["external"], **_safety_contracts())).domains == [
|
|
295
|
+
"external"
|
|
296
|
+
]
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""Provider defaults are declared in the manifest; the preview rule has one shared definition."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
from pydantic import ValidationError
|
|
7
|
+
|
|
8
|
+
from nutria_plugin import PREVIEW_CONFORMANCE_VECTORS, CapabilityDescriptor, check_prepared_preview
|
|
9
|
+
from tests.test_capability_contracts import _capability, _safety_contracts
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _with_input(name: str, *, required: bool) -> dict:
|
|
13
|
+
return {
|
|
14
|
+
"kind": "value",
|
|
15
|
+
"semantic_field": name,
|
|
16
|
+
"argument_name": name,
|
|
17
|
+
"required": required,
|
|
18
|
+
"data_class": "non_personal",
|
|
19
|
+
"accepted_origins": ["current_user"],
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _declared(**overrides) -> dict:
|
|
24
|
+
base = _capability(**_safety_contracts())
|
|
25
|
+
base["inputs"] = [*base["inputs"], _with_input("fecha", required=False)]
|
|
26
|
+
return {**base, **overrides}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_provider_default_arguments_default_to_empty() -> None:
|
|
30
|
+
assert CapabilityDescriptor.model_validate(_capability(**_safety_contracts())).provider_default_arguments == []
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_optional_declared_input_may_be_a_provider_default() -> None:
|
|
34
|
+
descriptor = CapabilityDescriptor.model_validate(_declared(provider_default_arguments=["fecha"]))
|
|
35
|
+
|
|
36
|
+
assert descriptor.provider_default_arguments == ["fecha"]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@pytest.mark.parametrize(
|
|
40
|
+
("overrides", "message"),
|
|
41
|
+
[
|
|
42
|
+
({"provider_default_arguments": ["recipient"]}, "optional declared inputs"),
|
|
43
|
+
({"provider_default_arguments": ["unknown"]}, "optional declared inputs"),
|
|
44
|
+
({"provider_default_arguments": ["fecha", "fecha"]}, "must not repeat"),
|
|
45
|
+
({"provider_default_arguments": ["preview_only"]}, "control argument"),
|
|
46
|
+
({"provider_default_arguments": ["idempotency_key"]}, "control argument"),
|
|
47
|
+
],
|
|
48
|
+
)
|
|
49
|
+
def test_provider_default_arguments_are_validated(overrides: dict, message: str) -> None:
|
|
50
|
+
with pytest.raises(ValidationError, match=message):
|
|
51
|
+
CapabilityDescriptor.model_validate(_declared(**overrides))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_provider_default_arguments_need_a_prepared_action() -> None:
|
|
55
|
+
payload = _capability(
|
|
56
|
+
exposure="host",
|
|
57
|
+
non_callable_reason={"code": "host_only", "safe_summary": "Host executes it."},
|
|
58
|
+
completion={"evidence": "none"},
|
|
59
|
+
provider_default_arguments=["recipient"],
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
with pytest.raises(ValidationError, match="require a prepared_action"):
|
|
63
|
+
CapabilityDescriptor.model_validate(payload)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@pytest.mark.parametrize("vector", PREVIEW_CONFORMANCE_VECTORS, ids=lambda item: item["name"])
|
|
67
|
+
def test_conformance_vectors_match_the_reference_rule(vector: dict) -> None:
|
|
68
|
+
assert (
|
|
69
|
+
check_prepared_preview(vector["capability"], vector["schema"], vector["requested"], vector["snapshot"])
|
|
70
|
+
== vector["violations"]
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_personal_values_are_checked_for_presence_only() -> None:
|
|
75
|
+
vector = next(item for item in PREVIEW_CONFORMANCE_VECTORS if item["name"] == "echoes_supplied_values")
|
|
76
|
+
snapshot = {**vector["snapshot"], "recipient": "restored value"}
|
|
77
|
+
|
|
78
|
+
assert check_prepared_preview(vector["capability"], vector["schema"], vector["requested"], snapshot) == [
|
|
79
|
+
"supplied_argument_contradicted:recipient"
|
|
80
|
+
]
|
|
81
|
+
assert (
|
|
82
|
+
check_prepared_preview(
|
|
83
|
+
vector["capability"], vector["schema"], vector["requested"], snapshot, personal_arguments={"recipient"}
|
|
84
|
+
)
|
|
85
|
+
== []
|
|
86
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|