dsh-open-dream-rsi 0.3.1 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -40,8 +40,8 @@ directory holding your `tasks.json`:
40
40
 
41
41
  ```bash
42
42
  # from the npm registry, a tarball, a checkout, or straight from GitHub — pick one:
43
- dsh plugin --profile <name> add dsh-open-dream-rsi # or pin: dsh-open-dream-rsi@0.2.1
44
- dsh plugin --profile <name> add /path/to/dsh-open-dream-rsi-0.2.1.tgz
43
+ dsh plugin --profile <name> add dsh-open-dream-rsi # or pin: dsh-open-dream-rsi@0.3.1
44
+ dsh plugin --profile <name> add /path/to/dsh-open-dream-rsi-0.3.1.tgz
45
45
  dsh plugin --profile <name> add /path/to/open-dream-rsi/plugins/deepseek_harness
46
46
  dsh plugin --profile <name> add github:patrykorwat/open-dream-rsi#path:plugins/deepseek_harness
47
47
 
@@ -58,6 +58,27 @@ dsh plugin --profile <name> add "github:patrykorwat/open-dream-rsi#<sha>&path:pl
58
58
  (The pin must point at a commit that already contains this directory —
59
59
  pnpm fetches sources, not releases.)
60
60
 
61
+ ## Updating
62
+
63
+ The bundle is self-contained (the Python server is vendored, no pip, no
64
+ build step), so updating is a re-install of the same package id:
65
+
66
+ ```bash
67
+ dsh plugin --profile <name> add dsh-open-dream-rsi
68
+ ```
69
+
70
+ Installed from git instead? Pin a commit that already contains the bundle
71
+ files — an older sha registers a synthetic `0.0.0` package and dsh dies in
72
+ `resolveBundleDir`:
73
+
74
+ ```bash
75
+ dsh plugin --profile <name> add github:patrykorwat/open-dream-rsi#<sha>&path:plugins/deepseek_harness
76
+ ```
77
+
78
+ Verify the installed version afterwards with your profile's plugin list
79
+ (see `dsh plugin --help`). Re-installs never touch your memory:
80
+ `tasks.json` / `.dream_rsi` live beside the directory dsh launches from.
81
+
61
82
  ## Install (stdio, `--patch` overlay)
62
83
 
63
84
  1. Make the server importable (not on PyPI — install from the repo):
@@ -46,7 +46,7 @@ from open_dream_rsi.bench_policy import (
46
46
  run_policy_benchmark,
47
47
  )
48
48
 
49
- __version__ = "0.2.1"
49
+ __version__ = "0.3.9"
50
50
 
51
51
  __all__ = [
52
52
  "DiscoveryTree",
@@ -19,8 +19,8 @@ import json
19
19
  import shutil
20
20
  import tempfile
21
21
  import time
22
- from dataclasses import asdict, dataclass, field
23
- from typing import Any, Callable, Dict, List, Optional
22
+ from dataclasses import asdict, dataclass
23
+ from typing import Any, Dict, List, Optional
24
24
 
25
25
  from open_dream_rsi.loop import AutoRSIRuntime, Task
26
26
  from open_dream_rsi.memory import DreamMemory
@@ -57,7 +57,7 @@ def _make_client(provider: str, model: Optional[str]) -> Any:
57
57
  def _default_tasks() -> List[Task]:
58
58
  from open_dream_rsi.dashboard import DEMOS
59
59
 
60
- return [Task(max_attempts=3, **t) for t in DEMOS]
60
+ return [Task(**{**t, "max_attempts": 3}) for t in DEMOS]
61
61
 
62
62
 
63
63
  def run_arm(
@@ -85,6 +85,9 @@ def run_arm(
85
85
  # benchmarks (bench-policy) — keep the machinery under test pure.
86
86
  enable_knowledge=False,
87
87
  enable_thoughts=False,
88
+ # Published arm numbers are byte-stable: the fair queue must not
89
+ # reorder these tasks (benchmarks size their budget per task set).
90
+ fair_queue=False,
88
91
  )
89
92
  runtime.api_calls_used = 0
90
93
  report = runtime.run_once()
@@ -20,6 +20,11 @@ expansion strategy differs):
20
20
  * ``evolved_policy`` — the loop asks the LLM for a policy program per
21
21
  category, gates it by counterfactual rollout, and (on evidence) steers
22
22
  online expansion with the promoted code.
23
+ * ``sentinel_guided`` — same, but the recorded tree carries structured
24
+ Sentinel facts: nodes whose error class keeps repeating are recorded
25
+ BLOCKED (choice removal, the TravelPlanner-measured mechanism), and the
26
+ promoted policy reads ``sentinel_blocked`` to skip them — structure
27
+ over luck: no epsilon, no lessons, no thoughts.
23
28
 
24
29
  The scripted model plays two roles deterministically (like ``MockLLM`` in
25
30
  ``bench.py``): a task solver following the family ladder, and a policy
@@ -37,10 +42,13 @@ import re
37
42
  import tempfile
38
43
  import time
39
44
  from dataclasses import asdict, dataclass, field
40
- from typing import Any, Dict, List, Optional, Sequence
45
+ from typing import Any, Dict, List, Sequence
46
+
47
+ from pathlib import Path
41
48
 
42
49
  from open_dream_rsi.loop import AutoRSIRuntime, Task
43
50
  from open_dream_rsi.memory import DreamMemory
51
+ from open_dream_rsi.sentinel import SentinelEngine, SentinelObservation
44
52
 
45
53
  # ---------------------------------------------------------------------------
46
54
  # The decoy-trap suite. Each category has exactly three code families whose
@@ -64,7 +72,6 @@ class TrapSuite:
64
72
  promising: str
65
73
  fix: str
66
74
  low: str
67
- low: str
68
75
 
69
76
 
70
77
  TRAP_SUITES: List[TrapSuite] = [
@@ -156,6 +163,63 @@ TRAP_LESSON_TEXT = (
156
163
  )
157
164
 
158
165
 
166
+ #: The policy program the scripted policy-writer returns when the recorded
167
+ #: tree carries Sentinel repeats (the generation prompt's tree summary shows
168
+ #: ``same_error=`` lines): the structural explorer (oldest fresh node,
169
+ #: periodic root re-entry) restricted to nodes whose error class has NOT
170
+ #: kept repeating. The blocked facts prune the dead side-chains from the
171
+ #: exploration queue, so the promising branch is reached with fewer live
172
+ #: attempts; on a fact-free tree the same code reduces to the plain
173
+ #: explorer (asserted in tests/test_bench_policy.py).
174
+ SENTINEL_EXPLORER_POLICY = """
175
+ def choose_action(frontier, step):
176
+ if not frontier:
177
+ return None
178
+ def born(n):
179
+ tail = n['node_id'].rsplit('/', 1)[-1]
180
+ digits = ''.join(ch for ch in tail if ch.isdigit())
181
+ return int(digits) if digits else -1
182
+ clean = [n for n in frontier if not n.get('sentinel_blocked')]
183
+ pool = clean or frontier
184
+ fresh = [n for n in pool if n['children'] == 0]
185
+ if fresh and step % 3 != 0:
186
+ return min(fresh, key=born)['node_id']
187
+ return min(pool, key=born)['node_id']
188
+ """
189
+
190
+
191
+ class _RepeatBlockSentinel:
192
+ """Benchmark-side engine wrapper: repeats become BLOCKED (choice removal).
193
+
194
+ The runtime's ``observe_structured()`` path records replay-safe facts on
195
+ each node; this wrapper composes the TravelPlanner-measured mechanism —
196
+ once an error class has repeated >= threshold inside the episode, the
197
+ observation is marked blocked, so the frontier feature (and any policy
198
+ reading it) treats the branch as removed. Pure composition: the engine
199
+ itself never blocks (SentinelObservation is rebuilt, never mutated).
200
+ """
201
+
202
+ def __init__(self, engine: SentinelEngine, repeat_threshold: int) -> None:
203
+ self.engine = engine
204
+ self.repeat_threshold = int(repeat_threshold)
205
+
206
+ def observe_structured(self, tool, result, session_id, status=None,
207
+ error_message=None, budget=None, blocked=False):
208
+ obs = self.engine.observe_structured(
209
+ tool, result, session_id, status=status,
210
+ error_message=error_message, budget=budget, blocked=blocked)
211
+ if (obs.error_class is not None
212
+ and obs.in_session_count >= self.repeat_threshold):
213
+ obs = SentinelObservation(
214
+ signature=obs.signature, error_class=obs.error_class,
215
+ in_session_count=obs.in_session_count,
216
+ cross_session_count=obs.cross_session_count,
217
+ recurring=obs.recurring, finalize_nudge=obs.finalize_nudge,
218
+ budget_used=obs.budget_used, budget_total=obs.budget_total,
219
+ blocked=True)
220
+ return obs
221
+
222
+
159
223
  #: One-line PLAN texts the scripted solver states per code family when
160
224
  #: thoughts are requested (system prompt mentions PLAN). Plain English — no
161
225
  #: family code appears here, so the ideas ledger can never leak code into
@@ -262,6 +326,10 @@ class TrapSolver:
262
326
  user = messages[-1]["content"]
263
327
  if "exploration policy" in system:
264
328
  self.policy_calls += 1
329
+ if "same_error=" in user:
330
+ # the tree summary shows Sentinel repeats: write the
331
+ # blocked-aware explorer instead of the plain round-robin
332
+ return f"```python\n{SENTINEL_EXPLORER_POLICY}\n```"
265
333
  return f"```python\n{EXPLORER_POLICY}\n```"
266
334
  if "knowledge curator" in system:
267
335
  self.curator_calls += 1
@@ -338,6 +406,15 @@ ARMS: Dict[str, Dict[str, Any]] = {
338
406
  # KB. Any improvement over epsilon_greedy is attributable to thoughts.
339
407
  "thought_guided": dict(enable_policy_code=False, enable_knowledge=False,
340
408
  explore_epsilon=0.3, enable_thoughts=True),
409
+ # Sentinel-guided arm: the runtime gets a repeat-block Sentinel engine
410
+ # (wired by run_policy_arm from the sentinel_repeat_block key, which
411
+ # must never reach AutoRSIRuntime itself); the LLM-written policy reads
412
+ # sentinel_blocked and stops re-picking nodes whose error class keeps
413
+ # repeating — the TravelPlanner choice-removal mechanism, ported to
414
+ # exploration structure. No epsilon, no lessons, no thoughts.
415
+ "sentinel_guided": dict(enable_policy_code=True, enable_knowledge=False,
416
+ enable_thoughts=False, explore_epsilon=0.0,
417
+ sentinel_repeat_block=2),
341
418
  }
342
419
 
343
420
 
@@ -376,17 +453,31 @@ def run_policy_arm(arm: str, cfg: Dict[str, Any], cycles: int, budget: int,
376
453
  t0 = time.time()
377
454
  total_solves = total_calls = total_policy = total_curator = 0
378
455
  rates: List[List[float]] = []
456
+ # The sentinel arm wires a repeat-block engine into the runtime: error
457
+ # classes repeating >= threshold inside the episode are recorded BLOCKED
458
+ # on the node, surfacing as the sentinel_blocked frontier feature the
459
+ # promoted policy reads. The raw SentinelEngine only observes; the
460
+ # repeat->blocked mapping is the benchmark composition of the
461
+ # TravelPlanner gate (choice removal recorded on the world).
462
+ block_cfg = int(cfg.get("sentinel_repeat_block") or 0)
463
+ arm_cfg = {k: v for k, v in cfg.items() if k != "sentinel_repeat_block"}
379
464
  for seed in seeds:
380
465
  tasks = _trap_tasks()
381
466
  solver = TrapSolver()
382
467
  root = tempfile.mkdtemp(prefix=f"odr-polbench-{arm}-")
468
+ engine = None
469
+ if block_cfg:
470
+ engine = _RepeatBlockSentinel(
471
+ SentinelEngine(state_path=Path(root) / "sentinel_state.json"),
472
+ block_cfg)
383
473
  rates.append([])
384
474
  for c in range(cycles):
385
475
  memory = DreamMemory(root) # persistent across cycles within a run
386
476
  runtime = AutoRSIRuntime(
387
477
  client=solver, memory=memory, tasks=tasks,
388
478
  api_call_budget=budget, dream_iterations=dream_iterations,
389
- rng_seed=seed * 100 + c, **cfg,
479
+ rng_seed=seed * 100 + c, fair_queue=False,
480
+ sentinel_engine=engine, **arm_cfg,
390
481
  )
391
482
  runtime.api_calls_used = 0
392
483
  report = runtime.run_once()
@@ -450,11 +541,14 @@ def to_markdown(summary: Dict[str, Any]) -> str:
450
541
  "trap tasks and then burns its whole budget re-polishing the decoy; "
451
542
  "replay-gated LLM-written policies reach the hidden fixes and reuse "
452
543
  "them as warm starts; the curated knowledge base lets epsilon alone "
453
- "spend luck elsewhere because the trap itself is remembered.", ""]
544
+ "spend luck elsewhere because the trap itself is remembered; the "
545
+ "sentinel-guided arm re-derives the same escape from structured "
546
+ "failure facts — nodes whose error class keeps repeating are "
547
+ "skipped, no luck and no lesson text required.", ""]
454
548
  return "\n".join(lines)
455
549
 
456
550
 
457
- def to_svg(summary: Dict[str, Any], width: int = 860, height: int = 300,
551
+ def to_svg(summary: Dict[str, Any], width: int = 960, height: int = 300,
458
552
  theme: str = "dark") -> str:
459
553
  """Grouped bar chart: solve rate (%) per cycle per arm. Pure SVG, no deps.
460
554
 
@@ -465,9 +559,11 @@ def to_svg(summary: Dict[str, Any], width: int = 860, height: int = 300,
465
559
  cycles = summary["cycles"]
466
560
  dark = theme == "dark"
467
561
  colors = ({"greedy": "#e5534b", "epsilon_greedy": "#d4a72c", "evolved_policy": "#3fb950",
468
- "knowledge_curator": "#58a6ff", "thought_guided": "#bc8cff"} if dark else
562
+ "knowledge_curator": "#58a6ff", "thought_guided": "#bc8cff",
563
+ "sentinel_guided": "#f0883e"} if dark else
469
564
  {"greedy": "#c0392b", "epsilon_greedy": "#b8860b", "evolved_policy": "#1e7d3c",
470
- "knowledge_curator": "#1f6fb2", "thought_guided": "#6f42c1"})
565
+ "knowledge_curator": "#1f6fb2", "thought_guided": "#6f42c1",
566
+ "sentinel_guided": "#d97706"})
471
567
  palette = dict(bg="#0d1117", grid="#21262d", axis="#8b949e", text="#c9d1d9") if dark \
472
568
  else dict(bg="#ffffff", grid="#d8dee4", axis="#57606a", text="#24292f")
473
569
  pad_l, pad_r, pad_t, pad_b = 48, 16, 30, 46
@@ -510,7 +606,7 @@ def to_svg(summary: Dict[str, Any], width: int = 860, height: int = 300,
510
606
  lx += 150
511
607
  parts.append(f'<text x="{pad_l}" y="18" fill="{palette["text"]}" font-size="13" '
512
608
  f'font-weight="600">Decoy-trap suite — solve rate per cycle '
513
- f'(greedy vs ε-greedy vs replay-gated policies vs curated KB vs thoughts)</text>')
609
+ f'({len(arms)} arms, mean over {summary.get("runs", 1)} seeds)</text>')
514
610
  parts.append("</svg>")
515
611
  return "\n".join(parts)
516
612
 
@@ -60,6 +60,7 @@ def cmd_loop(args: argparse.Namespace) -> int:
60
60
  interval_seconds=args.interval,
61
61
  max_tokens=args.max_tokens,
62
62
  enable_policy_code=not args.no_policy_code,
63
+ enable_evolution_stop=bool(getattr(args, "evolution_stop", False)),
63
64
  enable_knowledge=not args.no_knowledge,
64
65
  enable_thoughts=not args.no_thoughts,
65
66
  enable_judge=not args.no_judge,
@@ -108,6 +109,7 @@ def cmd_sessions(args: argparse.Namespace) -> int:
108
109
  from open_dream_rsi.sessions import (
109
110
  episode_failures,
110
111
  load_episodes,
112
+ read_claude_code_sessions,
111
113
  read_cursor_sessions,
112
114
  read_hermes_sessions,
113
115
  write_episodes,
@@ -119,6 +121,9 @@ def cmd_sessions(args: argparse.Namespace) -> int:
119
121
  source=args.filter,
120
122
  limit=args.limit,
121
123
  redact=not args.no_redact)
124
+ elif args.source == "claude":
125
+ eps = read_claude_code_sessions(args.db, limit=args.limit,
126
+ redact=not args.no_redact)
122
127
  else:
123
128
  # --db accepts either the Cursor User dir or a state.vscdb copy
124
129
  db_arg = args.db
@@ -242,7 +247,8 @@ def cmd_dream(args: argparse.Namespace) -> int:
242
247
  cost), so any trigger — a Hermes hook, the MCP tool, or this CLI —
243
248
  can fire as often as it likes without overrunning the budget."""
244
249
  from open_dream_rsi.dream import dream_once
245
- from open_dream_rsi.sessions import default_cursor_user_dir
250
+ from open_dream_rsi.sessions import (default_claude_projects_dir,
251
+ default_cursor_user_dir)
246
252
 
247
253
  client = None
248
254
  if not args.offline:
@@ -251,6 +257,9 @@ def cmd_dream(args: argparse.Namespace) -> int:
251
257
  # the Cursor store is a User DIR (state.vscdb inside), not a db file
252
258
  sessions_db = args.sessions or args.cursor_user_dir \
253
259
  or str(default_cursor_user_dir())
260
+ elif args.source == "claude":
261
+ # Claude Code transcripts live in a projects DIR of JSONL files
262
+ sessions_db = args.sessions or str(default_claude_projects_dir())
254
263
  else:
255
264
  sessions_db = args.sessions
256
265
  report = dream_once(
@@ -263,10 +272,12 @@ def cmd_dream(args: argparse.Namespace) -> int:
263
272
 
264
273
 
265
274
  def cmd_lessons(args: argparse.Namespace) -> int:
266
- """Git-backed lesson stores: publish active lessons, import others'
275
+ """Git-backed stores: publish lessons/worlds/policies, import others'
267
276
  knowledge as staging (see README 'Sharing lessons')."""
268
277
  from open_dream_rsi.share import (LessonShareError, export_lessons,
269
- import_lessons, store_status)
278
+ export_policies, export_worlds,
279
+ import_lessons, import_policies,
280
+ import_worlds, store_status)
270
281
 
271
282
  memory = DreamMemory(args.memory)
272
283
  try:
@@ -283,6 +294,31 @@ def cmd_lessons(args: argparse.Namespace) -> int:
283
294
  print(f"[odr] {cat}: +{n} staging lesson(s) — activate via "
284
295
  f"the paired-replay gate (odr loop)")
285
296
  return 0
297
+ elif args.lessons_cmd == "worlds-export":
298
+ st = export_worlds(memory, args.store, task_ids=args.task,
299
+ message=args.message, push=not args.no_push)
300
+ elif args.lessons_cmd == "worlds-import":
301
+ counts = import_worlds(args.store, memory, task_ids=args.task)
302
+ if not counts:
303
+ print("[odr] nothing imported (empty/filtered store)")
304
+ return 0
305
+ for tid, n in sorted(counts.items()):
306
+ print(f"[odr] {tid}: imported world ({n} nodes) -> "
307
+ f"trees/imported/{tid}.json (evidence, never a live task)")
308
+ return 0
309
+ elif args.lessons_cmd == "policies-export":
310
+ st = export_policies(memory, args.store, categories=args.category,
311
+ message=args.message, push=not args.no_push)
312
+ elif args.lessons_cmd == "policies-import":
313
+ counts = import_policies(args.store, memory,
314
+ categories=args.category)
315
+ if not counts:
316
+ print("[odr] nothing imported (empty/filtered store)")
317
+ return 0
318
+ for cat, n in sorted(counts.items()):
319
+ print(f"[odr] {cat}: +{n} policy program(s) registered as "
320
+ f"CANDIDATE->VALIDATED in the ALM (adoption stays local)")
321
+ return 0
286
322
  else: # status
287
323
  st = store_status(args.store)
288
324
  except LessonShareError as exc:
@@ -293,13 +329,59 @@ def cmd_lessons(args: argparse.Namespace) -> int:
293
329
  else:
294
330
  print(f"[odr] store: {st.location} "
295
331
  f"({'git' if st.git else 'plain dir'}, ok={st.ok})")
332
+ label = {"export": "lesson(s)", "worlds-export": "node(s)",
333
+ "policies-export": "program(s)"}.get(args.lessons_cmd, "entry")
296
334
  for cat, n in sorted(st.categories.items()):
297
- print(f" {cat}: {n} lesson(s)")
335
+ if ":" in cat: # status mixes sections; derive the label per key
336
+ label = {"world": "node(s)", "policy": "program(s)"}[
337
+ cat.split(":", 1)[0]]
338
+ print(f" {cat}: {n} {label}")
339
+ else:
340
+ print(f" {cat}: {n} {label}")
298
341
  for e in st.errors:
299
342
  print(f" ! {e}")
300
343
  return 0 if st.ok else 1
301
344
 
302
345
 
346
+ def cmd_holdout(args: argparse.Namespace) -> int:
347
+ """Single-use holdout reservations: a preregistered eval task is consumed
348
+ once; a later phase cannot silently reuse it (see README 'Holdout hygiene')."""
349
+ from open_dream_rsi.holdout import HoldoutRegistry, split_reserved
350
+
351
+ reg = HoldoutRegistry(args.memory)
352
+ if args.holdout_cmd == "claim":
353
+ refused = [t for t in args.ids if not reg.claim(t, args.purpose,
354
+ phase=args.phase)]
355
+ ok = [t for t in args.ids if t not in refused]
356
+ print(f"[odr] reserved {len(ok)} task id(s) for '{args.purpose}'"
357
+ + (f" (phase {args.phase})" if args.phase else ""))
358
+ if refused:
359
+ print(f"[odr] REFUSED (already held for another purpose): "
360
+ f"{', '.join(refused)}", file=sys.stderr)
361
+ return 1
362
+ return 0
363
+ if args.holdout_cmd == "release":
364
+ released = [t for t in args.ids if reg.release(t)]
365
+ print(f"[odr] released {len(released)} reservation(s): "
366
+ f"{', '.join(released) or '(none)'}")
367
+ return 0
368
+ if args.holdout_cmd == "show":
369
+ entries = reg.entries()
370
+ if not entries:
371
+ print("[odr] no reservations")
372
+ for tid, meta in sorted(entries.items()):
373
+ print(f" {tid} purpose={meta.get('purpose')}"
374
+ + (f" phase={meta['phase']}" if meta.get("phase") else ""))
375
+ return 0
376
+ # split: report which tasks of a queue file are holdout-reserved
377
+ tasks = json.loads(Path(args.tasks).read_text(encoding="utf-8"))
378
+ allowed, held = split_reserved(tasks, reg)
379
+ print(f"[odr] {len(allowed)} allowed, {len(held)} holdout-reserved")
380
+ for t in held:
381
+ print(f" held: {t.get('task_id') if isinstance(t, dict) else t}")
382
+ return 0
383
+
384
+
303
385
  def cmd_skills(args: argparse.Namespace) -> int:
304
386
  """Render the curated lesson KB into Hermes-style skills (issue #3
305
387
  boundary: only lessons that EARNED activation become a prompt)."""
@@ -354,6 +436,8 @@ def cmd_artifacts(args: argparse.Namespace) -> int:
354
436
  def main(argv: list[str] | None = None) -> int:
355
437
  parser = argparse.ArgumentParser(prog="odr", description="Open Dream-RSI autonomous supervisor")
356
438
  parser.add_argument("--memory", default=".dream_rsi", help="memory directory (one per instance)")
439
+ from open_dream_rsi import __version__ as _v
440
+ parser.add_argument("--version", action="version", version=f"open-dream-rsi {_v}")
357
441
  sub = parser.add_subparsers(dest="command", required=True)
358
442
 
359
443
  loop = sub.add_parser("loop", help="run the self-improvement cycle")
@@ -369,6 +453,10 @@ def main(argv: list[str] | None = None) -> int:
369
453
  loop.add_argument("--dream-iters", type=int, default=60)
370
454
  loop.add_argument("--no-policy-code", action="store_true",
371
455
  help="disable LLM-written exploration policies (section-3 step)")
456
+ loop.add_argument("--evolution-stop", action="store_true",
457
+ help="anytime-valid stopping for policy evolution "
458
+ "(freeze regeneration after a betting-martingale "
459
+ "alarm; the last promoted policy stays active)")
372
460
  loop.add_argument("--no-knowledge", action="store_true",
373
461
  help="disable the knowledge curator (lessons.json KB, section-4 step)")
374
462
  loop.add_argument("--no-thoughts", action="store_true",
@@ -392,9 +480,11 @@ def main(argv: list[str] | None = None) -> int:
392
480
  dr.add_argument("--sessions", default=None,
393
481
  help="host session store to import evidence from "
394
482
  "(hermes: state.db path; cursor: the User dir)")
395
- dr.add_argument("--source", default="hermes", choices=["hermes", "cursor"],
483
+ dr.add_argument("--source", default="hermes",
484
+ choices=["hermes", "cursor", "claude"],
396
485
  help="kind of the --sessions store (default hermes; "
397
- "cursor reads state.vscdb directly, no MCP needed)")
486
+ "cursor reads state.vscdb directly, no MCP needed; "
487
+ "claude reads ~/.claude/projects JSONL)")
398
488
  dr.add_argument("--cursor-user-dir", default=None,
399
489
  help="Cursor User dir for --source cursor (default: the "
400
490
  "platform location, e.g. %%APPDATA%%\\Cursor\\User)")
@@ -407,7 +497,7 @@ def main(argv: list[str] | None = None) -> int:
407
497
  help="force one KB category (default: per-episode cwd)")
408
498
  dr.add_argument("--budget", type=int, default=20,
409
499
  help="max API calls for a FULL dream (default 20)")
410
- dr.add_argument("--max-tokens", type=int, default=4096)
500
+ dr.add_argument("--max-tokens", type=int, default=100_000)
411
501
  dr.add_argument("--offline", action="store_true",
412
502
  help="no LLM: lifecycle maintenance only")
413
503
  dr.set_defaults(func=cmd_dream)
@@ -452,16 +542,19 @@ def main(argv: list[str] | None = None) -> int:
452
542
 
453
543
  sess = sub.add_parser(
454
544
  "sessions",
455
- help="import host transcripts (Hermes state.db / Cursor state.vscdb) "
545
+ help="import host transcripts (Hermes state.db / Cursor "
546
+ "state.vscdb / Claude Code projects JSONL) "
456
547
  "as curator evidence — export to JSONL, then distill into "
457
548
  "staging lessons (promotion gate still decides activation)")
458
549
  sess_sub = sess.add_subparsers(dest="sessions_cmd", required=True)
459
550
 
460
551
  exp = sess_sub.add_parser("export", help="read a host store, write episodes.jsonl")
461
- exp.add_argument("--source", required=True, choices=["hermes", "cursor"])
552
+ exp.add_argument("--source", required=True,
553
+ choices=["hermes", "cursor", "claude"])
462
554
  exp.add_argument("--db", default=None,
463
- help="path to state.db (hermes) or Cursor User dir "
464
- "(default: platform Cursor location)")
555
+ help="path to state.db (hermes), the Cursor User dir, "
556
+ "or the Claude Code projects dir (default: the "
557
+ "platform location)")
465
558
  exp.add_argument("--filter", default=None,
466
559
  help="hermes only: session source filter (e.g. cli, desktop)")
467
560
  exp.add_argument("--limit", type=int, default=None)
@@ -525,11 +618,74 @@ def main(argv: list[str] | None = None) -> int:
525
618
  limp.add_argument("--category", action="append", default=None)
526
619
  limp.set_defaults(func=cmd_lessons)
527
620
 
621
+ wexp = ls_sub.add_parser("worlds-export",
622
+ help="add archived discovery trees to a store")
623
+ wexp.add_argument("--store", required=True,
624
+ help="local dir or git URL")
625
+ wexp.add_argument("--task", action="append", default=None,
626
+ help="limit to these task ids (repeatable)")
627
+ wexp.add_argument("--message", default=None, help="git commit message")
628
+ wexp.add_argument("--no-push", action="store_true",
629
+ help="commit locally but do not push")
630
+ wexp.set_defaults(func=cmd_lessons)
631
+
632
+ wimp = ls_sub.add_parser("worlds-import",
633
+ help="import a store's worlds as evidence "
634
+ "(trees/imported/, never live tasks)")
635
+ wimp.add_argument("--store", required=True, help="local dir or git URL")
636
+ wimp.add_argument("--task", action="append", default=None,
637
+ help="limit to these task ids (repeatable)")
638
+ wimp.set_defaults(func=cmd_lessons)
639
+
640
+ pexp = ls_sub.add_parser("policies-export",
641
+ help="add promoted exploration-policy programs "
642
+ "(structural gate applies on export)")
643
+ pexp.add_argument("--store", required=True, help="local dir or git URL")
644
+ pexp.add_argument("--category", action="append", default=None,
645
+ help="limit to these categories (repeatable)")
646
+ pexp.add_argument("--message", default=None, help="git commit message")
647
+ pexp.add_argument("--no-push", action="store_true",
648
+ help="commit locally but do not push")
649
+ pexp.set_defaults(func=cmd_lessons)
650
+
651
+ pimp = ls_sub.add_parser("policies-import",
652
+ help="register a store's policy programs as "
653
+ "ALM CANDIDATE->VALIDATED (never incumbents)")
654
+ pimp.add_argument("--store", required=True, help="local dir or git URL")
655
+ pimp.add_argument("--category", action="append", default=None)
656
+ pimp.set_defaults(func=cmd_lessons)
657
+
528
658
  lst = ls_sub.add_parser("status", help="verify manifest + checksums")
529
659
  lst.add_argument("--store", required=True)
530
660
  lst.add_argument("--json", action="store_true")
531
661
  lst.set_defaults(func=cmd_lessons)
532
662
 
663
+ hld = sub.add_parser(
664
+ "holdout",
665
+ help="single-use holdout reservations — a preregistered eval task "
666
+ "is consumed once; later phases cannot silently reuse it")
667
+ hld_sub = hld.add_subparsers(dest="holdout_cmd", required=True)
668
+
669
+ hc = hld_sub.add_parser("claim", help="reserve task ids for a purpose")
670
+ hc.add_argument("--ids", nargs="+", required=True, help="task id(s)")
671
+ hc.add_argument("--purpose", required=True,
672
+ help="e.g. travelplanner_eval, spolki_holdout")
673
+ hc.add_argument("--phase", default=None,
674
+ help="optional phase label recorded with the reservation")
675
+ hc.set_defaults(func=cmd_holdout)
676
+
677
+ hr = hld_sub.add_parser("release", help="forget a reservation (correction path)")
678
+ hr.add_argument("--ids", nargs="+", required=True)
679
+ hr.set_defaults(func=cmd_holdout)
680
+
681
+ hs = hld_sub.add_parser("show", help="list all reservations")
682
+ hs.set_defaults(func=cmd_holdout)
683
+
684
+ hsplit = hld_sub.add_parser(
685
+ "split", help="partition a task queue into allowed vs held-back")
686
+ hsplit.add_argument("--tasks", required=True, help="tasks JSON file")
687
+ hsplit.set_defaults(func=cmd_holdout)
688
+
533
689
  dash = sub.add_parser("dashboard", help="serve the live web dashboard")
534
690
  dash.add_argument("--host", default="0.0.0.0",
535
691
  help="bind address (default 0.0.0.0 — reachable on the LAN)")
@@ -1,4 +1,4 @@
1
- from typing import Any, Callable, Dict, List, Optional, Protocol, Tuple, runtime_checkable
1
+ from typing import Callable, Dict, List, Optional, Protocol, Tuple, runtime_checkable
2
2
 
3
3
  from open_dream_rsi.core.tree import DiscoveryTree
4
4
  from open_dream_rsi.core.dreamer import DreamEngine