@lmzhen/dsh-evolution-replay 0.1.0-rc.9 → 0.2.0-rc.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.
- package/lib/index.js +17 -24
- package/lib/types/index.d.ts +8 -16
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -4,9 +4,12 @@ import z from "@deepseek-ai/schemastery";
|
|
|
4
4
|
* Replay/A-B evaluation for evolution plans.
|
|
5
5
|
*
|
|
6
6
|
* The pure scoring functions remain deterministic and runtime-free. The DSH
|
|
7
|
-
* driver records every `evolution/plan-applied`
|
|
8
|
-
* in-memory leaderboard and exposes `/evolution
|
|
9
|
-
*
|
|
7
|
+
* driver records every `evolution/plan-applied` process event (payload v2,
|
|
8
|
+
* with sessionId) into an in-memory leaderboard and exposes `/evolution
|
|
9
|
+
* replay` (via the `/evolution` command family) for comparison, so a human can
|
|
10
|
+
* A/B review policy/prompt changes against real plan outcomes. Durability
|
|
11
|
+
* across restarts is the evolution-activity store's job; this leaderboard is
|
|
12
|
+
* deliberately in-memory.
|
|
10
13
|
* @module @lmzhen/dsh-evolution-replay
|
|
11
14
|
*/
|
|
12
15
|
const DEFAULT_WEIGHTS = {
|
|
@@ -62,17 +65,15 @@ var EvolutionReplayDriver = class {
|
|
|
62
65
|
this.maxPlans = config.maxPlans ?? 50;
|
|
63
66
|
this.weights = config.weights ?? DEFAULT_WEIGHTS;
|
|
64
67
|
}
|
|
65
|
-
record(
|
|
66
|
-
if (event.type !== "evolution/plan-applied") return;
|
|
67
|
-
const data = event.data;
|
|
68
|
+
record(plan) {
|
|
68
69
|
this.plans.push({
|
|
69
|
-
policyId: typeof
|
|
70
|
-
acceptedOps:
|
|
71
|
-
rejectedOps:
|
|
72
|
-
memoryOps:
|
|
73
|
-
skillOps:
|
|
74
|
-
evidenceQuotes: typeof
|
|
75
|
-
estimatedInputChars: typeof
|
|
70
|
+
policyId: typeof plan.policyFingerprint === "string" ? plan.policyFingerprint : plan.planId,
|
|
71
|
+
acceptedOps: plan.memoryApplied + plan.skillApplied,
|
|
72
|
+
rejectedOps: plan.rejectedOps,
|
|
73
|
+
memoryOps: plan.memoryApplied,
|
|
74
|
+
skillOps: plan.skillApplied,
|
|
75
|
+
evidenceQuotes: typeof plan.evidenceQuotes === "number" ? plan.evidenceQuotes : plan.memoryApplied + plan.skillApplied,
|
|
76
|
+
estimatedInputChars: typeof plan.estimatedInputChars === "number" ? plan.estimatedInputChars : 0
|
|
76
77
|
});
|
|
77
78
|
if (this.plans.length > this.maxPlans) this.plans.shift();
|
|
78
79
|
}
|
|
@@ -87,17 +88,9 @@ const name = "evolution-replay";
|
|
|
87
88
|
function apply(ctx, rawConfig = {}) {
|
|
88
89
|
const driver = new EvolutionReplayDriver(rawConfig);
|
|
89
90
|
ctx.provide("evolutionReplay", driver);
|
|
90
|
-
ctx.on("
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
ctx.inject(["commands"], (commandCtx) => {
|
|
94
|
-
commandCtx.commands.register({
|
|
95
|
-
name: "evolution replay",
|
|
96
|
-
description: "Compare recent evolution plan outcomes",
|
|
97
|
-
recordInput: false,
|
|
98
|
-
handler: () => ({ text: driver.compare().report })
|
|
99
|
-
});
|
|
91
|
+
ctx.on("evolution/plan-applied", (event) => {
|
|
92
|
+
driver.record(event);
|
|
100
93
|
});
|
|
101
94
|
}
|
|
102
95
|
//#endregion
|
|
103
|
-
export { Config, DEFAULT_WEIGHTS, EvolutionReplayDriver, apply, comparePlans, name
|
|
96
|
+
export { Config, DEFAULT_WEIGHTS, EvolutionReplayDriver, apply, comparePlans, name };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
* Replay/A-B evaluation for evolution plans.
|
|
3
3
|
*
|
|
4
4
|
* The pure scoring functions remain deterministic and runtime-free. The DSH
|
|
5
|
-
* driver records every `evolution/plan-applied`
|
|
6
|
-
* in-memory leaderboard and exposes `/evolution
|
|
7
|
-
*
|
|
5
|
+
* driver records every `evolution/plan-applied` process event (payload v2,
|
|
6
|
+
* with sessionId) into an in-memory leaderboard and exposes `/evolution
|
|
7
|
+
* replay` (via the `/evolution` command family) for comparison, so a human can
|
|
8
|
+
* A/B review policy/prompt changes against real plan outcomes. Durability
|
|
9
|
+
* across restarts is the evolution-activity store's job; this leaderboard is
|
|
10
|
+
* deliberately in-memory.
|
|
8
11
|
* @module @deepseek-ai/dsh-evolution-replay
|
|
9
12
|
*/
|
|
10
13
|
import type { Context } from '@deepseek-ai/cordis';
|
|
11
14
|
import z from '@deepseek-ai/schemastery';
|
|
15
|
+
import type { EvolutionPlanAppliedEvent } from '@deepseek-ai/dsh-evolution-core';
|
|
12
16
|
export interface ReplayPlan {
|
|
13
17
|
policyId: string;
|
|
14
18
|
acceptedOps: number;
|
|
@@ -36,7 +40,6 @@ export interface Config {
|
|
|
36
40
|
weights?: ReplayWeights;
|
|
37
41
|
}
|
|
38
42
|
export declare const Config: z<Config>;
|
|
39
|
-
export declare function scorePlan(plan: ReplayPlan, weights?: ReplayWeights): number;
|
|
40
43
|
export declare function comparePlans(plans: ReplayPlan[], weights?: ReplayWeights): ReplayResult;
|
|
41
44
|
declare module '@deepseek-ai/cordis' {
|
|
42
45
|
interface Context {
|
|
@@ -48,18 +51,7 @@ export declare class EvolutionReplayDriver {
|
|
|
48
51
|
private readonly maxPlans;
|
|
49
52
|
private readonly weights;
|
|
50
53
|
constructor(config?: Config);
|
|
51
|
-
record(
|
|
52
|
-
type: string;
|
|
53
|
-
data: {
|
|
54
|
-
planId: string;
|
|
55
|
-
policyFingerprint?: string | undefined;
|
|
56
|
-
memoryApplied: number;
|
|
57
|
-
skillApplied: number;
|
|
58
|
-
rejectedOps: number;
|
|
59
|
-
evidenceQuotes?: number | undefined;
|
|
60
|
-
estimatedInputChars?: number | undefined;
|
|
61
|
-
};
|
|
62
|
-
}): void;
|
|
54
|
+
record(plan: EvolutionPlanAppliedEvent): void;
|
|
63
55
|
plansSnapshot(): ReplayPlan[];
|
|
64
56
|
compare(weights?: ReplayWeights): ReplayResult;
|
|
65
57
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-replay",
|
|
3
3
|
"description": "Replay/A-B evaluation primitives for evolution plans (community build)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0-rc.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
36
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
36
|
+
"@lmzhen/dsh-evolution-core": "^0.2.0-rc.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
40
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
41
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
40
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
41
|
+
"@deepseek-ai/dsh-session": "^0.1.1-rc.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
45
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
46
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
44
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
45
|
+
"@deepseek-ai/dsh-session": "^0.1.1-rc.2",
|
|
46
|
+
"@lmzhen/dsh-evolution-core": "^0.2.0-rc.1"
|
|
47
47
|
}
|
|
48
48
|
}
|