dsh-continual-evolve 0.15.8 → 0.15.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
@@ -7,7 +7,7 @@ English | [中文](README.zh.md)
7
7
  [![CI](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml/badge.svg)](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml)
8
8
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
9
9
  [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24-339933)](package.json)
10
- [![Tests](https://img.shields.io/badge/tests-328%20passing-brightgreen)]()
10
+ [![Tests](https://img.shields.io/badge/tests-330%20passing-brightgreen)]()
11
11
  [![Coverage · statements](https://img.shields.io/badge/coverage_statements-96%25-brightgreen)]()
12
12
  [![Coverage · branches](https://img.shields.io/badge/coverage_branches-90%25-green)]()
13
13
  [![Coverage · functions](https://img.shields.io/badge/coverage_functions-100%25-brightgreen)]()
@@ -22,7 +22,7 @@ Reusable experience gathered in one session (user preferences, pitfalls, project
22
22
 
23
23
  1. **Session-start injection** — the plugin registers a single system-prompt section: the workspace's memory index as a store query (hooks only, whole-line truncated over budget, ordered feedback > user > reference), the central-library path, and a three-line guide. The section is computed once per session and reused byte-for-byte, keeping the system prompt stable and the prompt cache warm; an empty store costs zero tokens.
24
24
  2. **Four tools, one writer** — `memory_write` (create/update/delete) is the explicit path for "remember …" / "forget …": every proposal passes the code gates (id shape, type enum, the feedback Why/How contract, secret screening carried over from v1, 64KB body cap, optional `corrects` links to the same-workspace active memory being superseded) inside one transaction. `memory_read` fetches bodies by id and searches by keyword — whitespace-separated terms are AND-combined, with literal substring matching for short terms and whenever the trigram index misses; the injected index carries hooks only. Each memory body served by id increments that memory's view counter (views + last viewed, the same presence heartbeat as skills). `skill_write` (create/update/delete in the project, plus an explicit move-to-global) sediments reusable procedures through the same discipline (kebab ids, secret screening, 64KB cap, no duplicate ids or bodies across scopes); every applied skill is materialized by the plugin as `<workspace>/.agents/skills/<id>/SKILL.md` — the database is the source of truth, the files are a read-only projection patrol restores on drift. `skill_read` fetches skill bodies by id and searches project plus global skills (the project shadows a same-named global); each body served by id increments that skill's view counter (views + last viewed), which the card shows as a presence heartbeat — viewed, not applied, so long-unviewed rows are removal candidates while pruning itself stays human. On hosts without the tools service the plugin degrades to "tell the user" phrasing and stays functional.
25
- 3. **Proposal-based extraction** — the trajectory-to-memory automation, audited in the `extraction_log`: every `agent/turn-stopping` schedules that session's boundary, with state kept **per session** (a run in flight keeps only its newest boundary — coalescing, not queueing; `compaction/start` and session close drain it) and **no idle timer**. A run reads the session increment since its cursor, feeds FTS-similar existing memories to one LLM call, and the model's structured proposal lands through the same gates; failures and rejections never advance the cursor. A cheap pre-gate (increment head + ownership triple-test, tiny verdict) runs first: refusals consume the increment as a model skip without the full call, and an unclear gate fails open to the full call — worst case degrades to the old single-call behavior, never to a stall. Full and gate usages ledger in separate `usage` / `cheap_usage` columns. Internal agents, empty increments, turns without real user prose, and turns that already carried an explicit `memory_write` are mechanically skipped — and every skip is ledgered, consecutive quiet turns of one session as a single row carrying how many wake-ups it stands for.
25
+ 3. **Proposal-based extraction** — the trajectory-to-memory automation, audited in the `extraction_log`: every `agent/turn-stopping` schedules that session's boundary, with state kept **per session** (a run in flight keeps only its newest boundary — coalescing, not queueing; `compaction/start` and session close drain it) and **no idle timer**. A run reads the session increment since its cursor, feeds FTS-similar existing memories to one LLM call, and the model's structured proposal lands through the same gates; failures and rejections never advance the cursor. A cheap pre-gate (increment head + ownership triple-test, tiny verdict) runs first: refusals consume the increment as a model skip without the full call, and an unclear gate fails open to the full call — worst case degrades to the old single-call behavior, never to a stall. Full and gate usages ledger in separate `usage` / `cheap_usage` columns, and a gate that dies keeps its error head in the same row's `cheap_error` — a dead gate stays tellable from a gate that never existed. Internal agents, empty increments, turns without real user prose, and turns that already carried an explicit `memory_write` are mechanically skipped — and every skip is ledgered, consecutive quiet turns of one session as a single row carrying how many wake-ups it stands for.
26
26
  4. **Autonomous content-quality loop** — the second background automation, independent from extraction by construction (own prompts, own daily budget, own `review_log` ledger, no cursor; only the store's write gates are shared): a cheap gate model call decides whether a memory/skill entry deserves a close look, and only approvals run the evolve pass that judges content quality (memories on home-ownership plus accuracy/usability/reusability/duplication/freshness, skills on home-ownership plus trigger precision/executability/reusability/duplication) and proposes the rewrite. The same three home tests (user/environment vs repo-version subject, name-stripped sentence, repo facts live in ADR/docs) guard the extraction prompt, so repo-version specifics never enter as memories in the first place. Gate/leg failures ledger the error text instead of a bare code. New writes are reviewed as they land, the existing stock drains through a bounded backlog queue, and untouched entries requeue after 30 days. Two hard guarantees bound the autonomy: delete never lands automatically (rewrite or quarantine only — quarantine hides, never deletes) and oversized rewrites degrade to quarantine. A daily cap (default 100 items, new > corrects-linked > stale > spot-check priority, the tail drops instead of rolling over) bounds the token spend, and every terminal path lands one `item-review` verdict row plus one daily rollup row (budget vs reviewed vs backlog vs dropped, tokens split by cheap/evolve purpose) for later replay. Ships in trial mode (`review.dryRun`, default on): verdicts ledgered, nothing applied.
27
27
  5. **Rollback is a ledger, not a mechanism** — every mutation lands an `extraction_log` row with full before/after snapshots; undo means rewriting the `before` values. Skill mutations land the same way in `skill_log`, review verdicts in `review_log`. A hygiene pass rides on every applied run: orphan FTS rows are dropped and secret-bearing rows are quarantined (hidden, never deleted; a quarantined skill's materialized file is removed so it stops loading). The read-only card surfaces quarantine anomalies.
28
28
  6. **Read-only card** — mounted on the plugin's page in the official plugin manager (the `plugins.bundle.config` slot; hosts without it silently degrade to no card), shaped like the market's own settings card and aligned with ZCode's Settings → Memory viewer: a dropdown scope selector over the store's workspace partitions (opening on the host's current workspace), a search box, per-entry relative updated times, click-to-preview bodies (5 MiB cap), patrol warnings, and a skills section listing the workspace's project skills plus visible global skills (global rows badged, project shadowing global) with the same preview, each row showing its view count. Localized through the host's `locale/*.json` metadata channel; host theme tokens, the `Button` primitive, and zh/en copy that tracks the DSH language. The card is a request-time projection of the database and has no edit path.
package/README.zh.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![CI](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml/badge.svg)](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml)
8
8
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
9
9
  [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24-339933)](package.json)
10
- [![Tests](https://img.shields.io/badge/tests-328%20passing-brightgreen)]()
10
+ [![Tests](https://img.shields.io/badge/tests-330%20passing-brightgreen)]()
11
11
  [![Coverage · statements](https://img.shields.io/badge/coverage_statements-96%25-brightgreen)]()
12
12
  [![Coverage · branches](https://img.shields.io/badge/coverage_branches-90%25-green)]()
13
13
  [![Coverage · functions](https://img.shields.io/badge/coverage_functions-100%25-brightgreen)]()
@@ -22,7 +22,7 @@ Agent 每个会话积累的可复用经验(用户偏好、踩坑教训、项
22
22
 
23
23
  1. **开局注入** —— 插件只注册一个 system-prompt section:注入本工作区的记忆索引(查库结果,只含钩子,超预算按整行截断,feedback > user > reference 排序)、中央库路径、三行指南。该 section 每会话只算一次并逐字节复用,system prompt 稳定、prompt cache 持续命中;空 store 零 token。
24
24
  2. **四个工具,一个写者** —— `memory_write`(create/update/delete)承接显式的记住/忘掉:每条提案过代码门禁(id 规范、type 枚举、feedback 的 Why/How 契约、v1 移植的 secret 筛查、64KB 正文上限、可选 `corrects` 指向被替代的同工作区 active 记忆)后在一个事务内落盘。`memory_read` 按 id 取正文、按关键词检索——空格分隔的关键词取 AND,短词与 trigram 未命中时回退字面子串匹配;注入索引只有钩子。按 id 取到的每份记忆正文计一次查阅(与技能同纪律的存在心跳)。`skill_write`(项目内 create/update/delete + 显式搬到全局)沉淀可复用的操作规程,走同一套纪律(短横线 id、secret 筛查、64KB 上限、跨范围禁重名重文);每条落地的技能由插件代码物化为 `<workspace>/.agents/skills/<id>/SKILL.md`——库是唯一真相,文件是只读投影,漂移由巡检按库还原。`skill_read` 按 id 取技能正文、检索项目与全局技能(同名时项目遮蔽全局);按 id 取到的每份正文计一次查阅(查阅次数 + 上次查阅,卡片展示)。这是存在心跳——只证明被翻过,不证明有用:长期零查阅是删除候选,剪枝拍板仍需人工。宿主没有工具服务时降级为告诉用户措辞,注入不受影响。
25
- 3. **提案制提取** —— 轨迹到记忆的自动化,全程 `extraction_log` 可对账:每个 `agent/turn-stopping` 调度**该会话自己**的边界,状态按会话隔离(运行中只保留最新边界——合并而非排队;`compaction/start` 与会话收尾触发 drain),**没有空闲计时器**。一次运行读取该会话游标之后的轨迹增量,用 FTS 取相似既有记忆喂给一次 LLM 调用,模型的结构化提案过同一套门禁落盘;失败与被拒不推游标,下次触发重试。贵调用之前先过一道便宜预检门(增量前 4KB + 归属三测,小 verdict):拒了直接按 model-skip 消费游标,不烧全量 prompt;门不清不楚就透传给贵调用——最差退化成老单调用,永不 stall。贵用量与门用量分 `usage` / `cheap_usage` 两列记账。内部 agent、空增量、无真实用户文本的轮次、当轮已有显式 `memory_write` 的轮次机械跳过——每次跳过都记账,同一会话连续的空转轮次合成一行并累计唤醒次数。
25
+ 3. **提案制提取** —— 轨迹到记忆的自动化,全程 `extraction_log` 可对账:每个 `agent/turn-stopping` 调度**该会话自己**的边界,状态按会话隔离(运行中只保留最新边界——合并而非排队;`compaction/start` 与会话收尾触发 drain),**没有空闲计时器**。一次运行读取该会话游标之后的轨迹增量,用 FTS 取相似既有记忆喂给一次 LLM 调用,模型的结构化提案过同一套门禁落盘;失败与被拒不推游标,下次触发重试。贵调用之前先过一道便宜预检门(增量前 4KB + 归属三测,小 verdict):拒了直接按 model-skip 消费游标,不烧全量 prompt;门不清不楚就透传给贵调用——最差退化成老单调用,永不 stall。贵用量与门用量分 `usage` / `cheap_usage` 两列记账;门自己挂了按 fail-open 透传,错误原文留在同一行的 `cheap_error`——门死了与门不存在可区分。内部 agent、空增量、无真实用户文本的轮次、当轮已有显式 `memory_write` 的轮次机械跳过——每次跳过都记账,同一会话连续的空转轮次合成一行并累计唤醒次数。
26
26
  4. **内容质量自进化环** —— 第二条后台自动化,与提取在结构上独立(自有提示词、自有日预算、自有 `review_log` 账本、无游标;只共享库的写门):便宜门模型先判某条记忆/技能值不值得细看,批了才跑贵改写,按内容质量打分(记忆:归属 + 准确/可用/可复用/不重复/不过时五维;技能:归属 + 触发精度/可执行完备/可复用/不重复四维)并给出改写提案。同一套归属三测(主语是用户/环境还是某仓库的某版机制、去名后还成立吗、仓库事实住 ADR/docs)也守在提取 prompt 门口,版本细节从源头就不进记忆;评审调用失败记错误原文,不记秃码。新写即审、存量走有界积压队列排空、长期未动 30 天回炉。两条硬保证框住自动化:删除永不自动落盘(只有改写与隔离——隔离隐藏不删),超幅改写自动转隔离。日上限默认 100 条(新写 > 被纠正牵连 > 陈旧 > 抽查,尾部丢弃不滚雪球)框住 token 开销;每条终态落一行 `item-review` verdict 行、每天合一行日 rollup(预算 vs 实审 vs 积压 vs 丢弃,token 按便宜/贵分账),方便以后复盘。默认试运行(`review.dryRun` 开):只记 verdict,不落盘。
27
27
  5. **回滚靠账本,不靠机制** —— 每次变更落一条带 before/after 全文快照的 `extraction_log` 行;undo 就是取 before 重写。技能变更同样落 `skill_log`,评审 verdict 落 `review_log`。每次应用后随跑一次巡检:孤儿 FTS 行清除、含密钥条目隔离(隐藏,不物理删除;被隔离技能的物化文件一并撤下,使其不再被加载)。只读卡片显形巡检异常。
28
28
  6. **只读卡片** —— 挂在官方插件管理的本 bundle 页面(`plugins.bundle.config` slot,老宿主自动降级为无卡片):形态对齐市场自家设置卡,内容对齐 ZCode 设置的记忆选项卡——下拉作用域选择器列出库里的工作区分区(默认选中宿主当前工作区)、搜索框、每条记忆的相对更新时间、点击行内展开正文预览(5 MiB 上限)、巡检异常警告,以及技能区(本工作区技能 + 可见的全局技能,全局行打标记,同名时项目遮蔽全局),预览同记忆,每行显示查阅次数。显示名与描述走宿主 `locale/*.json` 通道双语;宿主主题 token、`Button` 原语、中英文案跟随 DSH 语言。卡片是数据库的请求时投影,没有编辑路径。
package/lib/extraction.js CHANGED
@@ -7,12 +7,18 @@ const FAILURE_RAW_MAX = 2048;
7
7
  const UNEXPECTED_ERROR_RAW_MAX = 2048;
8
8
  /** Head length of an error message embedded in a ledger `skip_reason`. */
9
9
  const ERROR_REASON_MAX = 300;
10
+ /** Head length of a failed pre-gate call's error kept in the ledger `cheap_error` column. */
11
+ const GATE_ERROR_MAX = 200;
10
12
  /** Split an unexpected throw into a ledger-sized reason head and file body. */
11
13
  function errorText(error) {
12
14
  const message = error instanceof Error && error.message.length > 0 ? error.message : String(error);
13
15
  const stack = error instanceof Error && typeof error.stack === "string" ? error.stack : message;
14
16
  return { message, detail: `${message}\n${stack}`.slice(0, UNEXPECTED_ERROR_RAW_MAX) };
15
17
  }
18
+ /** One-line head of a thrown pre-gate error (flat, so the column stays greppable). */
19
+ function errorHead(error) {
20
+ return errorText(error).message.replace(/\s+/g, " ").trim().slice(0, GATE_ERROR_MAX);
21
+ }
16
22
  /**
17
23
  * Run one extraction pass for a target. Never throws unless the ledger
18
24
  * itself is unwritable: every terminal path is either a landed application,
@@ -111,8 +117,13 @@ async function runExtractionInner(deps, target, opts) {
111
117
  // (manifest + full-body candidates + full increment). A "not worth it"
112
118
  // consumes the increment exactly like a model skip; an unclear gate
113
119
  // (unparseable/failed) fails OPEN to the full call — worst case degrades
114
- // to the old single-call behavior, never to a stall.
120
+ // to the old single-call behavior, never to a stall. A gate that dies
121
+ // still rides the run's own ledger row as `cheap_error`: without it a
122
+ // failed gate is indistinguishable from a gate that never existed, which
123
+ // is how a 512-token budget truncating every call on a reasoning model
124
+ // stayed invisible.
115
125
  let cheapUsage;
126
+ let cheapError;
116
127
  {
117
128
  const gateStarted = Date.now();
118
129
  try {
@@ -132,8 +143,11 @@ async function runExtractionInner(deps, target, opts) {
132
143
  return { status: "skipped", skipReason: verdict.reason, cursor: boundarySeq };
133
144
  }
134
145
  }
135
- catch {
136
- // Fail open: the full call below is the old behavior.
146
+ catch (error) {
147
+ // Fail open: the full call below is the old behavior. The error
148
+ // head is kept for the run's own row (never a row of its own, so
149
+ // one run stays one ledger row).
150
+ cheapError = errorHead(error);
137
151
  }
138
152
  }
139
153
  const manifest = store.list(target.workspaceId).slice(0, 50).map(manifestLineOf);
@@ -155,7 +169,7 @@ async function runExtractionInner(deps, target, opts) {
155
169
  catch (error) {
156
170
  const { message, detail } = errorText(error);
157
171
  try {
158
- store.logSkipped({ ...ledgerBase, skipReason: "llm-failed", status: "failed", durationMs: Date.now() - started, cheapUsage, files: detail });
172
+ store.logSkipped({ ...ledgerBase, skipReason: "llm-failed", status: "failed", durationMs: Date.now() - started, cheapUsage, cheapError, files: detail });
159
173
  }
160
174
  catch (ledgerError) {
161
175
  throw new Error(`llm call failed (${message}); failure ledger write also failed (${errorText(ledgerError).message})`);
@@ -175,6 +189,7 @@ async function runExtractionInner(deps, target, opts) {
175
189
  model: target.model,
176
190
  usage,
177
191
  cheapUsage,
192
+ cheapError,
178
193
  durationMs: Date.now() - started,
179
194
  files: text.slice(0, FAILURE_RAW_MAX),
180
195
  });
@@ -191,6 +206,7 @@ async function runExtractionInner(deps, target, opts) {
191
206
  model: target.model,
192
207
  usage,
193
208
  cheapUsage,
209
+ cheapError,
194
210
  durationMs: Date.now() - started,
195
211
  });
196
212
  return { status: "skipped", skipReason: parsed.reason, cursor: boundarySeq };
@@ -203,6 +219,7 @@ async function runExtractionInner(deps, target, opts) {
203
219
  model: target.model,
204
220
  usage,
205
221
  cheapUsage,
222
+ cheapError,
206
223
  decision: parsed.reason,
207
224
  }, parsed.proposals);
208
225
  if (!outcomes.every((outcome) => outcome.ok)) {
@@ -28,6 +28,8 @@ export interface ProposalContext {
28
28
  usage?: unknown;
29
29
  /** Pre-gate call payload (extraction cheap gate); carried into the ledger row. */
30
30
  cheapUsage?: unknown;
31
+ /** Error head when the pre-gate call threw (fail open); carried into the ledger row. */
32
+ cheapError?: string | undefined;
31
33
  /** One-line model decision summary for the ledger. */
32
34
  decision?: string | undefined;
33
35
  }
@@ -63,6 +63,7 @@ export function applyProposals(db, ctx, proposals) {
63
63
  model: ctx.model,
64
64
  usage: ctx.usage,
65
65
  cheapUsage: ctx.cheapUsage,
66
+ cheapError: ctx.cheapError,
66
67
  files: applied ? files : [],
67
68
  };
68
69
  if (!applied) {
@@ -71,10 +72,10 @@ export function applyProposals(db, ctx, proposals) {
71
72
  writeLedger(db.database.prepare(LEDGER_SQL), ledger);
72
73
  return { outcomes, applied };
73
74
  }
74
- const LEDGER_SQL = "INSERT INTO extraction_log (run_id, ts, session_id, workspace_id, trigger, decision, skip_reason, status, duration_ms, model, usage, cheap_usage, files) " +
75
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
75
+ const LEDGER_SQL = "INSERT INTO extraction_log (run_id, ts, session_id, workspace_id, trigger, decision, skip_reason, status, duration_ms, model, usage, cheap_usage, cheap_error, files) " +
76
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
76
77
  function writeLedger(stmt, entry) {
77
- stmt.run(entry.runId ?? null, new Date().toISOString(), entry.sessionId ?? null, entry.workspaceId ?? null, entry.trigger, entry.decision ?? null, entry.skipReason ?? null, entry.status ?? null, entry.durationMs ?? null, entry.model ?? null, entry.usage === undefined ? null : JSON.stringify(entry.usage), entry.cheapUsage === undefined ? null : JSON.stringify(entry.cheapUsage), entry.files === undefined ? null : JSON.stringify(entry.files));
78
+ stmt.run(entry.runId ?? null, new Date().toISOString(), entry.sessionId ?? null, entry.workspaceId ?? null, entry.trigger, entry.decision ?? null, entry.skipReason ?? null, entry.status ?? null, entry.durationMs ?? null, entry.model ?? null, entry.usage === undefined ? null : JSON.stringify(entry.usage), entry.cheapUsage === undefined ? null : JSON.stringify(entry.cheapUsage), entry.cheapError ?? null, entry.files === undefined ? null : JSON.stringify(entry.files));
78
79
  }
79
80
  /** Validate one proposal and land it; appends the audit payload on success. */
80
81
  function applyOne(db, ctx, proposal, stmts, files) {
package/lib/store.d.ts CHANGED
@@ -134,6 +134,13 @@ export interface LedgerEntry {
134
134
  usage?: unknown;
135
135
  /** Pre-gate call payload (extraction cheap gate); `undefined` when the run never reached it. */
136
136
  cheapUsage?: unknown;
137
+ /**
138
+ * Why the pre-gate call left no payload: the error head when the gate
139
+ * threw (fail open). `undefined` when the gate never ran, never resolved
140
+ * to an answer, or was not reached — the column exists so that a failed
141
+ * gate is tellable from a gate that never existed.
142
+ */
143
+ cheapError?: string | undefined;
137
144
  /** Applied/attempted mutations: `{id, action, before?, after?, sourceSeqs}`; a parse-failed run instead carries the raw answer's head. */
138
145
  files?: unknown;
139
146
  }
package/lib/store.js CHANGED
@@ -70,7 +70,7 @@ CREATE TABLE IF NOT EXISTS extraction_log (
70
70
  trigger TEXT CHECK (trigger IN ('turn-debounce','compaction','close-drain','explicit','import','item-review')),
71
71
  decision TEXT, skip_reason TEXT,
72
72
  status TEXT, duration_ms INTEGER, model TEXT, usage TEXT,
73
- cheap_usage TEXT,
73
+ cheap_usage TEXT, cheap_error TEXT,
74
74
  files TEXT, occurrences INTEGER NOT NULL DEFAULT 1
75
75
  );
76
76
  CREATE TABLE IF NOT EXISTS state (
@@ -302,6 +302,7 @@ export async function openMemoryStore(explicitPath) {
302
302
  ensureLedgerOccurrences(database);
303
303
  ensureMemoriesCorrects(database);
304
304
  ensureExtractionCheapUsage(database);
305
+ ensureExtractionCheapError(database);
305
306
  const stmts = {
306
307
  get: database.prepare("SELECT * FROM memories WHERE workspace_id = ? AND id = ?"),
307
308
  list: database.prepare(`SELECT * FROM memories WHERE workspace_id = ? AND status = 'active' ${LIST_ORDER}`),
@@ -320,8 +321,8 @@ export async function openMemoryStore(explicitPath) {
320
321
  "WHERE status = 'active' AND workspace_id <> '' GROUP BY workspace_id ORDER BY ts DESC LIMIT 1"),
321
322
  recentSkill: database.prepare("SELECT workspace_id, MAX(ts) AS ts FROM skill_log " +
322
323
  "WHERE workspace_id IS NOT NULL AND workspace_id <> '' GROUP BY workspace_id ORDER BY ts DESC LIMIT 1"),
323
- ledger: database.prepare("INSERT INTO extraction_log (run_id, ts, session_id, workspace_id, trigger, decision, skip_reason, status, duration_ms, model, usage, cheap_usage, files) " +
324
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"),
324
+ ledger: database.prepare("INSERT INTO extraction_log (run_id, ts, session_id, workspace_id, trigger, decision, skip_reason, status, duration_ms, model, usage, cheap_usage, cheap_error, files) " +
325
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"),
325
326
  latestSkip: database.prepare("SELECT rowid AS rid, skip_reason AS reason, status FROM extraction_log " +
326
327
  "WHERE workspace_id IS ? AND session_id IS ? ORDER BY ts DESC, rowid DESC LIMIT 1"),
327
328
  bumpSkip: database.prepare(`UPDATE extraction_log SET ts = ?, ${LEDGER_OCCURRENCES} = ${LEDGER_OCCURRENCES} + 1 WHERE rowid = ?`),
@@ -1002,6 +1003,19 @@ function ensureExtractionCheapUsage(database) {
1002
1003
  }
1003
1004
  database.exec("ALTER TABLE extraction_log ADD COLUMN cheap_usage TEXT");
1004
1005
  }
1006
+ /**
1007
+ * Add the extraction ledger `cheap_error` column to a store created before
1008
+ * the failed-gate head was ledgered. Separate from the `cheap_usage`
1009
+ * migration above so a store that already carries that column still gains
1010
+ * this one. Same single-migration discipline as the columns above.
1011
+ */
1012
+ function ensureExtractionCheapError(database) {
1013
+ const columns = database.prepare("SELECT name FROM pragma_table_info('extraction_log')").all();
1014
+ if (columns.some((column) => column.name === "cheap_error")) {
1015
+ return;
1016
+ }
1017
+ database.exec("ALTER TABLE extraction_log ADD COLUMN cheap_error TEXT");
1018
+ }
1005
1019
  /** Parse the daily skip-counts map; corrupt payloads degrade to empty. */
1006
1020
  function parseCounts(raw) {
1007
1021
  if (raw === null) {
@@ -1026,6 +1040,6 @@ function parseCounts(raw) {
1026
1040
  }
1027
1041
  /** JSON-encode the optional ledger fields and insert the row (never throws past a warn). */
1028
1042
  function writeLedger(stmt, entry) {
1029
- stmt.run(entry.runId ?? null, new Date().toISOString(), entry.sessionId ?? null, entry.workspaceId ?? null, entry.trigger, entry.decision ?? null, entry.skipReason ?? null, entry.status ?? null, entry.durationMs ?? null, entry.model ?? null, entry.usage === undefined ? null : JSON.stringify(entry.usage), entry.cheapUsage === undefined ? null : JSON.stringify(entry.cheapUsage), entry.files === undefined ? null : JSON.stringify(entry.files));
1043
+ stmt.run(entry.runId ?? null, new Date().toISOString(), entry.sessionId ?? null, entry.workspaceId ?? null, entry.trigger, entry.decision ?? null, entry.skipReason ?? null, entry.status ?? null, entry.durationMs ?? null, entry.model ?? null, entry.usage === undefined ? null : JSON.stringify(entry.usage), entry.cheapUsage === undefined ? null : JSON.stringify(entry.cheapUsage), entry.cheapError ?? null, entry.files === undefined ? null : JSON.stringify(entry.files));
1030
1044
  }
1031
1045
  //# sourceMappingURL=store.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-continual-evolve",
3
- "version": "0.15.8",
3
+ "version": "0.15.9",
4
4
  "description": "ZCode-style workspace memory for DeepSeek Harness: one central SQLite store partitioned by workspace, index injection, and sole-writer gated writes.",
5
5
  "license": "MIT",
6
6
  "repository": {