Skip to content

Add product-based agent authorization validation - #356

Merged
bokelley merged 3 commits into
mainfrom
bokelley/fix-registry-agents
Dec 24, 2025
Merged

bokelley merged 3 commits into
mainfrom
bokelley/fix-registry-agents

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Implement validation endpoints that accept Product schema's publisher_properties format, allowing clients to validate agent authorization against product inventory selectors. Added database layer for querying and expanding selectors to concrete identifiers for real-time caching.

Changes

  • Database: validateAgentForProduct() validates against product selectors with per-selector breakdown showing coverage percentage and unauthorized items
  • Database: expandPublisherPropertiesToIdentifiers() expands selectors (all/by_id/by_tag) to flat identifier list for real-time caching
  • API endpoints: POST /api/registry/validate/product-authorization and POST /api/registry/expand/product-identifiers
  • Agent list response: Returns property_summary (counts, not full list) for sales agents to avoid millions of records

Test Plan

  • All schema tests pass (158 schemas validated)
  • All unit tests pass (30 tests)
  • TypeScript compilation succeeds
  • New database migration creates discovered_properties and agent_property_authorizations tables

🤖 Generated with Claude Code

bokelley and others added 3 commits December 24, 2025 06:22
Implement validation endpoints that accept the Product schema's publisher_properties format, allowing clients to validate agent authorization against product inventory selectors (all/by_id/by_tag). Includes endpoint to expand selectors to concrete identifiers for real-time caching.

Changes:
- Database layer: validateAgentForProduct() validates against product selectors with per-selector breakdown
- Database layer: expandPublisherPropertiesToIdentifiers() expands selectors to flat identifier list for caching
- Service layer: expose validation methods with clear use cases
- HTTP endpoints: POST /api/registry/validate/product-authorization and /api/registry/expand/product-identifiers
- Agent list response: return property_summary (counts, not full list) for sales agents only
- Migration: new discovered_properties and agent_property_authorizations tables

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

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Fix N+1 query in tag validation: Replace per-tag queries with single
  query using unnest() to find covered tags
- Add AgentType type guard: New isValidAgentType() function for safe
  runtime validation of agent_type values
- Change default agent type: Use 'unknown' instead of 'sales' for
  discovered agents with missing/invalid type
- Fix NULL handling in UNIQUE constraint: Use partial unique index
  for property_id to properly handle NULLs
- Improve agent lookup in registry.html: Replace fragile url.includes()
  fallback with structured matching strategies
- Use type guard consistently in http.ts for FederatedAgent conversion

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

Co-Authored-By: Claude Opus 4.5 <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.

1 participant