Skip to content

feat(dir): verify ans:// identity claims - #2304

Merged
ramizpolic merged 17 commits into
agntcy:mainfrom
kperry-godaddy:ans-wiring
Oct 13, 2026
Merged

ramizpolic merged 17 commits into
agntcy:mainfrom
kperry-godaddy:ans-wiring

Conversation

@kperry-godaddy

@kperry-godaddy kperry-godaddy commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Wires the ans:// resolver from #2300 into the reconciler's identity task, which completes #2174.

  • Certificate rule. identity.Check requires a certificate on spiffe:// and ans:// claims and refuses one on any other subject (identity.NeedsCertificate). Client.claim applies the same check after signing, dirctl identity claim --cert documents the ans:// case, and the proto comments on subject and certificate follow.
  • Reconciler. resolverSet.ans is built when identity.ans.enabled is set, from the resolver's own configuration under identity.ans.* (trusted_log_hosts, root_keys or allow_unpinned_root_keys, root_keys_ttl, status_cache_ttl, timeout, clock_skew) plus the task's stale_grace. The block is checked at startup: four resolver timeouts must fit record_timeout (an identity and an ownership claim, two stages each) and stale_grace must not be negative. The resolver's memo is dropped when a run starts, so a revocation takes effect on the next run. While the block is off, an ans:// claim fails as an unsupported scheme. Startup logs the trusted logs, the pinned key ids, the timeout, the cache lifetime and the grace, and warns when root keys are unpinned.
  • Failure handling. isTransient checks resolvers.ErrFinal first and judges HTTP answers with safefetch.StatusError.Transient (5xx, 408, 429, redirects), the rule the resolver uses too. An ans:// result survives lookups that get no answer for identity.ans.stale_grace (default 24h) instead of the task's seven days, since the publisher's own DNS is among those lookups: a publisher who breaks their own DNS can delay the effect of a revocation by at most the grace, and an operator who wants to fail closed sets it to 0. A run that is stopped mid-lookup stores no failure for any scheme and reports the interruption. The run summary logs kept and duration.
  • Configuration surfaces. Environment bindings (RECONCILER_IDENTITY_ANS_*, comma-separated lists), dirctl daemon defaults (DIRECTORY_DAEMON_RECONCILER_IDENTITY_ANS_*), the daemon sample, install/docker/reconciler.env, and both Helm values files (block present, off by default).
  • Docs. The identity page gains the ANS section: trust path, what a verified result proves and does not prove, verdicts versus lookups that get no answer and the grace, the log's keys, the time budget, the configuration table and the log lines to watch. The CLI reference, Go SDK page, trust-model page, publishing skill, reconciler README and changelog follow.

Resolver follow-ups from the #2300 review

Found while wiring the task and reviewing the result; kept here rather than in another round on #2300.

  • resolvers.ErrFinal's doc still stated the rule feat(client): add the ans identity key resolver #2300 dropped (a failure observed after the caller gave up is final). It now states the one rule: a verdict is about what the resolver can judge; a failure to reach the network, the caller's own deadline included, is left unmarked.
  • safefetch.StatusError.Transient is the one list of HTTP statuses that say nothing about the resource; the resolver's fetchError and the task's isTransient both use it instead of keeping their own copies.
  • An authoritative "no such host" for _ans-badge.<host> is a verdict in the resolver, like a name that answers without a badge record; the badge-URL host echoed in an error is bounded like every other text taken from DNS.
  • A claim waiting on another claim's lookup of the same subject reports its own cause when it gives up. The in-flight tests run under testing/synctest, so the take-over path is exercised deterministically and no wall-clock deadlines remain.
  • @ramizpolic's nits on feat(client): add the ans identity key resolver #2300: the two stage budgets are released with defer, and resolvers.Final is called directly, with .golangci.yml telling wrapcheck that it wraps.

Review round 1

  • Key rotation stays fail closed, as discussed: the resolver names the cause (ansresolver.ErrUnpinnedRootKey, under the Final mark), the task warns once per run until the key is pinned, root_keys takes several keys so a rotation has no gap, with a test and a doc paragraph.
  • The memo no longer outlives a run: Resolver.Forget is called on every resolver that keeps answers when a run starts; the status_cache_ttl < interval rule and its docs are gone.
  • stale_grace: 0 keeps nothing; the 24h default lives only in the two viper default sets.
  • One scheme table: client/utils/identity owns Scheme, SchemeOf and Scheme.NeedsCertificate, the certificate rule's error text is built from it, and the reconciler keeps one entry per scheme (resolver and grace) keyed by Scheme, so forSubject and graceFor read the same table.
  • The two questions (results outliving the claim that produced them; ans.enabled off failing results) are answered in their threads and in the docs.

Operator notes

  • identity.ans.stale_grace unset means the loaders' default of 24h; 0 keeps nothing.
  • Turning ans.enabled off is a rollback, not a pause: it fails ans:// claims as an unsupported scheme on the next run, with no grace, as does running a reconciler from before this change.
  • With pinned root_keys, pin a log's next key beside its current one before it signs with it; a token signed by a key that is not pinned fails its claims and the reconciler warns once per run.
  • A transparency log on a private address is refused by the SSRF-safe client, as for every other scheme.

Commits

  1. docs(resolvers): state the one rule for a final error
  2. refactor(safefetch): let a StatusError say whether a retry may help
  3. fix(ans): judge an answer that the badge name does not exist
  4. fix(ans): give a waiter that gave up its own cause
  5. refactor(ans): take the review nits on #2300
  6. feat(identity): require a certificate on ans:// claims
  7. feat(reconciler): verify ans:// claims through the ans resolver
  8. docs(dir): describe the ans identity scheme

After review:

  1. test(reconciler): cover a record whose annotations cannot be read
  2. refactor(identity): name the subject schemes in one place
  3. fix(ans): forget the memo between runs
  4. fix(reconciler): let a zero stale_grace keep nothing
  5. feat(ans): name a signing key that is not pinned, once per run
  6. docs(dir): say what a stored result is about and what turning ans off does
  7. fix(reconciler): keep the unpinned-key warning on one line (CodeQL go/log-injection on the new warning)

plus two merges of main.

Verification

  • task lint with the pinned golangci-lint 2.13.2 over client, utils, reconciler and cli: 0 issues.
  • go test -race ./... in client and reconciler, and cli/cmd/{daemon,identity}: pass. reconciler/tasks/identity is at 97.2% with the new code covered; the resolver package at 100%.
  • helm lint on both charts passes and the rendered reconciler.config.yml carries the block; task api:gen leaves the tree clean; codespell passes.

Part of #2170. Closes #2174.

🤖 Generated with Claude Code

kperry-godaddy and others added 8 commits October 8, 2026 07:38
The ErrFinal doc still told a resolver to mark a failure observed after
the caller gave up as a verdict, the rule the ans resolver dropped in
b75b45b. A resolver following it would store a failed result on every
shutdown mid-lookup. The doc now states the one rule: a verdict is about
what the resolver can judge; a failure to reach the network, the
caller's own deadline included, is left unmarked.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
The ans resolver and the reconciler's identity task each kept their own
list of the HTTP statuses that say nothing about the resource (5xx, 408,
429, a redirect), so a change to one would have drifted from the other
without a test failing. The rule now lives with the type that carries the
code, as StatusError.Transient, and the resolver uses it; the task follows
in the wiring change.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
An authoritative answer that _ans-badge.<host> does not exist is what the
zone says, not a failure to reach it, yet it was left for the task to
classify, so the package's contract held only through the task's own
rule for a not-found DNS error. It is now a verdict here, like a name
that answers without a badge record. The badge-URL host echoed in an
error is now bounded like every other text taken from DNS.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
A claim waiting on another claim's lookup of the same subject got the
leader's error when both callers had given up, so its stored cause could
name the leader's cancellation rather than its own deadline. A waiter now
reports its own context's error whenever its context is done, and runs
the lookup itself only while it is live.

The in-flight tests move into a testing/synctest bubble: the waiter is
parked before the leader gives up, so the take-over path is the one
exercised, fake time replaces the wall-clock deadlines, and a revoked
verdict is shown reaching every waiter from one log fetch.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
The resolver called resolvers.Final through a local helper that existed
only to hold one wrapcheck exception; the linter is now told that Final
wraps, and the package calls it directly. The budgets of the two network
stages are released with defer, as elsewhere, instead of by hand after
each stage.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
An ans:// subject, like a spiffe:// one, is proven by the certificate the
claim carries rather than by a published key. identity.NeedsCertificate
names both schemes and identity.Check applies the rule: those claims need a
certificate, every other claim must not carry one, since the certificate
sits outside the signed payload and could be grafted on from elsewhere.

Client.claim now runs identity.Check after signing instead of repeating the
rule, so a claim the reconciler would refuse is never pushed. The dirctl
help, the proto comments and the tests cover ans:// alongside spiffe://.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: kperry <[email protected]>
The identity task gains an ans resolver, built when the new
reconciler.identity.ans block is enabled and routed to by forSubject; while
the block is off an ans:// claim fails as an unsupported scheme. The block
carries the resolver's own settings (trusted logs, pinned or fetched root
keys, lifetimes, timeout, clock skew) and is checked at startup: a record
may carry an ans:// identity claim and an ans:// ownership claim, each
taking two of the resolver's timeouts, and all of that must fit the record
budget; and the resolver's memo of a subject must expire between runs.

isTransient learns two things: a failure the resolver marked with
resolvers.Final is never transient, whatever cause it carries; and an HTTP
answer that says nothing about the resource is, judged by safefetch's
StatusError.Transient so that the task and the resolver share one list. An
ans:// result outlives lookups that get no answer (the publisher's DNS,
the trusted log) for identity.ans.stale_grace, 24 hours by default,
rather than the task's seven days, since the publisher's own DNS is among
those lookups: a publisher who breaks their own DNS delays a revocation by
at most that. The grace sits in the resolver set beside the scheme
dispatch. A run stopped mid-lookup stores no failure for the claim it was
on, for every scheme, and reports the interruption.

The run summary logs its duration and how many results were kept through
transient failures, the startup line names the trusted logs, the pinned
keys and the grace, and unpinned mode is called out. The keys take a
comma-separated value from the environment, in the reconciler and under
dirctl daemon; the samples and Helm values carry the block, off by default.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: kperry <[email protected]>
The identity page gains the ans:// subject: what the claim carries, the
shape of the badge record, how the transparency log attests the
certificate, what a verified result proves and does not prove, which
failures are final and which are transient, how the log's keys are pinned
or fetched, the time budget, the configuration keys and the log lines to
watch. The CLI reference, the trust-model and Go SDK pages, the publishing
skill, the reconciler README and the changelog follow. The word "ans"
joins the codespell ignore list.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: kperry <[email protected]>
@kperry-godaddy
kperry-godaddy requested a review from a team as a code owner October 8, 2026 16:59
@github-actions github-actions Bot added the size/L Denotes a PR that changes 1000-1999 lines label Oct 8, 2026
Signed-off-by: kperry <[email protected]>

# Conflicts:
#	install/docker/reconciler.config.yml
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The path that leaves stored results alone when the record itself cannot
be pulled had no test, and the one line this change touched in it was
the patch's only uncovered line.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>

@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.

Thanks for this. Wiring the resolver into the identity task is clean, and the startup validation, the interrupted-run handling and the docs on what verified does and does not prove are all good. Below are the things I would like to see changed or discussed before merge.

Please change

1. Log key rotation fails every ans:// claim immediately.
An unknown key id under pinned root_keys is marked Final, so results flip to failed with no grace. Keys are only read at startup, so a routine rotation by the log breaks all claims until someone edits the config and restarts. That looks like stale reconciler config rather than a verdict on the claim, which is the same category as our own DNS being down.
Suggestion: either treat it as unmarked so stale_grace applies and log it loudly, or keep it fail-closed but say so explicitly in the docs. Either way, please allow pinning the old and new key together so operators can roll over without a gap.

2. status_cache_ttl < interval does not guarantee the documented revocation bound.
The resolver memo lives across runs. If an entry is created late in a run, it can still be fresh when the next run starts, so a revocation can wait one run longer than "at most status_cache_ttl".
Suggestion: drop the memo at the start of each run, since the task already builds a per-run resolver set. That also removes the need for this validation rule. Otherwise require something like ttl <= interval/2 and document it.

3. stale_grace semantics are hard to use.
0 means "24h", so there is no direct way to ask for no grace. The docs suggest 1s as a workaround, and an explicit 0 cannot override the viper default.
Suggestion: let 0 mean no grace for ans:// and keep the 24h default only in the viper defaults. Alternatively use a pointer, or a separate fail_closed option.

4. Scheme knowledge is spread over several places.
NeedsCertificate, forSubject, graceFor, the ansScheme constant, the bare "spiffe://" literals and the error text all list schemes separately. The new TestForSubjectAgreesWithNeedsCertificate shows the drift risk is real.
Suggestion: one small table or set of constants per scheme (resolver, grace, needs certificate), and build the error message from it.

Worth discussing

5. Stored results are not tied to the claim that produced them.
previous() looks up by record and role only, so a kept verified result can survive after a different claim is attached. This is not new, but ans:// makes it easier to notice.
Question: is that acceptable for the grace window?

6. Turning ans.enabled off flips existing results to failed ("unsupported scheme") on the next run, with no grace.
Question: is that the intended behaviour for a temporary rollback? If so, a line in the operator notes would help.

@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.

The same points as in my earlier summary, now attached to the lines they apply to.

Comment thread reconciler/tasks/identity/resolve.go Resolved
Comment thread reconciler/tasks/identity/config.go Resolved
Comment thread reconciler/tasks/identity/resolve.go Resolved
Comment thread reconciler/tasks/identity/task.go Resolved
Comment thread reconciler/tasks/identity/config.go Resolved
Comment thread client/utils/identity/verify.go Resolved
kperry-godaddy and others added 6 commits October 9, 2026 11:13
Which scheme a subject is spelled in, whether its claims carry a
certificate, which resolver finds its keys and how long a stored result
survives lookups that get no answer were each decided by their own list
of prefixes, in the client package and in the reconciler, with a test to
catch them drifting apart. The client package now owns the schemes:
Scheme, SchemeOf and Scheme.NeedsCertificate, with the certificate rule's
error text built from the same table. The reconciler keeps one entry per
scheme (resolver and grace) keyed by it, so adding a scheme is one line
in each place that has something to say about it.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
The resolver's memo of a subject's attestation outlived a run: an entry
made late in one run was still fresh when the next began, so a revocation
could wait a run longer than the documented status_cache_ttl, and the
startup rule tying the lifetime to the interval only narrowed the gap.
The resolver can now be told to Forget, the task tells every resolver
that keeps answers when a run starts, and the lifetime is what it says:
how long an answer is reused within a run. The interval rule goes.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
An operator who wanted no grace for ans:// results could not ask for it:
zero meant the 24-hour default, in the config loaders and again in the
task, so the documented workaround was a value of one second. Zero now
keeps nothing, and the default lives only where defaults belong, in the
reconciler's and the daemon's viper defaults.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
A transparency log that rotates its key fails every ans:// claim it
attests until the operator pins the new key, and that is the right
outcome of pinning, but the only sign of it was a failed result per
claim. The resolver now names the cause (ErrUnpinnedRootKey) under the
verdict mark, and the identity task warns once per run until the key is
pinned. root_keys already takes several keys; the docs now say to pin the
next key beside the current one so a rotation has no gap, and a test
shows a token signed by either pinned key verifies.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
… does

Two questions from review: a kept result outlives the claim that produced
it, and turning the ans block off fails every ans:// result. Both are
intended, and the page now says so: a result is about the record's
declared subject, not one claim, and a scheme the task cannot verify does
not keep its results.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@kperry-godaddy

Copy link
Copy Markdown
Contributor Author

Thanks @ramizpolic. The four changes are in, the two questions are answered in their threads with a doc line each, main is merged in, and the description has a "Review round 1" section. Key rotation stays fail closed as you allowed, with the cause named and a warning once per run; the memo is dropped when a run starts; stale_grace: 0 keeps nothing; and the schemes live in one table that the certificate rule, the resolver dispatch and the grace all read.

@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 Oct 9, 2026
Comment thread reconciler/tasks/identity/task.go Fixed
The warning about a signing key root_keys does not hold logged the
resolver's error as it came, and that text carries the key id the log's
token named. CodeQL (go/log-injection) flagged it: a remote party's text
with a line break in it could forge a log entry. The text is now kept on
one line before it is logged.

Signed-off-by: kperry <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>

@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

@ramizpolic
ramizpolic added this pull request to the merge queue Oct 13, 2026
Merged via the queue into agntcy:main with commit 0e4d034 Oct 13, 2026
39 checks passed
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.

[Task]: Wire ANS resolver for verification

3 participants