Skip to content

Conversation

@Bigshmow
Copy link
Contributor

@Bigshmow Bigshmow commented Jan 27, 2026

Explanation

Adds AiDigestController to the @metamask/ai-controllers package for fetching and caching AI-generated asset digests.

What it does:

  • AiDigestService - Fetches digest data from GET /digests/assets/:assetId/latest
  • AiDigestController - Manages state, caching (10 min TTL, 50 entry max), and FIFO eviction
  • Follows existing controller patterns (BaseController, messenger actions, etc.)

Design decisions:

  • DigestData type mirrors the API response structure from va-mmcx-digest-api - we'll iterate inline as the API evolves
  • baseUrl is required (no default) - consuming apps must provide their API endpoint
  • Eviction handles stale entries, error/loading states, and invalid entries from corrupted persistence

This is a V1 implementation - the API response shape may evolve as the backend is finalized.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Adds new persisted controller state and a network-backed fetch flow; correctness of TTL/FIFO eviction and API error handling affects UI behavior and storage growth, but does not touch auth or funds.

Overview
Adds a new AiDigestController that fetches asset digests via an injected DigestService, persists them in controller state, and exposes messenger actions for fetchDigest, clearDigest, and clearAllDigests.

Implements caching with a 10-minute TTL (CACHE_DURATION_MS) and a 50-entry max (MAX_CACHE_ENTRIES) with stale + FIFO eviction, and introduces AiDigestService to call GET /digests/assets/:assetId/latest with explicit error handling.

Updates @metamask/ai-controllers exports, tests (replaces the placeholder greeter test), adds base-controller/messenger deps and TS project references, and notes the addition in the changelog.

Written by Cursor Bugbot for commit 6a24fd3. This will update automatically on new commits. Configure here.

@Bigshmow Bigshmow force-pushed the feat/adds-ai-digest-controller branch from a3d2868 to fce4710 Compare January 27, 2026 22:54
@Bigshmow
Copy link
Contributor Author

Bigshmow commented Jan 28, 2026

re this PR's failing lint job: Is this dedupe issue a known issue? resolved

@Bigshmow Bigshmow marked this pull request as ready for review January 28, 2026 03:06
@Bigshmow Bigshmow requested review from a team as code owners January 28, 2026 03:06
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

@Bigshmow Bigshmow enabled auto-merge January 30, 2026 15:43
@Bigshmow Bigshmow added this pull request to the merge queue Jan 30, 2026
Merged via the queue into main with commit 0588017 Jan 30, 2026
306 checks passed
@Bigshmow Bigshmow deleted the feat/adds-ai-digest-controller branch January 30, 2026 15:54
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