feat: add multi-user attribution and team sync schema (v28)#468
Open
BYK wants to merge 2 commits into
Open
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
knowledgetable:created_by,updated_by— user attributionsensitivity— auto-promotion product hint (normal/sensitive/restricted)promotion_status,promoted_at— personal → team promotion flowapproval_status,approved_by,approved_at— team admin approval workflowsource_user_id,source_entry_id— team DB origin trackinglast_accessed_at— access tracking2 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.
Type & CRUD updates (
packages/core/src/ltm.ts)KnowledgeEntrytype: 11 new fieldsSensitivity,PromotionStatus,ApprovalStatusKNOWLEDGE_COLS/KNOWLEDGE_COLS_K: 11 new columnscreate(): accepts optionalcreatedByandsensitivityparamsupdate(): accepts optionalupdatedByparamTests
db.test.ts: schema version assertion → 28ltm.test.ts: 7 new tests covering default values,createdBy/sensitivityon create,updatedByon update, andteam_knowledge/team_configtable existenceWhat is NOT changed (scope boundaries)
forSession()team merging — Phase 2forSession()personal preference boost — Phase 2last_accessed_atwrites — deferred (hot path)agents-file.ts—.lore.mdformat unchangedcurator.ts/distillation.ts— callers use defaultsVerification
Closes phase 0 of #467.