Initial TrueGrowth source import
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
## Context
|
||||
Backup/restore currently has fixed domains and incremental-only import. New features use `localStorage`, `aitu-storage`, `aitu-app`, `localforage` databases, and Cache Storage, so domain ownership must be explicit and restore must support clearing selected domains before import.
|
||||
|
||||
## Goals / Non-Goals
|
||||
- Goals: complete environment backup, replace restore, encrypted secrets, full task persistence, full prompt metadata, and backward compatibility with v2/v3 ZIP files.
|
||||
- Non-Goals: backing up crash logs, analytics buffers, transient preview caches, Service Worker failed-domain state, or arbitrary browser origin storage.
|
||||
|
||||
## Decisions
|
||||
- Use backup v4 for complete backups and keep v2/v3 import support.
|
||||
- Introduce an environment domain with a strict whitelist instead of dumping every browser storage key.
|
||||
- Store normal environment data in `environment/data.json`; store sensitive settings in `environment/secrets.enc.json` only when the user provides a password.
|
||||
- Implement replace restore by clearing selected durable domains before importing them, then reloading the workspace.
|
||||
- Persist imported tasks with the task storage writer instead of only restoring in-memory task queue state.
|
||||
|
||||
## Risks / Trade-offs
|
||||
- Risk: Cross-device restoration of existing encrypted settings cannot rely on the original device key.
|
||||
- Mitigation: decrypt current settings at export time and re-encrypt the secrets payload with the user-provided backup password.
|
||||
- Risk: Large task/media histories can increase memory pressure.
|
||||
- Mitigation: read/write task and environment records in batches and avoid including transient caches.
|
||||
- Risk: Old backups lack v4 environment files.
|
||||
- Mitigation: keep existing v2/v3 import behavior and treat missing v4 domains as skipped.
|
||||
|
||||
## Migration Plan
|
||||
1. Add v4 types, validation helpers, and environment data service.
|
||||
2. Update export to write v4 manifest fields and optional environment files.
|
||||
3. Update import to accept `ImportOptions` and support merge/replace.
|
||||
4. Update UI defaults and result reporting.
|
||||
5. Add focused unit coverage for manifest compatibility, prompt metadata, encrypted secrets, and task persistence.
|
||||
@@ -0,0 +1,19 @@
|
||||
# Change: Add complete environment backup and restore
|
||||
|
||||
## Why
|
||||
Recent features store durable user data outside the original backup domains, so restoring a backup can lose tasks, PPT preferences, chats, playlists, skills, model preferences, and selected environment settings.
|
||||
|
||||
## What Changes
|
||||
- Add a v4 backup format with complete backup/replace restore semantics while preserving existing incremental import.
|
||||
- Add an environment backup domain for whitelisted localStorage, KV storage, IndexedDB store snapshots, and optional password-encrypted secrets.
|
||||
- Make task backup independent from asset backup and persist restored tasks to IndexedDB.
|
||||
- Expand prompt backup to all prompt types, deleted prompt records, and prompt history overrides.
|
||||
- Add UI controls for complete backup, environment data, optional encrypted secrets, and merge vs replace restore.
|
||||
|
||||
## Impact
|
||||
- Affected specs: backup-restore
|
||||
- Affected code:
|
||||
- `packages/drawnix/src/services/backup-restore/*`
|
||||
- `packages/drawnix/src/components/backup-restore/*`
|
||||
- storage services for tasks, workspace, prompts, chats, playlists, settings, and environment data
|
||||
- `apps/web/public/sw-debug/shared/*` for shared constants/types compatibility
|
||||
@@ -0,0 +1,48 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Complete Environment Backup
|
||||
The system SHALL support a complete backup mode that captures all durable user-facing environment data needed to restore the app to the backed-up state.
|
||||
|
||||
#### Scenario: Complete backup includes durable domains
|
||||
- **GIVEN** the user has projects, assets, tasks, workflows, prompts, knowledge base content, chats, playlists, skills, model preferences, and UI preferences
|
||||
- **WHEN** the user creates a complete backup
|
||||
- **THEN** the backup SHALL include every selected durable domain
|
||||
- **AND** the manifest SHALL record v4 schema metadata, selected domains, per-domain stats, and backup mode
|
||||
|
||||
### Requirement: Replace Restore
|
||||
The system SHALL support replace restore for complete backups by clearing selected local domains before importing backup data.
|
||||
|
||||
#### Scenario: Replace restore mirrors the backup
|
||||
- **GIVEN** the current browser has existing local data
|
||||
- **AND** the user selects replace restore for a complete backup
|
||||
- **WHEN** restore completes
|
||||
- **THEN** selected domains SHALL match the backup content instead of being merged with previous local content
|
||||
- **AND** the workspace SHALL reload and restore the backed-up current board when available
|
||||
|
||||
### Requirement: Encrypted Secrets
|
||||
The system SHALL export sensitive configuration only when the user explicitly includes secrets and provides a backup password.
|
||||
|
||||
#### Scenario: Secrets require password
|
||||
- **GIVEN** settings contain API keys, provider profiles, or sync credentials
|
||||
- **WHEN** the user creates a backup without enabling secrets
|
||||
- **THEN** sensitive values SHALL NOT be written to normal backup JSON
|
||||
- **WHEN** the user enables secrets and provides a password
|
||||
- **THEN** sensitive values SHALL be written only to an encrypted secrets payload
|
||||
|
||||
### Requirement: Full Task and Prompt Fidelity
|
||||
The system SHALL include full terminal and archived generation history required by prompt history, media library, PPT, audio, and task queue views.
|
||||
|
||||
#### Scenario: Task and prompt data survives restore
|
||||
- **GIVEN** completed or archived image, video, audio, PPT, text, and agent tasks exist
|
||||
- **WHEN** the user backs up and restores data
|
||||
- **THEN** restored task records SHALL be persisted to IndexedDB
|
||||
- **AND** prompt preset settings SHALL include all supported prompt types, deleted prompt contents, and prompt overrides
|
||||
|
||||
### Requirement: Backward Compatibility
|
||||
The system SHALL continue importing existing v2 and v3 backups.
|
||||
|
||||
#### Scenario: Legacy backups import incrementally
|
||||
- **GIVEN** a valid v2 or v3 backup without environment files
|
||||
- **WHEN** the user imports it
|
||||
- **THEN** existing prompt, project, asset, task, and knowledge base import behavior SHALL continue to work
|
||||
- **AND** missing v4 environment data SHALL be reported as skipped, not as a fatal error
|
||||
@@ -0,0 +1,21 @@
|
||||
## 1. Specification
|
||||
- [x] 1.1 Add OpenSpec proposal, design, tasks, and backup-restore delta.
|
||||
- [x] 1.2 Validate the OpenSpec change in strict mode.
|
||||
|
||||
## 2. Backup Format and Environment Domain
|
||||
- [x] 2.1 Upgrade backup types and manifest to v4-compatible fields.
|
||||
- [x] 2.2 Add environment export/import helpers with storage whitelists.
|
||||
- [x] 2.3 Add password-based encrypted secrets export/import.
|
||||
|
||||
## 3. Data Completeness Fixes
|
||||
- [x] 3.1 Export and import tasks independently from assets and persist restored tasks.
|
||||
- [x] 3.2 Include all prompt types, deleted prompt contents, and prompt overrides.
|
||||
- [x] 3.3 Support replace restore clearing for projects, assets, prompts, tasks, knowledge base, and environment domains.
|
||||
|
||||
## 4. UI
|
||||
- [x] 4.1 Add complete/incremental backup controls and environment/secrets options.
|
||||
- [x] 4.2 Add merge/replace restore controls, password input, warnings, and per-domain result output.
|
||||
|
||||
## 5. Verification
|
||||
- [x] 5.1 Add unit tests for prompt metadata and environment encryption behavior.
|
||||
- [x] 5.2 Run targeted tests and OpenSpec validation.
|
||||
Reference in New Issue
Block a user