@tea-agent/loop-agent 0.38.0 → 0.38.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 (147) hide show
  1. package/CHANGELOG.md +191 -0
  2. package/dist/application/dag/generate-task-dag.js +9 -0
  3. package/dist/build-stamp.json +3 -3
  4. package/dist/commands/init-upgrade.js +97 -19
  5. package/dist/executors/dag-pi-executor.js +42 -4
  6. package/dist/executors/shell-executor.js +269 -15
  7. package/dist/infrastructure/harness/atomic-write.js +2 -1
  8. package/dist/shared/openspec-spec.js +76 -0
  9. package/dist/shared/operator/capabilities.js +149 -27
  10. package/dist/task/config-types.js +43 -0
  11. package/dist/task/frontend-project-capability.js +292 -38
  12. package/dist/worker/console/chat/deferred-turn.js +91 -0
  13. package/dist/worker/console/chat/mcp-inventory.js +221 -0
  14. package/dist/worker/console/chat/pi-runtime.js +165 -83
  15. package/dist/worker/console/chat/repo-walk.js +10 -1
  16. package/dist/worker/console/chat/routes.js +477 -55
  17. package/dist/worker/console/chat/semantic-activity.js +20 -8
  18. package/dist/worker/console/chat/session-store.js +146 -2
  19. package/dist/worker/console/chat/turn-process.js +17 -30
  20. package/dist/worker/console/harness-pi-model-matrix.js +137 -0
  21. package/dist/worker/console/operator-actions.js +128 -4
  22. package/dist/worker/console/operator-user-error.js +19 -0
  23. package/dist/worker/console/pi-readiness.js +8 -1
  24. package/dist/worker/console/recovery-cta.js +4 -4
  25. package/dist/worker/console/recovery-error-copy.js +4 -4
  26. package/dist/worker/console/security.js +20 -1
  27. package/dist/worker/console/server.js +6 -1
  28. package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-DSvF6RXQ.js → abnfDiagram-N423BO3Z-C4bmo3iY.js} +1 -1
  29. package/dist/worker/console/static/assets/{arc-DuI4ogtJ.js → arc-SAD7McOS.js} +1 -1
  30. package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-DdBbgD4y.js → architectureDiagram-T3A2C74G-DAVLUdK1.js} +1 -1
  31. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-xQC2HELm.js → blockDiagram-VBNYF7ZC-CPPdv4vj.js} +1 -1
  32. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-DPMSgwIZ.js → c4Diagram-5PPSVZJV-D1GRGZax.js} +1 -1
  33. package/dist/worker/console/static/assets/channel-R6oQIDkw.js +1 -0
  34. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-WTEKTxin.js → chunk-2GRJ4B5K-D_Bq2ZqK.js} +1 -1
  35. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B6vZ0Pv_.js → chunk-2Q5K7J3B-CPLVtamK.js} +1 -1
  36. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-BrerNAix.js → chunk-5RXB4S5H-DnaZWcL3.js} +1 -1
  37. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-D_ch2aaI.js → chunk-5VM5RSS4-BRTmFgnq.js} +1 -1
  38. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-VvfacNrq.js → chunk-6Q2QTUOP-BRlfYZoH.js} +1 -1
  39. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-B-uGFIg2.js → chunk-GF5L2VYU-CjNybD4u.js} +1 -1
  40. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-BlysCtod.js → chunk-JWPE2WC7-D3e-74fG.js} +1 -1
  41. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-BjAUAfcT.js → chunk-KBJHAD2P-Br3ir6f2.js} +1 -1
  42. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-BeZnBmb-.js → chunk-RYQCIY6F-1NgVuRbh.js} +1 -1
  43. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-Bbfe3UJG.js → chunk-XXDRQBXY-BTYuvuWN.js} +1 -1
  44. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BPXlmPWI.js +1 -0
  45. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BPXlmPWI.js +1 -0
  46. package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-BKJQnYVM.js → cose-bilkent-JH36ORCC-BC6Bgosf.js} +1 -1
  47. package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-B1wtI3hU.js → cynefin-VYW2F7L2-DV-HypfL.js} +1 -1
  48. package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DCF6DBSu.js → cynefinDiagram-MW4NZA55-DhTaddO-.js} +1 -1
  49. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BJyNGRlP.js → dagre-VZM6K2ZE-BnEcOmiI.js} +1 -1
  50. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-B7j1-VsZ.js → diagram-7IWD3JNH-xphGRVKp.js} +1 -1
  51. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-BREJ140a.js → diagram-B4RE2ZJO-CrdD1mRG.js} +1 -1
  52. package/dist/worker/console/static/assets/{diagram-LBJQPF4R-CDPHmHGH.js → diagram-LBJQPF4R-D4YdLsaF.js} +1 -1
  53. package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BtZLrez1.js → diagram-Q27KOJAE-LCKyGZ5U.js} +1 -1
  54. package/dist/worker/console/static/assets/{diagram-UB23O5K3-mzybu8oU.js → diagram-UB23O5K3-BeiTe7t0.js} +1 -1
  55. package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-Dk3I2uO6.js → ebnfDiagram-BXEA7PRR-BO2cq8GS.js} +1 -1
  56. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-BT97u_tQ.js → erDiagram-JOGREHBK-CmWww3Nt.js} +1 -1
  57. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-CMOtYzui.js → flowDiagram-UKHOOZJN-C2kkUYg5.js} +1 -1
  58. package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-DiNydkuY.js → ganttDiagram-PKOTCBZU-DY_JZ2iQ.js} +1 -1
  59. package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Cwt6fLkl.js → gitGraphDiagram-DS77QQ5N-BizhCSw9.js} +1 -1
  60. package/dist/worker/console/static/assets/index-BXN89VPX.js +325 -0
  61. package/dist/worker/console/static/assets/index-CuH5CNFu.css +1 -0
  62. package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-AsGIGKKB.js → infoDiagram-6WML65LV-Dlo2eK_d.js} +1 -1
  63. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-BL8ITZh3.js → ishikawaDiagram-WSZJBQD7-3EIlIIuZ.js} +1 -1
  64. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-VPKAUX8M.js → journeyDiagram-NVQOT4AX-DiMDe5Yh.js} +1 -1
  65. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-BL56hfGp.js → kanban-definition-27J2QSJJ-sN553oIN.js} +1 -1
  66. package/dist/worker/console/static/assets/{linear-BmSG3nIZ.js → linear-D9Py31Ld.js} +1 -1
  67. package/dist/worker/console/static/assets/{mermaid.core-DWGK9kwP.js → mermaid.core-D7Occzk_.js} +5 -5
  68. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS--vvKLjo0.js → mindmap-definition-FAOFIHXS-DjDRboiR.js} +1 -1
  69. package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-B41mxb2-.js → pegDiagram-VL7TDLO6-Cgc4qlzp.js} +1 -1
  70. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-DTlu77sw.js → pieDiagram-7S7Q4E2Y-DxZj8pKd.js} +1 -1
  71. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-Bk5A7alv.js → quadrantDiagram-CIZ2JOQS-CJ50MngR.js} +1 -1
  72. package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-Csf9jzQy.js → railroadDiagram-AXF67PYL-BY-OD8Tr.js} +1 -1
  73. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-CeptoSNx.js → requirementDiagram-LRYGKXZP-CQFButfK.js} +1 -1
  74. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-A-DLCLer.js → sankeyDiagram-W5VNT64P-BB_QUK_b.js} +1 -1
  75. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-22VbPdOI.js → sequenceDiagram-SI44F4Z6-CqhXZjyx.js} +1 -1
  76. package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-DWvAyBC9.js → sizeCapture-X5ZJPWSS-2l1U4rgJ.js} +1 -1
  77. package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-qICZ75yT.js → stateDiagram-OKZ733FA-BX1FbrhJ.js} +1 -1
  78. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DJKi0Qel.js +1 -0
  79. package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-xi7lcMyp.js → swimlanes-SLNWSIFB-DOSnT7hb.js} +2 -2
  80. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-YYe7EEm5.js +8 -0
  81. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-Bu6Nl6O2.js → timeline-definition-Z64GVDOM-DVJQA7AN.js} +1 -1
  82. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-BzMz4Bn9.js → vennDiagram-T6HMQDX7-74uxl9gx.js} +1 -1
  83. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-CxaJnzc5.js → wardleyDiagram-T6FBY63Y-DsBxlcg_.js} +1 -1
  84. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-5JK-omQK.js → xychartDiagram-ELKLHX3M-snuW9Mjw.js} +1 -1
  85. package/dist/worker/console/static/index.html +2 -2
  86. package/dist/worker/console/static-src/app/console-types.js +39 -0
  87. package/dist/worker/console/static-src/app/useOperatorActions.js +1 -1
  88. package/dist/worker/console/static-src/app/useRecoveryActions.js +2 -2
  89. package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +82 -22
  90. package/dist/worker/console/static-src/operator-chat/mutation-gate.js +45 -0
  91. package/dist/worker/console/static-src/operator-chat/resource-diagnostics.js +204 -0
  92. package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +8 -1
  93. package/dist/worker/console/static-src/operator-chat/turn-submission.js +42 -0
  94. package/dist/worker/console/static-src/operator-chat/useChatSessions.js +18 -0
  95. package/dist/worker/console/static-src/operator-chat/useChatStream.js +216 -10
  96. package/dist/worker/console/static-src/operator-chat/useChatThread.js +50 -22
  97. package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +26 -1
  98. package/dist/workflows/dag/backend-test-case-coverage-analysis.js +755 -51
  99. package/dist/workflows/dag/backend-test-case-manifest.js +4 -0
  100. package/dist/workflows/dag/backend-test-execution-contract.js +18 -9
  101. package/dist/workflows/dag/backend-test-gap-fill.js +205 -0
  102. package/dist/workflows/dag/backend-test-intake-context.js +32 -0
  103. package/dist/workflows/dag/backend-test-layout.js +133 -0
  104. package/dist/workflows/dag/backend-test-markdown-workflow.js +167 -32
  105. package/dist/workflows/dag/backend-test-module-stem.js +5 -0
  106. package/dist/workflows/dag/backend-test-pytest-collection.js +368 -33
  107. package/dist/workflows/dag/backend-test-result-contract.js +1 -1
  108. package/dist/workflows/dag/backend-test-scenario-param.js +884 -140
  109. package/dist/workflows/dag/backend-test-scenario-partitions.js +249 -0
  110. package/dist/workflows/dag/backend-test-writer-completeness.js +100 -56
  111. package/dist/workflows/dag/contract-validator-registrations.js +3 -1
  112. package/dist/workflows/dag/convergence/controller.js +141 -0
  113. package/dist/workflows/dag/dynamic-runtime/map.js +24 -8
  114. package/dist/workflows/dag/dynamic-runtime/shared.js +1 -1
  115. package/dist/workflows/dag/failure-routing.js +9 -4
  116. package/dist/workflows/dag/frontend-implementation-contract.js +386 -0
  117. package/dist/workflows/dag/frontend-plan-render.js +90 -0
  118. package/dist/workflows/dag/frontend-prewrite-gate.js +479 -28
  119. package/dist/workflows/dag/init-hybrid.js +920 -110
  120. package/dist/workflows/dag/lifecycle.js +4 -0
  121. package/dist/workflows/dag/node-execution.js +77 -8
  122. package/dist/workflows/dag/prompt.js +45 -0
  123. package/dist/workflows/dag/report.js +6 -0
  124. package/dist/workflows/dag/rerun-feedback.js +212 -0
  125. package/dist/workflows/dag/rerun-plan.js +93 -27
  126. package/dist/workflows/dag/rerun-run.js +3 -0
  127. package/dist/workflows/dag/rerun-task.js +61 -2
  128. package/dist/workflows/dag/retry-policy.js +33 -0
  129. package/dist/workflows/dag/types.js +148 -4
  130. package/dist/workflows/dag/validate.js +7 -2
  131. package/docs/templates/backend-test-dag.json +60 -35
  132. package/docs/templates/frontend-design-contract.md +40 -14
  133. package/docs/templates/frontend-implementation-contract.schema.json +9 -2
  134. package/docs/templates/frontend-task-constraints.md +40 -13
  135. package/docs/templates/frontend-task-requirement.md +54 -20
  136. package/harness.json +3 -1
  137. package/package.json +1 -1
  138. package/skills/frontend-design-review/references/review-checklist.md +2 -0
  139. package/skills/frontend-implementation/references/design-spec.md +16 -19
  140. package/skills/frontend-implementation/references/node-contracts.md +15 -11
  141. package/dist/worker/console/static/assets/channel-DLVz9TYW.js +0 -1
  142. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BeAuGcO9.js +0 -1
  143. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BeAuGcO9.js +0 -1
  144. package/dist/worker/console/static/assets/index-DQxiso1w.js +0 -325
  145. package/dist/worker/console/static/assets/index-_j0Hzo69.css +0 -1
  146. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DzKvfHTX.js +0 -1
  147. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Cxqr_qM1.js +0 -8
@@ -13,13 +13,45 @@ const CONTROLLER_PROTOCOL_CAPABILITIES = [
13
13
  "worker-attempt-revision-v1",
14
14
  "recovery-decision-v2",
15
15
  ];
16
- function officialModelCallable(coverage, kind) {
16
+ function officialModelCallable(coverage, _kind) {
17
17
  if (coverage === "human-gated-required")
18
18
  return "prepare-only";
19
- if (coverage === "advanced" && kind !== "read")
19
+ // 2026-08-18: advanced actions (read or mutation) stay OUT of the model
20
+ // tool surface — low-frequency/forensic commands with generic args[] params
21
+ // diluted model attention. They remain dispatchable via UI capabilities.
22
+ if (coverage === "advanced")
20
23
  return "never";
21
24
  return "always";
22
25
  }
26
+ const OFFICIAL_ACTION_DESCRIPTIONS = {
27
+ dagDecisionInspect: "Inspect a pending DAG decision envelope (inputs, options, chosen branch). Use before advising the operator on approve/reject; read-only.",
28
+ dagDecisionValidate: "Validate a DAG decision envelope against its schema. Use when a decision payload looks malformed or a writer emitted a suspect envelope; read-only.",
29
+ dagCloseoutDraft: "Draft the closeout handoff document for a finished DAG run. Use when the run is FINISHED and you need the handoff text; read-only.",
30
+ planList: "List execution plans in the repository. Use to discover plan ids before plan create/complete/check.",
31
+ planCreate: "Create an execution plan from a summary. Use to record the next work block before starting it.",
32
+ planComplete: "Mark an execution plan complete with a summary of what was delivered. Use after a work block is done and verified.",
33
+ planCheck: "Check execution-plan health and drift. Use to audit plan state without mutating anything.",
34
+ docsAudit: "Audit docs freshness and links (document catalog policy). Use when asked whether docs are stale or need review.",
35
+ handoffCheck: "Check handoff document completeness against the verification matrix. Use before claiming a task is fully handed off.",
36
+ handoffCoverage: "Show verification coverage across tests/docs/links for the repo. Use when asked what is verified and what is not.",
37
+ coverageReport: "Produce the verification coverage report. Use for a structured view of tests vs requirements.",
38
+ stats: "Repository workflow statistics (tasks, runs, durations). Use for quantitative status questions.",
39
+ promoteRun: "Task advance alias; passes a task id and flags through to task advance to promote a run. Does not pre-verify run state here — confirm with dagReport that the run is FINISHED before calling.",
40
+ closeoutTask: "Task advance alias; passes a task id and flags through to task advance to close out a task. Confirm the task's work is delivered and verified before calling.",
41
+ knowledgeCurate: "Generate knowledge-base curation proposals (may write a proposal file when --output is passed). Write-capable; use via the operator CLI, not as a model tool.",
42
+ knowledgeQuery: "Query the repository knowledge base. Use instead of re-reading files when a curated answer may exist.",
43
+ workerFeatureReview: "Review worker feature status and checkpoints (agent-worker). Use to see where a feature line stands.",
44
+ workerFeatureDoctor: "Diagnose worker feature health (agent-worker). Use when a feature line looks stuck or inconsistent.",
45
+ workerTaskValidate: "Validate a worker task spec (agent-worker). Use before queuing or when a task looks malformed.",
46
+ workerBatchPlanReady: "Show which batch tasks are ready to run (agent-worker). Use for queue triage before workerBatchRunReady.",
47
+ workerReportMorning: "Morning report for overnight worker activity (agent-worker). Use at the start of a session to catch overnight failures.",
48
+ workerReportMetrics: "Worker throughput and failure metrics (agent-worker). Use for quantitative worker questions.",
49
+ workerAdmissionShow: "Show night admission queue state (agent-worker). Use before night-scheduler mutations.",
50
+ workerSchedulerList: "List night-scheduler schedules (agent-worker). Use to discover schedule ids.",
51
+ workerSchedulerStatus: "Night-scheduler status overview (agent-worker). Use to check whether overnight jobs are healthy.",
52
+ workerSchedulerLedger: "Night-scheduler harvest ledger (agent-worker). Use to audit what overnight runs produced.",
53
+ workerSchedulerDoctor: "Diagnose night-scheduler health (agent-worker). Use when overnight jobs fail to fire or harvest.",
54
+ };
23
55
  const officialAction = (action, cli, kind, coverage) => ({
24
56
  action,
25
57
  cli,
@@ -38,7 +70,8 @@ const officialAction = (action, cli, kind, coverage) => ({
38
70
  "TRANSACTION_INCOMPLETE",
39
71
  "NOT_FOUND",
40
72
  ],
41
- description: `Official CLI action coverage for ${cli}.`,
73
+ description: OFFICIAL_ACTION_DESCRIPTIONS[action] ??
74
+ `Official CLI action coverage for ${cli}.`,
42
75
  inputParams: [
43
76
  {
44
77
  name: "args",
@@ -63,8 +96,6 @@ const officialAction = (action, cli, kind, coverage) => ({
63
96
  });
64
97
  const OFFICIAL_ACTIONS = [
65
98
  ...[
66
- ["dagDoctor", "loop-agent dag doctor", "read", "model-callable"],
67
- ["dagStatus", "loop-agent dag status", "read", "model-callable"],
68
99
  [
69
100
  "dagDecisionInspect",
70
101
  "loop-agent dag decision inspect",
@@ -160,8 +191,8 @@ const OFFICIAL_ACTIONS = [
160
191
  [
161
192
  "knowledgeCurate",
162
193
  "loop-agent knowledge curate",
163
- "read",
164
- "model-callable",
194
+ "mutation",
195
+ "advanced",
165
196
  ],
166
197
  ["knowledgeQuery", "loop-agent knowledge query", "read", "model-callable"],
167
198
  [
@@ -284,7 +315,6 @@ const OFFICIAL_ACTIONS = [
284
315
  "long-running",
285
316
  "advanced",
286
317
  ],
287
- ["workerPoolDoctor", "agent-worker pool doctor", "read", "model-callable"],
288
318
  [
289
319
  "workerPoolMarkFailed",
290
320
  "agent-worker pool mark-failed",
@@ -337,6 +367,12 @@ const OFFICIAL_ACTIONS = [
337
367
  ],
338
368
  ],
339
369
  ].map(([action, cli, kind, coverage]) => officialAction(action, cli, kind, coverage));
370
+ /**
371
+ * Action ids produced by the officialAction() factory (the generic CLI
372
+ * coverage tail). Derived from the same tuple table so dispatcher / gate
373
+ * checks do not string-match descriptions.
374
+ */
375
+ export const OFFICIAL_TAIL_ACTION_IDS = new Set(OFFICIAL_ACTIONS.map((entry) => entry.action));
340
376
  /** Shared constants so dag + dagSpecVersions cannot diverge. */
341
377
  const DAG_SPEC_SUPPORTED_PARSE = [1, 2, 3, 4];
342
378
  const DAG_SPEC_NEW_WRITER_DEFAULT = 4;
@@ -612,7 +648,7 @@ export function buildOperatorCapabilitiesDocument() {
612
648
  resultSchemaVersion: 1,
613
649
  envelopeSchemaVersion: 1,
614
650
  requiredErrorCodes: [...COMMON_MUTATION_ERRORS],
615
- description: "Create or advance a task via the single lifecycle mutation entry.",
651
+ description: "Create a new task (lifecycle entry). Prefer taskAdvance for the standard flow (PRD import, taskKind, boundaries, DAG generation); newTask only bootstraps a task id + title.",
616
652
  inputParams: [
617
653
  {
618
654
  name: "taskId",
@@ -688,7 +724,7 @@ export function buildOperatorCapabilitiesDocument() {
688
724
  resultSchemaVersion: 1,
689
725
  envelopeSchemaVersion: 1,
690
726
  requiredErrorCodes: ["NOT_FOUND", "INVALID_INPUT"],
691
- description: "Read source instruction contract for a task.",
727
+ description: "Read the task's source instruction contract (需求.md/执行约束.md projection: requirements, constraints, allowed/forbidden paths). Use before drafting or revising a contract to stay aligned with the source.",
692
728
  inputParams: [
693
729
  {
694
730
  name: "taskId",
@@ -838,8 +874,33 @@ export function buildOperatorCapabilitiesDocument() {
838
874
  resultSchemaVersion: 1,
839
875
  envelopeSchemaVersion: 1,
840
876
  requiredErrorCodes: ["INVALID_INPUT"],
841
- description: "Build Observe deep link from stable object identity.",
842
- inputParams: [],
877
+ description: "Build Observe deep link from stable object identity. Pass exactly one of dagRunId (preferred), taskId (resolves to latest run), featureId, or workerRunId; omit all for the Console home link.",
878
+ inputParams: [
879
+ {
880
+ name: "dagRunId",
881
+ type: "string",
882
+ required: false,
883
+ description: "dag run id; deep-links to #/dag/<runId> (preferred when known)",
884
+ },
885
+ {
886
+ name: "taskId",
887
+ type: "string",
888
+ required: false,
889
+ description: "task id; resolves to the latest dag run when one exists, else #/task/<taskId>",
890
+ },
891
+ {
892
+ name: "featureId",
893
+ type: "string",
894
+ required: false,
895
+ description: "feature line id; deep-links to the feature view",
896
+ },
897
+ {
898
+ name: "workerRunId",
899
+ type: "string",
900
+ required: false,
901
+ description: "worker run id; deep-links to the worker run view",
902
+ },
903
+ ],
843
904
  modelCallable: "always",
844
905
  humanConfirmation: "none",
845
906
  },
@@ -851,7 +912,7 @@ export function buildOperatorCapabilitiesDocument() {
851
912
  resultSchemaVersion: 1,
852
913
  envelopeSchemaVersion: 1,
853
914
  requiredErrorCodes: ["INVALID_INPUT"],
854
- description: "Repo preflight (registry entry; envelope migration follow-up).",
915
+ description: "Preflight a repository for loop-agent: checks harness presence, task-pool layout, and reports what the Console can operate on. Use at session start on an unfamiliar repo, before init/upgrade decisions.",
855
916
  inputParams: [],
856
917
  modelCallable: "always",
857
918
  humanConfirmation: "none",
@@ -910,7 +971,7 @@ export function buildOperatorCapabilitiesDocument() {
910
971
  resultSchemaVersion: 1,
911
972
  envelopeSchemaVersion: 1,
912
973
  requiredErrorCodes: ["NOT_FOUND", "INVALID_INPUT"],
913
- description: "Task lifecycle status (read-only).",
974
+ description: "Read one task's lifecycle status: state, blockers, gates, contract revision, run associations. Use for task-level questions; use dagStatus for a specific DAG run's live node/liveness.",
914
975
  inputParams: [
915
976
  {
916
977
  name: "taskId",
@@ -930,7 +991,7 @@ export function buildOperatorCapabilitiesDocument() {
930
991
  resultSchemaVersion: 1,
931
992
  envelopeSchemaVersion: 1,
932
993
  requiredErrorCodes: ["NOT_FOUND", "INVALID_INPUT"],
933
- description: "Spine audit (registry entry).",
994
+ description: "Audit a task's minimal spec spine: source docs, path ownership, requirement ids, final verification coverage. Use before closing out a task to confirm every AC is verified.",
934
995
  inputParams: [
935
996
  {
936
997
  name: "taskId",
@@ -1023,7 +1084,7 @@ export function buildOperatorCapabilitiesDocument() {
1023
1084
  "EXTERNALLY_MODIFIED",
1024
1085
  "INVALID_INPUT",
1025
1086
  ],
1026
- description: "Generate + strict-validate DAG via task advance (stops at writeSet gate).",
1087
+ description: "Generate + strict-validate a task's DAG (via task advance, stops at the writeSet gate). Legacy entry; the standard flow is taskAdvance then prepareDagExecution + runDag.",
1027
1088
  inputParams: [
1028
1089
  {
1029
1090
  name: "taskId",
@@ -1079,7 +1140,7 @@ export function buildOperatorCapabilitiesDocument() {
1079
1140
  "CONTROLLER_MISMATCH",
1080
1141
  "INVALID_INPUT",
1081
1142
  ],
1082
- description: "Consume a single-use execution receipt and execute the reviewed DAG (prefer task advance --approve-gate when gate token present). accepted/queued/running/operationId are NOT completion — supervise via operationGet/status/dagReport/dagDoctor/operationWait.",
1143
+ description: "Consume a single-use executionId from prepareDagExecution and execute the reviewed DAG. Do not pass a DAG path and do not bash `task advance --approve-gate`. accepted/queued/running/operationId are NOT completion — supervise via operationGet/status/dagReport/dagDoctor/operationWait.",
1083
1144
  inputParams: [
1084
1145
  {
1085
1146
  name: "executionId",
@@ -1102,7 +1163,7 @@ export function buildOperatorCapabilitiesDocument() {
1102
1163
  resultSchemaVersion: 1,
1103
1164
  envelopeSchemaVersion: 1,
1104
1165
  requiredErrorCodes: ["INVALID_INPUT", "NOT_FOUND"],
1105
- description: "Read-only R1 subgraph plan (no mutation). Call before dagRerun. Prefer primaryFailure.nodeId from dagReport. If eligible=false (writer/decision/fingerprint, unsafe shell, worker-managed, workspace/controller drift), do not force execute — Worker-owned runs use workerTaskRetry; standalone runs use standaloneTaskRerun or same-task advance after fixing the root cause (contract changes must be adopted first). Returns planHash required by execute.",
1166
+ description: "Read-only check for failed-node recovery; it does not execute. Call after dagReport with primaryFailure.nodeId. eligible=true returns the exact planHash required by dagRerun. eligible=false covers writer/decision/fingerprint, unsafe shell, Worker ownership, or workspace/controller drift: use workerTaskRetry for Worker/Task Pool failures, or standaloneTaskRerun after any required contract adopt for standalone runs. Do not force dagRerun or invent a new task.",
1106
1167
  inputParams: [
1107
1168
  {
1108
1169
  name: "runId",
@@ -1132,7 +1193,7 @@ export function buildOperatorCapabilitiesDocument() {
1132
1193
  "BINDING_DRIFT",
1133
1194
  "INVALID_INPUT",
1134
1195
  ],
1135
- description: "Execute R1 continuation from effective node. Requires planHash from a fresh dagRerunPlan (eligible=true). Prefer this over new task / standaloneTaskRerun for provider flake and safe downstream failures. Server enforces planHash/binding/fingerprint freshness.",
1196
+ description: "Continue the same DAG from the effective failed node by creating a continuation run. Requires a fresh eligible dagRerunPlan and its exact planHash. Prefer this for provider, network, rate-limit, timeout, and other safe downstream failures. Not a full task regenerate: use standaloneTaskRerun for that. Server rejects stale planHash, binding, or fingerprint drift.",
1136
1197
  inputParams: [
1137
1198
  {
1138
1199
  name: "runId",
@@ -1498,7 +1559,7 @@ export function buildOperatorCapabilitiesDocument() {
1498
1559
  "INVALID_INPUT",
1499
1560
  "HUMAN_CONFIRMATION_REQUIRED",
1500
1561
  ],
1501
- description: "Full standalone task regenerate validate execute with parent lineage. Only when node rerun plan is ineligible or primaryRecovery recommends rerun-task; the server checks read-only run facts before accepting. Regeneration reuses the CURRENT contract snapshot: if the failure requires contract changes (e.g. allowing a catalog index path), first update the contract (re-import PRD, or adopt externally-edited sources via `task contract adopt`) BEFORE calling this action, otherwise the regenerated DAG repeats the same failure.",
1562
+ description: "Regenerate the whole standalone DAG from the CURRENT contract, then validate and execute a new run with parent lineage and the latest unresolved verify/review feedback when available. This is NOT continue-from-failed-node (use dagRerun for that). Server rejects the call when dagRerunPlan is eligible, primaryRecovery.humanRequired=true, or run facts do not recommend rerun-task. Feedback is recovery context, not a contract rewrite; adopt required contract changes before calling or the new DAG repeats the same failure.",
1502
1563
  inputParams: [
1503
1564
  {
1504
1565
  name: "runId",
@@ -1542,7 +1603,7 @@ export function buildOperatorCapabilitiesDocument() {
1542
1603
  "INVALID_INPUT",
1543
1604
  "HUMAN_CONFIRMATION_REQUIRED",
1544
1605
  ],
1545
- description: "Requeue failed Task Pool task (Failed → Ready) via in-package pool store. Only when read-only validation confirms the task exists in Failed state; the server checks this before accepting.",
1606
+ description: "Requeue a Worker Task Pool task Failed → Ready. Not a DAG node rerun (use dagRerun) and not a standalone DAG regenerate (use standaloneTaskRerun). Confirm with workerPoolDoctor first; server accepts only Failed pool tasks. Pass featureId when known it must match the pool record.",
1546
1607
  inputParams: [
1547
1608
  {
1548
1609
  name: "taskId",
@@ -1568,6 +1629,66 @@ export function buildOperatorCapabilitiesDocument() {
1568
1629
  modelCallable: "always",
1569
1630
  humanConfirmation: "none",
1570
1631
  },
1632
+ {
1633
+ action: "dagDoctor",
1634
+ cli: "loop-agent dag doctor [--run-id <id>] --json",
1635
+ kind: "read",
1636
+ inputSchemaVersion: 1,
1637
+ resultSchemaVersion: 1,
1638
+ envelopeSchemaVersion: 1,
1639
+ requiredErrorCodes: ["NOT_FOUND", "INVALID_INPUT"],
1640
+ description: "Diagnose DAG run health. Omit runId for a repo-wide inventory (active/paused/completed + health issues). Pass runId for one run's liveness, heartbeat, failure node, and recovery hints. Use this to supervise stalls; it does not mutate the run.",
1641
+ inputParams: [
1642
+ {
1643
+ name: "runId",
1644
+ type: "string",
1645
+ required: false,
1646
+ description: "optional dag run id; omit to inventory all runs, pass to diagnose one run",
1647
+ },
1648
+ ],
1649
+ modelCallable: "always",
1650
+ humanConfirmation: "none",
1651
+ },
1652
+ {
1653
+ action: "dagStatus",
1654
+ cli: "loop-agent dag status --run-id <id>",
1655
+ kind: "read",
1656
+ inputSchemaVersion: 1,
1657
+ resultSchemaVersion: 1,
1658
+ envelopeSchemaVersion: 1,
1659
+ requiredErrorCodes: ["NOT_FOUND", "INVALID_INPUT"],
1660
+ description: "Read one DAG run's live status, current node, and liveness. Requires runId. Complements dagReport (terminal handoff) and dagDoctor (health diagnosis). Does not mutate the run.",
1661
+ inputParams: [
1662
+ {
1663
+ name: "runId",
1664
+ type: "string",
1665
+ required: true,
1666
+ description: "dag run id",
1667
+ },
1668
+ ],
1669
+ modelCallable: "always",
1670
+ humanConfirmation: "none",
1671
+ },
1672
+ {
1673
+ action: "workerPoolDoctor",
1674
+ cli: "agent-worker pool doctor --repo . --json",
1675
+ kind: "read",
1676
+ inputSchemaVersion: 1,
1677
+ resultSchemaVersion: 1,
1678
+ envelopeSchemaVersion: 1,
1679
+ requiredErrorCodes: ["INVALID_INPUT", "NOT_FOUND"],
1680
+ description: "Read-only Task Pool inventory (legacy + v2). Use before workerTaskRetry to confirm the task exists and status is Failed. Optional taskId filters the returned inventory to that task.",
1681
+ inputParams: [
1682
+ {
1683
+ name: "taskId",
1684
+ type: "string",
1685
+ required: false,
1686
+ description: "optional task id to focus the inventory",
1687
+ },
1688
+ ],
1689
+ modelCallable: "always",
1690
+ humanConfirmation: "none",
1691
+ },
1571
1692
  ...OFFICIAL_ACTIONS,
1572
1693
  ];
1573
1694
  return {
@@ -1947,12 +2068,12 @@ export const OPERATOR_COMMAND_COVERAGE = Object.freeze([
1947
2068
  },
1948
2069
  {
1949
2070
  command: "loop-agent knowledge curate",
1950
- coverage: "model-callable",
2071
+ coverage: "advanced",
1951
2072
  action: "knowledgeCurate",
1952
2073
  source: "loop-agent",
2074
+ note: "Writes knowledge proposals (conditional on --output); not model-callable.",
1953
2075
  },
1954
- {
1955
- command: "loop-agent knowledge query",
2076
+ { command: "loop-agent knowledge query",
1956
2077
  coverage: "model-callable",
1957
2078
  action: "knowledgeQuery",
1958
2079
  source: "loop-agent",
@@ -2527,9 +2648,10 @@ export function assertCoverageManifestConsistent() {
2527
2648
  capability.humanConfirmation !== "required"))
2528
2649
  throw new Error(`invalid required gate classification: ${entry.action}`);
2529
2650
  if (entry.coverage === "advanced") {
2530
- const expected = capability.kind === "read" ? "always" : "never";
2531
- if (capability.modelCallable !== expected) {
2532
- throw new Error(`invalid advanced classification: ${entry.action} (expected modelCallable=${expected} for kind=${capability.kind})`);
2651
+ // 2026-08-18: advanced actions are never model-callable (read or
2652
+ // mutation) — see officialModelCallable. UI dispatch stays available.
2653
+ if (capability.modelCallable !== "never") {
2654
+ throw new Error(`invalid advanced classification: ${entry.action} (expected modelCallable=never)`);
2533
2655
  }
2534
2656
  }
2535
2657
  }
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { isOpenspecSpecFilePath } from "../shared/openspec-spec.js";
2
3
  export const taskFlowSchema = z.enum([
3
4
  "auto",
4
5
  "micro",
@@ -65,6 +66,24 @@ export const frontendMockConfigSchema = z.object({
65
66
  serviceRoot: z.string().min(1).optional(),
66
67
  verifyCommands: z.array(frontendMockVerifyCommandSchema).optional().default([]),
67
68
  });
69
+ /** OpenSpec gate policy for frontend prewrite: cited (default) vs scan-strict. */
70
+ export const frontendOpenspecPolicySchema = z.enum(["cited", "scan-strict"]);
71
+ /**
72
+ * Frontend OpenSpec gate configuration. `cited` (the task-config default) makes
73
+ * the prewrite gate verify contract-declared requiredReadPaths plus task-source
74
+ * citations instead of the full generation-time directory snapshot; `scan-strict`
75
+ * keeps the auto-discovered full-read semantics.
76
+ */
77
+ export const frontendOpenspecConfigSchema = z.object({
78
+ policy: frontendOpenspecPolicySchema.optional().default("cited"),
79
+ requiredReadPaths: z
80
+ .array(z
81
+ .string()
82
+ .refine((candidate) => !candidate.includes("\\") &&
83
+ isOpenspecSpecFilePath(candidate), "frontendOpenspec.requiredReadPaths entries must be repo-relative supported files under openspec/schemas/, openspec/project-specs/, or ai_workspace/"))
84
+ .optional()
85
+ .default([]),
86
+ });
68
87
  /** Batch limits and gate profile for the browser-driven frontend test DAG.
69
88
  * Token fields are post-case stop thresholds, not model-provider hard caps. */
70
89
  export const frontendTestConfigSchema = z.object({
@@ -105,6 +124,26 @@ export const frontendTestConfigSchema = z.object({
105
124
  .strict()
106
125
  .optional(),
107
126
  });
127
+ /** Backend-test artifact layout and pipeline mode configuration (plan A/B/D). */
128
+ export const backendTestConfigSchema = z
129
+ .object({
130
+ /** Repository-relative test root. Default "testcase". */
131
+ testRoot: z.string().min(1).optional(),
132
+ /** Markdown subdirectory relative to testRoot. Default "md". */
133
+ markdownRel: z.string().min(1).optional(),
134
+ /** Pytest script subdirectory relative to testRoot. Default "." (testRoot itself). */
135
+ scriptRel: z.string().min(1).optional(),
136
+ /** User-provided shared setup document (plan B). Read-only bound source. */
137
+ sharedSetupDoc: z.string().min(1).optional(),
138
+ /** Pipeline mode: full 16-node chain (default) or gap-fill incremental DAG (plan D). */
139
+ mode: z.enum(["full", "gap-fill"]).optional(),
140
+ /** Required for mode=gap-fill: user missing-scenario document path. */
141
+ gapDoc: z.string().min(1).optional(),
142
+ /** gap-fill pytest execution scope: only affected items (default) or all eligible. */
143
+ executeScope: z.enum(["affected", "all"]).optional(),
144
+ })
145
+ .strict()
146
+ .optional();
108
147
  export const convergenceConfigSchema = z.object({
109
148
  enabled: z.boolean().optional().default(false),
110
149
  maxPasses: z.number().int().positive().optional().default(3),
@@ -175,6 +214,10 @@ const taskConfigObjectSchema = z.object({
175
214
  frontendMock: frontendMockConfigSchema.optional(),
176
215
  /** Frontend browser-test batch and post-case token-stop configuration. */
177
216
  frontendTest: frontendTestConfigSchema.optional(),
217
+ /** Frontend OpenSpec gate policy and contract-declared required read paths. */
218
+ frontendOpenspec: frontendOpenspecConfigSchema.optional(),
219
+ /** Backend-test layout / shared-setup / gap-fill configuration. */
220
+ backendTest: backendTestConfigSchema,
178
221
  notes: z.string().optional().default(""),
179
222
  });
180
223
  export const taskConfigSchema = z.preprocess((raw) => {