feat(cortex): Epic 0 - Foundation & Context voor V2 architectuur
Implementeert de basis voor de Cortex V2 three-layer architecture. E0.S1 - CortexContext Types (lib/cortex/types.ts): - EscalationReason type voor Reflex → Orchestrator - LocalClassificationResult met ambiguity detection - CortexContext voor AI classificatie context - IntentChain en IntentAction voor multi-intent flows - NudgeSuggestion voor proactieve suggesties - CONFIDENCE_THRESHOLD (0.7) en AMBIGUITY_THRESHOLD (0.1) - getCurrentShift() utility (DRY - herbruikbaar) E0.S2 - Context API (app/api/cortex/context/route.ts): - GET endpoint voor huidige context - Haalt agenda vandaag op uit database - Retourneert CortexContext object E0.S3 - Feature Flags (lib/config/feature-flags.ts): - CORTEX_V2_ENABLED, CORTEX_MULTI_INTENT - CORTEX_NUDGE, CORTEX_LOGGING - isFeatureEnabled() helper - Dev mode: default true E0.S4 - CortexStore V2 (stores/cortex-store.ts): - Types geïmporteerd uit lib/cortex (DRY) - ChatEntities type voor AI responses (string-based) - V2 state: context, activeChain, chainHistory, suggestions - V2 actions: chain management, nudge management, clarification E0.S5 - Classification Logging (lib/cortex/logger.ts): - PII sanitization (BSN, tel, namen, email) - logClassification(), logEscalation(), logNudge() - logPerformance() met threshold checks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
46
lib/config/feature-flags.ts
Normal file
46
lib/config/feature-flags.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Feature Flags for Cortex V2
|
||||
*
|
||||
* Controls gradual rollout of new features.
|
||||
* In development, all flags default to true for testing.
|
||||
*/
|
||||
|
||||
/** Feature flag definitions */
|
||||
export const FEATURE_FLAGS = {
|
||||
/** Enable Cortex V2 architecture (Reflex + Orchestrator) */
|
||||
CORTEX_V2_ENABLED: process.env.NEXT_PUBLIC_CORTEX_V2 === 'true',
|
||||
|
||||
/** Enable multi-intent detection and ActionChainCard */
|
||||
CORTEX_MULTI_INTENT: process.env.NEXT_PUBLIC_CORTEX_MULTI_INTENT === 'true',
|
||||
|
||||
/** Enable proactive nudge suggestions */
|
||||
CORTEX_NUDGE: process.env.NEXT_PUBLIC_CORTEX_NUDGE === 'true',
|
||||
|
||||
/** Enable classification logging (dev only) */
|
||||
CORTEX_LOGGING: process.env.NEXT_PUBLIC_CORTEX_LOGGING === 'true',
|
||||
} as const;
|
||||
|
||||
/** Type for feature flag keys */
|
||||
export type FeatureFlagKey = keyof typeof FEATURE_FLAGS;
|
||||
|
||||
/**
|
||||
* Check if a feature flag is enabled
|
||||
*/
|
||||
export function isFeatureEnabled(flag: FeatureFlagKey): boolean {
|
||||
// In development, default to true if env var not set
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
const envValue = process.env[`NEXT_PUBLIC_${flag}`];
|
||||
// Only return false if explicitly set to 'false'
|
||||
return envValue !== 'false';
|
||||
}
|
||||
return FEATURE_FLAGS[flag];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all enabled features (useful for debugging)
|
||||
*/
|
||||
export function getEnabledFeatures(): FeatureFlagKey[] {
|
||||
return (Object.keys(FEATURE_FLAGS) as FeatureFlagKey[]).filter(
|
||||
(flag) => isFeatureEnabled(flag)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user