Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

test(ruflo-mods): the /clear rollup record keeps the ending session's rung, the next starts at OK (#3795)

ruve5d887af4340
diff --git a/plugins/ruflo-mods/tests/rollup.test.ts b/plugins/ruflo-mods/tests/rollup.test.ts
index d474662e6d..7516f901dd 100644
--- a/plugins/ruflo-mods/tests/rollup.test.ts
+++ b/plugins/ruflo-mods/tests/rollup.test.ts
@@ -136,6 +136,19 @@ describe('sessionRollup option (ADR-451 item 6)', () => {
expect((s.kv.get('sessionRollup') as Rollup[]).map(r => r.tools)).toEqual([1, 2])
})
+ test('/clear records the ending session\'s rung, then the budget starts over for the next one (#3795)', { options: { sessionRollup: true, costBudgetUsd: 2 } }, async ($, on) => {
+ boot(on)
+ const s = store(on)
+ on('session.measure', ($, e) => ({ changed: e.changed }))
+ await $.session.start(START)
+ for (const usd of [1.1, 1.7]) await $.session.measure({ context: { window: 200_000 }, rateLimits: [], cost: { usd }, changed: ['cost' as const] })
+ await $.session.end({ ...(END as object), reason: 'clear' } as never)
+ await $.session.measure({ context: { window: 200_000 }, rateLimits: [], cost: { usd: 0.1 }, changed: ['cost' as const] })
+ await $.session.end(END)
+ // The first record is written before the budget resets, so it keeps WARNING; the second session starts at OK.
+ expect((s.kv.get('sessionRollup') as Rollup[]).map(r => r.cost)).toEqual(['WARNING', 'OK'])
+ })
+
test('a hostile stored ledger is treated as empty and replaced by one clean record', { options: { sessionRollup: true } }, async ($, on) => {
boot(on)
const s = store(on, { __proto__: 1, length: 1e9, 0: { at: 1 } })