dsh-retrace 0.4.135 → 0.4.148
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 +14 -9
- package/README.zh.md +10 -9
- package/bin/retrace.mjs +0 -0
- package/lib/adapter/compaction-backend.js +92 -0
- package/lib/adapter/contract.js +1 -1
- package/lib/adapter/dsh-writer.js +5 -5
- package/lib/adapter/dsh.js +504 -4
- package/lib/adapter/register-compaction-backend.js +93 -0
- package/lib/auto-fold-scheduler.js +519 -0
- package/lib/cache-metrics.js +358 -0
- package/lib/checkpoint-restore.js +769 -0
- package/lib/client-config.js +231 -0
- package/lib/client-css.js +36 -0
- package/lib/client-i18n.js +167 -12
- package/lib/client.bundle.js +39 -2
- package/lib/client.js +869 -162
- package/lib/close-guard-client.js +3 -3
- package/lib/close-guard.js +1 -1
- package/lib/compat-matrix.js +302 -0
- package/lib/context-level.js +139 -0
- package/lib/core-contract.js +77 -0
- package/lib/dynamic-client.js +39 -2
- package/lib/dynamic-host.js +274 -20
- package/lib/fold-auto.js +621 -0
- package/lib/fold-boundary.js +1051 -0
- package/lib/fold-core-text.js +52 -0
- package/lib/fold-core.js +191 -0
- package/lib/fold-summary.js +168 -0
- package/lib/host-core.js +205 -9
- package/lib/http.js +208 -8
- package/lib/hw3-fallback.js +262 -0
- package/lib/identity-check-cli.js +379 -0
- package/lib/index.js +577 -1
- package/lib/ledger-guard.js +491 -0
- package/lib/marker-carrier.js +5 -5
- package/lib/message-list.js +1 -1
- package/lib/platform/dsh-home.js +137 -0
- package/lib/preimage-store.js +312 -0
- package/lib/prewrite-guard.js +28 -0
- package/lib/request-guard.js +118 -0
- package/lib/rollback.js +392 -28
- package/lib/span-semantics.js +1 -1
- package/lib/token-estimate.js +91 -0
- package/lib/undo-store.js +243 -0
- package/lib/versioning.js +20 -0
- package/lib/zip-store.js +160 -0
- package/package.json +31 -2
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ it cannot dirty the log, and new markers create **no token-meter pairing debt**
|
|
|
35
35
|
|
|
36
36
|
> Versions: [VERSIONS.md](./VERSIONS.md)
|
|
37
37
|
|
|
38
|
-
>
|
|
38
|
+
> **0.4.148 is the current release** — install/pin `0.4.148` (the **GitHub Release is out; the npm package is still pending** — the latest npm version is `0.4.139`; see [VERSIONS.md](./VERSIONS.md)). The `dsh-retrace@0.4.148` examples below apply to this release.
|
|
39
39
|
|
|
40
40
|
## ⚡ One-minute install
|
|
41
41
|
|
|
@@ -89,8 +89,10 @@ Full steps in [📦 Installation](#-installation).
|
|
|
89
89
|
|
|
90
90
|
| | What | |
|
|
91
91
|
|---|---|---|
|
|
92
|
-
| 🕘 | **
|
|
93
|
-
| ↩️ | **
|
|
92
|
+
| 🕘 | **Unified restore list** | one **Checkpoints** tab in the conversation view — **change records and pre-operation file snapshots in ONE list**. Each row shows the round (when the log has it), type, time, message count, file-change badges, and old-vs-new input (collapsed by default); pushed live via `session/projection` (no polling), windowed for long histories, nested history browsable outline-style |
|
|
93
|
+
| ↩️ | **Rollback** | **three-way choice: context-only / artifacts-only / both**, with a dry-run preview. Rollback is **always available**; when an entry has no file preimage only context rollback is selectable (the other two are disabled with a reason). A **confirm dialog** lists the round, messages removed, file actions and a risk note (export first). Preview refuses while the agent is running; preview/rollback failures are shown instead of failing silently; a rollback is itself a new checkpoint (`restore`) |
|
|
94
|
+
| ⤓ | **Export as…** | **read-only** zip of exactly that entry (`manifest.json` + the captured file preimages + the original text); it **never rolls anything back**. Uses the host preimage store when available, otherwise a manifest-only archive with a visible note |
|
|
95
|
+
| 🎛 | **Three fixed actions per row** | **Jump to conversation / Rollback / Export as…**, always in that order; an **older host** shows an explicit "upgrade and restart" notice instead of silently missing features |
|
|
94
96
|
| 🧬 | **Lineage identity** | every new session gets a stable lineage id automatically; the sidebar shows one badge per conversation (no duplicates on refresh) |
|
|
95
97
|
| 🧭 | **Jump-to-conversation** | one click from a checkpoint to that point in the conversation (auto-loads history, anchor highlight); when the point is out of the auto-load budget the reason is reported instead of nothing happening |
|
|
96
98
|
| 🧹 | **Bounded storage** | snapshots keep the most recent N checkpoints (default 50); throttled background sweep prunes truncated ones |
|
|
@@ -151,7 +153,7 @@ The same result with plain file edits and `pnpm` — exactly the steps
|
|
|
151
153
|
```json
|
|
152
154
|
{
|
|
153
155
|
"dependencies": {
|
|
154
|
-
"dsh-retrace": "^0.4.
|
|
156
|
+
"dsh-retrace": "^0.4.148"
|
|
155
157
|
},
|
|
156
158
|
"dsh": {
|
|
157
159
|
"profile": {
|
|
@@ -351,12 +353,12 @@ Historical details and exact error strings live in [CHANGELOG.md](./CHANGELOG.md
|
|
|
351
353
|
### Upgrading
|
|
352
354
|
|
|
353
355
|
```bash
|
|
354
|
-
dsh plugin --profile desktop add dsh-retrace@0.4.
|
|
356
|
+
dsh plugin --profile desktop add dsh-retrace@0.4.148
|
|
355
357
|
# then restart DSH — plugins are not hot-reloaded
|
|
356
358
|
```
|
|
357
359
|
|
|
358
|
-
**`0.4.27` and `0.4.31`
|
|
359
|
-
|
|
360
|
+
**`0.4.27` and `0.4.31` are marked deprecated on npm.** Their replacements carry every
|
|
361
|
+
fix they had.
|
|
360
362
|
|
|
361
363
|
**No data migration is required.** The session format is unchanged (v3), no session is
|
|
362
364
|
re-written, and nothing has to be re-indexed: upgrade, restart, and the symptoms above
|
|
@@ -375,7 +377,7 @@ whole tree down, so recover first and diagnose second:
|
|
|
375
377
|
|
|
376
378
|
### Pinning
|
|
377
379
|
|
|
378
|
-
Pin an exact plugin version (`dsh-retrace@0.4.
|
|
380
|
+
Pin an exact plugin version (`dsh-retrace@0.4.148`) and let `dsh-log-contract` resolve to
|
|
379
381
|
`>=0.3.18`. Do not rely on `^0.4` across a host upgrade: compatibility here is decided by
|
|
380
382
|
the **host surface**, not by semver alone.
|
|
381
383
|
|
|
@@ -389,7 +391,6 @@ the **host surface**, not by semver alone.
|
|
|
389
391
|
| **DSH** | `>=0.1.5 <0.3.0` (see `package.json#dsh.compatibility`); desktop and web modes supported |
|
|
390
392
|
| **Runtime files** | All files needed at runtime are **committed** in this repository and declared in `package.json#files` (`lib/**`, `cordis.patch.yml`, `README*.md`, `HUMANS.txt`, `LICENSE`) |
|
|
391
393
|
| **Build output** | Build output is committed (`lib/client.bundle.js`, `lib/dynamic-client.js`, `lib/dynamic-host.js`) and reproducible in-repo: `pnpm i && pnpm build` (`scripts/generate-dynamic.mjs`, `scripts/build-client.mjs`) |
|
|
392
|
-
| **Single-file size** | Every distributed file is **below 256 KiB** (largest ≈ 249 KB) |
|
|
393
394
|
| **Runtime dependencies** | `dsh-log-contract` (log-contract validation), `zod` (argument validation). No post-install scripts, no network access, no additional code download |
|
|
394
395
|
| **Peer dependencies** | `@deepseek-ai/cordis` and DSH client packages (provided by DSH itself, not bundled or redistributed here) |
|
|
395
396
|
| **Permissions / external services** | Reads and writes only the local DSH session data directory and session logs. No external services, no telemetry, no data upload |
|
|
@@ -411,6 +412,10 @@ the **host surface**, not by semver alone.
|
|
|
411
412
|
`message-pending` ("still being generated") rather than being misreported as gone.
|
|
412
413
|
- Regenerate re-sends only the **text** of the original prompt; prompts that
|
|
413
414
|
carried images fall back to the text-only content.
|
|
415
|
+
- File **restore** is text-only: a non-UTF-8 (binary) file is reported as
|
|
416
|
+
`binary-unsupported` and skipped instead of being written back. **Export as…**
|
|
417
|
+
packages the captured preimage bytes (including non-text files) without restoring
|
|
418
|
+
anything.
|
|
414
419
|
- True restore edits the session log **in place** (it neutralizes the two marker
|
|
415
420
|
segments; sequence numbers stay as they are). It refuses to run while the session is
|
|
416
421
|
the one you are viewing, while it is running, or while another process holds the file,
|
package/README.zh.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
> 版本索引:[VERSIONS.md](./VERSIONS.md)
|
|
32
32
|
|
|
33
|
-
> 0.4.
|
|
33
|
+
> **0.4.148 为当前版本**——安装/固定请用 `0.4.148`(**GitHub Release 已发,npm 待发**;npm 最新可安装版本仍为 `0.4.139`,见 [VERSIONS.md](./VERSIONS.md));下文的 `dsh-retrace@0.4.148` 示例适用于该版本。
|
|
34
34
|
|
|
35
35
|
## ⚡ 一分钟安装
|
|
36
36
|
|
|
@@ -84,8 +84,10 @@ dsh plugin --profile desktop add dshmarket # 只需一次
|
|
|
84
84
|
|
|
85
85
|
| | 能力 | 说明 |
|
|
86
86
|
|---|---|---|
|
|
87
|
-
| 🕘 |
|
|
88
|
-
| ↩️ |
|
|
87
|
+
| 🕘 | **统一读档点列表** | 对话视图里的「读档点」Tab:**改动记录与操作前文件快照合并在一个列表**。每行显示轮次(日志里取得到才有)、类型、时间、消息数、文件变更徽标,以及新旧输入对照(默认折叠);经 `session/projection` 推送帧实时更新(零轮询),大列表窗口化,嵌套历史按大纲逐层展开 |
|
|
88
|
+
| ↩️ | **回档** | **三选一:仅对话 / 仅产物 / 两者**,先干跑预览。回档**始终可用**;该条没有文件前像时只能选「仅对话」(另两项置灰并给出原因)。**确认弹窗**列明轮次、移除消息数、文件动作与风险提示(建议先导出)。预览在会话运行中直接拒绝;预览/回档失败都会在界面上显示,不静默;回档本身是新读档点(`restore`) |
|
|
89
|
+
| ⤓ | **导出另存为** | 把该条内容打成**只读** zip(`manifest.json` + 捕获的文件前像 + 原文),**只导出、不回档**。宿主提供前像存储时用真实前像,否则退化为仅 manifest 的归档并显式提示 |
|
|
90
|
+
| 🎛 | **每行固定三个动作** | **回到会话 / 回档 / 导出另存为**,顺序固定;**旧宿主**会显式提示「请升级并重启」,而不是静默缺少功能 |
|
|
89
91
|
| 🧬 | **谱系标识** | 新建会话自动分配稳定谱系标识;侧栏每个会话只显示一个标识(刷新不重复) |
|
|
90
92
|
| 🧭 | **跳转对话** | 从读档点一键跳转到对应位置(自动翻页加载更早历史 + 锚点高亮);该点超出自动加载预算时,给出可诊断原因,而不是点了没反应 |
|
|
91
93
|
| 🧹 | **存储有界** | 快照只保留最近 N 个读档点(默认 50);节流后台扫掠回收被截断的旧档 |
|
|
@@ -135,7 +137,7 @@ dsh plugin --profile <name> add dsh-retrace
|
|
|
135
137
|
```json
|
|
136
138
|
{
|
|
137
139
|
"dependencies": {
|
|
138
|
-
"dsh-retrace": "^0.4.
|
|
140
|
+
"dsh-retrace": "^0.4.148"
|
|
139
141
|
},
|
|
140
142
|
"dsh": {
|
|
141
143
|
"profile": {
|
|
@@ -305,12 +307,11 @@ Client 半区会依据包内 `dsh.client` 元数据被自动打包进 Web 客户
|
|
|
305
307
|
### 升级
|
|
306
308
|
|
|
307
309
|
```bash
|
|
308
|
-
dsh plugin --profile desktop add dsh-retrace@0.4.
|
|
310
|
+
dsh plugin --profile desktop add dsh-retrace@0.4.148
|
|
309
311
|
# 然后重启 DSH —— 插件不会热重载
|
|
310
312
|
```
|
|
311
313
|
|
|
312
|
-
**`0.4.27` 与 `0.4.31`
|
|
313
|
-
包含其全部修复。
|
|
314
|
+
**`0.4.27` 与 `0.4.31` 在 npm 上标记为 deprecated**;它们的替代版本包含其全部修复。
|
|
314
315
|
|
|
315
316
|
**不需要数据迁移。** 会话格式未变(v3),不改写任何会话,也不需要重建索引:升级、重启即可。
|
|
316
317
|
若宿主仍提供旧成员,兼容访问器会让那些路径继续可用 —— 本构建不丢弃老宿主。
|
|
@@ -325,7 +326,7 @@ dsh plugin --profile desktop add dsh-retrace@0.4.135
|
|
|
325
326
|
|
|
326
327
|
### 版本固定建议
|
|
327
328
|
|
|
328
|
-
请固定到确切版本(`dsh-retrace@0.4.
|
|
329
|
+
请固定到确切版本(`dsh-retrace@0.4.148`),并让 `dsh-log-contract` 解析到 `>=0.3.18`。
|
|
329
330
|
**不要在跨宿主升级时依赖 `^0.4` 这种范围**:这里的兼容性由**宿主的面**决定,光看 semver 不够。
|
|
330
331
|
|
|
331
332
|
---
|
|
@@ -340,6 +341,7 @@ dsh plugin --profile desktop add dsh-retrace@0.4.135
|
|
|
340
341
|
(`target-shadowed`);写入尚未 flush 的消息会如实报 `message-pending`(「消息生成中」),
|
|
341
342
|
不再被误判成「已不在活跃对话」。
|
|
342
343
|
- 重新生成只重发原提示的**文本**部分;携带图片的提示会退化为仅文本重发。
|
|
344
|
+
- 文件**恢复**仅支持文本:非 UTF-8(二进制)文件会如实报 `binary-unsupported` 并跳过,不会写回工作区。**导出另存为**会把捕获到的前像字节(含非文本文件)打包带走,但只导出、不回档。
|
|
343
345
|
- **真正恢复**会**原地**改写会话日志(中和两段标记,seq 编号不动)。会话是你当前正在查看的、
|
|
344
346
|
正在运行的,或文件被其他进程持有时,它会拒绝执行;成功后需重开该会话(或刷新)才看到结果。
|
|
345
347
|
|
|
@@ -472,7 +474,6 @@ retrace lineage <session> # 会话 parent 链谱系
|
|
|
472
474
|
| **Node.js** | `>=20.0.0`(见 `package.json#engines`) |
|
|
473
475
|
| **DSH** | `>=0.1.5 <0.3.0`(见 `package.json#dsh.compatibility`;桌面与 Web 两种模式均支持) |
|
|
474
476
|
| **运行所需文件** | 运行时所需文件**全部随仓库提交**并在 `package.json#files` 声明(`lib/**`、`cordis.patch.yml`、README 等) |
|
|
475
|
-
| **单文件体积** | 每个分发文件 **< 256 KiB**(最大约 249 KB) |
|
|
476
477
|
| **构建产物** | 运行所需构建产物**随包提交**(`lib/client.bundle.js`、`lib/dynamic-client.js`、`lib/dynamic-host.js`);仓库内可复现:`pnpm i && pnpm build`(生成器 `scripts/generate-dynamic.mjs`、`scripts/build-client.mjs`) |
|
|
477
478
|
| **运行时依赖** | `dsh-log-contract`(日志契约校验)、`zod`(参数校验);**不联网、不下载额外代码** |
|
|
478
479
|
| **宿主依赖(peer)** | `@deepseek-ai/cordis` 与若干 `@deepseek-ai/dsh-*` 客户端包(由 DSH 提供,不由本插件分发) |
|
package/bin/retrace.mjs
CHANGED
|
File without changes
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-retrace — lib/adapter/compaction-backend.js
|
|
3
|
+
*
|
|
4
|
+
* 注册官方 compaction 后端 = **适配器 2**。
|
|
5
|
+
*
|
|
6
|
+
* 分层
|
|
7
|
+
* - 业务核心(fold-summary/fold-boundary/context-level)= 载体无关纯函数,零改动;
|
|
8
|
+
* - 适配器 1 = retrace.fold(DSH foldSurface 主动折叠,已实现);
|
|
9
|
+
* - 适配器 2 = 本文件:官方 BasicCompactionEngine 子类,**自动折叠**(压力/溢出自动触发),
|
|
10
|
+
* 摘要 = 核心确定摘要(非 LLM)——零 LLM 调用 = 零 token 成本 + 确定性;
|
|
11
|
+
* - 未来平台 = 新适配器实现同一 core-contract,核心不动。
|
|
12
|
+
*
|
|
13
|
+
* 官方机制(桌面捆绑 dsh-compaction-basic,源码实读):
|
|
14
|
+
* - BasicCompactionEngine extends CompactionEngine(cordis Service);
|
|
15
|
+
* - `summarize(input, agent, signal)` 是**唯一子类定制钩子**(源码注释明示);
|
|
16
|
+
* - 触发(thresholdRatio 0.8 自动压力 / context-overflow 恢复)、范围(
|
|
17
|
+
* selectCompactableRange)、保尾(retainRatio 0.16)、装配(agent/pre-step 监听)、
|
|
18
|
+
* 落盘(compaction/start…end + checkpoint marker)全部继承官方;
|
|
19
|
+
* - 我们只把「LLM 摘要」换成「核心确定摘要」:输入 input.messages(派生消息,
|
|
20
|
+
* 官方 buildSummarizationInput 已按 surface 序取好)→ buildSummaryFromMessages。
|
|
21
|
+
*
|
|
22
|
+
* 装配:本文件不自动注册——由 register-compaction-backend.js 装配(opt-in)。
|
|
23
|
+
* ⚠️ 标准桌面宿主已装官方 compaction-basic,cordis 同名注册=拒绝,
|
|
24
|
+
* 插件单方不可替换 → 交付口径 = 无官方后端宿主下的确定性自动折叠(见 register 模块头)。
|
|
25
|
+
* 依赖(@deepseek-ai/dsh-compaction-basic)仅桌面宿主存在 → 动态 import + 降级友好:
|
|
26
|
+
* 找不到包/宿主未装配时创建函数返回 null,调用方静默跳过(不崩插件)。
|
|
27
|
+
*/
|
|
28
|
+
import { buildSummaryFromMessages } from '../fold-summary.js'
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 创建确定摘要 compaction 后端(官方 BasicCompactionEngine 子类)。
|
|
32
|
+
* @param {object} deps
|
|
33
|
+
* @param {object} deps.basic - @deepseek-ai/dsh-compaction-basic 模块(动态注入,便于测试桩)。
|
|
34
|
+
* @param {object} deps.buildSummary - 核心摘要函数(默认 buildSummaryFromMessages,可注入测试)。
|
|
35
|
+
* @param {string} [deps.summaryKind] - 摘要类型标签(日志用,默认 'retrace-deterministic')。
|
|
36
|
+
* @returns {Function} create(ctx, config) → 后端实例;basic 缺失时 create 返回 null。
|
|
37
|
+
*/
|
|
38
|
+
export function createDeterministicCompactionBackend(deps) {
|
|
39
|
+
const { basic, summaryKind = 'retrace-deterministic' } = deps
|
|
40
|
+
if (!basic?.BasicCompactionEngine) {
|
|
41
|
+
return () => null // 宿主无官方 compaction-basic → 不装配(降级)
|
|
42
|
+
}
|
|
43
|
+
const { BasicCompactionEngine } = basic
|
|
44
|
+
// 默认核心确定摘要(消息版);可注入(测试/未来平台复用同一 create)
|
|
45
|
+
const summarize = typeof deps.buildSummary === 'function' ? deps.buildSummary : buildSummaryFromMessages
|
|
46
|
+
|
|
47
|
+
/** 子类:唯一覆写点 = summarize(官方源码注释:sole subclass customization hook)。 */
|
|
48
|
+
class DeterministicCompactionBackend extends BasicCompactionEngine {
|
|
49
|
+
static inject = BasicCompactionEngine.inject
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 用核心确定摘要替代 LLM 摘要:input.messages(派生消息,官方已按 surface 序排好)
|
|
53
|
+
* → buildSummaryFromMessages → 固定模板文本块。零 LLM 调用。
|
|
54
|
+
* @param {object} input - { system?, tools?, messages }(官方 buildSummarizationInput)。
|
|
55
|
+
* @param {object} agent - 官方 agent(未用,兼容签名)。
|
|
56
|
+
* @param {object} signal - 官方取消信号(未用——本地纯函数瞬间完成)。
|
|
57
|
+
* @returns {Promise<{summary: Array<{type:'text',text:string}>, llmStreamCall:boolean, provider:string, model:string, kind:string}>}
|
|
58
|
+
*/
|
|
59
|
+
async summarize(input, agent, signal) {
|
|
60
|
+
const messages = Array.isArray(input?.messages) ? input.messages : []
|
|
61
|
+
const text = summarize(messages)
|
|
62
|
+
if (!text || !text.trim()) {
|
|
63
|
+
throw new Error(`retrace deterministic compaction produced empty summary (${messages.length} messages)`)
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
summary: [{ type: 'text', text }],
|
|
67
|
+
// rawOutput 不返回(undefined)→ 官方 commitCompactionBody 的
|
|
68
|
+
// callProvenance = {}(llmStreamCall!==true 且 rawOutput===undefined);空数组会
|
|
69
|
+
// 落盘误导性 rawOutput:[] 事件字段。
|
|
70
|
+
llmStreamCall: false, // 零 LLM:官方据此省略 rawOutput/usage 记账
|
|
71
|
+
provider: 'retrace',
|
|
72
|
+
model: summaryKind,
|
|
73
|
+
kind: summaryKind,
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** create(ctx, config):与官方 BasicCompactionEngine 同签名(继承其 Config 校验)。 */
|
|
79
|
+
return (ctx, config = {}) => {
|
|
80
|
+
const instance = new DeterministicCompactionBackend(ctx, {
|
|
81
|
+
...config,
|
|
82
|
+
auto: config.auto !== false, // 默认开启自动压力触发(与官方默认一致)
|
|
83
|
+
})
|
|
84
|
+
// 实例盖静态标记,register 探测用它(不依赖 constructor.name,
|
|
85
|
+
// 打包压缩/宿主包装后名字不可靠)。
|
|
86
|
+
try { Object.defineProperty(instance, RETRACE_BACKEND_TAG, { value: true, configurable: false, enumerable: false }) } catch { /* 只读宿主实例(理论不可能)忽略 */ }
|
|
87
|
+
return instance
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** 实例标记(register 探测 retrace 后端用;压缩安全,不依赖类名)。 */
|
|
92
|
+
export const RETRACE_BACKEND_TAG = Symbol.for('dsh-retrace.compaction-backend')
|
package/lib/adapter/contract.js
CHANGED
|
@@ -214,15 +214,15 @@ export function createDshMarkerWriter({ validateMarker, log = () => {}, meter, d
|
|
|
214
214
|
* @returns {Promise<object>} 第 2 段事件(调用方读 seq/surfaceOp)。
|
|
215
215
|
*/
|
|
216
216
|
async writeMarker(session, span, meta) {
|
|
217
|
-
// ──
|
|
217
|
+
// ── 自动折叠默认关闭(最底层闸,需显式开启)─────────────────────────
|
|
218
218
|
// 判定收敛在 marker-carrier.isAutoFoldSource(op='fold' 且未声明用户发起);
|
|
219
219
|
// AUTOFOLD_HARD_DISABLED=true ⇒ 拒写并返回显式错误码,零落盘(审计段/载体段
|
|
220
220
|
// 都不写)。拒写留一行可核日志:走注入的宿主 logger(console.log 进不了宿主
|
|
221
|
-
//
|
|
221
|
+
// 日志,排障时拿不到证据)。手动 recall / edit / regenerate 与用户显式
|
|
222
222
|
// 折叠(userInitiated)不受影响。
|
|
223
223
|
if (AUTOFOLD_HARD_DISABLED && isAutoFoldSource(meta)) {
|
|
224
224
|
log(`retrace: HARD-BLOCK 拒写自动触发的折叠 marker(AUTOFOLD_HARD_DISABLED=true):op=${String(meta?.op ?? '')} session=${String(session?.id ?? '')} targetSeq=${String(meta?.targetSeq ?? '')} span=${String(span?.start ?? '?')}..${String(span?.end ?? '?')} — 零写入`)
|
|
225
|
-
throw editorError('autofold-hard-disabled', '
|
|
225
|
+
throw editorError('autofold-hard-disabled', '自动触发的折叠默认关闭(AUTOFOLD_HARD_DISABLED=true):本次 marker 零落盘;手动编辑/撤回与用户显式折叠不受影响。')
|
|
226
226
|
}
|
|
227
227
|
// 契约边界:业务层 → 适配器。span 不合规(空/倒置/非连续段)在这里立刻报错,
|
|
228
228
|
// 不进入形状翻译——否则会写出 surfaceOp 与 sourceEventSeqs 不一致的载体
|
|
@@ -361,9 +361,9 @@ export function createDshMarkerWriter({ validateMarker, log = () => {}, meter, d
|
|
|
361
361
|
* ② **成对审计未被绕过,而是不适用**:两段路径的成对纪律(第 1 段
|
|
362
362
|
* `compaction/prune` = shadow-price claim,与第 2 段紧邻成对,见 writeMarker
|
|
363
363
|
* 与 assertPairing)原样保留;本路径一条 claim 都不写 —— 回收副本不遮蔽任何
|
|
364
|
-
* 节点,写 claim 会留下无人消费的孤儿审计行(
|
|
364
|
+
* 节点,写 claim 会留下无人消费的孤儿审计行(真实会话里出现过的
|
|
365
365
|
* 形态)。单段 append 无第 1 段 ⇒ 无"半对"可言;
|
|
366
|
-
* ③
|
|
366
|
+
* ③ 自动折叠默认关闭的闸(AUTOFOLD_HARD_DISABLED + isAutoFoldSource)只判
|
|
367
367
|
* `op === 'fold'`:本写入的 op 是回收,不落在该闸上;那道闸的代码一行不动;
|
|
368
368
|
* ④ 写入前过注入的 `validateMarker`(prewrite-guard 完整契约校验,信封不带 seq
|
|
369
369
|
* —— 与 unhide 取消标记同规),与 marker 写入共用同一条校验链;
|