dsh-mnemon-strategy-default-three-tier 0.5.8 → 0.5.10
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 +16 -9
- package/lib/extension-sdk.d.ts +4 -1
- package/lib/extension-sdk.js +4 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +48 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# dsh-mnemon-strategy-default-three-tier
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
The **Layered strategy** (分层策略 in the Chinese interface), dsh-mnemon's default
|
|
4
|
+
main strategy: runtime memory stays resident, while Project Documents and Memory
|
|
5
|
+
Spaces are read on demand. It is one ordinary Cordis Strategy plugin that consumes
|
|
6
|
+
public Source facts and proposes that View; it imports no Source implementation
|
|
7
|
+
and grants no authority. Its type id is `default-three-tier`.
|
|
5
8
|
|
|
6
9
|
`compose` is pure. `createTurn` owns the executing turn's retrieval policy:
|
|
7
10
|
one Documents query (4 results / 6,000 content characters), two different Recall
|
|
@@ -14,16 +17,20 @@ Source schemas and provenance are the public read protocol. This plugin formats
|
|
|
14
17
|
the familiar compact model response; Core retains the evidence/authority envelope
|
|
15
18
|
for auditing without serializing it again into every model tool result.
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
This plugin also owns the Layered strategy's instructions and reminders.
|
|
18
21
|
They are pinned in `ViewSpec.guidance`, separately from Source projections. The
|
|
19
22
|
Host renders them for the selected turn; a different Strategy does not inherit
|
|
20
23
|
this plugin's instructions. DSH-assisted write/archival workflows remain Host
|
|
21
24
|
adapters over Source operations; Core does not schedule autonomous maintenance.
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
Its manifest declares `workflows: ['idle-review', 'runtime-capacity']`, the
|
|
27
|
+
background work the dsh-mnemon Host runs for the turns it composes: idle review,
|
|
28
|
+
and Runtime capacity maintenance, which the Host applies to named tools, generic
|
|
29
|
+
View Actions, child writes and browser management. A Strategy built by spreading
|
|
30
|
+
this manifest copies the declaration; `workflows: []` keeps it out of both.
|
|
31
|
+
`threeTierActionWorkflow` in `./extension-sdk` is kept for existing callers and
|
|
32
|
+
deprecated; the Host reads the declaration instead. A maintenance operation
|
|
33
|
+
retains its exact Source instance, scope, revision and authority;
|
|
27
34
|
archive destinations stay within the selected writable Source and pinned
|
|
28
35
|
namespaces. A browser write needs no conversation. One eligible destination
|
|
29
36
|
requires no model; routing and local profile compaction use a clean workspace
|
|
@@ -55,7 +62,7 @@ Replay and Related admission include the exact Source instance identity. Writes
|
|
|
55
62
|
still require an offered Action and Host authorization, including implicit
|
|
56
63
|
capacity maintenance. Explicit operator management is a separate channel.
|
|
57
64
|
|
|
58
|
-
With no extensions the original
|
|
65
|
+
With no extensions the Layered strategy's original composition is retained. Disabling
|
|
59
66
|
one extension only removes its contribution for new turns; running turns keep
|
|
60
67
|
their pinned View. If disabling explicit selection leaves multiple Sources in
|
|
61
68
|
the same role, the original ambiguity check applies rather than silently
|
|
@@ -71,7 +78,7 @@ no auto-activation patch; installing it does not override a configured Strategy.
|
|
|
71
78
|
|
|
72
79
|
## Installation and verification
|
|
73
80
|
|
|
74
|
-
The default Starter already mounts and selects
|
|
81
|
+
The default Starter already mounts and selects the Layered strategy. In an independent Profile, install the package, mount its Entry and explicitly select `default-three-tier`; another installed Strategy does not win by import order.
|
|
75
82
|
|
|
76
83
|
Installing an npm package is not the same as activating a contribution. From a source checkout, run `pnpm verify` with declared public peers installed; use a packed peer for unreleased SDK work.
|
|
77
84
|
|
package/lib/extension-sdk.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ import { MemoryAvailableSource, MemoryJsonValue, MemoryStrategyContribution, Mem
|
|
|
3
3
|
/** The three-tier slots are Core's standard View extension slots. */
|
|
4
4
|
type ThreeTierExtensionValues = MemoryViewExtensionValues;
|
|
5
5
|
type ThreeTierExtensionSlot = MemoryViewExtensionSlot;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Pure default-product policy. The Host executes it through public Source protocols.
|
|
8
|
+
* @deprecated The Host runs the workflows a Strategy declares in its manifest's `workflows`.
|
|
9
|
+
*/
|
|
7
10
|
declare function threeTierActionWorkflow(strategyTypeId: string, sourceTypeId: string, actionId: string): 'runtime-capacity' | undefined;
|
|
8
11
|
declare function validateThreeTierExtension<K extends ThreeTierExtensionSlot>(slot: K, value: MemoryJsonValue): ThreeTierExtensionValues[K];
|
|
9
12
|
/** An extension only for this Strategy; `defineMemoryViewExtension` also follows other Strategies. */
|
package/lib/extension-sdk.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { defineMemoryStrategyExtension, memoryViewExtensionValues, validateMemoryViewExtension } from "dsh-mnemon/extension-sdk";
|
|
2
2
|
import { COMPOSABLE_MEMORY_API_VERSION } from "dsh-mnemon/contracts";
|
|
3
3
|
//#region src/extension-sdk.ts
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Pure default-product policy. The Host executes it through public Source protocols.
|
|
6
|
+
* @deprecated The Host runs the workflows a Strategy declares in its manifest's `workflows`.
|
|
7
|
+
*/
|
|
5
8
|
function threeTierActionWorkflow(strategyTypeId, sourceTypeId, actionId) {
|
|
6
9
|
return strategyTypeId === "default-three-tier" && sourceTypeId === "runtime" && actionId === "mutate" ? "runtime-capacity" : void 0;
|
|
7
10
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ declare const DEFAULT_THREE_TIER_VIEW_STRATEGY: {
|
|
|
15
15
|
maxRoutes: number;
|
|
16
16
|
maxActions: number;
|
|
17
17
|
extensionSlots: string[];
|
|
18
|
+
workflows: ("idle-review" | "runtime-capacity")[];
|
|
18
19
|
};
|
|
19
20
|
compose(request: MemoryViewRequest, sources: readonly MemoryAvailableSource[], contributions?: readonly import("dsh-mnemon/extension-sdk").MemoryStrategyContribution[] | undefined): MemoryViewSpec;
|
|
20
21
|
};
|
package/lib/index.js
CHANGED
|
@@ -196,18 +196,23 @@ var ThreeTierTurn = class {
|
|
|
196
196
|
const input = memoryInputRecord(request.input, "Documents search");
|
|
197
197
|
const query = String(input.query).trim();
|
|
198
198
|
const includeArchived = input.includeArchived === true;
|
|
199
|
+
if (this.state.documentSearchPending !== void 0) {
|
|
200
|
+
await Promise.allSettled([this.state.documentSearchPending]);
|
|
201
|
+
return this.documents(request, read);
|
|
202
|
+
}
|
|
199
203
|
if (this.state.documentSearchClaimed) return {
|
|
200
204
|
...this.empty(request),
|
|
201
205
|
output: {
|
|
202
206
|
query,
|
|
203
207
|
includeArchived,
|
|
204
208
|
notRun: true,
|
|
209
|
+
budgetExhausted: true,
|
|
205
210
|
results: [],
|
|
206
|
-
hint: "This Agent turn already used its Documents search
|
|
211
|
+
hint: "This query did not run: this Agent turn already used its Documents search. The empty list does not mean no document matches. Use the admitted evidence, make one focused mnemon_recall where it is offered only if exact durable history is still missing, or answer with appropriate uncertainty."
|
|
207
212
|
}
|
|
208
213
|
};
|
|
209
214
|
this.state.documentSearchClaimed = true;
|
|
210
|
-
const
|
|
215
|
+
const pending = read({
|
|
211
216
|
query,
|
|
212
217
|
includeArchived,
|
|
213
218
|
limit: Math.min(4, typeof input.limit === "number" ? Math.max(1, input.limit) : 4)
|
|
@@ -215,6 +220,16 @@ var ThreeTierTurn = class {
|
|
|
215
220
|
maxResults: 4,
|
|
216
221
|
maxCharacters: 6e3
|
|
217
222
|
});
|
|
223
|
+
this.state.documentSearchPending = pending;
|
|
224
|
+
let evidence;
|
|
225
|
+
try {
|
|
226
|
+
evidence = await pending;
|
|
227
|
+
} catch (error) {
|
|
228
|
+
this.state.documentSearchClaimed = false;
|
|
229
|
+
throw error;
|
|
230
|
+
} finally {
|
|
231
|
+
if (this.state.documentSearchPending === pending) delete this.state.documentSearchPending;
|
|
232
|
+
}
|
|
218
233
|
const metadata = optionalObject(evidence.metadata) ?? {};
|
|
219
234
|
const results = evidence.items.filter((item) => optionalObject(item.provenance)?.kind !== "suggestion").map((item) => {
|
|
220
235
|
const record = optionalObject(item.provenance) ?? {};
|
|
@@ -277,14 +292,19 @@ var ThreeTierTurn = class {
|
|
|
277
292
|
};
|
|
278
293
|
}
|
|
279
294
|
if (retrieval.recallAttempts.length >= MODEL_RECALL_ATTEMPT_LIMIT) {
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
295
|
+
const inflight = retrieval.recallAttempts.flatMap((entry) => entry.pending === void 0 ? [] : [entry.pending]);
|
|
296
|
+
if (inflight.length > 0) {
|
|
297
|
+
await Promise.allSettled(inflight);
|
|
298
|
+
signal.throwIfAborted();
|
|
299
|
+
return this.recall(request, read, signal, authority);
|
|
300
|
+
}
|
|
283
301
|
return {
|
|
284
|
-
query:
|
|
285
|
-
mode:
|
|
286
|
-
|
|
287
|
-
|
|
302
|
+
query: scoped.query,
|
|
303
|
+
mode: scoped.mode ?? "smart",
|
|
304
|
+
results: [],
|
|
305
|
+
notRun: true,
|
|
306
|
+
budgetExhausted: true,
|
|
307
|
+
hint: "The two-query turn Recall budget is exhausted, so this query did not run. It has no results; the empty list does not mean nothing matches. Answer from the evidence the other Recall calls returned, or state what remains unknown."
|
|
288
308
|
};
|
|
289
309
|
}
|
|
290
310
|
const attemptIndex = retrieval.recallAttempts.length;
|
|
@@ -346,6 +366,7 @@ var ThreeTierTurn = class {
|
|
|
346
366
|
query: `related:${id}`,
|
|
347
367
|
mode: "related",
|
|
348
368
|
results: [],
|
|
369
|
+
notRun: true,
|
|
349
370
|
hint: "Related traversal requires an insight admitted by the current turn's direct Recall. No Provider query was made."
|
|
350
371
|
};
|
|
351
372
|
const digest = sha256(JSON.stringify({
|
|
@@ -356,13 +377,28 @@ var ThreeTierTurn = class {
|
|
|
356
377
|
edge: options.edge ?? ""
|
|
357
378
|
}));
|
|
358
379
|
if (retrieval.relatedDigest !== void 0) {
|
|
380
|
+
if (retrieval.relatedDigest !== digest) {
|
|
381
|
+
if (retrieval.relatedPending !== void 0) {
|
|
382
|
+
await Promise.allSettled([retrieval.relatedPending]);
|
|
383
|
+
signal.throwIfAborted();
|
|
384
|
+
return this.related(id, memoryBodyId, read, signal, authority, options);
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
query: `related:${id}`,
|
|
388
|
+
mode: "related",
|
|
389
|
+
results: [],
|
|
390
|
+
notRun: true,
|
|
391
|
+
budgetExhausted: true,
|
|
392
|
+
hint: "Related traversal is complete for this turn, so this one did not run. It has no results; the empty list does not mean nothing is related. Answer from the evidence the other calls returned."
|
|
393
|
+
};
|
|
394
|
+
}
|
|
359
395
|
const last = retrieval.relatedResult ?? await retrieval.relatedPending;
|
|
360
396
|
const previous = last?.memoryEvidence?.sourceInstanceKey === authority.sourceInstanceKey ? last : void 0;
|
|
361
397
|
return {
|
|
362
398
|
query: previous?.query ?? `related:${id}`,
|
|
363
399
|
mode: previous?.mode ?? "related",
|
|
364
400
|
...replayEvidence(previous, [selected], authority.sourceInstanceKey),
|
|
365
|
-
hint:
|
|
401
|
+
hint: "This exact Related traversal already ran. The Host replayed its admitted evidence without another Provider query; stop retrieval and answer from it."
|
|
366
402
|
};
|
|
367
403
|
}
|
|
368
404
|
retrieval.relatedDigest = digest;
|
|
@@ -496,7 +532,8 @@ const DEFAULT_THREE_TIER_VIEW_STRATEGY = defineMemoryStrategy({
|
|
|
496
532
|
"selection",
|
|
497
533
|
"projection",
|
|
498
534
|
"capture"
|
|
499
|
-
]
|
|
535
|
+
],
|
|
536
|
+
workflows: ["idle-review", "runtime-capacity"]
|
|
500
537
|
},
|
|
501
538
|
compose(request, sources, contributions = []) {
|
|
502
539
|
if (contributions.length === 0) return composeThreeTier(request, sources);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mnemon-strategy-default-three-tier",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"description": "Explicit three-tier View Strategy for Composable View Memory.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^22.0.0",
|
|
39
|
-
"dsh-mnemon": "^0.5.
|
|
39
|
+
"dsh-mnemon": "^0.5.32",
|
|
40
40
|
"tsdown": "^0.22.0",
|
|
41
41
|
"typescript": "^5.9.0",
|
|
42
42
|
"vitest": "^3.2.0"
|