@tea-agent/loop-agent 0.52.0 → 0.53.0-next.2

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 (148) hide show
  1. package/CHANGELOG.md +62 -4
  2. package/dist/build-stamp.json +3 -3
  3. package/dist/executors/dag-pi/plan/finalize-tools.js +13 -0
  4. package/dist/executors/dag-pi/plan/record-tools.js +37 -11
  5. package/dist/executors/dag-pi/sessions/plan-batches.js +1 -1
  6. package/dist/executors/dag-pi/sessions/segmented-plan.js +28 -20
  7. package/dist/executors/dag-pi/tools/plan-decision-tools.js +2 -1
  8. package/dist/executors/dag-pi-executor.js +50 -5
  9. package/dist/executors/pi-executor.js +12 -0
  10. package/dist/executors/pi-sdk-executor.js +2 -2
  11. package/dist/shared/frontend-execution-policy.js +28 -2
  12. package/dist/shared/pi-context-pressure/compaction-policy.js +22 -34
  13. package/dist/shared/pi-context-pressure/index.js +1 -1
  14. package/dist/task/config-types.js +2 -2
  15. package/dist/task/source-prepare/prepare.js +1 -1
  16. package/dist/task/source-prepare/semantic-intake.js +2 -2
  17. package/dist/task/source-prepare/source-fidelity-pi.js +2 -1
  18. package/dist/worker/console/automation-actions.js +62 -7
  19. package/dist/worker/console/chat/api-workbench-core.js +131 -4
  20. package/dist/worker/console/chat/api-workbench-schema.js +278 -0
  21. package/dist/worker/console/chat/api-workbench-spring.js +333 -0
  22. package/dist/worker/console/chat/api-workbench.js +88 -2
  23. package/dist/worker/console/chat/human-gate-card.js +16 -1
  24. package/dist/worker/console/chat/image-cache.js +39 -8
  25. package/dist/worker/console/chat/pi-runtime/custom-tools/apiworkbench-tools.js +120 -5
  26. package/dist/worker/console/chat/pi-runtime.js +2 -3
  27. package/dist/worker/console/chat/provider-error.js +12 -2
  28. package/dist/worker/console/chat/repo-walk.js +8 -0
  29. package/dist/worker/console/chat/routes.js +125 -13
  30. package/dist/worker/console/chat/todo-diff.js +90 -0
  31. package/dist/worker/console/chat/turn-process.js +3 -0
  32. package/dist/worker/console/network-proxy-settings.js +67 -1
  33. package/dist/worker/console/operator-actions.js +25 -0
  34. package/dist/worker/console/pi-compaction-settings.js +16 -13
  35. package/dist/worker/console/server.js +20 -0
  36. package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-CR1jj_rz.js → abnfDiagram-N423BO3Z-9YdcTSkA.js} +1 -1
  37. package/dist/worker/console/static/assets/{arc-CjxcQfEu.js → arc-5o9a24RM.js} +1 -1
  38. package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-D-3u2qFL.js → architectureDiagram-T3A2C74G-kk-Y4K8w.js} +1 -1
  39. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bdr7gWVo.js → blockDiagram-VBNYF7ZC-BuMyp-i-.js} +1 -1
  40. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-hQHNe5T3.js → c4Diagram-5PPSVZJV-BnAbUXQM.js} +1 -1
  41. package/dist/worker/console/static/assets/channel-DzpJs7JM.js +1 -0
  42. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-BEg_su6q.js → chunk-2GRJ4B5K-sQ2VjuFx.js} +1 -1
  43. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-DZnV6VTC.js → chunk-2Q5K7J3B-CbkqzTV8.js} +1 -1
  44. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Dg0LzAqO.js → chunk-5RXB4S5H-CaP8JTC3.js} +1 -1
  45. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-D2vqr52W.js → chunk-5VM5RSS4-D7yUFtwu.js} +1 -1
  46. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D8We_g6R.js → chunk-6Q2QTUOP-zowLlgmO.js} +1 -1
  47. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-DbEU8drD.js → chunk-GF5L2VYU-KGzLFdSC.js} +1 -1
  48. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-Boi8TJYN.js → chunk-JWPE2WC7-DuVIxg_I.js} +1 -1
  49. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CjJmKa9f.js → chunk-KBJHAD2P-CXP8iZrQ.js} +1 -1
  50. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-C-KV-ag7.js → chunk-RYQCIY6F-DASfOCYV.js} +1 -1
  51. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DZlTonsZ.js → chunk-XXDRQBXY-DFwLDf-r.js} +1 -1
  52. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-ClK7LSSv.js +1 -0
  53. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-ClK7LSSv.js +1 -0
  54. package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-BIvFe3yn.js → cose-bilkent-JH36ORCC-CIrJSuNM.js} +1 -1
  55. package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-BOBPfv8u.js → cynefinDiagram-MW4NZA55-BrI5M-XP.js} +1 -1
  56. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BF54orLO.js → dagre-VZM6K2ZE-BEJlUQi2.js} +1 -1
  57. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-CxjAP2AP.js → diagram-7IWD3JNH-Buw7nAqS.js} +1 -1
  58. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-BXYkuNGt.js → diagram-B4RE2ZJO-DHURLBbb.js} +1 -1
  59. package/dist/worker/console/static/assets/{diagram-LBJQPF4R-DQTu-2Iy.js → diagram-LBJQPF4R-CEFuptxk.js} +1 -1
  60. package/dist/worker/console/static/assets/{diagram-Q27KOJAE-DNURuIYc.js → diagram-Q27KOJAE-Cejgl71p.js} +1 -1
  61. package/dist/worker/console/static/assets/{diagram-UB23O5K3-D69uANY8.js → diagram-UB23O5K3-Bwxq3Xoa.js} +1 -1
  62. package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-C658EcrV.js → ebnfDiagram-BXEA7PRR-i4NNenm0.js} +1 -1
  63. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-BRccYtAl.js → erDiagram-JOGREHBK-BaSp03BR.js} +1 -1
  64. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-DnIR4sLs.js → flowDiagram-UKHOOZJN-CQtgCCPg.js} +1 -1
  65. package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Bo3eWFVC.js → ganttDiagram-PKOTCBZU-DkS9Vbt8.js} +1 -1
  66. package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-EyWDCNU_.js → gitGraphDiagram-DS77QQ5N-Dm64UQgY.js} +1 -1
  67. package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-B0Eld9u0.js → infoDiagram-6WML65LV-BpcLrRRV.js} +1 -1
  68. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DsJQiJ27.js → ishikawaDiagram-WSZJBQD7-DFjxaE3Q.js} +1 -1
  69. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-fpE0yqjC.js → journeyDiagram-NVQOT4AX-G6kuLGYK.js} +1 -1
  70. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-Dq9IrDdT.js → kanban-definition-27J2QSJJ-DistDdnp.js} +1 -1
  71. package/dist/worker/console/static/assets/{linear-CFV4BDyf.js → linear-Cadcj4Jf.js} +1 -1
  72. package/dist/worker/console/static/assets/main-CKu0wCrM.js +654 -0
  73. package/dist/worker/console/static/assets/main-DpBoCiky.css +1 -0
  74. package/dist/worker/console/static/assets/{mermaid.core-BMMXqtrB.js → mermaid.core-CVqQBsGx.js} +4 -4
  75. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-DurrK_Gi.js → mindmap-definition-FAOFIHXS-oIAAXLn3.js} +1 -1
  76. package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-CzZayNy2.js → pegDiagram-VL7TDLO6-BgBPFLA0.js} +1 -1
  77. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-B1W7Y0cE.js → pieDiagram-7S7Q4E2Y-RTyZdL9S.js} +1 -1
  78. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BdbL83CU.js → quadrantDiagram-CIZ2JOQS-BHEYQMZx.js} +1 -1
  79. package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-W-bQpd18.js → railroadDiagram-AXF67PYL-B2JIrks2.js} +1 -1
  80. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-C9bi4tQJ.js → requirementDiagram-LRYGKXZP-TJ5_MWbY.js} +1 -1
  81. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-D4kO56Wd.js → sankeyDiagram-W5VNT64P-BzjUsr0j.js} +1 -1
  82. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CIbesK1e.js → sequenceDiagram-SI44F4Z6-DrmrPPVE.js} +1 -1
  83. package/dist/worker/console/static/assets/{sheet-workbook-kFN3yUBr.js → sheet-workbook-DCQgjy0Q.js} +1 -1
  84. package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-Dk4XAK7C.js → sizeCapture-X5ZJPWSS-BLp8F5fC.js} +1 -1
  85. package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-Bz9B6UZ7.js → stateDiagram-OKZ733FA-5MNm447q.js} +1 -1
  86. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-gP-t-MQJ.js +1 -0
  87. package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-qLEds93n.js → swimlanes-SLNWSIFB-Cs2RUkNq.js} +2 -2
  88. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-D6MJJUTV.js +8 -0
  89. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-C9rVFC0h.js → timeline-definition-Z64GVDOM-BoeTHoWc.js} +1 -1
  90. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-CoKJ9hU0.js → vennDiagram-T6HMQDX7-DFWej-Mm.js} +1 -1
  91. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-tHz_S7-L.js → wardleyDiagram-T6FBY63Y-BcD0_2m5.js} +1 -1
  92. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-DKzKYnvG.js → xychartDiagram-ELKLHX3M-y4PQYZiq.js} +1 -1
  93. package/dist/worker/console/static/index.html +2 -2
  94. package/dist/worker/console/static-src/markdown-incremental.js +138 -0
  95. package/dist/worker/console/static-src/operator-chat/automation-catalog-model.js +43 -0
  96. package/dist/worker/console/static-src/operator-chat/composer-drop.js +138 -0
  97. package/dist/worker/console/static-src/operator-chat/composer-image-paths.js +25 -5
  98. package/dist/worker/console/static-src/operator-chat/composer-image-preview.js +115 -0
  99. package/dist/worker/console/static-src/operator-chat/composer-session-ledger.js +44 -2
  100. package/dist/worker/console/static-src/operator-chat/composer-upload.js +115 -0
  101. package/dist/worker/console/static-src/operator-chat/gate-expiry.js +43 -0
  102. package/dist/worker/console/static-src/operator-chat/process-label.js +15 -2
  103. package/dist/worker/console/static-src/operator-chat/schedule-relative-time.js +54 -0
  104. package/dist/worker/console/static-src/operator-chat/schedule-rule-summary.js +213 -0
  105. package/dist/worker/console/static-src/operator-chat/tasks-model.js +4 -0
  106. package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +8 -0
  107. package/dist/worker/console/static-src/operator-chat/turn-process-disclosure.js +12 -0
  108. package/dist/worker/console/static-src/operator-chat/turn-state-projection.js +51 -0
  109. package/dist/worker/console/static-src/operator-chat/useChatStream.js +22 -2
  110. package/dist/worker/console/static-src/operator-chat/useChatThread.js +15 -1
  111. package/dist/worker/console/static-src/operator-chat/useComposer.js +290 -21
  112. package/dist/worker/console/static-src/operator-chat/useSessionAutomationCounts.js +98 -0
  113. package/dist/worker/console/static-src/pages/api-request-template.js +144 -0
  114. package/dist/worker/console/static-src/session-search-shortcut.js +38 -0
  115. package/dist/worker/console/version-notes-comparison.js +52 -0
  116. package/dist/worker/console/version-notes.js +16 -1
  117. package/dist/worker/console/workspace-context.js +10 -0
  118. package/dist/worker/observe/static/console-theme.css +50 -3
  119. package/dist/worker/observe/static/console-theme.js +86 -1
  120. package/dist/worker/scheduler/automation-across-workspaces.js +120 -0
  121. package/dist/workflows/dag/checkpoint.js +6 -1
  122. package/dist/workflows/dag/frontend-committed-facts.js +38 -5
  123. package/dist/workflows/dag/frontend-design-policy.js +22 -0
  124. package/dist/workflows/dag/frontend-implementation-contract.js +39 -12
  125. package/dist/workflows/dag/frontend-imported-run-artifacts.js +126 -0
  126. package/dist/workflows/dag/frontend-recovery-run.js +7 -110
  127. package/dist/workflows/dag/frontend-test-framework-adapters.js +14 -0
  128. package/dist/workflows/dag/frontend-verification-trace.js +20 -8
  129. package/dist/workflows/dag/frontend-writer-reuse.js +104 -0
  130. package/dist/workflows/dag/frontend-writer-status.js +0 -4
  131. package/dist/workflows/dag/hybrid/templates/frontend.js +15 -8
  132. package/dist/workflows/dag/init-hybrid.js +1 -1
  133. package/dist/workflows/dag/reconcile-run.js +11 -1
  134. package/dist/workflows/dag/recovery-lease.js +23 -0
  135. package/dist/workflows/dag/rerun-feedback.js +4 -2
  136. package/dist/workflows/dag/rerun-run.js +40 -0
  137. package/dist/workflows/dag/runner.js +11 -0
  138. package/dist/workflows/dag/terminal-status.js +2 -1
  139. package/docs/README.md +1 -0
  140. package/docs/operations/README.md +1 -0
  141. package/package.json +3 -3
  142. package/dist/worker/console/static/assets/channel-CBlJfald.js +0 -1
  143. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-mNUYCdDo.js +0 -1
  144. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-mNUYCdDo.js +0 -1
  145. package/dist/worker/console/static/assets/main-D-ZQ4gLb.css +0 -1
  146. package/dist/worker/console/static/assets/main-Dwhb3ZRq.js +0 -645
  147. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-BBRlxIq8.js +0 -1
  148. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CRBvOMCQ.js +0 -8
@@ -0,0 +1,52 @@
1
+ /** Compare documented list entries, never infer changes to the underlying code. */
2
+ export function compareNotesEntries(baseline, target) {
3
+ const parse = (body) => {
4
+ const entries = [];
5
+ let heading = "";
6
+ let entry;
7
+ for (const line of body.replaceAll("\r\n", "\n").split("\n")) {
8
+ if (!line.trim()) {
9
+ if (entry)
10
+ entry.text += "\n";
11
+ continue;
12
+ }
13
+ if (line === "本预发布快照记录构建时已整理的待发布变化,不表示相对上一构建全部新增。" || line === "未记录新增用户可见变化。")
14
+ continue;
15
+ if (/^### [^#]/.test(line)) {
16
+ heading = line.trimEnd();
17
+ entry = undefined;
18
+ continue;
19
+ }
20
+ // Complex Markdown stays intact in the full snapshot rather than being
21
+ // silently truncated or misrepresented as a reliable comparison.
22
+ if (/^\s*(?:`{3,}|~{3,})/.test(line))
23
+ return null;
24
+ if (/^[-*+] /.test(line)) {
25
+ entry = { heading, text: line.trimEnd() };
26
+ entries.push(entry);
27
+ }
28
+ else if (entry && /^ {2,}\S/.test(line))
29
+ entry.text += `\n${line.trimEnd()}`;
30
+ else
31
+ return null;
32
+ }
33
+ return entries.map(item => ({ ...item, text: item.text.trimEnd() }));
34
+ };
35
+ const oldEntries = parse(baseline), newEntries = parse(target);
36
+ if (!oldEntries || !newEntries)
37
+ return null;
38
+ const key = (item) => `${item.heading}\n${item.text.replace(/^[-*+] /, "- ")}`;
39
+ const previous = new Set(oldEntries.map(key));
40
+ const added = newEntries.filter(item => !previous.has(key(item)));
41
+ let heading = "";
42
+ const blocks = [];
43
+ for (const entry of added) {
44
+ if (entry.heading !== heading) {
45
+ heading = entry.heading;
46
+ if (heading)
47
+ blocks.push(heading);
48
+ }
49
+ blocks.push(entry.text);
50
+ }
51
+ return blocks.join("\n\n");
52
+ }
@@ -6,6 +6,7 @@ import path from "node:path";
6
6
  import semver from "semver";
7
7
  import { processTreeSpawnOptions, terminateProcessTree } from "../../executors/process-tree.js";
8
8
  import { resolveUpdateCommandLaunch } from "../../shared/update/npm-client.js";
9
+ import { compareNotesEntries } from "./version-notes-comparison.js";
9
10
  export const resolveNotesCommand = resolveUpdateCommandLaunch;
10
11
  const PACKAGE = "@tea-agent/loop-agent";
11
12
  const MAX_CHANGELOG = 256 * 1024;
@@ -283,7 +284,21 @@ export function createVersionNotes(options) {
283
284
  const sections = parseVersionNotes(pkg.changelog).filter(s => channel === "next" ? s.version === version : !semver.prerelease(s.version) && semver.valid(options.installedVersion) && semver.gt(s.version, options.installedVersion) && semver.lte(s.version, version)).sort((a, b) => semver.rcompare(a.version, b.version)).slice(0, 10);
284
285
  if (!sections.length)
285
286
  return response("candidate", "not-documented", "missing-section", [], version);
286
- return response("candidate", "ok", "documented", sections, version);
287
+ const result = response("candidate", "ok", "documented", sections, version);
288
+ if (channel === "next" && semver.prerelease(version)) {
289
+ result.comparison = { status: "unavailable", baselineVersion: options.installedVersion };
290
+ try {
291
+ const baselineText = await boundedFile(path.join(options.packageRoot, "CHANGELOG.md"), MAX_CHANGELOG);
292
+ const baseline = parseVersionNotes(baselineText).filter(s => s.version === options.installedVersion);
293
+ if (baseline.length === 1 && sections.length === 1 && semver.valid(options.installedVersion) && semver.lt(options.installedVersion, version)) {
294
+ const body = compareNotesEntries(baseline[0].body, sections[0].body);
295
+ if (body !== null)
296
+ result.comparison = { status: "compared", baselineVersion: options.installedVersion, body };
297
+ }
298
+ }
299
+ catch { /* Missing or unreadable baseline must not hide the target notes. */ }
300
+ }
301
+ return result;
287
302
  }
288
303
  catch (error) {
289
304
  const reason = error instanceof Error && ["download-timeout", "invalid-package", "changelog-too-large", "read-failed"].includes(error.message) ? error.message : "download-failed";
@@ -2,6 +2,7 @@ import { createApiWorkbenchService } from "./chat/api-workbench-core.js";
2
2
  import { deliverScheduledGoalResult } from "./chat/scheduled-goal-delivery.js";
3
3
  import { AutomationRuntime } from "./automation-runtime.js";
4
4
  import { AutomationStore } from "../scheduler/automation-store.js";
5
+ import { readRegisteredWorkspaces } from "../scheduler/automation-across-workspaces.js";
5
6
  import { deliverAutomationReminder } from "./chat/automation-delivery.js";
6
7
  import { ScheduledGoalHost } from "./scheduled-goal-host.js";
7
8
  /**
@@ -306,6 +307,15 @@ export async function createWorkspaceContext(record, deps) {
306
307
  const actionContext = {
307
308
  repoRoot,
308
309
  appData,
310
+ /*
311
+ * The automation catalog spans every registered workspace.
312
+ *
313
+ * A task is stored in the ledger of the repository that owns it, so a
314
+ * single-workspace read hid every other workspace's tasks the moment the
315
+ * operator switched. The registry file is read here rather than threading the
316
+ * live registry instance down four layers for one array.
317
+ */
318
+ automationWorkspaces: () => readRegisteredWorkspaces(appData.root),
309
319
  operatorSessionId: deps.operatorSessionId,
310
320
  client,
311
321
  operations,
@@ -1,5 +1,52 @@
1
1
  /* Opt-in palettes. Repeat tokens at the Inspect boundary: it owns local defaults
2
2
  * and is loaded after the Console stylesheet. Specificity keeps load order safe. */
3
+ /*
4
+ * `auto` follows the operating system.
5
+ *
6
+ * The token body below is the SAME one `midnight` uses, repeated rather than
7
+ * aliased: CSS cannot select by media query and also reference another theme's
8
+ * declarations, and a second palette would drift. If midnight changes, this
9
+ * block must change with it — that coupling is the cost of not having a
10
+ * three-layer token system yet (a separate, larger refactor).
11
+ */
12
+ @media (prefers-color-scheme: dark) {
13
+ :root[data-console-theme="auto"],
14
+ :root[data-console-theme="auto"] body[data-shell="observe-console"],
15
+ :root[data-console-theme="auto"] .inspect-workspace-root {
16
+ color-scheme: dark;
17
+ --canvas: #1c222a;
18
+ --canvas-soft: #202730;
19
+ --surface: #252d37;
20
+ --surface-muted: #2d3641;
21
+ --ink: #dce2e9;
22
+ --surface-ink: #dce2e9;
23
+ --body: #bcc5d0;
24
+ --muted: #a1acba;
25
+ --muted-soft: #909eaf;
26
+ --muted-ink: #a1acba;
27
+ --hairline: #353f4b;
28
+ --hairline-strong: #526171;
29
+ --orange: #a0bcd3;
30
+ --orange-active: #b8cfe0;
31
+ --blue: #a0bcd3;
32
+ --brand: #b2aacb;
33
+ --theme-action: #4d6b86;
34
+ --theme-action-hover: #557590;
35
+ --theme-on-action: #ffffff;
36
+ --green: #99c5b0;
37
+ --amber: #d3b783;
38
+
39
+ --red: #dea4ac;
40
+ --peach: #303e4d;
41
+ --mint: #2d403b;
42
+ --lavender: #393746;
43
+ --gold: #c3ac80;
44
+ --shadow-sm: 0 1px 2px rgb(0 0 0 / 12%);
45
+ --shadow-panel: 0 1px 2px rgb(0 0 0 / 12%), 0 6px 18px rgb(0 0 0 / 10%);
46
+ --shadow-soft: 0 8px 24px rgb(0 0 0 / 18%);
47
+ --shadow-lg: 0 16px 40px rgb(0 0 0 / 24%);
48
+ }
49
+ }
3
50
  :root[data-console-theme="midnight"],
4
51
  :root[data-console-theme="midnight"] body[data-shell="observe-console"],
5
52
  :root[data-console-theme="midnight"] .inspect-workspace-root {
@@ -25,7 +72,7 @@
25
72
  --theme-on-action: #ffffff;
26
73
  --green: #99c5b0;
27
74
  --amber: #d3b783;
28
- --warn: #d3b783;
75
+
29
76
  --red: #dea4ac;
30
77
  --peach: #303e4d;
31
78
  --mint: #2d403b;
@@ -62,7 +109,7 @@
62
109
  --theme-on-action: #ffffff;
63
110
  --green: #15803d;
64
111
  --amber: #b45309;
65
- --warn: #b45309;
112
+
66
113
  --red: #dc2626;
67
114
  --peach: #edf3fe;
68
115
  --mint: #e6faed;
@@ -175,4 +222,4 @@
175
222
 
176
223
  :root[data-console-theme="daylight"] {
177
224
  .oc-bubble-user { background: var(--peach); }
178
- }
225
+ }
@@ -1,6 +1,7 @@
1
1
  /** Shared Console theme identities; the default leaves the original palette intact. */
2
2
  export const CONSOLE_THEMES = Object.freeze([
3
3
  { id: "default", label: "默认" },
4
+ { id: "auto", label: "跟随系统" },
4
5
  { id: "midnight", label: "深色" },
5
6
  { id: "daylight", label: "浅色" },
6
7
  ]);
@@ -12,13 +13,36 @@ const STORAGE_KEY = "loop-console.theme.v1";
12
13
  * paints the OS window frame with the theme-color meta value, so it must track
13
14
  * the active theme: a fixed brand colour leaves an orange titlebar above the
14
15
  * dark midnight palette. Values mirror console-theme.css --canvas.
16
+ *
17
+ * `auto` has no fixed value — it resolves from the media query below.
15
18
  */
16
19
  const TITLEBAR_COLOR = Object.freeze({
17
20
  default: "#f4f2ee",
18
21
  midnight: "#1c222a",
19
22
  daylight: "#eef0f2",
23
+ autoDark: "#1c222a",
24
+ autoLight: "#f4f2ee",
20
25
  });
21
26
 
27
+ /** @returns whether the operating system asks for a dark appearance. */
28
+ function prefersDark() {
29
+ try {
30
+ return typeof matchMedia === "function" && matchMedia("(prefers-color-scheme: dark)").matches;
31
+ } catch {
32
+ return false;
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Resolve a theme id to the palette that should actually apply.
38
+ * @param theme - a stored or selected theme id.
39
+ * @returns `midnight`/`daylight`/`default`, with `auto` resolved by the media query.
40
+ */
41
+ function resolvePalette(theme) {
42
+ if (theme !== "auto") return theme;
43
+ return prefersDark() ? "midnight" : "default";
44
+ }
45
+
22
46
  function normalizeTheme(value) {
23
47
  return CONSOLE_THEMES.some((theme) => theme.id === value) ? value : "default";
24
48
  }
@@ -41,7 +65,10 @@ function syncTitlebarColor(theme) {
41
65
  meta.setAttribute("name", "theme-color");
42
66
  head.appendChild(meta);
43
67
  }
44
- meta.setAttribute("content", TITLEBAR_COLOR[theme] ?? TITLEBAR_COLOR.default);
68
+ const color = theme === "auto"
69
+ ? (prefersDark() ? TITLEBAR_COLOR.autoDark : TITLEBAR_COLOR.autoLight)
70
+ : (TITLEBAR_COLOR[theme] ?? TITLEBAR_COLOR.default);
71
+ meta.setAttribute("content", color);
45
72
  } catch {
46
73
  // The palette switch above already succeeded; the titlebar is optional.
47
74
  }
@@ -57,6 +84,7 @@ export function applyStoredConsoleTheme() {
57
84
  const theme = normalizeTheme(value);
58
85
  document.documentElement.dataset.consoleTheme = theme;
59
86
  syncTitlebarColor(theme);
87
+ watchSystemTheme();
60
88
  return theme;
61
89
  }
62
90
 
@@ -65,6 +93,7 @@ export function setConsoleTheme(value) {
65
93
  // Apply before persistence: a storage failure must not disable the picker.
66
94
  document.documentElement.dataset.consoleTheme = theme;
67
95
  syncTitlebarColor(theme);
96
+ watchSystemTheme();
68
97
  try {
69
98
  window.localStorage.setItem(STORAGE_KEY, theme);
70
99
  } catch {
@@ -72,3 +101,59 @@ export function setConsoleTheme(value) {
72
101
  }
73
102
  return theme;
74
103
  }
104
+
105
+ /**
106
+ * Repaint the titlebar when the OS appearance flips while `auto` is selected.
107
+ *
108
+ * The palette itself needs no JavaScript — the `prefers-color-scheme` block in
109
+ * console-theme.css already follows the system. Only the `theme-color` meta tag
110
+ * is a value rather than a CSS rule, so it has to be rewritten by hand; without
111
+ * this an installed window keeps its light titlebar over a dark page.
112
+ *
113
+ * Attached once per page: re-running it on every picker click would stack
114
+ * listeners that all write the same tag.
115
+ */
116
+ let watchingSystemTheme = false;
117
+
118
+ function watchSystemTheme() {
119
+ if (watchingSystemTheme) return;
120
+ try {
121
+ if (typeof matchMedia !== "function") return;
122
+ const query = matchMedia("(prefers-color-scheme: dark)");
123
+ if (typeof query.addEventListener !== "function") return;
124
+ query.addEventListener("change", () => {
125
+ if (document?.documentElement?.dataset?.consoleTheme === "auto") {
126
+ syncTitlebarColor("auto");
127
+ }
128
+ });
129
+ watchingSystemTheme = true;
130
+ } catch {
131
+ // Cosmetic only; the palettes still apply from CSS.
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Keep the titlebar in step with a theme attribute written from outside.
137
+ *
138
+ * The Console shell can switch the palette by writing
139
+ * `documentElement.dataset.consoleTheme` directly (the settings picker does
140
+ * exactly that). The CSS follows immediately because it is attribute-driven,
141
+ * but the `theme-color` meta tag is a plain value and would keep the previous
142
+ * theme's colour — a light titlebar above a dark page. A `MutationObserver` on
143
+ * that one attribute closes the gap without every caller having to remember to
144
+ * call {@link setConsoleTheme}.
145
+ */
146
+ export function syncTitlebarWithThemeAttribute() {
147
+ try {
148
+ if (typeof MutationObserver !== "function" || typeof document === "undefined") return;
149
+ const target = document.documentElement;
150
+ if (!target) return;
151
+ const observer = new MutationObserver(() => {
152
+ syncTitlebarColor(normalizeTheme(target.dataset.consoleTheme));
153
+ });
154
+ observer.observe(target, { attributes: true, attributeFilter: ["data-console-theme"] });
155
+ syncTitlebarColor(normalizeTheme(target.dataset.consoleTheme));
156
+ } catch {
157
+ // Cosmetic only.
158
+ }
159
+ }
@@ -0,0 +1,120 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { AutomationStore } from "./automation-store.js";
4
+ /**
5
+ * Read every workspace's ledger and merge the results.
6
+ *
7
+ * DSH has a single Host-level catalog with no workspace dimension at all
8
+ * (`schedule/src/index.ts`: `catalog()` reads the whole task table). Loop keeps
9
+ * tasks per repository on purpose — the ledger is committed inside that repo —
10
+ * so the equivalent view has to be assembled rather than read.
11
+ *
12
+ * Failures are per-workspace: a repository that was deleted, or whose ledger is
13
+ * corrupt, must not blank the whole list. The caller gets what could be read plus
14
+ * the ids that failed.
15
+ *
16
+ * @param workspaces - the registered workspaces to scan.
17
+ * @param options - optional store factory, for tests.
18
+ * @returns tasks across all readable workspaces, and the ids that failed.
19
+ */
20
+ export async function listAcrossWorkspaces(workspaces, options = {}) {
21
+ const storeFor = options.storeFor ?? ((repoRoot) => new AutomationStore(repoRoot));
22
+ const tasks = [];
23
+ const failedWorkspaceIds = [];
24
+ // Sequential rather than parallel: each read may take the ledger's mutex, and a
25
+ // burst of parallel opens across many repositories gains little.
26
+ for (const workspace of workspaces) {
27
+ try {
28
+ const found = await storeFor(workspace.repoRoot).listTasks({ kind: "workspace" });
29
+ for (const task of found) {
30
+ tasks.push({ ...task, workspaceId: workspace.workspaceId, workspaceName: workspace.name });
31
+ }
32
+ }
33
+ catch {
34
+ failedWorkspaceIds.push(workspace.workspaceId);
35
+ }
36
+ }
37
+ tasks.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt) || a.id.localeCompare(b.id));
38
+ return { tasks, failedWorkspaceIds };
39
+ }
40
+ /**
41
+ * Which workspace a repository path belongs to.
42
+ *
43
+ * Used by the write paths: a task is addressed by id, but the store that owns it
44
+ * is chosen by workspace, so the id has to be resolved to a repository first.
45
+ *
46
+ * @param workspaces - the registered workspaces.
47
+ * @param repoRoot - an absolute repository root.
48
+ * @returns the matching workspace, when one is registered for that path.
49
+ */
50
+ export function workspaceForRepoRoot(workspaces, repoRoot) {
51
+ const target = path.resolve(repoRoot);
52
+ return workspaces.find((workspace) => path.resolve(workspace.repoRoot) === target);
53
+ }
54
+ /**
55
+ * Read the registered workspaces straight from the registry file.
56
+ *
57
+ * The chat routes hold an app-data root but not the live `WorkspaceRegistry`
58
+ * instance, and threading that instance through four layers of dependencies to
59
+ * read one array is more coupling than the read is worth. The file is the same
60
+ * one the registry maintains (`<appDataRoot>/workspaces.json`) and is only read
61
+ * here, never written.
62
+ *
63
+ * A missing or unreadable file yields an empty list: the caller then falls back
64
+ * to the single-repository path, which is exactly the old behaviour.
65
+ *
66
+ * @param appDataRoot - the console app-data root.
67
+ * @returns registered, non-hidden workspaces.
68
+ */
69
+ export async function readRegisteredWorkspaces(appDataRoot) {
70
+ try {
71
+ const raw = JSON.parse(await readFile(path.join(appDataRoot, "workspaces.json"), "utf8"));
72
+ if (!Array.isArray(raw.workspaces))
73
+ return [];
74
+ const out = [];
75
+ for (const entry of raw.workspaces) {
76
+ if (!entry || typeof entry !== "object")
77
+ continue;
78
+ const record = entry;
79
+ if (record.hidden === true)
80
+ continue;
81
+ if (typeof record.workspaceId !== "string" || typeof record.repoRoot !== "string")
82
+ continue;
83
+ out.push({
84
+ workspaceId: record.workspaceId,
85
+ name: typeof record.name === "string" && record.name !== "" ? record.name : record.repoRoot,
86
+ repoRoot: record.repoRoot,
87
+ });
88
+ }
89
+ return out;
90
+ }
91
+ catch {
92
+ return [];
93
+ }
94
+ }
95
+ /**
96
+ * Find the workspace that owns one task id.
97
+ *
98
+ * Ids are unique inside a ledger, not across ledgers, so a write has to look
99
+ * before it can address anything: the caller wants "this task", not "this task in
100
+ * whichever repository I happen to be standing in".
101
+ *
102
+ * @param workspaces - the registered workspaces to search.
103
+ * @param taskId - the task id to locate.
104
+ * @param options - optional store factory, for tests.
105
+ * @returns the owning workspace, or undefined when none holds the id.
106
+ */
107
+ export async function findWorkspaceOwningTask(workspaces, taskId, options = {}) {
108
+ const storeFor = options.storeFor ?? ((repoRoot) => new AutomationStore(repoRoot));
109
+ for (const workspace of workspaces) {
110
+ try {
111
+ // `requireTask` throws when the id is absent, which is the cheap answer here.
112
+ await storeFor(workspace.repoRoot).getTask({ kind: "workspace" }, taskId);
113
+ return workspace;
114
+ }
115
+ catch {
116
+ continue;
117
+ }
118
+ }
119
+ return undefined;
120
+ }
@@ -347,7 +347,7 @@ export async function executeDagCheckpoint(input) {
347
347
  }
348
348
  },
349
349
  runDir,
350
- abortSignal: input.abortSignal,
350
+ abortSignal,
351
351
  createExecuteNodeForRank: (rankWriterNodeIds) => buildRankAwareExecuteNode({
352
352
  baseExecuteNode,
353
353
  customExecuteNode: input.executeNode,
@@ -445,6 +445,11 @@ export async function executeDagCheckpoint(input) {
445
445
  // makes run-dag exit non-zero after every node already finished.
446
446
  clearInterval(heartbeatTimer);
447
447
  await stateWriteQueue;
448
+ // Cancellation owns the run outcome even when the in-flight node was
449
+ // the last node or an earlier node already recorded another failure.
450
+ // Preserve individual node outcomes, but never start recovery after abort.
451
+ if (abortSignal?.aborted)
452
+ state.failureCategory = "controller-interrupted";
448
453
  state.finishedAt = new Date().toISOString();
449
454
  const runDirBeforeTransfer = runDir;
450
455
  await writeBudgetLedgerArtifacts(runDir, state.budgetLedger);
@@ -124,13 +124,26 @@ export function assemblePlanPatchFromCommittedFacts(records, contractRequirement
124
124
  const stateFlows = facts.filter((fact) => fact.kind === "state-flow");
125
125
  const stateByName = new Map();
126
126
  const unnamedStates = [];
127
+ // A shared interaction has one contribution per requirement. A later
128
+ // non-goal batch must not replace the positive behavior from another batch.
129
+ // Corrections replace only their scope; an unscoped correction is global.
127
130
  const interactionByName = new Map();
128
131
  const unnamedInteractions = [];
129
132
  for (const flow of stateFlows) {
130
133
  for (const name of asStringArray(flow.removeUiStateNames))
131
134
  stateByName.delete(name);
132
- for (const name of asStringArray(flow.removeInteractionNames))
133
- interactionByName.delete(name);
135
+ const scope = asStringArray(flow.scopeRequirementIds);
136
+ for (const name of asStringArray(flow.removeInteractionNames)) {
137
+ if (scope.length === 0)
138
+ interactionByName.delete(name);
139
+ else {
140
+ const contributions = interactionByName.get(name);
141
+ for (const owner of scope)
142
+ contributions?.delete(owner);
143
+ if (contributions?.size === 0)
144
+ interactionByName.delete(name);
145
+ }
146
+ }
134
147
  for (const state of Array.isArray(flow.uiStates) ? flow.uiStates : []) {
135
148
  if (!isRecord(state))
136
149
  continue;
@@ -144,20 +157,40 @@ export function assemblePlanPatchFromCommittedFacts(records, contractRequirement
144
157
  if (!isRecord(interaction))
145
158
  continue;
146
159
  const name = asString(interaction.name);
147
- if (name)
148
- interactionByName.set(name, interaction);
160
+ if (name) {
161
+ const contributions = scope.length === 0
162
+ ? new Map()
163
+ : interactionByName.get(name) ?? new Map();
164
+ for (const owner of scope.length ? scope : [""])
165
+ contributions.set(owner, interaction);
166
+ interactionByName.set(name, contributions);
167
+ }
149
168
  else
150
169
  unnamedInteractions.push(interaction);
151
170
  }
152
171
  }
153
172
  if (stateFlows.length > 0) {
154
173
  patch.uiStates = [...stateByName.values(), ...unnamedStates];
155
- patch.interactions = [...interactionByName.values(), ...unnamedInteractions];
174
+ patch.interactions = [...interactionByName.values()].map(contributions => {
175
+ const entries = [...new Set(contributions.values())];
176
+ const merged = { ...entries.at(-1) };
177
+ for (const field of ["trigger", "expectedBehavior"]) {
178
+ merged[field] = [...new Set(entries.map(entry => asString(entry[field])).filter(Boolean))].join("\n");
179
+ }
180
+ for (const field of ["implementationTargets", "verificationTargetIds"]) {
181
+ merged[field] = [...new Set(entries.flatMap(entry => asStringArray(entry[field])))];
182
+ }
183
+ return merged;
184
+ }).concat(unnamedInteractions);
156
185
  }
157
186
  const mockApi = lastByKind("mock-api");
158
187
  if (!mockApi && facts.some(f => f.kind === "mock-endpoint" && f.removed !== true))
159
188
  throw Error("MOCK_POLICY_MISSING: endpoint has no policy");
160
189
  if (mockApi && isRecord(mockApi.mockApi)) {
190
+ if (typeof mockApi.realIntegrationGap === "string" && mockApi.realIntegrationGap.trim())
191
+ patch.realIntegrationGap = mockApi.realIntegrationGap;
192
+ if (Array.isArray(mockApi.residualRisks))
193
+ patch.residualRisks = asStringArray(mockApi.residualRisks);
161
194
  const endpoints = new Map();
162
195
  for (const endpoint of Array.isArray(mockApi.mockApi.endpoints) ? mockApi.mockApi.endpoints : []) {
163
196
  if (isRecord(endpoint))
@@ -396,6 +396,27 @@ export function checkDesignApproval(designApproval) {
396
396
  }
397
397
  return [];
398
398
  }
399
+ /** A component keeps one creation/reuse decision across Plan scopes. */
400
+ export function checkComponentChoiceConsistency(contract) {
401
+ const groups = new Map();
402
+ for (const choice of contract.uiComponentChoices ?? []) {
403
+ const name = choice.component.trim();
404
+ const group = groups.get(name) ?? [];
405
+ group.push(choice);
406
+ groups.set(name, group);
407
+ }
408
+ return [...groups].flatMap(([component, choices]) => {
409
+ const decisions = new Set(choices.map(choice => choice.decision));
410
+ // specified identifies a specification, not whether the component exists.
411
+ if (!decisions.has("new") || !decisions.has("reuse-existing"))
412
+ return [];
413
+ return [{
414
+ code: "component-choice-inconsistent",
415
+ path: component,
416
+ message: `Component "${component}" has conflicting decisions: ${choices.map(choice => `${choice.purpose}=${choice.decision}`).join(", ")}. Inspect the baseline and replace each conflicting record_component_choice using its original purpose, keeping all covers and supporting evidence. Keep creation/reuse consistent across scopes; do not remove requirement coverage.`,
417
+ }];
418
+ });
419
+ }
399
420
  /**
400
421
  * UX vocabulary collisions (item ③, dogfood dag-1788504923861-0f7b17a9):
401
422
  * prioritize-planner-task / prioritizePlannerTask / prioritize-planner-tasks
@@ -734,6 +755,7 @@ export function evaluateFrontendDesignPolicy(input) {
734
755
  ...checkDependencies(input.contract, input.allowedDependencies),
735
756
  ...checkUiStateAttribution(input.contract),
736
757
  ...checkUxNameCollisions(input.contract),
758
+ ...checkComponentChoiceConsistency(input.contract),
737
759
  ...checkRequiredDeliverables(input.contract),
738
760
  ...checkImplementationSlices(input.contract, input.writeSetPatterns),
739
761
  ...checkDesignInputBindings(input.contract, input.sourceFreshness),
@@ -18,7 +18,7 @@ export { extractRequiredDeliverablePaths } from "./frontend-contract-facts.js";
18
18
  // Cycle-safe value imports: the check functions are hoisted declarations used
19
19
  // only at call time, so the contract module and the policy module can depend
20
20
  // on each other without module-init ordering issues.
21
- import { checkDependencies, checkImplementationSlices, checkDesignInputBindings, checkTargetPaths, checkUiDesignCoverage, checkUiStateAttribution, checkRequiredDeliverables, checkUxNameCollisions, } from "./frontend-design-policy.js";
21
+ import { checkDependencies, checkImplementationSlices, checkDesignInputBindings, checkTargetPaths, checkUiDesignCoverage, checkUiStateAttribution, checkRequiredDeliverables, checkUxNameCollisions, checkComponentChoiceConsistency, } from "./frontend-design-policy.js";
22
22
  import { isDagSourceBindingV2 } from "./types.js";
23
23
  import { canonicalContractRel, classifyStructuredContractFailure, formatStructuredArtifactPointer, persistRuntimeSkeleton, } from "./structured-output-repair.js";
24
24
  import { renderFrontendPlanMarkdown } from "./frontend-plan-render.js";
@@ -553,32 +553,48 @@ export async function deriveFrontendInteractionIdsFromRun(runDir) {
553
553
  try {
554
554
  raw = await readFile(specPath, "utf8");
555
555
  }
556
- catch {
557
- return [];
556
+ catch (error) {
557
+ if (error.code === "ENOENT")
558
+ return [];
559
+ throw error;
558
560
  }
561
+ const invalid = () => new Error("FRONTEND_INTERACTION_AUTHORITY_INVALID: frozen run interaction vocabulary is malformed or inconsistent");
559
562
  let spec;
560
563
  try {
561
564
  spec = JSON.parse(raw);
562
565
  }
563
566
  catch {
564
- return [];
567
+ throw invalid();
565
568
  }
569
+ if (!spec || typeof spec !== "object" || (spec.tasks !== undefined && !Array.isArray(spec.tasks)))
570
+ throw invalid();
571
+ let declared;
566
572
  for (const task of spec.tasks ?? []) {
567
- const ids = task.shell?.frontendDesignPolicy?.interactionIds;
568
- if (ids && ids.length > 0)
569
- return ids.filter((id) => typeof id === "string" && id.trim());
573
+ const ids = task?.shell?.frontendDesignPolicy?.interactionIds;
574
+ if (ids === undefined)
575
+ continue;
576
+ if (!Array.isArray(ids) || ids.some(id => typeof id !== "string" || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(id)))
577
+ throw invalid();
578
+ const normalized = [...new Set(ids)].sort();
579
+ if (declared && JSON.stringify(declared) !== JSON.stringify(normalized))
580
+ throw invalid();
581
+ declared = normalized;
570
582
  }
571
- return [];
583
+ return declared ?? [];
584
+ }
585
+ /** Empty vocabulary retains the existing unrestricted task semantics. */
586
+ export function undeclaredFrontendInteractionIds(names, declared) {
587
+ return declared.length ? [...new Set(names.filter(name => !declared.includes(name)))] : [];
572
588
  }
573
589
  function checkInteractionIdVocabulary(canonical, declaredIds) {
574
590
  const findings = [];
575
591
  if (declaredIds.length === 0)
576
592
  return findings;
577
593
  for (const interaction of canonical.interactions ?? []) {
578
- if (!declaredIds.includes(interaction.name)) {
594
+ if (undeclaredFrontendInteractionIds([interaction.name], declaredIds).length) {
579
595
  findings.push({
580
596
  code: "interaction-name-not-declared",
581
- message: `interaction "${interaction.name}" is not in the frozen interaction id vocabulary; allowed: [${declaredIds.join(", ")}] — retract the wrong record via record_data_flow {"interaction": "${interaction.name}", "retracted": true} or retract_data_flow, then record the declared id`,
597
+ message: `interaction "${interaction.name}" is not in the frozen interaction id vocabulary; allowed: [${declaredIds.join(", ")}]; correct the owning interaction fact using the active Plan protocol, preserving its requirements and verification coverage`,
582
598
  path: "interactions",
583
599
  });
584
600
  }
@@ -1345,13 +1361,23 @@ export const frontendImplementationContractSchema = z
1345
1361
  message: "requirement needs targets or evidenceGap",
1346
1362
  path: ["requirements"],
1347
1363
  });
1348
- for (const targetId of requirement.verificationTargetIds)
1349
- if (!verificationIds.includes(targetId))
1364
+ for (const targetId of requirement.verificationTargetIds) {
1365
+ const target = value.verificationTargets.find((item) => item.id === targetId);
1366
+ if (!target) {
1350
1367
  ctx.addIssue({
1351
1368
  code: "custom",
1352
1369
  message: `unknown verification target ${targetId}`,
1353
1370
  path: ["requirements"],
1354
1371
  });
1372
+ }
1373
+ else if (!target.requirementIds.includes(requirement.id)) {
1374
+ ctx.addIssue({
1375
+ code: "custom",
1376
+ message: `verification target ${targetId} does not cover requirement ${requirement.id}; correct the requirement/target association before finalizing the plan`,
1377
+ path: ["requirements"],
1378
+ });
1379
+ }
1380
+ }
1355
1381
  // Interactions bind to VTs too: an interaction whose behavior
1356
1382
  // verification points at an unmaterialized VT is untraceable —
1357
1383
  // r20 review finding (dangling *-BEHAVIOR references sailed
@@ -3579,6 +3605,7 @@ export async function analyzeFrontendPlanPatchCandidate(input) {
3579
3605
  ...checkUiStateAttribution(analysis.canonical),
3580
3606
  ...checkRequiredDeliverables(analysis.canonical),
3581
3607
  ...checkUxNameCollisions(analysis.canonical),
3608
+ ...checkComponentChoiceConsistency(analysis.canonical),
3582
3609
  ...checkDependencies(analysis.canonical, await deriveAllowedDependenciesFromRun(input.runDir)),
3583
3610
  ...checkTargetPaths(analysis.canonical, await deriveWriteSetFromRun(input.runDir), await collectExistingFrontendVerificationPaths(workspaceRootFromDagRunDir(input.runDir), analysis.canonical)),
3584
3611
  // F1: front-load slice containment/coverage/acyclicity so the plan