mindforge-cc 10.0.3 → 10.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mindforge/config.json +25 -2
- package/.mindforge/engine/cross-model-eval.md +74 -0
- package/.mindforge/engine/proactive/signal-detector.md +60 -0
- package/.mindforge/engine/proactive/suggestion-engine.md +100 -0
- package/.mindforge/personas/agent-architect.md +57 -0
- package/.mindforge/personas/agent-evaluator.md +162 -0
- package/.mindforge/personas/agent-memory-designer.md +157 -0
- package/.mindforge/personas/agent-ops-engineer.md +120 -0
- package/.mindforge/personas/agent-orchestrator.md +112 -0
- package/.mindforge/personas/ai-economist.md +57 -0
- package/.mindforge/personas/ai-safety-engineer.md +57 -0
- package/.mindforge/personas/analytics-engineer.md +57 -0
- package/.mindforge/personas/anti-pattern-hunter.md +61 -0
- package/.mindforge/personas/api-gateway-designer.md +132 -0
- package/.mindforge/personas/auth-engineer.md +112 -0
- package/.mindforge/personas/build-engineer.md +57 -0
- package/.mindforge/personas/business-analyst.md +56 -0
- package/.mindforge/personas/cache-architect.md +100 -0
- package/.mindforge/personas/causal-scientist.md +57 -0
- package/.mindforge/personas/cdn-architect.md +118 -0
- package/.mindforge/personas/change-agent.md +104 -0
- package/.mindforge/personas/code-narrator.md +52 -0
- package/.mindforge/personas/codegen-specialist.md +68 -0
- package/.mindforge/personas/communication-architect.md +102 -0
- package/.mindforge/personas/compliance-engineer.md +96 -0
- package/.mindforge/personas/consensus-engineer.md +116 -0
- package/.mindforge/personas/contract-tester.md +60 -192
- package/.mindforge/personas/data-architect.md +108 -0
- package/.mindforge/personas/data-mesh-architect.md +57 -0
- package/.mindforge/personas/data-pipeline-architect.md +120 -0
- package/.mindforge/personas/de-sloppifier.md +60 -0
- package/.mindforge/personas/debt-manager.md +66 -0
- package/.mindforge/personas/decision-architect.md +82 -51
- package/.mindforge/personas/deployment-captain.md +74 -0
- package/.mindforge/personas/design-system-lead.md +112 -0
- package/.mindforge/personas/dmux-orchestrator.md +75 -0
- package/.mindforge/personas/dx-engineer.md +96 -0
- package/.mindforge/personas/ecommerce-engineer.md +57 -0
- package/.mindforge/personas/edge-engineer.md +94 -0
- package/.mindforge/personas/edtech-architect.md +106 -0
- package/.mindforge/personas/embedding-architect.md +57 -0
- package/.mindforge/personas/environment-engineer.md +57 -0
- package/.mindforge/personas/eval-judge.md +55 -0
- package/.mindforge/personas/event-architect.md +102 -0
- package/.mindforge/personas/experiment-designer.md +138 -0
- package/.mindforge/personas/feature-store-engineer.md +57 -0
- package/.mindforge/personas/finops-analyst.md +66 -0
- package/.mindforge/personas/fintech-architect.md +57 -0
- package/.mindforge/personas/flutter-engineer.md +104 -0
- package/.mindforge/personas/gaming-engineer.md +57 -0
- package/.mindforge/personas/graphql-designer.md +73 -0
- package/.mindforge/personas/healthcare-engineer.md +57 -0
- package/.mindforge/personas/hiring-strategist.md +105 -0
- package/.mindforge/personas/hitl-architect.md +165 -0
- package/.mindforge/personas/i18n-architect.md +69 -0
- package/.mindforge/personas/iot-architect.md +105 -0
- package/.mindforge/personas/knowledge-curator.md +139 -0
- package/.mindforge/personas/knowledge-engineer.md +57 -0
- package/.mindforge/personas/lakehouse-architect.md +57 -0
- package/.mindforge/personas/llm-orchestrator.md +57 -0
- package/.mindforge/personas/logistics-architect.md +106 -0
- package/.mindforge/personas/market-analyst.md +53 -0
- package/.mindforge/personas/marketplace-engineer.md +105 -0
- package/.mindforge/personas/mcp-designer.md +54 -0
- package/.mindforge/personas/meeting-designer.md +104 -0
- package/.mindforge/personas/mentorship-lead.md +106 -0
- package/.mindforge/personas/migration-architect.md +57 -0
- package/.mindforge/personas/ml-ops-engineer.md +101 -0
- package/.mindforge/personas/mobile-architect.md +105 -0
- package/.mindforge/personas/mobile-security-engineer.md +106 -0
- package/.mindforge/personas/multi-tenancy-architect.md +71 -0
- package/.mindforge/personas/multimodal-engineer.md +57 -0
- package/.mindforge/personas/offline-specialist.md +105 -0
- package/.mindforge/personas/onboarding-navigator.md +63 -0
- package/.mindforge/personas/payments-engineer.md +135 -0
- package/.mindforge/personas/pipeline-engineer.md +115 -0
- package/.mindforge/personas/platform-engineer.md +97 -0
- package/.mindforge/personas/platform-lead.md +57 -0
- package/.mindforge/personas/privacy-engineer.md +57 -0
- package/.mindforge/personas/product-owner.md +56 -0
- package/.mindforge/personas/productivity-analyst.md +57 -0
- package/.mindforge/personas/prompt-architect.md +101 -0
- package/.mindforge/personas/proofreader.md +53 -0
- package/.mindforge/personas/pwa-architect.md +105 -0
- package/.mindforge/personas/quality-scorer.md +63 -0
- package/.mindforge/personas/react-native-engineer.md +106 -0
- package/.mindforge/personas/resilience-engineer.md +69 -0
- package/.mindforge/personas/rfc-architect.md +64 -0
- package/.mindforge/personas/saga-orchestrator.md +80 -0
- package/.mindforge/personas/secrets-engineer.md +57 -0
- package/.mindforge/personas/skill-smith.md +79 -0
- package/.mindforge/personas/sre-lead.md +107 -0
- package/.mindforge/personas/stream-engineer.md +57 -0
- package/.mindforge/personas/streaming-engineer.md +64 -0
- package/.mindforge/personas/swarm-templates.json +674 -44
- package/.mindforge/personas/system-designer.md +57 -0
- package/.mindforge/personas/team-coach.md +120 -0
- package/.mindforge/personas/tech-lead-coach.md +103 -0
- package/.mindforge/personas/technical-writer-lead.md +111 -0
- package/.mindforge/personas/vibe-checker.md +75 -0
- package/.mindforge/personas/worktree-manager.md +56 -0
- package/.mindforge/personas/zero-trust-engineer.md +113 -0
- package/.mindforge/skills/a11y-testing/SKILL.md +143 -0
- package/.mindforge/skills/agent-evaluation-framework/SKILL.md +227 -0
- package/.mindforge/skills/agent-memory-design/SKILL.md +199 -0
- package/.mindforge/skills/agent-orchestration-patterns/SKILL.md +129 -0
- package/.mindforge/skills/agent-tool-selection/SKILL.md +204 -0
- package/.mindforge/skills/ai-agent-deployment/SKILL.md +176 -0
- package/.mindforge/skills/ai-cost-management/SKILL.md +57 -0
- package/.mindforge/skills/ai-safety-alignment/SKILL.md +53 -0
- package/.mindforge/skills/analytics-instrumentation/SKILL.md +172 -0
- package/.mindforge/skills/api-gateway-patterns/SKILL.md +177 -0
- package/.mindforge/skills/api-marketplace/SKILL.md +56 -0
- package/.mindforge/skills/api-versioning/SKILL.md +100 -0
- package/.mindforge/skills/app-store-deployment/SKILL.md +44 -0
- package/.mindforge/skills/architecture-tradeoff-analysis/SKILL.md +97 -0
- package/.mindforge/skills/audit-logging/SKILL.md +140 -0
- package/.mindforge/skills/auth-patterns/SKILL.md +148 -0
- package/.mindforge/skills/autonomous-agent-harness/SKILL.md +218 -0
- package/.mindforge/skills/autonomous-agents/SKILL.md +59 -0
- package/.mindforge/skills/build-system-optimization/SKILL.md +54 -0
- package/.mindforge/skills/build-vs-buy/SKILL.md +80 -0
- package/.mindforge/skills/bundle-optimization/SKILL.md +174 -0
- package/.mindforge/skills/business-analyst/SKILL.md +82 -0
- package/.mindforge/skills/caching-strategies/SKILL.md +132 -0
- package/.mindforge/skills/capacity-planning/SKILL.md +96 -0
- package/.mindforge/skills/causal-inference/SKILL.md +42 -0
- package/.mindforge/skills/cdn-optimization/SKILL.md +212 -0
- package/.mindforge/skills/change-management/SKILL.md +106 -0
- package/.mindforge/skills/chaos-engineering/SKILL.md +99 -0
- package/.mindforge/skills/ci-cd-pipeline/SKILL.md +118 -0
- package/.mindforge/skills/cli-design/SKILL.md +118 -0
- package/.mindforge/skills/code-generation-patterns/SKILL.md +92 -0
- package/.mindforge/skills/code-review-methodology/SKILL.md +180 -0
- package/.mindforge/skills/code-tour/SKILL.md +145 -0
- package/.mindforge/skills/codebase-onboarding/SKILL.md +95 -0
- package/.mindforge/skills/compliance-as-code/SKILL.md +195 -0
- package/.mindforge/skills/conflict-resolution/SKILL.md +87 -0
- package/.mindforge/skills/connection-pooling/SKILL.md +151 -0
- package/.mindforge/skills/container-security/SKILL.md +151 -0
- package/.mindforge/skills/context-engineering/SKILL.md +114 -0
- package/.mindforge/skills/contract-testing/SKILL.md +85 -0
- package/.mindforge/skills/cost-estimation/SKILL.md +82 -0
- package/.mindforge/skills/cqrs-event-sourcing/SKILL.md +95 -0
- package/.mindforge/skills/cross-platform-testing/SKILL.md +43 -0
- package/.mindforge/skills/data-governance/SKILL.md +42 -0
- package/.mindforge/skills/data-lakehouse/SKILL.md +42 -0
- package/.mindforge/skills/data-mesh/SKILL.md +42 -0
- package/.mindforge/skills/data-modeling/SKILL.md +107 -0
- package/.mindforge/skills/data-pipeline-design/SKILL.md +171 -0
- package/.mindforge/skills/data-privacy-engineering/SKILL.md +42 -0
- package/.mindforge/skills/database-performance/SKILL.md +174 -0
- package/.mindforge/skills/database-sharding-advanced/SKILL.md +206 -0
- package/.mindforge/skills/de-sloppify/SKILL.md +120 -0
- package/.mindforge/skills/defense-in-depth/SKILL.md +84 -0
- package/.mindforge/skills/delegation-patterns/SKILL.md +123 -0
- package/.mindforge/skills/dependency-management/SKILL.md +94 -0
- package/.mindforge/skills/deployment-workflow/SKILL.md +135 -0
- package/.mindforge/skills/design-system/SKILL.md +113 -0
- package/.mindforge/skills/developer-onboarding/SKILL.md +99 -0
- package/.mindforge/skills/developer-productivity-metrics/SKILL.md +59 -0
- package/.mindforge/skills/distributed-consensus/SKILL.md +141 -0
- package/.mindforge/skills/dmux-workflows/SKILL.md +141 -0
- package/.mindforge/skills/dns-architecture/SKILL.md +167 -0
- package/.mindforge/skills/ecommerce-architecture/SKILL.md +41 -0
- package/.mindforge/skills/edge-computing/SKILL.md +91 -0
- package/.mindforge/skills/edtech-platform/SKILL.md +41 -0
- package/.mindforge/skills/email-deliverability/SKILL.md +177 -0
- package/.mindforge/skills/embedding-systems/SKILL.md +55 -0
- package/.mindforge/skills/environment-management/SKILL.md +54 -0
- package/.mindforge/skills/error-handling-architecture/SKILL.md +118 -0
- package/.mindforge/skills/estimation-techniques/SKILL.md +113 -0
- package/.mindforge/skills/eval-harness/SKILL.md +180 -0
- package/.mindforge/skills/event-driven-architecture/SKILL.md +162 -0
- package/.mindforge/skills/experiment-design/SKILL.md +139 -0
- package/.mindforge/skills/experiment-platform/SKILL.md +43 -0
- package/.mindforge/skills/feature-engineering/SKILL.md +42 -0
- package/.mindforge/skills/feature-flag-management/SKILL.md +183 -0
- package/.mindforge/skills/fine-tuning-workflow/SKILL.md +189 -0
- package/.mindforge/skills/fintech-patterns/SKILL.md +41 -0
- package/.mindforge/skills/flutter-architecture/SKILL.md +42 -0
- package/.mindforge/skills/gaming-backend/SKILL.md +41 -0
- package/.mindforge/skills/git-workflow-design/SKILL.md +129 -0
- package/.mindforge/skills/graceful-degradation/SKILL.md +95 -0
- package/.mindforge/skills/graphql-patterns/SKILL.md +243 -0
- package/.mindforge/skills/guardrails-and-safety/SKILL.md +137 -0
- package/.mindforge/skills/healthcare-systems/SKILL.md +40 -0
- package/.mindforge/skills/hiring-engineering/SKILL.md +119 -0
- package/.mindforge/skills/human-in-the-loop-design/SKILL.md +234 -0
- package/.mindforge/skills/i18n-architecture/SKILL.md +147 -0
- package/.mindforge/skills/idempotency-patterns/SKILL.md +84 -0
- package/.mindforge/skills/incident-communication/SKILL.md +96 -0
- package/.mindforge/skills/incident-management/SKILL.md +97 -0
- package/.mindforge/skills/infrastructure-as-code/SKILL.md +98 -0
- package/.mindforge/skills/instinct-clustering/SKILL.md +190 -0
- package/.mindforge/skills/internal-developer-platform/SKILL.md +51 -0
- package/.mindforge/skills/iot-platform/SKILL.md +41 -0
- package/.mindforge/skills/k8s-deployment/SKILL.md +358 -0
- package/.mindforge/skills/knowledge-graphs/SKILL.md +56 -0
- package/.mindforge/skills/knowledge-sharing-systems/SKILL.md +112 -0
- package/.mindforge/skills/llm-cost-optimization/SKILL.md +198 -0
- package/.mindforge/skills/llm-orchestration/SKILL.md +56 -0
- package/.mindforge/skills/load-testing/SKILL.md +84 -0
- package/.mindforge/skills/logistics-optimization/SKILL.md +40 -0
- package/.mindforge/skills/market-researcher/SKILL.md +99 -0
- package/.mindforge/skills/marketplace-trust/SKILL.md +40 -0
- package/.mindforge/skills/mcp-server-patterns/SKILL.md +264 -0
- package/.mindforge/skills/media-streaming/SKILL.md +41 -0
- package/.mindforge/skills/meeting-architecture/SKILL.md +146 -0
- package/.mindforge/skills/mentoring-patterns/SKILL.md +77 -0
- package/.mindforge/skills/microservices-patterns/SKILL.md +83 -0
- package/.mindforge/skills/migration-platform/SKILL.md +61 -0
- package/.mindforge/skills/migration-strategies/SKILL.md +129 -0
- package/.mindforge/skills/ml-feature-store/SKILL.md +56 -0
- package/.mindforge/skills/ml-monitoring/SKILL.md +42 -0
- package/.mindforge/skills/mobile-performance/SKILL.md +44 -0
- package/.mindforge/skills/mobile-security/SKILL.md +45 -0
- package/.mindforge/skills/model-evaluation/SKILL.md +53 -0
- package/.mindforge/skills/monorepo-management/SKILL.md +100 -0
- package/.mindforge/skills/multi-tenancy-patterns/SKILL.md +145 -0
- package/.mindforge/skills/multi-turn-conversation-design/SKILL.md +206 -0
- package/.mindforge/skills/multimodal-ai/SKILL.md +51 -0
- package/.mindforge/skills/mutation-testing/SKILL.md +97 -0
- package/.mindforge/skills/notification-system-design/SKILL.md +168 -0
- package/.mindforge/skills/observability-stack/SKILL.md +136 -0
- package/.mindforge/skills/offline-first-design/SKILL.md +43 -0
- package/.mindforge/skills/on-call-design/SKILL.md +111 -0
- package/.mindforge/skills/pagination-patterns/SKILL.md +230 -0
- package/.mindforge/skills/payment-integration/SKILL.md +176 -0
- package/.mindforge/skills/performance-reviews/SKILL.md +140 -0
- package/.mindforge/skills/platform-observability/SKILL.md +58 -0
- package/.mindforge/skills/platform-reliability/SKILL.md +52 -0
- package/.mindforge/skills/post-incident-learning/SKILL.md +96 -0
- package/.mindforge/skills/product-manager/SKILL.md +104 -0
- package/.mindforge/skills/progressive-web-app/SKILL.md +44 -0
- package/.mindforge/skills/prompt-engineering/SKILL.md +94 -0
- package/.mindforge/skills/proofreader/SKILL.md +158 -0
- package/.mindforge/skills/push-notification-architecture/SKILL.md +45 -0
- package/.mindforge/skills/python-performance/SKILL.md +183 -0
- package/.mindforge/skills/quality-audit/SKILL.md +171 -0
- package/.mindforge/skills/queue-design/SKILL.md +85 -0
- package/.mindforge/skills/rag-architecture/SKILL.md +176 -0
- package/.mindforge/skills/rate-limiting-design/SKILL.md +94 -0
- package/.mindforge/skills/react-native-patterns/SKILL.md +42 -0
- package/.mindforge/skills/react-performance/SKILL.md +229 -0
- package/.mindforge/skills/real-time-analytics/SKILL.md +42 -0
- package/.mindforge/skills/real-time-sync/SKILL.md +83 -0
- package/.mindforge/skills/responsive-native/SKILL.md +44 -0
- package/.mindforge/skills/responsive-patterns/SKILL.md +141 -0
- package/.mindforge/skills/rfc-pipeline/SKILL.md +114 -0
- package/.mindforge/skills/saas-multi-tenant/SKILL.md +41 -0
- package/.mindforge/skills/santa-method/SKILL.md +134 -0
- package/.mindforge/skills/search-implementation/SKILL.md +98 -0
- package/.mindforge/skills/secrets-platform/SKILL.md +56 -0
- package/.mindforge/skills/secrets-rotation/SKILL.md +173 -0
- package/.mindforge/skills/self-serve-infrastructure/SKILL.md +51 -0
- package/.mindforge/skills/serverless-patterns/SKILL.md +119 -0
- package/.mindforge/skills/skill-creator-meta/SKILL.md +146 -0
- package/.mindforge/skills/sprint-retrospective-facilitation/SKILL.md +112 -0
- package/.mindforge/skills/stakeholder-communication/SKILL.md +85 -0
- package/.mindforge/skills/state-management/SKILL.md +104 -0
- package/.mindforge/skills/stream-processing/SKILL.md +43 -0
- package/.mindforge/skills/streaming-architecture/SKILL.md +81 -0
- package/.mindforge/skills/supply-chain-security/SKILL.md +145 -0
- package/.mindforge/skills/synthetic-data-generation/SKILL.md +52 -0
- package/.mindforge/skills/system-design/SKILL.md +88 -0
- package/.mindforge/skills/team-topology-design/SKILL.md +107 -0
- package/.mindforge/skills/technical-debt-management/SKILL.md +86 -0
- package/.mindforge/skills/technical-interview-design/SKILL.md +98 -0
- package/.mindforge/skills/technical-leadership/SKILL.md +75 -0
- package/.mindforge/skills/technical-writing/SKILL.md +237 -0
- package/.mindforge/skills/technology-radar/SKILL.md +88 -0
- package/.mindforge/skills/testing-anti-patterns/SKILL.md +288 -0
- package/.mindforge/skills/tool-design/SKILL.md +138 -0
- package/.mindforge/skills/typescript-advanced/SKILL.md +198 -0
- package/.mindforge/skills/using-git-worktrees/SKILL.md +139 -0
- package/.mindforge/skills/verification-loop/SKILL.md +13 -1
- package/.mindforge/skills/vibe-security/SKILL.md +165 -0
- package/.mindforge/skills/visual-regression-testing/SKILL.md +97 -0
- package/.mindforge/skills/websocket-patterns/SKILL.md +203 -0
- package/.mindforge/skills/writing-plans/SKILL.md +170 -0
- package/.mindforge/skills/writing-skills/SKILL.md +216 -0
- package/.mindforge/skills/zero-trust-architecture/SKILL.md +166 -0
- package/CHANGELOG.md +176 -0
- package/MINDFORGE.md +4 -4
- package/package.json +2 -2
- package/.mindforge/personas/data-privacy-engineer.md +0 -187
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: multi-tenancy-patterns
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
min_mindforge_version: 0.3.0
|
|
5
|
+
status: stable
|
|
6
|
+
triggers: multi-tenancy, tenant isolation, shared database tenancy, row-level security, tenant context, data isolation, tenant provisioning, tenant migration, tenant routing, schema per tenant, tenant-aware query, tenant onboarding
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Skill — Multi-Tenancy Patterns
|
|
10
|
+
|
|
11
|
+
## When this skill activates
|
|
12
|
+
Any task involving multi-tenant architecture, tenant isolation, shared database
|
|
13
|
+
strategies, tenant context propagation, or tenant provisioning workflows.
|
|
14
|
+
|
|
15
|
+
## Mandatory actions when this skill is active
|
|
16
|
+
|
|
17
|
+
### Before designing multi-tenancy
|
|
18
|
+
1. Assess isolation requirements (regulatory, security, performance).
|
|
19
|
+
2. Determine tenant scale (10 tenants vs 10,000 tenants).
|
|
20
|
+
3. Choose isolation level based on business requirements, not engineering convenience.
|
|
21
|
+
|
|
22
|
+
### Isolation levels
|
|
23
|
+
|
|
24
|
+
**Shared Database + Row-Level Security (RLS):**
|
|
25
|
+
- Single database, single schema, tenant_id column on every table.
|
|
26
|
+
- Cheapest to operate, easiest to deploy.
|
|
27
|
+
- Least isolated — bugs can leak data between tenants.
|
|
28
|
+
- Best for: SaaS with many small tenants, cost-sensitive.
|
|
29
|
+
- Risk: a missing WHERE clause exposes all tenant data.
|
|
30
|
+
|
|
31
|
+
**Schema per tenant:**
|
|
32
|
+
- Single database, separate schema per tenant.
|
|
33
|
+
- Moderate isolation and moderate cost.
|
|
34
|
+
- Migrations must run per-schema (automation required).
|
|
35
|
+
- Best for: moderate tenant count (< 1000), need logical separation.
|
|
36
|
+
|
|
37
|
+
**Database per tenant:**
|
|
38
|
+
- Completely separate database per tenant.
|
|
39
|
+
- Maximum isolation, maximum cost.
|
|
40
|
+
- Independent scaling, independent backup/restore.
|
|
41
|
+
- Best for: enterprise customers, regulatory requirements, high-value tenants.
|
|
42
|
+
|
|
43
|
+
### RLS implementation (PostgreSQL)
|
|
44
|
+
|
|
45
|
+
```sql
|
|
46
|
+
-- Enable RLS on the table
|
|
47
|
+
ALTER TABLE orders ENABLE ROW LEVEL SECURITY;
|
|
48
|
+
|
|
49
|
+
-- Create policy that filters by tenant
|
|
50
|
+
CREATE POLICY tenant_isolation ON orders
|
|
51
|
+
USING (tenant_id = current_setting('app.current_tenant')::uuid);
|
|
52
|
+
|
|
53
|
+
-- Force RLS even for table owner
|
|
54
|
+
ALTER TABLE orders FORCE ROW LEVEL SECURITY;
|
|
55
|
+
|
|
56
|
+
-- Set tenant context at connection level
|
|
57
|
+
SET app.current_tenant = 'tenant-uuid-here';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Critical rules:**
|
|
61
|
+
- RLS policies must be impossible to bypass from application code.
|
|
62
|
+
- NEVER use a superuser connection that bypasses RLS in application code.
|
|
63
|
+
- Test RLS with a dedicated "tenant leak" test suite.
|
|
64
|
+
- Add a CHECK constraint: `tenant_id IS NOT NULL` on every tenant-scoped table.
|
|
65
|
+
|
|
66
|
+
### Tenant context propagation
|
|
67
|
+
|
|
68
|
+
**Middleware pattern:**
|
|
69
|
+
```
|
|
70
|
+
Request → Extract tenant → Validate → Set context → Handler → Response
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Extraction sources (priority order):**
|
|
74
|
+
1. JWT claim (most secure — server-signed).
|
|
75
|
+
2. Subdomain: `tenant1.app.com` → tenant_id lookup.
|
|
76
|
+
3. Path prefix: `app.com/tenant1/...` → extract from URL.
|
|
77
|
+
4. Header: `X-Tenant-ID` (for service-to-service only).
|
|
78
|
+
|
|
79
|
+
**Propagation through the stack:**
|
|
80
|
+
- HTTP layer: middleware sets tenant in request context.
|
|
81
|
+
- Service layer: receives tenant from context, passes to repositories.
|
|
82
|
+
- Data layer: sets session variable before executing queries.
|
|
83
|
+
- Background jobs: serialize tenant_id in job payload, restore before processing.
|
|
84
|
+
|
|
85
|
+
### Tenant routing
|
|
86
|
+
|
|
87
|
+
**Subdomain routing:**
|
|
88
|
+
- `tenant1.app.com`, `tenant2.app.com`
|
|
89
|
+
- Requires wildcard DNS and TLS certificate.
|
|
90
|
+
- Clean separation, easy to identify tenant.
|
|
91
|
+
- Custom domains: CNAME tenant1.com → tenant1.app.com.
|
|
92
|
+
|
|
93
|
+
**Path-based routing:**
|
|
94
|
+
- `app.com/tenant1/dashboard`, `app.com/tenant2/dashboard`
|
|
95
|
+
- Simpler DNS/TLS setup.
|
|
96
|
+
- Requires path prefix stripping in routing layer.
|
|
97
|
+
|
|
98
|
+
**Header-based routing (internal only):**
|
|
99
|
+
- `X-Tenant-ID: tenant-uuid`
|
|
100
|
+
- For service-to-service communication within the platform.
|
|
101
|
+
- Never expose to end users (spoofing risk).
|
|
102
|
+
|
|
103
|
+
### Tenant provisioning
|
|
104
|
+
|
|
105
|
+
**Onboarding workflow:**
|
|
106
|
+
1. Create tenant record (name, plan, config).
|
|
107
|
+
2. Provision resources (schema/database if applicable).
|
|
108
|
+
3. Run seed data (default roles, settings, sample data).
|
|
109
|
+
4. Configure DNS/routing (subdomain or custom domain).
|
|
110
|
+
5. Send welcome notification.
|
|
111
|
+
|
|
112
|
+
**Automation requirements:**
|
|
113
|
+
- Provisioning must be fully automated (no manual steps).
|
|
114
|
+
- Must complete in < 30 seconds for shared DB, < 5 minutes for isolated DB.
|
|
115
|
+
- Rollback on failure — no half-provisioned tenants.
|
|
116
|
+
|
|
117
|
+
### Tenant-aware migrations
|
|
118
|
+
|
|
119
|
+
**Shared DB (RLS):**
|
|
120
|
+
- Standard migrations — all tenants share the schema.
|
|
121
|
+
- Add tenant_id to new tables, backfill existing tables.
|
|
122
|
+
|
|
123
|
+
**Schema per tenant:**
|
|
124
|
+
- Migration runner must iterate all tenant schemas.
|
|
125
|
+
- Parallel execution for speed, with error handling per-tenant.
|
|
126
|
+
- Failed migrations must not block other tenants.
|
|
127
|
+
|
|
128
|
+
**Database per tenant:**
|
|
129
|
+
- Migration runner connects to each tenant DB.
|
|
130
|
+
- Version tracking per-tenant (some may be ahead/behind during rollout).
|
|
131
|
+
- Canary strategy: migrate one tenant first, verify, then batch.
|
|
132
|
+
|
|
133
|
+
### Testing multi-tenancy
|
|
134
|
+
|
|
135
|
+
- **Isolation tests:** Create 2+ tenants, write data as tenant A, verify tenant B cannot see it.
|
|
136
|
+
- **Context tests:** Verify tenant context survives async operations (background jobs, event handlers).
|
|
137
|
+
- **Edge cases:** What happens with no tenant context? (Must fail closed, not open.)
|
|
138
|
+
- **Performance:** Verify RLS does not degrade query performance significantly (check EXPLAIN).
|
|
139
|
+
- **All environments** must have multiple tenants configured (including development).
|
|
140
|
+
|
|
141
|
+
## Self-check before task completion
|
|
142
|
+
- [ ] Did I follow the mandatory actions for this skill?
|
|
143
|
+
- [ ] Did I apply the patterns appropriate to the context?
|
|
144
|
+
- [ ] Did I verify the implementation meets the criteria above?
|
|
145
|
+
- [ ] Did I document decisions and trade-offs made?
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: multi-turn-conversation-design
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
min_mindforge_version: 10.0.4
|
|
5
|
+
status: stable
|
|
6
|
+
triggers: multi-turn conversation, conversation state, context carryover, clarification strategy, conversation repair, intent disambiguation, dialogue management, turn-taking, conversation memory, slot filling, conversation flow, dialogue state tracking
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Skill — Multi-Turn Conversation Design (Dialogue State Management)
|
|
10
|
+
|
|
11
|
+
## When this skill activates
|
|
12
|
+
When designing conversational interfaces, building dialogue systems, implementing
|
|
13
|
+
multi-step user interactions, or troubleshooting conversation flow issues. Use for
|
|
14
|
+
chatbots, voice assistants, multi-step forms, or any interface where information
|
|
15
|
+
is gathered across multiple exchanges.
|
|
16
|
+
|
|
17
|
+
Core principle: **Continuity over repetition** — a well-designed conversation feels
|
|
18
|
+
like talking to someone with a good memory. Never re-ask what was already provided.
|
|
19
|
+
Never lose context between turns. Never make the user repeat themselves.
|
|
20
|
+
|
|
21
|
+
## Mandatory actions when this skill is active
|
|
22
|
+
|
|
23
|
+
### Dialogue State Tracking
|
|
24
|
+
|
|
25
|
+
1. **State schema (track at every turn):**
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"conversation_id": "uuid",
|
|
29
|
+
"turn_number": 5,
|
|
30
|
+
"current_intent": "book_flight",
|
|
31
|
+
"confidence": 0.92,
|
|
32
|
+
"slots": {
|
|
33
|
+
"origin": {"value": "SFO", "confirmed": true, "source": "turn_2"},
|
|
34
|
+
"destination": {"value": "JFK", "confirmed": true, "source": "turn_3"},
|
|
35
|
+
"date": {"value": null, "confirmed": false, "source": null},
|
|
36
|
+
"passengers": {"value": 1, "confirmed": false, "source": "assumed_default"}
|
|
37
|
+
},
|
|
38
|
+
"pending_clarifications": ["date"],
|
|
39
|
+
"conversation_history": ["summary of prior turns"],
|
|
40
|
+
"user_preferences": {"prefers_direct_flights": true}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Rules:
|
|
45
|
+
- State is updated after EVERY turn (never stale)
|
|
46
|
+
- Each slot tracks: value, whether confirmed by user, and which turn provided it
|
|
47
|
+
- Assumed values are marked as unconfirmed (verify before critical actions)
|
|
48
|
+
- History is summarized (not raw) to stay within context limits
|
|
49
|
+
|
|
50
|
+
### Context Carryover
|
|
51
|
+
|
|
52
|
+
2. **Explicit reference to prior context:**
|
|
53
|
+
```
|
|
54
|
+
Good (references prior turn):
|
|
55
|
+
"You mentioned you're flying from SFO. What date works for you?"
|
|
56
|
+
|
|
57
|
+
Bad (no reference, feels disconnected):
|
|
58
|
+
"What date would you like to fly?"
|
|
59
|
+
|
|
60
|
+
Good (acknowledges what's known):
|
|
61
|
+
"I have SFO to JFK for 1 passenger. I just need your travel date."
|
|
62
|
+
|
|
63
|
+
Bad (re-asks known information):
|
|
64
|
+
"Where are you flying from?"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Rules:
|
|
68
|
+
- Start responses by acknowledging what you already know
|
|
69
|
+
- Reference specific prior statements: "Earlier you said X..."
|
|
70
|
+
- Summarize collected information periodically (every 3-4 turns)
|
|
71
|
+
- If context window is exhausted: summarize and explicitly note what's carried forward
|
|
72
|
+
- Never assume context persists implicitly — make carryover visible
|
|
73
|
+
|
|
74
|
+
### Clarification Strategy
|
|
75
|
+
|
|
76
|
+
3. **When to clarify (confidence-based):**
|
|
77
|
+
```
|
|
78
|
+
Confidence >= 0.9: Proceed without clarification
|
|
79
|
+
Confidence 0.7-0.9: Proceed but confirm ("I'll book SFO to JFK — is that right?")
|
|
80
|
+
Confidence 0.5-0.7: Ask targeted question with options
|
|
81
|
+
Confidence < 0.5: Ask open-ended clarification
|
|
82
|
+
|
|
83
|
+
Clarification types (from most to least specific):
|
|
84
|
+
1. Binary confirmation: "Did you mean San Francisco?"
|
|
85
|
+
2. Multiple choice: "Did you mean SFO, SJC, or OAK?"
|
|
86
|
+
3. Constrained question: "Which airport in the Bay Area?"
|
|
87
|
+
4. Open question: "Where are you flying from?" (last resort)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Rules:
|
|
91
|
+
- Always prefer more specific clarification formats (binary > choice > open)
|
|
92
|
+
- Limit choices to 3-5 options maximum
|
|
93
|
+
- Never ask two clarification questions in one turn (one at a time)
|
|
94
|
+
- If user answers a different question than asked: accept the new info, don't force the original question
|
|
95
|
+
- After 2 failed clarification attempts on same slot: offer to skip or use default
|
|
96
|
+
|
|
97
|
+
### Conversation Repair
|
|
98
|
+
|
|
99
|
+
4. **Detecting and recovering from misunderstanding:**
|
|
100
|
+
```
|
|
101
|
+
Misunderstanding signals:
|
|
102
|
+
- User contradicts a prior agent response
|
|
103
|
+
- User repeats their question with different phrasing
|
|
104
|
+
- User says "no", "that's not what I meant", "wrong"
|
|
105
|
+
- User provides information that conflicts with current state
|
|
106
|
+
|
|
107
|
+
Repair protocol:
|
|
108
|
+
1. Acknowledge the misunderstanding explicitly
|
|
109
|
+
"I misunderstood — let me correct that."
|
|
110
|
+
2. State what you incorrectly assumed
|
|
111
|
+
"I thought you meant [X], but you're saying [Y]."
|
|
112
|
+
3. Update state with correct information
|
|
113
|
+
4. Confirm the correction
|
|
114
|
+
"Got it — [Y], not [X]. Is that right?"
|
|
115
|
+
5. Continue from the corrected state
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Rules:
|
|
119
|
+
- Never argue with the user about what they meant
|
|
120
|
+
- Repair immediately (don't wait for the user to notice the error)
|
|
121
|
+
- After repair: replay any downstream logic that depended on the wrong value
|
|
122
|
+
- Track repair frequency (high repair rate = poor understanding, needs model improvement)
|
|
123
|
+
|
|
124
|
+
### Slot Filling
|
|
125
|
+
|
|
126
|
+
5. **Multi-turn information gathering:**
|
|
127
|
+
```
|
|
128
|
+
Slot filling strategy:
|
|
129
|
+
1. Identify all required slots for the current intent
|
|
130
|
+
2. Check which are already filled (from prior turns or user profile)
|
|
131
|
+
3. Ask for unfilled slots in natural priority order (most important first)
|
|
132
|
+
4. One slot per turn (don't overwhelm)
|
|
133
|
+
5. Allow user to provide multiple slots in one message (parse and fill all)
|
|
134
|
+
6. Confirm all slots before executing action
|
|
135
|
+
|
|
136
|
+
Example flow:
|
|
137
|
+
Turn 1: User: "I want to book a flight"
|
|
138
|
+
→ Intent: book_flight, all slots empty
|
|
139
|
+
Turn 2: Agent: "Where are you flying from?"
|
|
140
|
+
→ User: "SFO to JFK next Tuesday"
|
|
141
|
+
→ Fill: origin=SFO, destination=JFK, date=next_tuesday
|
|
142
|
+
Turn 3: Agent: "SFO to JFK next Tuesday for 1 passenger. Shall I search?"
|
|
143
|
+
→ Confirm all slots, offer to proceed
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Rules:
|
|
147
|
+
- Never re-ask a filled slot (check state first)
|
|
148
|
+
- If user provides extra info: accept and fill (don't say "I didn't ask that yet")
|
|
149
|
+
- Required slots must be confirmed before executing actions
|
|
150
|
+
- Optional slots get defaults (stated explicitly: "I'll assume 1 passenger unless you say otherwise")
|
|
151
|
+
|
|
152
|
+
### Intent Disambiguation
|
|
153
|
+
|
|
154
|
+
6. **Handling ambiguous or multi-intent messages:**
|
|
155
|
+
```
|
|
156
|
+
Single intent (clear):
|
|
157
|
+
"Book me a flight to NYC" → book_flight
|
|
158
|
+
|
|
159
|
+
Ambiguous intent (clarify):
|
|
160
|
+
"I need to go to NYC" → travel? meeting? moving? → "Are you looking to book a flight?"
|
|
161
|
+
|
|
162
|
+
Multi-intent (handle sequentially):
|
|
163
|
+
"Book a flight and a hotel" → [book_flight, book_hotel]
|
|
164
|
+
→ "Let's start with the flight. Where are you flying from?"
|
|
165
|
+
→ Complete flight, then: "Now let's find you a hotel."
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Rules:
|
|
169
|
+
- Handle one intent at a time (queue others, don't drop them)
|
|
170
|
+
- When disambiguating: offer the most likely interpretation first
|
|
171
|
+
- Track which intents are pending (never lose a queued intent)
|
|
172
|
+
- If intents are independent: handle in order mentioned
|
|
173
|
+
- If intents are dependent: handle the dependency first
|
|
174
|
+
|
|
175
|
+
### Conversation Flow Design
|
|
176
|
+
|
|
177
|
+
7. **Turn structure:**
|
|
178
|
+
```
|
|
179
|
+
Every agent turn should contain:
|
|
180
|
+
1. Acknowledgment: what you understood from the user's message
|
|
181
|
+
2. Progress indicator: what's done, what remains
|
|
182
|
+
3. Next action: what you need from the user OR what you're doing next
|
|
183
|
+
|
|
184
|
+
Pattern:
|
|
185
|
+
"[Acknowledge]. [Progress]. [Next step]."
|
|
186
|
+
"Got it, SFO to JFK. I just need your travel date. When are you flying?"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Rules:
|
|
190
|
+
- Keep agent turns concise (2-3 sentences for information gathering)
|
|
191
|
+
- Never end a turn without a clear next step (question, confirmation, or action)
|
|
192
|
+
- Use progressive disclosure (don't dump all information at once)
|
|
193
|
+
- Match formality to user's tone (mirror their communication style)
|
|
194
|
+
|
|
195
|
+
## Self-check before task completion
|
|
196
|
+
|
|
197
|
+
Before marking a task done when this skill was active:
|
|
198
|
+
|
|
199
|
+
- [ ] Is dialogue state tracked and updated every turn (intent, slots, confidence)?
|
|
200
|
+
- [ ] Does every agent response reference prior context (no disconnected turns)?
|
|
201
|
+
- [ ] Is clarification strategy confidence-based (specific at high confidence, open at low)?
|
|
202
|
+
- [ ] Is there a repair protocol for misunderstandings (acknowledge, correct, confirm)?
|
|
203
|
+
- [ ] Does slot filling never re-ask already-provided information?
|
|
204
|
+
- [ ] Are multi-intent messages handled sequentially (queued, not dropped)?
|
|
205
|
+
- [ ] Does every agent turn have: acknowledgment, progress, next step?
|
|
206
|
+
- [ ] Are assumed/default values explicitly stated and marked unconfirmed?
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: multimodal-ai
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
min_mindforge_version: 10.5.0
|
|
5
|
+
status: stable
|
|
6
|
+
triggers: multimodal AI system, vision language model, image generation integration, audio AI processing, multi-input AI pipeline, multimodal embedding, visual question answering, image understanding AI, multimodal fusion, cross-modal retrieval, visual AI agent, multimodal prompt design
|
|
7
|
+
compose:
|
|
8
|
+
- agent-orchestration-patterns
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Multimodal AI Systems
|
|
12
|
+
|
|
13
|
+
## When this skill activates
|
|
14
|
+
|
|
15
|
+
This skill activates when building AI systems that process multiple input modalities (vision + language, audio + text, image generation from text), implementing vision-language models, designing multimodal embeddings, or creating cross-modal retrieval systems. It applies to any system where AI must understand or generate content across different sensory modalities.
|
|
16
|
+
|
|
17
|
+
## Mandatory actions when this skill is active
|
|
18
|
+
|
|
19
|
+
### Before writing any code
|
|
20
|
+
|
|
21
|
+
1. **Map modality requirements** — Identify all input/output modalities (text, image, audio, video). Determine which modalities are primary (must-have) vs. augmentative (enhances quality but optional). Define the fusion strategy: early fusion (combine raw inputs), late fusion (combine model outputs), or hybrid.
|
|
22
|
+
2. **Select appropriate models** — Choose vision-language models based on task: GPT-4V/Claude for reasoning + vision, CLIP for embeddings, DALL-E/Stable Diffusion for generation, Whisper for audio. Validate that models support your required resolution, context length, and throughput.
|
|
23
|
+
3. **Design preprocessing pipelines** — Each modality requires specific preprocessing: images need resizing/normalization/format conversion, audio needs resampling/segmentation, video needs frame extraction. Define preprocessing specs upfront to avoid format mismatches.
|
|
24
|
+
4. **Establish quality metrics** — Define success criteria per modality: image classification accuracy, caption BLEU score, audio transcription WER, cross-modal retrieval Recall@K. Multimodal systems fail silently when one modality degrades.
|
|
25
|
+
|
|
26
|
+
### During implementation
|
|
27
|
+
|
|
28
|
+
- **Normalize modality inputs** — Convert all modalities to consistent formats before fusion. Use standard libraries: PIL/OpenCV for images, librosa/soundfile for audio, ffmpeg for video. Validate dimensions and data types at pipeline entry points.
|
|
29
|
+
- **Handle modality-specific errors gracefully** — Image decoding failures, audio corruption, and video format issues should not crash the pipeline. Implement per-modality error handling with clear logging and fallback strategies (skip corrupted input, use placeholder, or retry with degraded quality).
|
|
30
|
+
- **Implement attention mechanisms for fusion** — When combining modalities, use attention weights to let the model learn which modality is most informative for each input. Cross-attention between image patches and text tokens is the gold standard for VLMs.
|
|
31
|
+
- **Batch processing by modality** — Group inputs by modality for efficient GPU utilization. Processing a mixed batch of images and text is slower than processing homogeneous batches sequentially.
|
|
32
|
+
- **Design multimodal prompts carefully** — Vision-language models require structured prompts: "Image: [image] Question: {query} Answer:". Test prompt templates with diverse inputs to avoid format brittleness. Place modality markers consistently.
|
|
33
|
+
- **Cache embeddings aggressively** — Multimodal embeddings are expensive to compute. Cache image embeddings, audio embeddings, and text embeddings separately with content-based keys (hash of preprocessed input). Invalidate caches only when model or preprocessing changes.
|
|
34
|
+
|
|
35
|
+
### After implementation
|
|
36
|
+
|
|
37
|
+
- **Validate cross-modal alignment** — Test that similar concepts across modalities produce similar embeddings (dog image + "dog" text should be close in embedding space). Use cosine similarity thresholds and spot-check with diverse examples.
|
|
38
|
+
- **Measure modality-specific performance** — Isolate performance per modality. A system may excel at text understanding but fail at vision. Track accuracy, latency, and cost per modality separately.
|
|
39
|
+
- **Test edge cases per modality** — Images: unusual aspect ratios, corrupted files, black images, high-resolution inputs. Audio: silence, noise, overlapping speech. Text: empty strings, non-ASCII characters, extremely long inputs.
|
|
40
|
+
- **Monitor modality imbalance** — If one modality dominates the training data or inference distribution, the model may ignore other modalities. Track input distribution and validate that minority modalities still contribute to predictions.
|
|
41
|
+
|
|
42
|
+
## Self-check before task completion
|
|
43
|
+
|
|
44
|
+
- [ ] All input modalities are preprocessed to consistent formats with validation
|
|
45
|
+
- [ ] Modality fusion strategy (early/late/hybrid) is explicitly implemented and tested
|
|
46
|
+
- [ ] Per-modality error handling prevents pipeline crashes from corrupted inputs
|
|
47
|
+
- [ ] Multimodal prompts are structured consistently and tested with diverse examples
|
|
48
|
+
- [ ] Cross-modal retrieval accuracy meets target thresholds (Recall@K ≥ target)
|
|
49
|
+
- [ ] Embeddings are cached with content-based keys to reduce compute cost
|
|
50
|
+
- [ ] Performance is measured and validated separately for each modality
|
|
51
|
+
- [ ] Edge cases (corrupted files, unusual formats, empty inputs) are handled gracefully
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mutation-testing
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
min_mindforge_version: 10.0.8
|
|
5
|
+
status: stable
|
|
6
|
+
triggers: mutation testing, stryker, mutmut, mutation score, surviving mutant, killed mutant, mutation operator, test strength, weak test detection, mutation coverage, test effectiveness, kill ratio
|
|
7
|
+
compose: testing-standards
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Mutation Testing
|
|
11
|
+
|
|
12
|
+
## When this skill activates
|
|
13
|
+
|
|
14
|
+
This skill activates when evaluating test suite effectiveness, identifying weak tests, configuring mutation testing tools, or analyzing mutation testing results. It applies whenever the question is "are my tests actually catching bugs?" rather than "do my tests pass?"
|
|
15
|
+
|
|
16
|
+
## Mandatory actions when this skill is active
|
|
17
|
+
|
|
18
|
+
### Before
|
|
19
|
+
|
|
20
|
+
1. Verify the project has a passing test suite (mutation testing requires green tests as baseline).
|
|
21
|
+
2. Identify the language and select the appropriate tool (Stryker for JS/TS, mutmut for Python, PIT for Java).
|
|
22
|
+
3. Determine scope: full codebase or targeted (changed files only for CI, full for periodic audits).
|
|
23
|
+
4. Check that test execution time is reasonable (mutation testing multiplies runtime by mutant count).
|
|
24
|
+
5. Establish the target kill ratio (minimum 80%, aim for 90%+ on critical paths).
|
|
25
|
+
|
|
26
|
+
### During
|
|
27
|
+
|
|
28
|
+
**Core Concept:**
|
|
29
|
+
- Mutation testing modifies your source code (introduces bugs) and checks if tests fail.
|
|
30
|
+
- If a test fails after mutation: the mutant is **killed** (good — tests caught the bug).
|
|
31
|
+
- If all tests pass after mutation: the mutant **survived** (bad — tests missed the bug).
|
|
32
|
+
- Surviving mutants reveal exactly where test coverage is superficial.
|
|
33
|
+
|
|
34
|
+
**Mutation Operators:**
|
|
35
|
+
- **Arithmetic**: Replace `+` with `-`, `*` with `/`.
|
|
36
|
+
- **Conditional**: Replace `>` with `>=`, `==` with `!=`, flip `&&` to `||`.
|
|
37
|
+
- **Boundary**: Change `i < 10` to `i <= 10` (off-by-one detection).
|
|
38
|
+
- **Return value**: Replace `return x` with `return 0`, `return null`, `return !x`.
|
|
39
|
+
- **Removal**: Delete function calls, remove assignments, skip statements.
|
|
40
|
+
- **String**: Replace string literals with empty string or different value.
|
|
41
|
+
|
|
42
|
+
**Metrics and Interpretation:**
|
|
43
|
+
- **Mutation score** = (killed mutants / total mutants) * 100%.
|
|
44
|
+
- **Killed**: Test suite detected the mutation (test failed). This is the goal.
|
|
45
|
+
- **Survived**: No test caught the mutation. Investigate WHY.
|
|
46
|
+
- **Timeout**: Mutation caused infinite loop. Counted as killed (behavior changed).
|
|
47
|
+
- **No coverage**: No test executes the mutated line. Add tests for this code.
|
|
48
|
+
- **Equivalent mutant**: Mutation produces identical behavior (e.g., `x * 1`). Ignore these.
|
|
49
|
+
|
|
50
|
+
**Investigating Surviving Mutants:**
|
|
51
|
+
1. Look at the mutated line and the operator applied.
|
|
52
|
+
2. Ask: "What assertion would fail if this mutation were a real bug?"
|
|
53
|
+
3. If no assertion exists: write a test that specifically validates that behavior.
|
|
54
|
+
4. If assertion exists but passes: the assertion is too weak (not checking the right value).
|
|
55
|
+
5. Common causes: missing boundary tests, testing only happy path, asserting on wrong property.
|
|
56
|
+
|
|
57
|
+
**Tool Configuration:**
|
|
58
|
+
|
|
59
|
+
*Stryker (JavaScript/TypeScript):*
|
|
60
|
+
- Configure `mutate` array to target source files (exclude test files, configs).
|
|
61
|
+
- Use `--incremental` for CI (only mutate changed files).
|
|
62
|
+
- Set thresholds: `{ high: 90, low: 80, break: 75 }`.
|
|
63
|
+
|
|
64
|
+
*mutmut (Python):*
|
|
65
|
+
- Run `mutmut run` for full analysis, `mutmut results` for summary.
|
|
66
|
+
- Use `--paths-to-mutate` to scope to specific modules.
|
|
67
|
+
- Inspect survivors with `mutmut show <id>`.
|
|
68
|
+
|
|
69
|
+
*PIT (Java):*
|
|
70
|
+
- Configure via Maven/Gradle plugin with target classes and test classes.
|
|
71
|
+
- Use `STRONGER` mutator group for comprehensive coverage.
|
|
72
|
+
- Set `mutationThreshold` in build to fail below target.
|
|
73
|
+
|
|
74
|
+
**Performance Optimization:**
|
|
75
|
+
- In CI: only mutate files changed in the PR (incremental mode).
|
|
76
|
+
- Use parallel execution (Stryker supports `--concurrency`).
|
|
77
|
+
- Exclude generated code, DTOs, and trivial getters/setters.
|
|
78
|
+
- Run full mutation analysis on a schedule (nightly/weekly), not every commit.
|
|
79
|
+
|
|
80
|
+
### After
|
|
81
|
+
|
|
82
|
+
1. Kill ratio meets the configured threshold (80%+ minimum).
|
|
83
|
+
2. All surviving mutants in critical code paths have been investigated.
|
|
84
|
+
3. New tests written to kill meaningful surviving mutants.
|
|
85
|
+
4. Equivalent mutants documented and excluded from score calculation.
|
|
86
|
+
5. CI is configured to run incremental mutation testing on PRs.
|
|
87
|
+
|
|
88
|
+
## Self-check before task completion
|
|
89
|
+
|
|
90
|
+
- [ ] Mutation testing tool is configured correctly for the project language.
|
|
91
|
+
- [ ] Scope is appropriate (not wasting time on generated/trivial code).
|
|
92
|
+
- [ ] Kill ratio meets the minimum threshold for the module's criticality.
|
|
93
|
+
- [ ] Surviving mutants have been triaged: fix (write test) or dismiss (equivalent mutant).
|
|
94
|
+
- [ ] New tests added actually kill the previously surviving mutants (verified by re-run).
|
|
95
|
+
- [ ] CI integration uses incremental mode to keep pipeline fast.
|
|
96
|
+
- [ ] Results are documented for team visibility (report or dashboard).
|
|
97
|
+
- [ ] Performance impact is acceptable (total mutation test time within budget).
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: notification-system-design
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
min_mindforge_version: 10.0.4
|
|
5
|
+
status: stable
|
|
6
|
+
triggers: notification system, multi-channel notification, frequency capping, preference management, notification delivery, push notification architecture, notification template, notification queue, do not disturb, notification deduplication, channel routing, notification personalization
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Skill — Notification System Design (Multi-Channel Delivery Architecture)
|
|
10
|
+
|
|
11
|
+
## When this skill activates
|
|
12
|
+
When designing notification delivery systems, implementing multi-channel messaging,
|
|
13
|
+
building preference management, or architecting notification infrastructure. Use for
|
|
14
|
+
any system that needs to send timely, relevant messages to users across push, email,
|
|
15
|
+
SMS, in-app, or other channels.
|
|
16
|
+
|
|
17
|
+
Core principle: **Respect over reach** — every notification should earn its delivery
|
|
18
|
+
by being timely, relevant, and respectful of user preferences and attention.
|
|
19
|
+
|
|
20
|
+
## Mandatory actions when this skill is active
|
|
21
|
+
|
|
22
|
+
### Channel Selection (Urgency Matrix)
|
|
23
|
+
|
|
24
|
+
1. **Route notifications by urgency and type:**
|
|
25
|
+
```
|
|
26
|
+
| Urgency | Channels | Examples |
|
|
27
|
+
|------------|-----------------------------|-----------------------------------|
|
|
28
|
+
| Critical | Push + Email + SMS | Security alert, payment failure |
|
|
29
|
+
| Important | Push + Email | Order shipped, appointment reminder|
|
|
30
|
+
| Standard | Push OR Email | New feature, weekly digest |
|
|
31
|
+
| Low | In-app only | Social activity, recommendations |
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Rules:
|
|
35
|
+
- Critical notifications bypass frequency caps (but still respect DND)
|
|
36
|
+
- Never send SMS for non-critical notifications (highest user annoyance cost)
|
|
37
|
+
- In-app is the lowest-friction channel — use it generously
|
|
38
|
+
- Email is async — never rely on it for time-sensitive actions
|
|
39
|
+
- User channel preferences override the urgency matrix (except Critical/security)
|
|
40
|
+
|
|
41
|
+
### Frequency Capping
|
|
42
|
+
|
|
43
|
+
2. **Rate limiting per user:**
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"caps": {
|
|
47
|
+
"push": {"max_per_day": 5, "max_per_hour": 2},
|
|
48
|
+
"email": {"max_per_day": 3, "max_per_week": 10},
|
|
49
|
+
"sms": {"max_per_day": 1, "max_per_week": 3},
|
|
50
|
+
"in_app": {"max_per_day": 20}
|
|
51
|
+
},
|
|
52
|
+
"aggregation": {
|
|
53
|
+
"combine_similar": true,
|
|
54
|
+
"digest_threshold": 3,
|
|
55
|
+
"digest_window_minutes": 30
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Rules:
|
|
61
|
+
- Caps are per-user, per-channel, across ALL notification types
|
|
62
|
+
- When cap is reached: queue for next window OR downgrade to lower-urgency channel
|
|
63
|
+
- Aggregate similar notifications into digests (e.g., "3 new comments" not 3 separate pushes)
|
|
64
|
+
- Track notification fatigue: if open rate drops below 5%, reduce frequency automatically
|
|
65
|
+
- Critical/security notifications are exempt from caps but tracked separately
|
|
66
|
+
|
|
67
|
+
### Preference Management
|
|
68
|
+
|
|
69
|
+
3. **User preference schema:**
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"user_id": "uuid",
|
|
73
|
+
"global": {
|
|
74
|
+
"muted": false,
|
|
75
|
+
"do_not_disturb": {"enabled": true, "start": "22:00", "end": "08:00", "timezone": "America/New_York"}
|
|
76
|
+
},
|
|
77
|
+
"channels": {
|
|
78
|
+
"push": {"enabled": true},
|
|
79
|
+
"email": {"enabled": true, "digest_mode": "daily"},
|
|
80
|
+
"sms": {"enabled": false}
|
|
81
|
+
},
|
|
82
|
+
"categories": {
|
|
83
|
+
"marketing": {"push": false, "email": true},
|
|
84
|
+
"social": {"push": true, "email": false},
|
|
85
|
+
"transactional": {"push": true, "email": true},
|
|
86
|
+
"security": {"push": true, "email": true, "sms": true}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Rules:
|
|
92
|
+
- Users can control preferences at: global, channel, and category level
|
|
93
|
+
- Category-level overrides channel-level (fine-grained control)
|
|
94
|
+
- Security/transactional notifications: always delivered (legal requirement), but user chooses channel
|
|
95
|
+
- DND hours: queue notifications and deliver when DND ends (except Critical)
|
|
96
|
+
- Preference changes take effect immediately (no "takes up to 24 hours")
|
|
97
|
+
|
|
98
|
+
### Delivery Architecture
|
|
99
|
+
|
|
100
|
+
4. **System architecture:**
|
|
101
|
+
```
|
|
102
|
+
Event Source → Notification Service → Channel Router → Delivery Providers → Tracking
|
|
103
|
+
|
|
104
|
+
Components:
|
|
105
|
+
1. Event Ingestion: receives trigger events from application services
|
|
106
|
+
2. Notification Service: applies business logic (templates, personalization, dedup)
|
|
107
|
+
3. Preference Engine: checks user preferences and caps
|
|
108
|
+
4. Channel Router: selects delivery channel(s) per urgency matrix + preferences
|
|
109
|
+
5. Queue (per channel): buffers for rate limiting and retry
|
|
110
|
+
6. Delivery Providers: FCM/APNs (push), SendGrid/SES (email), Twilio (SMS)
|
|
111
|
+
7. Tracking: delivery status, opens, clicks, dismissals
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
5. **Delivery guarantees:**
|
|
115
|
+
- At-least-once delivery with deduplication
|
|
116
|
+
- Idempotency key per notification (event_type + user_id + dedup_window)
|
|
117
|
+
- Exponential retry with jitter (max 3 retries per channel)
|
|
118
|
+
- Dead letter queue for permanently failed deliveries
|
|
119
|
+
- Track delivery status: queued → sent → delivered → opened → clicked/dismissed
|
|
120
|
+
|
|
121
|
+
6. **Deduplication:**
|
|
122
|
+
```
|
|
123
|
+
Dedup key = hash(notification_type + user_id + content_hash)
|
|
124
|
+
Dedup window = configurable per type (default: 1 hour)
|
|
125
|
+
|
|
126
|
+
If same dedup key seen within window:
|
|
127
|
+
- Suppress duplicate
|
|
128
|
+
- Log suppression (for debugging)
|
|
129
|
+
- Update existing notification if content changed
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Template System
|
|
133
|
+
|
|
134
|
+
7. **Notification templates:**
|
|
135
|
+
```
|
|
136
|
+
Template: order_shipped
|
|
137
|
+
Channels: push, email
|
|
138
|
+
Personalization tokens: {{user.first_name}}, {{order.id}}, {{order.tracking_url}}
|
|
139
|
+
|
|
140
|
+
Push:
|
|
141
|
+
title: "Your order is on its way!"
|
|
142
|
+
body: "{{user.first_name}}, order #{{order.id}} has shipped. Track it here."
|
|
143
|
+
action_url: "{{order.tracking_url}}"
|
|
144
|
+
|
|
145
|
+
Email:
|
|
146
|
+
subject: "Order #{{order.id}} shipped"
|
|
147
|
+
template_id: "tmpl_order_shipped_v2"
|
|
148
|
+
variables: {first_name, order_id, tracking_url, items}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Rules:
|
|
152
|
+
- Templates support multi-language (locale selected from user preferences)
|
|
153
|
+
- Preview rendering available before send (catch token errors)
|
|
154
|
+
- Version templates (never edit in place — create new version, deprecate old)
|
|
155
|
+
- A/B test notification copy via experiment-design skill
|
|
156
|
+
|
|
157
|
+
## Self-check before task completion
|
|
158
|
+
|
|
159
|
+
Before marking a task done when this skill was active:
|
|
160
|
+
|
|
161
|
+
- [ ] Did I define an urgency matrix mapping notification types to channels?
|
|
162
|
+
- [ ] Are frequency caps defined per-user, per-channel with aggregation rules?
|
|
163
|
+
- [ ] Do user preferences support global, channel, and category-level control?
|
|
164
|
+
- [ ] Is DND (do not disturb) implemented with timezone awareness?
|
|
165
|
+
- [ ] Is delivery at-least-once with deduplication via idempotency keys?
|
|
166
|
+
- [ ] Are retries exponential with a dead letter queue for failures?
|
|
167
|
+
- [ ] Are templates versioned, multi-language, and previewable?
|
|
168
|
+
- [ ] Are Critical/security notifications exempt from caps but still respect DND?
|