fix(loop): guard empty vector-memory block against set -e crash - #11
Open
allenter wants to merge 3 commits into
Open
fix(loop): guard empty vector-memory block against set -e crash#11allenter wants to merge 3 commits into
allenter wants to merge 3 commits into
Conversation
Layer a zero-dependency, pure-Python vector memory store (memories/vault/) on top of the existing single-file consensus baton: - scripts/core/memory_vault.py: chunk consensus + docs, index into memories/vault/index.json (TF-IDF char n-grams + cosine similarity, no external deps), and semantic search with -top-k / min-score. Backend swappable: replace _embed_chunk() to plug in ChromaDB or a model embedding. - auto-loop.sh: each cycle auto-retrieves the top relevant historical blocks (keyed off Next Action) and injects them into the prompt as '## Highly-relevant past memory'; after a successful/soft-timeout cycle it indexes the latest consensus + docs into the vault. - .gitignore: ignore memories/vault/* runtime data. - Docs updated: README(EN/ZH), CLAUDE.md, PROMPT.md, INDEX.md. consensus.md remains the authoritative running-state baton; the vault adds long-term recall of decisions/context that consensus collapses.
Add a Memory Vault panel to the control deck: - server.py: new GET /api/vault endpoint. Reads memories/vault/index.json directly (no subprocess) and returns stats (chunk/source/term counts, size, last-indexed), per-source breakdown, latest entries, plus optional in-process cosine semantic search via ?q=. - app.js: fetchVault() renderer with stat cards, a canvas bar chart of chunks per source, latest-entry list, and a live semantic-search box (Enter or button) showing scored hits with source tags. - index.html: Memory Vault section between Consensus and Recent Log. - styles.css: dark-theme styles for stats, canvas, entries, tags. Pure stdlib on the server side; canvas drawn client-side.
Fresh clones crash on the very first cycle: with an empty vector vault MEMORY_BLOCK is "", so the `$([ -n "$MEMORY_BLOCK" ] && printf ...)` command substitution returns 1 and set -euo pipefail kills the loop right after Cycle MaxMiksa#1 [START], before any cycle log is written. Append `|| true` so the substitution is a no-op when the block is empty and behaves exactly as before otherwise. Verified with empty and non-empty blocks, and a fresh-clone run completing 3 cycles. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: fix(loop): 修复首次运行时空向量记忆导致 set -e 崩溃
问题描述
全新 clone 后首次运行
make start,循环在 Cycle #1 启动瞬间静默退出(exit 1),无任何 cycle 结果写入日志。复现步骤
git clone仓库(无memories/vault/)make startCycle #1 [START]后进程立刻以 exit 1 退出,logs/无 cycle 日志根因
scripts/core/auto-loop.sh主循环构建FULL_PROMPT时:首次运行时
memories/vault/为空,vault_retrieve_prompt返回空字符串 →MEMORY_BLOCK=""。此时[ -n "$MEMORY_BLOCK" ]为假,&&短路,命令替换$(...)返回 exit code 1。而脚本顶部启用了set -euo pipefail,非零的命令替换导致整个脚本以 exit 1 终止。修复
|| true保证空块时命令替换返回 0,非空块时行为完全不变。验证
MEMORY_BLOCK:脚本正常通过 prompt 构建,进入循环MEMORY_BLOCK:记忆块正常注入 prompt,格式不变变更文件
scripts/core/auto-loop.sh(1 行)测试建议
bash -n scripts/core/auto-loop.shmake start,确认能进入 Cycle Add local dashboard launcher and improve macOS runtime support #1 而不退出Co-Authored-By: Claude noreply@anthropic.com