ld-vibe-harness 0.2.0 → 0.3.0
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/.claude-plugin/plugin.json +2 -2
- package/.codex-plugin/plugin.json +4 -4
- package/CHANGELOG.md +32 -0
- package/README.en.md +13 -12
- package/README.md +20 -20
- package/adapters/antigravity/installer.js +26 -8
- package/adapters/dsh/index.js +0 -3
- package/adapters/dsh/package.json +2 -2
- package/agents/ldvh-experience-recorder.md +2 -3
- package/agents/ldvh-post-work-reviewer.md +0 -1
- package/agents/ldvh-pre-action-reviewer.md +0 -1
- package/agents/ldvh-researcher.md +1 -2
- package/cli/ldvh.mjs +137 -5
- package/docs/ARCHITECTURE.md +37 -37
- package/docs/PRIVACY.md +7 -6
- package/hooks/_client.mjs +1 -12
- package/hooks/hook-engine.js +684 -84
- package/lib/capture-notice.js +8 -22
- package/lib/commit-validation.js +0 -59
- package/lib/data-paths.js +0 -1
- package/lib/experience-arming.js +10 -4
- package/lib/gate-events.js +27 -2
- package/lib/git-gate-runner.js +83 -34
- package/lib/goal-anchor.js +17 -45
- package/lib/goal-tools.js +4 -26
- package/lib/goal-writer.js +5 -18
- package/lib/governed-projects.js +18 -7
- package/lib/guidance-budget.js +2 -2
- package/lib/guidance-text.js +7 -7
- package/lib/hook-manager.js +40 -14
- package/lib/hook-repair.js +77 -13
- package/lib/host-api.js +7 -3
- package/lib/host-seams.js +78 -57
- package/lib/idle-settings.js +1 -4
- package/lib/intent-tools.js +6 -14
- package/lib/intent-writer.js +12 -45
- package/lib/ldvh-tools.js +26 -61
- package/lib/object-identifier.js +0 -2
- package/lib/object-reference.js +0 -2
- package/lib/operation-declarations.bundle.json +1 -64
- package/lib/recall-criteria.bundle.json +2 -67
- package/lib/recall-criteria.js +0 -2
- package/lib/recall-injection.js +1 -5
- package/lib/recall-synonyms.js +1 -3
- package/lib/research-consult-tools.js +201 -19
- package/lib/research-consult.js +49 -27
- package/lib/review-ask-tool.js +75 -11
- package/lib/review-ask.js +12 -9
- package/lib/source-recall.js +6 -16
- package/lib/web-preferences.js +2 -2
- package/package.json +2 -2
- package/plugin-specs/experience-accumulation-system-foundation.yaml +5 -25
- package/plugin-specs/fact-model-common.yaml +3 -14
- package/plugin-specs/gate-consult-system-foundation.yaml +39 -29
- package/plugin-specs/goal-fact-type.yaml +20 -67
- package/plugin-specs/goal-planning-system-foundation.yaml +27 -98
- package/plugin-specs/intent-fact-type.yaml +13 -22
- package/plugin-specs/intent-record-system-foundation.yaml +1 -2
- package/plugin-specs/ldvh-root.yaml +6 -6
- package/plugin-specs/norm-fact-type.yaml +1 -1
- package/plugin-specs/pitfall-fact-type.yaml +5 -49
- package/plugin-specs/report-fact-type.yaml +1 -1
- package/plugin-specs/research-system-foundation.yaml +12 -9
- package/plugin.json +4 -4
- package/rules/AGENTS.md +3 -3
- package/server/local-daemon.js +86 -28
- package/server/mcp-server.js +211 -53
- package/server/tool-registry.js +0 -23
- package/skills/ldvh-governance-flow/SKILL.md +10 -19
- package/skills/ldvh-onboarding/SKILL.md +2 -2
- package/agents/ldvh-friction-recorder.md +0 -27
- package/lib/aux-task-registry.js +0 -129
- package/lib/friction-discovery.js +0 -383
- package/lib/friction-failure-registration.js +0 -56
- package/lib/friction-observation-buffer.js +0 -889
- package/lib/friction-promotion-lock.js +0 -124
- package/lib/friction-review-promotion.js +0 -193
- package/lib/friction-tools.js +0 -829
- package/lib/friction-writer.js +0 -1123
- package/lib/milestone-tools.js +0 -684
- package/lib/milestone-writer.js +0 -707
- package/lib/verification-run.js +0 -195
- package/plugin-specs/friction-fact-type.yaml +0 -333
- package/plugin-specs/friction-settlement-system-foundation.yaml +0 -334
- package/plugin-specs/milestone-fact-type.yaml +0 -212
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
import { defineTool } from "./define-tool.js";
|
|
3
3
|
import { toParameterSpec } from "./parameter-spec-adapter.js";
|
|
4
4
|
import { resolveGovernanceScope } from "./governance-scope.js";
|
|
5
|
+
import { REVIEW_ASK_ANSWERS, REVIEW_ASK_POINTS } from "./review-ask.js";
|
|
5
6
|
import {
|
|
6
7
|
CONSULT_ANSWERS,
|
|
8
|
+
CONSULT_POINT,
|
|
7
9
|
INTERNAL_LOOKUP_LIMIT,
|
|
8
10
|
RESEARCH_OPERATION_SUMMARY,
|
|
11
|
+
buildResearchFingerprintTask,
|
|
9
12
|
classifyInternalHits,
|
|
10
13
|
internalHitLines,
|
|
11
14
|
internalLookup,
|
|
@@ -38,9 +41,15 @@ function invalidRequest(operationKey, gap, requested) {
|
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
function unavailable(operationKey, gaps, requested) {
|
|
44
|
+
function unavailable(operationKey, gaps, requested, switchEnabled = null) {
|
|
42
45
|
return envelope(operationKey, "unavailable", {
|
|
43
|
-
result: {
|
|
46
|
+
result: {
|
|
47
|
+
point: CONSULT_POINT,
|
|
48
|
+
decision: null,
|
|
49
|
+
asked: false,
|
|
50
|
+
switch_enabled: switchEnabled,
|
|
51
|
+
human_requested: false,
|
|
52
|
+
},
|
|
44
53
|
scope: { requested: requested ?? operationKey, completed: [], not_completed: [requested ?? operationKey] },
|
|
45
54
|
sources: [],
|
|
46
55
|
gaps,
|
|
@@ -70,16 +79,39 @@ function renderEnvelope(operationKey, value) {
|
|
|
70
79
|
const env = value?.envelope ?? {};
|
|
71
80
|
const lines = [`LDVH ${env.operation_key ?? operationKey}: ${env.outcome ?? "unknown"}`];
|
|
72
81
|
const result = env.result;
|
|
82
|
+
if (result?.point !== undefined) lines.push(`point: ${result.point}`);
|
|
83
|
+
if (result?.human_requested === true) lines.push("human_requested: true");
|
|
84
|
+
if (result?.switch_enabled !== undefined) lines.push(`switch_enabled: ${result.switch_enabled}`);
|
|
73
85
|
if (result?.internal_found !== undefined) lines.push(`internal_found: ${result.internal_found}`);
|
|
74
86
|
if (result?.internal_hit_count !== undefined) lines.push(`internal_hits: ${result.internal_hit_count}`);
|
|
75
87
|
if (result?.internal_weak_hit_count !== undefined) lines.push(`internal_weak_hits: ${result.internal_weak_hit_count}`);
|
|
76
88
|
if (result?.internal_source_read !== undefined) lines.push(`internal_source_read: ${result.internal_source_read}`);
|
|
77
89
|
if (result?.decision !== undefined) lines.push(`decision: ${result.decision ?? "null"}`);
|
|
78
90
|
if (result?.asked !== undefined) lines.push(`asked: ${result.asked}`);
|
|
91
|
+
if (result?.reused === true) lines.push("reused: true");
|
|
92
|
+
if (result?.fingerprint !== undefined) lines.push(`fingerprint: ${result.fingerprint}`);
|
|
93
|
+
if (typeof result?.custom_note === "string" && result.custom_note.length > 0) {
|
|
94
|
+
lines.push(`custom_note: ${result.custom_note}`);
|
|
95
|
+
}
|
|
79
96
|
if (result?.need !== undefined) lines.push(`need: ${result.need}`);
|
|
97
|
+
if (result?.needs_ask_question === true && typeof result?.question === "string") {
|
|
98
|
+
lines.push("needs_ask_question: true");
|
|
99
|
+
lines.push(`question: ${result.question}`);
|
|
100
|
+
if (Array.isArray(result.options) && result.options.length > 0) {
|
|
101
|
+
lines.push(`options: ${result.options.join(" / ")}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
80
104
|
if (Array.isArray(result?.internal_hits)) {
|
|
81
105
|
for (const line of internalHitLines(result.internal_hits)) lines.push(`- ${line}`);
|
|
82
106
|
}
|
|
107
|
+
const tpl = result?.research_template;
|
|
108
|
+
if (tpl !== undefined && tpl !== null && typeof tpl === "object") {
|
|
109
|
+
if (typeof tpl.kind === "string") lines.push(`research_template.kind: ${tpl.kind}`);
|
|
110
|
+
if (typeof tpl.prompt === "string" && tpl.prompt.length > 0) {
|
|
111
|
+
lines.push("research_template.prompt: |");
|
|
112
|
+
for (const line of tpl.prompt.split("\n")) lines.push(` ${line}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
83
115
|
for (const gap of env.gaps ?? []) lines.push(`gap: ${typeof gap === "string" ? gap : JSON.stringify(gap)}`);
|
|
84
116
|
for (const next of env.follow_up ?? []) lines.push(`follow_up: ${typeof next === "string" ? next : JSON.stringify(next)}`);
|
|
85
117
|
return text(lines.join("\n"));
|
|
@@ -102,11 +134,11 @@ function parameterSchema() {
|
|
|
102
134
|
},
|
|
103
135
|
scope: {
|
|
104
136
|
type: "string",
|
|
105
|
-
description: "
|
|
137
|
+
description: "范围限定(时间、版本、适用场景),会进入提请题面与内容指纹"
|
|
106
138
|
},
|
|
107
139
|
purpose: {
|
|
108
140
|
type: "string",
|
|
109
|
-
description: "
|
|
141
|
+
description: "这次查证服务于哪个判断(会进入提请题面、内容指纹与主控调研执行指引)"
|
|
110
142
|
},
|
|
111
143
|
sub_questions: {
|
|
112
144
|
type: "array",
|
|
@@ -115,7 +147,16 @@ function parameterSchema() {
|
|
|
115
147
|
},
|
|
116
148
|
internal_gap: {
|
|
117
149
|
type: "string",
|
|
118
|
-
description: "「内部已有 X 仍缺 Y
|
|
150
|
+
description: "「内部已有 X 仍缺 Y」的说明。提供它表示主控判定内部结论不足以回答本次需要,即使内部有强命中也继续走提请(或人主动要求时直接进入调研)"
|
|
151
|
+
},
|
|
152
|
+
human_requested: {
|
|
153
|
+
type: "boolean",
|
|
154
|
+
description: "本次联网调查是否由 Human 主动提出(true=人主动要求,不受第三处开关限制,先查内部避免重复后免请示直接返回主控调研执行指引;与 record_decision 互斥)"
|
|
155
|
+
},
|
|
156
|
+
record_decision: {
|
|
157
|
+
type: "string",
|
|
158
|
+
enum: ["research", "skip"],
|
|
159
|
+
description: "Human 已通过 ask_question 明确作答后,据实传入其选择(research=联网调查 / skip=不调查),用于显式留痕;不得在 Human 未作答时自行填写,且与 human_requested=true 互斥"
|
|
119
160
|
},
|
|
120
161
|
limit: {
|
|
121
162
|
type: "number",
|
|
@@ -127,13 +168,15 @@ function parameterSchema() {
|
|
|
127
168
|
};
|
|
128
169
|
}
|
|
129
170
|
|
|
130
|
-
function internalFoundEnvelope(args, lookup, classified) {
|
|
171
|
+
function internalFoundEnvelope(args, lookup, classified, { humanRequested = false } = {}) {
|
|
131
172
|
const hits = classified.strong;
|
|
132
173
|
const weak = classified.weak;
|
|
133
174
|
const followUp = [
|
|
134
175
|
"先按 object_uid 精确读这些内部对象再判断是否够用;命中是候选不是结论,适用性由你判(02 §9.2)",
|
|
135
176
|
"命中可能全是**词面碰撞**:逐条看命中词(写在 match_reason 里)是否真的与本次问题相关——「强命中」只说明词面稀有度,不代表语义相关;机械层判不了相关性",
|
|
136
|
-
|
|
177
|
+
humanRequested
|
|
178
|
+
? "若精读后仍不足以回答 Human 要求的调研问题,带 internal_gap 参数并保持 human_requested: true 再次调用本工具,将免重复请示直接进入主控调研工序"
|
|
179
|
+
: "内部结论不足以回答本次需要时,带 internal_gap 参数再次调用本工具(写明「内部已有 X 仍缺 Y」),本工具会据此继续提请联网",
|
|
137
180
|
INTERNAL_READING_LINE,
|
|
138
181
|
weak.length > 0
|
|
139
182
|
? `另有 ${weak.length} 条弱命中(通用词/单字碰撞),不构成可用结论`
|
|
@@ -144,7 +187,10 @@ function internalFoundEnvelope(args, lookup, classified) {
|
|
|
144
187
|
].filter((line) => line !== "");
|
|
145
188
|
return envelope("research-consult", "completed", {
|
|
146
189
|
result: {
|
|
190
|
+
point: CONSULT_POINT,
|
|
147
191
|
need: trimmed(args?.need),
|
|
192
|
+
human_requested: humanRequested,
|
|
193
|
+
switch_enabled: null,
|
|
148
194
|
internal_found: true,
|
|
149
195
|
internal_hit_count: hits.length,
|
|
150
196
|
internal_hits: hits,
|
|
@@ -163,19 +209,75 @@ function internalFoundEnvelope(args, lookup, classified) {
|
|
|
163
209
|
});
|
|
164
210
|
}
|
|
165
211
|
|
|
212
|
+
function humanRequestedEnvelope(args, lookup, classified, escalation) {
|
|
213
|
+
const sourceUnread = lookup.source_read === false;
|
|
214
|
+
const gaps = [...lookup.gaps];
|
|
215
|
+
if (sourceUnread) {
|
|
216
|
+
gaps.push("内部事实源不可读:本次**未检查**内部事实源——这不是「未命中」,交付说明不得这样写");
|
|
217
|
+
}
|
|
218
|
+
const escalationLine = escalation === "internal-gap"
|
|
219
|
+
? "本次绕过强命中进入调研的理由是声明了内部缺口(internal_gap),须在交付说明里一并写出「内部已有 X 仍缺 Y」"
|
|
220
|
+
: (escalation === "weak-only"
|
|
221
|
+
? "内部只有弱命中,不构成可用结论;按 Human 主动要求免请示直接进入主控调研工序"
|
|
222
|
+
: "内部未命中(按机制查过);按 Human 主动要求免请示直接进入主控调研工序");
|
|
223
|
+
return envelope("research-consult", sourceUnread ? "partial" : "completed", {
|
|
224
|
+
result: {
|
|
225
|
+
point: CONSULT_POINT,
|
|
226
|
+
need: trimmed(args?.need),
|
|
227
|
+
human_requested: true,
|
|
228
|
+
switch_enabled: null,
|
|
229
|
+
internal_found: classified.usable,
|
|
230
|
+
internal_hit_count: classified.strong.length,
|
|
231
|
+
internal_hits: classified.strong,
|
|
232
|
+
internal_weak_hit_count: classified.weak.length,
|
|
233
|
+
internal_source_read: lookup.source_read,
|
|
234
|
+
internal_completeness: lookup.completeness,
|
|
235
|
+
asked: false,
|
|
236
|
+
decision: CONSULT_ANSWERS.RESEARCH,
|
|
237
|
+
consult_required: true,
|
|
238
|
+
research_template: researchDispatchTemplate({
|
|
239
|
+
need: args?.need,
|
|
240
|
+
purpose: args?.purpose,
|
|
241
|
+
scope: args?.scope,
|
|
242
|
+
subQuestions: args?.sub_questions,
|
|
243
|
+
keywords: args?.keywords
|
|
244
|
+
})
|
|
245
|
+
},
|
|
246
|
+
scope: {
|
|
247
|
+
requested: "human-requested-research",
|
|
248
|
+
completed: ["internal-lookup"],
|
|
249
|
+
not_completed: sourceUnread ? ["internal-lookup"] : []
|
|
250
|
+
},
|
|
251
|
+
sources: [{ kind: "fact-source", path: "ldvh-base" }],
|
|
252
|
+
gaps,
|
|
253
|
+
verification: { checks: ["internal-lookup", "governance-scope", "human-requested-bypass"], passed: !sourceUnread },
|
|
254
|
+
follow_up: [
|
|
255
|
+
"Human 主动要求联网调查(已先查内部,免重复请示):由**主控亲自执行完整调研工序**(按 research_template 检索取证、整理三态证据与逐字引证、做收敛判定),以保证工序完整",
|
|
256
|
+
"若结论需跨会话复用或落盘:按 `ldvh_report_session`(create -> submit-round -> audit-citation -> check-delivery -> finalize)走完 33 号机器,再用 `ldvh_report_write` 创建 `report_form=\"research\"` 的报告并做写后回读",
|
|
257
|
+
"仅在需要拆分局部、有界的外部检索子任务时,才按需可选委派 `ldvh-researcher` 辅助取证,整体结论与交付仍由主控负最终责任",
|
|
258
|
+
INTERNAL_READING_LINE,
|
|
259
|
+
escalationLine
|
|
260
|
+
]
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
166
264
|
function consultEnvelope(args, lookup, classified, outcome, escalation) {
|
|
167
265
|
const decision = outcome?.decision ?? null;
|
|
168
266
|
const asked = outcome?.asked === true;
|
|
267
|
+
const needsAskQuestion = decision === null && outcome?.needs_ask_question === true;
|
|
169
268
|
const sourceUnread = lookup.source_read === false;
|
|
170
269
|
const gaps = [...lookup.gaps];
|
|
171
270
|
if (sourceUnread) {
|
|
172
271
|
gaps.push("内部事实源不可读:本次**未检查**内部事实源——这不是「未命中」,交付说明不得这样写");
|
|
173
272
|
}
|
|
174
273
|
if (outcome?.recordError !== undefined) gaps.push(`答复未能留痕(${outcome.recordError})——重试会再次提问`);
|
|
175
|
-
if (outcome?.reason !== undefined && decision === null) gaps.push(outcome.reason);
|
|
274
|
+
if (outcome?.reason !== undefined && decision === null && !needsAskQuestion) gaps.push(outcome.reason);
|
|
176
275
|
const outcomeKind = sourceUnread ? "partial" : (decision === null ? "partial" : "completed");
|
|
177
276
|
const commonResult = {
|
|
277
|
+
point: CONSULT_POINT,
|
|
178
278
|
need: trimmed(args?.need),
|
|
279
|
+
human_requested: false,
|
|
280
|
+
switch_enabled: true,
|
|
179
281
|
internal_found: classified.usable,
|
|
180
282
|
internal_hit_count: classified.strong.length,
|
|
181
283
|
internal_hits: classified.strong,
|
|
@@ -184,9 +286,12 @@ function consultEnvelope(args, lookup, classified, outcome, escalation) {
|
|
|
184
286
|
internal_completeness: lookup.completeness,
|
|
185
287
|
asked,
|
|
186
288
|
decision,
|
|
289
|
+
reused: outcome?.reused === true,
|
|
187
290
|
consult_required: decision === CONSULT_ANSWERS.RESEARCH,
|
|
188
|
-
...(outcome?.
|
|
189
|
-
|
|
291
|
+
...(outcome?.fingerprint === undefined ? {} : { fingerprint: outcome.fingerprint }),
|
|
292
|
+
...(outcome?.at === undefined ? {} : { recorded_at: outcome.at }),
|
|
293
|
+
...(needsAskQuestion
|
|
294
|
+
? { needs_ask_question: true, question: outcome.question, options: outcome.options }
|
|
190
295
|
: {}),
|
|
191
296
|
...(outcome?.custom_note === undefined ? {} : { custom_note: outcome.custom_note })
|
|
192
297
|
};
|
|
@@ -215,10 +320,10 @@ function consultEnvelope(args, lookup, classified, outcome, escalation) {
|
|
|
215
320
|
gaps,
|
|
216
321
|
verification: { checks: ["internal-lookup", "governance-scope", "answer-distinguishable"], passed: !sourceUnread },
|
|
217
322
|
follow_up: [
|
|
218
|
-
"
|
|
219
|
-
"
|
|
220
|
-
"
|
|
221
|
-
"
|
|
323
|
+
"Human 已同意联网调查:由**主控亲自执行完整调研工序**(按 research_template 检索取证、整理三态证据与逐字引证、做收敛判定),以保证工序完整",
|
|
324
|
+
"若结论需跨会话复用或落盘:用 `ldvh_report_session`(create -> submit-round -> audit-citation -> check-delivery -> finalize)走完 33 号机器,再用 `ldvh_report_write` 创建 `report_form=\"research\"` 的报告并做写后回读",
|
|
325
|
+
"仅在需要拆分局部、有界的外部检索子任务时,才按需可选委派 `ldvh-researcher` 辅助取证,整体结论与交付仍由主控负最终责任",
|
|
326
|
+
"答复只表明「被问过并给出同意/不调查」,不构成授权凭据(00 §2.5、32 §9.1)",
|
|
222
327
|
...commonFollowUp
|
|
223
328
|
]
|
|
224
329
|
});
|
|
@@ -231,7 +336,21 @@ function consultEnvelope(args, lookup, classified, outcome, escalation) {
|
|
|
231
336
|
gaps,
|
|
232
337
|
verification: { checks: ["internal-lookup", "governance-scope", "answer-distinguishable"], passed: !sourceUnread },
|
|
233
338
|
follow_up: [
|
|
234
|
-
"Human
|
|
339
|
+
"Human 明确选择不调查:按现有信息继续推进",
|
|
340
|
+
...commonFollowUp
|
|
341
|
+
]
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
if (needsAskQuestion) {
|
|
345
|
+
return envelope("research-consult", "partial", {
|
|
346
|
+
result: commonResult,
|
|
347
|
+
scope: { requested: "consult", completed: ["internal-lookup"], not_completed: ["consult"] },
|
|
348
|
+
sources: [{ kind: "host-service", path: "userQuestions" }],
|
|
349
|
+
gaps,
|
|
350
|
+
verification: { checks: ["internal-lookup", "governance-scope", "answer-distinguishable"], passed: false },
|
|
351
|
+
follow_up: [
|
|
352
|
+
"请原样使用 result.question 与 result.options(联网调查 / 不调查)调用宿主 `ask_question` 向 Human 征询(不自行改写题面,不带 `detail`),取得选择后用 `record_decision`(research / skip)再调一次工具显式留痕",
|
|
353
|
+
"若仍未取得答复:没有答复即没有决定,不得读成 skip,也不得据此暂停整件工作,按既有路径继续并在交付说明中如实写明「未取得该处答复」",
|
|
235
354
|
...commonFollowUp
|
|
236
355
|
]
|
|
237
356
|
});
|
|
@@ -280,7 +399,10 @@ function consultSwitch(deps) {
|
|
|
280
399
|
function switchOffEnvelope(args, lookup, classified, escalation) {
|
|
281
400
|
return envelope("research-consult", "completed", {
|
|
282
401
|
result: {
|
|
402
|
+
point: CONSULT_POINT,
|
|
283
403
|
need: trimmed(args?.need),
|
|
404
|
+
human_requested: false,
|
|
405
|
+
switch_enabled: false,
|
|
284
406
|
internal_found: classified.usable,
|
|
285
407
|
internal_hit_count: classified.strong.length,
|
|
286
408
|
internal_hits: classified.strong,
|
|
@@ -313,6 +435,28 @@ export async function executeResearchConsult(args, exec, deps) {
|
|
|
313
435
|
if (need === null) {
|
|
314
436
|
return invalidRequest("research-consult", "need 必填:要查清什么(一句话)", "need");
|
|
315
437
|
}
|
|
438
|
+
if (args?.human_requested !== undefined && typeof args.human_requested !== "boolean") {
|
|
439
|
+
return invalidRequest("research-consult", "human_requested 须为布尔值", "human_requested");
|
|
440
|
+
}
|
|
441
|
+
const humanRequested = args?.human_requested === true;
|
|
442
|
+
const rawRecordDecision = args?.record_decision;
|
|
443
|
+
if (rawRecordDecision !== undefined
|
|
444
|
+
&& rawRecordDecision !== CONSULT_ANSWERS.RESEARCH
|
|
445
|
+
&& rawRecordDecision !== CONSULT_ANSWERS.SKIP) {
|
|
446
|
+
return invalidRequest(
|
|
447
|
+
"research-consult",
|
|
448
|
+
`第三处联网调查(point="research")只设二档闭集,record_decision 须为 "${CONSULT_ANSWERS.RESEARCH}" 或 "${CONSULT_ANSWERS.SKIP}",收到 ${JSON.stringify(rawRecordDecision)}`,
|
|
449
|
+
"record_decision"
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
const explicitDecision = rawRecordDecision ?? null;
|
|
453
|
+
if (humanRequested && explicitDecision !== null) {
|
|
454
|
+
return invalidRequest(
|
|
455
|
+
"research-consult",
|
|
456
|
+
"human_requested=true(免请示直接进入调研)与 record_decision(显式记录请示答复)互斥,不得同时传入",
|
|
457
|
+
"human_requested"
|
|
458
|
+
);
|
|
459
|
+
}
|
|
316
460
|
const scope = await governedProject(deps, exec);
|
|
317
461
|
if (scope.ok !== true) {
|
|
318
462
|
return unavailable(
|
|
@@ -334,8 +478,11 @@ export async function executeResearchConsult(args, exec, deps) {
|
|
|
334
478
|
const classified = classifyInternalHits(lookup.hits);
|
|
335
479
|
const internalGap = trimmed(args?.internal_gap);
|
|
336
480
|
const escalation = internalGap !== null ? "internal-gap" : (classified.usable ? null : (classified.weak.length > 0 ? "weak-only" : "no-hit"));
|
|
337
|
-
if (classified.usable && escalation === null) {
|
|
338
|
-
return internalFoundEnvelope(args, lookup, classified);
|
|
481
|
+
if (explicitDecision === null && classified.usable && escalation === null) {
|
|
482
|
+
return internalFoundEnvelope(args, lookup, classified, { humanRequested });
|
|
483
|
+
}
|
|
484
|
+
if (humanRequested) {
|
|
485
|
+
return humanRequestedEnvelope(args, lookup, classified, escalation);
|
|
339
486
|
}
|
|
340
487
|
const switchState = consultSwitch(deps);
|
|
341
488
|
if (!switchState.available) {
|
|
@@ -365,17 +512,52 @@ export async function executeResearchConsult(args, exec, deps) {
|
|
|
365
512
|
return unavailable(
|
|
366
513
|
"research-consult",
|
|
367
514
|
["宿主询问接缝(requestResearchConsult)在本组合不可用,无法提请——如实报告,不得以自述代替答复(00 §4.6)"],
|
|
368
|
-
"consult"
|
|
515
|
+
"consult",
|
|
516
|
+
true
|
|
369
517
|
);
|
|
370
518
|
}
|
|
519
|
+
const purpose = trimmed(args?.purpose);
|
|
520
|
+
const cleanScope = trimmed(args?.scope);
|
|
371
521
|
const outcome = await seam.requestResearchConsult({
|
|
372
522
|
need,
|
|
373
|
-
|
|
523
|
+
purpose,
|
|
524
|
+
scope: cleanScope,
|
|
374
525
|
keywords: args?.keywords,
|
|
375
526
|
internalGap,
|
|
376
527
|
agent: exec?.agent,
|
|
377
528
|
signal: exec?.signal
|
|
378
529
|
});
|
|
530
|
+
if (explicitDecision !== null
|
|
531
|
+
&& typeof outcome?.fingerprint === "string"
|
|
532
|
+
&& typeof seam.recordReviewAskDecision === "function") {
|
|
533
|
+
const fingerprintTask = buildResearchFingerprintTask({
|
|
534
|
+
need,
|
|
535
|
+
purpose,
|
|
536
|
+
scope: cleanScope,
|
|
537
|
+
keywords: args?.keywords,
|
|
538
|
+
});
|
|
539
|
+
const mappedAnswer = explicitDecision === CONSULT_ANSWERS.RESEARCH
|
|
540
|
+
? REVIEW_ASK_ANSWERS.REVIEW
|
|
541
|
+
: REVIEW_ASK_ANSWERS.SKIP;
|
|
542
|
+
const recorded = await seam.recordReviewAskDecision({
|
|
543
|
+
fingerprint: outcome.fingerprint,
|
|
544
|
+
point: REVIEW_ASK_POINTS.RESEARCH,
|
|
545
|
+
answer: mappedAnswer,
|
|
546
|
+
task: fingerprintTask,
|
|
547
|
+
});
|
|
548
|
+
outcome.decision = explicitDecision;
|
|
549
|
+
outcome.asked = true;
|
|
550
|
+
outcome.needs_ask_question = false;
|
|
551
|
+
outcome.reused = false;
|
|
552
|
+
delete outcome.reason;
|
|
553
|
+
if (recorded?.ok) {
|
|
554
|
+
outcome.at = recorded.value?.at;
|
|
555
|
+
} else {
|
|
556
|
+
outcome.recordError = recorded?.error
|
|
557
|
+
? `${recorded.error.code}: ${recorded.error.message}`
|
|
558
|
+
: "review-ask/unavailable: failed to record decision";
|
|
559
|
+
}
|
|
560
|
+
}
|
|
379
561
|
return consultEnvelope(args, lookup, classified, outcome, escalation);
|
|
380
562
|
}
|
|
381
563
|
|
package/lib/research-consult.js
CHANGED
|
@@ -15,16 +15,31 @@ export const INTERNAL_LOOKUP_LIMIT = 8;
|
|
|
15
15
|
export const RESEARCH_TOOL_NAME = "ldvh_research_consult";
|
|
16
16
|
|
|
17
17
|
export const RESEARCH_OPERATION_SUMMARY = [
|
|
18
|
-
"
|
|
19
|
-
"先在内部事实源(Pitfall / Report / Norm
|
|
20
|
-
"
|
|
21
|
-
"
|
|
18
|
+
"「联网调查(把关请示第三处 / 33 号调研吸收)」入口:遇到依赖外部信息而自己不掌握的问题时先调本工具,不要跳过内部核查直接开外部检索。",
|
|
19
|
+
"先在内部事实源(Pitfall / Report / Norm)做确定性词面匹配:有强命中就直接返回内部候选(未传 internal_gap 时早退);未命中只代表「机械召回未命中」,不代表内部没有,须再用 ldvh_pitfall_list / ldvh_report_list / ldvh_norm_list 补检。",
|
|
20
|
+
"两条触发路径:① AI 主控自查发现问题复杂、内部未调查过且联网调查更有帮助时,在内部无可用结论(或带 internal_gap)且开关开启时,向 Human 征询二选一「联网调查/不调查」;② Human 主动要求调查时传 human_requested=true,不受开关限制、先查内部后免重复请示直接进入。",
|
|
21
|
+
"获准或 Human 主动要求后,返回主控联网调研执行指引(research_template),由**主控亲自执行完整调研工序**(检索取证、三态引证、收敛判定,以及按需走 ldvh_report_session / ldvh_report_write 落盘与下游方案衔接);ldvh-researcher 仅作按需可选的局部辅助。征询不是 Gate,未得答复照常推进并如实说明。",
|
|
22
22
|
].join("\n");
|
|
23
23
|
|
|
24
24
|
function trimmed(value) {
|
|
25
25
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
function normalizeInlineFragment(value) {
|
|
29
|
+
const raw = trimmed(value);
|
|
30
|
+
if (raw === null) return null;
|
|
31
|
+
const collapsed = raw.replace(/\s*\r?\n\s*/g, " ").trim();
|
|
32
|
+
const stripped = collapsed.replace(/[。,,;;??]+$/u, "");
|
|
33
|
+
return stripped.length > 0 ? stripped : collapsed;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function buildResearchFingerprintTask({ need, purpose, scope, keywords } = {}) {
|
|
37
|
+
return [need, purpose, scope, ...(Array.isArray(keywords) ? keywords : [])]
|
|
38
|
+
.filter((part) => typeof part === "string" && part.trim().length > 0)
|
|
39
|
+
.map((part) => part.trim())
|
|
40
|
+
.join(" | ");
|
|
41
|
+
}
|
|
42
|
+
|
|
28
43
|
export function buildInternalQuery({ need, keywords, scope } = {}) {
|
|
29
44
|
const parts = [];
|
|
30
45
|
const subject = trimmed(need);
|
|
@@ -97,41 +112,48 @@ export function classifyInternalHits(hits) {
|
|
|
97
112
|
};
|
|
98
113
|
}
|
|
99
114
|
|
|
100
|
-
export function composeConsultQuestion({ need, scope } = {}) {
|
|
101
|
-
const subject =
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
:
|
|
106
|
-
|
|
115
|
+
export function composeConsultQuestion({ need, purpose, scope } = {}) {
|
|
116
|
+
const subject = normalizeInlineFragment(need) ?? "这件事";
|
|
117
|
+
const goal = normalizeInlineFragment(purpose);
|
|
118
|
+
const extra = normalizeInlineFragment(scope);
|
|
119
|
+
if (goal !== null && extra !== null) {
|
|
120
|
+
return { question: `LDVH 联网调查 - 是否联网查证:${subject}?(用途:${goal};范围:${extra})` };
|
|
121
|
+
}
|
|
122
|
+
if (goal !== null) {
|
|
123
|
+
return { question: `LDVH 联网调查 - 是否联网查证:${subject}?(用途:${goal})` };
|
|
124
|
+
}
|
|
125
|
+
if (extra !== null) {
|
|
126
|
+
return { question: `LDVH 联网调查 - 是否联网查证:${subject}?(范围:${extra})` };
|
|
127
|
+
}
|
|
128
|
+
return { question: `LDVH 联网调查 - 是否联网查证:${subject}?` };
|
|
107
129
|
}
|
|
108
130
|
|
|
109
131
|
const RESEARCH_DISCIPLINE = [
|
|
110
|
-
"##
|
|
132
|
+
"## 调研工序硬性约束",
|
|
111
133
|
"",
|
|
112
|
-
"-
|
|
134
|
+
"- **证据阶段先只取证、不边查边改**:完成证据搜集与收敛判定前,不把未证实线索直接当作代码改动或规范修改依据。",
|
|
113
135
|
"- **每条结论都要有可回指的外部来源**:HTTP(S) URL + 锚点 + 逐字摘录。找不到就说找不到,不要用记忆或推断冒充检索结果。",
|
|
114
|
-
"-
|
|
115
|
-
"-
|
|
116
|
-
"-
|
|
136
|
+
"- **三态如实标注**:已证实(confirmed)、未证实(uncertain)、缺口(gap)——「查不到」本身就是结论,不得用近似材料顶替。",
|
|
137
|
+
"- **区分来源性质**:官方文档、规范原文与一手源码优先;博客、论坛、issue 只作线索,须标明其权威性限度。",
|
|
138
|
+
"- **收敛与工序完整**:按充分 / 零增益 / 轮次触顶(小范围 <= 2 轮、大范围 <= 4 轮)做收敛判定;需要跨会话复用或落盘时,走完 `ldvh_report_session`(`create -> submit-round -> audit-citation -> check-delivery -> finalize`)与 `ldvh_report_write`(`report_form=\"research\"`)。",
|
|
117
139
|
];
|
|
118
140
|
|
|
119
141
|
const RESEARCH_OUTPUT_FORMAT = [
|
|
120
|
-
"##
|
|
142
|
+
"## 证据整理与记录格式",
|
|
121
143
|
"",
|
|
122
|
-
"
|
|
144
|
+
"按轮次整理每条发现,字段如下:",
|
|
123
145
|
"",
|
|
124
|
-
"- **statement
|
|
146
|
+
"- **statement**:一句话事实断言(先只陈述事实,不写方案取舍语气)",
|
|
125
147
|
"- **state**:confirmed / uncertain / gap",
|
|
126
148
|
"- **evidence**(仅 confirmed):text 逐字摘录、source 完整 HTTP(S) URL、anchor 可定位锚点、confidence high/medium/low",
|
|
127
149
|
"- **issue** / **reason**(仅 uncertain):悬而未决之处与原因",
|
|
128
150
|
"- **description** / **priority**(仅 gap):缺口描述与优先级 high/medium/low",
|
|
129
151
|
"",
|
|
130
|
-
"
|
|
152
|
+
"每轮结束核对:本轮新增了哪些已证实事实、还剩哪些缺口、是否满足收敛条件或需要换检索路径;整体结论、证据完整性与交付由主控负最终责任。",
|
|
131
153
|
];
|
|
132
154
|
|
|
133
155
|
export function composeResearchDispatchTemplate({ need, purpose, scope, subQuestions, keywords } = {}) {
|
|
134
|
-
const subject = trimmed(need) ?? "
|
|
156
|
+
const subject = trimmed(need) ?? "(未提供调研问题——请先界定具体要查清的外部事实,不要自行编造)";
|
|
135
157
|
const goal = trimmed(purpose);
|
|
136
158
|
const extra = trimmed(scope);
|
|
137
159
|
const subs = Array.isArray(subQuestions)
|
|
@@ -141,9 +163,9 @@ export function composeResearchDispatchTemplate({ need, purpose, scope, subQuest
|
|
|
141
163
|
? keywords.filter((item) => typeof item === "string" && item.trim().length > 0).map((item) => item.trim())
|
|
142
164
|
: [];
|
|
143
165
|
const lines = [];
|
|
144
|
-
lines.push("#
|
|
166
|
+
lines.push("# 联网调研执行指引(33 号调研吸收 · 主控完整工序)");
|
|
145
167
|
lines.push("");
|
|
146
|
-
lines.push("
|
|
168
|
+
lines.push("由**主控亲自执行完整调研工序**(检索取证、三态整理与逐字引证、收敛判定,以及按需走受控报告落盘与后续方案衔接),不强制外包给零上下文子代理;`ldvh-researcher` 仅作为主控按需拆分局部有界检索子任务时的可选辅助。");
|
|
147
169
|
lines.push("");
|
|
148
170
|
lines.push("## 调研问题");
|
|
149
171
|
lines.push("");
|
|
@@ -173,11 +195,11 @@ export function composeResearchDispatchTemplate({ need, purpose, scope, subQuest
|
|
|
173
195
|
lines.push(terms.join("、"));
|
|
174
196
|
lines.push("");
|
|
175
197
|
}
|
|
176
|
-
lines.push("##
|
|
198
|
+
lines.push("## 阶段边界提醒");
|
|
177
199
|
lines.push("");
|
|
178
|
-
lines.push("-
|
|
179
|
-
lines.push("-
|
|
180
|
-
lines.push("-
|
|
200
|
+
lines.push("- **证据结论先于方案取舍**:先把三态证据与来源整理收敛,再进入后续方案设计与收敛(04 §6.1),不要把单条未验证线索直接写成方案结论。");
|
|
201
|
+
lines.push("- **按需走受控落盘**:若结论需跨会话复用,通过 `ldvh_report_session` 与 `ldvh_report_write`(`report_form=\"research\"`)落盘,并完成写后回读。");
|
|
202
|
+
lines.push("- **查不到也是有效结论**:换检索路径仍查不到时如实记为 `gap`,不要用推测补空白。");
|
|
181
203
|
lines.push("");
|
|
182
204
|
lines.push(...RESEARCH_DISCIPLINE);
|
|
183
205
|
lines.push("");
|