Skip to content

fix(hcs-25): resolve ans trust discovery agents by uid - #185

Merged
kantorcodes merged 1 commit into
hashgraph-online:mainfrom
chou-godaddy:fix/hcs-25-ans-trust-discovery-collector
Oct 19, 2026
Merged

kantorcodes merged 1 commit into
hashgraph-online:mainfrom
chou-godaddy:fix/hcs-25-ans-trust-discovery-collector

Conversation

@chou-godaddy

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

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #184. The ans-trust-discovery collector looked agents up by the UAID nativeId, but ANS Trust Index providers key GET /v1/ans/registered-agents/{id} by the ANS agent id, which HCS-14 (ans-dns-web profile) carries as the UAID uid parameter. Every lookup returned 404, so no ANS agent received signals.

  • Agent id: resolved from metadata.uid, then the uid parameter of metadata.uaidFull, then of subject.id. nativeId is no longer used, and UAID parameters are parsed without a regular expression.
  • Registries: the collector and the scoring adapter apply to ans and godaddy-ans by default. ans is the HCS-14 registry value; godaddy-ans is the Registry Broker namespace for the same agents.
  • 404: clears the stored scores, so an agent the provider no longer knows stops being scored.
  • Refresh interval: collection is skipped while stored signals are fresh (ttlMs, 24 hours after a success; failureTtlMs, 1 hour after a failure), and force overrides this. This keeps batch refreshes within provider rate limits.
  • Retries: network errors and HTTP 5xx are retried twice (maxRetries). HTTP 429 is not retried.

Testing

  • pnpm exec jest --config jest.config.json --testPathPattern __tests__/hcs-25 --coverage=false (203 passed on Node 22 and 24, including 14 new tests)
  • pnpm run typecheck
  • pnpm run lint
  • pnpm run build
  • Ran the collector and scoring adapter through collectAndScoreTrustScore against a live ANS Trust Index provider, using subjects shaped like Registry Broker records: a UAID without parameters, metadata.uid, and registry godaddy-ans. Each component and adapter total matched values computed independently from the provider responses. An unknown id returned 404 and cleared the stored scores, and a second run within the refresh interval made no request.

Notes

  • Transient failures keep the earlier scores with a timeout or error status, as the ethos collector does; the 1-hour failure interval then triggers a retry.
  • readUaidParam mirrors the parameter handling of parseHcs14Did so that hcs-25 keeps no imports from hcs-14. Happy to switch to parseHcs14Did if preferred.
  • typecheck, lint and full-suite results are unchanged from main.
  • The HCS-14 ans-dns-web resolver (src/hcs-14/resolvers/ans-dns-web-profile.ts) currently compares uid with the Agent Card ansName, and its fixtures use ans:// names, while the profile defines uid as the ANS agent ID (UUID). This PR follows the profile, which matches Registry Broker data; the provider endpoint rejects an ans:// name with 400. Happy to help align the resolver in a separate change.

The ans-trust-discovery collector looked agents up by the UAID nativeId,
but ANS Trust Index providers key the registered-agent endpoint by the
ANS agent id, which HCS-14 carries as the UAID uid parameter. Every
lookup returned 404, so no ANS agent received signals.

- Resolve the agent id from metadata.uid, then the uid parameter of
  metadata.uaidFull or the subject id. nativeId is no longer used, and
  parameters are parsed without a regular expression.
- Apply the collector and the scoring adapter to the ans and godaddy-ans
  registries by default: ans is the HCS-14 registry value and godaddy-ans
  is the Registry Broker namespace for the same agents.
- Clear stored scores when the provider returns 404 for the agent.
- Skip collection while stored signals are fresh (24 hours after a
  success, 1 hour after a failure) unless forced, so batch refreshes stay
  within provider rate limits.
- Retry network errors and HTTP 5xx twice. HTTP 429 is not retried.
- Correct the collector test that asserted the nativeId URL, and cover id
  resolution, 404 clearing, retries, rate limiting, caching and registry
  applicability.

Refs: hashgraph-online#184
Signed-off-by: chou-godaddy <chou@godaddy.com>
@kilo-code-bot

kilo-code-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • src/hcs-25/collectors/ans-trust-discovery.ts - 0 issues
  • src/hcs-25/adapters/ans-trust-discovery.ts - 0 issues
  • __tests__/hcs-25/hcs-25-collectors.test.ts - 0 issues
  • __tests__/hcs-25/hcs-25-adapters-ans-trust-discovery.test.ts - 0 issues

Reviewed by free · Input: 524.5K · Output: 44.9K · Cached: 776.2K

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

Checks green, review threads resolved, quiet window elapsed at 49106e0.

@internet-dot internet-dot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checks green, review threads resolved, quiet window elapsed at 49106e0.

@kantorcodes
kantorcodes merged commit 04f97c8 into hashgraph-online:main Oct 19, 2026
6 checks passed
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.

3 participants