Skip to content

feat(008): Profile Isolation and Scale — multi-tenant profiles#43

Open
AlexU-A wants to merge 11 commits intomainfrom
feat/008-profile-isolation
Open

feat(008): Profile Isolation and Scale — multi-tenant profiles#43
AlexU-A wants to merge 11 commits intomainfrom
feat/008-profile-isolation

Conversation

@AlexU-A
Copy link
Copy Markdown
Contributor

@AlexU-A AlexU-A commented Mar 21, 2026

Summary

  • Complete multi-tenant profile isolation system (Spec 008, all 8 WPs)
  • Drizzle ORM schema: 7 tables, 4 enums in profiles pgSchema with tenant-scoped queries
  • Profile generation pipeline: subprocess bridge to Spec 005 Python engine, corpus snapshots, advisory locks for concurrent tenant isolation
  • Immutable profile versioning: monotonic integers, atomic rollback, retention policy (90-day archive, 30-day hard-delete)
  • Three-tier composite inheritance (org > dept > individual): nearest-ancestor-wins merge for 129-feature vectors with per-feature override tracking
  • Self-service corpus intake: PDF/DOCX/text parsers with shared normalization, SHA-256 content-hash dedup (tenant-scoped)
  • Database-backed resolved profile cache with inheritance-aware invalidation and cache warming
  • 13 MCP tools (profile_* prefix) with executor routing and module entry point
  • Server wiring: profiles module mounted alongside existing content module
  • Cross-tenant isolation: 16 test cases verifying zero data leakage
  • Edge cases: tenant deletion, zero-doc corpus, single-author, no-author all handled
  • 7 integration test suites (45 scenarios, skip gracefully without DB)

Stats

  • ~14,000 lines across 50+ files
  • 263 unit tests passing, 50 integration tests (DB-dependent, skipped in CI without PostgreSQL)
  • TypeScript typecheck: clean

Test plan

  • npm run typecheck — zero errors
  • npx vitest run tests/profiles/ — 263 passed, 50 skipped (no DB), 0 failed
  • Cross-tenant isolation: 16/16 tests pass
  • Edge cases: 14/14 tests pass
  • Integration tests: require PostgreSQL with profiles schema applied
  • Performance validation: 50-doc generation <10min, rollback <30s, cached lookup <50ms p95

🤖 Generated with Claude Code

AlexU-A and others added 11 commits March 21, 2026 09:33
Drizzle ORM schema for profiles pgSchema (7 tables, 4 enums),
shared types/constants, Zod validation schemas (no tenantId in inputs
per Leash pattern), tenant-scoped query helpers with 10 unit tests.
DB client extended to export profiles schema.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… execution

Engine bridge (subprocess to Spec 005 Python engine), corpus snapshot
service, generation pipeline orchestrator with advisory locks for
tenant-isolated concurrency, structured operation logging, in-memory
metrics. 43 tests passing, typecheck clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pluggable parser interface + registry, PDF/DOCX/text parsers with
shared normalization pipeline, SHA-256 content-hash deduplication
(tenant-scoped per FR-007), intake orchestrator with per-document
status tracking and partial failure recovery. pdf-parse + mammoth deps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Immutable version management with monotonic integers, atomic rollback
in single transaction, paginated version history, retention policy
(90-day archive, 30-day hard-delete, active versions protected),
feature vector comparison with delta/percent-change. 42 new tests,
95 total passing, typecheck clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Hierarchy management with circular reference detection and depth limit,
nearest-ancestor-wins inheritance resolver, 129-feature vector merging
with per-feature override tracking, override source tracing/reporting,
cascade propagation for ancestor changes. 45 new tests, typecheck clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…alidation

Database-backed cache for inheritance-merged profiles, transparent
getOrResolve with hit/miss metrics, upsert semantics, inheritance-aware
invalidation via hierarchy tree walk, cache warming for large tenants
(threshold: 20+ profiles). 33 new tests, typecheck clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tion + edge case tests

13 profile_ MCP tools (list, get, generate, rollback, history, intake,
hierarchy, cache), profile-executor routing, ProfilesModule entry point
with dependency-ordered service init, server wiring (tools/index,
executor, main index). 16 cross-tenant isolation tests (zero leakage),
14 edge case tests (tenant deletion, zero-doc, single-author, no-author).
30 new tests, typecheck clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…cale

7 integration test suites (45 scenarios) covering tenant isolation,
version lifecycle, batch ingestion, drift-retraining, cache behavior,
session binding, and audit completeness. Tests skip gracefully when
DATABASE_URL is not set; will run against real PostgreSQL when available.

Feature 008 (Profile Isolation and Scale) is COMPLETE.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants