Skip to content

Conversation

@bokelley
Copy link
Contributor

Summary

Add comprehensive utilities for parsing, validating, and discovering properties in adagents.json files per the AdCP specification. This enables sales agents to verify authorization and publishers to manage inventory across multiple agents.

Features

  • Authorization verification: Check if agents are authorized for specific properties
  • Property discovery: Extract and query all properties with filtering by agent or tags
  • Domain matching: Wildcard patterns, subdomain handling, protocol-agnostic matching
  • Full test coverage: 35 unit tests covering all core logic and edge cases

Testing

  • All 215 tests pass (8 new tests added)
  • Type checking passes with mypy
  • Comprehensive examples included

Changes

  • New module src/adcp/adagents.py with 8 public functions
  • 3 exception types for error handling
  • Updated README with usage examples
  • Complete working example demonstrating all features

bokelley and others added 6 commits November 13, 2025 07:37
Add utilities for fetching, parsing, and validating adagents.json files
per the AdCP specification. This allows sales agents to verify they are
authorized for specific publisher properties.

Features:
- fetch_adagents(): Async function to fetch and validate adagents.json
- verify_agent_authorization(): Check if agent is authorized for a property
- verify_agent_for_property(): Convenience wrapper combining fetch + verify
- domain_matches(): Domain matching logic per AdCP rules (wildcards, subdomains)
- identifiers_match(): Property identifier matching logic

Implements AdCP spec for publisher authorization:
- Wildcard domain patterns (*.example.com)
- Common subdomain matching (www, m)
- Protocol-agnostic agent URL matching
- Property type and identifier validation
- Multiple identifier types (domain, bundle_id, etc.)

Exception hierarchy:
- AdagentsValidationError: Base error for validation issues
- AdagentsNotFoundError: adagents.json not found (404)
- AdagentsTimeoutError: Request timeout

Tests:
- 27 unit tests covering all core logic
- Domain matching edge cases
- Identifier matching rules
- Authorization verification scenarios
- Error handling and validation

All existing tests pass (207 tests total)
Type checking passes with mypy

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive example demonstrating adagents.json validation:
- Fetching and parsing adagents.json
- Verifying agent authorization
- Domain matching rules
- Identifier matching
- Error handling

Includes working examples with mock data and explanations of
all key use cases for sales agents and publishers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Document the new adagents.json validation functionality:
- Usage examples for fetch_adagents and verify_agent_authorization
- Domain matching rules (wildcards, subdomains, protocol-agnostic)
- Use cases for sales agents and publishers
- Reference to complete examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add utilities to extract and query properties from adagents.json:
- get_all_properties(): Extract all properties across all agents
- get_all_tags(): Get unique tags from all properties
- get_properties_by_agent(): Filter properties by agent URL

Features:
- Extracts properties with agent_url for reference
- Protocol-agnostic agent URL matching
- Handles empty/missing properties gracefully
- Returns structured data for indexing and discovery

Use cases:
- Build property indexes and registries
- Discover available inventory by tags
- Query what properties an agent can sell
- Aggregate publisher inventory across agents

Tests:
- 8 new unit tests covering all edge cases
- All 215 tests pass

Example added demonstrating property discovery and tag extraction.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add domain input validation to prevent injection attacks
- Add comprehensive domain normalization (handles trailing dots/slashes)
- Add HTTP session management with optional client parameter for connection pooling
- Add 14 new tests for domain validation and normalization
- Fix line length violation in docstring

Security improvements:
- Validate publisher domains before HTTP requests
- Check for suspicious characters (backslash, @, newlines, tabs)
- Prevent path traversal attempts
- Enforce DNS domain length limits (253 chars)

Performance improvements:
- Optional httpx.AsyncClient parameter for connection reuse
- Enables connection pooling for multiple adagents.json fetches
- Reduces overhead for production use cases

All 229 tests pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Ruff's import sorter requires imports to be in alphabetical order.
This fixes the CI linter failure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@bokelley bokelley merged commit 4ea16a1 into main Nov 13, 2025
7 checks passed
bokelley added a commit that referenced this pull request Nov 18, 2025
* feat: add adagents.json validation support

Add utilities for fetching, parsing, and validating adagents.json files
per the AdCP specification. This allows sales agents to verify they are
authorized for specific publisher properties.

Features:
- fetch_adagents(): Async function to fetch and validate adagents.json
- verify_agent_authorization(): Check if agent is authorized for a property
- verify_agent_for_property(): Convenience wrapper combining fetch + verify
- domain_matches(): Domain matching logic per AdCP rules (wildcards, subdomains)
- identifiers_match(): Property identifier matching logic

Implements AdCP spec for publisher authorization:
- Wildcard domain patterns (*.example.com)
- Common subdomain matching (www, m)
- Protocol-agnostic agent URL matching
- Property type and identifier validation
- Multiple identifier types (domain, bundle_id, etc.)

Exception hierarchy:
- AdagentsValidationError: Base error for validation issues
- AdagentsNotFoundError: adagents.json not found (404)
- AdagentsTimeoutError: Request timeout

Tests:
- 27 unit tests covering all core logic
- Domain matching edge cases
- Identifier matching rules
- Authorization verification scenarios
- Error handling and validation

All existing tests pass (207 tests total)
Type checking passes with mypy

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: add adagents validation example

Add comprehensive example demonstrating adagents.json validation:
- Fetching and parsing adagents.json
- Verifying agent authorization
- Domain matching rules
- Identifier matching
- Error handling

Includes working examples with mock data and explanations of
all key use cases for sales agents and publishers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: add Publisher Authorization Validation section to README

Document the new adagents.json validation functionality:
- Usage examples for fetch_adagents and verify_agent_authorization
- Domain matching rules (wildcards, subdomains, protocol-agnostic)
- Use cases for sales agents and publishers
- Reference to complete examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add property and tag discovery functions

Add utilities to extract and query properties from adagents.json:
- get_all_properties(): Extract all properties across all agents
- get_all_tags(): Get unique tags from all properties
- get_properties_by_agent(): Filter properties by agent URL

Features:
- Extracts properties with agent_url for reference
- Protocol-agnostic agent URL matching
- Handles empty/missing properties gracefully
- Returns structured data for indexing and discovery

Use cases:
- Build property indexes and registries
- Discover available inventory by tags
- Query what properties an agent can sell
- Aggregate publisher inventory across agents

Tests:
- 8 new unit tests covering all edge cases
- All 215 tests pass

Example added demonstrating property discovery and tag extraction.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add security and performance improvements to adagents validation

- Add domain input validation to prevent injection attacks
- Add comprehensive domain normalization (handles trailing dots/slashes)
- Add HTTP session management with optional client parameter for connection pooling
- Add 14 new tests for domain validation and normalization
- Fix line length violation in docstring

Security improvements:
- Validate publisher domains before HTTP requests
- Check for suspicious characters (backslash, @, newlines, tabs)
- Prevent path traversal attempts
- Enforce DNS domain length limits (253 chars)

Performance improvements:
- Optional httpx.AsyncClient parameter for connection reuse
- Enables connection pooling for multiple adagents.json fetches
- Reduces overhead for production use cases

All 229 tests pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: correct import sorting in __init__.py for CI linter

Ruff's import sorter requires imports to be in alphabetical order.
This fixes the CI linter failure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants