Skip to content

Introduce Credential Activity History Store - #481

Merged
ketzusaka merged 1 commit into
mainfrom
credential-activity-history
Sep 4, 2026
Merged

Introduce Credential Activity History Store#481
ketzusaka merged 1 commit into
mainfrom
credential-activity-history

Conversation

@ketzusaka

@ketzusaka ketzusaka commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Introduces a sharable on-device store for Android and iOS to retain credential activity. We're re-using some components from the Wallet storage here, while maintaining a separate database for the local activity as it is a separate concern and should never be backed up with the existing systems.

I've modeled the changes after how I typically use rust; mod.rs is mainly imports with most of the code in dedicated files, and tests in their related files.

This system is expected to evolve over time so i've prioritized a sensible migration strategy as part of these changes.

Tested integration on iOS. Will do Android later and follow up with any PRs that might be necessary for their integration. No runtime differences until the host apps are updated to use the new system.


Note

Medium Risk
Touches encrypted cache schema/migration and new persisted user-activity data; incorrect migration or reset behavior could drop or leak history, but changes are well-tested and isolated from the credential vault.

Overview
Adds persistent credential activity history in the encrypted cache database so host apps can record proof-share outcomes (protocol, RP, client id, issuer schemas, terminal outcome, and optional failure reason).

CredentialStore gains record_activity, paginated list_activities, activity_metadata, and clear_activities, plus a UniFFI ActivityChangedListener (background thread, same pattern as vault changes) fired only on successful record/clear. New ActivityEntry / outcome types are exported for bindings.

Cache schema now creates an activity_entries table (indexed by created_at) via ensure_activity_schema, applied on every open—including after a disposable cache_entries wipe on schema version mismatch—so activity history is intended to outlive TTL cache resets while session seeds and similar rows are cleared.

Inserts enforce failure_reason only when outcome is Failed. ActivityQuery is a stub for future filtering. Small walletkit-sqlite addition: Transaction::query_row_optional.

Reviewed by Cursor Bugbot for commit 055b38d. Bugbot is set up for automated code reviews on this repo. Configure here.

@ketzusaka
ketzusaka force-pushed the credential-activity-history branch from a003298 to c53e3ff Compare August 25, 2026 21:46
@ketzusaka
ketzusaka marked this pull request as ready for review August 25, 2026 22:25
Comment thread crates/walletkit-core/src/storage/activity/activity_store.rs Outdated
Comment thread crates/walletkit-core/src/storage/credential_activity/schema.rs Outdated
Comment thread crates/walletkit-core/src/storage/credential_activity/activity_store.rs Outdated
Comment thread crates/walletkit-core/src/storage/credential_activity/schema.rs Outdated
Comment thread crates/walletkit-core/src/storage/credential_activity/schema.rs Outdated
Comment thread crates/walletkit-core/src/storage/credential_activity/schema.rs Outdated
Comment thread crates/walletkit-core/src/storage/credential_activity/schema.rs Outdated
Comment thread crates/walletkit-core/src/storage/credential_activity/activity_store.rs Outdated
Comment thread crates/walletkit-core/src/storage/credential_activity/activity_store.rs Outdated
Comment thread crates/walletkit-core/src/storage/credential_activity/activity_store.rs Outdated
Comment thread crates/walletkit-core/src/storage/credential_activity/activity_store.rs Outdated
Comment thread crates/walletkit-core/src/authenticator/with_storage.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
@ketzusaka
ketzusaka force-pushed the credential-activity-history branch from c53e3ff to 57a7ff5 Compare August 31, 2026 19:49
Comment thread crates/walletkit-core/src/storage/activity/maintenance.rs Outdated
Comment thread crates/walletkit-core/src/storage/activity/maintenance.rs Outdated
@ketzusaka
ketzusaka force-pushed the credential-activity-history branch 3 times, most recently from e2490d0 to d44b0b2 Compare September 1, 2026 00:01
Comment thread crates/walletkit-core/src/storage/paths.rs Outdated
Comment thread crates/walletkit-core/src/storage/activity/activity_store.rs Outdated
Comment thread crates/walletkit-core/src/storage/activity/activity_store.rs Outdated
Comment thread crates/walletkit-core/src/storage/activity/activity_store.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/authenticator/with_storage.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
@ketzusaka
ketzusaka force-pushed the credential-activity-history branch from d44b0b2 to 4806cbd Compare September 2, 2026 06:31

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4806cbd. Configure here.

Comment thread crates/walletkit-core/src/storage/cache/schema.rs
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/storage/cache/schema.rs
Comment thread crates/walletkit-core/src/storage/credential_storage.rs
Comment thread crates/walletkit-core/src/storage/cache/activity.rs Outdated
Comment thread crates/walletkit-core/src/storage/cache/activity.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/storage/types.rs Outdated
Comment thread crates/walletkit-core/src/storage/traits.rs Outdated
Comment thread crates/walletkit-core/src/storage/cache/activity.rs Outdated
Comment thread crates/walletkit-core/src/storage/cache/activity.rs Outdated
@ketzusaka
ketzusaka force-pushed the credential-activity-history branch 2 times, most recently from 4d4fc15 to 1514bd0 Compare September 3, 2026 17:00
Introduces a sharable on-device store for Android and iOS to retain credential activity. We're re-using some components from the Wallet storage here, while maintaining a separate database for the local activity as it is a separate concern and should never be backed up with the existing systems.

I've modeled the changes after how I typically use rust; mod.rs is mainly imports with most of the code in dedicated files, and tests in their related files.

This system is expected to evolve over time so i've prioritized a sensible migration strategy as part of these changes.

Tested integration on iOS. Will do Android later and follow up with any PRs that might be necessary for their integration. No runtime differences until the host apps are updated to use the new system.
@ketzusaka
ketzusaka force-pushed the credential-activity-history branch from 1514bd0 to 055b38d Compare September 3, 2026 17:06
fn on_vault_changed(&self);
}

/// Listener notified when credential-activity history changes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Dzejkop let's keep this in the backlog for how to overall improve the listener experience, the risk of deadlocking here or other nasty stuff crossing the boundaries often is high

/// callback is delivered on a dedicated background thread to avoid re-entering
/// the `UniFFI` call stack (see `logger.rs` for rationale).
///
/// This is only called when an activity entry is recorded.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is confusing, can we overall revise the doc comment here? it's hard to parse

.collect())
}

fn map_entry(row: &Row<'_, '_>) -> StorageResult<ActivityEntry> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high impact. not a blocker for this PR, but I strongly suggest that when parsing fails for corrupted entries, you delete the corrupted entry instead of erroring on the whole thing. with the current version, a single corrupted entry makes the history useless.

@ketzusaka
ketzusaka merged commit 555497e into main Sep 4, 2026
22 checks passed
@ketzusaka
ketzusaka deleted the credential-activity-history branch September 4, 2026 03:47
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