Skip to main content

Implementation Plan: Data Management

Feature ID: data-management Spec: ./spec.md Status: Done (Retrospective) Last updated: 2026-05-01


1. Architecture

2. Tech Choices

ConcernChoiceRationale
AggregationPer-work iterator over relations + repoKeeps memory bounded
Secret redactionredactSecretsFromSettings(plugin, value)Single helper enforces Principle VII
Masked detectionPrefix MASKED: is reservedSimple, unambiguous
Conflict resolutionStateless: client supplies resolutions[]Idempotent retries
Path safetypath.basename(slug) on every IOCheap defence-in-depth
Sync transportGitFacadeService against user's repoPrinciple II

3. Data Model

No core schema changes. The transient export envelope is the only new structure; nothing persisted.

The settings store schemas already include x-secret; the redactor consults the JSON schema, not a hardcoded list.

4. API Surface

MethodEndpointDescription
POST/api/account/exportDownload JSON
POST/api/account/import/previewValidate + summarise
POST/api/account/import/applyApply with conflict resolutions
GET/api/account/sync/statusRead sync configuration
POST/api/account/sync/configureSet up the GitHub repo
POST/api/account/sync/pushPush to GitHub
POST/api/account/sync/pullPull (returns preview)
POST/api/account/sync/apply-pullApply pulled preview
DELETE/api/account/syncDisconnect sync

5. Plugin / Web / CLI

  • Plugins: GitHub plugin handles the repo IO (add/remove/list/get-content).
  • Web: Settings → Data with three panels (Export, Import, GitHub Sync).
  • CLI: not exposed.

6. Background Jobs

None — all sync operations are user-initiated.

7. Security & Permissions

  • All endpoints require JWT.
  • Pull always ignores secret values regardless of file contents.
  • Path traversal blocked via path.basename.

8. Observability

  • Import returns ImportResult with worksCreated, worksUpdated, worksSkipped, userPluginsImported, warnings[], errors[].
  • Activity log entries: account_exported, account_imported, sync_pushed, sync_pulled.

9. Risks & Mitigations

RiskMitigation
Real secret leaks via exportRedactor enforced for every secret-flagged field
Masked secrets imported as real valuesMASKED: detection skips them with warning
Path traversal in sync repopath.basename(slug) on read and write
Slug collision corrupts existing dataConflict-resolution flow forces explicit choice

10. Constitution Reconciliation

See spec.md §9. Principle VII is the dominant constraint here; every transport boundary enforces it.

11. References

  • Spec: ./spec.md
  • Implementation: apps/api/src/account/ (export, import, sync services)