@thincoder/core 0.11.1 → 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.
Files changed (382) hide show
  1. package/CHANGELOG.md +64 -2
  2. package/advisor/compaction.mjs +7 -5
  3. package/advisor/convergence.mjs +34 -3
  4. package/advisor/history.mjs +24 -11
  5. package/advisor/loop.mjs +49 -12
  6. package/advisor/messages.mjs +114 -33
  7. package/advisor/project-context.mjs +171 -42
  8. package/advisor/run.mjs +24 -10
  9. package/advisor.mjs +36 -46
  10. package/agent/batch-attribution.mjs +87 -0
  11. package/agent/batch-changed-surface.mjs +129 -0
  12. package/agent/chat-call.mjs +14 -9
  13. package/agent/completion.mjs +70 -41
  14. package/agent/continue-decision.mjs +14 -8
  15. package/agent/digest-account.mjs +133 -59
  16. package/agent/dispatch-gates.mjs +6 -0
  17. package/agent/dispatch-run.mjs +1 -1
  18. package/agent/dispatch.mjs +10 -4
  19. package/agent/family-tools.mjs +37 -23
  20. package/agent/helpers.mjs +139 -73
  21. package/agent/image-heal.mjs +18 -4
  22. package/agent/offload.mjs +25 -29
  23. package/agent/post-turn.mjs +36 -35
  24. package/agent/record-results.mjs +39 -7
  25. package/agent/run-stages.mjs +132 -52
  26. package/agent/run-start.mjs +150 -78
  27. package/agent/setup-reminders.mjs +194 -91
  28. package/agent/setup.mjs +219 -140
  29. package/agent/spawn-child.mjs +40 -3
  30. package/agent/suspension.mjs +43 -15
  31. package/agent/timers.mjs +9 -4
  32. package/agent/turn-domain-text.mjs +105 -0
  33. package/agent/turn-loop.mjs +84 -27
  34. package/agent/turn-projection.mjs +286 -0
  35. package/agent/turn-task-state.mjs +274 -0
  36. package/agent/turn-tool-process.mjs +163 -0
  37. package/agent/write-gate-ledger.mjs +569 -0
  38. package/agent/write-gate.mjs +29 -352
  39. package/agent-tools/advisor-async.mjs +35 -172
  40. package/agent-tools/advisor-launch.mjs +178 -0
  41. package/agent-tools/advisor-settle.mjs +28 -1
  42. package/agent-tools/advisor.mjs +37 -48
  43. package/agent-tools/async-discard.mjs +7 -2
  44. package/agent-tools/async-settle.mjs +18 -12
  45. package/agent-tools/audit-block.mjs +6 -6
  46. package/agent-tools/bash-async.mjs +5 -2
  47. package/agent-tools/batch-closeout.mjs +223 -35
  48. package/agent-tools/batch-gate.mjs +142 -342
  49. package/agent-tools/batch-ledger-bind.mjs +240 -20
  50. package/agent-tools/batch-ledger-view.mjs +109 -0
  51. package/agent-tools/batch-lifecycle.mjs +197 -48
  52. package/agent-tools/batch-paths.mjs +29 -8
  53. package/agent-tools/batch-read.mjs +151 -4
  54. package/agent-tools/batch-record-write.mjs +417 -0
  55. package/agent-tools/batch-regions.mjs +215 -0
  56. package/agent-tools/batch-reopen.mjs +23 -11
  57. package/agent-tools/batch-segment-vocab.mjs +459 -0
  58. package/agent-tools/batch-skeleton.mjs +196 -239
  59. package/agent-tools/batch-supersede.mjs +232 -0
  60. package/agent-tools/batch-tier-gate.mjs +214 -0
  61. package/agent-tools/batch.mjs +192 -439
  62. package/agent-tools/browser-async.mjs +5 -2
  63. package/agent-tools/consult.mjs +17 -11
  64. package/agent-tools/context.mjs +76 -33
  65. package/agent-tools/design-review-record.mjs +225 -0
  66. package/agent-tools/design-slots.mjs +1 -1
  67. package/agent-tools/design-token.mjs +279 -81
  68. package/agent-tools/digest-budget.mjs +10 -9
  69. package/agent-tools/doc-check.mjs +43 -33
  70. package/agent-tools/doc-graph.mjs +140 -0
  71. package/agent-tools/eng.mjs +12 -12
  72. package/agent-tools/escalate-async.mjs +5 -5
  73. package/agent-tools/goal.mjs +5 -2
  74. package/agent-tools/judge-domain.mjs +347 -0
  75. package/agent-tools/manifest.mjs +34 -18
  76. package/agent-tools/parent-channel.mjs +6 -3
  77. package/agent-tools/plan.mjs +11 -10
  78. package/agent-tools/read-history.mjs +112 -11
  79. package/agent-tools/review-facts.mjs +19 -6
  80. package/agent-tools/settings.mjs +23 -2
  81. package/agent-tools/skill.mjs +7 -8
  82. package/agent-tools/spawn-gates.mjs +14 -24
  83. package/agent-tools/ssh-session.mjs +8 -5
  84. package/agent-tools/ssh-text.mjs +155 -0
  85. package/agent-tools/ssh-transfer.mjs +1 -1
  86. package/agent-tools/ssh-transport.mjs +19 -148
  87. package/agent-tools/subagent-actions-query.mjs +10 -6
  88. package/agent-tools/subagent-actions.mjs +2 -2
  89. package/agent-tools/subagent-async.mjs +19 -17
  90. package/agent-tools/subagent-brief.mjs +76 -0
  91. package/agent-tools/subagent-design-token.mjs +168 -0
  92. package/agent-tools/subagent-run.mjs +1 -1
  93. package/agent-tools/subagent-scheduler.mjs +13 -13
  94. package/agent-tools/subagent-spawn.mjs +92 -112
  95. package/agent-tools/subagent.mjs +16 -28
  96. package/agent-tools/task.mjs +0 -8
  97. package/agent-tools/taskbook-block.mjs +94 -0
  98. package/agent-tools/timer.mjs +12 -8
  99. package/agent-tools/verify.mjs +13 -4
  100. package/agent-tools.mjs +7 -3
  101. package/agent.mjs +26 -7
  102. package/attachments.mjs +3 -3
  103. package/auto-think.mjs +5 -2
  104. package/browser/actions.mjs +9 -3
  105. package/browser/cdp.mjs +45 -17
  106. package/browser/launch.mjs +25 -43
  107. package/browser/pool.mjs +299 -0
  108. package/browser/queue.mjs +2 -0
  109. package/browser/session-state.mjs +450 -0
  110. package/browser/session.mjs +127 -151
  111. package/browser/snapshot.mjs +89 -0
  112. package/client-identity.mjs +1 -1
  113. package/compaction-work-state.mjs +230 -0
  114. package/compress-form.mjs +41 -6
  115. package/config-defaults.mjs +7 -3
  116. package/config-migrate.mjs +40 -0
  117. package/config-normalize.mjs +28 -2
  118. package/config-reload.mjs +59 -0
  119. package/config.mjs +110 -110
  120. package/context-degrade.mjs +93 -34
  121. package/context-echo.mjs +6 -15
  122. package/context-push.mjs +328 -31
  123. package/context.mjs +298 -170
  124. package/conventions.mjs +11 -9
  125. package/declaration.mjs +126 -22
  126. package/declared-repos.mjs +94 -0
  127. package/doc-check/doc-names.mjs +73 -0
  128. package/doc-check/doc-tokens.mjs +110 -0
  129. package/doc-check/existence.mjs +160 -0
  130. package/doc-check/index.mjs +309 -213
  131. package/doc-check/line-refs.mjs +27 -101
  132. package/doc-check/paragraph.mjs +218 -102
  133. package/doc-graph/anchors.mjs +474 -0
  134. package/doc-graph/doc-batch-face.mjs +59 -0
  135. package/doc-graph/doc-suffix.mjs +27 -0
  136. package/doc-graph/graph-tokens.mjs +160 -0
  137. package/doc-graph.mjs +778 -0
  138. package/escape.mjs +6 -5
  139. package/explore-distill.mjs +41 -8
  140. package/generate-title.mjs +10 -1
  141. package/i18n.mjs +1 -1
  142. package/instance-inbox-watch.mjs +272 -0
  143. package/instance-inbox.mjs +218 -0
  144. package/instance-registry.mjs +179 -0
  145. package/knowledge/README.md +3 -0
  146. package/knowledge/prompt-resources.md +10 -0
  147. package/ledger-close-proof.mjs +100 -49
  148. package/ledger-close.mjs +188 -0
  149. package/ledger-cmd.mjs +47 -91
  150. package/ledger-consistency.mjs +113 -0
  151. package/ledger-db.mjs +47 -15
  152. package/ledger-executors.mjs +1 -1
  153. package/ledger-tools.mjs +121 -62
  154. package/ledger-write-ops.mjs +162 -46
  155. package/ledger.mjs +1 -1
  156. package/manifest-discovery.mjs +3 -1
  157. package/manifest-schema.mjs +27 -5
  158. package/memory/docs.mjs +51 -15
  159. package/memory/file-list.mjs +6 -0
  160. package/memory/schema.mjs +2 -2
  161. package/model-specs.mjs +87 -21
  162. package/origin-guard.mjs +190 -0
  163. package/package.json +3 -1
  164. package/path-resolve.mjs +338 -57
  165. package/prompt-files.mjs +114 -2
  166. package/prompt-overlays.mjs +21 -11
  167. package/prompts/advisor-design.md +96 -36
  168. package/prompts/advisor-round1.md +48 -4
  169. package/prompts/advisor-round2.md +54 -10
  170. package/prompts/advisor-round3.md +53 -9
  171. package/prompts/common.md +99 -434
  172. package/prompts/consult-base.md +7 -4
  173. package/prompts/discipline-engineering.md +504 -295
  174. package/prompts/discipline-normal.md +106 -281
  175. package/prompts/knowledge/business-gates.md +30 -0
  176. package/prompts/knowledge/decision-quality.md +21 -0
  177. package/prompts/knowledge/doc-lookup.md +30 -0
  178. package/prompts/knowledge/document-writing.md +33 -0
  179. package/prompts/knowledge/documentation-evaluation.md +48 -0
  180. package/prompts/knowledge/evidence-discipline.md +38 -0
  181. package/prompts/knowledge/normal-coding-workflow.md +110 -0
  182. package/prompts/knowledge/normal-delivery-collaboration.md +124 -0
  183. package/prompts/knowledge/normal-work-management.md +60 -0
  184. package/prompts/knowledge/product-security.md +28 -0
  185. package/prompts/knowledge/project-records.md +73 -0
  186. package/prompts/knowledge/tool-advisor.md +29 -0
  187. package/prompts/knowledge/tool-apply-patch.md +17 -0
  188. package/prompts/knowledge/tool-bash.md +48 -0
  189. package/prompts/knowledge/tool-batch-eng-coder.md +19 -0
  190. package/prompts/knowledge/tool-batch-eng-designer.md +20 -0
  191. package/prompts/knowledge/tool-batch-review.md +18 -0
  192. package/prompts/knowledge/tool-batch.md +94 -0
  193. package/prompts/knowledge/tool-browser.md +68 -0
  194. package/prompts/knowledge/tool-code-search.md +4 -0
  195. package/prompts/knowledge/tool-consult-start.md +12 -0
  196. package/prompts/knowledge/tool-consult-stop.md +6 -0
  197. package/prompts/knowledge/tool-context.md +6 -0
  198. package/prompts/knowledge/tool-delete.md +21 -0
  199. package/prompts/knowledge/tool-doc-check.md +71 -0
  200. package/prompts/knowledge/tool-doc-graph-read.md +20 -0
  201. package/prompts/knowledge/tool-doc-graph.md +49 -0
  202. package/prompts/knowledge/tool-doc-search.md +6 -0
  203. package/prompts/knowledge/tool-edit.md +41 -0
  204. package/prompts/knowledge/tool-eng.md +2 -0
  205. package/prompts/knowledge/tool-execute.md +21 -0
  206. package/prompts/knowledge/tool-fetch.md +18 -0
  207. package/prompts/knowledge/tool-file-ops.md +21 -0
  208. package/prompts/knowledge/tool-get-current-time.md +7 -0
  209. package/prompts/knowledge/tool-git-read.md +21 -0
  210. package/prompts/knowledge/tool-git.md +29 -0
  211. package/prompts/knowledge/tool-glob.md +17 -0
  212. package/prompts/knowledge/tool-goal.md +8 -0
  213. package/prompts/knowledge/tool-grep.md +21 -0
  214. package/prompts/knowledge/tool-hashline-edit.md +16 -0
  215. package/prompts/knowledge/tool-insert-after.md +17 -0
  216. package/prompts/knowledge/tool-instance-list.md +6 -0
  217. package/prompts/knowledge/tool-instance-send.md +10 -0
  218. package/prompts/knowledge/tool-knowledge.md +18 -0
  219. package/prompts/knowledge/tool-ledger-read.md +28 -0
  220. package/prompts/knowledge/tool-ledger.md +46 -0
  221. package/prompts/knowledge/tool-lint.md +16 -0
  222. package/prompts/knowledge/tool-ls.md +15 -0
  223. package/prompts/knowledge/tool-lsp.md +11 -0
  224. package/prompts/knowledge/tool-main-history.md +2 -0
  225. package/prompts/knowledge/tool-manifest-read.md +14 -0
  226. package/prompts/knowledge/tool-manifest.md +34 -0
  227. package/prompts/knowledge/tool-memory-read.md +20 -0
  228. package/prompts/knowledge/tool-memory.md +19 -0
  229. package/prompts/knowledge/tool-notify-parent.md +12 -0
  230. package/prompts/knowledge/tool-operations.md +102 -0
  231. package/prompts/knowledge/tool-peer-instances.md +2 -0
  232. package/prompts/knowledge/tool-plan.md +5 -0
  233. package/prompts/knowledge/tool-process-read.md +13 -0
  234. package/prompts/knowledge/tool-process.md +15 -0
  235. package/prompts/knowledge/tool-question.md +16 -0
  236. package/prompts/knowledge/tool-read-history-batch.md +22 -0
  237. package/prompts/knowledge/tool-read-history.md +35 -0
  238. package/prompts/knowledge/tool-read-image.md +11 -0
  239. package/prompts/knowledge/tool-read.md +22 -0
  240. package/prompts/knowledge/tool-recent-changes.md +6 -0
  241. package/prompts/knowledge/tool-repo-outline.md +4 -0
  242. package/prompts/knowledge/tool-settings-read.md +12 -0
  243. package/prompts/knowledge/tool-settings.md +17 -0
  244. package/prompts/knowledge/tool-skill.md +6 -0
  245. package/prompts/knowledge/tool-ssh.md +74 -0
  246. package/prompts/knowledge/tool-subagent.md +57 -0
  247. package/prompts/knowledge/tool-task.md +14 -0
  248. package/prompts/knowledge/tool-team-ledger-read.md +11 -0
  249. package/prompts/knowledge/tool-team-ledger.md +15 -0
  250. package/prompts/knowledge/tool-timer.md +23 -0
  251. package/prompts/knowledge/tool-tree.md +16 -0
  252. package/prompts/knowledge/tool-verify.md +19 -0
  253. package/prompts/knowledge/tool-wait-for.md +25 -0
  254. package/prompts/knowledge/tool-websearch.md +19 -0
  255. package/prompts/knowledge/tool-write.md +12 -0
  256. package/prompts/knowledge/upstream-protocol.md +45 -0
  257. package/prompts/persona-coder.md +1 -3
  258. package/prompts/persona-eng-coder.md +24 -6
  259. package/prompts/persona-eng-designer.md +150 -171
  260. package/prompts/persona-engineering.md +531 -442
  261. package/prompts/persona-explore.md +1 -3
  262. package/prompts/persona-normal.md +17 -9
  263. package/prompts/persona-plan.md +5 -3
  264. package/prompts/persona-tester.md +0 -2
  265. package/prompts/subagent-base.md +2 -2
  266. package/provider/anthropic.mjs +10 -6
  267. package/provider/core.mjs +8 -5
  268. package/provider/errors.mjs +63 -4
  269. package/provider/google.mjs +29 -10
  270. package/provider/reasoning-echo.mjs +16 -0
  271. package/provider/responses.mjs +7 -3
  272. package/provider/sse.mjs +11 -6
  273. package/provider-flows.mjs +2 -2
  274. package/rules.mjs +11 -10
  275. package/session-index-build.mjs +1 -1
  276. package/session-index-pass.mjs +1 -1
  277. package/session-index-query.mjs +1 -1
  278. package/session-index.mjs +1 -1
  279. package/session-lifecycle.mjs +131 -42
  280. package/session-slot-write.mjs +38 -6
  281. package/session.mjs +30 -11
  282. package/shell-identity.mjs +129 -22
  283. package/skip-dirs.mjs +26 -2
  284. package/team-ledger.mjs +34 -30
  285. package/text-budget.mjs +1 -1
  286. package/think-off.mjs +27 -0
  287. package/token-ttl.mjs +74 -5
  288. package/token-window.mjs +371 -47
  289. package/tool-docs/advisor.md +2 -27
  290. package/tool-docs/apply_patch.md +1 -15
  291. package/tool-docs/bash.md +2 -43
  292. package/tool-docs/batch-eng-coder.md +3 -0
  293. package/tool-docs/batch-eng-designer.md +3 -0
  294. package/tool-docs/batch-review.md +3 -0
  295. package/tool-docs/batch.md +2 -84
  296. package/tool-docs/browser.md +2 -49
  297. package/tool-docs/code_search.md +2 -2
  298. package/tool-docs/consult_start.md +2 -8
  299. package/tool-docs/consult_stop.md +2 -4
  300. package/tool-docs/context.md +1 -5
  301. package/tool-docs/delete.md +2 -17
  302. package/tool-docs/doc_check.md +2 -107
  303. package/tool-docs/doc_graph-read.md +3 -0
  304. package/tool-docs/doc_graph.md +3 -0
  305. package/tool-docs/doc_search.md +2 -4
  306. package/tool-docs/edit.md +1 -38
  307. package/tool-docs/eng.md +3 -1
  308. package/tool-docs/execute.md +2 -18
  309. package/tool-docs/fetch.md +2 -14
  310. package/tool-docs/file_ops.md +2 -18
  311. package/tool-docs/get_current_time.md +1 -6
  312. package/tool-docs/git-read.md +3 -0
  313. package/tool-docs/git.md +2 -35
  314. package/tool-docs/glob.md +2 -10
  315. package/tool-docs/goal.md +1 -6
  316. package/tool-docs/grep.md +2 -18
  317. package/tool-docs/hashline_edit.md +2 -15
  318. package/tool-docs/insert_after.md +2 -16
  319. package/tool-docs/instance_list.md +3 -0
  320. package/tool-docs/instance_send.md +3 -0
  321. package/tool-docs/knowledge.md +3 -0
  322. package/tool-docs/ledger-read.md +3 -0
  323. package/tool-docs/ledger.md +3 -8
  324. package/tool-docs/lint.md +2 -10
  325. package/tool-docs/ls.md +2 -11
  326. package/tool-docs/lsp.md +2 -9
  327. package/tool-docs/main_history.md +3 -1
  328. package/tool-docs/manifest-read.md +2 -8
  329. package/tool-docs/manifest.md +2 -35
  330. package/tool-docs/memory-read.md +3 -0
  331. package/tool-docs/memory.md +2 -20
  332. package/tool-docs/notify_parent.md +2 -13
  333. package/tool-docs/peer_instances.md +3 -1
  334. package/tool-docs/plan.md +1 -5
  335. package/tool-docs/process-read.md +3 -0
  336. package/tool-docs/process.md +2 -13
  337. package/tool-docs/question.md +3 -17
  338. package/tool-docs/read.md +2 -19
  339. package/tool-docs/read_history-batch.md +3 -0
  340. package/tool-docs/read_history.md +2 -18
  341. package/tool-docs/read_image.md +2 -9
  342. package/tool-docs/recent_changes.md +2 -2
  343. package/tool-docs/repo_outline.md +2 -2
  344. package/tool-docs/settings-read.md +3 -0
  345. package/tool-docs/settings.md +1 -12
  346. package/tool-docs/skill.md +2 -6
  347. package/tool-docs/ssh.md +1 -62
  348. package/tool-docs/subagent.md +2 -100
  349. package/tool-docs/task.md +1 -7
  350. package/tool-docs/team_ledger-read.md +3 -0
  351. package/tool-docs/team_ledger.md +3 -9
  352. package/tool-docs/timer.md +2 -19
  353. package/tool-docs/tree.md +2 -13
  354. package/tool-docs/verify.md +2 -12
  355. package/tool-docs/wait_for.md +2 -32
  356. package/tool-docs/websearch.md +2 -19
  357. package/tool-docs/write.md +2 -12
  358. package/tools/browser.mjs +54 -9
  359. package/tools/doc-write-gate.mjs +73 -0
  360. package/tools/edit-batch.mjs +170 -92
  361. package/tools/edit-diff.mjs +78 -62
  362. package/tools/edit-receipt.mjs +39 -0
  363. package/tools/execute.mjs +3 -3
  364. package/tools/file.mjs +28 -14
  365. package/tools/git.mjs +36 -21
  366. package/tools/index.mjs +6 -0
  367. package/tools/knowledge.mjs +143 -0
  368. package/tools/linter.mjs +3 -3
  369. package/tools/ops.mjs +5 -3
  370. package/tools/patch.mjs +124 -44
  371. package/tools/process-doc-mark.mjs +33 -4
  372. package/tools/repomap.mjs +25 -3
  373. package/tools/search.mjs +74 -26
  374. package/tools/shared.mjs +29 -27
  375. package/tools/ssh.mjs +5 -5
  376. package/tools/tree.mjs +32 -10
  377. package/tools/web-deepseek.mjs +1 -1
  378. package/tools/web.mjs +2 -2
  379. package/tools/write-gate-params.mjs +31 -0
  380. package/tools/write-path.mjs +16 -4
  381. package/window-policy.mjs +243 -0
  382. package/doc-check/anchors.mjs +0 -235
@@ -3,13 +3,12 @@
3
3
  * The agent calls this explicitly to get an independent review.
4
4
  * The top-level `type` is REQUIRED and must be exactly "code" or "design"
5
5
  * (F30 fail-closed — no silent default; ADVISOR-GUARDS.md §2.4).
6
- * AGENT-LOOP-ASYNC-POOL.md §6.10 (R13 — async advisor): at depth 0 the review launches into the
7
- * background pool by DEFAULT (async:true / omitted; async:false forces the
8
- * blocking review); depth>0 (eng-coder self-review) stays synchronous always.
6
+ * AGENT-LOOP-ASYNC-POOL.md §6.10 (R13 — async advisor): `async` is REQUIRED — `true` launches the
7
+ * review into the background pool at depth 0, `false` forces the blocking review (omitting it is
8
+ * refused: a default here would decide for the caller); depth>0 (eng-coder self-review) stays
9
+ * synchronous always.
9
10
  */
10
11
  import { runAdvisorReview, advisorIncompleteMarker, ADVISOR_LAUNCH_REFUSAL_PREFIX } from "../advisor/run.mjs"
11
- import { readFileSync } from "node:fs"
12
- import { countRoundBlocks } from "./batch-skeleton.mjs"
13
12
  import { resolveBatchDocPath } from "./batch.mjs"
14
13
  // 设计评审的文档受理面单源 = review-facts.mjs 的 resolveReviewDocPaths(判据正文 =
15
14
  // docs/core/design/ADVISOR-GUARDS.md §12:相对形按会话项目根 / 绝对形照用 / 受理 = 项目内现存 `.md`)。
@@ -37,21 +36,8 @@ import { DESC } from "../tools/shared.mjs"
37
36
  export { validateDesignToken } from "./advisor-async.mjs"
38
37
 
39
38
  /**
40
- * §3 点火基线(`docs/core/design/ADVISOR-GUARDS.md` §1.1 判据 1):绑了批档 ⇒ 记下点火时该档 §3
41
- * 已有的轮次块数(块计数单源 = `countRoundBlocks`);未绑 / 读不到 ⇒ `null`——读不到不等于
42
- * 「没有记录要验」,结算面的 §3 落地门据此判 `batch-unreadable`。每轮发起刷新:同一实例的修轮
43
- * 是新的一轮,基线随之推进(否则上一轮留下的块会让本轮一字未写也过门)。
39
+ * `batchDoc` 缺失形态(缺失 ∥ `null` ∥ 空串 ∥ 纯空白——非字符串不在此判,留给 `resolveBatchDocPath` 的既有文案)。
44
40
  */
45
- function section3BlocksBaseline(batchDocAbs) {
46
- if (typeof batchDocAbs !== "string" || !batchDocAbs) return null
47
- try {
48
- return countRoundBlocks(readFileSync(batchDocAbs, "utf8"), 3)
49
- } catch {
50
- return null
51
- }
52
- }
53
-
54
- /** `batchDoc` 缺失形态(缺失 ∥ `null` ∥ 空串 ∥ 纯空白——非字符串不在此判,留给 `resolveBatchDocPath` 的既有文案)。 */
55
41
  function missingBatchDoc(raw) {
56
42
  return raw === undefined || raw === null || (typeof raw === "string" && raw.trim() === "")
57
43
  }
@@ -113,14 +99,14 @@ export const advisorTool = {
113
99
  type: { type: "string", enum: ["code", "design"], description: "Review type (required): 'design' for design doc review, 'code' for code review. Omitting it is refused — there is no default." },
114
100
  async: {
115
101
  type: "boolean",
116
- description: "Background review: default at depth 0 = true (ack now, report via digest); async:false forces the blocking review. depth>0 → always sync.",
102
+ description: "Background review: Required — `true` = review in the background (ack now, report via digest); `false` = the blocking review; omitting it is refused. depth>0 → always sync: an explicit `async: true` there is refused.",
117
103
  },
118
104
  object: {
119
105
  type: "object",
120
106
  properties: {
121
107
  type: { type: "string", description: "Review type as declared by the caller (design/code)" },
122
108
  target: { type: "string", description: "Review target — document + section, or file(s)" },
123
- status: { type: "string", description: "Object state: 待评审 / 已批准 / 已实现 (pending-review / approved / implemented)" },
109
+ status: { type: "string", description: "Object state: pending-review / approved / implemented" },
124
110
  reason: { type: "string", description: "Why this review runs: user-initiated / delivery verification" },
125
111
  exclude: { type: "string", description: "Explicit exclusion list — approved/implemented items NOT in this review" },
126
112
  },
@@ -134,11 +120,11 @@ export const advisorTool = {
134
120
  documents: {
135
121
  type: "array",
136
122
  items: { type: "string" },
137
- description: "Doc paths to review (design / requirements / referenced docs). One rule: a relative path resolves against the session project root (e.g. docs/core/design/ADVISOR-GUARDS.md); an absolute path is used as-is. Accepted = an existing .md file anywhere inside a project (a repo-root doc such as METHODOLOGY.md counts); anything else is refused with the resolved path, the reason, and the two expected forms. The advisor reviews ONLY these — no git diff scan. Use for both review types to pass the task's docs list.",
123
+ description: "Doc paths to review (design / requirements / referenced docs). One rule: a relative path resolves against the session project root (e.g. docs/<area>/<name>.md); an absolute path is used as-is. Accepted = an existing .md file anywhere inside a project (a repo-root doc counts); anything else is refused with the resolved path, the reason, and the two expected forms. The advisor reviews ONLY these — no git diff scan. Use for both review types to pass the task's docs list.",
138
124
  },
139
125
  batchDoc: {
140
126
  type: "string",
141
- description: "Design review only, REQUIRED: the batch record this review belongs to — the reviewer then also gets the `batch` write channel to record its findings + verdict. A design review without it is refused at launch (a token with no batch has no closer); a path that does not resolve to a readable file is refused. Relative paths resolve against the session cwd first, then candidate project roots (project-root-relative e.g. <repo>/docs/batches/…, or absolute). Code reviews do not pass it.",
127
+ description: "Optional: the batch record this review belongs to. Carrying it binds the review to that record on either track. On a design review the settlement writes the round's block into that record's §3 (tool stamp + a settlement header line + the review verbatim) in the same stroke that decides the token, and the reviewer gets no batch tool in engineering mode; a code review bound to a record keeps the §3 write channel (there is no settlement to write for it), and so does a reviewer in normal mode. A design review that omits it is refused at launch (a token with no batch has no closer); a path that does not resolve to a readable file is refused. Relative paths resolve against the session cwd first, then candidate project roots (project-root-relative e.g. <repo>/docs/batches/…, or absolute). A tool-face batch — delivered files are scripts / tests / CI, no design doc — runs on the code track and passes this same parameter together with `paths` = the delivered files.",
142
128
  },
143
129
  },
144
130
  required: ["type"],
@@ -168,6 +154,12 @@ export const advisorTool = {
168
154
  })
169
155
  }
170
156
  const reviewType = args.type
157
+ // §6.10 (R13):`async` 必填——**参数级拒判放在类型门之后、账链门之前**(缺参不该先花一次台账查;
158
+ // 也不该让“先补另一个参数”成为模型的下一步)。depth 不再替调用方选。
159
+ if (args.async !== true && args.async !== false) {
160
+ if (ctx._toolCallId !== undefined) (agent._advisorRefusals ??= new Set()).add(ctx._toolCallId)
161
+ return "Advisor: async is required — pass true for the background review or false for the blocking review. Nothing was sent: no review instance, no round consumed, no design token minted, no LLM call."
162
+ }
171
163
  // 准入门:`type="design"` 且 `batchDoc` 缺失 / 空 ⇒ 拒发(判据与拒文 = `docs/core/design/ADVISOR-GUARDS.md`
172
164
  // §2 第 6 条);「携了须可读」那半幅随账链门(下段)一并判——判据与文案仍单源 `resolveBatchDocPath`。
173
165
  // 绑定落 `resolved.run`(评审实例键)。
@@ -191,7 +183,8 @@ export const advisorTool = {
191
183
  // 评审照发、token 照签,收口时重锚不到任何行。
192
184
  // 批档绝对路径在本门就要用 ⇒ `resolveBatchDocPath` 从绑定行提前到此处调一次(绑定行复用同值,不二次解析);
193
185
  // 携了不可读 ⇒ 走其既有 throw(顺序表第 3 行:可读是账链的前提,前提坏先报前提)。
194
- // 代码评审不走本门(绑定行对 `type="code"` 仍走原解析——行为零变)。
186
+ // 代码评审不走本门(账链门仍只判设计轨——代码轨不签 token,没有可关之物)。绑定面则与轨无关:
187
+ // 携 `batchDoc` 即在绑定行落 `resolved.run.batchDoc`(判据单源 = `docs/core/design/BATCH-LEDGER-REVIEW-UNIFY.md` §2.15)。
195
188
  let designBatchDocAbs = null
196
189
  if (reviewType === "design") {
197
190
  designBatchDocAbs = resolveBatchDocPath(agent.cwd, args.batchDoc)
@@ -234,7 +227,7 @@ export const advisorTool = {
234
227
  const cands = [...new Set(invalid.flatMap((v) => v.candidates ?? []))]
235
228
  if (cands.length > 0) lines.push(`Candidates: ${cands.join(" ∥ ")} — pass one explicitly (an absolute path is the surest form).`)
236
229
  }
237
- lines.push("Expected form 1 — project-root-relative: docs/core/design/ADVISOR-GUARDS.md (resolved against the session project root).", "Expected form 2 — absolute: D:\\repo\\docs\\core\\design\\ADVISOR-GUARDS.md (used as-is).")
230
+ lines.push("Expected form 1 — project-root-relative: docs/<area>/<name>.md (resolved against the session project root).", "Expected form 2 — absolute: D:\\repo\\docs\\<area>\\<name>.md (used as-is).")
238
231
  return withIdentityLine(
239
232
  `Advisor: design review documents must be documentation files (per the project's conventions). Invalid:\n${lines.join("\n")}`,
240
233
  { type: reviewType, scope: scopeSummary(documents), round: "—", criterion: "scope-not-doc" },
@@ -242,41 +235,35 @@ export const advisorTool = {
242
235
  }
243
236
  }
244
237
 
245
- // §6.10 (R13 — ruling ②-3 A): async gate. Depth-0 defaults to the
246
- // background pool; depth>0 (eng-coder internal self-review) is ALWAYS sync —
247
- // an explicit async:true there is rejected, the default never flips.
248
- // depth 显式校验(归一形态——判定单点:`depth` 取一次 + `asyncRequested` 显式布尔,
249
- // 判定表与原逐值等价):
250
- // depth 0 + 未传/true ⇒ 异步(本层默认)/ depth 0 + false ⇒ 同步;
251
- // depth>0(或直调方无 depth) + 显式 true ⇒ 拒;其余 ⇒ 同步。
252
- // 「无 depth」= 无 dispatch 上下文的直调方(测试/legacy)——按同步处理。
238
+ // §6.10 (R13 — ruling ②-3 A):depth 0 可异步、depth>0 一律同步——显式 `async:true` 在那里被拒
239
+ // (判据不变)。“无 depth” = 无 dispatch 上下文的直调方(测试/legacy)——按同步处理。
253
240
  const depth = ctx?.depth ?? null
254
241
  const asyncRequested = args.async === true
255
242
  if (asyncRequested && depth !== 0) {
256
243
  // 拒发登记(与 cap/池满拒同款):评审未跑——不置 called/不耗轮次(record-results
257
244
  // 的 REFUSED 契约——advisor 评审发现 #1:拒发不得静默满足 guard)。
258
245
  if (ctx._toolCallId !== undefined) (agent._advisorRefusals ??= new Set()).add(ctx._toolCallId)
259
- return "Advisor: async reviews are only available at depth 0 — the top-level session owns the background pool; inside a child (eng-coder self-review) reviews run synchronously. Call advisor again without async:true (or with async:false)."
246
+ return "Advisor: async reviews are only available at depth 0 — the top-level session owns the background pool; inside a child (eng-coder self-review) reviews run synchronously. Call advisor again with async:false."
260
247
  }
261
- const isAsync = asyncRequested || (depth === 0 && args.async !== false)
248
+ const isAsync = asyncRequested
262
249
 
250
+ // BATCH-RECORD.md §4.2 评审侧批次档绑定(判据单源 = `docs/core/design/BATCH-LEDGER-REVIEW-UNIFY.md` §2.15):
251
+ // 绑定值在**发起时点取一次**,随后随 launch 载荷一路传下去(异步 = 条目 `batchDoc` 字段,同步 = callbacks)。
252
+ // 为什么不能在启动时读活字段:`resolved.run` 是实例级对象(代码轨续用同一实例)——发起①携 A 排队、
253
+ // 发起②携 B 覆盖同一字段,槽释放后①启动读到 B,评审就把裁定写进一本它没被指派的档。
254
+ // 不携即清:这一笔不携档(缺 / null / 空串 / 纯空白)⇒ null,不继承上一笔(静默继承比没有绑定更坏)。
255
+ // 位置 = 实例解析之前:路径不可读 ⇒ 在建实例与记账镜之前就炸(本档不变量「零实例 / 零 token / 零槽」)。
256
+ const launchBatchDoc = missingBatchDoc(args.batchDoc)
257
+ ? null
258
+ // 设计评审的绝对路径由账链门那一段算好(`designBatchDocAbs`——不二次解析);代码评审仍走原解析。
259
+ : designBatchDocAbs ?? resolveBatchDocPath(agent.cwd, args.batchDoc)
263
260
  // Per-review instance resolution (§6.10 ③ — ruling ②-5 A): fix rounds
264
261
  // continue the same reviewId (design = the doc-set instance's designId —
265
262
  // slot/spawn continuity; code = the newest OPEN instance). The resolution
266
263
  // scopes agent._advisorRound/_lastAdvisorOutput so the message builder and
267
264
  // the run.mjs cap read THIS instance's round/prior (multi-review isolation).
268
265
  const resolved = resolveAdvisorLaunch(agent, reviewType, { documents })
269
- // BATCH-RECORD.md §4.2 评审侧批次档绑定(评审实例的唯一路径来源):准入面与账链门已保证设计评审的
270
- // `batchDoc`(判据 = `docs/core/design/ADVISOR-GUARDS.md` §2 第 6 ∥ 7 条),本段只剩绑定落 `resolved.run`
271
- // (评审实例键,与 reviewType/round/designId 同族)——并发设计评审各绑各档,不用单值会话态
272
- // (BATCH-RECORD.md §4.7 #6)。
273
- if (args.batchDoc !== undefined && args.batchDoc !== null) {
274
- // 设计评审的绝对路径由账链门那一段算好(`designBatchDocAbs`——不二次解析);代码评审仍走原解析。
275
- resolved.run.batchDoc = designBatchDocAbs ?? resolveBatchDocPath(agent.cwd, args.batchDoc)
276
- }
277
- // §3 点火基线(ADVISOR-GUARDS.md §1.1 判据 1):结算面判「§3 已被本轮写过」需要「本轮之前有几块」
278
- // 这个点——只在点火拍可得(结算时再读只能得到「现在有几块」)。两轨同源(`run` 由池条目透传)。
279
- resolved.run.section3BlocksAtStart = section3BlocksBaseline(resolved.run.batchDoc)
266
+ resolved.run.batchDoc = launchBatchDoc
280
267
  // Design token minted for EVERY design round — the reviewer echoes it only on
281
268
  // a clean pass; on pass it is slotted under the instance's designId at settle
282
269
  // (sync: right here; async: the settle callback — fix #2). A NEW instance
@@ -293,6 +280,8 @@ export const advisorTool = {
293
280
  const ack = launchAsyncAdvisor(agent, ctx, {
294
281
  reviewType, documents, paths, object: reviewObject,
295
282
  designToken, designId, run: resolved.run,
283
+ // 逐笔绑定快照:条目持此值,`entry.start()` 不再读活的 `run.batchDoc`(排队窗口的值会被后一笔覆盖)。
284
+ batchDoc: launchBatchDoc,
296
285
  })
297
286
  if (ack.error) {
298
287
  // Pool-full refusal (②-6a — no queueing): the review did NOT launch — the
@@ -336,8 +325,8 @@ export const advisorTool = {
336
325
  const result = await runAdvisorReview(agent, reviewType, {
337
326
  onOutput: ctx.onOutput,
338
327
  signal: ctx.signal,
339
- // 同步路径的实例绑定传递(异步路径由池条目 run.batchDoc 取——run.mjs 自行解析)。
340
- batchDoc: resolved.run.batchDoc ?? null,
328
+ // 同步路径的绑定传递 = 同一逐笔值(异步路径走条目 `batchDoc` 字段,同值同形)。
329
+ batchDoc: launchBatchDoc,
341
330
  }, designToken, documents, paths, reviewObject, designId)
342
331
 
343
332
  // B 启动拒绝(稳定前缀):拒发登记(同池满 / cap 款——不置 called、不耗轮次),
@@ -42,7 +42,7 @@
42
42
  * `../log.mjs`——叶子向、无环。
43
43
  */
44
44
  import { carrierField, getAsyncPool, parentAborted, writeTombstone } from "./async-settle.mjs"
45
- import { pushReal } from "../context.mjs"
45
+ import { pushInject, pushRecord } from "../context.mjs"
46
46
  import { escapeXml } from "../agent/helpers.mjs"
47
47
  import { logEvent } from "../log.mjs"
48
48
  // #9(后台 bash 任务族——收尾档②):杀单点(树杀)经 `bash-async.mjs` 落面。
@@ -127,7 +127,12 @@ function discardRole(parent, spec, ctx) {
127
127
  // `pushReal`(机器 + 人读双线);**history 数组本体形**(VSC 挂起载体——池挂数组)无注入目标 ⇒
128
128
  // 跳过(与对侧 VSC copy 的 `parent?.history` 守卫同判;§6.20.1「carrier 形无注入目标」先例)
129
129
  // ——墓碑与 `ev:discarded` 照发,仅模型可见提醒缺席(数组形无人读线可达面)。
130
- if (parent?.history) pushReal(parent, { role: "user", content: spec.reminder(out.discarded.length, escapeXml(list)) })
130
+ if (parent?.history) {
131
+ const msg = { role: "user", content: spec.reminder(out.discarded.length, escapeXml(list)) }
132
+ // B 段:一次性投递走待发队,持久写入只落人读线。
133
+ pushInject(parent, msg)
134
+ pushRecord(parent, msg)
135
+ }
131
136
  logEvent("ev:discarded", { n: out.discarded.length, ids: out.discarded.map((d) => `${d.role}#${d.id}`).join(", ") })
132
137
  return out
133
138
  }
@@ -23,7 +23,7 @@
23
23
  * escalate-async/consult)单向 import 本模块;scheduler 反向 import 本模块(getAsyncPool)
24
24
  * 与既有 scheduler ↔ subagent-async 同款惰性环——无求值期依赖。
25
25
  *
26
- * S1 续轮第二批(2026-09-14——异步机械族 VSC 侧并入,AGENT-LOOP.md §2.3 载体口径):
26
+ * S1 续轮第二批(2026-09-14——异步机械族 VSC 侧并入,AGENT-LOOP.md §9.1 载体字段):
27
27
  * - #94 载体吸收:`carrierField`(父对象字段优先 / 回退 `history`——VSC 形跨 runAgent
28
28
  * 载体)+ 墓碑三函数单点(`writeTombstoneTo` / `writeTombstone` / `tombstoneOf`,
29
29
  * 原核内 3 处 inline 写全部收口);`getAsyncPool` / `parkAsyncPending` 走吸收。
@@ -31,19 +31,19 @@
31
31
  * `bindChildController` = 链结单点(原 4 处逐字同构,interrupt 不逐链中止)。
32
32
  */
33
33
  import { logEvent, errText } from "../log.mjs"
34
- import { pushReal } from "../context.mjs"
34
+ import { pushInject, pushRecord } from "../context.mjs"
35
35
  import { escapeXml } from "../agent/helpers.mjs"
36
36
  import { TURN_CAP_MARK } from "../agent/spawn-child.mjs"
37
37
  import { dependentLabels, maybeRefillAsync, refreshQueuedTokens } from "./subagent-scheduler.mjs"
38
38
  // ED-4(2026-09-16):advisor 排队补位——同 scheduler ↔ 本模块惰性环(函数声明提升——无求值期依赖)
39
39
  import { refillAdvisorQueue } from "./advisor-async.mjs"
40
40
 
41
- // ─── #94 载体吸收(VSC 侧并入——AGENT-LOOP.md §2.3 载体五字段)───────────────
41
+ // ─── #94 载体吸收(VSC 侧并入——AGENT-LOOP.md §9.1 载体字段)───────────────
42
42
 
43
43
  /**
44
44
  * 载体字段读取吸收(#94——「VSC 的跨 runAgent 存活载体面按核内结构归一」):
45
- * §2.3 载体口径 = `_asyncSubagents` · `_asyncAdvisors` · `_consultSessions` ·
46
- * `_pendingAsyncResults` · `_suspended`(AGENT-LOOP.md §2.3 seam 表);#9 后台任务池
45
+ * §9.1 载体口径 = `_asyncSubagents` · `_asyncAdvisors` · `_consultSessions` ·
46
+ * `_pendingAsyncResults` · `_suspended`(AGENT-LOOP.md §9.1);#9 后台任务池
47
47
  * `_bgTasks` 同列(写侧父字段 + 借用/别名 history——见 `bash-async.mjs` `ensureBgPool`)。
48
48
  * CLI 形:字段直接挂 agent(跨 run 存活);VSC 形:字段挂 depth-0 `history`
49
49
  * (agent per-run 重建——run 起始把 history 容器绑到 agent 字段,绑定不变式)。
@@ -171,7 +171,7 @@ export function buildChildSignal(parent, ctx) {
171
171
  // ─── D3 settle 共享 helper ───────────────────────────────────────────────────
172
172
 
173
173
  /**
174
- * AGENT-LOOP.md §6.15 消化窗口持有释放(TUI-OOM-ROOTCAUSE——D-SM2 表 2 候选 1):注入完成后置空条目
174
+ * AGENT-LOOP.md §9 消化窗口持有释放(TUI-OOM-ROOTCAUSE——D-SM2 表 2 候选 1):注入完成后置空条目
175
175
  * 对子代理对象的引用(`childAgent`/`report`——条目前此从不显式释放,挂起期 = 分钟级驻留)。
176
176
  * 幂等(重入不抛);池内/挂起未消化窗口语义零变(settle 时刻不释放——表 2 候选 2 否决:
177
177
  * status/observe 在窗口内仍读 child 摘要)。三消费点(回合尾收集 / run 起始 pending 注入 /
@@ -267,25 +267,31 @@ export function settleAsyncEntry(parent, entry, opts = {}) {
267
267
  ctx?.callbacks?.onToken?.(`${entry.relayPrefix}⟦ev⟧stopped\x1e0\x1e0\x1estopped\x1e`)
268
268
  if (role === "advisor") {
269
269
  // ②-6b:评审取消——token 未签发提醒(settleAdvisorRun 不消费预算)。
270
- pushReal(parent, {
270
+ const msg300 = {
271
271
  role: "user",
272
272
  content: `[System reminder: async advisor review #${escapeXml(String(entry.id))} cancelled — the review did not settle; token not issued (评审已取消——token 未签发)]`,
273
- })
273
+ }
274
+ pushInject(parent, msg300)
275
+ pushRecord(parent, msg300)
274
276
  } else if (role === "escalate") {
275
- pushReal(parent, {
277
+ const msg275 = {
276
278
  role: "user",
277
279
  content: `[System reminder: async escalate #${entry.id} (${entry.tag}) cancelled by user — partial changes not merged/audited]`,
278
- })
280
+ }
281
+ pushInject(parent, msg275)
282
+ pushRecord(parent, msg275)
279
283
  } else {
280
284
  // §6.9 D-SD5:running 依赖取消——提醒列出依赖者(供模型决策)。
281
285
  const dependents = dependentLabels(parent, String(entry.id))
282
286
  const autoNote = parent.autoApprove
283
287
  ? " — AUTO session: they auto-start on slot availability (round2 #3)"
284
288
  : " — they stay queued until you cancel them or an AUTO session starts them"
285
- pushReal(parent, {
289
+ const msg285 = {
286
290
  role: "user",
287
291
  content: `[System reminder: subagent ${escapeXml(role)}#${entry.id} cancelled by user — partial changes not merged/audited${dependents.length > 0 ? `; queued dependents ${dependents.join(", ")} marked "dependency cancelled"${autoNote}` : ""}]`,
288
- })
292
+ }
293
+ pushInject(parent, msg285)
294
+ pushRecord(parent, msg285)
289
295
  }
290
296
  } else if (!aborted) {
291
297
  // 族记账 hook(advisor 陈旧判定/token D1 落盘;escalate 三分类 merge 决策;subagent/
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * audit-block.mjs — 审计块构造器(AGENT-LOOP-SUBAGENT.md §6.26 · 台账 #23)。
3
3
  *
4
- * 自 `subagent-spawn.mjs` **逐字搬移**(D23-3 外提:spawn 档越 300 软线 + 块构造成纯函数
4
+ * 自 `subagent-spawn.mjs` **逐字搬移**(D23-3 外提:spawn 档越 300 行线 + 块构造成纯函数
5
5
  * ⇒ 判据可直测;D23-4:块内文本零改——含块内自指词,整块搬移不改真值)。本档承载
6
6
  * spawn 级固定机制性指令的第二块(审计模板 + 批档 §2 指向 + touched 快照):
7
7
  * 装配侧只收集(`thincoder-core/agent-tools/subagent-spawn.mjs`),下发面 = system 固块
8
8
  * (`child._spawnSystemBlock` → 核 `prepareRun` 拼接——`thincoder-core/agent/setup.mjs`)。
9
9
  *
10
- * 2026-10-24(§6.22 KD-SC6):任务书 = 批次档 §2(子代理自读);A2 拼装摘要面(按 marker 抽取
10
+ * 2026-10-24(§6.22 KD-SC6):任务书 = 绑定批档,按角色切片(§8.1 现行;本块只引交付任务书 = §2);A2 拼装摘要面(按 marker 抽取
11
11
  * 设计档 / 文件清单 / 验收三段)已随 KD-SC6 删除——审计块只注入批档路径行 + §2 指向句(路径取
12
12
  * `ctx.agent._batchDoc`)。理由:工程角色 `_engTaskInput` 只剩一行机械文本,摘要失去来源。
13
13
  */
@@ -37,7 +37,7 @@ export function buildAuditBlock(ctx) {
37
37
  `workspace changes not listed there are unrelated to this delivery and are NOT grounds for an out-of-list finding.\n` +
38
38
  `Scope discipline (F-TS6 A1): read ONLY the audited files and the design-doc sections relevant to this delivery — do NOT re-read whole documents.\n` +
39
39
  `Every deviation item MUST be fieldized: file:line + design reference (doc path + section/AC id) + severity + evidence (quoted code or doc text).\n` +
40
- // §6.22 KD-SC6:任务书 = 批次档 §2(审计子代理自读)——审计块注入批档路径 + §2 指向句
40
+ // §6.22 KD-SC6:任务书 = 绑定批档,按角色切片(§8.1)——审计块注入批档路径 + 交付任务书 §2 的指向句
41
41
  // (A2 拼装摘要面已删:工程角色 _engTaskInput = 一行机械文本,摘要无来源)。审计子代理本身是
42
42
  // explore(任务书 = 父侧五项)——故指向句限定为「**交付**的任务书 = §2」,不冒称本 child 的唯一通道。
43
43
  `Batch record (batchDoc): ${batchDoc}\n` +
@@ -49,9 +49,9 @@ export function buildAuditBlock(ctx) {
49
49
  "Zero-git scope authority: this audit task receives NO git context — nothing is injected. " +
50
50
  "The evidence base is the design documents, the current disk state (read/glob/grep), and the _touchedFiles list above. " +
51
51
  "Workspace changes NOT listed in _touchedFiles are unrelated to this delivery — they are NOT grounds for an out-of-file-list finding." +
52
- // §6.7.6 D-A1.2:审计预算句——A1 指令模板 + 批档指向块之后、A3 报告模板之前(定序——评审 #7)。
53
- // 逐字设计锚(D-A1.2 代码块):只读该读的——10 轮机械预算——超时报 PROBLEM 下结论。
54
- // 前导 \n 与 A3 同款块分隔约定(上一句 Zero-git 句末无换行——不触碰既有句)。
52
+ // §6.7.6(AGENT-LOOP-SUBAGENT.md):审计预算句——审计指令模板 + 批档指向块之后、审计报告模板之前(定序——评审 #7)。
53
+ // 逐字设计锚(§6.7.6 的「审计效率」行):只读该读的——10 轮机械预算——超时报 PROBLEM 下结论。
54
+ // 前导 \n 与审计报告模板同款块分隔约定(上一句 Zero-git 句末无换行——不触碰既有句)。
55
55
  `\n[Audit budget — mechanical]: read ONLY the touched files listed above and the design-doc sections the parent task book names (affected-files table, acceptance criteria, status line). Do NOT read whole documents. Budget = 10 tool rounds max — if you cannot conclude within it, report PROBLEM (inconclusive) rather than continuing to explore.\n` +
56
56
  // §6.7.6 D-TS6 A3:审计输出报告格式模板(三态——字段化行——不让模型自由发挥)。
57
57
  `\n[Audit report format — mechanical template:]\n` +
@@ -35,7 +35,7 @@ import { join } from "node:path"
35
35
  import { spawn } from "node:child_process"
36
36
  import { configDir } from "../config.mjs"
37
37
  import { cleanupOldToolResults, escapeXml } from "../agent/helpers.mjs"
38
- import { pushReal } from "../context.mjs"
38
+ import { pushInject, pushRecord } from "../context.mjs"
39
39
  import { makeDecoder, sanitizeOutput } from "../tools/shared.mjs"
40
40
  import { killProcessTree } from "../tools/process-tree.mjs"
41
41
  // 过程档标记(TOOLS.md §6.28):后台径的结算摘要也是输出行——解析基准 = entry 记下的 spawn 局部 `cwd`。
@@ -247,7 +247,10 @@ export async function injectBgResult(parent, entry) {
247
247
  const { text, truncated } = renderTail(entry)
248
248
  const body = text.trim() ? escapeXml(text) : "(no output)"
249
249
  const note = truncated ? `\n[... tail truncated — the full output is in the log: ${entry.logPath}]` : ""
250
- pushReal(parent, { role: "user", content: `${head}\n${body}${note}` })
250
+ const msg = { role: "user", content: `${head}\n${body}${note}` }
251
+ // B 段:一次性投递走待发队,持久写入只落人读线(机读线零触)。
252
+ pushInject(parent, msg)
253
+ pushRecord(parent, msg)
251
254
  writeTombstone(parent, entry.id, entry.error != null ? "failed" : "consumed", "bg")
252
255
  }
253
256