Skip to content

feat: add multi-user attribution and team sync schema (v28)#468

Open
BYK wants to merge 2 commits into
mainfrom
feat/team-sync-schema
Open

feat: add multi-user attribution and team sync schema (v28)#468
BYK wants to merge 2 commits into
mainfrom
feat/team-sync-schema

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 24, 2026

Summary

Adds migration v28 with columns for multi-user attribution, promotion workflow, approval workflow, and team sync scaffolding. This is Phase 0 of the multi-DB sync architecture (see #467 for full RFC).

Changes

Migration v28 (packages/core/src/db.ts)

11 new columns on knowledge table:

  • created_by, updated_by — user attribution
  • sensitivity — auto-promotion product hint (normal/sensitive/restricted)
  • promotion_status, promoted_at — personal → team promotion flow
  • approval_status, approved_by, approved_at — team admin approval workflow
  • source_user_id, source_entry_id — team DB origin tracking
  • last_accessed_at — access tracking

2 new tables:

  • team_knowledge — local read-only cache for approved team entries (empty scaffolding)
  • team_config — team credentials and sync state (empty scaffolding)

All columns nullable/defaulted for backward compat. Zero impact on local-only users.

Security note: These columns are sync metadata and product UX hints, NOT access control. Isolation is enforced at the DB level (database-per-user/team via Turso). See #467.

Type & CRUD updates (packages/core/src/ltm.ts)

  • KnowledgeEntry type: 11 new fields
  • Named types: Sensitivity, PromotionStatus, ApprovalStatus
  • KNOWLEDGE_COLS / KNOWLEDGE_COLS_K: 11 new columns
  • create(): accepts optional createdBy and sensitivity params
  • update(): accepts optional updatedBy param
  • Synthetic lat.md entry: all 11 new fields with defaults

Tests

  • db.test.ts: schema version assertion → 28
  • ltm.test.ts: 7 new tests covering default values, createdBy/sensitivity on create, updatedBy on update, and team_knowledge/team_config table existence

What is NOT changed (scope boundaries)

  • forSession() team merging — Phase 2
  • forSession() personal preference boost — Phase 2
  • last_accessed_at writes — deferred (hot path)
  • agents-file.ts.lore.md format unchanged
  • curator.ts / distillation.ts — callers use defaults
  • Gateway sync module — Phase 1+
  • CLI team commands — Phase 1+

Verification

  • Typecheck: 4/4 packages clean
  • Tests: 1822/1822 pass, 0 fail, 8287 expect() calls

Closes phase 0 of #467.

BYK added 2 commits May 24, 2026 15:36
Add migration v28 with columns for multi-user attribution, promotion
workflow, approval workflow, and team sync scaffolding on the knowledge
table. Also creates team_knowledge and team_config tables for future
team DB integration.

New knowledge columns:
- created_by, updated_by (user attribution)
- sensitivity (auto-promotion product hint)
- promotion_status, promoted_at (personal -> team flow)
- approval_status, approved_by, approved_at (team approval workflow)
- source_user_id, source_entry_id (team DB origin tracking)
- last_accessed_at (access tracking)

All columns nullable/defaulted for backward compat with local-only
users. These columns are sync metadata and product UX hints, not
access control — isolation is enforced at the DB level
(database-per-user/team via Turso).

Updates ltm.ts: KnowledgeEntry type, KNOWLEDGE_COLS, create() accepts
createdBy/sensitivity, update() accepts updatedBy.

Includes 7 new tests for v28 column defaults and CRUD behavior.
- Remove stale SCHEMA_VERSION = 16 dead code constant (C1)
- Fix v27 → v28 in KnowledgeEntry comment and test describe block (C2/C3)
- Add team_knowledge and team_config to recoverMissingObjects() for
  partial migration recovery (C4)
- Use named types (Sensitivity, PromotionStatus, ApprovalStatus) in
  KnowledgeEntry type for compile-time validation (M3)
- Add sensitivity param to update() so entries can be reclassified
  after creation, with test coverage (M5)
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.

1 participant