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): keep guidance observations independent of route ownership (the e2e contract); keep rung and dropped-id fixes

ruvc259ce957521
diff --git a/plugins/ruflo-mods/hooks/guidance/index.ts b/plugins/ruflo-mods/hooks/guidance/index.ts
index 9afa33cdbf..8952215983 100644
--- a/plugins/ruflo-mods/hooks/guidance/index.ts
+++ b/plugins/ruflo-mods/hooks/guidance/index.ts
@@ -6,7 +6,7 @@ import { MAX_PROJECTION_BYTES, parseProjection, PROJECTION_PATH, selectGuidance
export type GuidanceHooks = {
start: () => void
- prompt: (text: string, fs: FileHost, record: boolean) => Promise<string | undefined>
+ prompt: (text: string, fs: FileHost) => Promise<string | undefined>
active: () => ActiveTask | undefined
check: (task: ActiveTask | undefined, decision: unknown) => void
tool: (task: ActiveTask | undefined, event: unknown, result: { deny?: unknown; isError?: boolean }) => void
@@ -29,10 +29,9 @@ export function createGuidance(state: ModState, options: ModOptions): GuidanceHo
start() {
if (!s.runId) { s.runId = newRunId(); s.status = 'missing' }
},
- async prompt(text, fs, record) {
+ async prompt(text, fs) {
if (!s.runId) return undefined
- const learn = options.guidanceLearning && record // a project that does not own routing records nothing
- if (learn) finishTask(s, 'interrupted')
+ if (options.guidanceLearning) finishTask(s, 'interrupted')
const read = await projection({
stat: async path => {
const stat = await fs.stat(path)
@@ -44,7 +43,7 @@ export function createGuidance(state: ModState, options: ModOptions): GuidanceHo
s.status = read.kind === 'ok' ? 'ready' : read.kind === 'absent' ? 'missing' : 'unreadable'
if (read.kind !== 'ok') return undefined
const selected = selectGuidance(text, read.value)
- if (learn) {
+ if (options.guidanceLearning) {
s.active = { taskId: ++s.taskSeq, projection: read.value, ruleIds: options.guidanceContext ? selected.ids : [], checks: { allow: 0, ask: 0, deny: 0 }, tools: { ok: 0, error: 0, denied: 0 }, toolIds: new Set(), idsDropped: 0 }
}
return options.guidanceContext ? selected.context : undefined
diff --git a/plugins/ruflo-mods/hooks/route/index.ts b/plugins/ruflo-mods/hooks/route/index.ts
index e5a8fecb34..6552ac4ecc 100644
--- a/plugins/ruflo-mods/hooks/route/index.ts
+++ b/plugins/ruflo-mods/hooks/route/index.ts
@@ -23,7 +23,7 @@ export function registerRoute(on: On, state: ModState, options: ModOptions, guid
on('prompt.submit', async ($, e, next) => {
const text = typeof e.text === 'string' ? e.text : ''
if (state.agentTrim.enabled) state.agentTrim.prompt = text.slice(0, 4000).toLowerCase() // agent.offer keeps a type the prompt names
- const advisory = guidance ? await guidance.prompt(text, { stat: path => $.fs.stat(path), read: path => $.fs.read(path) }, state.owned.has('route')) : undefined
+ const advisory = guidance ? await guidance.prompt(text, { stat: path => $.fs.stat(path), read: path => $.fs.read(path) }) : undefined
const context = [...(e.context ?? []), ...(advisory ? [advisory] : [])]
if (!state.owned.has('route')) return next(advisory ? { ...e, context } : e)
const result = routeTask(text)
diff --git a/plugins/ruflo-mods/tests/guidance.test.ts b/plugins/ruflo-mods/tests/guidance.test.ts
index 644228dde4..69b73ec121 100644
--- a/plugins/ruflo-mods/tests/guidance.test.ts
+++ b/plugins/ruflo-mods/tests/guidance.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, test, tier } from 'claude-code/testing'
-import { HELPER, prompt, ROOT, START, world } from './fixtures/world'
+import { prompt, ROOT, START, world } from './fixtures/world'
tier('user')
@@ -77,21 +77,6 @@ describe('guidance (ADR-447)', () => {
expect(queued(w.files).length).toBe(0)
})
- test('a project that does not own routing records no observations but still gets guidance context', { options }, async ($, on) => {
- const classic = { hooks: { UserPromptSubmit: [{ hooks: [{ command: 'node "$CLAUDE_PROJECT_DIR/.claude/helpers/hook-handler.cjs" route' }] }] } }
- const w = world(on, classic, { [PATH]: projection(), [HELPER]: '// an older helper' })
- let context = ''
- on('prompt.submit', ($, e) => { context = e.context?.join('\n') ?? ''; return { text: e.text } })
- on('tool.call', () => ({ result: 'ok' }))
- on('turn.complete', ($, e) => ({ text: e.answer }))
- await $.session.start(START)
- await $.prompt.submit(prompt('Write parser tests'))
- await $.tool.call({ tool: 'Read', file_path: 'a' })
- await $.turn.complete(complete('t1'))
- expect(context).toContain('TEST-001')
- expect(queued(w.files).length).toBe(0)
- })
-
test('tool ids past the per-task cap are counted and the report says how many', { options }, async ($, on) => {
world(on, {}, { [PATH]: projection() })
on('prompt.submit', ($, e) => ({ text: e.text }))