Skip to content

Cache contract metadata with explicit invalidation #1212

Description

@mikewheeleer

Summary

Repeated metadata reads add latency, but stale metadata can mislabel events or authorize the wrong contract behavior.

Why this matters

This closes a correctness, security, or operability gap in the TalentTrust backend and makes the behavior explicit under retries, chain inconsistency, authorization, and failure.

Requirements

  • Repository scope: Talenttrust/Talenttrust-Backend only.
  • Use a bounded cache with network and contract keys; invalidate on deployment/config changes; expose age and refresh failures.
  • Preserve tenant isolation, structured errors, auditability, and existing API compatibility unless this issue explicitly requires a contract change.
  • Add focused unit and integration coverage for the new behavior.

Technical guidance

  • Follow the repository's existing service, queue, persistence, logging, authentication, and error-envelope conventions.
  • Keep side effects bounded and make retries, ordering, authorization, and failure handling explicit.
  • Document non-obvious operational and security decisions in the PR.

Edge cases — each must have a test

  • cache miss
  • fresh hit
  • expired entry
  • same address on two networks
  • metadata fetch fails

Acceptance criteria

  • Every requirement and edge case above is implemented and tested
  • Unit and integration tests cover success, failure, retry, authorization, and boundary paths
  • Existing tests pass with no regressions
  • Errors and logs are structured and do not leak secrets or internal stack details
  • npm run lint, npm test, and npm run build passes locally
  • Code follows existing conventions with no duplication or dead code
  • Documentation or concise comments explain non-obvious decisions
  • PR description explains the approach, includes test evidence and security notes, and references Closes #

Out of scope

  • unbounded permanent caching

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveStellar Wave Program task

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions