diff --git a/claude/claude-plugin/funes/scripts/funes-index.sh b/claude/claude-plugin/funes/scripts/funes-index.sh index a3b18e5..2c71092 100755 --- a/claude/claude-plugin/funes/scripts/funes-index.sh +++ b/claude/claude-plugin/funes/scripts/funes-index.sh @@ -72,7 +72,7 @@ agent_version() { # of the last of them, or, before there is one, the `spool` record `setup add` wrote just before # that walk. The transcript the payload named was converted already and is skipped. The next mark is # the stamp `$3` the worker took before it converted anything, unless a conversion failed and -# dropped it. +# dropped it. The journal a workflow keeps beside its sub-agents holds no turn and is left out. convert_stale() { jq=$1 named=$2 @@ -82,7 +82,7 @@ convert_stale() { mark="$HERE/converted" since=$mark [ -e "$since" ] || since="$HERE/spool" - find "$projects" -type f -name '*.jsonl' -newer "$since" 2>/dev/null | while IFS= read -r src; do + find "$projects" -type f -name '*.jsonl' ! -name journal.jsonl -newer "$since" 2>/dev/null | while IFS= read -r src; do [ "$src" = "$named" ] || convert_one "$jq" "$src" || rm -f "$stamp" done [ ! -e "$stamp" ] || mv -f "$stamp" "$mark" diff --git a/claude/setup b/claude/setup index e51f635..5f7cc33 100755 --- a/claude/setup +++ b/claude/setup @@ -89,8 +89,9 @@ lost() { # Convert the transcripts Claude Code has already written, so recall reaches them before the next # turn. Sub-agent transcripts nest under their session's directory and are picked up by the same -# walk. What the memory holds stays beside the scripts, where the converter reads the numbering -# each session was indexed with. +# walk. The journal a workflow keeps beside its sub-agents holds no turn and is left out. What the +# memory holds stays beside the scripts, where the converter reads the numbering each session was +# indexed with. # # The walk shares the mark the hooks' sweeps keep: every transcript older than it was converted as # it stands, by the walk that stamped it or by a sweep since. So a re-run reads the transcripts @@ -115,9 +116,9 @@ seed() { indexed >"$rows.new" : >"$stamp" if [ -e "$mark" ] && [ ! -e "$legacy" ] && [ -f "$rows" ] && ! lost "$rows" "$rows.new"; then - find "$projects" -type f -name '*.jsonl' -newer "$mark" + find "$projects" -type f -name '*.jsonl' ! -name journal.jsonl -newer "$mark" else - find "$projects" -type f -name '*.jsonl' + find "$projects" -type f -name '*.jsonl' ! -name journal.jsonl fi >"$work/transcripts" || true mv -f "$rows.new" "$rows" awk 'NF == 3 { print $1, $2 }' "$rows" >"$work/indexed" diff --git a/claude/test/hooks.sh b/claude/test/hooks.sh index f002f7c..4098f1e 100755 --- a/claude/test/hooks.sh +++ b/claude/test/hooks.sh @@ -93,13 +93,18 @@ await() { fail "$2" } -# Two sessions written after the install: the hook fires for one of them only. +# Two sessions written after the install, and the journal a workflow keeps beside its sub-agents: +# the hook fires for one of the sessions only. tick transcript a.jsonl transcript b.jsonl +journal="$tree/a/subagents/workflows/wf_1/journal.jsonl" +mkdir -p "${journal%/*}" +printf '%s\n' '{"type":"started","agentId":"agent-1","key":"review"}' >"$journal" fire [ -f "$spool/a.funes.jsonl" ] || fail "the session the payload named was not converted" [ -f "$spool/b.funes.jsonl" ] || fail "the session whose hook never fired was not converted" +[ ! -e "$spool/journal.funes.jsonl" ] || fail "a workflow's journal was converted" [ -f "$scripts/converted" ] || fail "the sweep left no mark" # A third, written after that run; the second, drained by funes meanwhile, is not re-emitted. diff --git a/claude/test/setup.sh b/claude/test/setup.sh index 345b3b0..ce6de4b 100755 --- a/claude/test/setup.sh +++ b/claude/test/setup.sh @@ -38,6 +38,11 @@ mkdir -p "$tree" done cat "$BUNDLE/claude-plugin/funes/test/session.jsonl" } >"$tree/session.jsonl" +# The journal a workflow keeps beside its sub-agents: records the converter makes no turn of. +journal="$tree/session/subagents/workflows/wf_1/journal.jsonl" +mkdir -p "${journal%/*}" +printf '%s\n' '{"type":"started","agentId":"agent-1","key":"review"}' \ + '{"type":"result","agentId":"agent-1","key":"review","result":"ok"}' >"$journal" cp -R "$BUNDLE" "$HOME/.funes/agents/claude" setup="$HOME/.funes/agents/claude/setup" @@ -68,6 +73,7 @@ if grep -q acme/kb "$hooks"; then fail "the memory is in the hook command"; fi [ "$(cat "$plugin/funes/scripts/memory")" = acme/kb ] || fail "no memory file" [ "$(cat "$plugin/funes/scripts/spool")" = "$FUNES_HOME/spool/claude" ] || fail "the spool is not recorded" [ -f "$FUNES_HOME/spool/claude/session.funes.jsonl" ] || fail "the history was not seeded" +[ ! -e "$FUNES_HOME/spool/claude/journal.funes.jsonl" ] || fail "a workflow's journal was converted" mark="$plugin/funes/scripts/converted" [ -f "$mark" ] || fail "the walk left no mark" [ ! -e "$plugin/funes/scripts/swept" ] || fail "the mark of the earlier hooks stays" @@ -130,6 +136,7 @@ age_mark "$setup" add acme/kb >/dev/null [ ! -e "$older" ] || fail "a transcript older than the mark was read" [ ! -e "$seeded" ] || fail "a transcript whose last turn is indexed was converted again" +[ ! -e "$FUNES_HOME/spool/claude/journal.funes.jsonl" ] || fail "a workflow's journal newer than the mark was converted" # The rows stay beside the scripts, for the converter. [ "$(cat "$plugin/funes/scripts/indexed")" = "other 2026-10-01T09:30:00.000Z 4 $id $last 5" ] || fail "the memory's rows were not kept: $(cat "$plugin/funes/scripts/indexed")"