Skip to content

feat(dir): add ownership claim referrer, search, and CLI (v1)#1478

Open
vivekkrishna wants to merge 1 commit into
agntcy:mainfrom
vivekkrishna:feat/ownership-v1
Open

feat(dir): add ownership claim referrer, search, and CLI (v1)#1478
vivekkrishna wants to merge 1 commit into
agntcy:mainfrom
vivekkrishna:feat/ownership-v1

Conversation

@vivekkrishna
Copy link
Copy Markdown
Contributor

Summary

  • Introduces single-source-of-truth record ownership via OCI referrers (agntcy.dir.ownership.v1.Claim)
  • Adds owners DB table as a derived search index synced from OCI referrers
  • Enforces caller SPIFFE ID == owner_id when authentication is enabled
  • Exposes dirctl ownership claim command and --owner search filter

Changes

Proto / API

  • proto/agntcy/dir/ownership/v1/claim.proto: new Claim message (owner_id, claimed_at)
  • api/ownership/v1/claim.go: MarshalReferrer / UnmarshalReferrer + ReferrerType()
  • api/core/v1/referrer_types.go: OwnershipClaimReferrerType = "agntcy.dir.ownership.v1.Claim"
  • proto/agntcy/dir/core/v1/rules.proto: CEL whitelist extended with ownership type
  • proto/agntcy/dir/search/v1/record_query.proto: RECORD_QUERY_TYPE_OWNER = 17

Server

  • server/store/oci/types.go: OwnershipClaimArtifactMediaType + OCI type mapping
  • server/database/gorm/record.go: Owner model, AddOwner, RemoveOwners, ownership JOIN filter
  • server/database/gorm/gorm.go: Owner table migration
  • server/types/database.go: OwnershipDatabaseAPI interface
  • server/types/search.go: Owners []string field + WithOwners() filter option
  • server/database/utils/utils.go: RECORD_QUERY_TYPE_OWNERWithOwners()
  • server/controller/store.go: ownership claim enforcement + immediate DB indexing on push

Reconciler

  • reconciler/tasks/ownership/: new task that walks OCI referrers and syncs owners table
  • reconciler/config/config.go: Ownership config field + env var bindings
  • reconciler/service/service.go: ownership task registration

CLI

  • cli/cmd/ownership/ownership.go: dirctl ownership claim --record <CID> --owner <id>
  • cli/cmd/root.go: ownership command registered
  • cli/cmd/search/filters.go: --owner flag + RECORD_QUERY_TYPE_OWNER query
  • cli/cmd/daemon/config.go: ownership reconciler defaults (enabled=true, interval=5m)

Tests

  • tests/e2e/local/13_ownership_search_test.go: 7 e2e tests (all passing) covering exact match, wildcards, combined filters, and negative cases

Test plan

  • All unit tests pass (go test ./... in server, reconciler, api, cli modules)
  • Lint clean (task lint)
  • 7 ownership e2e tests pass locally with running daemon
  • Full e2e suite in CI (requires Docker for DNS validation container)

🤖 Generated with Claude Code

@vivekkrishna vivekkrishna requested a review from a team as a code owner May 9, 2026 12:27
@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label May 9, 2026
Introduces a single-source-of-truth ownership model using OCI referrers:

- api: add OwnershipClaim proto + MarshalReferrer/UnmarshalReferrer
- api/core: add OwnershipClaimReferrerType constant and CEL whitelist entry
- server/store/oci: add OwnershipClaimArtifactMediaType mapping
- server/database: add owners table (Owner model, AddOwner, RemoveOwners, WithOwners filter)
- server/controller: enforce caller SPIFFE ID == owner_id; index claim on push
- reconciler: add ownership task to walk referrers and sync owners table
- cli: add dirctl ownership claim command and --owner search filter
- cli/daemon: register ownership reconciler defaults
- tests/e2e: add ownership-based search test suite (7 cases, all passing)

Signed-off-by: Vivek Krishna Choppa <vivekkrishnachoppa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant