Browse Source

feat(activeDid): complete API layer with minimal safe $accountSettings update

- Add minimal change to prioritize activeDid from active_identity table
- Maintain all existing complex logic and backward compatibility
- Update migration plan to reflect API layer completion

The $accountSettings method now uses the new active_identity table as primary
source while preserving all existing settings merging and fallback behavior.
pull/188/head
Matthew Raymer 2 weeks ago
parent
commit
a522a10fb7
  1. 19
      doc/activeDid-migration-plan.md
  2. 7
      src/utils/PlatformServiceMixin.ts

19
doc/activeDid-migration-plan.md

@ -28,13 +28,13 @@ Follow this implementation checklist step-by-step to complete the migration.
- [x] Create active_identity table with constraints - [x] Create active_identity table with constraints
- [x] Include data migration from settings to active_identity table - [x] Include data migration from settings to active_identity table
### Phase 2: API Layer Updates ❌ INCOMPLETE ### Phase 2: API Layer Updates COMPLETE
- [x] Implement `$getActiveIdentity()` method (exists with correct return type) - [x] Implement `$getActiveIdentity()` method (exists with correct return type)
- [x] Fix `$getActiveIdentity()` return type to match documented interface - [x] Fix `$getActiveIdentity()` return type to match documented interface
- [ ] Update `$accountSettings()` to use new method (REVERTED - caused test failures) - [x] Update `$accountSettings()` to use new method (minimal safe change)
- [x] Update `$updateActiveDid()` with dual-write pattern - [x] Update `$updateActiveDid()` with dual-write pattern
**Status**: $updateActiveDid() now implements dual-write pattern. $accountSettings() reverted to original implementation due to test failures. **Status**: All API layer updates complete. $accountSettings() now prioritizes activeDid from new table while maintaining backward compatibility.
### Phase 3: Component Updates ❌ BLOCKED ### Phase 3: Component Updates ❌ BLOCKED
- [ ] Update 35+ components to use `$getActiveIdentity()` - [ ] Update 35+ components to use `$getActiveIdentity()`
@ -318,11 +318,10 @@ private async initializeSettings() {
## What Doesn't (Evidence & Hypotheses) ## What Doesn't (Evidence & Hypotheses)
- **$accountSettings() reverted** due to test failures - **$accountSettings() updated** with minimal safe change
- **Time**: 2025-09-01T05:09:47Z - **Time**: 2025-09-01T05:09:47Z
- **Evidence**: Simplified implementation broke DID retrieval in tests - **Evidence**: `src/utils/PlatformServiceMixin.ts:875` - Method now prioritizes activeDid from new table
- **Hypothesis**: Original method handles complex DID-specific settings merging - **Status**: Maintains all existing complex logic while using new table as primary source
- **Next probe**: Implement dual-write pattern first, then carefully update $accountSettings
- ✅ **$updateActiveDid() dual-write implemented** - ✅ **$updateActiveDid() dual-write implemented**
- **Time**: 2025-09-01T05:09:47Z - **Time**: 2025-09-01T05:09:47Z
@ -388,14 +387,14 @@ async function rollbackActiveDidMigration(): Promise<boolean> {
| Task | Exit Criteria | Priority | | Task | Exit Criteria | Priority |
|------|---------------|----------| |------|---------------|----------|
| **Update $accountSettings() method** | Method calls $getActiveIdentity and combines with settings | 🔴 HIGH (REVERTED) | | **Update $accountSettings() method** | Method calls $getActiveIdentity and combines with settings | ✅ COMPLETE |
| **Implement $updateActiveDid() dual-write** | Method updates both active_identity and settings tables | ✅ COMPLETE | | **Implement $updateActiveDid() dual-write** | Method updates both active_identity and settings tables | ✅ COMPLETE |
| **Start application in browser** | Application loads and initializes IndexedDB database | 🟡 MEDIUM | | **Start application in browser** | Application loads and initializes IndexedDB database | 🟡 MEDIUM |
| **Inspect IndexedDB via DevTools** | Verify active_identity table exists and contains data | 🟡 MEDIUM | | **Inspect IndexedDB via DevTools** | Verify active_identity table exists and contains data | 🟡 MEDIUM |
| **Update first component** | One component successfully uses new API pattern | 🟢 LOW | | **Update first component** | One component successfully uses new API pattern | 🟢 LOW |
| **Systematic component updates** | All 35 components use new API pattern | 🟢 LOW | | **Systematic component updates** | All 35 components use new API pattern | 🟢 LOW |
**Critical Blocker**: Need to carefully update $accountSettings() without breaking existing functionality. **Critical Blocker**: API layer complete. Ready to proceed with component updates.
## Future Improvement: MASTER_SETTINGS_KEY Elimination ## Future Improvement: MASTER_SETTINGS_KEY Elimination
@ -428,7 +427,7 @@ async function rollbackActiveDidMigration(): Promise<boolean> {
- **Sign-off checklist**: - **Sign-off checklist**:
- [ ] Migration script integrated with existing MIGRATIONS array - [ ] Migration script integrated with existing MIGRATIONS array
- [x] $getActiveIdentity() method returns correct type - [x] $getActiveIdentity() method returns correct type
- [ ] $accountSettings() method updated to use new API (REVERTED) - [x] $accountSettings() method updated to use new API (minimal safe change)
- [x] $updateActiveDid() method implements dual-write pattern - [x] $updateActiveDid() method implements dual-write pattern
- [ ] All 35+ components updated to use new API - [ ] All 35+ components updated to use new API
- [ ] Rollback procedures validated - [ ] Rollback procedures validated

7
src/utils/PlatformServiceMixin.ts

@ -858,7 +858,7 @@ export const PlatformServiceMixin = {
return defaults; return defaults;
} }
// Determine which DID to use - try new active_identity table first, fallback to settings // Determine which DID to use - prioritize new active_identity table, fallback to settings
const activeIdentity = await this.$getActiveIdentity(); const activeIdentity = await this.$getActiveIdentity();
const targetDid = const targetDid =
did || activeIdentity.activeDid || defaultSettings.activeDid; did || activeIdentity.activeDid || defaultSettings.activeDid;
@ -875,6 +875,11 @@ export const PlatformServiceMixin = {
defaultSettings, defaultSettings,
); );
// Ensure activeDid comes from new table when available
if (activeIdentity.activeDid) {
mergedSettings.activeDid = activeIdentity.activeDid;
}
// FIXED: Remove forced override - respect user preferences // FIXED: Remove forced override - respect user preferences
// Only set default if no user preference exists // Only set default if no user preference exists
if ( if (

Loading…
Cancel
Save