feat: RAG everywhere -- every model call sees past context #82

Merged
joshtronic merged 1 commit from feat/rag-everywhere into master 2026-05-22 04:56:00 +00:00
Owner

Previously RAG was wired into exactly one path -- the discretionary
site-work Claude block. The other three Claude Code paths (tier-1
issue work, maintenance, PR-review) and all four harness-side
executors (agent-read, agent-post, agent-reflect-read,
agent-reflect-ideas) built their prompts without past-context
retrieval. Cross-tick continuity was a coin flip -- got it for the
one block that knew about it, missed it everywhere else.

Factored a shared lib/rag.sh with two helpers:

ensure_rag_built lazy + idempotent per-tick build. First model
call in a tick pays the ~25s flush+rebuild;
subsequent calls share via a marker file keyed
by $IGOR_TICK_PID (which tick.sh now exports so
child scripts find the same marker). Failures
return non-zero and the caller proceeds with
no context.

rag_query auto-calls ensure_rag_built if needed, then
runs rag.py query -k 5, returns the markdown
blob on stdout. Empty on any failure.

rag_cleanup_marker tick.sh's cleanup traps hook this so the
per-tick marker doesn't accumulate in
$IGOR_STATE_DIR/rag-built/.

Wired into:

tick.sh maintenance Claude path query: "maintenance pass on "
tick.sh PR-review Claude path query: PR title + body
tick.sh tier-1 Claude path query: issue title + body
tick.sh discretionary site-work query: $W_IN_FLIGHT (was: only path)
agent-read.sh query: the URL
agent-post.sh query: the blog idea
agent-reflect-read.sh query: "reading source "
agent-reflect-ideas.py query: the tick's output context

Each user message gets a "## Past context (RAG)" section appended
with the retrieved snippets, or a "(no past context retrieved this
tick)" placeholder when the build/query failed. The placeholder
keeps the prompt shape stable across success and degraded modes so
downstream parsing doesn't need a branch.

agent-reflect-ideas.py is Python; can't source bash directly, so it
invokes lib/rag.sh's rag_query via subprocess with the inherited
env. Same shape, same outcome.

Build cost: ~25s the first time any path needs it in a tick. Ticks
that exit early (no claimable work + no discretionary fire, lock
held, shift gate closed) never call into ensure_rag_built and pay
nothing -- the laziness is the whole point. After the first build
within a tick, all subsequent queries hit redis and return in ~1-2s.

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

Previously RAG was wired into exactly one path -- the discretionary site-work Claude block. The other three Claude Code paths (tier-1 issue work, maintenance, PR-review) and all four harness-side executors (agent-read, agent-post, agent-reflect-read, agent-reflect-ideas) built their prompts without past-context retrieval. Cross-tick continuity was a coin flip -- got it for the one block that knew about it, missed it everywhere else. Factored a shared lib/rag.sh with two helpers: ensure_rag_built lazy + idempotent per-tick build. First model call in a tick pays the ~25s flush+rebuild; subsequent calls share via a marker file keyed by $IGOR_TICK_PID (which tick.sh now exports so child scripts find the same marker). Failures return non-zero and the caller proceeds with no context. rag_query <text> auto-calls ensure_rag_built if needed, then runs rag.py query -k 5, returns the markdown blob on stdout. Empty on any failure. rag_cleanup_marker tick.sh's cleanup traps hook this so the per-tick marker doesn't accumulate in $IGOR_STATE_DIR/rag-built/. Wired into: tick.sh maintenance Claude path query: "maintenance pass on <repo>" tick.sh PR-review Claude path query: PR title + body tick.sh tier-1 Claude path query: issue title + body tick.sh discretionary site-work query: $W_IN_FLIGHT (was: only path) agent-read.sh query: the URL agent-post.sh query: the blog idea agent-reflect-read.sh query: "reading source <url>" agent-reflect-ideas.py query: the tick's output context Each user message gets a "## Past context (RAG)" section appended with the retrieved snippets, or a "(no past context retrieved this tick)" placeholder when the build/query failed. The placeholder keeps the prompt shape stable across success and degraded modes so downstream parsing doesn't need a branch. agent-reflect-ideas.py is Python; can't source bash directly, so it invokes lib/rag.sh's rag_query via subprocess with the inherited env. Same shape, same outcome. Build cost: ~25s the first time any path needs it in a tick. Ticks that exit early (no claimable work + no discretionary fire, lock held, shift gate closed) never call into ensure_rag_built and pay nothing -- the laziness is the whole point. After the first build within a tick, all subsequent queries hit redis and return in ~1-2s. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
feat: RAG everywhere -- every model call sees past context
All checks were successful
Lint / check-sync (push) Successful in 5s
Lint / check-sync (pull_request) Successful in 5s
e03c6897f2
Previously RAG was wired into exactly one path -- the discretionary
site-work Claude block. The other three Claude Code paths (tier-1
issue work, maintenance, PR-review) and all four harness-side
executors (agent-read, agent-post, agent-reflect-read,
agent-reflect-ideas) built their prompts without past-context
retrieval. Cross-tick continuity was a coin flip -- got it for the
one block that knew about it, missed it everywhere else.

Factored a shared lib/rag.sh with two helpers:

  ensure_rag_built     lazy + idempotent per-tick build. First model
                       call in a tick pays the ~25s flush+rebuild;
                       subsequent calls share via a marker file keyed
                       by $IGOR_TICK_PID (which tick.sh now exports so
                       child scripts find the same marker). Failures
                       return non-zero and the caller proceeds with
                       no context.

  rag_query <text>     auto-calls ensure_rag_built if needed, then
                       runs rag.py query -k 5, returns the markdown
                       blob on stdout. Empty on any failure.

  rag_cleanup_marker   tick.sh's cleanup traps hook this so the
                       per-tick marker doesn't accumulate in
                       $IGOR_STATE_DIR/rag-built/.

Wired into:

  tick.sh maintenance Claude path    query: "maintenance pass on <repo>"
  tick.sh PR-review Claude path      query: PR title + body
  tick.sh tier-1 Claude path         query: issue title + body
  tick.sh discretionary site-work    query: $W_IN_FLIGHT (was: only path)
  agent-read.sh                      query: the URL
  agent-post.sh                      query: the blog idea
  agent-reflect-read.sh              query: "reading source <url>"
  agent-reflect-ideas.py             query: the tick's output context

Each user message gets a "## Past context (RAG)" section appended
with the retrieved snippets, or a "(no past context retrieved this
tick)" placeholder when the build/query failed. The placeholder
keeps the prompt shape stable across success and degraded modes so
downstream parsing doesn't need a branch.

agent-reflect-ideas.py is Python; can't source bash directly, so it
invokes lib/rag.sh's rag_query via subprocess with the inherited
env. Same shape, same outcome.

Build cost: ~25s the first time any path needs it in a tick. Ticks
that exit early (no claimable work + no discretionary fire, lock
held, shift gate closed) never call into ensure_rag_built and pay
nothing -- the laziness is the whole point. After the first build
within a tick, all subsequent queries hit redis and return in ~1-2s.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
joshtronic deleted branch feat/rag-everywhere 2026-05-22 04:56:00 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
joshtronic/igor!82
No description provided.