@lmzhen/dsh-evolution-core 0.41.0 → 0.43.0
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/lib/composition/index.js +2 -2
- package/lib/{composition-Da8NfRI7.js → composition-CVafrlEw.js} +2 -2
- package/lib/guards-3f02mnf2.js +29 -0
- package/lib/http-routes.js +205 -1
- package/lib/index.js +3584 -15050
- package/lib/mutations-jUuOPaCn.js +718 -0
- package/lib/platform/index.js +2 -2
- package/lib/{platform-CFp373_0.js → platform-B06_h8t-.js} +4 -1
- package/lib/runtime/plugin.js +2 -2
- package/lib/{session-projection-CXUNPkq9.js → session-projection-EB7mUOlJ.js} +63 -63
- package/lib/skill-health-BLGZTIv8.js +3773 -0
- package/lib/skill-history-_Cssts5o.js +1912 -0
- package/lib/skills.js +4067 -0
- package/lib/subagent/index.js +1 -1
- package/lib/types/home-fence.d.ts +7 -0
- package/lib/types/home-fence.js +58 -3
- package/lib/types/index.d.ts +1 -18
- package/lib/types/index.js +1 -18
- package/lib/types/io.js +1 -1
- package/lib/types/mutation-authority.d.ts +14 -37
- package/lib/types/mutation-authority.js +16 -103
- package/lib/types/mutation-storage-adapter.js +9 -6
- package/lib/types/mutation-unit.d.ts +14 -0
- package/lib/types/mutation-unit.js +30 -10
- package/lib/types/opt-in.js +1 -1
- package/lib/types/params.js +1 -1
- package/lib/types/platform/index.d.ts +8 -1
- package/lib/types/platform/index.js +3 -0
- package/lib/types/platform-services.js +0 -1
- package/lib/types/review-channel.js +3 -1
- package/lib/types/review-context.js +3 -1
- package/lib/types/run-registry.d.ts +2 -24
- package/lib/types/scope.js +1 -1
- package/lib/types/signals.d.ts +1 -1
- package/lib/types/skill-store.d.ts +7 -1
- package/lib/types/skill-store.js +43 -80
- package/lib/types/skills.d.ts +11 -0
- package/lib/types/skills.js +11 -0
- package/lib/types/subagent/types.d.ts +3 -3
- package/lib/types/tree-lock.js +4 -1
- package/lib/types/unit-claim.d.ts +8 -0
- package/lib/types/unit-claim.js +3 -0
- package/lib/types/unit-journal.d.ts +3 -1
- package/lib/types/unit-journal.js +12 -3
- package/lib/types/unit-storage.d.ts +1 -0
- package/lib/types/write-gates.d.ts +1 -1
- package/lib/types/write-gates.js +3 -1
- package/lib/types/write.d.ts +11 -0
- package/lib/types/write.js +11 -0
- package/lib/write.js +357 -0
- package/package.json +16 -4
- package/lib/http-routes-_anZVlPf.js +0 -233
- package/lib/types/unit-backend.d.ts +0 -5
- package/lib/types/unit-backend.js +0 -55
- package/lib/types/unit-transaction.d.ts +0 -225
- package/lib/types/unit-transaction.js +0 -501
- package/lib/{ensure-C5Mo1dbB.js → ensure-BjToTMMj.js} +1 -1
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import { type WriteConfirm, type WriteConfirmMode } from './write-authority.ts';
|
|
26
26
|
import type { ConfirmContext } from './write-authority.ts';
|
|
27
|
-
import {
|
|
27
|
+
import type { WriteOrigin } from './skill-store.ts';
|
|
28
28
|
/** The point whose verdict is being taken. */
|
|
29
29
|
export type WriteGatePoint = 'admission' | 'execution';
|
|
30
30
|
/** What every gate reads. */
|
package/lib/types/write-gates.js
CHANGED
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
* @module @lmzhen/dsh-evolution-core/write-gates
|
|
24
24
|
*/
|
|
25
25
|
import { DEFAULT_WRITE_CONFIRM_MODE, DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS } from "./write-authority.js";
|
|
26
|
-
import { SKILL_ACTION_REQUIRED_FIELDS
|
|
26
|
+
import { SKILL_ACTION_REQUIRED_FIELDS } from "./constants.js";
|
|
27
|
+
import { errorText } from "./errors.js";
|
|
28
|
+
import { isUnreadWrite } from "./skill-reads.js";
|
|
27
29
|
/** The confirm question's stable id — one question per write, so an answer to an earlier prompt
|
|
28
30
|
* can never be read as the answer to a later one. */
|
|
29
31
|
const CONFIRM_QUESTION_ID = 'evolution-skill-write';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The one byte-write engine surface. Consumers must import it from the documented subpath. */
|
|
2
|
+
export * from './write-kernel.ts';
|
|
3
|
+
export * from './mutation-unit.ts';
|
|
4
|
+
export * from './mutation-storage-adapter.ts';
|
|
5
|
+
export * from './unit-claim.ts';
|
|
6
|
+
export * from './unit-journal.ts';
|
|
7
|
+
export * from './unit-storage.ts';
|
|
8
|
+
export * from './unit-undo.ts';
|
|
9
|
+
export * from './unit-undo-plan.ts';
|
|
10
|
+
export * from './unit-members.ts';
|
|
11
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The one byte-write engine surface. Consumers must import it from the documented subpath. */
|
|
2
|
+
export * from "./write-kernel.js";
|
|
3
|
+
export * from "./mutation-unit.js";
|
|
4
|
+
export * from "./mutation-storage-adapter.js";
|
|
5
|
+
export * from "./unit-claim.js";
|
|
6
|
+
export * from "./unit-journal.js";
|
|
7
|
+
export * from "./unit-storage.js";
|
|
8
|
+
export * from "./unit-undo.js";
|
|
9
|
+
export * from "./unit-undo-plan.js";
|
|
10
|
+
export * from "./unit-members.js";
|
|
11
|
+
//# sourceMappingURL=write.js.map
|
package/lib/write.js
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { r as contentHash } from "./mutations-jUuOPaCn.js";
|
|
2
|
+
import { $ as writeUnitSnapshot, A as unitJournalPort, B as readUnitEvidence, F as readUnitJournal, G as unitIndexPath, H as readUnitReceipt, I as unitJournalPath, J as unitSnapshotsDir, K as unitReceiptPath, L as unitJournalPhaseRank, M as UNIT_JOURNAL_PHASES, N as UNIT_JOURNAL_SCHEMA_VERSION, P as assertUnitJournalTransition, Q as writeUnitReceipt, R as writeUnitJournal, U as readUnitSnapshot, V as readUnitIndex, W as unitEvidencePath, X as upsertUnitIndex, Y as unitStorageKey, Z as writeUnitEvidence, et as MutationUnit, f as entryTarget, j as unitSnapshotPort, k as pruneTreeChangeUnits, nt as validateMutationRequest, q as unitSnapshotPath, rt as WriteKernel, tt as fileMutationLock, z as UNIT_STORAGE_SCHEMA_VERSION } from "./skill-history-_Cssts5o.js";
|
|
3
|
+
//#region lib/types/unit-undo.js
|
|
4
|
+
/**
|
|
5
|
+
* Cross-skill unit undo executor.
|
|
6
|
+
*
|
|
7
|
+
* Phase A is a zero-write preflight: every live path still carries the unit's after-bytes and
|
|
8
|
+
* every pre-unit blob is readable. Phase B restores archived members, applies support files,
|
|
9
|
+
* writes the body last, then archives a target the unit created. Any preflight refusal means
|
|
10
|
+
* no write at all.
|
|
11
|
+
*/
|
|
12
|
+
async function executeUnitUndo(plan, sink) {
|
|
13
|
+
const refusals = [...plan.refusals];
|
|
14
|
+
const restores = [];
|
|
15
|
+
for (const restore of plan.restores) {
|
|
16
|
+
if (sink.hasArchived !== void 0) {
|
|
17
|
+
if (!await sink.hasArchived(restore.skill)) refusals.push(`${restore.skill}(归档成员不在 .archive)`);
|
|
18
|
+
else restores.push(restore);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
restores.push(restore);
|
|
22
|
+
}
|
|
23
|
+
const prepared = [];
|
|
24
|
+
for (const op of plan.ops) {
|
|
25
|
+
const live = op.path === "" ? await sink.readSkill(op.skill) : await sink.readSupport(op.skill, op.path);
|
|
26
|
+
if (live === null) {
|
|
27
|
+
if (op.remove) continue;
|
|
28
|
+
if (op.expectedHash === contentHash("")) {
|
|
29
|
+
const bytes = op.preUnitHash === void 0 ? null : await sink.readBlob(op.preUnitHash);
|
|
30
|
+
if (bytes === null) {
|
|
31
|
+
refusals.push(`${op.skill}/${op.path === "" ? "SKILL.md" : op.path}(单元前字节读不到:blob ${op.preUnitHash ?? "(missing)"})`);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
prepared.push({
|
|
35
|
+
...op,
|
|
36
|
+
bytes,
|
|
37
|
+
live: "",
|
|
38
|
+
absent: true
|
|
39
|
+
});
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
refusals.push(`${op.skill}/${op.path === "" ? "SKILL.md" : op.path}(盘上文件不存在)`);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (contentHash(live) !== op.expectedHash) {
|
|
46
|
+
refusals.push(`${op.skill}/${op.path === "" ? "SKILL.md" : op.path}(盘上字节已变,回退会覆盖别人的改动)`);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (op.remove) {
|
|
50
|
+
prepared.push({
|
|
51
|
+
...op,
|
|
52
|
+
bytes: "",
|
|
53
|
+
live,
|
|
54
|
+
absent: false
|
|
55
|
+
});
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const bytes = op.preUnitHash === void 0 ? null : await sink.readBlob(op.preUnitHash);
|
|
59
|
+
if (bytes === null) {
|
|
60
|
+
refusals.push(`${op.skill}/${op.path === "" ? "SKILL.md" : op.path}(单元前字节读不到:blob ${op.preUnitHash ?? "(missing)"})`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
prepared.push({
|
|
64
|
+
...op,
|
|
65
|
+
bytes,
|
|
66
|
+
live,
|
|
67
|
+
absent: false
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (refusals.length > 0) return {
|
|
71
|
+
ok: false,
|
|
72
|
+
message: `整单元撤销未开始(零写)—— 预检未通过:${refusals.join(";")}。修好后可重试。`,
|
|
73
|
+
reverted: []
|
|
74
|
+
};
|
|
75
|
+
const reverted = [];
|
|
76
|
+
const done = () => reverted.length === 0 ? "无" : reverted.join(", ");
|
|
77
|
+
for (const restore of restores) {
|
|
78
|
+
const result = await sink.restoreFromArchive(restore.skill);
|
|
79
|
+
if (!result.ok) return {
|
|
80
|
+
ok: false,
|
|
81
|
+
message: `恢复「${restore.skill}」失败:${result.message} —— 撤销未完成(已回退:${done()})。`,
|
|
82
|
+
reverted
|
|
83
|
+
};
|
|
84
|
+
reverted.push(restore.skill);
|
|
85
|
+
}
|
|
86
|
+
const supportOps = prepared.filter((op) => op.path !== "");
|
|
87
|
+
const bodyOps = prepared.filter((op) => op.path === "");
|
|
88
|
+
for (const op of supportOps) {
|
|
89
|
+
const result = op.remove ? await sink.removeSupportFile(op.skill, op.path, { sha256: op.expectedHash }) : op.absent ? await sink.writeSupportFile(op.skill, op.path, op.bytes) : await sink.writeSupportFile(op.skill, op.path, op.bytes, { sha256: op.expectedHash });
|
|
90
|
+
if (!result.ok) return {
|
|
91
|
+
ok: false,
|
|
92
|
+
message: `${op.skill}/${op.path}:${result.message} —— 撤销未完成(已回退:${done()})。`,
|
|
93
|
+
reverted
|
|
94
|
+
};
|
|
95
|
+
reverted.push(op.skill + "/" + op.path);
|
|
96
|
+
}
|
|
97
|
+
for (const op of bodyOps) {
|
|
98
|
+
const result = await sink.updateSkill(op.skill, op.bytes, { sha256: op.expectedHash });
|
|
99
|
+
if (!result.ok) return {
|
|
100
|
+
ok: false,
|
|
101
|
+
message: `${op.skill}/SKILL.md:${result.message} —— 撤销未完成(已回退:${done()})。`,
|
|
102
|
+
reverted
|
|
103
|
+
};
|
|
104
|
+
reverted.push(op.skill + "/SKILL.md");
|
|
105
|
+
}
|
|
106
|
+
for (const skill of plan.archiveTargets) {
|
|
107
|
+
const result = await sink.archive(skill, "merge undone");
|
|
108
|
+
if (!result.ok) return {
|
|
109
|
+
ok: false,
|
|
110
|
+
message: `归档新目标「${skill}」失败:${result.message} —— 撤销未完成(已回退:${done()})。`,
|
|
111
|
+
reverted
|
|
112
|
+
};
|
|
113
|
+
reverted.push(skill);
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
ok: true,
|
|
117
|
+
message: `已按单元撤销:${reverted.join(", ")}。`,
|
|
118
|
+
reverted
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region lib/types/unit-undo-plan.js
|
|
123
|
+
/**
|
|
124
|
+
* Cross-skill unit undo planner.
|
|
125
|
+
*
|
|
126
|
+
* The curator's single-skill undo already proves the rule: one path is described by
|
|
127
|
+
* (baseline, oldest after, newest after), and a path the unit created is removed. A merge
|
|
128
|
+
* unit adds two shapes:
|
|
129
|
+
*
|
|
130
|
+
* - a source that the merge ARCHIVED: undo restores it from .archive; it has no live ops;
|
|
131
|
+
* - a target the merge CREATED: undo archives the target (never hard-deletes it); it has no
|
|
132
|
+
* body op.
|
|
133
|
+
*
|
|
134
|
+
* The plan is pure; the executor resolves hashes to bytes and applies anchors. Any refusal
|
|
135
|
+
* means the caller writes nothing.
|
|
136
|
+
*/
|
|
137
|
+
function slotsOf(entries) {
|
|
138
|
+
const body = {};
|
|
139
|
+
const support = /* @__PURE__ */ new Map();
|
|
140
|
+
const refusals = [];
|
|
141
|
+
for (const entry of entries) {
|
|
142
|
+
if (!(entry.path !== void 0 && entryTarget(entry, entries) === "support")) {
|
|
143
|
+
if (entry.action === "baseline") body.baseline ??= entry;
|
|
144
|
+
else {
|
|
145
|
+
body.oldest ??= entry;
|
|
146
|
+
body.newest = entry;
|
|
147
|
+
}
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const path = entry.path;
|
|
151
|
+
const slot = support.get(path) ?? {};
|
|
152
|
+
support.set(path, slot);
|
|
153
|
+
if (entry.action === "baseline") slot.baseline ??= entry;
|
|
154
|
+
else {
|
|
155
|
+
slot.oldest ??= entry;
|
|
156
|
+
slot.newest = entry;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
for (const [path, slot] of support) if (slot.newest === void 0) refusals.push(`${path}(单元里没有该路径的 after 条目)`);
|
|
160
|
+
return {
|
|
161
|
+
body,
|
|
162
|
+
support,
|
|
163
|
+
refusals
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/** Plan one unit across a live target and any archived sources. */
|
|
167
|
+
function planUnitUndoAcross(members) {
|
|
168
|
+
const ops = [];
|
|
169
|
+
const restores = [];
|
|
170
|
+
const archiveTargets = [];
|
|
171
|
+
const refusals = [];
|
|
172
|
+
for (const member of members) {
|
|
173
|
+
if (member.status === "missing") {
|
|
174
|
+
refusals.push(`${member.skill}(成员技能不在活动树或归档里)`);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (member.status === "archived") {
|
|
178
|
+
if (member.archivedPath === void 0 || member.archivedPath === "") {
|
|
179
|
+
refusals.push(`${member.skill}(归档成员缺少归档路径)`);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
restores.push({
|
|
183
|
+
skill: member.skill,
|
|
184
|
+
archivedPath: member.archivedPath
|
|
185
|
+
});
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (member.createdInUnit === true) {
|
|
189
|
+
archiveTargets.push(member.skill);
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const { body, support, refusals: slotRefusals } = slotsOf(member.entries);
|
|
193
|
+
refusals.push(...slotRefusals.map((reason) => member.skill + ":" + reason));
|
|
194
|
+
for (const [path, slot] of support) {
|
|
195
|
+
if (slot.newest === void 0) continue;
|
|
196
|
+
const removal = slot.oldest?.removed === true;
|
|
197
|
+
const preUnitHash = removal ? slot.oldest?.hash : slot.baseline !== void 0 ? slot.baseline.hash : slot.oldest?.beforeHash;
|
|
198
|
+
ops.push({
|
|
199
|
+
skill: member.skill,
|
|
200
|
+
path,
|
|
201
|
+
remove: !removal && preUnitHash === void 0,
|
|
202
|
+
...preUnitHash === void 0 ? {} : { preUnitHash },
|
|
203
|
+
expectedHash: removal ? contentHash("") : slot.newest.hash
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (body.newest !== void 0) {
|
|
207
|
+
const preUnitHash = body.baseline !== void 0 ? body.baseline.hash : body.oldest?.beforeHash;
|
|
208
|
+
if (preUnitHash === void 0) refusals.push(`${member.skill}:SKILL.md 缺少单元前字节`);
|
|
209
|
+
else ops.push({
|
|
210
|
+
skill: member.skill,
|
|
211
|
+
path: "",
|
|
212
|
+
remove: false,
|
|
213
|
+
preUnitHash,
|
|
214
|
+
expectedHash: body.newest.hash
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
ops,
|
|
220
|
+
restores,
|
|
221
|
+
archiveTargets,
|
|
222
|
+
refusals
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region lib/types/unit-members.js
|
|
227
|
+
/** Candidate skills: head first, then `sources[]` order, DEDUPLICATED (sources may name the head). */
|
|
228
|
+
function candidateSkills(head) {
|
|
229
|
+
const out = [head.skill];
|
|
230
|
+
for (const source of head.sources) if (!out.includes(source.skill)) out.push(source.skill);
|
|
231
|
+
return out;
|
|
232
|
+
}
|
|
233
|
+
/** @param indexes - skill name -> that skill's index text, or null when the index file is absent. */
|
|
234
|
+
/** The `path` of one manifest move, or the empty string when the record carries no string one.
|
|
235
|
+
* Kept as a function so the read never stringifies an object (the linter refuses
|
|
236
|
+
* `String(unknown)` for exactly that reason) and every call site reads the same way. */
|
|
237
|
+
function movePath(move) {
|
|
238
|
+
const raw = move.path;
|
|
239
|
+
return typeof raw === "string" ? raw : "";
|
|
240
|
+
}
|
|
241
|
+
function resolveUnitMembersFromIndexes(head, indexes, readEntries) {
|
|
242
|
+
const members = [];
|
|
243
|
+
const missing = [];
|
|
244
|
+
for (const skill of candidateSkills(head)) {
|
|
245
|
+
const text = indexes.get(skill);
|
|
246
|
+
if (text === void 0 || text === null) {
|
|
247
|
+
missing.push({
|
|
248
|
+
skill,
|
|
249
|
+
reason: "index-absent"
|
|
250
|
+
});
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
const entries = readEntries(text).filter((entry) => entry.unitId === head.unitId);
|
|
254
|
+
if (entries.length === 0) {
|
|
255
|
+
missing.push({
|
|
256
|
+
skill,
|
|
257
|
+
reason: "unit-absent"
|
|
258
|
+
});
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
members.push({
|
|
262
|
+
skill,
|
|
263
|
+
entries
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
const conflicts = [];
|
|
267
|
+
const manifest = head.unitHead?.moves ?? void 0;
|
|
268
|
+
if (manifest !== void 0) {
|
|
269
|
+
const shardPaths = [];
|
|
270
|
+
for (const slice of members) for (const entry of slice.entries) for (const move of entry.unitHead?.moves ?? []) {
|
|
271
|
+
const path = movePath(move);
|
|
272
|
+
if (path !== "") shardPaths.push(path);
|
|
273
|
+
}
|
|
274
|
+
const wanted = manifest.map((move) => movePath(move)).filter((p) => p !== "");
|
|
275
|
+
for (const path of wanted) if (!shardPaths.includes(path)) conflicts.push({
|
|
276
|
+
kind: "missing",
|
|
277
|
+
path
|
|
278
|
+
});
|
|
279
|
+
for (const path of shardPaths) if (!wanted.includes(path)) conflicts.push({
|
|
280
|
+
kind: "foreign",
|
|
281
|
+
path
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
members,
|
|
286
|
+
missing,
|
|
287
|
+
conflicts
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
/** A unit's members are trustworthy only when nothing is missing and nothing conflicts. */
|
|
291
|
+
function unitMembersAreComplete(members) {
|
|
292
|
+
return members.missing.length === 0 && members.conflicts.length === 0;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* The io shell (A19.2): open ONLY the known keys -- never enumerate a directory. A skill whose index
|
|
296
|
+
* file is unreadable becomes `null` (index-absent), which the core then reports by name.
|
|
297
|
+
*/
|
|
298
|
+
async function resolveUnitMembers(root, io, head, indexPath, readEntries) {
|
|
299
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
300
|
+
for (const skill of candidateSkills(head)) {
|
|
301
|
+
let text = null;
|
|
302
|
+
try {
|
|
303
|
+
text = await io.readText(indexPath(root, skill));
|
|
304
|
+
} catch {
|
|
305
|
+
text = null;
|
|
306
|
+
}
|
|
307
|
+
indexes.set(skill, text);
|
|
308
|
+
}
|
|
309
|
+
return resolveUnitMembersFromIndexes(head, indexes, (raw) => readEntries(raw));
|
|
310
|
+
}
|
|
311
|
+
/** G3b: a LANDMARK carries the owning skill and no manifest (the two forms never coexist). */
|
|
312
|
+
function isLandmark(entry) {
|
|
313
|
+
const head = entry.unitHead;
|
|
314
|
+
return head !== void 0 && head.moves === void 0 && head.skill !== void 0;
|
|
315
|
+
}
|
|
316
|
+
/** @param entry - the entry being judged. @param ownerEntries - the owner skill's index, or null when
|
|
317
|
+
* the owner has no readable index. */
|
|
318
|
+
function landmarkVerdict(entry, ownerEntries) {
|
|
319
|
+
const head = entry.unitHead;
|
|
320
|
+
if ((isLandmark(entry) ? head?.skill : void 0) === void 0 || entry.unitId === void 0) return {
|
|
321
|
+
jumpable: false,
|
|
322
|
+
reason: "not-a-landmark"
|
|
323
|
+
};
|
|
324
|
+
if (ownerEntries === null) return {
|
|
325
|
+
jumpable: false,
|
|
326
|
+
reason: "owner-absent"
|
|
327
|
+
};
|
|
328
|
+
return ownerEntries.some((candidate) => candidate.unitId === entry.unitId) ? { jumpable: true } : {
|
|
329
|
+
jumpable: false,
|
|
330
|
+
reason: "unit-absent"
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Scan a whole corpus (skill name -> index entries, or null when unreadable) for stale route stubs.
|
|
335
|
+
* Sorted by (skill, version, owner): a function of the corpus, not of the caller's map order.
|
|
336
|
+
*/
|
|
337
|
+
function staleRouteStubs(indexes) {
|
|
338
|
+
const out = [];
|
|
339
|
+
for (const [skill, entries] of indexes) {
|
|
340
|
+
if (entries === null) continue;
|
|
341
|
+
for (const entry of entries) {
|
|
342
|
+
const head = entry.unitHead;
|
|
343
|
+
const owner = isLandmark(entry) ? head?.skill : void 0;
|
|
344
|
+
if (owner === void 0) continue;
|
|
345
|
+
const verdict = landmarkVerdict(entry, indexes.get(owner) ?? null);
|
|
346
|
+
if (!verdict.jumpable && verdict.reason !== "not-a-landmark") out.push({
|
|
347
|
+
skill,
|
|
348
|
+
v: entry.v,
|
|
349
|
+
owner,
|
|
350
|
+
reason: verdict.reason
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return out.sort((a, b) => a.skill.localeCompare(b.skill) || a.v - b.v || a.owner.localeCompare(b.owner));
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
357
|
+
export { MutationUnit, UNIT_JOURNAL_PHASES, UNIT_JOURNAL_SCHEMA_VERSION, UNIT_STORAGE_SCHEMA_VERSION, WriteKernel, assertUnitJournalTransition, candidateSkills, executeUnitUndo, fileMutationLock, isLandmark, landmarkVerdict, planUnitUndoAcross, pruneTreeChangeUnits, readUnitEvidence, readUnitIndex, readUnitJournal, readUnitReceipt, readUnitSnapshot, resolveUnitMembers, resolveUnitMembersFromIndexes, staleRouteStubs, unitEvidencePath, unitIndexPath, unitJournalPath, unitJournalPhaseRank, unitJournalPort, unitMembersAreComplete, unitReceiptPath, unitSnapshotPath, unitSnapshotPort, unitSnapshotsDir, unitStorageKey, upsertUnitIndex, validateMutationRequest, writeUnitEvidence, writeUnitJournal, writeUnitReceipt, writeUnitSnapshot };
|
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.
|
|
4
|
+
"version": "0.43.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -42,6 +42,14 @@
|
|
|
42
42
|
"types": "./lib/types/restrictor.d.ts",
|
|
43
43
|
"default": "./lib/restrictor.js"
|
|
44
44
|
},
|
|
45
|
+
"./write": {
|
|
46
|
+
"types": "./lib/types/write.d.ts",
|
|
47
|
+
"default": "./lib/write.js"
|
|
48
|
+
},
|
|
49
|
+
"./skills": {
|
|
50
|
+
"types": "./lib/types/skills.d.ts",
|
|
51
|
+
"default": "./lib/skills.js"
|
|
52
|
+
},
|
|
45
53
|
"./package.json": "./package.json",
|
|
46
54
|
"./row-overrides.json": "./row-overrides.json",
|
|
47
55
|
"./persisted-write-inventory.json": "./persisted-write-inventory.json"
|
|
@@ -57,24 +65,27 @@
|
|
|
57
65
|
"yaml": "^2.4.2",
|
|
58
66
|
"zod": "^4.4.3",
|
|
59
67
|
"js-yaml": "^4.1.0",
|
|
60
|
-
"@lmzhen/dsh-evolution-contract": "^0.
|
|
68
|
+
"@lmzhen/dsh-evolution-contract": "^0.43.0"
|
|
61
69
|
},
|
|
62
70
|
"peerDependencies": {
|
|
63
71
|
"@deepseek-ai/cordis": "^4.0.5",
|
|
64
72
|
"@deepseek-ai/dsh-scope": "^0.2.2-rc.0",
|
|
65
73
|
"@deepseek-ai/dsh-session": "^0.2.2-rc.0",
|
|
74
|
+
"@deepseek-ai/dsh-skill": "^0.2.2-rc.0",
|
|
66
75
|
"@deepseek-ai/dsh-session-projection": "^0.2.2-rc.0",
|
|
67
76
|
"@deepseek-ai/dsh-agent": "^0.2.2-rc.0",
|
|
68
77
|
"@deepseek-ai/dsh-subagent": "^0.2.2-rc.0",
|
|
69
78
|
"@deepseek-ai/dsh-tools": "^0.2.2-rc.0",
|
|
70
79
|
"@deepseek-ai/dsh-commands": "^0.2.2-rc.0",
|
|
71
80
|
"@deepseek-ai/dsh-llm": "^0.2.2-rc.0",
|
|
72
|
-
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.0"
|
|
81
|
+
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.0",
|
|
82
|
+
"@deepseek-ai/dsh-storage-domain": "^0.2.2-rc.0"
|
|
73
83
|
},
|
|
74
84
|
"devDependencies": {
|
|
75
85
|
"@deepseek-ai/cordis": "^4.0.5",
|
|
76
86
|
"@deepseek-ai/dsh-scope": "^0.2.2-rc.0",
|
|
77
87
|
"@deepseek-ai/dsh-session": "^0.2.2-rc.0",
|
|
88
|
+
"@deepseek-ai/dsh-skill": "^0.2.2-rc.0",
|
|
78
89
|
"@deepseek-ai/dsh-session-projection": "^0.2.2-rc.0",
|
|
79
90
|
"@deepseek-ai/dsh-agent": "^0.2.2-rc.0",
|
|
80
91
|
"@deepseek-ai/dsh-subagent": "^0.2.2-rc.0",
|
|
@@ -83,7 +94,8 @@
|
|
|
83
94
|
"js-yaml": "^4.1.0",
|
|
84
95
|
"@deepseek-ai/dsh-commands": "^0.2.2-rc.0",
|
|
85
96
|
"@deepseek-ai/dsh-llm": "^0.2.2-rc.0",
|
|
86
|
-
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.0"
|
|
97
|
+
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.0",
|
|
98
|
+
"@deepseek-ai/dsh-storage-domain": "^0.2.2-rc.0"
|
|
87
99
|
},
|
|
88
100
|
"engines": {
|
|
89
101
|
"dsh": ">=0.2.2-rc.0 <0.2.3-0"
|