Skip to content

Comments

Directory restructure + RAG token budget + persona recovery#271

Merged
joelteply merged 5 commits intomainfrom
feature/stability-cleanup
Feb 19, 2026
Merged

Directory restructure + RAG token budget + persona recovery#271
joelteply merged 5 commits intomainfrom
feature/stability-cleanup

Conversation

@joelteply
Copy link
Contributor

Summary

  • Relocate source from src/debug/jtag/ to src/ — 3596 file renames, delete root garbage (screenshots, old configs, dead scripts), delete unused Python files, update all hardcoded path references across workflows, docs, scripts
  • Token budget enforcement — ConversationHistorySource was using TOKENS_PER_MESSAGE_ESTIMATE=50 to guess message counts, causing 4-5x budget overruns and context window overflows. Now accumulates actual token counts (chars/3) and stops at the allocated budget.
  • Conversation history consolidation — Older messages that exceed token budget are compressed to "SenderName: first line..." instead of silently dropped. 85% budget for recent verbatim, 15% for consolidated older context.
  • Persona recovery from failed messages — When AI generation threw (API 400, timeout), the message bookmark was never updated, causing personas to retry the same failed message forever. Now uses try/finally to always advance the bookmark.

Test plan

  • TypeScript compiles clean (0 errors)
  • Rust tests pass (923/923)
  • npm start deploys successfully (254 commands, 17 daemons)
  • ./jtag ping confirms server + browser connected
  • All cloud providers respond (DeepSeek, Fireworks, Together, Groq confirmed)
  • Token budget proportional to model context window (verified via prompt captures)
  • Personas recover after API failures (bookmark fix confirmed)

Move all application source code up from the historical 3-level-deep
src/debug/jtag/ path to src/. Delete 155 unused root files (old configs,
debug dumps, screenshots, dead scripts). Update all hardcoded path
references across CI workflows, precommit hook, CLAUDE.md, README.md,
and ~70 documentation files.

Verified: TypeScript compiles, 923 Rust tests pass, npm start deploys
with 254 commands + 17 daemons, ping + chat working.
…token accumulation

ConversationHistorySource was converting its allocated token budget to a message
count using TOKENS_PER_MESSAGE_ESTIMATE=50, then fetching exactly that many messages
and returning ALL of them without verifying total tokens. With 200+ token messages
this caused 4-5x budget overruns and context window overflows on DeepSeek, Fireworks,
Together, and other providers.

Fix: fetch generous batch (500), convert to LLM format, iterate newest-to-oldest
accumulating actual token counts (chars/3), stop when allocated budget is exhausted.
Token budget is now the ONLY constraint — no artificial message caps.

ChatRAGBuilder: removed Math.min(50) hard cap that prevented 128K models from using
more than 50 messages. Generous fetch limit now scales with context window.
…g it

Old messages that exceed the token budget are now compressed to
"SenderName: first line..." and prepended as a conversation summary.
85% of budget goes to recent verbatim messages, 15% reserved for
consolidated older messages. The AI sees the full conversation arc
instead of losing everything beyond the cutoff.
When evaluateAndPossiblyRespondWithCognition threw (API 400, timeout,
network error), the bookmark was never updated. Rust's tick loop
re-polled the same un-bookmarked message, re-enqueued it, and the
persona retried the same failed message forever — silently stuck.

Wrap response in try/finally so the bookmark always advances.
A failed response attempt must not block the entire queue.
Copilot AI review requested due to automatic review settings February 19, 2026 01:12
@joelteply joelteply merged commit 21dc801 into main Feb 19, 2026
2 of 4 checks passed
@joelteply joelteply deleted the feature/stability-cleanup branch February 19, 2026 01:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reorganizes the codebase by relocating all source files from src/debug/jtag/ to src/, deletes obsolete build/test configuration files, removes unused Python scripts, and fixes critical issues with RAG token budget enforcement and persona message bookmark recovery.

Changes:

  • Relocated 3,596 source files from src/debug/jtag/ to src/ and updated all path references across documentation, workflows, and scripts
  • Implemented accurate token counting in ConversationHistorySource to prevent context window overflows (replaced 50-token estimates with actual char/3 calculation)
  • Added try/finally protection to persona message processing to ensure bookmarks advance even when AI generation fails

Reviewed changes

Copilot reviewed 43 out of 3818 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/api/data-seed/README.md Updated documentation paths from src/debug/jtag to src
src/README.md Updated setup instructions with new directory path
scripts/templates/.ts, scripts/.sh, scripts/*.cjs Removed unused template files and build scripts
papers/**/*.md Updated implementation file path references
docs/**/*.md Updated architecture and documentation cross-references
open-ports.txt, main.ts, lerna.json Removed obsolete tracking and configuration files
jest.config.*.js, eslint.config.js, babel.config.cjs Removed unused test and linting configuration files
archive/devtools_full_demo.py Removed obsolete Python DevTools recovery script (1,411 lines)
README.md, CLAUDE.md Updated all path references in main documentation
.github/workflows/*.yml Updated CI/CD workflow paths
.eslintrc.js, .eslintignore Removed legacy ESLint configuration files
.continuum/genome//*.md, .continuum/genome//*.sh Updated Python training script paths

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant