dsh-decision-layer 0.5.3 → 0.5.4
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 +2 -2
- package/README.md +2 -2
- package/lib/client.js +40 -16
- package/package.json +1 -1
- package/service/self-check.mjs +4 -0
- package/service/session-state.mjs +1 -0
package/README.en.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`dsh-decision-layer` adds structured, explicitly scoped decisions to the DeepSeek Harness (DSH) agent loop, backed by a pluggable adjudication backend. Dangerous-call gating, output self-check, tool narrowing, and loop prevention hook into the agent loop as automatic interventions.
|
|
6
6
|
|
|
7
|
-
> **0.5.
|
|
7
|
+
> **0.5.4 is a preview release.** The plugin works, but how much real value the adjudication interventions add is still being explored — every threshold is an unvalidated heuristic default. Treat it as something to observe, not a proven guarantee of impact. See [ROADMAP.md](<ROADMAP.md>) for scope and progress.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -49,4 +49,4 @@ Restart `dsh web` and refresh after installing or updating: the host and client
|
|
|
49
49
|
|
|
50
50
|
## Safety boundary and development
|
|
51
51
|
|
|
52
|
-
Automatic intervention only subtracts: the gate only denies, narrowing only removes tools, and neither grants new permissions. The gate defers to native DSH approval on backend failure rather than allowing; self-check, narrowing, and loop-guard errors skip intervention. The redacted summary sent to the backend carries only tool name and command/path with secret redaction — never file content. Node.js `>=20.11`; `npm test` and `npm run build:client` run local checks. Rebuild and commit `lib/client.js` with any client change. 0.5.
|
|
52
|
+
Automatic intervention only subtracts: the gate only denies, narrowing only removes tools, and neither grants new permissions. The gate defers to native DSH approval on backend failure rather than allowing; self-check, narrowing, and loop-guard errors skip intervention. The redacted summary sent to the backend carries only tool name and command/path with secret redaction — never file content. Node.js `>=20.11`; `npm test` and `npm run build:client` run local checks. Rebuild and commit `lib/client.js` with any client change. 0.5.4 is a preview: the interventions work, but their real value and thresholds are still being explored — feedback on misjudgments and feel observed in the decision log is welcome.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
DeepSeek Harness(DSH)的结构化裁决插件。它把有明确判断标准的问题交给同协议的裁决后端,供 agent 在需要时使用,并在 agent loop 上接入危险门控、产出自检、工具收窄和防循环等自动介入。
|
|
6
6
|
|
|
7
|
-
> **0.5.
|
|
7
|
+
> **0.5.4 是体验版。** 插件功能已可用,但裁决介入能带来多少实际价值仍在探索中——各决策点的阈值都是未经验证的启发式默认值,建议先以观察心态体验,别当成经过验证的效果保证。功能与后续进度以 [ROADMAP.md](<ROADMAP.md>) 为准。
|
|
8
8
|
|
|
9
9
|
## 安装
|
|
10
10
|
|
|
@@ -53,4 +53,4 @@ dsh plugin --profile web add file:/绝对路径/dsh-decision-layer
|
|
|
53
53
|
|
|
54
54
|
## 开发
|
|
55
55
|
|
|
56
|
-
服务端使用 Node.js `>=20.11`(`.mjs`,无需构建);客户端用 TypeScript + esbuild 构建。`npm test` 跑本地测试,`npm run build:client` 生成 `lib/client.js`。改动客户端后需重建并连同 `lib/client.js` 一起提交,否则 GitHub 安装拿到的是旧 bundle。0.5.
|
|
56
|
+
服务端使用 Node.js `>=20.11`(`.mjs`,无需构建);客户端用 TypeScript + esbuild 构建。`npm test` 跑本地测试,`npm run build:client` 生成 `lib/client.js`。改动客户端后需重建并连同 `lib/client.js` 一起提交,否则 GitHub 安装拿到的是旧 bundle。0.5.4 为体验版:介入能力已可用,但实际价值与阈值仍在探索,欢迎反馈决策日志观察到的误判与体感。
|
package/lib/client.js
CHANGED
|
@@ -96,6 +96,9 @@ var dictionaries = {
|
|
|
96
96
|
gatePassThrough: "\u672A\u5E72\u9884\uFF08\u6309\u539F\u8DEF\u5F84\u6267\u884C\uFF09",
|
|
97
97
|
checkResultLow: "\u5F97\u5206\u504F\u4F4E",
|
|
98
98
|
checkResultOk: "\u901A\u8FC7",
|
|
99
|
+
checkResultLowNoisy: "\u5F97\u5206\u504F\u4F4E\uFF08\u4F4E\u7F6E\u4FE1\uFF09",
|
|
100
|
+
checkNoiseTag: "\u566A\u58F0\uFF0C\u53EF\u5FFD\u7565",
|
|
101
|
+
checkNoiseHint: "\u6A21\u578B\u5BF9\u8FD9\u6B21\u6253\u5206\u51E0\u4E4E\u6CA1\u6709\u628A\u63E1\uFF08\u7F6E\u4FE1\u5EA6\u6781\u4F4E\uFF09\uFF0C\u8FD9\u6761\u4F4E\u5206\u4E0D\u8BA1\u5165\u8D28\u91CF\u8D8B\u52BF\u3001\u4E5F\u4E0D\u89E6\u53D1\u4EFB\u4F55\u8865\u5B8C\uFF0C\u89C6\u4F5C\u566A\u58F0\u5FFD\u7565\u5373\u53EF\u3002\u771F\u6B63\u503C\u5F97\u5173\u6CE8\u7684\u662F\u8FDE\u7EED\u591A\u6B21\u9AD8\u7F6E\u4FE1\u7684\u4F4E\u5206\u3002",
|
|
99
102
|
reasonUnavailable: "\u540E\u7AEF\u4E0D\u53EF\u8FBE",
|
|
100
103
|
reasonHttpError: "\u540E\u7AEF\u8FD4\u56DE\u9519\u8BEF",
|
|
101
104
|
reasonInvalidResponse: "\u54CD\u5E94\u683C\u5F0F\u4E0D\u7B26",
|
|
@@ -245,6 +248,9 @@ var dictionaries = {
|
|
|
245
248
|
gatePassThrough: "no intervention (proceeded on its original path)",
|
|
246
249
|
checkResultLow: "low score",
|
|
247
250
|
checkResultOk: "passed",
|
|
251
|
+
checkResultLowNoisy: "low score (low confidence)",
|
|
252
|
+
checkNoiseTag: "noise, ignore",
|
|
253
|
+
checkNoiseHint: "The model had almost no confidence in this score (near-zero confidence). This low score does not count toward the quality trend and triggers no re-prompt \u2014 treat it as noise. What matters is several consecutive high-confidence low scores.",
|
|
248
254
|
reasonUnavailable: "backend unreachable",
|
|
249
255
|
reasonHttpError: "backend returned an error",
|
|
250
256
|
reasonInvalidResponse: "unexpected response shape",
|
|
@@ -422,24 +428,33 @@ function renderCheck({ t }, entry) {
|
|
|
422
428
|
entry.reason ? ` \xB7 ${failDetail(t, entry)}` : ""
|
|
423
429
|
] })
|
|
424
430
|
] });
|
|
425
|
-
const
|
|
431
|
+
const noisy = entry.outcome === "low" && entry.lowConfidence === true;
|
|
432
|
+
const result = entry.outcome === "low" ? noisy ? t("checkResultLowNoisy") : t("checkResultLow") : t("checkResultOk");
|
|
433
|
+
const verdict = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: noisy ? "decision-log-muted-verdict" : "decision-log-verdict", children: result });
|
|
434
|
+
const score = entry.score !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "decision-log-detail", title: t("logScoreHint"), children: [
|
|
435
|
+
" \xB7 ",
|
|
436
|
+
t("logScore"),
|
|
437
|
+
" ",
|
|
438
|
+
entry.score,
|
|
439
|
+
"/2"
|
|
440
|
+
] }) : null;
|
|
441
|
+
const conf = typeof entry.confidence === "number" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "decision-log-detail", children: [
|
|
442
|
+
" \xB7 ",
|
|
443
|
+
t("logConfidence"),
|
|
444
|
+
" ",
|
|
445
|
+
entry.confidence
|
|
446
|
+
] }) : null;
|
|
447
|
+
const hint = noisy ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "decision-log-detail", title: t("checkNoiseHint"), children: [
|
|
448
|
+
" \xB7 ",
|
|
449
|
+
t("checkNoiseTag")
|
|
450
|
+
] }) : null;
|
|
426
451
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
427
452
|
label,
|
|
428
453
|
" \xB7 ",
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
" ",
|
|
434
|
-
entry.score,
|
|
435
|
-
"/2"
|
|
436
|
-
] }) : null,
|
|
437
|
-
typeof entry.confidence === "number" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "decision-log-detail", children: [
|
|
438
|
-
" \xB7 ",
|
|
439
|
-
t("logConfidence"),
|
|
440
|
-
" ",
|
|
441
|
-
entry.confidence
|
|
442
|
-
] }) : null
|
|
454
|
+
verdict,
|
|
455
|
+
score,
|
|
456
|
+
conf,
|
|
457
|
+
hint
|
|
443
458
|
] });
|
|
444
459
|
}
|
|
445
460
|
function renderNarrow({ t }, entry) {
|
|
@@ -538,7 +553,10 @@ function renderComplete({ t }, entry) {
|
|
|
538
553
|
function outcomeTagOf(entry) {
|
|
539
554
|
if (entry.kind === "narrow") return entry.outcome === "error" ? "error" : "ok";
|
|
540
555
|
if (entry.kind === "complete") return entry.outcome === "error" ? "error" : entry.outcome === "unsatisfied" ? "warn" : "ok";
|
|
541
|
-
|
|
556
|
+
if (entry.outcome === "deny") return "deny";
|
|
557
|
+
if (entry.outcome === "error") return "error";
|
|
558
|
+
if (entry.outcome === "low") return entry.kind === "check" && entry.lowConfidence === true ? "muted" : "warn";
|
|
559
|
+
return "ok";
|
|
542
560
|
}
|
|
543
561
|
function renderBody(props, entry) {
|
|
544
562
|
return entry.kind === "gate" ? renderGate(props, entry) : entry.kind === "narrow" ? renderNarrow(props, entry) : entry.kind === "complete" ? renderComplete(props, entry) : renderCheck(props, entry);
|
|
@@ -1538,6 +1556,7 @@ var css = `
|
|
|
1538
1556
|
.decision-log-item.decision-log-deny{border-left-color:#c0392b}
|
|
1539
1557
|
.decision-log-item.decision-log-error,.decision-log-item.decision-log-warn{border-left-color:#c98a1e}
|
|
1540
1558
|
.decision-log-item.decision-log-ok{border-left-color:#1f8a70}
|
|
1559
|
+
.decision-log-item.decision-log-muted{border-left-color:var(--dsw-alias-border-l2,#dce1e6)}
|
|
1541
1560
|
.decision-log-time{color:var(--dsw-alias-label-tertiary,#77818b);font-variant-numeric:tabular-nums;flex:0 0 auto}
|
|
1542
1561
|
.decision-log-body{color:var(--dsw-alias-label-primary,#202124);flex:1 1 auto;min-width:0}
|
|
1543
1562
|
.decision-rate{flex:0 0 auto;display:inline-flex;gap:1px;align-self:center}
|
|
@@ -1554,6 +1573,11 @@ var css = `
|
|
|
1554
1573
|
.decision-log-ok .decision-log-verdict{color:#1f8a70}
|
|
1555
1574
|
.decision-log-warn .decision-log-verdict{color:#c98a1e}
|
|
1556
1575
|
.decision-log-detail{color:var(--dsw-alias-label-secondary,#59636e)}
|
|
1576
|
+
/* A low-confidence low score is noise: its verdict is shown muted (not the amber
|
|
1577
|
+
warn accent) and a "noise, ignore" tag hangs off the row so it never reads as a
|
|
1578
|
+
real quality dip. */
|
|
1579
|
+
.decision-log-muted-verdict{font-weight:600;color:var(--dsw-alias-label-tertiary,#9aa5b1)}
|
|
1580
|
+
.decision-log-muted .decision-log-time{opacity:.75}
|
|
1557
1581
|
|
|
1558
1582
|
.decision-status{display:flex;align-items:center;gap:.5rem;margin-top:.7rem;font-size:.82rem}
|
|
1559
1583
|
.decision-status-dot{width:8px;height:8px;border-radius:50%;flex:0 0 auto;background:#9aa5b1}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-decision-layer",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "A structured decision layer for the DeepSeek Harness agent loop: a danger-call gate, output self-check, tool narrowing, and loop guard backed by a pluggable adjudication model.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
package/service/self-check.mjs
CHANGED
|
@@ -80,6 +80,10 @@ export function createSelfCheck({ evaluate, sessions, steer, settings, minConfid
|
|
|
80
80
|
// The trend run advances over every evaluated score; a high-confidence low
|
|
81
81
|
// score is the only thing that grows it. Thresholds flow to session-state.
|
|
82
82
|
const trend = { confident: lowScore && confidence !== undefined && confidence >= trendMinConfidence, trendRun, trendSevereRun };
|
|
83
|
+
// A low score the model is not confident about (confidence present but below
|
|
84
|
+
// the trend threshold) does not advance the quality-trend judgment. Flag it
|
|
85
|
+
// so the decision log can mark it as low-signal noise instead of a real dip.
|
|
86
|
+
if (lowScore && confidence !== undefined && !trend.confident) detail.lowConfidence = true;
|
|
83
87
|
record(turn, lowScore ? 'low' : 'ok', { score: answer.score, ...detail }, trend);
|
|
84
88
|
if (!lowScore) return { evaluated: true, lowScore: false, steered: false, score: answer.score };
|
|
85
89
|
const confident = confidence !== undefined && confidence >= minConfidence;
|
|
@@ -131,6 +131,7 @@ export function createSessionState({ maxSessions = 1024, maxLogEntries = 50, onL
|
|
|
131
131
|
if (Number.isSafeInteger(entry.unsatisfied) && entry.unsatisfied >= 0) record.unsatisfied = entry.unsatisfied;
|
|
132
132
|
if (Number.isSafeInteger(entry.insufficient) && entry.insufficient >= 0) record.insufficient = entry.insufficient;
|
|
133
133
|
if (entry.steered === true) record.steered = true;
|
|
134
|
+
if (entry.lowConfidence === true) record.lowConfidence = true;
|
|
134
135
|
if (Array.isArray(entry.tools)) {
|
|
135
136
|
const names = entry.tools.filter(name => typeof name === 'string' && name.trim()).slice(0, 12).map(name => name.trim().slice(0, 64));
|
|
136
137
|
if (names.length > 0) record.tools = names;
|