@lmzhen/dsh-evolution-core 0.59.6 → 0.60.1

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.
Files changed (103) hide show
  1. package/README.md +3 -1
  2. package/lib/authority-plugin.js +3 -2
  3. package/lib/composition/index.js +2 -2
  4. package/lib/{composition-B_F4TYOD.js → composition-BSqh70z_.js} +1 -1
  5. package/lib/{ensure-BpVDuDnA.js → ensure-DTCuxAxR.js} +1 -1
  6. package/lib/{extract-plan-D3ALlAmN.js → extract-plan-CP__XlEs.js} +2 -2
  7. package/lib/extract.js +4 -4
  8. package/lib/http-routes.js +3 -2
  9. package/lib/index.js +15 -15
  10. package/lib/{io-Cpa8wuvj.js → io-DT4-MXLr.js} +25 -1
  11. package/lib/io-node.js +1 -1
  12. package/lib/io-platform.js +163 -0
  13. package/lib/io-registry.js +10 -0
  14. package/lib/{mutation-authority-CZpc9F20.js → mutation-authority-C3RYyiaT.js} +66 -41
  15. package/lib/{mutation-storage-adapter-Cq1bmS1E.js → mutation-storage-adapter-CSVn34dK.js} +327 -210
  16. package/lib/{mutations-Y-wKod7W.js → mutations-JKFlfhSO.js} +1 -1
  17. package/lib/policy.js +1 -1
  18. package/lib/{quality-NPGr3VzA.js → quality-C0ri2SgY.js} +2 -2
  19. package/lib/restrictor.js +1 -1
  20. package/lib/result.js +1 -1
  21. package/lib/{review-context-yNiZadPw.js → review-context-D2LIOEi-.js} +2 -2
  22. package/lib/runtime/plugin.js +2 -2
  23. package/lib/{session-projection-DM15fsRp.js → session-projection-Dnmm5bzt.js} +1 -1
  24. package/lib/{skill-history-BvLWFoOo.js → skill-history-BOZ4HCDB.js} +2 -2
  25. package/lib/skills.js +268 -37
  26. package/lib/state/domain/index.js +433 -0
  27. package/lib/state/index.js +136 -0
  28. package/lib/state/migrate.js +90 -0
  29. package/lib/state/storage.js +605 -0
  30. package/lib/state/store-plugin.js +23 -0
  31. package/lib/state/store.js +268 -0
  32. package/lib/subagent/index.js +1 -1
  33. package/lib/types/authority-plugin.d.ts +1 -1
  34. package/lib/types/authority-plugin.js +2 -1
  35. package/lib/types/authority.d.ts +1 -1
  36. package/lib/types/authority.js +75 -48
  37. package/lib/types/composition/ensure.js +1 -1
  38. package/lib/types/contract.d.ts +8 -0
  39. package/lib/types/http-routes.d.ts +1 -0
  40. package/lib/types/http-routes.js +2 -1
  41. package/lib/types/io-platform.d.ts +74 -0
  42. package/lib/types/io-platform.js +178 -0
  43. package/lib/types/io-registry.d.ts +4 -0
  44. package/lib/types/io-registry.js +10 -0
  45. package/lib/types/io.d.ts +7 -0
  46. package/lib/types/io.js +25 -1
  47. package/lib/types/mutation-authority.d.ts +1 -1
  48. package/lib/types/mutation-storage-adapter.d.ts +1 -1
  49. package/lib/types/opt-in.js +2 -2
  50. package/lib/types/params.js +2 -2
  51. package/lib/types/policy.js +1 -1
  52. package/lib/types/restrictor.js +2 -2
  53. package/lib/types/result.d.ts +1 -1
  54. package/lib/types/result.js +1 -1
  55. package/lib/types/runtime/coherence.js +1 -1
  56. package/lib/types/runtime/llm.d.ts +1 -1
  57. package/lib/types/runtime/llm.js +1 -1
  58. package/lib/types/runtime/platform.d.ts +3 -3
  59. package/lib/types/runtime/platform.js +2 -2
  60. package/lib/types/runtime/projections.d.ts +1 -1
  61. package/lib/types/scope.js +1 -1
  62. package/lib/types/session-projection.d.ts +1 -1
  63. package/lib/types/signals.d.ts +1 -1
  64. package/lib/types/skill-store.d.ts +37 -4
  65. package/lib/types/skill-store.js +240 -24
  66. package/lib/types/skill-write-plan.d.ts +1 -1
  67. package/lib/types/skill-write-service.js +8 -2
  68. package/lib/types/state/conformance.d.ts +47 -0
  69. package/lib/types/state/conformance.js +246 -0
  70. package/lib/types/state/constants.d.ts +52 -0
  71. package/lib/types/state/constants.js +52 -0
  72. package/lib/types/state/domain/compatibility.d.ts +40 -0
  73. package/lib/types/state/domain/compatibility.js +36 -0
  74. package/lib/types/state/domain/index.d.ts +81 -0
  75. package/lib/types/state/domain/index.js +592 -0
  76. package/lib/types/state/index.d.ts +63 -0
  77. package/lib/types/state/index.js +174 -0
  78. package/lib/types/state/medium-declaration.d.ts +37 -0
  79. package/lib/types/state/medium-declaration.js +53 -0
  80. package/lib/types/state/migrate.d.ts +34 -0
  81. package/lib/types/state/migrate.js +103 -0
  82. package/lib/types/state/record-contract.d.ts +56 -0
  83. package/lib/types/state/record-contract.js +120 -0
  84. package/lib/types/state/storage.d.ts +112 -0
  85. package/lib/types/state/storage.js +178 -0
  86. package/lib/types/state/store-plugin.d.ts +14 -0
  87. package/lib/types/state/store-plugin.js +18 -0
  88. package/lib/types/state/store.d.ts +39 -0
  89. package/lib/types/state/store.js +270 -0
  90. package/lib/types/store-ledger.js +2 -2
  91. package/lib/types/subagent/run.d.ts +1 -1
  92. package/lib/types/subagent/types.d.ts +4 -4
  93. package/lib/types/{write-kernel.d.ts → target-writer.d.ts} +32 -15
  94. package/lib/types/{write-kernel.js → target-writer.js} +40 -8
  95. package/lib/types/tool-dispatch.js +6 -3
  96. package/lib/types/{mutation-unit.d.ts → unit-kernel.d.ts} +40 -13
  97. package/lib/types/{mutation-unit.js → unit-kernel.js} +155 -118
  98. package/lib/types/write.d.ts +1 -2
  99. package/lib/types/write.js +1 -2
  100. package/lib/{usage-D7yHG2Cb.js → usage-BO4Zj_zB.js} +2 -2
  101. package/lib/write.js +4 -4
  102. package/package.json +30 -3
  103. package/persisted-write-inventory.json +14 -5
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Platform-backed `EvolutionIo` provider.
3
+ *
4
+ * This is the Phase-B bridge: business code keeps its existing `EvolutionIoLike`
5
+ * seam, while the production backend becomes the platform filesystem
6
+ * (`ctx.fs`, implemented by `@deepseek-ai/dsh-fs-local`) instead of the family's
7
+ * own `node:fs` writer. Target identity, per-target locks and atomic publication
8
+ * therefore have one owner: the platform.
9
+ *
10
+ * Structural `PlatformFs` is deliberate: this package consumes the platform
11
+ * service shape without adding a runtime dependency; every operation is a
12
+ * one-to-one mapping, and no plugin-local write primitive is introduced.
13
+ *
14
+ * @module @lmzhen/dsh-evolution-core/io-platform
15
+ */
16
+ import { withFileLock } from '@lmzhen/dsh-evolution-platform/values/fs';
17
+ const MISSING_CODES = new Set(['FS_NOT_FOUND', 'FS_NOT_DIRECTORY', 'ENOENT', 'ENOTDIR']);
18
+ function codeOf(error) {
19
+ return typeof error?.code === 'string' ? String(error.code) : '';
20
+ }
21
+ function isMissing(error) {
22
+ return MISSING_CODES.has(codeOf(error));
23
+ }
24
+ function eexist(message) {
25
+ return Object.assign(new Error(message), { code: 'EEXIST' });
26
+ }
27
+ async function readOrNull(fs, path) {
28
+ const target = await fs.resolve(path);
29
+ try {
30
+ return await fs.readText(target);
31
+ }
32
+ catch (error) {
33
+ if (isMissing(error))
34
+ return null;
35
+ throw error;
36
+ }
37
+ }
38
+ /**
39
+ * Adapt one platform filesystem service to the family's existing IO seam.
40
+ * @param fs - the platform filesystem service (structurally `ctx.fs`).
41
+ * @returns the provider, ready for `ctx.evolutionIo.registerProvider`.
42
+ */
43
+ export function platformEvolutionIo(fs, options = {}) {
44
+ const lock = options.withFileLock;
45
+ return {
46
+ name: 'platform',
47
+ processScope: lock === undefined ? 'single-process' : 'cross-process',
48
+ async readText(path) {
49
+ return await readOrNull(fs, path);
50
+ },
51
+ async writeText(path, content) {
52
+ const target = await fs.resolve(path);
53
+ await fs.writeText(target, content);
54
+ },
55
+ async remove(path) {
56
+ const target = await fs.resolve(path);
57
+ try {
58
+ await fs.deleteFile(target);
59
+ }
60
+ catch (error) {
61
+ if (!isMissing(error))
62
+ throw error;
63
+ }
64
+ },
65
+ async list(path) {
66
+ const target = await fs.resolve(path);
67
+ try {
68
+ return (await fs.listDir(target)).map((entry) => entry.name);
69
+ }
70
+ catch (error) {
71
+ // EvolutionIoLike contract: a missing directory reads as empty; any
72
+ // other failure surfaces so an unreadable tree is never silent.
73
+ if (isMissing(error))
74
+ return [];
75
+ throw error;
76
+ }
77
+ },
78
+ async exists(path) {
79
+ const target = await fs.resolve(path);
80
+ try {
81
+ return (await fs.stat(target)) !== undefined;
82
+ }
83
+ catch (error) {
84
+ if (isMissing(error))
85
+ return false;
86
+ throw error;
87
+ }
88
+ },
89
+ async rename(path, destination) {
90
+ const source = await fs.resolve(path);
91
+ const target = await fs.resolve(destination);
92
+ const outcome = await fs.moveFile(source, target, {});
93
+ if (outcome.sourceDeleted !== true)
94
+ throw new Error('platform move retained the source: ' + path);
95
+ },
96
+ async copy(path, destination) {
97
+ const content = await readOrNull(fs, path);
98
+ if (content === null)
99
+ throw new Error('cannot copy missing file: ' + path);
100
+ const target = await fs.resolve(destination);
101
+ await fs.writeText(target, content);
102
+ },
103
+ async size(path) {
104
+ const target = await fs.resolve(path);
105
+ const info = await fs.stat(target);
106
+ return info === undefined || info.type !== 'file' ? null : info.size ?? null;
107
+ },
108
+ async isSymlink(path) {
109
+ const info = await fs.lstat(path);
110
+ return info === undefined ? null : info.type === 'symlink';
111
+ },
112
+ async createTextIfAbsent(path, content) {
113
+ const target = await fs.resolve(path);
114
+ try {
115
+ await fs.writeText(target, content, { kind: 'createIfAbsent' });
116
+ }
117
+ catch (error) {
118
+ if (codeOf(error) === 'FS_ALREADY_EXISTS' || codeOf(error) === 'FS_STALE_VERSION' || codeOf(error) === 'FS_NOT_OBSERVED') {
119
+ throw eexist('target appeared before create: ' + path);
120
+ }
121
+ throw error;
122
+ }
123
+ },
124
+ async transact(path, task) {
125
+ const run = async () => {
126
+ const target = await fs.resolve(path);
127
+ const info = await fs.stat(target);
128
+ const current = info === undefined ? null : await fs.readText(target);
129
+ const next = await task(current);
130
+ if (next === current)
131
+ return;
132
+ if (next === null) {
133
+ if (info === undefined)
134
+ return;
135
+ await fs.deleteFile(target, { version: info.version });
136
+ return;
137
+ }
138
+ if (info === undefined) {
139
+ try {
140
+ await fs.writeText(target, next, { kind: 'createIfAbsent' });
141
+ }
142
+ catch (error) {
143
+ if (codeOf(error) === 'FS_ALREADY_EXISTS' || codeOf(error) === 'FS_STALE_VERSION' || codeOf(error) === 'FS_NOT_OBSERVED') {
144
+ throw eexist('target appeared before write: ' + path);
145
+ }
146
+ throw error;
147
+ }
148
+ return;
149
+ }
150
+ // A whole-file literal replacement is the platform's guarded read→write
151
+ // critical section. Empty files cannot express a non-empty oldString.
152
+ if (current === null)
153
+ throw new Error('platform file vanished during transact: ' + path);
154
+ if (current === '')
155
+ await fs.writeText(target, next, { kind: 'replaceIfVersion', version: info.version });
156
+ else
157
+ await fs.editText(target, { oldString: current, newString: next, replaceAll: false }, { version: info.version });
158
+ };
159
+ if (lock === undefined)
160
+ await run();
161
+ else
162
+ await lock(path, run);
163
+ },
164
+ };
165
+ }
166
+ export const name = 'evolution-io-platform';
167
+ export const inject = ['evolutionIo', 'fs'];
168
+ /**
169
+ * Register the platform provider as the default IO backend.
170
+ * @param ctx - plugin context carrying `evolutionIo` and `fs`.
171
+ */
172
+ export function apply(ctx) {
173
+ const fs = ctx.fs;
174
+ if (fs === undefined)
175
+ throw new Error('evolution-io-platform requires the platform fs service');
176
+ ctx.effect(() => ctx.evolutionIo.registerProvider(platformEvolutionIo(fs, { withFileLock }), { default: true }), 'evolution-io-platform.provider');
177
+ }
178
+ //# sourceMappingURL=io-platform.js.map
@@ -33,6 +33,7 @@ export declare class EvolutionIoRegistry extends Service {
33
33
  /** P2-3 (v15): per-name dispose — the idempotent re-registration returns
34
34
  * the SAME function instance, so double-dispose is a single removal. */
35
35
  private readonly disposals;
36
+ private readonly readyResolvers;
36
37
  constructor(ctx: Context);
37
38
  /**
38
39
  * @param options.default - mark this provider as the one a nameless
@@ -49,6 +50,9 @@ export declare class EvolutionIoRegistry extends Service {
49
50
  registerProvider(provider: EvolutionIo, options?: {
50
51
  default?: boolean;
51
52
  }): () => void;
53
+ /** Resolve once at least one provider exists; plugins that construct with a
54
+ * provider in apply() await this instead of racing the registration row. */
55
+ whenReady(): Promise<void>;
52
56
  provider(name?: string): EvolutionIo;
53
57
  }
54
58
  export default EvolutionIoRegistry;
@@ -15,6 +15,7 @@ export class EvolutionIoRegistry extends Service {
15
15
  /** P2-3 (v15): per-name dispose — the idempotent re-registration returns
16
16
  * the SAME function instance, so double-dispose is a single removal. */
17
17
  disposals = new Map();
18
+ readyResolvers = [];
18
19
  constructor(ctx) {
19
20
  super(ctx, 'evolutionIo');
20
21
  }
@@ -64,6 +65,8 @@ export class EvolutionIoRegistry extends Service {
64
65
  };
65
66
  this.providers.set(provider.name, provider);
66
67
  this.disposals.set(provider.name, dispose);
68
+ for (const resolve of this.readyResolvers.splice(0))
69
+ resolve();
67
70
  return dispose;
68
71
  }
69
72
  // P3-D1 (v15): the speculative `hasProviders()` from v14 was removed — zero
@@ -72,6 +75,13 @@ export class EvolutionIoRegistry extends Service {
72
75
  // v20 (A-3): `hasProvider(name)` removed for the same reason — its only
73
76
  // callers were this package's own spec; a presence probe goes through
74
77
  // `provider(name)`, which fails loud on a missing name.
78
+ /** Resolve once at least one provider exists; plugins that construct with a
79
+ * provider in apply() await this instead of racing the registration row. */
80
+ whenReady() {
81
+ if (this.providers.size > 0)
82
+ return Promise.resolve();
83
+ return new Promise(resolve => { this.readyResolvers.push(resolve); });
84
+ }
75
85
  provider(name) {
76
86
  if (name) {
77
87
  const provider = this.providers.get(name);
package/lib/types/io.d.ts CHANGED
@@ -41,6 +41,13 @@ export interface EvolutionIoLike {
41
41
  * no await in the task need no Promise residue).
42
42
  */
43
43
  transact?(this: void, path: string, task: (current: string | null) => string | null | Promise<string | null>): Promise<void>;
44
+ /**
45
+ * Publish a new file only when the target does not exist. `link(tmp, path)`
46
+ * is the filesystem no-replace primitive (upstream fs-local uses the same
47
+ * publication rule): a concurrent creator wins and this call rejects with
48
+ * EEXIST, even when that creator does not participate in our locks.
49
+ */
50
+ createTextIfAbsent?: ((this: void, path: string, content: string) => Promise<void>) | undefined;
44
51
  /**
45
52
  * Optional symlink probe (G7). `true` = the path is a symlink, `false` = a
46
53
  * real entry, `null` = guard not applicable (backend without the probe or
package/lib/types/io.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * consumers (and the core's own tests) can use `nodeEvolutionIo`.
6
6
  */
7
7
  import { copyFileSync, existsSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
8
- import { cp, lstat, mkdir, open, readFile, readdir, rename, rm, stat } from 'node:fs/promises';
8
+ import { cp, link, lstat, mkdir, open, readFile, readdir, rename, rm, stat } from 'node:fs/promises';
9
9
  import { basename, dirname, join } from 'node:path';
10
10
  import { randomBytes } from 'node:crypto';
11
11
  // v43 S1-4: the family's ONE definition of "this read failure means it is not
@@ -88,6 +88,11 @@ export function evolutionIoAdapter(provider) {
88
88
  get processScope() { return provider().processScope; },
89
89
  readText: path => provider().readText(path),
90
90
  writeText: (path, content) => provider().writeText(path, content),
91
+ get createTextIfAbsent() {
92
+ const io = provider();
93
+ const fn = io.createTextIfAbsent;
94
+ return fn === undefined ? undefined : (path, content) => fn(path, content);
95
+ },
91
96
  remove: path => provider().remove(path),
92
97
  list: path => provider().list(path),
93
98
  exists: path => provider().exists(path),
@@ -408,6 +413,25 @@ export function nodeEvolutionIo() {
408
413
  throw error;
409
414
  }
410
415
  },
416
+ async createTextIfAbsent(path, content) {
417
+ await mkdir(dirname(path), { recursive: true });
418
+ await sweepStaleTmps(path);
419
+ const tmp = await writeDurableTmp(path, content);
420
+ try {
421
+ await link(tmp, path);
422
+ }
423
+ catch (error) {
424
+ await rm(tmp, { force: true }).catch(() => { });
425
+ throw error;
426
+ }
427
+ await rm(tmp, { force: true }).catch(() => { });
428
+ try {
429
+ await fsyncDirectory(dirname(path));
430
+ }
431
+ catch (error) {
432
+ throw Object.assign(new Error(`createTextIfAbsent: ${path} was linked but the directory fsync failed: ${error instanceof Error ? error.message : String(error)}`), { committed: true, cause: error });
433
+ }
434
+ },
411
435
  async writeText(path, content) {
412
436
  await mkdir(dirname(path), { recursive: true });
413
437
  // S4: serialized in-process; the durable tmp + rename commit is unchanged.
@@ -1,7 +1,7 @@
1
1
  import { HomeFence } from './home-fence.ts';
2
2
  import { LeaseStore } from './lease-store.ts';
3
3
  import type { EvolutionIoLike } from './io.ts';
4
- import type { MutationLockLease, MutationLockPort } from './mutation-unit.ts';
4
+ import type { MutationLockLease, MutationLockPort } from './unit-kernel.ts';
5
5
  import { TargetLockSet } from './authority.ts';
6
6
  export interface MutationAuthorityOptions {
7
7
  readonly io: EvolutionIoLike;
@@ -1,5 +1,5 @@
1
1
  import type { EvolutionIoLike } from './io.ts';
2
- import type { MutationJournalPort, MutationSnapshotPort } from './mutation-unit.ts';
2
+ import type { MutationJournalPort, MutationSnapshotPort } from './unit-kernel.ts';
3
3
  /**
4
4
  * Production adapter onto the existing unit snapshot store. A tree-change
5
5
  * snapshot is encoded as a UnitSnapshot with kind='tree-change'; merge
@@ -1,5 +1,5 @@
1
- import { toolsPort } from '@lmzhen/dsh-evolution-adapter/ports';
2
- import { scopeOf } from '@lmzhen/dsh-evolution-adapter/values';
1
+ import { toolsPort } from '@lmzhen/dsh-evolution-platform/ports';
2
+ import { scopeOf } from '@lmzhen/dsh-evolution-platform/values/scope';
3
3
  /**
4
4
  * Tool names only a session that mounted the family's MODEL rows can see.
5
5
  *
@@ -12,7 +12,7 @@
12
12
  * Writing is canonical-only (a deprecated name is not a live row field in 0.48).
13
13
  * @module
14
14
  */
15
- import { settingsPort } from '@lmzhen/dsh-evolution-adapter/ports';
15
+ import { settingsPort } from '@lmzhen/dsh-evolution-platform/ports';
16
16
  /** Deprecated alias (plugin-row name) -> canonical id (policy/snapshot name).
17
17
  * Retained for the one-time legacy-document migration and the doctor's old-key report;
18
18
  * live readers use the canonical id only. */
@@ -144,7 +144,7 @@ export const PARAM_EXPOSURE = Object.freeze([
144
144
  { id: 'skill-usage.eventsHome', group: 'deployment', tier: 'E1', authority: 'cordis', owner: 'skill-usage', applies: 'none', docAnchor: 'PARAMETERS.md#deployment', summary: 'Directory holding the family event log the usage store reads.', why: 'path' },
145
145
  { id: 'memory-files.root', group: 'deployment', tier: 'E1', authority: 'cordis', owner: 'memory-files', applies: 'none', docAnchor: 'PARAMETERS.md#deployment', summary: 'Directory holding MEMORY.md and USER.md (empty = $DSH_HOME/memories).', why: 'path' },
146
146
  { id: 'evolution-feedback.path', group: 'deployment', tier: 'E1', authority: 'cordis', owner: 'evolution-feedback', applies: 'none', docAnchor: 'PARAMETERS.md#deployment', summary: 'Event log the feedback scorer reads (empty = family events file).', why: 'path' },
147
- { id: 'evolution-state.provider', group: 'deployment', tier: 'E2', authority: 'cordis', owner: 'evolution-state', applies: 'none', docAnchor: 'PARAMETERS.md#deployment', summary: 'Registered state-store provider name.', why: 'identity' },
147
+ { id: 'evolution-state.provider', group: 'deployment', tier: 'E2', authority: 'cordis', owner: 'evolution-core', applies: 'none', docAnchor: 'PARAMETERS.md#deployment', summary: 'Registered state-store provider name.', why: 'identity' },
148
148
  { id: 'memory.provider', group: 'deployment', tier: 'E2', authority: 'cordis', owner: 'memory', applies: 'none', docAnchor: 'PARAMETERS.md#deployment', summary: 'Registered memory provider name.', why: 'identity' },
149
149
  { id: 'memory-files.providerName', group: 'deployment', tier: 'E2', authority: 'cordis', owner: 'memory-files', applies: 'none', docAnchor: 'PARAMETERS.md#deployment', summary: 'Name this package registers as the memory provider.', why: 'identity' },
150
150
  { id: 'substantiveMinToolCalls', group: 'deployment', tier: 'E2', authority: 'cordis', owner: 'evolution-review', applies: 'none', docAnchor: 'PARAMETERS.md#deployment', summary: 'Tool calls that make a turn count as substantive.', why: 'internal' },
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { asRecord } from "./guards.js";
7
7
  import { Service } from '@deepseek-ai/cordis';
8
- import { toolsPort } from '@lmzhen/dsh-evolution-adapter/ports';
8
+ import { toolsPort } from '@lmzhen/dsh-evolution-platform/ports';
9
9
  import z from '@deepseek-ai/schemastery';
10
10
  import { DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, FORBIDDEN_CONTROL_KEYS, PROTECTED_BUILTIN_SKILLS, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_STALE_AFTER_DAYS, EVOLUTION_WRITE_TOOLS, DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_USER_CHAR_LIMIT, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_CURATOR_MODEL, } from "./constants.js";
11
11
  import { DEFAULT_CITATION_POLICY, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_SUPPORT_FILE_CHAR_POLICY, POLICY_STAGE_DEFAULTS, } from "./limits.js";
@@ -1,5 +1,5 @@
1
- import { presetsPort } from '@lmzhen/dsh-evolution-adapter/ports';
2
- import { toolsPort } from '@lmzhen/dsh-evolution-adapter/ports';
1
+ import { presetsPort } from '@lmzhen/dsh-evolution-platform/ports';
2
+ import { toolsPort } from '@lmzhen/dsh-evolution-platform/ports';
3
3
  import { errorText } from "./errors.js";
4
4
  export const name = 'evolution-restrictor';
5
5
  export const inject = ['agentPresets'];
@@ -3,5 +3,5 @@
3
3
  *
4
4
  * @module @lmzhen/dsh-evolution-core/result
5
5
  */
6
- export * from '@lmzhen/dsh-evolution-platform-contract/result';
6
+ export * from '@lmzhen/dsh-evolution-platform/contract/result';
7
7
  //# sourceMappingURL=result.d.ts.map
@@ -3,5 +3,5 @@
3
3
  *
4
4
  * @module @lmzhen/dsh-evolution-core/result
5
5
  */
6
- export * from '@lmzhen/dsh-evolution-platform-contract/result';
6
+ export * from '@lmzhen/dsh-evolution-platform/contract/result';
7
7
  //# sourceMappingURL=result.js.map
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import { existsSync, readFileSync } from 'node:fs';
15
15
  import { join } from 'node:path';
16
- import { profileContextPort } from '@lmzhen/dsh-evolution-adapter/ports';
16
+ import { profileContextPort } from '@lmzhen/dsh-evolution-platform/ports';
17
17
  function packageTail(name) {
18
18
  return name.slice(name.lastIndexOf('/') + 1);
19
19
  }
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { Service } from '@deepseek-ai/cordis';
6
6
  import type { Context } from '@deepseek-ai/cordis';
7
- import type { EvolutionLlmRequest, ModelRoute, StreamChunk } from '@lmzhen/dsh-evolution-platform-contract';
7
+ import type { EvolutionLlmRequest, ModelRoute, StreamChunk } from '@lmzhen/dsh-evolution-platform/contract';
8
8
  export interface EvolutionLlmInput {
9
9
  readonly purpose: EvolutionLlmRequest['purpose'];
10
10
  readonly messages: EvolutionLlmRequest['messages'];
@@ -3,7 +3,7 @@
3
3
  * model calls. Feature-specific retries and parsing stay in their features.
4
4
  */
5
5
  import { Service } from '@deepseek-ai/cordis';
6
- import { EvolutionLlmError, modelRoute } from '@lmzhen/dsh-evolution-adapter/ports';
6
+ import { EvolutionLlmError, modelRoute } from '@lmzhen/dsh-evolution-platform/ports';
7
7
  /** Domain service for every auxiliary LLM request in the family. */
8
8
  export class EvolutionLlm extends Service {
9
9
  static inject = [];
@@ -2,11 +2,11 @@
2
2
  * Compatibility re-export of the adapter service.
3
3
  *
4
4
  * The concrete `EvolutionPlatform` service lives in
5
- * `@lmzhen/dsh-evolution-adapter`; core runtime still mounts it while P0
5
+ * `@lmzhen/dsh-evolution-platform`; core runtime still mounts it while P0
6
6
  * keeps the existing composition order.
7
7
  *
8
8
  * @module @lmzhen/dsh-evolution-core/runtime/platform
9
9
  */
10
- export { EvolutionPlatform } from '@lmzhen/dsh-evolution-adapter/service';
11
- export type { HostPlatformPorts } from '@lmzhen/dsh-evolution-adapter/service';
10
+ export { EvolutionPlatform } from '@lmzhen/dsh-evolution-platform/service';
11
+ export type { HostPlatformPorts } from '@lmzhen/dsh-evolution-platform/service';
12
12
  //# sourceMappingURL=platform.d.ts.map
@@ -2,10 +2,10 @@
2
2
  * Compatibility re-export of the adapter service.
3
3
  *
4
4
  * The concrete `EvolutionPlatform` service lives in
5
- * `@lmzhen/dsh-evolution-adapter`; core runtime still mounts it while P0
5
+ * `@lmzhen/dsh-evolution-platform`; core runtime still mounts it while P0
6
6
  * keeps the existing composition order.
7
7
  *
8
8
  * @module @lmzhen/dsh-evolution-core/runtime/platform
9
9
  */
10
- export { EvolutionPlatform } from '@lmzhen/dsh-evolution-adapter/service';
10
+ export { EvolutionPlatform } from '@lmzhen/dsh-evolution-platform/service';
11
11
  //# sourceMappingURL=platform.js.map
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { Service } from '@deepseek-ai/cordis';
8
8
  import type { Context } from '@deepseek-ai/cordis';
9
- import type { Session } from '@lmzhen/dsh-evolution-platform-contract';
9
+ import type { Session } from '@lmzhen/dsh-evolution-platform/contract';
10
10
  import { type EvolutionActivityState, type EvolutionEvidenceState, type EvolutionProjectionHistoryState, type EvolutionReadsState, type EvolutionSignalsState } from '../session-projection.ts';
11
11
  /** Domain service owning the family's projection registrations. */
12
12
  export declare class EvolutionProjections extends Service {
@@ -1,4 +1,4 @@
1
- import { scopeOf } from '@lmzhen/dsh-evolution-adapter/values';
1
+ import { scopeOf } from '@lmzhen/dsh-evolution-platform/values/scope';
2
2
  export function callingScope(ctx, held) {
3
3
  if (held !== undefined)
4
4
  return held;
@@ -1,5 +1,5 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
- import type { EvolutionProjectionDefinition, Session } from '@lmzhen/dsh-evolution-platform-contract';
2
+ import type { EvolutionProjectionDefinition, Session } from '@lmzhen/dsh-evolution-platform/contract';
3
3
  import { type EvidenceIndex } from './evidence.ts';
4
4
  import { type TurnFoldState, type TurnSignals } from './signals.ts';
5
5
  /** Time of the newest event folded for one session; 0 for a log with no event. */
@@ -5,7 +5,7 @@
5
5
  * is spent. `turn/end` calls `observeEvent`; the returned review kind is
6
6
  * accumulated until a configured interval fires.
7
7
  */
8
- import type { SessionEvent } from '@lmzhen/dsh-evolution-platform-contract';
8
+ import type { SessionEvent } from '@lmzhen/dsh-evolution-platform/contract';
9
9
  export type ReviewKind = 'memory' | 'skill' | 'combined';
10
10
  /** Review work due at one turn boundary. The delivery channel decides whether
11
11
  * to combine memory/skill (foreground) or schedule them independently (aux). */
@@ -36,7 +36,7 @@ import { type WriteAuthority } from './write-authority.ts';
36
36
  import { transactIo, type EvolutionIoLike } from './io.ts';
37
37
  import { type Probe } from './probe.ts';
38
38
  import type { SkillLimits } from './limits.ts';
39
- import { type MutationLockPort, type MutationResult } from './mutation-unit.ts';
39
+ import { type MutationLockPort, type MutationResult } from './unit-kernel.ts';
40
40
  import { SkillModel } from './skill-model.ts';
41
41
  import { type ExtractPlanDraft } from './extract-plan.ts';
42
42
  import { type MutationRecord } from './mutations.ts';
@@ -346,6 +346,31 @@ export declare function markerEntryName(marker: 'bundled' | 'hub-installed' | 'p
346
346
  * Single source shared with the plan validator. */
347
347
  export declare function validateRestructureTarget(filePath: string): string | null;
348
348
  export declare function validateSupportPath(filePath: string): string | null;
349
+ /**
350
+ * Index of `pattern` inside `content`, treating whitespace runs (spaces/tabs)
351
+ * as flexible and literal escape sequences (`\n`, `\t`, `\r`) as their real
352
+ * characters: a PATTERN whitespace run matches any content run of any length
353
+ * (even empty), while extra whitespace that only exists in the content is not
354
+ * skipped — the flexibility is one-sided on the pattern, and a backslash-
355
+ * escaped char in the pattern matches the real char in the content
356
+ * (model-copy drift). Returns the [start, end) range in the ORIGINAL content
357
+ * so a patch can replace exactly the matched span and keep every other byte
358
+ * intact. Returns null when no fuzzy match exists.
359
+ */
360
+ interface PlannedRestructureSection {
361
+ rel: string;
362
+ heading: string;
363
+ text: string;
364
+ }
365
+ /** Project one restructure without writing: the operator preview and the store share the planner. */
366
+ export declare function projectRestructureMarkdown(markdown: string, moves: SkillRestructureMove[]): {
367
+ ok: true;
368
+ body: string;
369
+ sections: readonly PlannedRestructureSection[];
370
+ } | {
371
+ ok: false;
372
+ message: string;
373
+ };
349
374
  /** One low-level CAS result; no audit/event is emitted by this primitive. */
350
375
  export interface SkillFileCasResult {
351
376
  readonly ok: boolean;
@@ -372,7 +397,7 @@ export declare class SkillLibrary {
372
397
  private readonly serial;
373
398
  /** Transitional target locks (same key as SkillWriteService). */
374
399
  private readonly targetLocks;
375
- /** Root structural gate; simple writes still use the serial until D.5d. */
400
+ /** Root structural gate; shared per canonical root across library instances. */
376
401
  private readonly rootGate;
377
402
  /** V10-03 (P2-18): see the constructor's threatExemptLabels. Empty by
378
403
  * default — the strict ANY-hit-blocks policy is unchanged. */
@@ -389,7 +414,7 @@ export declare class SkillLibrary {
389
414
  constructor(root?: string, io?: EvolutionIoLike, limits?: SkillLimits, onMutation?: (event: EvolutionSkillMutatedEvent) => void, transact?: typeof transactIo, threatExemptLabels?: readonly string[], authority?: WriteAuthority, mutationLock?: MutationLockPort, fence?: HistoryFence);
390
415
  /**
391
416
  * Transitional root lock for mutators that still own their write path. The
392
- * extract/restructure path takes the same lock through MutationUnit, so those
417
+ * extract/restructure path takes the same lock through UnitKernel, so those
393
418
  * two paths cannot interleave with create/update/patch across processes.
394
419
  */
395
420
  private unitHeadForOps;
@@ -416,7 +441,7 @@ export declare class SkillLibrary {
416
441
  */
417
442
  private canonicalTargetKey;
418
443
  private withMutationLock;
419
- /** The one MutationUnit constructor: storage ports are fixed here, callers pass the rest. */
444
+ /** The one UnitKernel constructor: storage ports are fixed here, callers pass the rest. */
420
445
  private commitUnit;
421
446
  /** The one frontmatter pipeline for create/update/patch; patch keeps its cap checks outside. */
422
447
  private prepareBody;
@@ -807,6 +832,14 @@ export declare class SkillLibrary {
807
832
  * returns before/after/version in the next phase.
808
833
  */
809
834
  apply(plan: SkillWritePlan): Promise<SkillWriteResult>;
835
+ /**
836
+ * Commit a multi-op plan as one atomic unit. Each op is first prepared by the
837
+ * existing single-op mutator in a collector context (so its validation and
838
+ * anchor/CAS checks stay the source of truth), then all collected writes are
839
+ * handed to ONE UnitKernel. Any preparation failure or stale anchor leaves
840
+ * every target untouched.
841
+ */
842
+ private applyMulti;
810
843
  private applyOne;
811
844
  writeSupportFile(rawName: string, filePath: string, content: string, origin?: WriteOrigin, anchor?: WriteAnchor): Promise<SkillActionResult>;
812
845
  private writeSupportFileCore;