Files

3.9 KiB

Persistence and database strategy

Extensions must follow a layered persistence model.

11.1 Default rule

Do not introduce a custom extension-owned database unless host storage and thread/document APIs are insufficient.

11.2 Storage hierarchy

A. Ephemeral UI state

Use in-memory UI state only.

Examples:

  • active tab
  • filter toggles
  • selection state

B. Small extension-owned persistent data

Use the host localstorage_* commands: native storage or the browser localstorage adapter. Local keys retain device-local semantics; sync: true keys use authenticated dashboard settings. Neither is canonical dashboard project storage.

Commands:

  • localstorage_put
  • localstorage_get
  • localstorage_delete
  • localstorage_list

Rules:

  • local storage is isolated by host account/profile and extension ID; optional sync: true settings additionally use authenticated dashboard user, workspace, group, and extension scope
  • local and synced keys are independent; see private localstorage API for cache and online write rules
  • use this for small configuration and lightweight persistent state

The separate browser storage_* commands use the draft storage adapter. This adapter keeps bounded JSON values in host-owned account-scoped local storage, with a 4 MiB extension limit and explicit storage-denial/quota errors. It works independently of the chat worker lock. Reload preserves values; an account-local browser reset removes only that account's preferences, conversation database and extension drafts. It preserves other accounts and server project files. Extension frames do not receive direct access to the host's storage, session or credentials. Check the advertised storage commands before use.

C. Host-owned conversational/workspace state

Use thread commands when the data belongs to chat or workspace interaction state.

D. Dashboard-backed extension project state

Use the host filesystem bridge for canonical extension-owned data that must be shared through a dashboard. Follow Dashboard-backed extension project sync; device-local extension storage must not become a fallback source of truth for shared projects.

Browser dashboard file writes use online confirmation. A file's syncable metadata does not create a browser offline queue or turn device-local drafts into accepted shared data. Native offline/RIBLT behavior is a separate host capability. Browser upload/delete/atomic-write adapters remain subject to gateway enablement and the outstanding live storage/authorization tests described in the cloud write plan.

E. Searchable document memory

Use extension_upsert_document_snapshot() for retrieval-oriented text snapshots.

F. Custom native database

Only use a custom native DB when the extension has complex domain persistence requirements that cannot be reasonably expressed through host storage layers.

11.3 Custom database requirements

If an extension uses its own database, its documentation must define:

  • why host persistence is insufficient
  • engine choice
  • file location
  • schema versioning strategy
  • migration strategy
  • reset behavior
  • uninstall behavior
  • backup/export expectations
  • scope rules for user, workspace, and entity ownership

Extension documentation must explicitly address schema drift and stale datastore risks.

Legacy unscoped native values remain in the offline profile namespace. They are not assigned to an arbitrary dashboard account; authenticated local values are isolated by dashboard origin and account. Changing sync never migrates values between namespaces.