← Starchild Wiki

Self-Learning Loop自学习闭环

In-session write → background consolidation → promotion / retirement → audit — a fully automated knowledge loop piggybacked on bg_review对话内写入 → 后台巩固 → 晋升/淘汰 → 审计——全部搭载 bg_review 的全自动知识闭环

Starchild Engineering · 2026 · bg_review · zero resident processes零常驻进程

1Overview总览

Self-learning is a closed loop — write in-session, consolidate in the background, promote or retire, audit everything. There are no resident processes: every step piggybacks on bg_review, the background review with a 6-hour cooldown, and each step carries its own budget and kill switch.self-learning 是一条闭环:对话内写入、后台巩固、晋升/淘汰、全程审计。无常驻进程——每一步都搭载在 bg_review(6 小时冷却的后台复查)上,且每一步都有独立预算与 kill switch。

 ┌──────────── 反馈环:MEMORY.md 快照 + topic-index + skills 注入下一轮对话 ◄────────────┐
 ▼                                                                                       │
对话轮次 —— L1 实时写入 · L2 每轮结论提取 · L3 空闲 flush(预算 ≤2 memory + ≤5 topic)    │
 ├─► memory ─── 近重复?─┬─ 是 ─► NOOP 拒写                                              │
 │                       └─ 否 ─► MEMORY.md 写入(+ ledger)─────────────────────────────┤
 ├─► topic save ─┬─► ADD ─────────► history.jsonl(append-only)                         │
 │               ├─► SUPERSEDE ──► 旧条目软失效(invalid_at),修正链 +1 ──┐             │
 │               └─► NOOP(近重复,不写)                                  │             │
 └─► skill_manage 创建 / patch ──► skills/(created_by 标记)              │             │
                                                     链深 ≥2 且存活 ≥3d = 晋升候选       │
                                                                           │             │
 L8 bg_review 总线(6h 冷却,空闲搭载,各环节独立 due-check、fail-silent) │             │
  ├─► L5 wiki lint(每 7d)─── 冲突 ──► conflicts.jsonl(只记录,不推送)  │             │
  ├─► L4 每日蒸馏(per-topic watermark,≤5 topic/轮)──► summary.md 重写   │             │
  └─► L6 每周晋升:规则门(免费)──► LLM 门(单次)◄───────────────────────┘             │
                         │                                                               │
                         ├─► promote(≤2 写/轮)──► MEMORY.md ───────────────────────────┘
                         ├─► skip(终局判决,不再烧预算)
                         └─► deferred(写失败 / 超预算)──► 重试环:下轮重新入队 ──► LLM 门

 L7 Skill Curator(闲置 ≥90d)──► skills/.archive/ ◄──► 可逆:移回目录 + refresh 即恢复
 L9 审计贯穿所有箭头:ledger · supersede 链 · distill / promotions / conflicts.jsonl · telemetry ┌──────────── feedback loop: MEMORY.md snapshot + topic-index + skills injected next turn ◄───────────┐
 ▼                                                                                                      │
Conversation turn — L1 realtime write · L2 per-turn extraction · L3 idle flush (≤2 memory + ≤5 topic)   │
 ├─► memory ─── near-dup? ─┬─ yes ─► NOOP, write rejected                                               │
 │                         └─ no ──► MEMORY.md write (+ ledger) ────────────────────────────────────────┤
 ├─► topic save ─┬─► ADD ─────────► history.jsonl (append-only)                                         │
 │               ├─► SUPERSEDE ──► old entry soft-invalidated (invalid_at), chain +1 ──┐                │
 │               └─► NOOP (near-duplicate, not written)                                │                │
 └─► skill_manage create / patch ──► skills/ (created_by marker)                       │                │
                                                 chain ≥2 and age ≥3d = promotion candidate             │
                                                                                       │                │
 L8 bg_review bus (6h cooldown, idle piggyback; per-stage due-check, fail-silent)      │                │
  ├─► L5 wiki lint (every 7d) ─── conflicts ──► conflicts.jsonl (record only, no push) │                │
  ├─► L4 daily distill (per-topic watermark, ≤5 topics/run) ──► summary.md rewrite     │                │
  └─► L6 weekly promotion: rule gate (free) ──► LLM gate (one call) ◄──────────────────┘                │
                         │                                                                              │
                         ├─► promote (≤2 writes/run) ──► MEMORY.md ─────────────────────────────────────┘
                         ├─► skip (terminal verdict, never re-burns budget)
                         └─► deferred (write failure / over budget) ──► retry loop: re-queued next run ──► LLM gate

 L7 Skill Curator (idle ≥90d) ──► skills/.archive/ ◄──► reversible: move back + refresh to restore
 L9 audit across every arrow: ledger · supersede chain · distill / promotions / conflicts.jsonl · telemetry

Figure 1图 1The real topology: three loops and three forks. Loops — the feedback loop (stores injected back into the next turn), the correction chain (SUPERSEDE deepens a chain until it qualifies for promotion), and the retry loop (deferred promotions re-queue next run). Forks — topic save (ADD / SUPERSEDE / NOOP), the bg_review bus (L5 / L4 / L6), and the LLM gate verdict (promote / skip / deferred).真实拓扑:三个环、三处分叉。环——反馈环(存储注入下一轮对话)、修正链(SUPERSEDE 不断加深链条直至满足晋升条件)、重试环(deferred 的晋升候选下轮重新入队)。分叉——topic save 三判决(ADD / SUPERSEDE / NOOP)、bg_review 总线三环节(L5 / L4 / L6)、LLM 门三判决(promote / skip / deferred)。

2L1 — In-Session Write LayerL1 — 对话内写入层

Realtime writes the agent makes proactively during a conversation, through three tools plus a routing discipline.会话期间 agent 主动发起的实时写入:三个工具加一条路由纪律。

memory — MEMORY.md (agent notes, 3000-char hard cap) + USER.md (user profile, 2000 chars). Actions: add / replace / remove / reinforce. Near-duplicate detection (Jaccard similarity) returns NOOP and rejects the write; reinforce stamps an entry with a ⟦×N⟧ reinforcement count; every write goes into the audit ledger. Snapshot freeze: a snapshot is loaded at session start and never hot-updated, protecting the prompt cache.memory — MEMORY.md(agent 笔记,3000 字符硬上限)+ USER.md(用户画像,2000 字符)。动作:add / replace / remove / reinforce。近重复检测(Jaccard 相似度)→ NOOP 拒写;reinforce 给条目打 ⟦×N⟧ 强化计数;所有写入进审计 ledger。快照冻结策略:会话开始时载入快照、不热更,以保护 prompt cache。

topic — at most 10 topics; each is a summary.md (≤1000 chars, LLM-distilled) plus a history.jsonl (append-only fact stream). save returns one of four decisions — ADD / SUPERSEDE / NOOP / ERROR. supersede is a soft invalidation: the old entry is stamped with invalid_at plus a superseded_by pointer, never deleted, forming a replayable correction chain. Every fact carries a stable entry_id.topic — 最多 10 个 topic,每个 = summary.md(≤1000 字符,LLM 蒸馏)+ history.jsonl(append-only 事实流)。save 返回 ADD / SUPERSEDE / NOOP / ERROR 四种决策。supersede 是软失效:旧条目打 invalid_at + superseded_by 指针,永不删除,形成可回放的修正链。每条事实都有稳定的 entry_id。

skill_manage — creates and patches skills (procedural knowledge) in-session. Agent-built skills carry an exclusive created_by="skill_manage" marker that the Curator later recognizes.skill_manage — 对话内创建 / patch 技能(程序性知识)。agent 自建技能带 created_by="skill_manage" 独占标记,供后续 Curator 识别。

Six-way routing discipline六路路由纪律every fact is routed to exactly one home:每条事实路由到唯一归属:

Fact事实类型Home归属
Name / timezone姓名 / 时区user_settings
User preferences用户偏好USER.md
Agent identityagent 身份agent_profile
Reply style回复风格SOUL.md
Reusable workflows可复用工作流skill
Environment facts / lessons环境事实 / 教训MEMORY.md
Specific facts (address / hash / threshold)具体事实(地址 / 哈希 / 阈值)topic

3L2 + L3 — Per-Turn Extraction & FlushL2 + L3 — 每轮提取与 Flush

Two lightweight capture layers turn conversation into gated knowledge without touching the main model's budget.两个轻量沉淀层,把对话转化为受门控的知识,不动主模型的预算。

L2 — per-turn extraction. After each turn ends, verified conclusions are extracted at low cost (commit 705c67b2) without involving the main model.L2 — 每轮轻量提取。turn 结束后提取已验证结论(commit 705c67b2),低成本,不动主模型。

L3 — Flush. When the session goes idle, flush fires: an independent small model with tools reviews the recent conversation and routes what is worth keeping into the right stores. It enforces a hard write budget — ≤2 memory adds and ≤5 topic saves per flush — and prefers topics over memory. The flush topic tool is a write-append-only wrapper: it can only save, never read-modify-delete.L3 — Flush。会话空闲时触发 flush:独立小模型带工具审读近期对话,把值得保留的内容路由写入。写入预算强制:每次 flush ≤2 条 memory add + ≤5 条 topic save,且倾向 topic 而非 memory。flush 的 topic 工具是 write-append-only 包装(只能 save,不能读改删)。

Verification ladderVerification ladderunverified guesses ("maybe X?") never enter storage; only verified facts are written, distilled into reusable rules rather than raw observation logs.未验证的猜测("maybe X?")禁止入库;只写已验证事实,且要求蒸馏成可复用规则而非原始观察日志。

Pre-compact flush contractPre-compact flush 契约flush is forced before compaction (commit 237ab1e5), so context loss during compression never evaporates knowledge.压缩前强制 flush(commit 237ab1e5),防止上下文丢失导致知识蒸发。

4L4 — M2 Daily DistillL4 — M2 每日蒸馏

Daily distillation (PR #851, core/memory/distill.py) piggybacks on the bg_review full pass, at most once per day via wall-clock due-check.每日蒸馏(PR #851,core/memory/distill.py)搭载在 bg_review full pass,经 wall-clock due-check 每日最多一次。

Per-topic watermark. Only topics that gained history entries since their own last successful regen are re-distilled; mtime is used for ordering only.Per-topic watermark。只重蒸馏「自己上次成功 regen 后新增了 history 条目」的 topic;mtime 仅用于排序。

Budget. ≤5 topic regens per round (distill_max_topics, configurable); topics that exceeded the budget or failed keep their watermark and are retried next round.预算。每轮 ≤5 个 topic regen(distill_max_topics 可配);超预算 / 失败的 topic 保留 watermark,下轮重试。

Logs & telemetry. logs/wiki/distill.jsonl; telemetry event memory.distill.日志与遥测。logs/wiki/distill.jsonl;遥测事件 memory.distill。

5L5 — Phase 5 Wiki LintL5 — Phase 5 Wiki Lint

Weekly wiki hygiene (core/memory/wiki_maintenance.py) — every 7 days, autosuspend-safe: no cron, no resident process, pure piggyback plus a wall-clock due-check.每周 wiki 卫生(core/memory/wiki_maintenance.py)——每 7 天一次,autosuspend-safe:无 cron、无常驻进程,纯搭载 + wall-clock due-check。

The cheap pure-rule gate runs first, LLM spend runs after; conflicts are only written to conflicts.jsonl, never auto-pushed. A 180s collaboration circuit breaker bounds the pass (MAINTENANCE_TIMEOUT_S).便宜的纯规则门在前,LLM 花费在后;发现冲突只写 conflicts.jsonl,不推送。180s 协作熔断(MAINTENANCE_TIMEOUT_S)封顶。

6L6 — M3 Weekly PromotionL6 — M3 每周晋升

New in PR #1164 (core/memory/promotion.py, 2026-08-12): a weekly promotion pipeline that closes the gap between topic — the high-capacity fact store — and MEMORY.md — the small behavioral store injected every turn — which previously had no machine path.PR #1164 新增(core/memory/promotion.py,2026-08-12):每周晋升管线,补齐 topic(高容量事实库)→ MEMORY.md(每轮注入的小型行为库)此前只有人工通道的缺口。

Four stages: rule gate (free) → LLM gate (single bounded call) → MemoryStore.add → audit log. The final semantics: a decision is final — it never re-burns budget.管线四段:规则门(免费)→ LLM 门(单次有界调用)→ MemoryStore.add → 审计日志。终局语义:判决终局,不重复烧预算。

① Rule gate (free)① 规则门(免费)candidates = surviving facts && supersede chain depth ≥2 (corrected at least once, proving ongoing maintenance) && survived ≥3 days && never decided. ≤8 candidates per round.候选 = 存活事实 && supersede 链深 ≥2(至少被修正过一次,证明被持续维护)&& 存活 ≥3 天 && 未决策过。每轮 ≤8 候选。

② LLM gate (single bounded call)② LLM 门(单次有界调用)gemini-3.6-flash judges candidates one by one against the current MEMORY.md snapshot: promote — rewritten into a generalized rule of ≤220 chars, keeping key numbers / IDs / paths — or skip (topic-local detail / transient / near-duplicate). The verdict is final.gemini-3.6-flash 对照当前 MEMORY.md 快照逐个判决:promote(改写成 ≤220 字符的泛化规则,保留关键数字 / ID / 路径)或 skip(topic 局部细节 / 瞬态 / 近重复)。判决终局。

③ Write (MemoryStore.add)③ 写入(MemoryStore.add)≤2 entries per round (aligned with the flush budget); MEMORY.md near-duplicate = final skip; write failure (full / error) = deferred, retried next round; over budget = deferred_budget, retried next round.每轮 ≤2 条(与 flush 预算对齐);MEMORY.md 近重复 = 终局 skip;写失败(满 / 错误)= deferred,下轮重试;超预算 = deferred_budget,下轮重试。

④ Audit④ 审计promotion_done_ids (FIFO, capped at 400) lives in review_state; the audit log is logs/wiki/promotions.jsonl — the equivalent of OpenClaw's Dream Diary; telemetry memory.promotion; kill switch promotion_enabled. Tested with 6 cases (rule gate / exclusion / end-to-end / due gate / write budget / LLM degradation) on a real MemoryStore end-to-end.promotion_done_ids(FIFO 上限 400)存 review_state;审计日志 logs/wiki/promotions.jsonl(相当于 OpenClaw 的 Dream Diary);遥测 memory.promotion;kill switch:promotion_enabled。测试:6 用例(规则门 / 排除 / 端到端 / due 门 / 写预算 / LLM 降级),真 MemoryStore 端到端。

7L7 — Skill CuratorL7 — Skill Curator

Skill hygiene (PR #592 + #661, core/skills/curator.py + scripts/skill_curator.py): agent-built skills — one-off helpers, near-duplicates — accumulate and eat system-prompt budget while diluting skill selection.技能卫生(PR #592 + #661,core/skills/curator.py + scripts/skill_curator.py):agent 自建技能(一次性 helper、近重复)堆积会占系统提示预算、稀释技能选择。

Safety model — all four must hold安全模型——4 条全满足才是候选created_by=="skill_manage" (official / preinstalled / marketplace skills are never touchable); not pinned; idle beyond idle_days (default 90 days); the directory really exists.created_by=="skill_manage"(官方 / 预装 / 市场技能永不可触);非 pinned;闲置超过 idle_days(默认 90 天);目录真实存在。

The maximum action is reversible: MOVE to skills/.archive/<name>__<ts>/ plus deregistration — fully reversible; dry-run by default, --apply actually moves files. A report-only overlap / bloat scan also ships in scripts/skill_curator.py.最大动作 = MOVE 到 skills/.archive/<name>__<ts>/ + 注销注册,完全可逆;默认 dry-run,--apply 才动文件系统。另有 report-only 的重叠 / 膨胀扫描(scripts/skill_curator.py)。

8L8 — The bg_review Scheduling BusL8 — 调度总线:bg_review

The only "scheduler" in the system: a background review process with a 6-hour cooldown, triggered on session idle, never resident.系统里唯一的"调度器":6 小时冷却的后台复查进程,会话空闲触发,非常驻。

The full pass carries three stages in order — Phase 5 wiki lint → M2 daily distill → M3 weekly promotion — L5, then L4, then L6. Each stage runs its own due-check: when not due, its overhead is near zero. Each stage fails silent: it never drags down the main flow.full pass 依次搭载三个环节:Phase 5 wiki lint → M2 daily distill → M3 weekly promotion(即 L5 → L4 → L6)。每个环节自带 due-check,not-due 时开销近似为零;每个环节 fail-silent,绝不拖垮主流程。

9L9 — Audit & TelemetryL9 — 审计与遥测

Every step is observable end-to-end: write journals, replayable correction chains, a jsonl log family, and telemetry events.全链可观测:写入日志、可回放的修正链、jsonl 日志族与遥测事件。

write_journal / ledger — every memory write is recorded.write_journal / ledger — 每次 memory 写入记录。

supersede chain — the full correction history of a fact is preserved (invalid_at soft invalidation) and replayable.supersede 链 — 事实修正历史全保留(invalid_at 软失效),可回放。

jsonl log family — distill.jsonl / promotions.jsonl / conflicts.jsonl under logs/wiki/.jsonl 日志族 — distill.jsonl / promotions.jsonl / conflicts.jsonl(logs/wiki/)。

telemetry_hooks — memory.flush / memory.distill / memory.promotion events.telemetry_hooks — memory.flush / memory.distill / memory.promotion 事件。

10Comparison & Positioning对比定位

Forensic comparison against OpenClaw and Hermes (2026-08-12).对 OpenClaw / Hermes 的取证对比(2026-08-12)。

vs OpenClaw Dreaming (light / REM / deep three stages + Dream Diary): our distill + promotion are the equivalent of its consolidation + promotion, and our fact-level supersede audit chain is stronger — OpenClaw's LanceDB forget is an unauditable hard delete.vs OpenClaw Dreaming(light / REM / deep 三阶段 + Dream Diary):我们的 distill + promotion 等价其巩固 + 晋升,且事实级 supersede 审计链更强——OpenClaw 的 LanceDB forget 是不可审计硬删。

vs Hermes Curator (pin / archive / consolidate / patch, idle-triggered): our Curator is pure rule-based archiving and lacks consolidate / patch actions (skill volume is small, not yet needed); Hermes' learning_graph (memory × skill visualization) and next-round prefetch are two things we have not built.vs Hermes Curator(pin / archive / consolidate / patch,空闲触发):我们的 Curator 是纯规则归档,缺 consolidate / patch 动作(技能量小,暂不需要);Hermes 的 learning_graph(记忆 × 技能可视化图)与下轮 prefetch 是我们尚未做的两项。

What is uniquely ours我们独有the six-way routing discipline; the supersede audit chain plus reinforce counting; and user-profile / self-model synthesis.六路路由纪律;supersede 审计链 + reinforce 计数;user-profile / self-model 合成。

11Layer Summary各层汇总

LayerTrigger触发时机Frequency频率Budget预算Audit artifact审计产物
L1 writeagent, in-sessionagent 会话内主动realtime实时MEMORY 3000 / USER 2000 chars; ≤10 topicsMEMORY 3000 / USER 2000 字符;≤10 topicswrite_journal / ledgerwrite_journal / ledger
L2 extractturn endturn 结束per-turn每轮low cost, no main model低成本,不动主模型
L3 flushsession idle会话空闲per idle session每次空闲会话≤2 memory + ≤5 topic≤2 memory + ≤5 topictelemetry memory.flush遥测 memory.flush
L4 distillbg_review full passbg_review full passdaily, ≤1×/day每日,最多 1 次≤5 topic regens≤5 topic regendistill.jsonl · memory.distilldistill.jsonl · memory.distill
L5 lintbg_review full passbg_review full passevery 7 days每 7 天rules first; 180s timeout规则先行;180s 熔断conflicts.jsonlconflicts.jsonl
L6 promotebg_review full passbg_review full passweekly每周≤8 candidates; ≤2 writes; ≤220 chars≤8 候选;≤2 写入;≤220 字符promotions.jsonl · memory.promotionpromotions.jsonl · memory.promotion
L7 curatoridle / report空闲 / 报告idle_days (90 d)idle_days(90 天)4-condition safety model4 条件安全模型archive move (reversible)归档移动(可逆)
L8 bussession idle会话空闲6 h cooldown6 小时冷却per-stage due-check各环节 due-check
L9 auditthroughout贯穿全链continuous持续supersede chain · jsonl familysupersede 链 · jsonl 日志族