pyagent-dns 0.1.0__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.
Files changed (37) hide show
  1. pyagent_dns-0.1.0/.gitignore +20 -0
  2. pyagent_dns-0.1.0/PKG-INFO +284 -0
  3. pyagent_dns-0.1.0/README.md +241 -0
  4. pyagent_dns-0.1.0/pyproject.toml +61 -0
  5. pyagent_dns-0.1.0/src/pyagent_dns/__init__.py +78 -0
  6. pyagent_dns-0.1.0/src/pyagent_dns/authority.py +1240 -0
  7. pyagent_dns-0.1.0/src/pyagent_dns/blueprint.py +178 -0
  8. pyagent_dns-0.1.0/src/pyagent_dns/diagnostics.py +90 -0
  9. pyagent_dns-0.1.0/src/pyagent_dns/events.py +87 -0
  10. pyagent_dns-0.1.0/src/pyagent_dns/middleware.py +392 -0
  11. pyagent_dns-0.1.0/src/pyagent_dns/py.typed +1 -0
  12. pyagent_dns-0.1.0/src/pyagent_dns/records.py +490 -0
  13. pyagent_dns-0.1.0/src/pyagent_dns/registry.py +254 -0
  14. pyagent_dns-0.1.0/src/pyagent_dns/resolver.py +141 -0
  15. pyagent_dns-0.1.0/src/pyagent_dns/signing.py +280 -0
  16. pyagent_dns-0.1.0/tests/__init__.py +1 -0
  17. pyagent_dns-0.1.0/tests/conftest.py +273 -0
  18. pyagent_dns-0.1.0/tests/fixtures/agent_card.json +17 -0
  19. pyagent_dns-0.1.0/tests/fixtures/blueprint_with_dns.yaml +28 -0
  20. pyagent_dns-0.1.0/tests/fixtures/blueprint_without_dns.yaml +21 -0
  21. pyagent_dns-0.1.0/tests/fixtures/grants.yaml +14 -0
  22. pyagent_dns-0.1.0/tests/fixtures/records.yaml +17 -0
  23. pyagent_dns-0.1.0/tests/fixtures/trusted_keys.yaml +8 -0
  24. pyagent_dns-0.1.0/tests/test_attenuation_property.py +208 -0
  25. pyagent_dns-0.1.0/tests/test_authority.py +574 -0
  26. pyagent_dns-0.1.0/tests/test_blueprint_ext.py +420 -0
  27. pyagent_dns-0.1.0/tests/test_contract_mockllm.py +190 -0
  28. pyagent_dns-0.1.0/tests/test_delegation.py +427 -0
  29. pyagent_dns-0.1.0/tests/test_diagnostics.py +59 -0
  30. pyagent_dns-0.1.0/tests/test_events.py +178 -0
  31. pyagent_dns-0.1.0/tests/test_grants.py +238 -0
  32. pyagent_dns-0.1.0/tests/test_middleware.py +675 -0
  33. pyagent_dns-0.1.0/tests/test_name_registry.py +339 -0
  34. pyagent_dns-0.1.0/tests/test_readme.py +53 -0
  35. pyagent_dns-0.1.0/tests/test_records.py +473 -0
  36. pyagent_dns-0.1.0/tests/test_resolver.py +197 -0
  37. pyagent_dns-0.1.0/tests/test_signing.py +369 -0
@@ -0,0 +1,20 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.egg-info/
5
+ .claude/
6
+ dist/
7
+ build/
8
+ .eggs/
9
+ *.egg
10
+ .venv/
11
+ venv/
12
+ .mypy_cache/
13
+ .ruff_cache/
14
+ .pytest_cache/
15
+ .coverage
16
+ htmlcov/
17
+ site/
18
+ .env
19
+ *.log
20
+ .DS_Store
@@ -0,0 +1,284 @@
1
+ Metadata-Version: 2.5
2
+ Name: pyagent-dns
3
+ Version: 0.1.0
4
+ Summary: Separates naming from authorization for multi-agent systems with signed records and attenuated authority graphs.
5
+ Project-URL: Homepage, https://pyagent.org
6
+ Project-URL: Repository, https://github.com/pyagent-core/pyagent
7
+ Project-URL: Documentation, https://pyagent.org
8
+ Project-URL: Design Patterns, https://pyagent.org/packages/patterns/
9
+ Project-URL: Getting Started, https://pyagent.org/getting-started/
10
+ Project-URL: Cookbook, https://pyagent.org/cookbook/
11
+ Author-email: PyAgent Team <team@pyagent.org>
12
+ License: MIT
13
+ Keywords: AXO,LLM,agent identity,agents,authorization,discovery,multi-agent,registry
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: cryptography>=42
24
+ Requires-Dist: pyagent-patterns>=0.1.0
25
+ Requires-Dist: pydantic>=2.7
26
+ Requires-Dist: pyyaml>=6.0
27
+ Provides-Extra: all
28
+ Requires-Dist: pyagent-blueprint>=0.1.0; extra == 'all'
29
+ Requires-Dist: pyagent-context>=0.1.0; extra == 'all'
30
+ Requires-Dist: pyagent-trace>=0.1.0; extra == 'all'
31
+ Provides-Extra: blueprint
32
+ Requires-Dist: pyagent-blueprint>=0.1.0; extra == 'blueprint'
33
+ Provides-Extra: context
34
+ Requires-Dist: pyagent-context>=0.1.0; extra == 'context'
35
+ Provides-Extra: dev
36
+ Requires-Dist: mypy>=1.10; extra == 'dev'
37
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
38
+ Requires-Dist: pytest>=8.0; extra == 'dev'
39
+ Requires-Dist: ruff>=0.5; extra == 'dev'
40
+ Provides-Extra: trace
41
+ Requires-Dist: pyagent-trace>=0.1.0; extra == 'trace'
42
+ Description-Content-Type: text/markdown
43
+
44
+ # pyagent-dns
45
+
46
+ A standalone PyAgent package that separates naming from authorization for multi-agent systems with signed records and attenuated authority graphs.
47
+
48
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](../../LICENSE)
49
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
50
+
51
+ > **Architecture Extension: 🛡️ Naming & Authorization**
52
+ > A local-first, spec-driven authorization plane for agents, tools, providers, data, and approvers.
53
+ > Resolves names to cryptographically signed records and verifies authority graphs before consequential actions run.
54
+ > Part of the PyAgent ecosystem: `pip install pyagent-dns`.
55
+
56
+ ## Disambiguation
57
+
58
+ `pyagent-dns` is:
59
+ - **Not AgentDNS**: It does not implement global decentralized root servers, cryptocurrency settlement, or billing tokens.
60
+ - **Not OWASP ANS or IETF DAWN**: It does not require public PKI certificate authorities or internet-wide DID federation.
61
+ - **What it is**: A local-first, in-repo implementation of the separation those standards leave open: **records describe, grants decide**.
62
+
63
+ ## Install
64
+
65
+ ```bash
66
+ pip install pyagent-dns # Core (records, Ed25519 signing, registry, graph, middleware)
67
+ pip install "pyagent-dns[trace]" # + PyAgent trace event bus integration
68
+ pip install "pyagent-dns[context]" # + PyAgent context sensitivity and redaction mapping
69
+ pip install "pyagent-dns[blueprint]" # + PyAgent blueprint extension loader
70
+ pip install "pyagent-dns[all]" # All optional integrations
71
+ ```
72
+
73
+ Depends on: `pyagent-patterns`, `pydantic`, `pyyaml`, `cryptography`.
74
+
75
+ ## Why Two Planes?
76
+
77
+ In conventional agent architectures, discovering a tool or endpoint implies having permission to call it. This ambient authority creates the confused deputy problem: a high-clearance supervisor delegates to a subagent, which then invokes high-risk tools with no boundary checks.
78
+
79
+ `pyagent-dns` splits this into two independent planes:
80
+ 1. **Naming Plane**: Cryptographically signed `NameRecord` objects declare capabilities, endpoints, data classes, and schema hashes.
81
+ 2. **Authorization Plane**: `Grant` declarations evaluate whether a principal chain may execute a specific action on a capability for a designated purpose under strict limits.
82
+
83
+ ---
84
+
85
+ ## Quickstart
86
+
87
+ Every Python block below is executed by the test suite, in order, so this page cannot drift from the API.
88
+
89
+ ### 1. Sign a NameRecord
90
+
91
+ ```python
92
+ from pyagent_dns.records import Identity, NameRecord, RecordKind
93
+ from pyagent_dns.signing import (
94
+ TrustedKey,
95
+ TrustedKeys,
96
+ fingerprint_of_public_key,
97
+ generate_keypair,
98
+ load_private_key,
99
+ sign_record,
100
+ )
101
+
102
+ # Writes private_key.pem (mode 0600) and public_key.pem. Never overwrites an existing key.
103
+ private_path, public_path = generate_keypair(".keys")
104
+ public_key = public_path.read_text()
105
+ fingerprint = fingerprint_of_public_key(public_key)
106
+
107
+ record = NameRecord(
108
+ name="portfolio-data.reader",
109
+ kind=RecordKind.TOOL,
110
+ version="1.0.0",
111
+ endpoint="https://internal.bank/tools/portfolio",
112
+ identity=Identity(
113
+ public_key_fingerprint=fingerprint,
114
+ public_key=public_key,
115
+ signed_by="security_team",
116
+ ),
117
+ schema_hash="sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
118
+ capabilities=("read_positions", "read_holdings"),
119
+ data_classes=("internal",),
120
+ owner="wealth_platform_team",
121
+ )
122
+ signed_record = sign_record(record, load_private_key(private_path))
123
+ ```
124
+
125
+ ### 2. Register it and resolve it
126
+
127
+ A record is only as trustworthy as the keys you trust. The registry verifies against the
128
+ `TrustedKeys` you give it, never against a key carried inside the record.
129
+
130
+ ```python
131
+ from pyagent_dns.registry import NameRegistry
132
+ from pyagent_dns.resolver import Resolver
133
+
134
+ trusted = TrustedKeys([TrustedKey("security_team", fingerprint, public_key)])
135
+ registry = NameRegistry(trusted)
136
+ registry.register(signed_record)
137
+
138
+ resolver = Resolver(registry)
139
+ resolution = resolver.resolve("portfolio-data.reader")
140
+ print(resolution.verification) # verified
141
+ print(resolution.from_cache) # False
142
+ ```
143
+
144
+ Resolution is a local lookup and a signature check. It never connects to the record's endpoint.
145
+
146
+ ### 3. Evaluate a grant
147
+
148
+ Resolving a name grants nothing. Permission comes only from a `Grant`.
149
+
150
+ ```python
151
+ from pyagent_dns.authority import (
152
+ Action,
153
+ AuthorityGraph,
154
+ CallContext,
155
+ Grant,
156
+ Limits,
157
+ ResourceSelector,
158
+ )
159
+
160
+ graph = AuthorityGraph(registry)
161
+ graph.add_grant(
162
+ Grant(
163
+ grant_id="grant-001",
164
+ principal="analyst_agent",
165
+ action=Action.CALL,
166
+ capability="portfolio-data.reader",
167
+ resource=ResourceSelector(data_classes=("internal",)),
168
+ purpose="portfolio_review",
169
+ limits=Limits(max_records_per_call=500),
170
+ )
171
+ )
172
+
173
+ decision = graph.authorize(
174
+ ["analyst_agent"],
175
+ Action.CALL,
176
+ "portfolio-data.reader",
177
+ ResourceSelector(),
178
+ CallContext(purpose="portfolio_review", records_requested=100),
179
+ resolution,
180
+ )
181
+ print(decision.allowed, decision.reason_code) # True GRANT_FOUND
182
+ ```
183
+
184
+ ### 4. Guard ReAct tools
185
+
186
+ ```python
187
+ from pyagent_dns.middleware import DnsMiddleware
188
+
189
+ middleware = DnsMiddleware(resolver, graph)
190
+ tools = {"portfolio-data.reader": lambda query: "positions: AAPL, GOOG"}
191
+
192
+ analyst_tools = middleware.guard_tools(
193
+ tools, principal_chain=["analyst_agent"], purpose="portfolio_review"
194
+ )
195
+ print(analyst_tools["portfolio-data.reader"]("account_123")) # positions: AAPL, GOOG
196
+
197
+ stranger_tools = middleware.guard_tools(
198
+ tools, principal_chain=["stranger"], purpose="portfolio_review"
199
+ )
200
+ print(stranger_tools["portfolio-data.reader"]("account_123")) # DENIED [NO_GRANT] ...
201
+ ```
202
+
203
+ A denied tool is never called. The model receives the `DENIED [CODE] reason` string as its
204
+ observation, so it can replan. Every decision is kept in `middleware.decisions`.
205
+
206
+ ---
207
+
208
+ ## Downward-Only Delegation (Attenuation)
209
+
210
+ A grant can be delegated to a subagent, but authority can only narrow, never widen:
211
+
212
+ ```python
213
+ from pyagent_dns.authority import AttenuationError, DelegationTerms, GrantScope
214
+
215
+ graph.add_grant(
216
+ Grant(
217
+ grant_id="grant-lead",
218
+ principal="lead_agent",
219
+ action=Action.CALL,
220
+ capability="portfolio-data.reader",
221
+ resource=ResourceSelector(data_classes=("internal",)),
222
+ purpose="portfolio_review",
223
+ limits=Limits(max_records_per_call=500),
224
+ delegation=DelegationTerms(allowed=True),
225
+ )
226
+ )
227
+
228
+ narrower = graph.delegate(
229
+ "grant-lead",
230
+ delegate_principal="subagent_researcher",
231
+ scope=GrantScope(limits=Limits(max_records_per_call=100)),
232
+ )
233
+ print(narrower.grant.limits.max_records_per_call) # 100
234
+
235
+ try:
236
+ graph.delegate(
237
+ "grant-lead",
238
+ delegate_principal="subagent_researcher",
239
+ scope=GrantScope(limits=Limits(max_records_per_call=1000)),
240
+ )
241
+ except AttenuationError as err:
242
+ print(f"Refused widening on: {err.dimension}") # limits.max_records_per_call
243
+ ```
244
+
245
+ ---
246
+
247
+ ## Known Limitations of v0.1
248
+
249
+ 1. **ReAct Tool Call Surface**: Because `pyagent-patterns` executes tools by text parsing in `ReAct`, tools accept a string input. Structured argument inspection and per-call numeric limits (`records_requested`, `amount`) are evaluated via `authorize_call()`, while `guard_tools()` hashes raw string input for approval bindings.
250
+ 2. **Blueprint Spec Extension**: Top-level `x-pyagent:dns` blocks are read directly from YAML via `load_blueprint_dns()`. They do not currently round-trip through `pyagent-blueprint`'s `BlueprintSpec` parser.
251
+ 3. **Local Resolution**: Verification validates the authenticity and integrity of the `NameRecord`. It does not connect to remote endpoints or verify live workload identity at runtime.
252
+
253
+ ---
254
+
255
+ ## Full Documentation
256
+
257
+ See [pyagent.org](https://pyagent.org) for full API references, architecture guides, and cookbook examples.
258
+
259
+ <!-- pyagent-ecosystem-footer:start -->
260
+
261
+ ## The PyAgent ecosystem
262
+
263
+ PyAgent is a spec-driven architecture for orchestrating multi-agent systems. Each package is independent — install
264
+ only what you need, or get everything with [`pip install pyagent-all`](https://pyagent.org/getting-started/).
265
+
266
+ | Package | What it gives you |
267
+ |---------|-------------------|
268
+ | `pyagent-blueprint` | [Declarative multi-agent blueprints](https://pyagent.org/guides/blueprint/) — compile, validate, and diff agent systems from YAML |
269
+ | `pyagent-patterns` | [Reusable multi-agent design patterns](https://pyagent.org/packages/patterns/) — Supervisor, Pipeline, ReAct, and 15 more |
270
+ | `pyagent-router` | [Difficulty-aware model routing](https://pyagent.org/guides/router/) — cost-efficient model selection per task |
271
+ | `pyagent-compress` | [Token-efficient agent compression](https://pyagent.org/guides/compression/) — inter-agent token budgets |
272
+ | `pyagent-providers` | [Multi-provider orchestration](https://pyagent.org/guides/providers/) — fallback chains and capability negotiation |
273
+ | `pyagent-context` | [Stateful agent memory](https://pyagent.org/guides/context/) — trust-aware, three-tier context ledger |
274
+ | `pyagent-trace` | [Multi-agent observability & tracing](https://pyagent.org/guides/tracing/) — pattern-aware OpenTelemetry spans |
275
+ | `pyagent-studio` | [Agent control plane dashboard](https://pyagent.org/guides/studio/) — live traces, cost, and governance |
276
+ | `pyagent-dns` | [Agent naming & authority graph](https://pyagent.org/packages/dns/) — signed records and attenuated grants |
277
+
278
+ **Learn more:**
279
+ [Design patterns](https://pyagent.org/packages/patterns/) ·
280
+ [Cookbook](https://pyagent.org/cookbook/) ·
281
+ [Get started](https://pyagent.org/getting-started/)
282
+
283
+ <!-- pyagent-ecosystem-footer:end -->
284
+
@@ -0,0 +1,241 @@
1
+ # pyagent-dns
2
+
3
+ A standalone PyAgent package that separates naming from authorization for multi-agent systems with signed records and attenuated authority graphs.
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](../../LICENSE)
6
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
7
+
8
+ > **Architecture Extension: 🛡️ Naming & Authorization**
9
+ > A local-first, spec-driven authorization plane for agents, tools, providers, data, and approvers.
10
+ > Resolves names to cryptographically signed records and verifies authority graphs before consequential actions run.
11
+ > Part of the PyAgent ecosystem: `pip install pyagent-dns`.
12
+
13
+ ## Disambiguation
14
+
15
+ `pyagent-dns` is:
16
+ - **Not AgentDNS**: It does not implement global decentralized root servers, cryptocurrency settlement, or billing tokens.
17
+ - **Not OWASP ANS or IETF DAWN**: It does not require public PKI certificate authorities or internet-wide DID federation.
18
+ - **What it is**: A local-first, in-repo implementation of the separation those standards leave open: **records describe, grants decide**.
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ pip install pyagent-dns # Core (records, Ed25519 signing, registry, graph, middleware)
24
+ pip install "pyagent-dns[trace]" # + PyAgent trace event bus integration
25
+ pip install "pyagent-dns[context]" # + PyAgent context sensitivity and redaction mapping
26
+ pip install "pyagent-dns[blueprint]" # + PyAgent blueprint extension loader
27
+ pip install "pyagent-dns[all]" # All optional integrations
28
+ ```
29
+
30
+ Depends on: `pyagent-patterns`, `pydantic`, `pyyaml`, `cryptography`.
31
+
32
+ ## Why Two Planes?
33
+
34
+ In conventional agent architectures, discovering a tool or endpoint implies having permission to call it. This ambient authority creates the confused deputy problem: a high-clearance supervisor delegates to a subagent, which then invokes high-risk tools with no boundary checks.
35
+
36
+ `pyagent-dns` splits this into two independent planes:
37
+ 1. **Naming Plane**: Cryptographically signed `NameRecord` objects declare capabilities, endpoints, data classes, and schema hashes.
38
+ 2. **Authorization Plane**: `Grant` declarations evaluate whether a principal chain may execute a specific action on a capability for a designated purpose under strict limits.
39
+
40
+ ---
41
+
42
+ ## Quickstart
43
+
44
+ Every Python block below is executed by the test suite, in order, so this page cannot drift from the API.
45
+
46
+ ### 1. Sign a NameRecord
47
+
48
+ ```python
49
+ from pyagent_dns.records import Identity, NameRecord, RecordKind
50
+ from pyagent_dns.signing import (
51
+ TrustedKey,
52
+ TrustedKeys,
53
+ fingerprint_of_public_key,
54
+ generate_keypair,
55
+ load_private_key,
56
+ sign_record,
57
+ )
58
+
59
+ # Writes private_key.pem (mode 0600) and public_key.pem. Never overwrites an existing key.
60
+ private_path, public_path = generate_keypair(".keys")
61
+ public_key = public_path.read_text()
62
+ fingerprint = fingerprint_of_public_key(public_key)
63
+
64
+ record = NameRecord(
65
+ name="portfolio-data.reader",
66
+ kind=RecordKind.TOOL,
67
+ version="1.0.0",
68
+ endpoint="https://internal.bank/tools/portfolio",
69
+ identity=Identity(
70
+ public_key_fingerprint=fingerprint,
71
+ public_key=public_key,
72
+ signed_by="security_team",
73
+ ),
74
+ schema_hash="sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
75
+ capabilities=("read_positions", "read_holdings"),
76
+ data_classes=("internal",),
77
+ owner="wealth_platform_team",
78
+ )
79
+ signed_record = sign_record(record, load_private_key(private_path))
80
+ ```
81
+
82
+ ### 2. Register it and resolve it
83
+
84
+ A record is only as trustworthy as the keys you trust. The registry verifies against the
85
+ `TrustedKeys` you give it, never against a key carried inside the record.
86
+
87
+ ```python
88
+ from pyagent_dns.registry import NameRegistry
89
+ from pyagent_dns.resolver import Resolver
90
+
91
+ trusted = TrustedKeys([TrustedKey("security_team", fingerprint, public_key)])
92
+ registry = NameRegistry(trusted)
93
+ registry.register(signed_record)
94
+
95
+ resolver = Resolver(registry)
96
+ resolution = resolver.resolve("portfolio-data.reader")
97
+ print(resolution.verification) # verified
98
+ print(resolution.from_cache) # False
99
+ ```
100
+
101
+ Resolution is a local lookup and a signature check. It never connects to the record's endpoint.
102
+
103
+ ### 3. Evaluate a grant
104
+
105
+ Resolving a name grants nothing. Permission comes only from a `Grant`.
106
+
107
+ ```python
108
+ from pyagent_dns.authority import (
109
+ Action,
110
+ AuthorityGraph,
111
+ CallContext,
112
+ Grant,
113
+ Limits,
114
+ ResourceSelector,
115
+ )
116
+
117
+ graph = AuthorityGraph(registry)
118
+ graph.add_grant(
119
+ Grant(
120
+ grant_id="grant-001",
121
+ principal="analyst_agent",
122
+ action=Action.CALL,
123
+ capability="portfolio-data.reader",
124
+ resource=ResourceSelector(data_classes=("internal",)),
125
+ purpose="portfolio_review",
126
+ limits=Limits(max_records_per_call=500),
127
+ )
128
+ )
129
+
130
+ decision = graph.authorize(
131
+ ["analyst_agent"],
132
+ Action.CALL,
133
+ "portfolio-data.reader",
134
+ ResourceSelector(),
135
+ CallContext(purpose="portfolio_review", records_requested=100),
136
+ resolution,
137
+ )
138
+ print(decision.allowed, decision.reason_code) # True GRANT_FOUND
139
+ ```
140
+
141
+ ### 4. Guard ReAct tools
142
+
143
+ ```python
144
+ from pyagent_dns.middleware import DnsMiddleware
145
+
146
+ middleware = DnsMiddleware(resolver, graph)
147
+ tools = {"portfolio-data.reader": lambda query: "positions: AAPL, GOOG"}
148
+
149
+ analyst_tools = middleware.guard_tools(
150
+ tools, principal_chain=["analyst_agent"], purpose="portfolio_review"
151
+ )
152
+ print(analyst_tools["portfolio-data.reader"]("account_123")) # positions: AAPL, GOOG
153
+
154
+ stranger_tools = middleware.guard_tools(
155
+ tools, principal_chain=["stranger"], purpose="portfolio_review"
156
+ )
157
+ print(stranger_tools["portfolio-data.reader"]("account_123")) # DENIED [NO_GRANT] ...
158
+ ```
159
+
160
+ A denied tool is never called. The model receives the `DENIED [CODE] reason` string as its
161
+ observation, so it can replan. Every decision is kept in `middleware.decisions`.
162
+
163
+ ---
164
+
165
+ ## Downward-Only Delegation (Attenuation)
166
+
167
+ A grant can be delegated to a subagent, but authority can only narrow, never widen:
168
+
169
+ ```python
170
+ from pyagent_dns.authority import AttenuationError, DelegationTerms, GrantScope
171
+
172
+ graph.add_grant(
173
+ Grant(
174
+ grant_id="grant-lead",
175
+ principal="lead_agent",
176
+ action=Action.CALL,
177
+ capability="portfolio-data.reader",
178
+ resource=ResourceSelector(data_classes=("internal",)),
179
+ purpose="portfolio_review",
180
+ limits=Limits(max_records_per_call=500),
181
+ delegation=DelegationTerms(allowed=True),
182
+ )
183
+ )
184
+
185
+ narrower = graph.delegate(
186
+ "grant-lead",
187
+ delegate_principal="subagent_researcher",
188
+ scope=GrantScope(limits=Limits(max_records_per_call=100)),
189
+ )
190
+ print(narrower.grant.limits.max_records_per_call) # 100
191
+
192
+ try:
193
+ graph.delegate(
194
+ "grant-lead",
195
+ delegate_principal="subagent_researcher",
196
+ scope=GrantScope(limits=Limits(max_records_per_call=1000)),
197
+ )
198
+ except AttenuationError as err:
199
+ print(f"Refused widening on: {err.dimension}") # limits.max_records_per_call
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Known Limitations of v0.1
205
+
206
+ 1. **ReAct Tool Call Surface**: Because `pyagent-patterns` executes tools by text parsing in `ReAct`, tools accept a string input. Structured argument inspection and per-call numeric limits (`records_requested`, `amount`) are evaluated via `authorize_call()`, while `guard_tools()` hashes raw string input for approval bindings.
207
+ 2. **Blueprint Spec Extension**: Top-level `x-pyagent:dns` blocks are read directly from YAML via `load_blueprint_dns()`. They do not currently round-trip through `pyagent-blueprint`'s `BlueprintSpec` parser.
208
+ 3. **Local Resolution**: Verification validates the authenticity and integrity of the `NameRecord`. It does not connect to remote endpoints or verify live workload identity at runtime.
209
+
210
+ ---
211
+
212
+ ## Full Documentation
213
+
214
+ See [pyagent.org](https://pyagent.org) for full API references, architecture guides, and cookbook examples.
215
+
216
+ <!-- pyagent-ecosystem-footer:start -->
217
+
218
+ ## The PyAgent ecosystem
219
+
220
+ PyAgent is a spec-driven architecture for orchestrating multi-agent systems. Each package is independent — install
221
+ only what you need, or get everything with [`pip install pyagent-all`](https://pyagent.org/getting-started/).
222
+
223
+ | Package | What it gives you |
224
+ |---------|-------------------|
225
+ | `pyagent-blueprint` | [Declarative multi-agent blueprints](https://pyagent.org/guides/blueprint/) — compile, validate, and diff agent systems from YAML |
226
+ | `pyagent-patterns` | [Reusable multi-agent design patterns](https://pyagent.org/packages/patterns/) — Supervisor, Pipeline, ReAct, and 15 more |
227
+ | `pyagent-router` | [Difficulty-aware model routing](https://pyagent.org/guides/router/) — cost-efficient model selection per task |
228
+ | `pyagent-compress` | [Token-efficient agent compression](https://pyagent.org/guides/compression/) — inter-agent token budgets |
229
+ | `pyagent-providers` | [Multi-provider orchestration](https://pyagent.org/guides/providers/) — fallback chains and capability negotiation |
230
+ | `pyagent-context` | [Stateful agent memory](https://pyagent.org/guides/context/) — trust-aware, three-tier context ledger |
231
+ | `pyagent-trace` | [Multi-agent observability & tracing](https://pyagent.org/guides/tracing/) — pattern-aware OpenTelemetry spans |
232
+ | `pyagent-studio` | [Agent control plane dashboard](https://pyagent.org/guides/studio/) — live traces, cost, and governance |
233
+ | `pyagent-dns` | [Agent naming & authority graph](https://pyagent.org/packages/dns/) — signed records and attenuated grants |
234
+
235
+ **Learn more:**
236
+ [Design patterns](https://pyagent.org/packages/patterns/) ·
237
+ [Cookbook](https://pyagent.org/cookbook/) ·
238
+ [Get started](https://pyagent.org/getting-started/)
239
+
240
+ <!-- pyagent-ecosystem-footer:end -->
241
+
@@ -0,0 +1,61 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pyagent-dns"
7
+ version = "0.1.0"
8
+ description = "Separates naming from authorization for multi-agent systems with signed records and attenuated authority graphs."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = {text = "MIT"}
12
+ authors = [{name = "PyAgent Team", email = "team@pyagent.org"}]
13
+ keywords = [
14
+ "agents",
15
+ "multi-agent",
16
+ "LLM",
17
+ "authorization",
18
+ "registry",
19
+ "discovery",
20
+ "agent identity",
21
+ "AXO",
22
+ ]
23
+ classifiers = [
24
+ "Development Status :: 3 - Alpha",
25
+ "Intended Audience :: Developers",
26
+ "License :: OSI Approved :: MIT License",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
31
+ "Typing :: Typed",
32
+ ]
33
+ dependencies = [
34
+ "pyagent-patterns>=0.1.0",
35
+ "pydantic>=2.7",
36
+ "pyyaml>=6.0",
37
+ "cryptography>=42",
38
+ ]
39
+
40
+ [project.urls]
41
+ Homepage = "https://pyagent.org"
42
+ Repository = "https://github.com/pyagent-core/pyagent"
43
+ Documentation = "https://pyagent.org"
44
+ "Design Patterns" = "https://pyagent.org/packages/patterns/"
45
+ "Getting Started" = "https://pyagent.org/getting-started/"
46
+ "Cookbook" = "https://pyagent.org/cookbook/"
47
+
48
+ [project.optional-dependencies]
49
+ trace = ["pyagent-trace>=0.1.0"]
50
+ context = ["pyagent-context>=0.1.0"]
51
+ blueprint = ["pyagent-blueprint>=0.1.0"]
52
+ dev = ["pytest>=8.0", "pytest-asyncio>=0.23", "ruff>=0.5", "mypy>=1.10"]
53
+ all = [
54
+ "pyagent-trace>=0.1.0",
55
+ "pyagent-context>=0.1.0",
56
+ "pyagent-blueprint>=0.1.0",
57
+ ]
58
+
59
+ [tool.hatch.build.targets.wheel]
60
+ packages = ["src/pyagent_dns"]
61
+
@@ -0,0 +1,78 @@
1
+ """pyagent-dns: Agent naming plane and authority graph for multi-agent systems."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pyagent_dns.authority import (
6
+ HIGH_RISK_ACTIONS,
7
+ Action,
8
+ AttenuationError,
9
+ AuthorityGraph,
10
+ CallContext,
11
+ Decision,
12
+ DelegationResult,
13
+ DelegationTerms,
14
+ DelegationToken,
15
+ Grant,
16
+ GrantEffect,
17
+ GrantScope,
18
+ Limits,
19
+ Obligation,
20
+ Outcome,
21
+ ResourceSelector,
22
+ )
23
+ from pyagent_dns.blueprint import DnsBundle, DnsExtensionSpec, load_blueprint_dns
24
+ from pyagent_dns.middleware import (
25
+ AuthorizationDeniedError,
26
+ AuthorizedAgent,
27
+ DnsMiddleware,
28
+ SessionCounter,
29
+ )
30
+ from pyagent_dns.records import (
31
+ Identity,
32
+ NameRecord,
33
+ RecordInfo,
34
+ RecordKind,
35
+ RecordLoadError,
36
+ RecordStatus,
37
+ )
38
+ from pyagent_dns.registry import NameRegistry
39
+ from pyagent_dns.resolver import Resolution, Resolver
40
+ from pyagent_dns.signing import VerificationStatus
41
+
42
+ __version__ = "0.1.0"
43
+
44
+ __all__ = [
45
+ "HIGH_RISK_ACTIONS",
46
+ "Action",
47
+ "AttenuationError",
48
+ "AuthorityGraph",
49
+ "AuthorizationDeniedError",
50
+ "AuthorizedAgent",
51
+ "CallContext",
52
+ "Decision",
53
+ "DelegationResult",
54
+ "DelegationTerms",
55
+ "DelegationToken",
56
+ "DnsBundle",
57
+ "DnsExtensionSpec",
58
+ "DnsMiddleware",
59
+ "Grant",
60
+ "GrantEffect",
61
+ "GrantScope",
62
+ "Identity",
63
+ "Limits",
64
+ "NameRecord",
65
+ "NameRegistry",
66
+ "Obligation",
67
+ "Outcome",
68
+ "RecordInfo",
69
+ "RecordKind",
70
+ "RecordLoadError",
71
+ "RecordStatus",
72
+ "Resolution",
73
+ "Resolver",
74
+ "ResourceSelector",
75
+ "SessionCounter",
76
+ "VerificationStatus",
77
+ "load_blueprint_dns",
78
+ ]