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-console): /ruflo dump evolve (and claude -p) wait for the flywheel file read; evolve reads keep their own cache

ruvc211e32b64b9
diff --git a/plugins/ruflo-console/hooks/dispatch.ts b/plugins/ruflo-console/hooks/dispatch.ts
index 52f917f9b2..02815477f1 100644
--- a/plugins/ruflo-console/hooks/dispatch.ts
+++ b/plugins/ruflo-console/hooks/dispatch.ts
@@ -8,6 +8,7 @@ import { CATALOG_PATH, commandsText, FALLBACK, parseCatalog, type Catalog } from
import type { Controller } from './controller'
import { median, p95 } from './controller'
import { plain } from './data/parse'
+import { loadEvolve } from './evolve'
import { labAnswer } from './mh-lab'
import { VIEWS, type State } from './state'
import { barText } from './views/bar'
@@ -59,6 +60,8 @@ async function dumpOf(control: Controller, state: State, view: State['view']): P
try {
await control.refresh()
await Promise.race([control.probe(true), new Promise(resolve => setTimeout(resolve, DUMP_WAIT_MS))])
+ // Self-Evolution draws from its own file read, which opening the view starts: a dump waits for it too.
+ if (view === 'evolve') await loadEvolve(state, control.host)
return viewText({ state, nowMs: Date.now(), columns: 100, act: control.actions }, view)
} finally {
diff --git a/plugins/ruflo-console/hooks/evolve.ts b/plugins/ruflo-console/hooks/evolve.ts
index 5533b0f2c5..23cdea2262 100644
--- a/plugins/ruflo-console/hooks/evolve.ts
+++ b/plugins/ruflo-console/hooks/evolve.ts
@@ -12,6 +12,7 @@
import type { ActionSpec } from './actions'
import { MANIFEST_PATHS, OSES, parseGate, parseLedger, parsePolicyLedger, parseWitness, readEvolve, shortRef, type EvolveFiles, type Os } from './data/evolve'
import { jsonAfter } from './data/cli'
+import type { ReadCache } from './data/files'
import { plain, recordOf } from './data/parse'
import type { Host } from './host'
import { labLines, LAB_MAX_LINES, PROMOTE_COMMAND } from './mh-lab'
@@ -192,6 +193,8 @@ export function evolveSpec(entry: EvolveEntry, state: State): ActionSpec | null
export const evolveWhy = (entry: EvolveEntry): string => entry.why ?? 'it cannot run now'
const reading = new WeakMap<State, Promise<void>>()
+/** The view's own read cache: shared with the disk pass, its files would count as state writes there. */
+const caches = new WeakMap<State, ReadCache>()
/** Reads the evolution files again (opening the view, r, â–¸ reread); a read already running is joined. */
export function loadEvolve(state: State, host: Host): Promise<void> {
@@ -202,7 +205,11 @@ export function loadEvolve(state: State, host: Host): Promise<void> {
state.evolve.isReading = true
host.invalidate()
- const run = readEvolve(host.fs, state.cache, state.cwd, Date.now())
+ const cache = caches.get(state) ?? new Map()
+
+ caches.set(state, cache)
+
+ const run = readEvolve(host.fs, cache, state.cwd, Date.now())
.then(files => {
state.evolve.files = files
})
diff --git a/plugins/ruflo-console/tests/views.test.ts b/plugins/ruflo-console/tests/views.test.ts
index 77919dd4f8..1fb5292dce 100644
--- a/plugins/ruflo-console/tests/views.test.ts
+++ b/plugins/ruflo-console/tests/views.test.ts
@@ -386,6 +386,9 @@ describe('views', () => {
mock.clock(on)
await $.session.start(SESSION)
+ // Headless, before the view was ever opened, the dump waits for the same file read.
+ expect((await $.command.run(command('dump evolve'))).text).toContain('dddddddd champion')
+
const { text, tree, rasters } = await drawn($, 'evolve')
const buttons = elementsOf(tree, 'Button').map(keyOf)