Skip to content

RSI Phase 2: agentic Rashi/Tosafot translation task type - #54

Open
ronshapiro wants to merge 9 commits into
basefrom
worktree-bridge-cse_013nvCXPadZwXNRyPP2mBoCF
Open

RSI Phase 2: agentic Rashi/Tosafot translation task type#54
ronshapiro wants to merge 9 commits into
basefrom
worktree-bridge-cse_013nvCXPadZwXNRyPP2mBoCF

Conversation

@ronshapiro

Copy link
Copy Markdown
Owner

Summary

Phase 2 of RecursiveSelfImprovingAgentPlan.md: the first content-generation task type, replacing the Gemini pipeline (precomputed/sugya_prompt_client.ts — left in place, unused, not deleted per instruction).

  • rsi_orchestrator/rashi_tosafot_translation.ts — for a given book, finds Rashi/Tosafot comments missing a translation or gone stale (via Phase 1's staleness.ts/generation_record.ts), and for each: asks Claude to punctuate + translate it, pointing at where the page's cached data and sugya boundaries live in the repo rather than pre-assembling context — the model decides how much it needs to read, per the plan's "goal and tools, not a scripted context-assembly function." Runs a bounded self-critique loop (generate → critique → at most one retry with feedback → give up) before writing to precomputed/ai_additions/<Book Page>.json and recording a generation record. Supports an optional [limit] CLI arg for bounded/smoke-test runs.
  • precomputed/ai_edits.ts — added writeAiEdit (read-modify-write), matching the existing aiEditsForPage read path.
  • rsi_orchestrator/headless_claude.ts — switched from --output-format text to --output-format json (probed the CLI's real output shape first) so it can report the actual model and cost per call — threaded through into each generation record, which Phase 4's model-routing learning depends on.

Test plan

  • npx jest precomputed/rsi_state rsi_orchestrator — 40 tests passing, all Claude/GitHub calls mocked via DI (no real usage spent building/testing this)
  • npx tsc --noEmit -p . — clean
  • npx eslint on all new/changed files — clean
  • Real smoke test against live-cached data (in progress alongside this PR — cache_all_api_requests.ts is populating the full local Sefaria cache in the background; will run rashi_tosafot_translation.ts <Book> <limit> against it once a book is available and report results)

🤖 Generated with Claude Code

ronshapiro and others added 5 commits August 11, 2026 03:49
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Extending Error without Object.setPrototypeOf breaks instanceof at
this project's (unset -> ES3-default) tsconfig target, which was
silently turning the rate-limit stop path into skip-and-retry-forever
under real ts-node execution (jest's babel target masked it).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ronshapiro
ronshapiro force-pushed the worktree-bridge-cse_013nvCXPadZwXNRyPP2mBoCF branch from d0860a6 to 1c7d9d4 Compare August 11, 2026 00:50
ronshapiro and others added 4 commits August 11, 2026 10:58
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sums cost across every generate/critique call (including rejected
attempts), not just the accepted one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
headless_claude.ts now switches to --output-format stream-json to
record every Read/Grep/Glob call Claude makes per request, logged to
a new context_usage_log.jsonl — raw signal for eventually learning
what context each task type actually needs, rather than a hand-picked
commentary allowlist.

Also fixes two real bugs found while validating this: the CLI's
--limit was applied before freshness filtering (a small --limit could
silently do nothing), and both triage_log.ts and context_usage_log.ts
had their test's cleanup pointed at the real production log path,
which would have deleted real accumulated data the first time either
log had real content (it just did, for context_usage_log.jsonl, and
was recovered from the git index before this commit).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ronshapiro added a commit that referenced this pull request Aug 11, 2026
Context-provisioning, budget/scheduling, and review-surface redesign
addressing real issues found in live runs (context wandering, no
spend pacing, no review gate).

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
ronshapiro added a commit that referenced this pull request Aug 11, 2026
Brings in PR #54's work (staleness enum, headless_claude model
pinning/rate-limit handling/tool-use capture, the translation task
type, and the design retrospective from real runs) that was still
unmerged upstream.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ronshapiro added a commit that referenced this pull request Aug 12, 2026
… routing) (#56)

* RSI Phase 2: agentic Rashi/Tosafot translation task type

Brings in PR #54's work (staleness enum, headless_claude model
pinning/rate-limit handling/tool-use capture, the translation task
type, and the design retrospective from real runs) that was still
unmerged upstream.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* RSI redesign Phase 1: JIT ref-addressed context fetching

Replaces raw Read/Grep/Glob access to the full cached page file with
a narrow context_fetch_cli tool (get-refs/get-neighbors/get-prior-sugyot)
plus a compact page skeleton and worked examples inlined in the prompt.
Auto-populates generation records' dependsOn from what was actually
fetched, instead of always [].

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* RSI redesign: per-task-type model routing config

Replaces the hardcoded MODEL constant with model_routing_config.json,
read via model_routing.ts, so a future routing tuner can propose
changes from logged outcomes instead of a hand-edited constant.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* RSI redesign: human-driven budget/schedule + status visibility

Adds budget_config.json (hand-edited enable/caps/pause per task
type, ships disabled by default), status_cli.ts for call-count/cost
visibility against those caps, and schedule_runner.ts as the bounded
per-tick cron/launchd entrypoint that honors the config. Folds
per-call cost/model logging into context_usage_log.jsonl (added a
`model` field) instead of a separate spend ledger, since the two
would otherwise track nearly identical data.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Address PR review comments

- parseRefLocation: replace the "on"-string heuristic and manual
  book-prefix loop with books.parse() over successive token suffixes
  — structural, not a hardcoded string convention.
- getTaskModelConfig: throw when a task type has no config entry
  instead of silently falling back to a hardcoded default.
- generationPrompt: throw if the page isn't cached instead of
  degrading to "(page not cached)" in the prompt text.
- context_fetch_cli.ts: use yargs (consistent with the sibling CLI)
  instead of hand-rolled argv parsing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant