dsh-logicprobe 0.4.0 → 0.5.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/README.en-US.md +10 -3
- package/README.md +10 -3
- package/lib/concurrency-tool.js +34 -0
- package/lib/concurrency.js +76 -0
- package/lib/data-engine.js +930 -0
- package/lib/data-tool.js +61 -0
- package/lib/engine.js +258 -0
- package/lib/index.js +37 -23
- package/lib/tool.js +1 -1
- package/lib/types/concurrency-tool.d.ts +8 -0
- package/lib/types/concurrency.d.ts +20 -0
- package/lib/types/data-engine.d.ts +199 -0
- package/lib/types/data-tool.d.ts +10 -0
- package/lib/types/engine.d.ts +20 -0
- package/package.json +82 -81
- package/skills/logicprobe/SKILL.md +285 -268
- package/skills/logicprobe/references/__pycache__/verification-harness.cpython-312.pyc +0 -0
- package/skills/logicprobe/references/concurrency-risk-guide.md +54 -0
- package/skills/logicprobe/references/dsh-model-schema.md +145 -129
- package/skills/logicprobe/references/logic-verification-guide.md +463 -413
- package/skills/logicprobe/references/verification-harness.py +806 -582
- package/skills/logicprobe-datamodel/SKILL.md +124 -0
- package/skills/logicprobe-datamodel/references/__pycache__/data-model-harness.cpython-312.pyc +0 -0
- package/skills/logicprobe-datamodel/references/data-model-guide.md +62 -0
- package/skills/logicprobe-datamodel/references/data-model-harness.py +528 -0
- package/skills/logicprobe-datamodel/references/data-model-schema.md +128 -0
- package/src/concurrency-tool.ts +37 -0
- package/src/concurrency.ts +102 -0
- package/src/data-engine.ts +1001 -0
- package/src/data-tool.ts +65 -0
- package/src/engine.ts +234 -0
- package/src/index.ts +315 -301
- package/src/tool.ts +60 -60
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { CheckResult } from './engine.js';
|
|
2
|
+
export declare const DATA_ENGINE_SCHEMA_VERSION = 1;
|
|
3
|
+
export type DataValue = number | string | boolean | null;
|
|
4
|
+
export type DataType = 'string' | 'integer' | 'number' | 'boolean' | 'uuid' | 'date' | 'datetime' | 'timestamp' | 'json' | 'enum' | 'array' | 'object' | 'binary';
|
|
5
|
+
export interface FieldSpec {
|
|
6
|
+
name: string;
|
|
7
|
+
type: DataType | string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
unique?: boolean;
|
|
10
|
+
nullable?: boolean;
|
|
11
|
+
default?: DataValue;
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
minLength?: number;
|
|
15
|
+
maxLength?: number;
|
|
16
|
+
pattern?: string;
|
|
17
|
+
enum?: DataValue[];
|
|
18
|
+
ref?: string;
|
|
19
|
+
items?: FieldSpec;
|
|
20
|
+
monotonic?: 'inc' | 'dec';
|
|
21
|
+
}
|
|
22
|
+
export interface EntitySpec {
|
|
23
|
+
name: string;
|
|
24
|
+
fields: FieldSpec[];
|
|
25
|
+
primaryKey?: string[];
|
|
26
|
+
uniqueKeys?: string[][];
|
|
27
|
+
indexes?: string[][];
|
|
28
|
+
}
|
|
29
|
+
export interface RelationshipSpec {
|
|
30
|
+
name?: string;
|
|
31
|
+
fromEntity: string;
|
|
32
|
+
fromField: string;
|
|
33
|
+
toEntity: string;
|
|
34
|
+
toField?: string;
|
|
35
|
+
onDelete?: 'cascade' | 'restrict' | 'set-null' | 'no-action';
|
|
36
|
+
}
|
|
37
|
+
export type DataInvariantSpec = {
|
|
38
|
+
id: string;
|
|
39
|
+
description: string;
|
|
40
|
+
kind: 'field-required';
|
|
41
|
+
entity: string;
|
|
42
|
+
field: string;
|
|
43
|
+
} | {
|
|
44
|
+
id: string;
|
|
45
|
+
description: string;
|
|
46
|
+
kind: 'unique';
|
|
47
|
+
entity: string;
|
|
48
|
+
fields: string[];
|
|
49
|
+
} | {
|
|
50
|
+
id: string;
|
|
51
|
+
description: string;
|
|
52
|
+
kind: 'referential-integrity';
|
|
53
|
+
entity: string;
|
|
54
|
+
field: string;
|
|
55
|
+
refEntity: string;
|
|
56
|
+
refField?: string;
|
|
57
|
+
} | {
|
|
58
|
+
id: string;
|
|
59
|
+
description: string;
|
|
60
|
+
kind: 'range';
|
|
61
|
+
entity: string;
|
|
62
|
+
field: string;
|
|
63
|
+
min?: number;
|
|
64
|
+
max?: number;
|
|
65
|
+
} | {
|
|
66
|
+
id: string;
|
|
67
|
+
description: string;
|
|
68
|
+
kind: 'count-equal';
|
|
69
|
+
sourceEntity: string;
|
|
70
|
+
targetEntity: string;
|
|
71
|
+
} | {
|
|
72
|
+
id: string;
|
|
73
|
+
description: string;
|
|
74
|
+
kind: 'field-equal';
|
|
75
|
+
sourceEntity: string;
|
|
76
|
+
sourceField: string;
|
|
77
|
+
targetEntity: string;
|
|
78
|
+
targetField: string;
|
|
79
|
+
} | {
|
|
80
|
+
id: string;
|
|
81
|
+
description: string;
|
|
82
|
+
kind: 'no-orphan';
|
|
83
|
+
entity: string;
|
|
84
|
+
field: string;
|
|
85
|
+
refEntity: string;
|
|
86
|
+
} | {
|
|
87
|
+
id: string;
|
|
88
|
+
description: string;
|
|
89
|
+
kind: 'idempotent-copy';
|
|
90
|
+
sourceEntity: string;
|
|
91
|
+
targetEntity: string;
|
|
92
|
+
} | {
|
|
93
|
+
id: string;
|
|
94
|
+
description: string;
|
|
95
|
+
kind: 'idempotent-migration';
|
|
96
|
+
from: string;
|
|
97
|
+
to: string;
|
|
98
|
+
} | {
|
|
99
|
+
id: string;
|
|
100
|
+
description: string;
|
|
101
|
+
kind: 'monotonic';
|
|
102
|
+
entity: string;
|
|
103
|
+
field: string;
|
|
104
|
+
direction: 'inc' | 'dec';
|
|
105
|
+
} | {
|
|
106
|
+
id: string;
|
|
107
|
+
description: string;
|
|
108
|
+
kind: 'sequence';
|
|
109
|
+
steps: string[];
|
|
110
|
+
} | {
|
|
111
|
+
id: string;
|
|
112
|
+
description: string;
|
|
113
|
+
kind: 'leads-to';
|
|
114
|
+
entity: string;
|
|
115
|
+
field: string;
|
|
116
|
+
from: DataValue;
|
|
117
|
+
to: DataValue;
|
|
118
|
+
} | {
|
|
119
|
+
id: string;
|
|
120
|
+
description: string;
|
|
121
|
+
kind: 'atomicity';
|
|
122
|
+
steps: string[];
|
|
123
|
+
};
|
|
124
|
+
export interface DataModelV1 {
|
|
125
|
+
schemaVersion: 1;
|
|
126
|
+
entities: EntitySpec[];
|
|
127
|
+
relationships?: RelationshipSpec[];
|
|
128
|
+
invariants?: DataInvariantSpec[];
|
|
129
|
+
boundaryChecks?: Array<{
|
|
130
|
+
entity: string;
|
|
131
|
+
field: string;
|
|
132
|
+
values?: DataValue[];
|
|
133
|
+
}>;
|
|
134
|
+
}
|
|
135
|
+
export interface CopyPairSpec {
|
|
136
|
+
id: string;
|
|
137
|
+
sourceEntity: string;
|
|
138
|
+
targetEntity: string;
|
|
139
|
+
mapping: Record<string, string>;
|
|
140
|
+
}
|
|
141
|
+
export interface BackupPairSpec {
|
|
142
|
+
id: string;
|
|
143
|
+
sourceEntity: string;
|
|
144
|
+
targetEntity: string;
|
|
145
|
+
mapping: Record<string, string>;
|
|
146
|
+
}
|
|
147
|
+
export interface MigrationMappingSpec {
|
|
148
|
+
id?: string;
|
|
149
|
+
from: string;
|
|
150
|
+
to: string;
|
|
151
|
+
transform?: 'copy' | 'rename' | 'split' | 'merge' | 'drop' | 'manual';
|
|
152
|
+
note?: string;
|
|
153
|
+
}
|
|
154
|
+
export interface DataVerificationOptions {
|
|
155
|
+
beforeModel?: unknown;
|
|
156
|
+
fieldMapping?: Record<string, string>;
|
|
157
|
+
copyPairs?: CopyPairSpec[];
|
|
158
|
+
migrationMappings?: MigrationMappingSpec[];
|
|
159
|
+
backupPairs?: BackupPairSpec[];
|
|
160
|
+
}
|
|
161
|
+
export interface DataComparisonSummary {
|
|
162
|
+
beforeModelHash: string;
|
|
163
|
+
afterModelHash: string;
|
|
164
|
+
fieldMapping: Record<string, string>;
|
|
165
|
+
beforeEntities: number;
|
|
166
|
+
beforeFields: number;
|
|
167
|
+
afterEntities: number;
|
|
168
|
+
afterFields: number;
|
|
169
|
+
addedEntities: string[];
|
|
170
|
+
removedEntities: string[];
|
|
171
|
+
addedFields: string[];
|
|
172
|
+
removedFields: string[];
|
|
173
|
+
addedRelationships: string[];
|
|
174
|
+
removedRelationships: string[];
|
|
175
|
+
}
|
|
176
|
+
export interface DataVerificationReport {
|
|
177
|
+
ok: boolean;
|
|
178
|
+
schemaVersion: 1;
|
|
179
|
+
modelHash: string;
|
|
180
|
+
summary: {
|
|
181
|
+
entities: number;
|
|
182
|
+
fields: number;
|
|
183
|
+
errors: number;
|
|
184
|
+
warnings: number;
|
|
185
|
+
checksRun: number;
|
|
186
|
+
truncated?: boolean;
|
|
187
|
+
};
|
|
188
|
+
checks: CheckResult[];
|
|
189
|
+
comparison?: DataComparisonSummary;
|
|
190
|
+
}
|
|
191
|
+
export declare function dataModelHash(model: DataModelV1): string;
|
|
192
|
+
export declare function validateDataModel(input: unknown): {
|
|
193
|
+
ok: true;
|
|
194
|
+
model: DataModelV1;
|
|
195
|
+
} | {
|
|
196
|
+
ok: false;
|
|
197
|
+
errors: string[];
|
|
198
|
+
};
|
|
199
|
+
export declare function runDataVerification(input: unknown, options?: DataVerificationOptions): DataVerificationReport;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DATA_ENGINE_SCHEMA_VERSION } from './data-engine.js';
|
|
2
|
+
export declare const LOGICPROBE_DATAMODEL_VERIFY_TOOL_NAME = "logicprobe_datamodel_verify";
|
|
3
|
+
/**
|
|
4
|
+
* Model-visible DSH tool wrapping the bundled data-model verification engine.
|
|
5
|
+
* The model passes a DataModelV1 object; the engine validates it and returns
|
|
6
|
+
* DS/DA/DD checks. Optional beforeModel/fieldMapping/copyPairs/migrationMappings
|
|
7
|
+
* enable before/after data-model regression and migration coverage checks.
|
|
8
|
+
*/
|
|
9
|
+
export declare const logicProbeDataModelVerifyTool: import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
10
|
+
export { DATA_ENGINE_SCHEMA_VERSION };
|
package/lib/types/engine.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export interface VariableSpec {
|
|
|
39
39
|
init: number | boolean;
|
|
40
40
|
min?: number;
|
|
41
41
|
max?: number;
|
|
42
|
+
monotonic?: 'inc' | 'dec';
|
|
42
43
|
}
|
|
43
44
|
export type InvariantSpec = {
|
|
44
45
|
id: string;
|
|
@@ -58,6 +59,24 @@ export type InvariantSpec = {
|
|
|
58
59
|
kind: 'event-before-state';
|
|
59
60
|
event: string;
|
|
60
61
|
state: string;
|
|
62
|
+
} | {
|
|
63
|
+
id: string;
|
|
64
|
+
description: string;
|
|
65
|
+
kind: 'leads-to';
|
|
66
|
+
from: string;
|
|
67
|
+
to: string;
|
|
68
|
+
} | {
|
|
69
|
+
id: string;
|
|
70
|
+
description: string;
|
|
71
|
+
kind: 'sequence';
|
|
72
|
+
events: string[];
|
|
73
|
+
} | {
|
|
74
|
+
id: string;
|
|
75
|
+
description: string;
|
|
76
|
+
kind: 'atomicity';
|
|
77
|
+
events: string[];
|
|
78
|
+
commit: string;
|
|
79
|
+
rollback?: string;
|
|
61
80
|
};
|
|
62
81
|
export interface ResourcePairSpec {
|
|
63
82
|
resource: string;
|
|
@@ -79,6 +98,7 @@ export interface LogicModelV1 {
|
|
|
79
98
|
concurrentPairs?: [string, string][];
|
|
80
99
|
boundaryChecks?: BoundaryCheckSpec[];
|
|
81
100
|
resourcePairs?: ResourcePairSpec[];
|
|
101
|
+
idempotentEvents?: string[];
|
|
82
102
|
}
|
|
83
103
|
export interface VerificationOptions {
|
|
84
104
|
maxStates?: number;
|
package/package.json
CHANGED
|
@@ -1,81 +1,82 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-logicprobe",
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "Design document & plan claim verification — enumerate claims, verify against codebase facts, then escalate to state-machine verification (S1-S8/A1-A11) and data-model verification (DS/DA/DD) for behavioral claims. Supports before/after regression, idempotency/monotonic/sequence/leads-to/atomicity constraints, and concurrency risk mining. Ships a native DeepSeek Harness (dsh) bundle that injects the claim-verification gate into the first model step.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"lib",
|
|
18
|
+
"src",
|
|
19
|
+
"skills",
|
|
20
|
+
"cordis.patch.yml"
|
|
21
|
+
],
|
|
22
|
+
"dsh": {
|
|
23
|
+
"category": "skill",
|
|
24
|
+
"displayName": "逻辑探针",
|
|
25
|
+
"bundle": {
|
|
26
|
+
"patch": "./cordis.patch.yml"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -p tsconfig.json",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"test:engine": "npm run build && node tests/engine/run.mjs && node tests/data-engine/run.mjs && node tests/concurrency/run.mjs && node tests/apply-smoke.mjs",
|
|
33
|
+
"test:full": "npm run build && node tests/full-suite.mjs"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
38
|
+
"@deepseek-ai/dsh-agent": "^0.1.0-rc.6",
|
|
39
|
+
"@deepseek-ai/dsh-llm": "^0.0.1-rc.1",
|
|
40
|
+
"@deepseek-ai/dsh-session": "^0.0.1-rc.1",
|
|
41
|
+
"@deepseek-ai/dsh-skill-filesystem": "^0.1.0-rc.6",
|
|
42
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
43
|
+
"@deepseek-ai/dsh-tools": "^0.1.0-rc.6"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
47
|
+
"@deepseek-ai/dsh-agent": "^0.1.0-rc.6",
|
|
48
|
+
"@deepseek-ai/dsh-cordis-host-runner": "^0.1.0-rc.6",
|
|
49
|
+
"@deepseek-ai/dsh-home-paths": "^0.1.0-rc.6",
|
|
50
|
+
"@deepseek-ai/dsh-llm": "^0.0.1-rc.1",
|
|
51
|
+
"@deepseek-ai/dsh-scope": "^0.1.0-rc.6",
|
|
52
|
+
"@deepseek-ai/dsh-session": "^0.0.1-rc.1",
|
|
53
|
+
"@deepseek-ai/dsh-skill": "^0.1.0-rc.6",
|
|
54
|
+
"@deepseek-ai/dsh-skill-filesystem": "^0.1.0-rc.6",
|
|
55
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
56
|
+
"@deepseek-ai/dsh-timeout": "^0.0.1-rc.1",
|
|
57
|
+
"@types/node": "^20.0.0",
|
|
58
|
+
"typescript": "^5.0.0",
|
|
59
|
+
"@deepseek-ai/dsh-tools": "^0.1.0-rc.6",
|
|
60
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.6"
|
|
61
|
+
},
|
|
62
|
+
"author": {
|
|
63
|
+
"name": "Amethyst Luna",
|
|
64
|
+
"url": "https://github.com/AmethystLuna"
|
|
65
|
+
},
|
|
66
|
+
"license": "MIT",
|
|
67
|
+
"repository": "https://github.com/AmethystLuna/logicprobe",
|
|
68
|
+
"keywords": [
|
|
69
|
+
"verification",
|
|
70
|
+
"fact-check",
|
|
71
|
+
"design-review",
|
|
72
|
+
"plan-review",
|
|
73
|
+
"state-machine",
|
|
74
|
+
"logic-verification",
|
|
75
|
+
"adversarial",
|
|
76
|
+
"refactoring",
|
|
77
|
+
"model-checking",
|
|
78
|
+
"agentskills",
|
|
79
|
+
"plugin",
|
|
80
|
+
"dsh"
|
|
81
|
+
]
|
|
82
|
+
}
|