@lmzhen/dsh-evolution-core 0.32.4 → 0.32.5
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 +63 -117
- package/lib/types/events.d.ts +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,123 +1,69 @@
|
|
|
1
1
|
# @lmzhen/dsh-evolution-core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
section, and importing the package root is its only entry.
|
|
5
|
-
|
|
6
|
-
## Model surface
|
|
7
|
-
|
|
8
|
-
- **Model-visible:** nothing of its own: the guidance text and memory snapshot it renders are injected by the rows that consume it (`tool-memory`, `tool-skill-manage`).
|
|
9
|
-
- **Prompt prefix / KV cache:** unchanged by this package: family-level rules single-sourced in `packages/README.md` §"Model-visible prompt prefix and the KV cache".
|
|
10
|
-
- **Mount it?** no: a library, not a row; consumed by the family's rows (e.g. `evolution-threat`, `evolution-policy`, `memory-files`, `skill-usage`, `evolution-state-json`).
|
|
11
|
-
|
|
12
|
-
## Known limitations
|
|
13
|
-
|
|
14
|
-
- **The family tree IS the platform's USER skill root.** `skillsRoot()` resolves to `<dshHome>/skills` — the root the platform's `skill-filesystem` serves at rank 400 — so "the same tree" holds while that root is enabled. Two divergences stay documented rather than mirrored: a platform row with `includeDefaultRoots:false` (or a composition without this family's catalog row) removes the only providers that serve the tree while family writes still succeed, and the platform's CWD-derived PROJECT roots (`<cwd>/.dsh/skills`, `<cwd>/.agents/skills`) are not read by the family at all, so `ctx.skills.get(name).path` and `SkillLibrary.read(name)` can name different files. Mirroring project roots is `U-3`, deliberately not started; point `customSkillDirs` (platform side) or `root` (family side) at a shared directory when the project tree has to be visible to both.
|
|
15
|
-
- This package is a library, not a Cordis row; do not mount it as a plugin.
|
|
16
|
-
- 数值配置已在消费方 Config 面钳制(`min 1`/各字段域);`MemoryStore` 内部对 `limit <= 0` 仍按 unbounded 防御处理——那是库内部防御,不构成"0 = 禁用"的配置语义。
|
|
17
|
-
- **Content-history storage grows with the number of DISTINCT bodies a skill has ever been written
|
|
18
|
-
with, not with the retained count.** Trimming drops index entries; the blobs they point at stay on
|
|
19
|
-
disk (they are shared by content, so a reference count would have to span every skill's index, and no
|
|
20
|
-
sweeper exists yet). Measured on a 3.6 KB skill written 41 times: a 5.7 KB index over 20 entries and
|
|
21
|
-
41 blob files totalling 150 KB (41x the live body); unchanged writes add nothing. Plan disk accordingly
|
|
22
|
-
or remove `.history/blobs` entries by hand.
|
|
23
|
-
- Skill-library writes are serialized **in-process**. The shipped IO backend declares single-process; a second process sharing `DSH_HOME` is unsupported. The full concurrency model, its two-phase exceptions and their provenance are in Notes and history.
|
|
24
|
-
|
|
25
|
-
**Runtime invariant:** No companion is published. The platform auto-assembles nothing and the family mounts no `<pkg>/invariant` cordis row, so a companion here would never execute (v37 S2.1 / I-3).
|
|
26
|
-
|
|
27
|
-
## Notes and history
|
|
28
|
-
|
|
29
|
-
- Similarity is TWO NAMED QUESTIONS plus a projection the caller declares (`quality.ts`): `identity(text)` ("is it the same text?", a normalized-content hash) and `affinity(a, b)` ("how much vocabulary do these two share?", Jaccard over two `vocabulary()` sets), asked over `projectionText(projection, input)` — `body` for the library-wide scan, `summary` (name + description) for the create-time hint. `computePrefixClusters` stays a name-side STRUCTURAL index, not a score. Adding a projection is one entry in that table; a caller that wants a fourth ruler should name the question it is really asking instead.
|
|
30
|
-
- A whole-body replacement that keeps less than half of the previous body appends one line to its own result
|
|
31
|
-
(`contentRetentionFeedback`, design §4 item 3): the ratio, both character counts, and the fact that the
|
|
32
|
-
replaced version is still in the history. Computed in the write funnel where both bodies are in hand, feedback
|
|
33
|
-
only — no ratio refuses a write, and the function owns no configuration.
|
|
34
|
-
- **A REMOVAL now leaves an entry (E2, 2026-09-30).** `nextHistoryIndex` mints an entry from the AFTER side,
|
|
35
|
-
so an operation with `after === null` (removing a support file) used to record nothing once its bytes were
|
|
36
|
-
already indexed: the deletion was invisible and its action vocabulary unreachable. A removal records the bytes
|
|
37
|
-
it removed, labeled with the write that removed them, so a face can say "these bytes are gone" and undoing that
|
|
38
|
-
entry puts the file back. The entry deliberately carries no `beforeHash` (its own hash IS the removed content).
|
|
39
|
-
- `anchorVerdict` is exported: the stage-time anchor rule ("does this write's target still hold the bytes the
|
|
40
|
-
caller staged against?") has ONE implementation, and read-only readers (a preview, a dry run) call it instead
|
|
41
|
-
of re-deriving a `contentHash` comparison.
|
|
42
|
-
- Content history is HISTORY ONLY: the skill tree is the single truth for current content, and no judgement reads the version index (design invariant I1). Recording is best-effort but happens inside the write lock, so the index never describes content that did not land; a failed record warns once per instance instead of failing the write.
|
|
43
|
-
- Skill-library mutations are read-modify-write on one file, so `SkillLibrary` serializes them in-process with a `makeSerialQueue` chain: `update`, `patch`, `restructure`, `writeSupportFile` and (since 0.3.46) `consolidate`'s target read→merge→commit run their whole read→validate→write under one serial task, so two concurrent mutators on one skill never interleave in this process.
|
|
44
|
-
- `create` is INSIDE the serial chain and, when a transact backend is bound, its exists check runs inside the same per-file transact (v18); `archive`/`consolidate` are rename-based two-phase paths and stay outside the single-file serial chain.
|
|
45
|
-
- **v18 residual (updated):** `create`, `removeSupportFile` and `setPinned` now run on the serial chain (`removeSupportFile`'s delete also goes through the per-file transact), so the remaining single-file residual is the protection TOCTOU (a marker check outside the transact) and the multi-file two-phase paths `archive`/`consolidate`/`restructure`.
|
|
46
|
-
- The race needs a concurrent mutator on the SAME skill file/package; the exposure is acknowledged and the protection check is the next candidate (see the v18 optimization plan, E-5).
|
|
47
|
-
- The constructor binds the IO backend's `transact` by default since 0.3.27: the single-file entry points (`update`, `patch`, `writeSupportFile`, and each per-file piece of `restructure`) run their read→write inside that transaction. The shipped backend is **single-process**, so this does not protect two processes sharing `DSH_HOME`.
|
|
48
|
-
- The two-phase paths deliberately stay outside that lock: `create`'s exists probe runs inside the transact when a transact backend is bound (v18), so only a transact-less custom backend can still double-pass the probe across processes; `archive`/`consolidate` are rename-based with best-effort rollback (an archive loser's rollback surfaces the raw failure when the source vanished), and `restructure`'s multi-file swap can expose an interleaved tree to a concurrent reader.
|
|
49
|
-
- These residual windows are documented rather than locked. The shipped backend is single-process; cross-process writers to the same skill file are unsupported and must not be treated as serialized.
|
|
3
|
+
> 内部引擎,支撑记忆、技能、历史、恢复和审批。
|
|
50
4
|
|
|
51
|
-
##
|
|
5
|
+
## 你会看到
|
|
6
|
+
|
|
7
|
+
没有直接入口;用户看到的是记忆、技能、历史和撤销。
|
|
8
|
+
|
|
9
|
+
## 什么时候会用到
|
|
10
|
+
|
|
11
|
+
每次 Agent 写记忆/技能、看历史、恢复时。
|
|
12
|
+
|
|
13
|
+
## 默认 / 前提
|
|
52
14
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
15
|
+
随 all/host/分层安装自动工作。
|
|
16
|
+
|
|
17
|
+
## 边界
|
|
18
|
+
|
|
19
|
+
普通用户不需要知道其中的事务/状态机。
|
|
20
|
+
|
|
21
|
+
## 维护者参考(用户可跳过)
|
|
22
|
+
|
|
23
|
+
## Events (the family's own, process-local)
|
|
56
24
|
|
|
57
|
-
|
|
|
25
|
+
| 事件 | the `@mode` | 用途 |
|
|
58
26
|
|---|---|---|
|
|
59
|
-
| `evolution/skill-mutated` | emit (
|
|
60
|
-
| `evolution/skills-refresh` | emit (
|
|
61
|
-
| `evolution/review-scheduled` | emit (
|
|
62
|
-
| `evolution/review-
|
|
63
|
-
| `evolution/review-
|
|
64
|
-
| `evolution/
|
|
65
|
-
| `evolution/memory-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
| `E-
|
|
86
|
-
| `E-
|
|
87
|
-
| `E-
|
|
88
|
-
| `E-
|
|
89
|
-
| `E-
|
|
90
|
-
| `E-
|
|
91
|
-
| `E-
|
|
92
|
-
| `E-
|
|
93
|
-
| `E-
|
|
94
|
-
| `E-
|
|
95
|
-
| `E-
|
|
96
|
-
| `E-
|
|
97
|
-
| `E-
|
|
98
|
-
| `E-
|
|
99
|
-
| `E-
|
|
100
|
-
| `E-
|
|
101
|
-
| `E-
|
|
102
|
-
| `E-325` | the host data plane is unavailable: no connection service, so panel/approval routes are not registered | use `/evolution pending`, `approve`, `reject` (same service methods) and run `/evolution doctor` |
|
|
103
|
-
| `E-319` | the confirmation before a create or bare delete went unanswered for `skillWriteConfirmTimeoutSeconds` (`skillWriteConfirm: 'timeout'`), so the write was cancelled | set `skillWriteConfirm` to `auto` (write without asking), keep `ask` (wait until answered), or raise the timeout |
|
|
104
|
-
Symptom → next step; the exact text of every code (`E-301`–`E-326`) is stored once in
|
|
105
|
-
|
|
106
|
-
## 单元与撤销(本包负责的契约)
|
|
107
|
-
|
|
108
|
-
- 本包持有单元契约的**类型与折叠**:SkillVersion.unitHead 两形态互斥(代表片 { moves, sources }/路标 { skill }),判别式固定为 moves !== undefined;读端折叠必须带上新字段,否则下一次写就丢。
|
|
109
|
-
- 成员解析与孤路标判定在 src/unit-members.ts:candidateSkills(代表片首位、去重保序)、resolveUnitMembersFromIndexes(只按已知 key、三向校验)、landmarkVerdict 与 staleRouteStubs(可跳 ⟺ 目标存在 ∧ 其索引仍持该 unitId;输出按 skill/version/owner 确定性排序)。
|
|
110
|
-
- 写作端的硬规则:kind 判 previous === null(不是 undefined);path 抄循环里既有的 rel;同一目标写两次时清单保留最后一次写入的 afterRef。
|
|
111
|
-
- 面向读者的完整说明见仓库 docs/units-and-undo.md。
|
|
112
|
-
|
|
113
|
-
## Restricted preset ids
|
|
114
|
-
|
|
115
|
-
The review and maintenance channels run under two internally generated restricted presets (they are
|
|
116
|
-
NOT user-facing preset picker entries):
|
|
117
|
-
|
|
118
|
-
- `evolution-reviewer-readonly` — the review channel's child preset;
|
|
119
|
-
- `evolution-maintainer-readonly` — the maintenance channel's child preset.
|
|
120
|
-
|
|
121
|
-
The family's own agent-preset ids (`EVOLUTION_PRESET_IDS`) are `evolution`, `evolution-ptc`,
|
|
122
|
-
`evolution-cordis` and `evolution-minimal`. The two id sets are deliberately separate: a restricted
|
|
123
|
-
preset is created at runtime from a parent preset, never installed or selected.
|
|
27
|
+
| `evolution/skill-mutated` | emit (one-way) | 技能树写入后失效目录缓存 |
|
|
28
|
+
| `evolution/skills-refresh` | emit (one-way) | `/evolution skills refresh` 显式刷新 |
|
|
29
|
+
| `evolution/review-scheduled` | emit (one-way) | 审查已安排 |
|
|
30
|
+
| `evolution/review-completed` | emit (one-way) | branch 审查完成 |
|
|
31
|
+
| `evolution/review-error` | emit (one-way) | 审查流水线失败 |
|
|
32
|
+
| `evolution/plan-applied` | emit (one-way) | 计划执行结果 |
|
|
33
|
+
| `evolution/memory-applied` | emit (one-way) | 记忆写入成功 |
|
|
34
|
+
| `evolution/memory-provider-registered` | emit (one-way) | 记忆 provider 注册 |
|
|
35
|
+
|
|
36
|
+
预设 id:`evolution`、`evolution-ptc`、`evolution-cordis`、`evolution-minimal`、`evolution-reviewer-readonly`、`evolution-maintainer-readonly`。
|
|
37
|
+
|
|
38
|
+
## 维护者参考:错误码表(用户可跳过)
|
|
39
|
+
|
|
40
|
+
(`E-301`–`E-326`):命令/服务不可用时的明确提示;具体文案在 `src/errors.ts`。
|
|
41
|
+
|
|
42
|
+
| 代码 | 含义 |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `E-301` | 批准服务未挂载 |
|
|
45
|
+
| `E-302` | 策展服务未挂载 |
|
|
46
|
+
| `E-303` | 回放服务未挂载 |
|
|
47
|
+
| `E-304` | 批准服务版本过旧 |
|
|
48
|
+
| `E-305` | 调用无 agent/投递通道 |
|
|
49
|
+
| `E-306` | 前台写入无法回放 |
|
|
50
|
+
| `E-307` | 设置分区/修订不可读 |
|
|
51
|
+
| `E-308` | 未知参数分组 |
|
|
52
|
+
| `E-309` | 参数修订冲突 |
|
|
53
|
+
| `E-310` | 设置服务拒绝写入 |
|
|
54
|
+
| `E-311` | 无设置服务 |
|
|
55
|
+
| `E-312` | 参数写入失败 |
|
|
56
|
+
| `E-313` | 未知参数 id |
|
|
57
|
+
| `E-314` | 部署参数不可从会话写 |
|
|
58
|
+
| `E-315` | 参数无用户层 |
|
|
59
|
+
| `E-316` | 命名空间未注册 |
|
|
60
|
+
| `E-317` | 技能写入未确认 |
|
|
61
|
+
| `E-318` | 技能未读先写 |
|
|
62
|
+
| `E-319` | 确认超时取消 |
|
|
63
|
+
| `E-320` | 无 profile home |
|
|
64
|
+
| `E-321` | 无 evolution-io |
|
|
65
|
+
| `E-322` | 参数跨字段约束 |
|
|
66
|
+
| `E-323` | 子代理通道不可用 |
|
|
67
|
+
| `E-324` | 受限 preset 不可用 |
|
|
68
|
+
| `E-325` | Host 数据面不可用 |
|
|
69
|
+
| `E-326` | 支撑文件未读先写 |
|
package/lib/types/events.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ declare module '@deepseek-ai/cordis' {
|
|
|
99
99
|
* A reviewed plan finished its write leg, with the counts that describe what landed. An
|
|
100
100
|
* ANNOUNCEMENT: the family's own ledger of plan outcomes (A98 / O-1).
|
|
101
101
|
* @param event - the outcome counts, the first failure message, and the policy fingerprint.
|
|
102
|
+
* @mode emit
|
|
102
103
|
*/
|
|
103
104
|
'evolution/plan-applied'(event: EvolutionPlanAppliedEvent): void;
|
|
104
105
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-core",
|
|
3
3
|
"description": "Shared stores, prompts, signals and lifecycle logic for the dsh-evolution plugin family (community build)",
|
|
4
|
-
"version": "0.32.
|
|
4
|
+
"version": "0.32.5",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"yaml": "^2.4.2",
|
|
50
50
|
"zod": "^4.4.3",
|
|
51
51
|
"js-yaml": "^4.1.0",
|
|
52
|
-
"@lmzhen/dsh-evolution-contract": "^0.32.
|
|
52
|
+
"@lmzhen/dsh-evolution-contract": "^0.32.5"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@deepseek-ai/cordis": "^4.0.5",
|