Skip to content

Commit 21dc801

Browse files
authored
Directory restructure + RAG token budget + persona recovery (#271)
* Relocate source from src/debug/jtag/ to src/ + root cleanup 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 budget enforcement: replace guessed message counts with actual 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. * Fix remaining src/debug/jtag path references across docs, scripts, and configs * Consolidate overflow conversation history instead of silently dropping 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. * Fix persona stuck on failed messages: always advance bookmark 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.
1 parent b3bcdee commit 21dc801

File tree

3,818 files changed

+324
-71733
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,818 files changed

+324
-71733
lines changed

.continuum/genome/SETUP-COMPLETE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
### 2. TypeScript Integration
3131

3232
**Modified Files:**
33-
- `src/debug/jtag/system/genome/fine-tuning/server/adapters/UnslothLoRAAdapter.ts`
33+
- `src/system/genome/fine-tuning/server/adapters/UnslothLoRAAdapter.ts`
3434
- `supportsFineTuning()`: Checks if environment bootstrapped
3535
- `executeUnslothTraining()`: Uses wrapper script (auto-activates conda)
3636
- Clear error messages if environment missing
@@ -299,7 +299,7 @@ If Unsloth import fails, training falls back to standard PyTorch (slower but wor
299299
300300
.gitignore # MODIFIED - Added genome paths
301301
302-
src/debug/jtag/system/genome/fine-tuning/server/adapters/
302+
src/system/genome/fine-tuning/server/adapters/
303303
└── UnslothLoRAAdapter.ts # MODIFIED - Uses wrapper script
304304
```
305305

@@ -319,7 +319,7 @@ src/debug/jtag/system/genome/fine-tuning/server/adapters/
319319
## Questions?
320320

321321
**Setup issues:** See `.continuum/genome/python/README.md`
322-
**Architecture questions:** See `src/debug/jtag/system/user/server/modules/PERSONA-CONVERGENCE-ROADMAP.md`
322+
**Architecture questions:** See `src/system/user/server/modules/PERSONA-CONVERGENCE-ROADMAP.md`
323323
**Training errors:** Run test script first to verify environment
324324

325325
**Philosophy:** "Test the shit out of it" - Every piece is validated before integration.

.continuum/genome/python/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ python3 -c "import unsloth; print(unsloth.__version__)"
101101

102102
```bash
103103
.continuum/genome/python/train-wrapper.sh \
104-
src/debug/jtag/system/genome/fine-tuning/server/adapters/scripts/peft-train.py \
104+
src/system/genome/fine-tuning/server/adapters/scripts/peft-train.py \
105105
--config config.json \
106106
--output output/
107107
```
@@ -245,5 +245,5 @@ If training fails with unclear errors:
245245
4. Check logs in temporary test directory
246246

247247
For architecture questions, see:
248-
- `src/debug/jtag/system/user/server/modules/PERSONA-CONVERGENCE-ROADMAP.md`
249-
- `src/debug/jtag/system/user/server/modules/LORA-GENOME-PAGING.md`
248+
- `src/system/user/server/modules/PERSONA-CONVERGENCE-ROADMAP.md`
249+
- `src/system/user/server/modules/LORA-GENOME-PAGING.md`

.continuum/genome/python/test-training.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ echo ""
7575
mkdir -p "$TEST_DIR/output"
7676

7777
if "$SCRIPT_DIR/train-wrapper.sh" \
78-
"$(dirname "$SCRIPT_DIR")/../../src/debug/jtag/system/genome/fine-tuning/server/adapters/scripts/unsloth-train.py" \
78+
"$(dirname "$SCRIPT_DIR")/../../src/system/genome/fine-tuning/server/adapters/scripts/unsloth-train.py" \
7979
--config "$TEST_DIR/config.json" \
8080
--output "$TEST_DIR/output"; then
8181

.eslintignore

Lines changed: 0 additions & 17 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
defaults:
1313
run:
14-
working-directory: src/debug/jtag
14+
working-directory: src
1515

1616
steps:
1717
- uses: actions/checkout@v4
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
node-version: '20'
2323
cache: 'npm'
24-
cache-dependency-path: src/debug/jtag/package-lock.json
24+
cache-dependency-path: src/package-lock.json
2525

2626
- name: Install dependencies
2727
run: npm ci

.github/workflows/dependencies.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ on:
44
push:
55
branches: [ main ]
66
paths:
7-
- 'src/debug/jtag/package.json'
8-
- 'src/debug/jtag/package-lock.json'
7+
- 'src/package.json'
8+
- 'src/package-lock.json'
99
pull_request:
1010
branches: [ main ]
1111
paths:
12-
- 'src/debug/jtag/package.json'
13-
- 'src/debug/jtag/package-lock.json'
12+
- 'src/package.json'
13+
- 'src/package-lock.json'
1414
schedule:
1515
- cron: '0 0 * * 0' # Run weekly on Sunday at midnight
1616

@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
defaults:
2121
run:
22-
working-directory: src/debug/jtag
22+
working-directory: src
2323

2424
steps:
2525
- uses: actions/checkout@v4
@@ -29,7 +29,7 @@ jobs:
2929
with:
3030
node-version: '20'
3131
cache: 'npm'
32-
cache-dependency-path: src/debug/jtag/package-lock.json
32+
cache-dependency-path: src/package-lock.json
3333

3434
- name: Install dependencies
3535
run: npm ci

.github/workflows/validate-continuum.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ name: Validate Continuum Config
33
on:
44
pull_request:
55
paths:
6-
- 'src/debug/jtag/**'
6+
- 'src/**'
77

88
jobs:
99
validate:
1010
runs-on: ubuntu-latest
1111
defaults:
1212
run:
13-
working-directory: src/debug/jtag
13+
working-directory: src
1414

1515
steps:
1616
- uses: actions/checkout@v4
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
node-version: '20'
2222
cache: 'npm'
23-
cache-dependency-path: src/debug/jtag/package-lock.json
23+
cache-dependency-path: src/package-lock.json
2424

2525
- name: Install dependencies
2626
run: npm ci

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build/
1313
continuum-jtag-*.tgz
1414

1515
# Generated manifest files (use generated.ts instead)
16-
src/debug/jtag/manifests/
16+
src/manifests/
1717

1818
# Generated test files
1919
test-config.md
@@ -162,7 +162,7 @@ src/ui/**/*.d.ts
162162
src/commands/**/*.js
163163
src/commands/**/*.js.map
164164
src/commands/**/*.d.ts
165-
/src/debug/jtag/.archive
165+
/src/.archive
166166
.tgz
167167

168168
# Runtime directories (session data, logs, temp files)
@@ -178,4 +178,4 @@ src/commands/**/*.d.ts
178178
!CLAUDE.md
179179
!test*output.txt
180180
_archive/
181-
src/debug/jtag/.continuum/sessions/validation/
181+
src/.continuum/sessions/validation/

CLAUDE.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ let results = algo.execute(&input);
337337
4. **Repeat**
338338

339339
```bash
340-
cd src/debug/jtag
340+
cd src
341341
npm start # DEPLOYS code changes, takes 130s or so
342342

343343
./jtag ping #check for server and browser connection
@@ -970,7 +970,7 @@ npm start
970970

971971
### Documentation
972972

973-
**Full Architecture**: `src/debug/jtag/system/user/server/modules/`
973+
**Full Architecture**: `src/system/user/server/modules/`
974974
- `AUTONOMOUS-LOOP-ROADMAP.md` - RTOS-inspired servicing
975975
- `SELF-MANAGED-QUEUE-DESIGN.md` - AI autonomy through tasks
976976
- `LORA-GENOME-PAGING.md` - Virtual memory for skills
@@ -1144,7 +1144,7 @@ The AIs will:
11441144
**Fix**: Always take screenshot after deployment
11451145

11461146
### 3. WRONG WORKING DIRECTORY
1147-
**Always work from**: `src/debug/jtag`
1147+
**Always work from**: `src`
11481148
**Commands**: `./jtag` NOT `./continuum`
11491149

11501150
### 4. IGNORE EXISTING TYPES
@@ -1433,20 +1433,20 @@ grep -r "UserEntity\|ChatMessageEntity" daemons/data-daemon/ | grep -v EntityReg
14331433
# Should return zero results (except EntityRegistry.ts)
14341434
```
14351435

1436-
### **[UNIVERSAL-PRIMITIVES.md](src/debug/jtag/docs/UNIVERSAL-PRIMITIVES.md)**
1436+
### **[UNIVERSAL-PRIMITIVES.md](src/docs/UNIVERSAL-PRIMITIVES.md)**
14371437
Commands.execute() and Events.subscribe()/emit() - the two primitives everything is built on.
14381438

1439-
### **[GENERATOR-OOP-PHILOSOPHY.md](src/debug/jtag/docs/GENERATOR-OOP-PHILOSOPHY.md)** - CORE PHILOSOPHY
1439+
### **[GENERATOR-OOP-PHILOSOPHY.md](src/docs/GENERATOR-OOP-PHILOSOPHY.md)** - CORE PHILOSOPHY
14401440
Generators and OOP are intertwined parallel forces:
14411441
- Generators ensure structural correctness at creation time
14421442
- OOP/type system ensures behavioral correctness at runtime
14431443
- AIs should strive to create generators for any repeatable pattern
14441444
- This enables tree-based delegation of ability with compounding capability
14451445

14461446
### **PersonaUser Convergence Docs**
1447-
- `src/debug/jtag/system/user/server/modules/PERSONA-CONVERGENCE-ROADMAP.md`
1448-
- `src/debug/jtag/system/user/server/modules/AUTONOMOUS-LOOP-ROADMAP.md`
1449-
- `src/debug/jtag/system/user/server/modules/LORA-GENOME-PAGING.md`
1447+
- `src/system/user/server/modules/PERSONA-CONVERGENCE-ROADMAP.md`
1448+
- `src/system/user/server/modules/AUTONOMOUS-LOOP-ROADMAP.md`
1449+
- `src/system/user/server/modules/LORA-GENOME-PAGING.md`
14501450

14511451
**Quick tip**: If you're about to write code that duplicates patterns or violates architecture rules, STOP and read ARCHITECTURE-RULES.md first. Then apply the aggressive refactoring principle from this guide.
14521452

0 commit comments

Comments
 (0)