Skip to content

Feat/exploration loop#118

Open
dabing823-spec wants to merge 2 commits intoTraderAlice:masterfrom
dabing823-spec:feat/exploration-loop
Open

Feat/exploration loop#118
dabing823-spec wants to merge 2 commits intoTraderAlice:masterfrom
dabing823-spec:feat/exploration-loop

Conversation

@dabing823-spec
Copy link
Copy Markdown

No description provided.

Joy88 and others added 2 commits April 11, 2026 20:52
Adds an autonomous "閒時探索" loop: at scheduled off-market ticks (or
manual trigger via tool), Alice runs a 4-phase cycle:

  1. Guard   — skip if the user is actively chatting (session mtime guard)
  2. Recall  — load relevant skills from data/skills/ by keyword triggers
  3. Explore — askWithSession with Alice persona + recalled skills injected;
               stream tool_use events to count depth
  4. Reflect — if tool depth >= threshold, ask Alice to emit a markdown skill
               (or SKIP); persist to data/skills/{id}.md; Brain commit

Design:
- File-driven — every skill is a markdown file with yaml-ish frontmatter
  (id, triggers, created, usageCount, confidence, lastUsedAt, summary)
- Recall is simple keyword matching, not embeddings — enough at N<200
- Prune uses usage×confidence÷age so recent high-signal skills stay
- Sonnet 4.6 is the configured default model (bounded subscription cost)
- Disabled by default in exploration.json — flip enabled: true to start

New files:
  src/domain/exploration/{types,skill-curator,explorer,scheduler,index}.ts
  src/domain/exploration/__tests__/{skill-curator,explorer}.spec.ts
  src/tool/exploration.ts  (explorationRunNow / explorationStatus /
                            skillList / skillDelete tools)

Wiring:
  src/core/config.ts   — new exploration section in Config + sectionSchemas
  src/main.ts          — build curator + explorer + scheduler, register tools

Tests:
  17 new tests (9 curator, 8 explorer) covering persist/recall/prune/
  markUsed round-trip, full loop happy path, SKIP reflection, below-
  threshold skip, user-active pause, and reflection parser edge cases.

Full backend test suite: 915/915 green. Typecheck clean.
(UI test failures in this run are pre-existing worktree symlink
artifacts — confirmed passing in the real working tree.)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previous default: every hour 14:00–23:00 and 00:00–08:00 TW
(≈16 runs spread across off-peak).

New default: every 30 minutes from 23:00–06:30 TW only.
→ ~16 runs concentrated during sleep, zero runs during the day.

Rationale: per user request, maximise autonomous research while
the user is asleep; minimise token contention during peak trading
and work hours when the user is actively chatting with Alice.

Co-Authored-By: Claude Opus 4.6 (1M context) <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