Skip to content

feat(dir): add AGNTCY identity claims and badge verification - #2292

Merged
muscariello merged 5 commits into
mainfrom
codex/agntcy-identity-claims
Nov 10, 2026
Merged

muscariello merged 5 commits into
mainfrom
codex/agntcy-identity-claims

Conversation

@sriaradhyula

@sriaradhyula sriaradhyula commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds opt-in agntcy:// identity verification through an external AGNTCY Identity Verifier. Directory authenticates the signed HTTP/JWS result, enforces the configured badge policy and exact claim/request bindings, then verifies the native claim signature locally. Native claims remain OCI referrers; badges remain in Identity Node.

Rebased onto main at 9fd9150eaeaa900e1f176d06076989ba89f9cb2b, including the ANS resolver registry and transactional policy invalidation. Closes #2291. The separate gRPC provider design in #2329 remains outside this PR.

Review fixes

  • Normalize persisted deadlines and SQL comparison times to UTC. Regression tests cover UTC, UTC+1, UTC−5 and UTC+9, UTC and local-offset input deadlines, verified search/counts, and ownership filters.
  • Reject a configured verifier at startup unless the reconciliation interval is positive and below the maximum verification age. The default one-hour interval must be explicitly shortened when using the default 30-minute maximum age.
  • Move claim input and validity output into shared resolver options (WithClaim, WithValidUntil). Register AGNTCY in the scheme map, with bounded grace and no subject-only evidence cache.
  • Remove the key-only AGNTCY /v1/resolve path, parallel ResolveClaim interface and deadline cache. Complete claims are required even in control-only mode; badge checks remain required by default.
  • Mark authenticated rejections as final verdicts. Trust/token reload errors fail the run before stored results change. Tests cover reload failures, local signature rejection, candidate-specific evidence and expiry-bounded outage grace.
  • Preserve main's policy invalidation. Compare both stored and effective claim status so an expired verified claim written as failed supersedes the old positive policy verdict. Regression tests cover both failure and renewal after expiry, including the enforcing read gate.
  • Clarify that immediate expiry applies to identity status and verified search. Stored policy verdicts are invalidated by a successful reconciliation write; the interval is not a strict freshness bound when reconciliation or writes fail.
  • Add a breaking-change note for external implementations of the variadic Resolver.Resolve interface.
  • Replace the Python live harness with an opt-in Go/Ginkgo suite using existing test dependencies, disposable real services, failure cleanup and a JSON report.

Local validation

Passed with Directory's Go 1.27.2 toolchain:

go -C client test -race ./utils/identity/... ./utils/jws
go -C api test -race ./identity/v1
go -C reconciler test -race ./tasks/identity
go -C server test -race ./database/... ./controller/... ./store/oci/...
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go -C cli build -o /tmp/pr2292-dirctl .

Repository-configured golangci-lint 2.14.0 reports zero issues for the full client, reconciler and server modules and the new Go/Ginkgo suite, without changed-line filtering. MkDocs build, changed-page Markdown/spelling checks and git diff --check pass.

I tested protocol and integration behavior with the live Go/Ginkgo tests/e2e/agntcy suite: 7/7 specs passed against real Keycloak, PostgreSQL, Identity Node, verifier, Directory daemon and OCI registry. This covers enrollment, native claim storage and exact manifest binding, verified search, same-agent/different-CID badge rejection, unrelated signer rejection, expired badges, outage expiry and recovery. Cleanup removed all fixture containers and the network. Reproduction instructions describe the required binaries, opt-in environment variables and Ginkgo JSON report.

The new policy regression failed before the fix and passes afterward. Database/controller race suites and the normal go -C server test ./policy/... suite pass. Expanding race coverage to ./policy/... exposes a pre-existing race in the unchanged test helper mapSource.Pull (server/policy/evaluation_test.go:28), where parallel TestRegistryPolicies_DecidesOnIndexedAt subtests append to a shared slice. The isolated test reproduces it; that broader race run is not passing.

Experimental dependencies

The agntcy.identity-verification.v2 protocol and service remain unreleased drafts. The integration stays off unless a verifier URL is configured. The nullable valid_until database column is added even when the verifier is disabled; existing unbounded rows retain their behavior. Documentation explicitly identifies these boundaries and scheduling requirements.

Companion verifier: identity#182, commit 53ec1e34049ddb34e8caed9762b4ab0ae5516838. Node controller fix: identity#181, commit 037e25d3a96e47033872d7ebeb75a9944721b337.

The badge policy proves agent control and exact record consistency using Node's subject-key-backed badge verification. Independent issuer accreditation and external credential status-list revocation require additional policies/adapters.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

The latest Buf updates on your PR. Results from workflow Buf CI / verify-proto (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped⏩ skipped✅ passedNov 10, 2026, 5:04 PM

@github-actions github-actions Bot added size/L Denotes a PR that changes 1000-1999 lines and removed size/XL Denotes a PR that changes 2000+ lines labels Oct 7, 2026
@ramizpolic
ramizpolic marked this pull request as ready for review November 9, 2026 17:02
@ramizpolic
ramizpolic requested a review from a team as a code owner November 9, 2026 17:02

@ramizpolic ramizpolic left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sriaradhyula LGTM overall, nice work!

For next steps, I think we need to decide to either:

  • rebase and patch the PR based on the nits above and merge
  • bring in #2329 into this PR and implement AGNTCY as the first provider
    • with code managed within DIR repo as a go package
    • with code managed somewhere else as either a go package or a gRPC server implementing the required interface

Let me know your thoughts, happy to help here!

@muscariello muscariello left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I read the resolver, the reconciler wiring and the database changes, and ran the PR's unit tests at this head: client identity, reconciler identity, server database and controller all pass. I didn't run the live E2E, the race runs or lint.

The result binding looks solid. Version, kind, profile, policy, verifier ID, subject, CID and the request digest (which carries the nonce) are all checked, the result is verified against the pinned key, redirects are off, and the claim signature is checked again locally.

Two bugs (inline):

  1. Expiry in verified search depends on the host's timezone. A result that expired hours ago can still be returned as verified. The fix is three .UTC() calls.
  2. The defaults make every verification expire before the next run.

Structural:
3. The key-only Resolve path is used only by tests, and it skips the badge check.
4. This no longer fits main. #2304 (ANS) reworked the resolver set, and a trial merge conflicts in reconciler/tasks/identity/config.go, resolve.go, task.go, server/database/gorm/identity_claims.go and docs/content/dir/dir-component-identity.md. Details on task.go:372.
5. The verifier (agntcy/identity#182) and the Node fix (agntcy/identity#181) are both open drafts, last updated Oct 7, and the protocol is a draft v2. Nothing changes unless a verifier URL is set, so the risk is small. But this adds a DB column, config and docs for a service that has no release yet. It's worth deciding whether to merge ahead of it, and at least marking the docs experimental.

Small: CI Lint fails on two findings in reconciler/tasks/identity/task.go: wsl_v5 at line 118 and nlreturn at line 312.

On @ramizpolic's question, I'd rebase and patch rather than bring #2329 in. #2329 is a new gRPC API with no agreed design yet, and adding it would make an already large PR larger. This protocol is HTTP and JWS, so it can be wrapped once #2329 exists.

Comment thread server/database/gorm/identity_claims.go Resolved
Comment thread server/database/gorm/record.go Resolved
Comment thread server/database/gorm/identity_claims.go Resolved
Comment thread reconciler/tasks/identity/task.go Resolved
@sriaradhyula
sriaradhyula force-pushed the codex/agntcy-identity-claims branch from 1b8517f to 8c83ae2 Compare November 10, 2026 04:43
@sriaradhyula

Copy link
Copy Markdown
Member Author

Rebased and patched without expanding scope into #2329. The docs explicitly mark the integration experimental and identify both unreleased Identity prerequisites and the database migration. Merge timing remains a maintainer decision. The lint findings are fixed.

I tested protocol bindings and rejection cases with unit/TLS fixtures, then ran race tests across identity resolvers, reconciliation, database, controller and OCI storage. I also ran the live E2E with real services, covering valid claims, CID mismatches, wrong signers, expired badges, verifier outages and recovery. All passed, along with full-module lint and the documentation build.

@ramizpolic @muscariello — I’ve replied to the inline comments with the fixes. Can I resolve the addressed review threads?

@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Comment thread tests/e2e/agntcy/run.py Resolved
ramizpolic
ramizpolic previously approved these changes Nov 10, 2026

@ramizpolic ramizpolic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@muscariello muscariello left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I checked each fix in the code at this head, not only the replies. All six of my threads are addressed, so feel free to resolve them:

  • the three .UTC() changes are in, and the database tests pass under UTC, Rome and New York;
  • startup refuses an interval at or above max_verification_age, and that's tested;
  • Resolve without a claim fails as Final, and the badge requirement is enforced;
  • the resolver now sits in main's scheme set, with claim-aware entries skipping the cache, and a failed reload returns an error from Run;
  • the docs are marked experimental and name identity#181, identity#182 and the migration.

Client identity, reconciler identity, and the server database tests all pass locally.

One new bug came in with the rebase, inline on policy_invalidation.go:76. Once a claim passes its deadline and is then written as failed, the read gate keeps the verdict it reached while the claim was verified. I reproduced it, and the fix is one line.

Two smaller points, also inline: the docs' outage guarantee doesn't hold for the read gate, and the Resolve signature change breaks outside implementers of a public interface.

Comment on lines 76 to 77
return before.GetStatus() != after.GetStatus() ||
before.Subject != after.Subject

@muscariello muscariello Nov 10, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this compares GetStatus(), a verified row that is past its deadline already reads as failed. When the reconciler then writes the claim as failed, this sees failed against failed and returns false. The verdict isn't superseded, so the read gate keeps the answer it reached while the claim was verified.

That's the verifier-outage path: the previous result is kept through grace until the deadline, and then the failed result is written.

To reproduce, in package gorm next to the existing invalidation tests:

until := time.Now().Add(time.Second)
verified := identityClaim(types.ClaimStatusVerified, "agntcy://Agent")
verified.ValidUntil = &until
require.NoError(t, db.UpsertIdentityClaim(verified))
seedVerdict(t, db)

time.Sleep(1500 * time.Millisecond)

require.NoError(t, db.UpsertIdentityClaim(identityClaim(types.ClaimStatusFailed, "agntcy://Agent")))
assertSuperseded(t, db) // fails: the verdict is still "evaluated"

Comparing both values fixes it, and keeps the case where an expired row is re-verified:

Suggested change
return before.GetStatus() != after.GetStatus() ||
before.Subject != after.Subject
return before.Status != after.Status ||
before.GetStatus() != after.GetStatus() ||
before.Subject != after.Subject

With that change the reproduction passes, and the existing invalidation and identity tests still pass.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — comparing only the effective status misses the stored verified → failed transition after expiry. I’ll compare both stored and effective status as suggested, add the expired-then-failed regression test, retain the renewal-after-expiry test, and check that the old policy verdict is superseded.


An outage may preserve the previous observation only until its deadline and the
AGNTCY scheme grace (the configured maximum verification age). Expired results are reported as failed by
status reads and excluded by verified search immediately, even between runs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This holds for status and verified search, but not for the policy read gate. A verdict is only superseded when something writes, and policy_invalidation.go already says a clock-dependent fact "cannot be kept correct by invalidation". After a deadline passes, the gate can keep the previous verdict for up to one reconciliation interval, until the next write. That assumes the fix on policy_invalidation.go:76.

Please either say so here, or supersede the verdicts when a result's deadline passes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll clarify that status and verified search honor expiry immediately, while stored policy verdicts are invalidated by the next successful reconciliation write. I won’t promise a strict one-interval bound when reconciliation is interrupted or cannot write. Immediate deadline enforcement in the policy gate would need a separate design change.

// claim's DER-encoded X.509 certificate, empty when the claim has none;
// only SPIFFE and ANS resolution read it.
Resolve(ctx context.Context, subject string, certificate []byte) ([]crypto.PublicKey, error)
Resolve(ctx context.Context, subject string, certificate []byte, opts ...Option) ([]crypto.PublicKey, error)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding opts here changes a public interface in the client module. Callers are unaffected, but any implementation of resolvers.Resolver outside this repo stops compiling. It's worth a line in the changelog.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I’ll add a breaking-change note under Unreleased, explaining that external Resolver implementations must add opts ...resolvers.Option to Resolve; implementations that do not use the options can ignore them. Existing call sites remain compatible.

@muscariello muscariello left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes to hold the merge on the verdict-invalidation bug in server/database/gorm/policy_invalidation.go:76, see the inline comment in my previous review. After a claim's deadline passes and it is written as failed, the stored verdict is not superseded, so the read gate keeps serving what it decided while the claim verified. That fails open in the gate. The suggestion there is the fix, and the reproduction test there should go in with it.

The other two points from that review, the docs line and the changelog note, don't block. I'll approve once the fix and its test are in.

Compare stored and effective claim status, and cover expired verified evidence being replaced with failure. Clarify policy freshness limits and document the resolver interface change.

Signed-off-by: Sri Aradhyula <[email protected]>
Replace the Python harness with an opt-in Ginkgo suite using disposable real services. Preserve enrollment, native OCI binding, verification rejection and outage recovery coverage, with cleanup and JSON reporting.

Signed-off-by: Sri Aradhyula <[email protected]>
@github-actions github-actions Bot added size/XL Denotes a PR that changes 2000+ lines and removed size/L Denotes a PR that changes 1000-1999 lines labels Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR exceeds the recommended size of 2000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note that this PR might take longer to review due to large size.

@sriaradhyula

sriaradhyula commented Nov 10, 2026 •

Copy link
Copy Markdown
Member Author

@muscariello @ramizpolic could you take another look when you have a chance? I’ve pushed the follow-up fixes: stored/effective status comparison with the expired-to-failed policy-gate regression test, clarified the policy expiry guarantees, and added the Resolver interface breaking-change note. I also ported the live harness to Go/Ginkgo; all 7 live scenarios passed. The PR description has the test details and notes the unrelated pre-existing policy test-helper race. Thanks!

@muscariello muscariello left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. I checked the follow-up commits in the code:

  • identityClaimFactsChanged compares both the stored and the effective status. TestPolicyGate_ExpiredClaimWrittenAsFailedSupersedes fails with the fix reverted and passes with it, and it checks that the gate no longer admits the record.
  • The docs now state the policy-verdict limit accurately, and the changelog has the breaking Resolve entry.
  • The Ginkgo suite replaces the Python harness with no new dependencies. It skips unless AGNTCY_E2E=1 is set, and CI doesn't run it.

Thanks for working through all of this. I've confirmed the mapSource.Pull race you reported on main, and it's being fixed separately.

@muscariello
muscariello added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 9ad8144 Nov 10, 2026
38 checks passed
@muscariello
muscariello deleted the codex/agntcy-identity-claims branch November 10, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Proposal]: Add AGNTCY Identity support to Directory IdentityClaims

3 participants