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

fix(ruflo-mods): /resume also gives the next session its own rollup record; redraw after the budget reset (#3795)

Dragan Spiridonov42424201c6e8
diff --git a/plugins/ruflo-mods/hooks/cost/index.ts b/plugins/ruflo-mods/hooks/cost/index.ts
index bd94e1b2ce..57b9ded08d 100644
--- a/plugins/ruflo-mods/hooks/cost/index.ts
+++ b/plugins/ruflo-mods/hooks/cost/index.ts
@@ -24,6 +24,7 @@ export function registerCost(on: On, state: ModState, options: ModOptions) {
on('session.end', { reason: /^clear$/ }, ($, e, next) => {
announced = 'OK'
state.budget = { level: 'OK', limit }
+ redraw(state)
return next(e)
})
diff --git a/plugins/ruflo-mods/hooks/rollup/index.ts b/plugins/ruflo-mods/hooks/rollup/index.ts
index 74531f5e01..8aac105087 100644
--- a/plugins/ruflo-mods/hooks/rollup/index.ts
+++ b/plugins/ruflo-mods/hooks/rollup/index.ts
@@ -81,9 +81,9 @@ export function registerRollup(on: On, state: ModState) {
// an unwritable ledger only means this session has no record
}
}
- // /clear ends this session and the process goes on with the next (no
- // session.start fires for it): the next session gets its own counters and record.
- if (e.reason === 'clear') Object.assign(r, { tools: 0, denied: 0, spawns: 0, rung: 'OK', written: false, base: { routed: state.routed, tightened: state.tightened } })
+ // /clear and /resume end this session and the process goes on under another
+ // (no session.start fires for it): the next session gets its own counters and record.
+ if (e.reason === 'clear' || e.reason === 'resume') Object.assign(r, { tools: 0, denied: 0, spawns: 0, rung: 'OK', written: false, base: { routed: state.routed, tightened: state.tightened } })
return next(e)
}).catch(($, e, next) => next(e))
}
diff --git a/plugins/ruflo-mods/tests/rollup.test.ts b/plugins/ruflo-mods/tests/rollup.test.ts
index b14e609843..d474662e6d 100644
--- a/plugins/ruflo-mods/tests/rollup.test.ts
+++ b/plugins/ruflo-mods/tests/rollup.test.ts
@@ -125,6 +125,17 @@ describe('sessionRollup option (ADR-451 item 6)', () => {
expect((s.kv.get('sessionRollup') as Rollup[]).map(r => r.tools)).toEqual([1, 3])
})
+ test('/resume in one process also gives the next session its own record', { options: { sessionRollup: true } }, async ($, on) => {
+ boot(on)
+ const s = store(on)
+ await $.session.start(START)
+ await $.tool.call({ tool: 'Read', file_path: 'a' } as never)
+ await $.session.end({ ...(END as object), reason: 'resume' } as never)
+ for (const f of ['b', 'c']) await $.tool.call({ tool: 'Read', file_path: f } as never)
+ await $.session.end(END)
+ expect((s.kv.get('sessionRollup') as Rollup[]).map(r => r.tools)).toEqual([1, 2])
+ })
+
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 } })