@lmzhen/dsh-evolution-plan-validator 0.3.15 → 0.3.17
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 +23 -11
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_MAX_OPS_PER_PLAN, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_USER_CHAR_LIMIT, MAX_RESTRUCTURE_MOVES, RESTRUCTURE_TARGET_RE } from "@lmzhen/dsh-evolution-core";
|
|
1
|
+
import { DEFAULT_MAX_OPS_PER_PLAN, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_USER_CHAR_LIMIT, FORBIDDEN_CONTROL_KEYS, MAX_RESTRUCTURE_MOVES, RESTRUCTURE_TARGET_RE } from "@lmzhen/dsh-evolution-core";
|
|
2
2
|
//#region lib/types/index.js
|
|
3
3
|
/**
|
|
4
4
|
* Deterministic validator for model-produced evolution plans.
|
|
@@ -20,13 +20,7 @@ const SKILL_ACTIONS = new Set([
|
|
|
20
20
|
"remove_file",
|
|
21
21
|
"restructure"
|
|
22
22
|
]);
|
|
23
|
-
const FORBIDDEN_KEYS =
|
|
24
|
-
"policy",
|
|
25
|
-
"threshold",
|
|
26
|
-
"prompt_hash",
|
|
27
|
-
"model_route",
|
|
28
|
-
"evolution_config"
|
|
29
|
-
];
|
|
23
|
+
const FORBIDDEN_KEYS = FORBIDDEN_CONTROL_KEYS;
|
|
30
24
|
function hasValidEvidence(evidence, sessionSeq) {
|
|
31
25
|
if (!Array.isArray(evidence) || evidence.length === 0) return false;
|
|
32
26
|
return evidence.every((item) => {
|
|
@@ -71,7 +65,16 @@ function validateEvolutionPlan(plan, context) {
|
|
|
71
65
|
ok: false
|
|
72
66
|
};
|
|
73
67
|
}
|
|
74
|
-
for (const [index,
|
|
68
|
+
for (const [index, rawOp] of (plan.memoryOps ?? []).entries()) {
|
|
69
|
+
if (rawOp === null || typeof rawOp !== "object" || Array.isArray(rawOp)) {
|
|
70
|
+
rejected.push({
|
|
71
|
+
index,
|
|
72
|
+
kind: "memory",
|
|
73
|
+
reason: `memory op ${index}: malformed operation (expected an object)`
|
|
74
|
+
});
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const op = rawOp;
|
|
75
78
|
const reason = validateMemoryOp(op, context, index);
|
|
76
79
|
if (reason) rejected.push({
|
|
77
80
|
index,
|
|
@@ -80,7 +83,16 @@ function validateEvolutionPlan(plan, context) {
|
|
|
80
83
|
});
|
|
81
84
|
else memoryOps.push(op);
|
|
82
85
|
}
|
|
83
|
-
for (const [index,
|
|
86
|
+
for (const [index, rawOp] of (plan.skillOps ?? []).entries()) {
|
|
87
|
+
if (rawOp === null || typeof rawOp !== "object" || Array.isArray(rawOp)) {
|
|
88
|
+
rejected.push({
|
|
89
|
+
index,
|
|
90
|
+
kind: "skill",
|
|
91
|
+
reason: `skill op ${index}: malformed operation (expected an object)`
|
|
92
|
+
});
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const op = rawOp;
|
|
84
96
|
const reason = validateSkillOp(op, context, index);
|
|
85
97
|
if (reason) rejected.push({
|
|
86
98
|
index,
|
|
@@ -119,7 +131,7 @@ function validateSkillOp(op, context, index) {
|
|
|
119
131
|
if ((action === "create" || action === "edit" || action === "update") && !(op.content ?? "").trim()) return `skill op ${index}: ${action} requires content`;
|
|
120
132
|
if (action === "patch" && !(op.old_string ?? "")) return `skill op ${index}: patch requires old_string`;
|
|
121
133
|
if (action === "delete" && !(op.absorbed_into ?? "").trim()) return `skill op ${index}: delete requires absorbed_into`;
|
|
122
|
-
const writeContent = op.file_content ?? op.content ?? "";
|
|
134
|
+
const writeContent = op.file_content ?? op.content ?? op.new_string ?? "";
|
|
123
135
|
if (action === "write_file" && !writeContent.trim()) return `skill op ${index}: write_file requires file_content`;
|
|
124
136
|
if (writeContent.length > (context.maxSkillContentChars ?? DEFAULT_SKILL_CONTENT_CHARS)) return `skill op ${index}: content exceeds skill budget`;
|
|
125
137
|
if (action === "restructure") {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-plan-validator",
|
|
3
3
|
"description": "Deterministic validator for model-produced evolution plans (community build)",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.17",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
36
|
-
"@lmzhen/dsh-evolution-core": "^0.3.
|
|
36
|
+
"@lmzhen/dsh-evolution-core": "^0.3.17"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|