🌊 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(ruflo-mods): the observation queue and a quoted path no longer read as "missing" (#3793)
Dragan Spiridonov061efa3b40f6
diff --git a/plugins/ruflo-mods/hooks/files.ts b/plugins/ruflo-mods/hooks/files.tsindex c3da4b89f0..7ddc5e7570 100644--- a/plugins/ruflo-mods/hooks/files.ts+++ b/plugins/ruflo-mods/hooks/files.ts@@ -23,7 +23,11 @@ export type Read<T> =* Anything else is an error: for the guard that means failing closed, so a* loosely matched message must never read as "no policy here".*/-export const isMissing = (error: unknown) => /\bENOENT\b/.test(String((error as Error)?.message ?? error))+export const isMissing = (error: unknown, path?: string) => {+ const message = String((error as Error)?.message ?? error)+ // The path a message quotes is the caller's own word, not the error: a project under ".../ENOENT-x/" is not missing.+ return /\bENOENT\b/.test(path ? message.split(path).join('') : message)+}/*** A reader that parses a project file once per change: one `$.fs.stat` per@@ -47,7 +51,7 @@ export function cachedFile<T>(pathOf: () => string, parse: (text: string) => T)key = `${path}:${stat.size}:${stat.mtimeMs}`} catch (error) {seen = undefined- return isMissing(error) ? { kind: 'absent' } : { kind: 'error', message: String(error) }+ return isMissing(error, path) ? { kind: 'absent' } : { kind: 'error', message: messageOf(error) }}if (seen?.key === key) return seen.read@@ -69,7 +73,7 @@ async function readAndParse<T>(fs: FileHost, path: string, parse: (text: string)try {text = await fs.read(path)} catch (error) {- return isMissing(error) ? { kind: 'absent' } : { kind: 'error', message: messageOf(error) }+ return isMissing(error, path) ? { kind: 'absent' } : { kind: 'error', message: messageOf(error) }}try {return { kind: 'ok', value: parse(text) }diff --git a/plugins/ruflo-mods/hooks/guidance/observations.ts b/plugins/ruflo-mods/hooks/guidance/observations.tsindex d86643d40f..e25740fd20 100644--- a/plugins/ruflo-mods/hooks/guidance/observations.ts+++ b/plugins/ruflo-mods/hooks/guidance/observations.ts@@ -86,14 +86,23 @@ export function flushObservations(s: GuidanceState, path: string, fs: { read: (ps.flush = s.flush.then(async () => {if (!s.pending.length) returnlet previous: Observation[] = []+ let existing: string | undefinedtry {- const text = await fs.read(path)- if (text.length > MAX_QUEUE_CHARS) return- const parsed = JSON.parse(text)+ existing = await fs.read(path)+ } catch (error) {+ // Only the read can say "no queue yet"; a parse error can quote the file's own text.+ if (!isMissing(error, path)) return+ }+ if (existing !== undefined) {+ if (existing.length > MAX_QUEUE_CHARS) return+ let parsed: unknown+ try {+ parsed = JSON.parse(existing)+ } catch {+ return+ }if (!Array.isArray(parsed) || parsed.length > MAX_OBSERVATIONS || parsed.some(r => !validObservation(r) || r.runId !== s.runId) || new Set(parsed.map(r => r.id)).size !== parsed.length) returnprevious = parsed- } catch (error) {- if (!isMissing(error)) return}const ids = new Set(previous.map(r => r.id))const additions = s.pending.filter(r => !ids.has(r.id))diff --git a/plugins/ruflo-mods/tests/register.test.ts b/plugins/ruflo-mods/tests/register.test.tsindex 6a9ce098cd..647af215c7 100644--- a/plugins/ruflo-mods/tests/register.test.ts+++ b/plugins/ruflo-mods/tests/register.test.ts@@ -2,6 +2,8 @@ import { describe, expect, test, tier } from 'claude-code/testing'import type { Plugin } from 'claude-code/testing'import { HELPER, prompt, ROOT, START, world } from './fixtures/world'+import { cachedFile, isMissing } from '../hooks/files'+import { flushObservations, guidanceState } from '../hooks/guidance/observations'tier('user')@@ -221,3 +223,23 @@ describe('register', () => {expect((await $.command.run({ command: 'ruflo-console', args: 'mods', origin: { kind: 'composer' }, presentation: { isFullscreen: false, columns: 100 } })).text).toBe(alias.text)})})++describe('missing means the read said ENOENT, not that some text did (#3793)', () => {+ test('a quoted path containing ENOENT is not "missing"; a real ENOENT still is', async () => {+ const path = '/home/u/ENOENT-repo/.claude-flow/policy/claude-code.json'+ expect(isMissing(new Error(`EACCES: permission denied, open '${path}'`), path)).toBe(false)+ expect(isMissing(new Error(`ENOENT: no such file or directory, open '${path}'`), path)).toBe(true)+ const read = cachedFile(() => path, text => text)+ const fs = { stat: async () => ({ kind: 'file', size: 1, mtimeMs: 1, isLink: false }) as never, read: async () => { throw new Error(`EACCES: permission denied, open '${path}'`) } }+ expect((await read(fs)).kind).toBe('error')+ })++ test('a corrupt observation queue whose text quotes ENOENT is never overwritten', async () => {+ const s = guidanceState()+ s.runId = 'mod-a-b-c'+ s.pending = [{ id: 'x' } as never]+ const writes: string[] = []+ await flushObservations(s, '/q.json', { read: async () => '[{"id": ENOENT', write: async (_p, t) => void writes.push(t) })+ expect(writes).toEqual([])+ })+})