"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const MemoryRetentionPolicy_1 = require("./memory/MemoryRetentionPolicy");
function assert(condition, message) {
    if (!condition)
        throw new Error(message);
}
function makeRecord(type, createdAt, confidence = 0.8) {
    return {
        id: `${type}-${createdAt}`,
        type,
        namespace: { project: 'open-life-core' },
        content: 'runtime fallback policy with cooldown and codex recovery',
        summary: 'runtime fallback policy',
        tags: ['runtime', 'fallback'],
        confidence,
        createdAt,
        updatedAt: createdAt
    };
}
async function main() {
    const retention = new MemoryRetentionPolicy_1.MemoryRetentionPolicy();
    const oldWorking = makeRecord('working', new Date(Date.now() - 10 * 24 * 60 * 60 * 1000).toISOString());
    const recentSemantic = makeRecord('semantic', new Date().toISOString(), 0.9);
    const profile = makeRecord('profile', new Date(Date.now() - 120 * 24 * 60 * 60 * 1000).toISOString(), 0.7);
    assert(retention.decide(oldWorking).keep === false, 'old working memory should expire');
    assert(retention.decide(recentSemantic).keep === true, 'recent semantic memory should be kept');
    assert(retention.decide(profile).keep === true, 'profile memory should persist');
    const recentScore = retention.score(recentSemantic, 'runtime fallback codex');
    const oldScore = retention.score(oldWorking, 'runtime fallback codex');
    assert(recentScore > oldScore, 'recent semantic memory should outrank stale working memory');
    console.log('TEST_MEMORY_RETENTION_OK');
}
main().catch((error) => {
    console.error(error.message || error);
    process.exit(1);
});
