//#region src/cognitive/persona/lifecycle.ts
const DAY_MS = 1440 * 60 * 1e3;
/**
* Compute the current lifecycle stage based on activity metrics.
*
* Transition rules:
*   new     → active   : totalExchanges >= 5
*   active  → dormant  : nowMs - lastActiveAt > 14 days
*   dormant → lapsed   : nowMs - lastActiveAt > 45 days
*
* Reactivation (dormant/lapsed → active) is handled in curator when
* the user sends a message; this function only handles time-based decay.
*/
function computeLifecycleStage(lifecycle, totalExchanges, nowMs) {
	const { stage, lastActiveAt } = lifecycle;
	const silenceMs = nowMs - lastActiveAt;
	switch (stage) {
		case "new": return totalExchanges >= 5 ? "active" : "new";
		case "active": return silenceMs > 14 * DAY_MS ? "dormant" : "active";
		case "dormant": return silenceMs > 45 * DAY_MS ? "lapsed" : "dormant";
		case "lapsed": return "lapsed";
	}
}
/**
* Whether the scheduler should attempt re-engagement for this user.
* True when dormant AND silent for more than 7 days.
*/
function shouldReEngage(lifecycle, nowMs) {
	if (lifecycle.stage !== "dormant") return false;
	return nowMs - lifecycle.lastActiveAt > 7 * DAY_MS;
}
/**
* Domain depth decay multiplier by lifecycle stage.
* Higher values = faster decay = observations are less stable.
*/
function getDecayMultiplier(lifecycle) {
	switch (lifecycle.stage) {
		case "active": return 1;
		case "new": return 1.5;
		case "dormant": return 2;
		case "lapsed": return 3;
	}
}
/**
* Factor to multiply optimalFrequencyHours by.
* Higher = less frequent proactive contact.
*/
function getProactiveFrequencyFactor(lifecycle) {
	switch (lifecycle.stage) {
		case "active": return 1;
		case "new": return 2;
		case "dormant": return .5;
		case "lapsed": return 3;
	}
}
//#endregion
export { shouldReEngage as i, getDecayMultiplier as n, getProactiveFrequencyFactor as r, computeLifecycleStage as t };
