dsh-vibe-math 2.7.0 → 2.7.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.md +5 -0
- package/README.md +5 -0
- package/cordis.patch.yml +6 -0
- package/docs/math-computation.md +44 -2
- package/docs/release-notes/RELEASE-NOTES-2.7.1.en.md +86 -0
- package/docs/release-notes/RELEASE-NOTES-2.7.1.md +86 -0
- package/package.json +5 -3
- package/prompt-corpus-persona/persona-corpus.json +8 -8
- package/prompt-corpus-persona/persona-corpus.md +12 -0
- package/prompt-corpus-v2/formal-verify-v2.json +162 -96
- package/prompt-corpus-v2/formal-verify-v2.md +949 -0
- package/prompt-corpus-v3/formal-verify-v3.json +171 -57
- package/prompt-corpus-v3/formal-verify-v3.md +1146 -0
- package/prompt-corpus-v4/formal-verify-v4.json +10 -10
- package/prompt-corpus-v4/formal-verify-v4.md +20 -0
- package/prompt-corpus-v5/prompt-corpus-v5.json +61 -61
- package/prompt-corpus-v5/prompt-corpus-v5.md +61 -0
- package/tests/audit-math-computation-contract.mjs +13 -0
- package/tests/audit-math-computation-parity.mjs +30 -1
- package/tests/audit-math-computation-sensitivity.mjs +1 -1
- package/tests/e2e-v5-round2.test.mjs +7 -0
- package/tests/formal-verify-v2.test.mjs +70 -2
- package/tests/formal-verify-v3.test.mjs +84 -2
- package/tests/helpers/math-computation-fake-seam.mjs +30 -2
- package/tests/math-computation-shared.test.mjs +304 -2
- package/vibe-math-v2/agent.cordis.yml +2 -0
- package/vibe-math-v2/math-computation.js +390 -47
- package/vibe-math-v2/math-engines.js +47 -6
- package/vibe-math-v2/vibe-math-v2.js +17 -1
- package/vibe-math-v3/agent.cordis.yml +2 -0
- package/vibe-math-v3/math-computation.js +390 -47
- package/vibe-math-v3/math-engines.js +47 -6
- package/vibe-math-v3/vibe-math-v3.js +17 -1
- package/vibe-math-v4/agent.cordis.yml +4 -0
- package/vibe-math-v4/math-computation.js +390 -47
- package/vibe-math-v4/math-engines.js +47 -6
- package/vibe-math-v4/vibe-math-v4.js +15 -0
- package/vibe-math-v5/agent.cordis.yml +4 -0
- package/vibe-math-v5/math-computation.js +390 -47
- package/vibe-math-v5/math-engines.js +47 -6
- package/vibe-math-v5/vibe-math-v5.js +15 -3
|
@@ -22,14 +22,47 @@ export const MATH_ENGINES = {
|
|
|
22
22
|
candidates: ['python3', 'python', 'py'], winPrefix: ['-3'],
|
|
23
23
|
versionArgv: ['--version'], versionRe: '(\\d+\\.\\d+\\.\\d+)',
|
|
24
24
|
scriptArgv: ['<script>'], evalArgv: ['-c', '<expr>'], stdinArgv: ['-'], ext: '.py',
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
// round-7 (live): NO shell metacharacters (`|`, `%`) in any probe argv - a real host rejected
|
|
26
|
+
// them with a null spawn. One line per package: "name ok|missing".
|
|
27
|
+
probeCode: "import importlib.util,sys\nfor p in sys.argv[1:]: print(p, 'ok' if importlib.util.find_spec(p) is not None else 'missing')",
|
|
28
|
+
// round-7 (finding 6, found on the real bundled python): the probe code iterates `sys.argv[1:]`,
|
|
29
|
+
// so the names must be SEPARATE argv items - the old comma-joined `<pkgs>` made it look up one
|
|
30
|
+
// package literally named "numpy,pandas" and reported everything missing.
|
|
31
|
+
packageProbe: { argv: ['-c', '<probeCode>', '<pkgs...>'], parse: 'pairs' },
|
|
27
32
|
license: 'free', argErrorHints: ARG_ERROR_HINTS,
|
|
28
33
|
install: {
|
|
29
34
|
manager: 'pip',
|
|
30
35
|
userArgv: ['<exe>', '-m', 'pip', 'install', '--user', '<pkg>'],
|
|
31
36
|
systemArgv: ['<exe>', '-m', 'pip', 'install', '<pkg>'],
|
|
32
37
|
uninstallArgv: ['<exe>', '-m', 'pip', 'uninstall', '-y', '<pkg>'],
|
|
38
|
+
// Round-6 (B): DISPATCH by the detected interpreter environment. `pip` is the documented
|
|
39
|
+
// fallback; the module picks conda/mamba/uv only when the interpreter's OWN environment says so
|
|
40
|
+
// (detect, don't guess) and the plan states which manager it assumed.
|
|
41
|
+
managers: {
|
|
42
|
+
conda: {
|
|
43
|
+
detect: 'conda-markers',
|
|
44
|
+
userArgv: ['conda', 'install', '-y', '-c', 'conda-forge', '<pkg>'],
|
|
45
|
+
uninstallArgv: ['conda', 'remove', '-y', '<pkg>'],
|
|
46
|
+
systemUnsupportedReason: 'conda 环境是用户级的;系统级安装不在 conda 的概念里(本工具只出用户级计划)',
|
|
47
|
+
},
|
|
48
|
+
mamba: {
|
|
49
|
+
detect: 'conda-markers',
|
|
50
|
+
userArgv: ['mamba', 'install', '-y', '-c', 'conda-forge', '<pkg>'],
|
|
51
|
+
uninstallArgv: ['mamba', 'remove', '-y', '<pkg>'],
|
|
52
|
+
systemUnsupportedReason: 'mamba 环境是用户级的;系统级安装不在 mamba 的概念里(本工具只出用户级计划)',
|
|
53
|
+
},
|
|
54
|
+
uv: {
|
|
55
|
+
detect: 'uv-next-to-interpreter',
|
|
56
|
+
userArgv: ['uv', 'pip', 'install', '<pkg>'],
|
|
57
|
+
uninstallArgv: ['uv', 'pip', 'uninstall', '<pkg>'],
|
|
58
|
+
systemUnsupportedReason: 'uv 装进当前虚拟环境(用户级);系统级需要发行版包管理器,本工具只出用户级计划',
|
|
59
|
+
},
|
|
60
|
+
pip: {
|
|
61
|
+
detect: 'fallback',
|
|
62
|
+
systemArgv: ['<exe>', '-m', 'pip', 'install', '<pkg>'],
|
|
63
|
+
uninstallArgv: ['<exe>', '-m', 'pip', 'uninstall', '-y', '<pkg>'],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
33
66
|
},
|
|
34
67
|
userInstall: { windows: 'winget install --id Python.Python.3.12', macos: 'brew install python', linux: 'apt install python3' },
|
|
35
68
|
},
|
|
@@ -38,13 +71,16 @@ export const MATH_ENGINES = {
|
|
|
38
71
|
candidates: ['Rscript', 'R'],
|
|
39
72
|
versionArgv: ['--version'], versionRe: '(\\d+\\.\\d+\\.\\d+)',
|
|
40
73
|
scriptArgv: ['<script>'], evalArgv: ['-e', '<expr>'], stdinArgv: ['--no-save', '--slave'], ext: '.R',
|
|
41
|
-
|
|
74
|
+
// round-7 (live): line-per-package, no `|` in the argv.
|
|
75
|
+
probeCode: "for (p in strsplit('__PKGS__',',')[[1]]) cat(p, if (requireNamespace(p, quietly=TRUE)) 'ok' else 'missing', '\\n')",
|
|
42
76
|
packageProbe: { argv: ['-e', '<probeCode>'], parse: 'pairs' },
|
|
43
77
|
license: 'free', argErrorHints: ARG_ERROR_HINTS,
|
|
44
78
|
install: {
|
|
45
79
|
manager: 'r',
|
|
46
80
|
userArgv: ['<exe>', '-e', "install.packages('__PKG__',lib=Sys.getenv('R_LIBS_USER'),repos='https://cloud.r-project.org')"],
|
|
47
81
|
uninstallArgv: ['<exe>', '-e', "remove.packages('__PKG__',lib=Sys.getenv('R_LIBS_USER'))"],
|
|
82
|
+
// Round-6 (C): user-only BY DESIGN, and the refusal now says why per engine.
|
|
83
|
+
systemUnsupportedReason: 'R 的用户库是 R_LIBS_USER;系统级安装要写发行版的包目录(需 root 或发行版包管理器),本工具只出用户级计划',
|
|
48
84
|
},
|
|
49
85
|
userInstall: { windows: 'winget install --id RProject.R', macos: 'brew install r', linux: 'apt install r-base' },
|
|
50
86
|
},
|
|
@@ -54,13 +90,15 @@ export const MATH_ENGINES = {
|
|
|
54
90
|
versionArgv: ['--version'], versionRe: '(\\d+\\.\\d+\\.\\d+)',
|
|
55
91
|
scriptArgv: ['--no-gui', '--quiet', '<script>'], evalArgv: ['--no-gui', '--quiet', '--eval', '<expr>'],
|
|
56
92
|
stdinArgv: ['--no-gui', '--quiet'], ext: '.m',
|
|
57
|
-
|
|
93
|
+
// round-7 (live): line-per-package via disp, no `|` and no `%` in the argv.
|
|
94
|
+
probeCode: "s=pkg('list'); n={'__QPKGS__'}; for i=1:numel(n); if any(cellfun(@(x) strcmp(x.name,n{i}),s)); disp([n{i} ' ok']); else; disp([n{i} ' missing']); end; end",
|
|
58
95
|
packageProbe: { argv: ['--no-gui', '--quiet', '--eval', '<probeCode>'], parse: 'pairs' },
|
|
59
96
|
license: 'free', argErrorHints: ARG_ERROR_HINTS,
|
|
60
97
|
install: {
|
|
61
98
|
manager: 'octave-pkg',
|
|
62
99
|
userArgv: ['<exe>', '--no-gui', '--quiet', '--eval', "pkg install -forge __PKG__"],
|
|
63
100
|
uninstallArgv: ['<exe>', '--no-gui', '--quiet', '--eval', 'pkg uninstall __PKG__'],
|
|
101
|
+
systemUnsupportedReason: 'Octave 的 pkg install 装进用户包目录;系统级要写 Octave 的 share/packages(需 root),本工具只出用户级计划',
|
|
64
102
|
},
|
|
65
103
|
userInstall: { windows: 'winget install --id GNU.Octave', macos: 'brew install octave', linux: 'apt install octave' },
|
|
66
104
|
},
|
|
@@ -76,6 +114,7 @@ export const MATH_ENGINES = {
|
|
|
76
114
|
manager: 'julia-pkg',
|
|
77
115
|
userArgv: ['<exe>', '-e', 'using Pkg; Pkg.add("__PKG__")'],
|
|
78
116
|
uninstallArgv: ['<exe>', '-e', 'using Pkg; Pkg.rm("__PKG__")'],
|
|
117
|
+
systemUnsupportedReason: 'Julia 的 Pkg.add 装进当前活动环境 / 用户 depot(JULIA_DEPOT_PATH);系统级不是 Julia 的概念,本工具只出用户级计划',
|
|
79
118
|
},
|
|
80
119
|
userInstall: { windows: 'winget install --id Julialang.Julia', macos: 'brew install julia', linux: 'apt install julia' },
|
|
81
120
|
},
|
|
@@ -84,7 +123,8 @@ export const MATH_ENGINES = {
|
|
|
84
123
|
candidates: ['matlab'],
|
|
85
124
|
versionArgv: ['-batch', 'disp(version)'], versionRe: '(\\d+\\.\\d+)',
|
|
86
125
|
scriptArgv: ['-batch', "run('<script>')"], evalArgv: ['-batch', '<expr>'], stdinArgv: null, ext: '.m',
|
|
87
|
-
|
|
126
|
+
// round-7 (live): no `|`/`%` in any probe argv (a real host rejected such argv with a null spawn).
|
|
127
|
+
probeCode: "t={'__QPKGS__'}; for i=1:numel(t); if license('test',t{i}); disp([t{i} ' ok']); else; disp([t{i} ' missing']); end; end",
|
|
88
128
|
packageProbe: { argv: ['-batch', '<probeCode>'], parse: 'pairs' },
|
|
89
129
|
license: 'commercial', argErrorHints: ARG_ERROR_HINTS,
|
|
90
130
|
licenseProbe: { argv: ['-batch', "disp(license('test','MATLAB'))"], okWhen: 'trim-1' },
|
|
@@ -96,7 +136,8 @@ export const MATH_ENGINES = {
|
|
|
96
136
|
candidates: ['maple'],
|
|
97
137
|
versionArgv: ['--version'], versionRe: '(\\d+\\.\\d+)',
|
|
98
138
|
scriptArgv: ['-q', '<script>'], evalArgv: ['-q', '-c', '<expr>'], stdinArgv: null, ext: '.mpl',
|
|
99
|
-
|
|
139
|
+
// round-7 (live): `print` instead of printf so the argv carries no `|`/`%`.
|
|
140
|
+
probeCode: 'for p in ["__PKGS__"] do try with(p) catch: print(p, " missing"); next end try; print(p, " ok") end do',
|
|
100
141
|
packageProbe: { argv: ['-q', '-c', '<probeCode>'], parse: 'pairs' },
|
|
101
142
|
license: 'commercial', argErrorHints: ARG_ERROR_HINTS,
|
|
102
143
|
licenseProbe: { argv: ['-q', '-c', 'printf("1")'], okWhen: 'exit-0' },
|
|
@@ -32,6 +32,8 @@ import {
|
|
|
32
32
|
MATH_RULE_LINES_EN,
|
|
33
33
|
MATH_ARCHIVE_WORKFLOW_LINE,
|
|
34
34
|
MATH_ARCHIVE_WORKFLOW_LINE_EN,
|
|
35
|
+
MATH_SUBSTITUTION_RULE_LINE,
|
|
36
|
+
MATH_SUBSTITUTION_RULE_LINE_EN,
|
|
35
37
|
MATH_PARAM_DEFAULTS,
|
|
36
38
|
MATH_PARAM_NAMES,
|
|
37
39
|
normalizeMathParams,
|
|
@@ -194,6 +196,11 @@ export function apply(ctx) {
|
|
|
194
196
|
// Same capability flag as the registered host: the prompt-side probe should not advertise
|
|
195
197
|
// engines on a host that cannot execute at all.
|
|
196
198
|
hasSubprocess: ()=>!!subprocessOf(),
|
|
199
|
+
// round-7 (fix 2): DSH's own bundled runtimes (`<home>/.dsh/dsh-runtimes/*/dependencies/<engine>/`)
|
|
200
|
+
// as a LAST resort after PATH. Generic roots only; the module globs the tree name (never
|
|
201
|
+
// `dsh-primary-runtime`) and accepts only the descriptor's own candidate names.
|
|
202
|
+
runtimeRoots: () => { const env = process.env.DSH_HOME; if (env) return [String(env)]; const home = String(process.env.HOME || process.env.USERPROFILE || ''); return home ? [home.replace(/[\\/]+$/, '') + '/.dsh'] : [] },
|
|
203
|
+
listDirAbs: async (abs)=>{ try { const t=await fsTarget(abs); const st=await fs.stat(t); if(!st) return []; return (await fs.listDir(t))||[] } catch(e){ return [] } },
|
|
197
204
|
log: (kind,msg)=>logActivity(String(kind||'math'),String(msg||'')),
|
|
198
205
|
refreshAvailability: ()=>refreshMathAvailability(),
|
|
199
206
|
}
|
|
@@ -1095,6 +1102,11 @@ export function apply(ctx) {
|
|
|
1095
1102
|
// both persona blocks by this preset — this is the drift check for the former.
|
|
1096
1103
|
if(mathAvailZh.indexOf(MATH_ARCHIVE_WORKFLOW_LINE.trim())===-1||mathAvailEn.indexOf(MATH_ARCHIVE_WORKFLOW_LINE_EN.trim())===-1){
|
|
1097
1104
|
logActivity('math','警告:mathAvailabilityLine 未附带归档工作流规则(MATH_ARCHIVE_WORKFLOW_LINE/_EN)')
|
|
1105
|
+
// round-6 A: substitution honesty is part of the same contract (an alternative that weakens
|
|
1106
|
+
// exactness must be declared). It is appended to the availability line by the module.
|
|
1107
|
+
if(mathAvailZh.indexOf(MATH_SUBSTITUTION_RULE_LINE.trim())===-1||mathAvailEn.indexOf(MATH_SUBSTITUTION_RULE_LINE_EN.trim())===-1){
|
|
1108
|
+
logActivity('math','警告:mathAvailabilityLine 未附带替代诚实性规则(MATH_SUBSTITUTION_RULE_LINE/_EN)')
|
|
1109
|
+
}
|
|
1098
1110
|
}
|
|
1099
1111
|
} catch(e){ /* a probe failure must never break a prompt; keep the last known line */ }
|
|
1100
1112
|
finally { mathAvailBusy=false }
|
|
@@ -3981,6 +3993,9 @@ export function apply(ctx) {
|
|
|
3981
3993
|
// audit-R2 lens-2: attached ONLY when the session surface really has it, so a surface without
|
|
3982
3994
|
// listDir reaches the module as an ABSENT field (the module's optional-callback contract).
|
|
3983
3995
|
...(typeof hostObj.listDir === 'function' ? { listDir: (rel)=>hostObj.listDir(rel) } : {}),
|
|
3996
|
+
// round-7 (fix 2): pass the bundled-runtime seam through to the per-session module instance.
|
|
3997
|
+
...(typeof hostObj.runtimeRoots === 'function' ? { runtimeRoots: ()=>hostObj.runtimeRoots() } : {}),
|
|
3998
|
+
...(typeof hostObj.listDirAbs === 'function' ? { listDirAbs: (abs)=>hostObj.listDirAbs(abs) } : {}),
|
|
3984
3999
|
resolveExecutable: (cmd)=>hostObj.resolveExecutable(cmd),
|
|
3985
4000
|
spawn: (o)=>hostObj.spawn(o),
|
|
3986
4001
|
// Optional capability flag: a host that KNOWS it has no subprocess service reports
|
|
@@ -104,6 +104,8 @@
|
|
|
104
104
|
- math_computation {op: probe|run|receipt|install, engine, mode: code|file|expr, …} — 先 probe 预检引擎/包/许可,再调引擎计算并把脚本与输出归档成可复核回执;缺引擎/缺包只报告与给安装指引/计划;shell 兜底不算归档。
|
|
105
105
|
- 归档→编辑→重跑:mode:'code' 的脚本原件在回执的 scriptPath(Computation/<id>/script.<ext>),你可以用普通文件工具打开并编辑它;编辑后用 mode:'file' 指向它重跑,会写出一份**新回执/新 attempt**(含新的 scriptHash)。**旧回执对修改后的代码无效**——报告里必须引用与当前代码哈希一致的那份回执;工具会在 scriptChanged / scriptChangedDuringRun 为 true 时显式告警。
|
|
106
106
|
- Archive -> edit -> re-run: for mode:'code' the script original is at the receipt's scriptPath (Computation/<id>/script.<ext>) and you may open/edit it with your normal file tools; after editing, re-run it with mode:'file' to write a NEW receipt/attempt with a NEW scriptHash. **An old receipt is NOT evidence for edited code** - cite the receipt whose scriptHash matches the current code; the tool warns explicitly via scriptChanged / scriptChangedDuringRun.
|
|
107
|
+
- 替代必须声明(诚实性):当替代方案改变了**精确性或结论强度**时(精确符号解 → 数值近似、闭式解 → 采样/求积、改了精度/容差/假设、换了算法类),结论里**必须写明**,不得读起来像得到了原本(精确/所要求的)结果;拿不到精确结果就直说。
|
|
108
|
+
- Declare substitutions (honesty): when an alternative changes EXACTNESS or conclusion strength (exact symbolic solution -> numerical approximation, closed form -> sampling/quadrature, changed precision/tolerances/assumptions, a different algorithm class), the conclusion MUST say so explicitly and must not read as if the original (exact/requested) result had been obtained; if the exact result is unavailable, say so plainly.
|
|
107
109
|
A /v5 slash command mirrors these (configure|start|resume|pause|stop|status|report|members|message|meeting|hire|fire|add|remove|set|paper).
|
|
108
110
|
|
|
109
111
|
LEAN FORMAL VERIFICATION (formalVerify, a tunable parameter):
|
|
@@ -218,6 +220,8 @@
|
|
|
218
220
|
- math_computation {op: probe|run|receipt|install, engine, mode: code|file|expr, …} — 先 probe 预检引擎/包/许可,再调引擎计算并把脚本与输出归档成可复核回执;缺引擎/缺包只报告与给安装指引/计划;shell 兜底不算归档。
|
|
219
221
|
- 归档→编辑→重跑:mode:'code' 的脚本原件在回执的 scriptPath(Computation/<id>/script.<ext>),你可以用普通文件工具打开并编辑它;编辑后用 mode:'file' 指向它重跑,会写出一份**新回执/新 attempt**(含新的 scriptHash)。**旧回执对修改后的代码无效**——报告里必须引用与当前代码哈希一致的那份回执;工具会在 scriptChanged / scriptChangedDuringRun 为 true 时显式告警。
|
|
220
222
|
- Archive -> edit -> re-run: for mode:'code' the script original is at the receipt's scriptPath (Computation/<id>/script.<ext>) and you may open/edit it with your normal file tools; after editing, re-run it with mode:'file' to write a NEW receipt/attempt with a NEW scriptHash. **An old receipt is NOT evidence for edited code** - cite the receipt whose scriptHash matches the current code; the tool warns explicitly via scriptChanged / scriptChangedDuringRun.
|
|
223
|
+
- 替代必须声明(诚实性):当替代方案改变了**精确性或结论强度**时(精确符号解 → 数值近似、闭式解 → 采样/求积、改了精度/容差/假设、换了算法类),结论里**必须写明**,不得读起来像得到了原本(精确/所要求的)结果;拿不到精确结果就直说。
|
|
224
|
+
- Declare substitutions (honesty): when an alternative changes EXACTNESS or conclusion strength (exact symbolic solution -> numerical approximation, closed form -> sampling/quadrature, changed precision/tolerances/assumptions, a different algorithm class), the conclusion MUST say so explicitly and must not read as if the original (exact/requested) result had been obtained; if the exact result is unavailable, say so plainly.
|
|
221
225
|
A /v5 slash command mirrors these (configure|start|resume|pause|stop|status|report|members|message|meeting|hire|fire|add|remove|set|paper).
|
|
222
226
|
|
|
223
227
|
LEAN FORMAL VERIFICATION (formalVerify, a tunable parameter):
|