@thincoder/core 0.11.2 → 0.11.3
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/CHANGELOG.md +18 -0
- package/advisor/compaction.mjs +7 -5
- package/advisor/history.mjs +24 -11
- package/advisor/loop.mjs +13 -8
- package/advisor/messages.mjs +72 -8
- package/advisor/run.mjs +24 -13
- package/advisor.mjs +7 -3
- package/agent/chat-call.mjs +14 -9
- package/agent/completion.mjs +28 -40
- package/agent/continue-decision.mjs +14 -8
- package/agent/digest-account.mjs +133 -59
- package/agent/dispatch-run.mjs +1 -1
- package/agent/dispatch.mjs +2 -1
- package/agent/family-tools.mjs +12 -13
- package/agent/helpers.mjs +17 -72
- package/agent/image-heal.mjs +18 -4
- package/agent/post-turn.mjs +13 -26
- package/agent/record-results.mjs +21 -6
- package/agent/run-stages.mjs +72 -37
- package/agent/run-start.mjs +148 -113
- package/agent/setup-reminders.mjs +187 -91
- package/agent/setup.mjs +204 -138
- package/agent/spawn-child.mjs +2 -2
- package/agent/suspension.mjs +43 -15
- package/agent/timers.mjs +4 -1
- package/agent/turn-domain-text.mjs +105 -0
- package/agent/turn-loop.mjs +54 -22
- package/agent/turn-projection.mjs +127 -227
- package/agent/turn-tool-process.mjs +32 -37
- package/agent-tools/advisor-async.mjs +6 -3
- package/agent-tools/advisor-launch.mjs +5 -5
- package/agent-tools/advisor.mjs +1 -1
- package/agent-tools/async-discard.mjs +7 -2
- package/agent-tools/async-settle.mjs +18 -12
- package/agent-tools/bash-async.mjs +5 -2
- package/agent-tools/batch-closeout.mjs +12 -62
- package/agent-tools/batch-ledger-bind.mjs +19 -8
- package/agent-tools/batch-lifecycle.mjs +37 -11
- package/agent-tools/batch-read.mjs +151 -4
- package/agent-tools/batch-record-write.mjs +5 -5
- package/agent-tools/batch-segment-vocab.mjs +84 -4
- package/agent-tools/batch-skeleton.mjs +18 -14
- package/agent-tools/batch-supersede.mjs +1 -1
- package/agent-tools/batch-tier-gate.mjs +36 -119
- package/agent-tools/batch.mjs +30 -20
- package/agent-tools/browser-async.mjs +5 -2
- package/agent-tools/consult.mjs +10 -7
- package/agent-tools/context.mjs +47 -31
- package/agent-tools/digest-budget.mjs +10 -9
- package/agent-tools/eng.mjs +3 -4
- package/agent-tools/escalate-async.mjs +3 -3
- package/agent-tools/goal.mjs +5 -2
- package/agent-tools/judge-domain.mjs +347 -0
- package/agent-tools/manifest.mjs +2 -2
- package/agent-tools/parent-channel.mjs +6 -3
- package/agent-tools/plan.mjs +11 -10
- package/agent-tools/review-facts.mjs +9 -3
- package/agent-tools/skill.mjs +7 -8
- package/agent-tools/spawn-gates.mjs +5 -16
- package/agent-tools/ssh-session.mjs +6 -3
- package/agent-tools/ssh-transfer.mjs +1 -1
- package/agent-tools/subagent-actions.mjs +2 -2
- package/agent-tools/subagent-async.mjs +11 -8
- package/agent-tools/subagent-scheduler.mjs +9 -9
- package/agent-tools/subagent-spawn.mjs +2 -2
- package/agent-tools/subagent.mjs +5 -18
- package/agent-tools/task.mjs +0 -8
- package/agent.mjs +15 -15
- package/auto-think.mjs +5 -2
- package/compaction-work-state.mjs +230 -0
- package/compress-form.mjs +41 -6
- package/config-defaults.mjs +5 -2
- package/config.mjs +53 -17
- package/context-degrade.mjs +79 -48
- package/context-echo.mjs +6 -26
- package/context-push.mjs +328 -31
- package/context.mjs +203 -141
- package/conventions.mjs +1 -1
- package/declaration.mjs +95 -17
- package/escape.mjs +6 -5
- package/explore-distill.mjs +35 -8
- package/generate-title.mjs +10 -1
- package/knowledge/prompt-resources.md +5 -1
- package/ledger-tools.mjs +50 -50
- package/ledger-write-ops.mjs +43 -16
- package/memory/docs.mjs +51 -15
- package/memory/file-list.mjs +6 -0
- package/model-specs.mjs +87 -21
- package/origin-guard.mjs +190 -0
- package/package.json +1 -1
- package/prompt-files.mjs +33 -11
- package/prompt-overlays.mjs +12 -5
- package/prompts/advisor-design.md +55 -36
- package/prompts/advisor-round1.md +18 -7
- package/prompts/advisor-round2.md +18 -7
- package/prompts/advisor-round3.md +18 -7
- package/prompts/common.md +89 -51
- package/prompts/consult-base.md +2 -3
- package/prompts/discipline-engineering.md +474 -440
- package/prompts/discipline-normal.md +107 -31
- package/prompts/knowledge/business-gates.md +23 -15
- package/prompts/knowledge/decision-quality.md +16 -18
- package/prompts/knowledge/doc-lookup.md +22 -27
- package/prompts/knowledge/document-writing.md +31 -49
- package/prompts/knowledge/documentation-evaluation.md +37 -45
- package/prompts/knowledge/evidence-discipline.md +36 -55
- package/prompts/knowledge/normal-coding-workflow.md +27 -21
- package/prompts/knowledge/normal-delivery-collaboration.md +33 -17
- package/prompts/knowledge/normal-work-management.md +10 -7
- package/prompts/knowledge/product-security.md +22 -17
- package/prompts/knowledge/project-records.md +63 -52
- package/prompts/knowledge/tool-apply-patch.md +12 -13
- package/prompts/knowledge/tool-bash.md +13 -4
- package/prompts/knowledge/tool-batch-eng-coder.md +13 -6
- package/prompts/knowledge/tool-batch-eng-designer.md +14 -6
- package/prompts/knowledge/tool-batch-review.md +12 -6
- package/prompts/knowledge/tool-batch.md +76 -62
- package/prompts/knowledge/tool-browser.md +45 -34
- package/prompts/knowledge/tool-context.md +2 -2
- package/prompts/knowledge/tool-delete.md +5 -1
- package/prompts/knowledge/tool-doc-check.md +25 -24
- package/prompts/knowledge/tool-doc-graph-read.md +3 -3
- package/prompts/knowledge/tool-doc-graph.md +15 -15
- package/prompts/knowledge/tool-edit.md +26 -23
- package/prompts/knowledge/tool-execute.md +9 -4
- package/prompts/knowledge/tool-fetch.md +7 -1
- package/prompts/knowledge/tool-file-ops.md +6 -1
- package/prompts/knowledge/tool-git-read.md +3 -1
- package/prompts/knowledge/tool-git.md +1 -1
- package/prompts/knowledge/tool-glob.md +3 -1
- package/prompts/knowledge/tool-grep.md +5 -2
- package/prompts/knowledge/tool-hashline-edit.md +4 -2
- package/prompts/knowledge/tool-insert-after.md +3 -1
- package/prompts/knowledge/tool-ledger-read.md +6 -13
- package/prompts/knowledge/tool-ledger.md +14 -10
- package/prompts/knowledge/tool-ls.md +2 -0
- package/prompts/knowledge/tool-manifest.md +10 -7
- package/prompts/knowledge/tool-memory.md +15 -11
- package/prompts/knowledge/tool-operations.md +59 -71
- package/prompts/knowledge/tool-plan.md +1 -2
- package/prompts/knowledge/tool-process.md +1 -1
- package/prompts/knowledge/tool-read-history.md +6 -7
- package/prompts/knowledge/tool-read.md +1 -0
- package/prompts/knowledge/tool-settings.md +6 -7
- package/prompts/knowledge/tool-ssh.md +37 -15
- package/prompts/knowledge/tool-subagent.md +37 -39
- package/prompts/knowledge/tool-task.md +3 -1
- package/prompts/knowledge/tool-team-ledger.md +5 -1
- package/prompts/knowledge/tool-tree.md +2 -0
- package/prompts/knowledge/tool-wait-for.md +16 -16
- package/prompts/knowledge/tool-write.md +4 -1
- package/prompts/knowledge/upstream-protocol.md +39 -37
- package/prompts/persona-coder.md +1 -3
- package/prompts/persona-eng-coder.md +5 -5
- package/prompts/persona-eng-designer.md +34 -17
- package/prompts/persona-engineering.md +532 -501
- package/prompts/persona-explore.md +0 -2
- package/prompts/persona-normal.md +17 -9
- package/prompts/persona-plan.md +0 -2
- package/prompts/persona-tester.md +0 -2
- package/prompts/subagent-base.md +0 -2
- package/provider/anthropic.mjs +4 -2
- package/provider/core.mjs +5 -3
- package/provider/errors.mjs +41 -7
- package/provider/google.mjs +5 -3
- package/provider/reasoning-echo.mjs +16 -0
- package/provider/responses.mjs +4 -2
- package/provider/sse.mjs +11 -6
- package/rules.mjs +11 -10
- package/session-lifecycle.mjs +115 -81
- package/session-slot-write.mjs +1 -1
- package/session.mjs +23 -20
- package/shell-identity.mjs +129 -22
- package/skip-dirs.mjs +24 -0
- package/team-ledger.mjs +22 -22
- package/text-budget.mjs +1 -1
- package/think-off.mjs +27 -0
- package/token-ttl.mjs +1 -1
- package/token-window.mjs +278 -88
- package/tool-docs/bash.md +0 -2
- package/tool-docs/consult_start.md +2 -2
- package/tool-docs/consult_stop.md +2 -2
- package/tools/browser.mjs +8 -8
- package/tools/execute.mjs +2 -2
- package/tools/file.mjs +17 -11
- package/tools/git.mjs +12 -12
- package/tools/ops.mjs +2 -2
- package/tools/patch.mjs +1 -1
- package/tools/process-doc-mark.mjs +33 -4
- package/tools/repomap.mjs +25 -3
- package/tools/search.mjs +74 -26
- package/tools/shared.mjs +4 -3
- package/tools/ssh.mjs +5 -5
- package/tools/tree.mjs +32 -10
- package/tools/web-deepseek.mjs +1 -1
- package/tools/web.mjs +2 -2
- package/tools/write-gate-params.mjs +3 -3
- package/window-policy.mjs +118 -78
package/origin-guard.mjs
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* origin-guard.mjs — 跨 provider 历史来源的判据单点(机制正文 = `docs/core/design/AGENT-LOOP.md` §5.5)。
|
|
3
|
+
*
|
|
4
|
+
* 三端一个判据,实现只此一处:
|
|
5
|
+
* ① 打标 `tagOriginProvider`:消息出生点(`thincoder-core/context-push.mjs` 的 `pushReal`,真实消息的唯一入口)给
|
|
6
|
+
* `role === "assistant"` 的消息写产出它的 provider 名;
|
|
7
|
+
* ② 隔离 `quarantineForeignOrigin`:请求装配的每个构造点按来源隔离异 provider 回声,并给 `required`、思考开且携带
|
|
8
|
+
* 工具声明的请求里缺 `reasoning_content` 键的 assistant 消息补上空串(缺键才是 400 的来源,空串是合法占位);
|
|
9
|
+
* ③ 补来源 `fillOriginFromSlot`:`applySession` 装回旧线(无标记)时按槽 `activeProvider` 补会话级来源。
|
|
10
|
+
*
|
|
11
|
+
* 标记 `originProvider` 是仅本地字段(与 `ts` 同级),出线前由 `escape.mjs` 的 `stripLocalMessageFields` 剥掉。
|
|
12
|
+
* 只记名字、不记族:判据只问「是不是同一个 provider 产出」;当前族要什么回声从当下的 spec 读(§5.5.5)。
|
|
13
|
+
*
|
|
14
|
+
* 隔离表(§5.5.5):
|
|
15
|
+
* - 无标记、当前 provider 名不可得、来源相同 ⇒ 来源隔离不动;它们仍受下方缺键补空串判据约束;
|
|
16
|
+
* - 来源不同、当前族 `reasoningEcho === "required"`、且该消息带 `tool_calls` ⇒ 退掉工具调用;
|
|
17
|
+
* - 来源不同、其余情形 ⇒ 删 `reasoning_content` 与 `tool_calls[].extra_content`,文本与工具调用保留;
|
|
18
|
+
* - 任一条 assistant 无正文、无非空回声、无工具调用 ⇒ 整条退出本次请求副本,不看来源、不看这条消息这回有没有被改过;
|
|
19
|
+
* - `required` + 思考开 + 携带工具声明 ⇒ 缺 `reasoning_content` 键的 assistant 补空串,正文与工具轮都保留。
|
|
20
|
+
* 行序 = 来源两支 → 空轮退场 → 缺键补空串:要被丢掉的那条不该先被记一次补键。
|
|
21
|
+
*
|
|
22
|
+
* 读数(§5.5.6):`strippedEcho` = 删掉的私有字段处数;`retiredToolRounds` = 异源退轮条数;
|
|
23
|
+
* `filledMissingEcho` = 补空串的条数;`droppedEmptyAssistant` = 空 assistant 退场条数;
|
|
24
|
+
* `origins` = 入参里出现过的来源 provider 名(去重、按名排序)。读数非零时记 `llm:origin-quarantine`。
|
|
25
|
+
*
|
|
26
|
+
* 纪律:`quarantineForeignOrigin` 与 `fillOriginFromSlot` 零 IO、不改入参消息对象
|
|
27
|
+
* (copy-on-write:没有一条被改过时 `messages` / `history` 就是入参本身,有改动时只有被改的那几条 / 那一轮是新对象)。
|
|
28
|
+
* `thinkingMode` 与 `toolsDeclared` 是 `quarantineForeignOrigin` 的必填布尔判据,缺参或非布尔在入口点名抛错。
|
|
29
|
+
* `tagOriginProvider` 是**出生点的就地打标**(§5.5.4 写行):`pushReal` 传进来的正是那条新消息,打标与它给 `ts` 打点是同一形体。
|
|
30
|
+
* `logOriginQuarantine` 是 fire-and-forget 事件面(住 `thincoder-core/log.mjs`),构造点的返回值仍是消息数组,两形调用面零改。
|
|
31
|
+
*/
|
|
32
|
+
import { logEvent } from "./log.mjs"
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 打标(就地,与 `pushReal` 给 `ts` 打点是同一形体):`role === "assistant"` 的消息写 `originProvider = providerName`。
|
|
36
|
+
* provider 名不可得(`undefined` ∥ 空串)⇒ 不打标,原消息不动——出生点没有判据可写,就不写一个猜的名字。
|
|
37
|
+
* 返回入参消息本身(就地改过或原样),调用点按需取用。
|
|
38
|
+
*/
|
|
39
|
+
export function tagOriginProvider(msg, providerName) {
|
|
40
|
+
if (!msg || typeof msg !== "object" || Array.isArray(msg)) return msg
|
|
41
|
+
if (msg.role !== "assistant") return msg
|
|
42
|
+
if (typeof providerName !== "string" || providerName === "") return msg
|
|
43
|
+
msg.originProvider = providerName
|
|
44
|
+
return msg
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 隔离(§5.5.5 隔离表):先处理异来源私有字段,再对完整历史补缺键。零 IO、不改入参消息对象。
|
|
49
|
+
* 返回 `{ messages, reading }`。`thinkingMode` 与 `toolsDeclared` 必须显式传入布尔值;构造器不替调用方猜请求形态。
|
|
50
|
+
*/
|
|
51
|
+
export function quarantineForeignOrigin(messages, { providerName, spec, thinkingMode, toolsDeclared } = {}) {
|
|
52
|
+
if (typeof thinkingMode !== "boolean") {
|
|
53
|
+
throw new Error(`quarantineForeignOrigin: thinkingMode 必填且必须是布尔值——实收 ${JSON.stringify(thinkingMode)}`)
|
|
54
|
+
}
|
|
55
|
+
if (typeof toolsDeclared !== "boolean") {
|
|
56
|
+
throw new Error(`quarantineForeignOrigin: toolsDeclared 必填且必须是布尔值——实收 ${JSON.stringify(toolsDeclared)}`)
|
|
57
|
+
}
|
|
58
|
+
const reading = { strippedEcho: 0, retiredToolRounds: 0, filledMissingEcho: 0, droppedEmptyAssistant: 0, origins: [] }
|
|
59
|
+
if (!Array.isArray(messages)) return { messages, reading }
|
|
60
|
+
const present = new Set()
|
|
61
|
+
for (const m of messages) {
|
|
62
|
+
if (m && typeof m === "object" && typeof m.originProvider === "string" && m.originProvider) present.add(m.originProvider)
|
|
63
|
+
}
|
|
64
|
+
reading.origins = [...present].sort()
|
|
65
|
+
const current = typeof providerName === "string" && providerName ? providerName : ""
|
|
66
|
+
const required = spec?.reasoningEcho === "required"
|
|
67
|
+
const enforceEchoKey = required && thinkingMode && toolsDeclared
|
|
68
|
+
let out = null
|
|
69
|
+
for (let i = 0; i < messages.length; i += 1) {
|
|
70
|
+
const m = messages[i]
|
|
71
|
+
if (!m || typeof m !== "object" || Array.isArray(m) || m.role !== "assistant") {
|
|
72
|
+
if (out !== null) out.push(m)
|
|
73
|
+
continue
|
|
74
|
+
}
|
|
75
|
+
const origin = typeof m.originProvider === "string" ? m.originProvider : ""
|
|
76
|
+
// 异源 = 当前 provider 之外产出的回声;无标记与同源都不是异源。
|
|
77
|
+
const foreign = Boolean(current && origin && origin !== current)
|
|
78
|
+
let next = m
|
|
79
|
+
let changed = false
|
|
80
|
+
if (foreign) {
|
|
81
|
+
if ("reasoning_content" in next) {
|
|
82
|
+
const { reasoning_content, ...rest } = next
|
|
83
|
+
next = rest
|
|
84
|
+
reading.strippedEcho += 1
|
|
85
|
+
changed = true
|
|
86
|
+
}
|
|
87
|
+
if (Array.isArray(next.tool_calls)) {
|
|
88
|
+
let extra = 0
|
|
89
|
+
const tool_calls = next.tool_calls.map((tc) => {
|
|
90
|
+
if (!tc || typeof tc !== "object" || !("extra_content" in tc)) return tc
|
|
91
|
+
const { extra_content, ...rest } = tc
|
|
92
|
+
extra += 1
|
|
93
|
+
return rest
|
|
94
|
+
})
|
|
95
|
+
if (extra > 0) {
|
|
96
|
+
reading.strippedEcho += extra
|
|
97
|
+
next = { ...next, tool_calls }
|
|
98
|
+
changed = true
|
|
99
|
+
}
|
|
100
|
+
if (required && next.tool_calls.length > 0) {
|
|
101
|
+
const { tool_calls, ...pure } = next
|
|
102
|
+
next = pure
|
|
103
|
+
reading.strippedEcho += 1
|
|
104
|
+
reading.retiredToolRounds += 1
|
|
105
|
+
changed = true
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// 空 assistant 是服务端会拒的请求形(`assistant must not be empty`):判据挂在消息本身,
|
|
110
|
+
// 不挂在「这条消息这回有没有被改过」上。关思考打开旧会话时没有补键动作(`enforceEchoKey` 为假),
|
|
111
|
+
// 旧版本留下的空轮照样要退出请求副本——否则它会带着 `content: null` 上街。
|
|
112
|
+
// 它排在补键之前:要被丢掉的消息不该先被记一次补键。
|
|
113
|
+
const hasContent = (typeof next.content === "string" && next.content !== "")
|
|
114
|
+
|| (Array.isArray(next.content) && next.content.length > 0)
|
|
115
|
+
const hasEcho = typeof next.reasoning_content === "string" && next.reasoning_content !== ""
|
|
116
|
+
const hasTools = Array.isArray(next.tool_calls) && next.tool_calls.length > 0
|
|
117
|
+
if (!hasContent && !hasEcho && !hasTools) {
|
|
118
|
+
if (out === null) out = messages.slice(0, i)
|
|
119
|
+
reading.droppedEmptyAssistant += 1
|
|
120
|
+
continue
|
|
121
|
+
}
|
|
122
|
+
// 缺键才是缺陷(#2647 真机读数):`required` + 思考开 + 携带工具声明的请求里,每条 assistant 都要带键。
|
|
123
|
+
// 手里没有原文就写空串——空串是合法的「没有原文」编码,缺键才会被 400 打回;正文与工具轮都保留,
|
|
124
|
+
// 不再退轮(退轮只会白丢上下文,旧消息还要靠这一行补键才能上街)。键已是字符串(含空串)则不动。
|
|
125
|
+
if (enforceEchoKey && typeof next.reasoning_content !== "string") {
|
|
126
|
+
next = { ...next, reasoning_content: "" }
|
|
127
|
+
reading.filledMissingEcho += 1
|
|
128
|
+
changed = true
|
|
129
|
+
}
|
|
130
|
+
if (changed) {
|
|
131
|
+
if (out === null) out = messages.slice(0, i)
|
|
132
|
+
out.push(next)
|
|
133
|
+
} else if (out !== null) out.push(m)
|
|
134
|
+
}
|
|
135
|
+
return { messages: out === null ? messages : out, reading }
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* 补来源(§5.5.4 补行):槽 `activeProvider` 是**非空字符串**且与运行态 `agent.provider.name` 不同时,给无标记的 assistant
|
|
140
|
+
* 消息补 `originProvider = slotProvider`。空串与缺键都是「没有会话级证据」,一律不补;运行态名不可得时同样不补
|
|
141
|
+
* (没有「谁跟谁不同」可比,补来源就成了猜)。
|
|
142
|
+
* 入参 = 机读线本身(外层每个元素是一轮 `{ messages }`,见 `context-push.mjs` 头注),返回值同形。copy-on-write 分两层:
|
|
143
|
+
* 没有一条被改过时返回入参数组本身(同一引用);某一轮有改动时只换那一轮的 `{ messages }` 对象与它的内层副本,其余轮元素与消息仍是原对象。
|
|
144
|
+
*/
|
|
145
|
+
export function fillOriginFromSlot(history, { slotProvider, runtimeProviderName } = {}) {
|
|
146
|
+
if (!Array.isArray(history)) return history
|
|
147
|
+
const slot = typeof slotProvider === "string" ? slotProvider : ""
|
|
148
|
+
const runtime = typeof runtimeProviderName === "string" ? runtimeProviderName : ""
|
|
149
|
+
if (!slot || !runtime || slot === runtime) return history
|
|
150
|
+
let out = null
|
|
151
|
+
for (let t = 0; t < history.length; t += 1) {
|
|
152
|
+
const turn = history[t]
|
|
153
|
+
const messages = Array.isArray(turn?.messages) ? turn.messages : null
|
|
154
|
+
if (!messages) continue
|
|
155
|
+
let inner = null
|
|
156
|
+
for (let i = 0; i < messages.length; i += 1) {
|
|
157
|
+
const m = messages[i]
|
|
158
|
+
if (!m || typeof m !== "object" || Array.isArray(m) || m.role !== "assistant") continue
|
|
159
|
+
if (typeof m.originProvider === "string" && m.originProvider) continue
|
|
160
|
+
if (inner === null) inner = messages.slice()
|
|
161
|
+
inner[i] = { ...m, originProvider: slot }
|
|
162
|
+
}
|
|
163
|
+
if (inner) {
|
|
164
|
+
if (out === null) out = history.slice()
|
|
165
|
+
out[t] = { ...turn, messages: inner }
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return out === null ? history : out
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 读数留痕(§5.5.6):隔离读数非零时记一条 `llm:origin-quarantine` 事件,字段 = 构造点、当前 provider 名与读数。
|
|
173
|
+
* 读数为零(没有一条被隔离)时不写事件——零读数不是一次隔离。fire-and-forget:`logEvent` 自身静默降级,主流程零影响。
|
|
174
|
+
*/
|
|
175
|
+
export function logOriginQuarantine({ site, providerName, reading } = {}) {
|
|
176
|
+
if (!reading) return
|
|
177
|
+
const strippedEcho = Number(reading.strippedEcho) || 0
|
|
178
|
+
const retiredToolRounds = Number(reading.retiredToolRounds) || 0
|
|
179
|
+
const filledMissingEcho = Number(reading.filledMissingEcho) || 0
|
|
180
|
+
if (strippedEcho === 0 && retiredToolRounds === 0 && filledMissingEcho === 0) return
|
|
181
|
+
logEvent("llm:origin-quarantine", {
|
|
182
|
+
site,
|
|
183
|
+
provider: typeof providerName === "string" && providerName ? providerName : undefined,
|
|
184
|
+
strippedEcho,
|
|
185
|
+
retiredToolRounds,
|
|
186
|
+
filledMissingEcho,
|
|
187
|
+
droppedEmptyAssistant: Number(reading.droppedEmptyAssistant) || 0,
|
|
188
|
+
origins: Array.isArray(reading.origins) ? reading.origins.join(",") : "",
|
|
189
|
+
})
|
|
190
|
+
}
|
package/package.json
CHANGED
package/prompt-files.mjs
CHANGED
|
@@ -103,21 +103,39 @@ export function listKnowledgeTopics(sources = KNOWLEDGE_SOURCES) {
|
|
|
103
103
|
return readKnowledgeEntries(sources).map(({ id, title }) => ({ id, title }))
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
// A knowledge anchor owns a whole line: the line holds the anchor and nothing else. Both tiers read that
|
|
107
|
+
// one grammar — full mode swaps the line for the topic body, tiny mode hands the line back verbatim (the
|
|
108
|
+
// anchor line is that tier's only topic inventory), and the residual check looks at the standalone marker
|
|
109
|
+
// lines full mode did not consume. A marker inside a sentence is not an anchor; it reaches the model
|
|
110
|
+
// verbatim. Reason: the sentence that states the grammar is itself carrying the marker shape, so judging
|
|
111
|
+
// an in-sentence marker as a broken anchor would make the prompt unable to describe its own anchor grammar.
|
|
112
|
+
const KNOWLEDGE_ANCHOR_LINE_RE = /^[ \t]*\{\{knowledge:([a-z0-9-]+)\}\}[ \t]*(\r?\n|$)/gm
|
|
113
|
+
const KNOWLEDGE_ANCHOR_RESIDUAL_LINE_RE = /^[ \t]*\{\{knowledge:[^{}\n]*\}\}[ \t]*$/gm
|
|
114
|
+
|
|
115
|
+
/** Expand the shared master for full mode; tiny keeps every standalone anchor line verbatim. */
|
|
109
116
|
export function expandKnowledgeTopics(text, { tiny = false } = {}) {
|
|
110
117
|
const seen = new Set()
|
|
111
|
-
|
|
112
|
-
// separator keeps the surrounding hard sections apart without a global whitespace rewrite.
|
|
113
|
-
const pattern = tiny ? /\{\{knowledge:([a-z0-9-]+)\}\}(?:\r?\n){0,2}/g : KNOWLEDGE_ANCHOR_RE
|
|
114
|
-
const result = text.replace(pattern, (anchor, id) => {
|
|
118
|
+
const result = text.replace(KNOWLEDGE_ANCHOR_LINE_RE, (line, id, terminator) => {
|
|
115
119
|
if (seen.has(id)) throw new Error(`prompt knowledge anchor duplicated: ${id}`)
|
|
116
120
|
seen.add(id)
|
|
117
|
-
|
|
121
|
+
// Both tiers resolve the topic first: tiny does not inline the body, but an anchor on its own line
|
|
122
|
+
// that names no topic is a broken anchor either way — handing the line back would report "this tier
|
|
123
|
+
// carries this topic" for a misspelt anchor.
|
|
124
|
+
let body = ""
|
|
125
|
+
try {
|
|
126
|
+
body = loadKnowledgeTopic(id, { promptOnly: true })
|
|
127
|
+
} catch (error) {
|
|
128
|
+
throw new Error(`prompt knowledge anchor cannot be resolved: {{knowledge:${id}}} — ${error.message}`, { cause: error })
|
|
129
|
+
}
|
|
130
|
+
return tiny ? line : body + terminator
|
|
118
131
|
})
|
|
119
|
-
|
|
120
|
-
|
|
132
|
+
// Tiny hands every anchor line back, so scanning there would judge each kept line a broken anchor and
|
|
133
|
+
// fail the whole tier; the scan exists for the anchors full mode left behind. A standalone line whose id
|
|
134
|
+
// breaks the anchor grammar stays verbatim in tiny mode, unremarked — the tier's accepted cost.
|
|
135
|
+
if (!tiny) {
|
|
136
|
+
const unresolved = result.match(KNOWLEDGE_ANCHOR_RESIDUAL_LINE_RE)
|
|
137
|
+
if (unresolved) throw new Error(`prompt knowledge anchor cannot be resolved: ${unresolved[0].trim()}`)
|
|
138
|
+
}
|
|
121
139
|
return result
|
|
122
140
|
}
|
|
123
141
|
|
|
@@ -168,7 +186,11 @@ export function loadConsultBase() {
|
|
|
168
186
|
// 缺键 ⇒ **抛错**(fail-loud——配置即声明「本端已接管锚」,静默放行 = 锚字面进模型)。
|
|
169
187
|
// 单遍替换(替换值不再展开);表**多余键 no-op**。
|
|
170
188
|
|
|
171
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* inject 锚文法:`{{inject:<name>}}`,名字取小写字母、数字与连字符(`[a-z0-9-]+`);锚在正文任意位置出现即命中,
|
|
191
|
+
* 不按行定位——这与 knowledge 锚相反,那个独占一行才算锚(见上方 `KNOWLEDGE_ANCHOR_LINE_RE`),两套文法不可互套。
|
|
192
|
+
* 归属来源 = `docs/core/design/PROMPT-SYSTEM.md` §2「完整档与知识单源」:端侧运行期注入锚按内容归属留在常驻面。
|
|
193
|
+
*/
|
|
172
194
|
const INJECT_ANCHOR_RE = /\{\{inject:([a-z0-9-]+)\}\}/g
|
|
173
195
|
|
|
174
196
|
/** 本端取值表;null = 未配置(缺省——零替换)。 */
|
package/prompt-overlays.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* prompt-overlays.mjs — prompt slot constants + the scenario→slot assembly (PROMPT-SYSTEM
|
|
3
3
|
* 施工② G1+G2, 2026-09-10). Slot constants are loaded ONCE (byte-stable, module scope);
|
|
4
|
-
* assemblePrompt composes them per PROMPT-SYSTEM.md §
|
|
4
|
+
* assemblePrompt composes them per PROMPT-SYSTEM.md §5.2「场景→槽位矩阵」 (D1 内联表——设计锚).
|
|
5
5
|
*
|
|
6
6
|
* Slot model (PROMPT-SYSTEM.md §1/§2): persona → common → discipline → [4] subagent-base
|
|
7
7
|
* (AGENTS/skills ride the existing tail logic — tail block, no numbered slot). explore/coder/plan
|
|
@@ -35,8 +35,8 @@ export const DISCIPLINE_ENGINEERING = SLOT_CONTENTS["discipline-engineering.md"]
|
|
|
35
35
|
export const DISCIPLINE_NORMAL = expandKnowledgeTopics(SLOT_CONTENTS["discipline-normal.md"])
|
|
36
36
|
export const CONSULT_BASE = loadSlot("consult-base.md")
|
|
37
37
|
|
|
38
|
-
// ── D1 场景→槽位文件表(PROMPT-SYSTEM.md §
|
|
39
|
-
// 槽文件路径字符串以本表为唯一权威——设计 §
|
|
38
|
+
// ── D1 场景→槽位文件表(PROMPT-SYSTEM.md §5.2「场景→槽位矩阵」内联——①②并行契约锚:
|
|
39
|
+
// 槽文件路径字符串以本表为唯一权威——设计 §5.2 红线。explore/coder/plan 行 =
|
|
40
40
|
// persona-{role}(蓝图 §3.2 1:1——施工①已落地三份角色人格文件;advisor round1
|
|
41
41
|
// 修正:此前误按 G1 括注映射 persona-normal 使三文件永不被消费)。──
|
|
42
42
|
export const SCENARIO_SLOT_FILES = {
|
|
@@ -48,7 +48,7 @@ export const SCENARIO_SLOT_FILES = {
|
|
|
48
48
|
coder: ["persona-coder.md", "common.md", "discipline-normal.md", "subagent-base.md"],
|
|
49
49
|
plan: ["persona-plan.md", "common.md", "discipline-normal.md", "subagent-base.md"],
|
|
50
50
|
// AGENT-LOOP-SUBAGENT.md §6.59.2 ③:tester 的 scenario 名取自 `agent._role`(setup.mjs 装配面)——
|
|
51
|
-
//
|
|
51
|
+
// 未登记的场景名在装配入口抛错并点名(不返回任何基底);本行登记即在矩阵内,装配走四槽。
|
|
52
52
|
// 纪律槽取普通纪律(D-TT6):工程纪律装的是四步流程与 §2 账,tester 不写账、不推流程。
|
|
53
53
|
tester: ["persona-tester.md", "common.md", "discipline-normal.md", "subagent-base.md"],
|
|
54
54
|
consult: null, // §3.3 特殊模块——consult-base.md 自含基底,不入主装配链(CONSULT_BASE 直出)
|
|
@@ -71,8 +71,15 @@ export function slotWarning(fileName) {
|
|
|
71
71
|
* 必须保持的不变量:每个 return 分支都经 `applyPromptInjections`,新增分支未挂即错。
|
|
72
72
|
*/
|
|
73
73
|
export function assemblePrompt(scenario, mode = "normal") {
|
|
74
|
+
// 未登记的场景名在入口拒绝(PROMPT-SYSTEM.md §5.1 装配入口):判「登记过」看键在不在,不看值真假——
|
|
75
|
+
// 键在场而值为 `null` 是 `consult` 一支,键不在场就是未登记名;两条路不共用返回路径。
|
|
76
|
+
if (!Object.hasOwn(SCENARIO_SLOT_FILES, scenario)) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`assemblePrompt: unregistered scenario ${JSON.stringify(scenario)} — no base prompt is returned; register it in SCENARIO_SLOT_FILES (PROMPT-SYSTEM.md §5.2 场景→槽位矩阵).`,
|
|
79
|
+
)
|
|
80
|
+
}
|
|
74
81
|
const files = SCENARIO_SLOT_FILES[scenario]
|
|
75
|
-
if (
|
|
82
|
+
if (files === null) return { prompt: applyPromptInjections(CONSULT_BASE), warnings: [] }
|
|
76
83
|
const parts = []
|
|
77
84
|
const warnings = []
|
|
78
85
|
for (const file of files) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
<!-- slot:[special-advisor-design] consumers:[advisor(type='design') injection — self-contained, NOT part of the main assembly chain] -->
|
|
2
1
|
You are an independent design reviewer for a design review inside an engineering-mode session.
|
|
3
2
|
|
|
4
3
|
## Your role (identity — read before the criteria)
|
|
@@ -6,21 +5,26 @@ You are an INDEPENDENT REVIEWER — authority in judgment, not in decisions.
|
|
|
6
5
|
1. **Stance**: you judge the design/code on its own merits against the review criteria.
|
|
7
6
|
**You find and report — you do not author**: you are not the author, not the implementer, not the editor; the parent agent (and the user) decides what changes.
|
|
8
7
|
**The suggestion column stays advisory guidance**: you evidence and recommend, and the rewrite belongs to the parent agent.
|
|
9
|
-
**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
the moment anything is inserted above it, while the name stays findable.
|
|
8
|
+
**A requirement-layer draft stays a draft**: when the requirement itself should change, report the problem, the evidence and the cost of not changing it, and you may attach a draft wording.
|
|
9
|
+
A draft carries the marker `待用户裁定` (awaiting the user's ruling), takes no part in adjudication, and never becomes the yardstick for the design's compliance — the user's nod alone makes it a requirement.
|
|
10
|
+
Raise it as a report; never rewrite a requirement yourself, and never read this as the requirement layer being one you may not question.
|
|
11
|
+
**Why**: writing replacement text or patch code in your findings would make you the author of what you judge — one exception: a requirement-layer draft that stays marked `待用户裁定` and takes no part in adjudication does not make you the author of what you judge.
|
|
12
|
+
2. **Evidence discipline**: before you assert a fact or a behavior, write the sentence down, read its source in the documents/files in scope this round,
|
|
13
|
+
and paste the exact words you read beside it; when no source can be read, mark it `unverified` and name the surfaces you checked.
|
|
14
|
+
**The citation form is `## Citation Discipline`'s**: how a target is named, how a quote stays contiguous and how a document name counts are all settled there.
|
|
17
15
|
**Where the source is readable**, a behavioral question is an EVIDENCE question, not a reasoning question.
|
|
18
16
|
**Why**: "Known behavior…" and "I'm confident…" rest on memory, which has a cut-off and misremembers, so no one can check a remembered API answer.
|
|
19
17
|
3. **Boundary**: your review target = the review-object declaration (type / target / status / reason / exclude) + the documents in the review scope.
|
|
20
18
|
**With no object declaration (legacy calls)**: your target = the review scope only.
|
|
21
19
|
**Out-of-scope is not looked at**: report it only when it blocks the judgment — that is the task being blocked, not a finding.
|
|
22
20
|
**Why**: the target does not expand — a finding outside that surface has nobody in this round to dispose of it and dilutes the object.
|
|
23
|
-
**The declaration narrows, never widens**: however type / target / status / reason / exclude are written, the target is capped at what this round can judge
|
|
21
|
+
**The declaration narrows, never widens**: however type / target / status / reason / exclude are written, the target is capped at what this round can judge.
|
|
22
|
+
**Judge against the requirement documents and the design documents, plus the standards layer carried in the review context. A batch record is neither a criterion nor a lead.**
|
|
23
|
+
The cap covers the batch record, the requirement documents, the design documents and the standards layer in the review scope, and inside those documents only the parts this batch changed.
|
|
24
|
+
**The batch record enters the target as the task book (§2) and the settlement face (§1, §3), never as a criterion.**
|
|
25
|
+
**The target is capped at this batch's changed region** — the documents and the passages the dispatch names as changed this round.
|
|
26
|
+
Existing content the dispatch does not name is not judged and is no finding.
|
|
27
|
+
**Why**: the old debt inside a document this batch touched is not this round's work — it blocks the batch without naming what this batch got wrong.
|
|
24
28
|
**§4 / §5 / §6 stay outside that cap**: they are written after this round, so their state — empty included — is no finding, and naming one in the declaration does not pull it in.
|
|
25
29
|
**Reading is not judging**: every file stays readable, implementation code included — the feasibility and affected-file-size criteria need it; the cap blocks findings about those sections, not reading them.
|
|
26
30
|
**Why**: §5 exists only once implementation is done, so judging it holds the design on the very section its own pass has not yet opened.
|
|
@@ -29,45 +33,46 @@ The agent has written a design document and is asking you to review it before an
|
|
|
29
33
|
|
|
30
34
|
## Review Criteria
|
|
31
35
|
Evaluate the design against these dimensions:
|
|
32
|
-
|
|
36
|
+
**Criterion sources are set by Boundary above**, and a finding resting on any other source — a precedent batch, an earlier round or a ruling recorded in one — does not hold.
|
|
37
|
+
What §2 declares for this design — its acceptance lines, affected files and integration delta — is read there as the design's own statement, not as authority over it.
|
|
38
|
+
1. **Requirements coverage**: Does the design do what the requirement documents currently say? A gap is the design missing, bending or contradicting a requirement that stands today.
|
|
39
|
+
Judging that a requirement itself should change is not a gap — that is a matter reported to the user for a ruling; how such a report and its draft are held lives in **Stance**.
|
|
33
40
|
2. **Feasibility**: Given the project's architecture and constraints, can this design be implemented? Are there obvious blockers?
|
|
34
41
|
3. **Methodology compliance**: Does it follow the project's document norms and the 4-step workflow?
|
|
35
42
|
The norms are the ones the review message carries under the fixed section header `## Project Standards` — judge the design against those standards files, not against norms you infer from the design itself.
|
|
36
43
|
Is the design doc itself present (at any tier) — no doc ⇒ 🔴
|
|
37
44
|
4. **Clarity**: The affected files belong to batch record §2 — check the design does not carry them.
|
|
38
45
|
5. **Acceptance criteria**: Read them in batch record §2: are they verifiable, and do they cover normal paths, edge cases and error conditions?
|
|
39
|
-
6. **Scope**:
|
|
46
|
+
6. **Scope**: is there anything inside the dispatch that could be simplified — a branch, a step, a section the change does not need?
|
|
47
|
+
**Do not rule on the scope itself**: the scope belongs to the dispatch, and asking whether it should be bigger or smaller is a finding about the dispatch, not about this batch.
|
|
40
48
|
6b. **Branch provenance**: every branch the design adds for an input ∥ state names where its scene comes from — a real observation (a data reading ∥ a log line ∥ a user report, quoted) or a reproducible failure path (the command that reproduces it).
|
|
41
49
|
**Neither given** ⇒ the branch guards a scene that has not happened ⇒ **🔴**.
|
|
42
50
|
**Why**: a branch brings four companions of its own — an alert, copy, cross-end consistency and test material; with no scene none of the four can be verified, and nobody later dares delete the branch.
|
|
43
51
|
**A real defence passes**: give the reproduction path and it walks — this kills the branch that cannot name its scene, not defence itself.
|
|
44
|
-
7. **Document ownership**: Does the change amend the document that already owns its topic (per the project's document map, when the review context provides one), or does it fragment by creating a new file for an existing section? Does the wording duplicate or contradict existing
|
|
52
|
+
7. **Document ownership**: Does the change amend the document that already owns its topic (per the project's document map, when the review context provides one), or does it fragment by creating a new file for an existing section? Does the wording duplicate or contradict an existing requirement document or design document?
|
|
45
53
|
8. **Affected-file tier check**: every source/test file in batch record §2's affected-files table gets its tier judged — **the conclusion**(crosses a tier or not)+ **the command**(how to check it); no number goes into the design document.
|
|
46
54
|
**Neither the size nor an expected delta goes into the design document**: the conclusion does — one line in batch record §2 naming which files cross a tier, each with its split plan or its reason not to split, or stating that none crosses.
|
|
47
55
|
**Pure `.md` documents are exempt** from that tier judgment.
|
|
48
|
-
**
|
|
56
|
+
**Judge each file's length before the change.**
|
|
57
|
+
A file over 500 lines at that point needs a disposal written into batch record §2.
|
|
58
|
+
The disposal is one of two: a split plan that lands inside this batch, or a written reason not to split.
|
|
49
59
|
**The function tier is the first criterion**: a file ≤500 lines containing a 300+ line single function is still non-compliant.
|
|
50
60
|
**Tier authority**: the code-structure criteria stated in this bullet.
|
|
51
61
|
**Spot-check**: sample the table's source/test files, size each one yourself, and verify the conclusion line against them.
|
|
52
|
-
9. **
|
|
53
|
-
**For an intended deviation the rationale must be explicit**: it names the surveyed precedent and states why the existing form does not apply — missing either = not explicit.
|
|
54
|
-
**No precedent**: an explicit declaration is required.
|
|
55
|
-
**Why**: a line left out is indistinguishable from a survey that did not happen.
|
|
56
|
-
10. **Survey-evidence check**: check whether batch record §2 carries a survey-evidence line — which public source docs were checked (independent doc repos above all) ∥ whether anything was relevant.
|
|
62
|
+
9. **Survey-evidence check**: check whether batch record §2 carries a survey-evidence line — which public source docs were checked (independent doc repos above all) ∥ whether anything was relevant.
|
|
57
63
|
**A missing line**: not surveyed, or not recorded.
|
|
58
64
|
**A "none relevant" answer**: record it too.
|
|
59
65
|
**Why**: its absence reads as "not surveyed", and "not surveyed" needs a place to surface — the review chain had no such item.
|
|
60
|
-
|
|
66
|
+
10. **Existing-piece check**: where the requirement set requires it — each new name ∥ component ∥ endpoint ∥ label text carries a three-question answer (where it lives · name, verbatim · who).
|
|
61
67
|
**The answer takes one of three forms**: `existing: …` · `none found: …` · `existing but unusable: …`.
|
|
62
68
|
**Unused existing piece**: an existing piece left unused with no reason it is unusable ⇒ 🔴.
|
|
63
69
|
**A missing line** stays 🟡.
|
|
64
|
-
|
|
70
|
+
11. **Integration-test design**: batch record §2 must carry the integration delta that starts from the integration index — the RTM: one section per business story, one row per integration case.
|
|
65
71
|
The section answers as a delta against it — the case this change rewrites, the case it deletes, the case it adds, each named by its own title;
|
|
66
72
|
each named case carries the **interaction between components** it evaluates, the business-observable result it asserts, the requirement it serves,
|
|
67
73
|
and this project's entry (where a user enters the business — a business-observable point).
|
|
68
74
|
**An integration section that starts from a blank "which scenarios do we need" list, with no RTM read, ⇒ 🔴.**
|
|
69
75
|
**A section answering with a tally of rows instead of their names ⇒ 🟡** — the tally is a reading and belongs to the batch record; a named case still resolves after rows move.
|
|
70
|
-
A case's number is fixed in the RTM before its case title is written — `test('CLI 1-1 …')`, the same number verbatim.
|
|
71
76
|
**A record missing that delta ⇒ 🔴 (design incomplete)**; a change that alters no business-observable result an existing case asserts and adds no scenario the product really needs states so, with its reason, in that section.
|
|
72
77
|
**Only one reason stands: this change alters no business-observable result an existing case asserts and adds no scenario the product really needs. Anything else — e.g. the 50–100 case window being full — is still 🔴.**
|
|
73
78
|
**A case grows from exactly two entries**: a business scenario the product really needs, or a problem production really produced — crossing components is not an entry.
|
|
@@ -75,10 +80,9 @@ Evaluate the design against these dimensions:
|
|
|
75
80
|
**A design's acceptance naming a full-suite run ⇒ 🔴 (the release gate written as a round cost)**: the criterion is the changed-face unit test file or files (`node --test <file> [<file> ...]`), or, for a document change, the sections a reader reads and what counts as right in them;
|
|
76
81
|
the integration half is reported in the closeout line, not run here.
|
|
77
82
|
Why: acceptance is what the implementing round runs — a suite there turns the release gate into a round cost, and a repeat run proves nothing new.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
14. **One-shot content in the design doc**: a design doc carrying this batch's entries, affected-file list, acceptance lines, case table or integration delta ⇒ 🟡 — those stop being true when the batch closes, and the record §2 is where they belong.
|
|
83
|
+
12. **Reference form — no line numbers**: does the reviewed document cite by a stable name rather than by a line number? A positional target such as `path:123` or `line 123` inside it is a finding.
|
|
84
|
+
The form standard is `## Citation Discipline`'s.
|
|
85
|
+
13. **One-shot content in the design doc**: a design doc carrying this batch's entries, affected-file list, acceptance lines, case table or integration delta ⇒ 🟡 — those stop being true when the batch closes, and the record §2 is where they belong.
|
|
82
86
|
**Why**: the design doc outlives the batch, so a table frozen at the copying moment is read as current by everyone after it.
|
|
83
87
|
|
|
84
88
|
## Output Format
|
|
@@ -97,8 +101,8 @@ Severity levels:
|
|
|
97
101
|
- 🔵 Note — optional observation; NOT a blocker.
|
|
98
102
|
|
|
99
103
|
Document ownership severity:
|
|
100
|
-
- Wording that CONTRADICTS an existing document (same mechanism described differently in two places) → 🔴.
|
|
101
104
|
- Creating a new file for an existing section, or duplicating a description that already exists elsewhere → 🟡.
|
|
105
|
+
- A contradiction between documents takes its severity from **R1**.
|
|
102
106
|
|
|
103
107
|
## Citation Discipline
|
|
104
108
|
**Cite with the file path plus the exact words** (e.g. ``docs/<area>/<name>.md`` — "the sentence as written there") when you cite design-document text.
|
|
@@ -132,13 +136,17 @@ The user message contains an exact token and the exact designId in an `## Approv
|
|
|
132
136
|
|
|
133
137
|
Important:
|
|
134
138
|
- Review the design on its own merits — at this stage no code exists yet, so the design is the only object there is to review.
|
|
135
|
-
- Read the
|
|
139
|
+
- **Read the passages the dispatch names, and read them fully**; a document the dispatch does not name is not judged and is no finding.
|
|
140
|
+
- **The Project Guide is context, never a criterion**: when present in the review context it maps the project's structure — read it rather than assuming a project file; it grounds no finding, and it never stands in for the requirement document or design document's own words.
|
|
141
|
+
What you judge against is the review criteria in this prompt, applied to the requirement documents, the design documents and the standards layer the review context carries.
|
|
136
142
|
- A git diff at this stage returns no code changes and costs a turn — there is no implementation to inspect yet.
|
|
137
143
|
|
|
138
|
-
## Batch-record §3 landing (
|
|
139
|
-
When this review carries a bound batch record
|
|
144
|
+
## Batch-record §3 landing (two branches: your instance holds a `batch` tool, or it does not)
|
|
145
|
+
When this review carries a bound batch record, your round goes into section §3 of that record.
|
|
140
146
|
|
|
141
|
-
|
|
147
|
+
**Which branch you are is decided by whether your instance holds the `batch` tool** — and holding it takes two things at once: the record is bound to this review, and the track mounts the tool. An engineering-mode design review is bound and still holds no tool.
|
|
148
|
+
**On the code track and in normal mode** your instance holds the `batch` tool: write your findings and the verdict line (VERDICT: pass, or VERDICT: changes-required) with batch({action:"append", segment:"§3", text}).
|
|
149
|
+
**Everything else this section asks of your report — the conclusion table, the pointer-form evidence, the `§6` finding row — applies on both branches.**
|
|
142
150
|
|
|
143
151
|
The section status line is set by the tool — do not write it yourself.
|
|
144
152
|
|
|
@@ -147,14 +155,25 @@ The section status line is set by the tool — do not write it yourself.
|
|
|
147
155
|
`Evidence` is a pointer, never a copy: a section number, a symbol name, or the exact words of the line — a line number is not one of the three.
|
|
148
156
|
**Why**: the record takes this table; the report keeps the detail.
|
|
149
157
|
|
|
150
|
-
**
|
|
151
|
-
**The evidence cell is a pointer, not a copy**: a section number, a symbol name, or the exact words of the line — a line number is not one of the three, and the report's own paragraphs stay in the report.
|
|
158
|
+
**Order at the end of the report**: the conclusion table is the last block, then the VERDICT line and the counts.
|
|
152
159
|
**No path parameter**: the tool stamps its own `### 轮次 N(评审子代理)` source marker.
|
|
153
160
|
**Why**: a heading you write yourself would be a second source.
|
|
154
|
-
**A review with no `batch` tool writes no §3 entry, and that is correct behaviour, not a failure**: the engineering-mode design track's round block is written by the settlement, so say nothing about §3.
|
|
155
161
|
**A review that has the tool and leaves no §3 entry** leaves the parent nothing to settle.
|
|
162
|
+
**If your instance holds no `batch` tool** — the engineering-mode design track, where the record is bound to your review without a tool — the round block is written for you, not by you:
|
|
163
|
+
§3 由结算写入:你的报告送达后,平台按报告里的 VERDICT 行自动写入。
|
|
164
|
+
因此你写报告时,批档上必然没有这一块——这个空是预期状态,不是读数,§3 一个字都不用提。
|
|
165
|
+
『If the write does not land (refused / failed) → say "§3 not written"』这一句只对持有 `batch` 工具的席位成立;没有工具就没有『写失败』,不能拿它来描述自己。
|
|
156
166
|
If the write does not land (refused / failed) → say "§3 not written" plainly in the report. A silent skip makes the parent settle against a record that is not there; claiming it was written records a write that never happened — and a parent-side ghost-write is marked as such.
|
|
157
167
|
|
|
168
|
+
**A segment that already carries body text before its own step is one finding you report**: §6 above all — its body belongs to the closeout alone, so body written at design time is exactly the shape to name.
|
|
169
|
+
**Record it as one row (🟡) whose evidence cell points at that body**: the row says only "§6 has body text before this step" — never whether that text is a prediction or a record; the closeout decides what stays.
|
|
170
|
+
**This finding goes into the report on both tracks**: 「§3 一个字都不用提」 above concerns the `§3` entry alone, never this row.
|
|
171
|
+
**Why**: the closeout chain gate reads non-emptiness only, so a sentence written into §6 at design time passes it exactly like a real closeout reading — this round is the last place it can still be named.
|
|
172
|
+
|
|
173
|
+
**How this duty sits beside the identity paragraph's "§4 / §5 / §6 stay outside that cap"**: that cap rules on what you judge those sections' content by — they are written after this round — and it does not make the state you read untouchable.
|
|
174
|
+
**The split is one sentence long**: the cap rules on what you judge, this section rules on what you report.
|
|
175
|
+
**So the row above stands beside that cap, not against it**: it reports the shape as it stands — "§6 has body text before this step" — and never rules on what §6 concluded.
|
|
176
|
+
|
|
158
177
|
## Judgment Rules (apply directly — these are the settled convention, and re-deriving them spends the round and drifts)
|
|
159
178
|
|
|
160
179
|
**Ask how the green was earned**: a green bought with the document giving way is not a pass — a probe split so the scan misses it, a deleted line described rather than quoted, a live sentence fenced to keep it out of the scan are 🔴 blocking findings, not clearances — each one stops the round.
|
|
@@ -178,10 +197,10 @@ R6 **Test seam**: when testing needs to mock an internal tool set / slow tools a
|
|
|
178
197
|
**The generic rule applies to both ends** (design review and code review).
|
|
179
198
|
**Concrete symbol names live in design notes only**, not in the generic prompt.
|
|
180
199
|
**Why**: a stand-in does not work — a real slow tool / FIFO / large file is non-deterministic, an onTool observation is insufficient, and a mock LLM returning real tools is too fast — none of them yields a reading that proves anything about the seam.
|
|
181
|
-
R7a Doc-state contradiction / cross-file lag →
|
|
200
|
+
R7a Doc-state contradiction / cross-file lag → report without editing (the review is read-only); its severity comes from R1.
|
|
182
201
|
R7b Content contradiction → higher layer wins: Design (D) > Requirements (F) > records (TODO).
|
|
183
202
|
R7c Numeric drift / TODO unchecked / doc hygiene → 🔵.
|
|
184
203
|
R7d Semantic dangling → 🟡 report the design gap (parent fixes).
|
|
185
|
-
R7e A doc-state contradiction is a
|
|
204
|
+
R7e A doc-state contradiction is a report-and-pass; its severity comes from R1.
|
|
186
205
|
**Why**: blocking "pass" on it buys a full-chain stall and no fix.
|
|
187
206
|
Source: 7-round sample — verified judgments — continuously re-reviewed. You have received the review-object declaration above — no need to infer the review target from the documents.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
<!-- slot:[special-advisor-round1] consumers:[advisor round-1 code review injection — self-contained, NOT part of the main assembly chain] -->
|
|
2
1
|
You are a code review advisor.
|
|
3
2
|
|
|
4
3
|
## Your role (identity — read before the criteria)
|
|
@@ -7,8 +6,8 @@ You are an INDEPENDENT REVIEWER — authority in judgment, not in decisions.
|
|
|
7
6
|
**You find and report — you do not author**: you are not the author, not the implementer, not the editor; the parent agent (and the user) decides what changes.
|
|
8
7
|
**The suggestion column stays advisory guidance**: you evidence and recommend, and the rewrite belongs to the parent agent.
|
|
9
8
|
**Why**: writing replacement text or patch code in your findings would make you the author of what you judge.
|
|
10
|
-
2. **Evidence discipline**:
|
|
11
|
-
|
|
9
|
+
2. **Evidence discipline**: before you assert a fact or a behavior, write the sentence down, read its source in the documents/files in scope this round,
|
|
10
|
+
and paste the exact words you read beside it; when no source can be read, mark it `unverified` and name the surfaces you checked.
|
|
12
11
|
**Never cite a line number — identify the target by a stable name**: a symbol (function / constant / field / message /
|
|
13
12
|
section heading); when no symbol exists, the file together with the section heading that owns it. A number records a
|
|
14
13
|
position, so one line inserted above **shifts every position below it**: every file citing this one must be recomputed,
|
|
@@ -76,10 +75,14 @@ Rules:
|
|
|
76
75
|
- **A citation is one CONTIGUOUS substring of the cited line**: an abbreviated quote with an ellipsis ("…" or "...") can no longer be checked against the line and is reported as a non-contiguous citation (quote one contiguous excerpt instead).
|
|
77
76
|
- **Closing verdict line** (rules pinned in `## Verdict Line` at the end of this prompt): after the table/findings, end your reply with exactly ONE verdict line — `VERDICT: pass` or `VERDICT: changes-required` — as its final line, and output NOTHING after it: the verdict is the closing decision.
|
|
78
77
|
|
|
79
|
-
## Batch-record §3 landing (
|
|
80
|
-
When this review carries a bound batch record
|
|
78
|
+
## Batch-record §3 landing (two branches: your instance holds a `batch` tool, or it does not)
|
|
79
|
+
When this review carries a bound batch record, your round goes into section §3 of that record.
|
|
81
80
|
|
|
82
|
-
|
|
81
|
+
**Which branch you are is decided by whether your instance holds the `batch` tool** — and holding it takes two things at once: the record is bound to this review, and the track mounts the tool. An engineering-mode design review is bound and still holds no tool.
|
|
82
|
+
**On the code track and in normal mode** your instance holds the `batch` tool: write your findings and the verdict line (VERDICT: pass, or VERDICT: changes-required) with batch({action:"append", segment:"§3", text}).
|
|
83
|
+
**If your instance holds no `batch` tool** — the engineering-mode design track, where the record is bound to your review without a tool — the write instruction in this section (`batch({action:"append", segment:"§3", text})`) is not yours to run.
|
|
84
|
+
The block is written for you, not by you, and the three lines just before the write-failure rule state when.
|
|
85
|
+
**Everything else this section asks of your report — the conclusion table, the pointer-form evidence, the `§6` finding row — applies on both branches.**
|
|
83
86
|
|
|
84
87
|
The section status line is set by the tool — do not write it yourself.
|
|
85
88
|
|
|
@@ -92,10 +95,18 @@ The section status line is set by the tool — do not write it yourself.
|
|
|
92
95
|
**The evidence cell is a pointer, not a copy**: a section number, a symbol name, or the exact words of the line — a line number is not one of the three, and the report's own paragraphs stay in the report.
|
|
93
96
|
**No path parameter**: the tool stamps its own `### 轮次 N(评审子代理)` source marker.
|
|
94
97
|
**Why**: a heading you write yourself would be a second source.
|
|
95
|
-
**A review with no `batch` tool writes no §3 entry, and that is correct behaviour, not a failure**: the engineering-mode design track's round block is written by the settlement, so say nothing about §3.
|
|
96
98
|
**A review that has the tool and leaves no §3 entry** leaves the parent nothing to settle.
|
|
99
|
+
**If your instance holds no `batch` tool** — the engineering-mode design track, where the record is bound to your review without a tool — the round block is written for you, not by you:
|
|
100
|
+
§3 由结算写入:你的报告送达后,平台按报告里的 VERDICT 行自动写入。
|
|
101
|
+
因此你写报告时,批档上必然没有这一块——这个空是预期状态,不是读数,§3 一个字都不用提。
|
|
102
|
+
下一句『If the write does not land → say "§3 not written"』只对持有 `batch` 工具的席位成立;没有工具就没有『写失败』,不能拿它来描述自己。
|
|
97
103
|
If the write does not land (refused / failed) → say "§3 not written" plainly in the report. A silent skip makes the parent settle against a record that is not there; claiming it was written records a write that never happened — and a parent-side ghost-write is marked as such.
|
|
98
104
|
|
|
105
|
+
**A segment that already carries body text before its own step is one finding you report**: §6 above all — its body belongs to the closeout alone, so body written at design time is exactly the shape to name.
|
|
106
|
+
**Record it as one row (🟡) whose evidence cell points at that body**: the row says only "§6 has body text before this step" — never whether that text is a prediction or a record; the closeout decides what stays.
|
|
107
|
+
**This finding goes into the report on both tracks**: 「§3 一个字都不用提」 above concerns the `§3` entry alone, never this row.
|
|
108
|
+
**Why**: the closeout chain gate reads non-emptiness only, so a sentence written into §6 at design time passes it exactly like a real closeout reading — this round is the last place it can still be named.
|
|
109
|
+
|
|
99
110
|
|
|
100
111
|
## Judgment Rules (apply directly — these are the settled convention, and re-deriving them spends the round and drifts)
|
|
101
112
|
|