feat(compaction): add proactive context budget and checkpointing

This commit is contained in:
William Valentin
2026-02-16 15:44:00 -08:00
parent 65efda3533
commit 8758ea8f1c
7 changed files with 478 additions and 1 deletions
+20
View File
@@ -1169,6 +1169,12 @@ describe('configSchema — compaction importance threshold', () => {
it('defaults compaction importance threshold to disabled behavior', () => {
const result = configSchema.parse(minimalConfig);
expect(result.compaction.importance_threshold).toBe(1);
expect(result.compaction.proactive.enabled).toBe(false);
expect(result.compaction.proactive.warn_pct).toBe(75);
expect(result.compaction.proactive.checkpoint_pct).toBe(85);
expect(result.compaction.proactive.auto_compact_pct).toBe(95);
expect(result.compaction.proactive.checkpoint_cooldown_ms).toBe(300000);
expect(result.compaction.proactive.memory_namespace).toBe('session/checkpoints');
});
it('accepts a custom importance threshold', () => {
@@ -1176,9 +1182,23 @@ describe('configSchema — compaction importance threshold', () => {
...minimalConfig,
compaction: {
importance_threshold: 0.5,
proactive: {
enabled: true,
warn_pct: 70,
checkpoint_pct: 82,
auto_compact_pct: 93,
checkpoint_cooldown_ms: 120000,
memory_namespace: 'notes/checkpoints',
},
},
});
expect(result.compaction.importance_threshold).toBe(0.5);
expect(result.compaction.proactive.enabled).toBe(true);
expect(result.compaction.proactive.warn_pct).toBe(70);
expect(result.compaction.proactive.checkpoint_pct).toBe(82);
expect(result.compaction.proactive.auto_compact_pct).toBe(93);
expect(result.compaction.proactive.checkpoint_cooldown_ms).toBe(120000);
expect(result.compaction.proactive.memory_namespace).toBe('notes/checkpoints');
});
});