@tea-agent/loop-agent 0.42.0-next.14 → 0.42.0-next.15

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 (92) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/build-stamp.json +3 -3
  3. package/dist/executors/dag-pi-executor.js +617 -94
  4. package/dist/executors/shell-executor.js +4 -0
  5. package/dist/worker/console/chat/pi-runtime.js +45 -2
  6. package/dist/worker/console/chat/resource-loader.js +4 -1
  7. package/dist/worker/console/chat/routes.js +8 -0
  8. package/dist/worker/console/chat/subagents/agent-tool.js +62 -0
  9. package/dist/worker/console/chat/subagents/explore-agent.js +169 -0
  10. package/dist/worker/console/chat/subagents/index.js +5 -0
  11. package/dist/worker/console/chat/subagents/orchestrator.js +273 -0
  12. package/dist/worker/console/chat/subagents/tool-policy.js +53 -0
  13. package/dist/worker/console/chat/subagents/types.js +13 -0
  14. package/dist/worker/console/chat/tool-preview.js +10 -0
  15. package/dist/worker/console/chat/tools.js +11 -1
  16. package/dist/worker/console/interview/tools.js +1 -0
  17. package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BGMbAdAG.js → abnfDiagram-N423BO3Z-CgXb0EVO.js} +1 -1
  18. package/dist/worker/console/static/assets/{arc-CJu1LND8.js → arc-DN59MZqN.js} +1 -1
  19. package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-BmJh9gMQ.js → architectureDiagram-T3A2C74G-BUk3sWpn.js} +1 -1
  20. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-BWjaX3ZF.js → blockDiagram-VBNYF7ZC-IH-cPBFE.js} +1 -1
  21. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-CLEOAxLB.js → c4Diagram-5PPSVZJV-BJWf1nGo.js} +1 -1
  22. package/dist/worker/console/static/assets/channel-i1DjpDIw.js +1 -0
  23. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-CydnyQUX.js → chunk-2GRJ4B5K-BCPb5H0y.js} +1 -1
  24. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-tjJ1IoZ1.js → chunk-2Q5K7J3B-Cfs3jeW2.js} +1 -1
  25. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-DR358Phd.js → chunk-5RXB4S5H-BhQI1B_T.js} +1 -1
  26. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-B-LuWFZD.js → chunk-5VM5RSS4-Cc_m4gyV.js} +1 -1
  27. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-FG53fA6v.js → chunk-6Q2QTUOP-JPqDS3IV.js} +1 -1
  28. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-Bkt-w8SZ.js → chunk-GF5L2VYU-AeGX6EAg.js} +1 -1
  29. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-WxHo0z2I.js → chunk-JWPE2WC7-pEyTjekV.js} +1 -1
  30. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CqHrBJhp.js → chunk-KBJHAD2P-Bi5UopKd.js} +1 -1
  31. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-D4MVae_f.js → chunk-RYQCIY6F-FkGFJxgQ.js} +1 -1
  32. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-CamBh0Ll.js → chunk-XXDRQBXY-D-7LGrV2.js} +1 -1
  33. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-DgDRdE1V.js +1 -0
  34. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-DgDRdE1V.js +1 -0
  35. package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-C3qheCuW.js → cose-bilkent-JH36ORCC-CCEDNDaX.js} +1 -1
  36. package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-DQlWfkS7.js → cynefin-VYW2F7L2-DDd-t7fm.js} +1 -1
  37. package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-BAxa9rFb.js → cynefinDiagram-MW4NZA55-LWe4Ikzr.js} +1 -1
  38. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-YM09nLJw.js → dagre-VZM6K2ZE-BBCZScc-.js} +1 -1
  39. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-I4W9EJj2.js → diagram-7IWD3JNH-B6liRVig.js} +1 -1
  40. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-DH8eJ8Ff.js → diagram-B4RE2ZJO-DO_hIrpW.js} +1 -1
  41. package/dist/worker/console/static/assets/{diagram-LBJQPF4R-D0D0ntDW.js → diagram-LBJQPF4R-dmCy93uR.js} +1 -1
  42. package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BIISKq1s.js → diagram-Q27KOJAE-D6mFTIxP.js} +1 -1
  43. package/dist/worker/console/static/assets/{diagram-UB23O5K3--xyAWj0w.js → diagram-UB23O5K3-DCteVUfY.js} +1 -1
  44. package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-B3sYXLJ4.js → ebnfDiagram-BXEA7PRR-DTv530VK.js} +1 -1
  45. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-zRSYWhJP.js → erDiagram-JOGREHBK-DCXDMxCr.js} +1 -1
  46. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-BUYlie03.js → flowDiagram-UKHOOZJN-BwEBLOJh.js} +1 -1
  47. package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-DP4kzzrM.js → ganttDiagram-PKOTCBZU-Ck-Vymjm.js} +1 -1
  48. package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-CAPoUxTF.js → gitGraphDiagram-DS77QQ5N-Hqs6X_3L.js} +1 -1
  49. package/dist/worker/console/static/assets/{index-CWhTyxvc.js → index-BmMi-Bve.js} +71 -71
  50. package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-BXPfjekV.js → infoDiagram-6WML65LV-Cjc6M9eg.js} +1 -1
  51. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-aOI3pV6t.js → ishikawaDiagram-WSZJBQD7-CPchYZMl.js} +1 -1
  52. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-DAPZuvi4.js → journeyDiagram-NVQOT4AX-BABdJNNC.js} +1 -1
  53. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-atwDzL3C.js → kanban-definition-27J2QSJJ-1oXhbM4j.js} +1 -1
  54. package/dist/worker/console/static/assets/{linear-D5E09qji.js → linear-PTmQ9LkV.js} +1 -1
  55. package/dist/worker/console/static/assets/{mermaid.core-CE4idY-s.js → mermaid.core-B6Lxil0V.js} +5 -5
  56. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-CbZxtPca.js → mindmap-definition-FAOFIHXS-BUqjNGEw.js} +1 -1
  57. package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-De-FYEte.js → pegDiagram-VL7TDLO6-8D1N-orJ.js} +1 -1
  58. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-Bs0USobz.js → pieDiagram-7S7Q4E2Y-BlPMN9d9.js} +1 -1
  59. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-Bq3ZrGCJ.js → quadrantDiagram-CIZ2JOQS-BIL5YDes.js} +1 -1
  60. package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-Bk8ojyIj.js → railroadDiagram-AXF67PYL-Dqmil3ie.js} +1 -1
  61. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-CGhoyws1.js → requirementDiagram-LRYGKXZP-C_-Dp4mH.js} +1 -1
  62. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-DmVSQs3b.js → sankeyDiagram-W5VNT64P-C0s5-bQS.js} +1 -1
  63. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-C80h1u0Q.js → sequenceDiagram-SI44F4Z6-DiVCHPfi.js} +1 -1
  64. package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-CcbksQVZ.js → sizeCapture-X5ZJPWSS-CxQ9WVvx.js} +1 -1
  65. package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-CFTTTQKj.js → stateDiagram-OKZ733FA-D9mFHA-Y.js} +1 -1
  66. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-BqXQxfFC.js +1 -0
  67. package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-Cw7Jr7Tg.js → swimlanes-SLNWSIFB-DDnC5l-M.js} +2 -2
  68. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CXwWNRJl.js +8 -0
  69. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-CVcdTVa5.js → timeline-definition-Z64GVDOM-C8QySPC-.js} +1 -1
  70. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-BpLbmWp9.js → vennDiagram-T6HMQDX7-BeYdDiz6.js} +1 -1
  71. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-6PXfbwj-.js → wardleyDiagram-T6FBY63Y-D8hjFWLH.js} +1 -1
  72. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-Bjkcz4ih.js → xychartDiagram-ELKLHX3M-ClqG_JGK.js} +1 -1
  73. package/dist/worker/console/static/index.html +1 -1
  74. package/dist/worker/console/static-src/operator-chat/tools-catalog.js +21 -2
  75. package/dist/workflows/dag/frontend-contract-facts.js +130 -0
  76. package/dist/workflows/dag/frontend-design-policy.js +99 -14
  77. package/dist/workflows/dag/frontend-implementation-contract.js +56 -8
  78. package/dist/workflows/dag/frontend-plan-render.js +13 -2
  79. package/dist/workflows/dag/frontend-shadow-dual-write.js +1 -0
  80. package/dist/workflows/dag/frontend-typed-event-store.js +3 -0
  81. package/dist/workflows/dag/init-hybrid.js +7 -3
  82. package/dist/workflows/dag/node-execution.js +54 -16
  83. package/docs/operations/README.md +1 -0
  84. package/docs/templates/frontend-implementation-contract.schema.json +34 -2
  85. package/package.json +2 -3
  86. package/skills/frontend-plan/SKILL.md +8 -0
  87. package/skills/frontend-plan/references/decision-contract.md +26 -3
  88. package/dist/worker/console/static/assets/channel-DOsaUk1k.js +0 -1
  89. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D4-D49vY.js +0 -1
  90. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D4-D49vY.js +0 -1
  91. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-C4YCesmi.js +0 -1
  92. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-lN2U_DLl.js +0 -8
@@ -28,31 +28,37 @@ function sortFindings(findings) {
28
28
  * visual UI-state dimension (it cannot cover behavioural interactions). */
29
29
  export function checkUiDesignCoverage(contract) {
30
30
  const findings = [];
31
- const purposes = new Set((contract.uiComponentChoices ?? []).map((choice) => choice.purpose));
32
- const hasStyling = Boolean(contract.stylingStrategy?.trim());
33
- // Reuse of an existing component/pattern covers behavioural interactions
34
- // without forcing one uiComponentChoices row per interaction: the model
35
- // should not enumerate every click/hover on a reused Button. Only
36
- // interactions with no reuse and no explicit purpose are flagged.
37
- const hasReuseChoice = (contract.uiComponentChoices ?? []).some((choice) => choice.decision === "reuse-existing");
31
+ // Explicit per-id coverage (dogfood r-plan-quality): one choice covers an
32
+ // interaction/state when its purpose equals the name OR the choice lists
33
+ // the name in covers. The old wildcards are gone — a single reuse-existing
34
+ // row no longer passes every interaction, and a non-empty stylingStrategy
35
+ // no longer passes every state.
36
+ const covered = new Set();
37
+ for (const choice of contract.uiComponentChoices ?? []) {
38
+ if (choice.purpose.trim())
39
+ covered.add(choice.purpose);
40
+ for (const id of choice.covers ?? []) {
41
+ if (id.trim())
42
+ covered.add(id);
43
+ }
44
+ }
38
45
  for (const state of contract.uiStates) {
39
46
  if (!state.applicable)
40
47
  continue;
41
- const covered = purposes.has(state.name) || hasStyling;
42
- if (!covered) {
48
+ if (!covered.has(state.name)) {
43
49
  findings.push({
44
50
  code: "ui-design-coverage-missing",
45
- message: `applicable UI state "${state.name}" has no matching uiComponentChoices.purpose or stylingStrategy`,
51
+ message: `applicable UI state "${state.name}" is not covered by any uiComponentChoices purpose or covers entry`,
46
52
  path: state.name,
47
53
  });
48
54
  }
49
55
  }
50
56
  for (const interaction of contract.interactions) {
51
- if (purposes.has(interaction.name) || hasReuseChoice)
57
+ if (covered.has(interaction.name))
52
58
  continue;
53
59
  findings.push({
54
60
  code: "ui-design-coverage-missing",
55
- message: `interaction "${interaction.name}" has no matching uiComponentChoices.purpose and no reuse-existing choice covering it`,
61
+ message: `interaction "${interaction.name}" is not covered by any uiComponentChoices purpose or covers entry`,
56
62
  path: interaction.name,
57
63
  });
58
64
  }
@@ -158,7 +164,7 @@ export function checkMockStrategy(contract, allowedMockStrategies) {
158
164
  * A component specReference must still not point into clearly non-component
159
165
  * spec areas — templates and the ai_workspace governance subtree cannot be the
160
166
  * authoritative component definition. */
161
- export function checkComponentChoice(contract, componentSpecCandidatePaths) {
167
+ export function checkComponentChoice(contract, componentSpecCandidatePaths, options) {
162
168
  const findings = [];
163
169
  const candidates = new Set(componentSpecCandidatePaths.map(normalizeRelativePath));
164
170
  const isNonComponentSpecArea = (path) => {
@@ -200,6 +206,23 @@ export function checkComponentChoice(contract, componentSpecCandidatePaths) {
200
206
  });
201
207
  }
202
208
  }
209
+ else if (choice.decision === "reuse-existing") {
210
+ if (!(choice.evidencePath && choice.evidencePath.trim().length > 0)) {
211
+ findings.push({
212
+ code: "component-reuse-evidence-missing",
213
+ message: `reuse-existing component choice #${index} is missing evidencePath naming the existing repo file that proves the reuse; a greenfield path must use decision=new`,
214
+ path: choice.purpose,
215
+ });
216
+ }
217
+ else if (options?.hasFreshPathEvidence &&
218
+ !options.hasFreshPathEvidence(choice.evidencePath)) {
219
+ findings.push({
220
+ code: "component-reuse-path-not-fresh",
221
+ message: `reuse-existing component choice #${index} evidencePath "${choice.evidencePath}" has no fresh existence evidence (path not found); reuse requires an existing file — use decision=new for greenfield paths`,
222
+ path: choice.evidencePath,
223
+ });
224
+ }
225
+ }
203
226
  else if (choice.decision === "new") {
204
227
  if (!choice.specReference || !choice.specReference.path) {
205
228
  findings.push({
@@ -371,6 +394,64 @@ export function checkDesignApproval(designApproval) {
371
394
  }
372
395
  return [];
373
396
  }
397
+ /**
398
+ * UX vocabulary collisions (item ③, dogfood dag-1788504923861-0f7b17a9):
399
+ * prioritize-planner-task / prioritizePlannerTask / prioritize-planner-tasks
400
+ * are one behavior renamed three ways. Case/separator-insensitive duplicates
401
+ * inside interactions or inside uiStates are blocking.
402
+ */
403
+ export function checkUxNameCollisions(contract) {
404
+ const findings = [];
405
+ const normalize = (name) => name.toLowerCase().replace(/[^a-z0-9]/g, "");
406
+ const collisions = (names, kind) => {
407
+ const byNormalized = new Map();
408
+ const found = [];
409
+ for (const name of names) {
410
+ const key = normalize(name);
411
+ if (!key)
412
+ continue;
413
+ const existing = byNormalized.get(key);
414
+ if (existing !== undefined && existing !== name) {
415
+ found.push({
416
+ code: "ux-name-collision",
417
+ message: `"${name}" and "${existing}" are the same ${kind} name up to case/separator — one behavior must keep one stable name`,
418
+ path: name,
419
+ });
420
+ }
421
+ else {
422
+ byNormalized.set(key, name);
423
+ }
424
+ }
425
+ return found;
426
+ };
427
+ findings.push(...collisions(contract.interactions.map((interaction) => interaction.name), "interaction"));
428
+ findings.push(...collisions(contract.uiStates.map((state) => state.name), "UI state"));
429
+ return findings;
430
+ }
431
+ /**
432
+ * Deliverable completeness (item ⑦): every file explicitly declared by Contract
433
+ * from frozen source fragments (projected into targets.requiredDeliverables)
434
+ * must be planned — bound by some requirement's implementationTargets or a
435
+ * verification target's file, or listed in targets.files. allowedPaths is a
436
+ * write boundary and never implies coverage.
437
+ */
438
+ export function checkRequiredDeliverables(contract) {
439
+ const required = contract.targets.requiredDeliverables ?? [];
440
+ if (required.length === 0)
441
+ return [];
442
+ const planned = new Set([
443
+ ...contract.targets.files,
444
+ ...contract.requirements.flatMap((requirement) => requirement.implementationTargets),
445
+ ...contract.verificationTargets.map((target) => target.file),
446
+ ]);
447
+ return required
448
+ .filter((path) => !planned.has(path))
449
+ .map((path) => ({
450
+ code: "required-deliverable-unplanned",
451
+ message: `Contract declares required deliverable "${path}" but no requirement implementationTarget, verification target, or targets.files entry plans it`,
452
+ path,
453
+ }));
454
+ }
374
455
  /** Aggregate the deterministic design-policy checks into a single
375
456
  * deterministic result. Any finding blocks; an empty finding list approves. */
376
457
  export function evaluateFrontendDesignPolicy(input) {
@@ -379,10 +460,14 @@ export function evaluateFrontendDesignPolicy(input) {
379
460
  ...checkUiDesignCoverage(input.contract),
380
461
  ...checkSourceFreshness(input.contract, input.sourceFreshness),
381
462
  ...checkMockStrategy(input.contract, input.allowedMockStrategies),
382
- ...checkComponentChoice(input.contract, input.componentSpecCandidatePaths),
463
+ ...checkComponentChoice(input.contract, input.componentSpecCandidatePaths, input.hasFreshPathEvidence
464
+ ? { hasFreshPathEvidence: input.hasFreshPathEvidence }
465
+ : undefined),
383
466
  ...checkTargetPaths(input.contract, input.writeSetPatterns),
384
467
  ...checkDependencies(input.contract, input.allowedDependencies),
385
468
  ...checkUiStateAttribution(input.contract),
469
+ ...checkUxNameCollisions(input.contract),
470
+ ...checkRequiredDeliverables(input.contract),
386
471
  ]);
387
472
  const classification = findings.length > 0 ? "blocked" : "approved";
388
473
  const result = {
@@ -9,10 +9,12 @@ import { findPackageRoot } from "../../shared/package-metadata.js";
9
9
  import { pathMatchesPattern } from "../../shared/git-progress.js";
10
10
  import { resolveDagTaskSourcePath } from "../../task/dag-source-paths.js";
11
11
  import { readTypedEventStoreFromJsonl } from "./frontend-typed-event-store.js";
12
+ import { extractRequiredDeliverablePaths } from "./frontend-contract-facts.js";
13
+ export { extractRequiredDeliverablePaths } from "./frontend-contract-facts.js";
12
14
  // Cycle-safe value imports: the check functions are hoisted declarations used
13
15
  // only at call time, so the contract module and the policy module can depend
14
16
  // on each other without module-init ordering issues.
15
- import { checkDependencies, checkTargetPaths, checkUiDesignCoverage, checkUiStateAttribution, } from "./frontend-design-policy.js";
17
+ import { checkDependencies, checkTargetPaths, checkUiDesignCoverage, checkUiStateAttribution, checkRequiredDeliverables, checkUxNameCollisions, } from "./frontend-design-policy.js";
16
18
  import { isDagSourceBindingV2 } from "./types.js";
17
19
  import { canonicalContractRel, classifyStructuredContractFailure, formatStructuredArtifactPointer, persistRuntimeSkeleton, } from "./structured-output-repair.js";
18
20
  import { renderFrontendPlanMarkdown } from "./frontend-plan-render.js";
@@ -600,12 +602,30 @@ const uiComponentChoiceSchema = z
600
602
  decision: z.enum(["specified", "reuse-existing", "new"]),
601
603
  specReference: uiComponentSpecReferenceSchema.nullable().optional(),
602
604
  // Optional: the decision enum already carries the semantic (specified →
603
- // specReference, new → task-source traceability, reuse-existing → no
604
- // rationale needed).
605
- // Omit for reuse-existing to keep plan output small.
605
+ // specReference, new → task-source traceability, reuse-existing →
606
+ // evidencePath). Omit for reuse-existing to keep plan output small.
606
607
  rationale: z.string().min(1).optional(),
608
+ // Multi-id coverage (dogfood r-plan-quality): ONE choice may cover many
609
+ // UI states/interactions explicitly instead of the old implicit
610
+ // "reuse-existing covers everything" wildcard.
611
+ covers: z.array(z.string().min(1)).optional(),
612
+ // reuse-existing evidence (dogfood dag-1788504923861-0f7b17a9: 18
613
+ // reuse-existing rows cited conventions in a not-yet-written
614
+ // src/planner.ts): a repo-relative path to the existing file that
615
+ // proves the reuse. Enforced by superRefine + fresh-existence checks.
616
+ evidencePath: safePath.optional(),
607
617
  })
608
- .strict();
618
+ .strict()
619
+ .superRefine((choice, ctx) => {
620
+ if (choice.decision === "reuse-existing" &&
621
+ !(choice.evidencePath && choice.evidencePath.trim().length > 0)) {
622
+ ctx.addIssue({
623
+ code: z.ZodIssueCode.custom,
624
+ path: ["evidencePath"],
625
+ message: "decision=reuse-existing requires evidencePath naming the existing repo file that proves the reuse; use decision=new for greenfield paths",
626
+ });
627
+ }
628
+ });
609
629
  const uiComponentChoicesSchema = z.array(uiComponentChoiceSchema);
610
630
  /**
611
631
  * Normalize unstable model emissions before the strict schema sees them:
@@ -680,6 +700,11 @@ export const frontendImplementationContractSchema = z
680
700
  files: z.array(safePath).min(1),
681
701
  routes: z.array(z.string().startsWith("/")).optional(),
682
702
  publicApiChanges: z.array(z.string().min(1)).optional(),
703
+ // Runtime-owned deliverable contract (dogfood r-plan-quality):
704
+ // explicit, source-bound file inventory committed by Contract.
705
+ // The design-policy completeness gate checks ONLY these —
706
+ // allowedPaths is a write boundary, not a coverage obligation.
707
+ requiredDeliverables: z.array(safePath).optional(),
683
708
  })
684
709
  .strict(),
685
710
  requirements: z.array(z
@@ -1634,7 +1659,12 @@ export function compactFrontendImplementationContract(value) {
1634
1659
  const targets = asRecord(record.targets);
1635
1660
  if (targets) {
1636
1661
  const compactTargets = { ...targets };
1637
- for (const field of ["files", "routes", "publicApiChanges"]) {
1662
+ for (const field of [
1663
+ "files",
1664
+ "routes",
1665
+ "publicApiChanges",
1666
+ "requiredDeliverables",
1667
+ ]) {
1638
1668
  if (Object.hasOwn(compactTargets, field)) {
1639
1669
  compactTargets[field] = dedupeJsonArray(compactTargets[field]);
1640
1670
  }
@@ -2425,6 +2455,16 @@ export async function analyzeFrontendImplementationContract(input) {
2425
2455
  files: referencedConcretePaths,
2426
2456
  };
2427
2457
  }
2458
+ // Both Plan precheck and policy materialization consume this exact inventory.
2459
+ // Never trust a Plan patch or infer delivery obligations from prose.
2460
+ const contractRecords = await readTypedEventStoreFromJsonl(path.join(input.runDir, input.contractNodeId ?? "frontend-contract-pi", "contract-typed-facts.jsonl"));
2461
+ const requiredDeliverables = extractRequiredDeliverablePaths(contractRecords
2462
+ .filter((record) => record.phase === "committed")
2463
+ .map((record) => record.fact));
2464
+ delete result.data.targets.requiredDeliverables;
2465
+ if (requiredDeliverables.length > 0) {
2466
+ result.data.targets.requiredDeliverables = requiredDeliverables;
2467
+ }
2428
2468
  const blockingGaps = [
2429
2469
  ...(result.data.evidenceGaps ?? []),
2430
2470
  ...result.data.requirements.flatMap((item) => item.evidenceGap ? [item.evidenceGap] : []),
@@ -2632,6 +2672,7 @@ const FRONTEND_PLAN_PATCH_PROTECTED_PATHS = [
2632
2672
  "/sourceBinding",
2633
2673
  "/riskLevel",
2634
2674
  "/targets/files",
2675
+ "/targets/requiredDeliverables",
2635
2676
  "/mockApi/productionDefaultOff",
2636
2677
  ];
2637
2678
  const PLAN_LEDGER_FACT_KINDS_FOR_COMPILE = [
@@ -2680,6 +2721,8 @@ function frontendPlanPatchProtectedPathViolations(patch) {
2680
2721
  const targets = asRecord(record.targets);
2681
2722
  if (targets && Object.hasOwn(targets, "files"))
2682
2723
  violations.push("/targets/files");
2724
+ if (targets && Object.hasOwn(targets, "requiredDeliverables"))
2725
+ violations.push("/targets/requiredDeliverables");
2683
2726
  const mockApi = asRecord(record.mockApi);
2684
2727
  if (mockApi && Object.hasOwn(mockApi, "productionDefaultOff"))
2685
2728
  violations.push("/mockApi/productionDefaultOff");
@@ -2864,6 +2907,8 @@ export async function analyzeFrontendPlanPatchCandidate(input) {
2864
2907
  const policyPreFindings = [
2865
2908
  ...checkUiDesignCoverage(analysis.canonical),
2866
2909
  ...checkUiStateAttribution(analysis.canonical),
2910
+ ...checkRequiredDeliverables(analysis.canonical),
2911
+ ...checkUxNameCollisions(analysis.canonical),
2867
2912
  ...checkDependencies(analysis.canonical, await deriveAllowedDependenciesFromRun(input.runDir)),
2868
2913
  ...checkTargetPaths(analysis.canonical, await deriveWriteSetFromRun(input.runDir)),
2869
2914
  ];
@@ -3082,9 +3127,11 @@ export async function buildContractFromCommittedFacts(input) {
3082
3127
  }
3083
3128
  // b. Committed contract terminal fact (contract-finalized).
3084
3129
  const contractRecords = await readTypedEventStoreFromJsonl(path.join(input.runDir, contractNodeId, "contract-typed-facts.jsonl"));
3085
- const contractKinds = new Set(contractRecords
3130
+ const committedContractFacts = contractRecords
3086
3131
  .filter((record) => record.phase === "committed")
3087
- .map((record) => record.fact.kind)
3132
+ .map((record) => record.fact);
3133
+ const contractKinds = new Set(committedContractFacts
3134
+ .map((fact) => fact?.kind)
3088
3135
  .filter((kind) => typeof kind === "string"));
3089
3136
  if (!contractKinds.has("contract-finalized")) {
3090
3137
  return {
@@ -3139,6 +3186,7 @@ export async function buildContractFromCommittedFacts(input) {
3139
3186
  runDir: input.runDir,
3140
3187
  rawContractText: serializeDeterministicJson(merged),
3141
3188
  sourceBinding: input.sourceBinding,
3189
+ contractNodeId,
3142
3190
  });
3143
3191
  return {
3144
3192
  ok: true,
@@ -12,8 +12,19 @@ function bulletList(items) {
12
12
  return "";
13
13
  return items.map((item) => `- ${item}`).join("\n");
14
14
  }
15
+ /** The runtime's deterministic fallback for an outcome the plan did not
16
+ * author. It is bookkeeping for the schema's non-empty constraint, not user
17
+ * prose — the renderer must never present it as requirement content. */
18
+ const IMPLIED_OUTCOME_PREFIX = "implied by contract:";
15
19
  function requirementsCoverage(contract) {
16
- const lines = contract.requirements.map((requirement) => `- ${requirement.id}: ${requirement.expectedOutcome}`);
20
+ const lines = contract.requirements.map((requirement) => {
21
+ const targets = requirement.implementationTargets.join(", ");
22
+ const verificationTargets = requirement.verificationTargetIds.join(", ");
23
+ const authoredOutcome = requirement.expectedOutcome.startsWith(IMPLIED_OUTCOME_PREFIX)
24
+ ? ""
25
+ : ` — ${requirement.expectedOutcome}`;
26
+ return `- ${requirement.id} → ${targets || "(no targets)"} [${verificationTargets || "no VT"}]${authoredOutcome}`;
27
+ });
17
28
  return lines.length > 0 ? lines.join("\n") : "_(no requirements)_";
18
29
  }
19
30
  function uiStateHandling(contract) {
@@ -98,7 +109,7 @@ export function renderFrontendPlanMarkdown(contract) {
98
109
  interactionNotes(contract),
99
110
  "",
100
111
  "## Mock & API Strategy",
101
- contract.mockApi.strategy,
112
+ contract.mockApi?.strategy || "_(not specified)_",
102
113
  "",
103
114
  "## Dependency Policy",
104
115
  contract.dependencyPolicy || "_(not specified)_",
@@ -226,6 +226,7 @@ export function parseTargetSurfaceFacts(text) {
226
226
  }
227
227
  export const PLAN_LEDGER_FACT_KINDS = [
228
228
  "target-surface",
229
+ "state-registry",
229
230
  "component-choice",
230
231
  "state-flow",
231
232
  "data-flow",
@@ -95,6 +95,8 @@ export const CONTRACT_FACT_KINDS = [
95
95
  "open-question",
96
96
  "split-proposal",
97
97
  "openspec-selection",
98
+ "ui-state-declaration",
99
+ "required-deliverables",
98
100
  "contract-finalized",
99
101
  ];
100
102
  export const CONTRACT_TERMINAL_FACT_KINDS = ["contract-finalized"];
@@ -124,6 +126,7 @@ export const PLAN_RECORD_FACT_KINDS = [
124
126
  "plan-requirement",
125
127
  "plan-verification-target",
126
128
  "plan-evidence-gap",
129
+ "state-registry",
127
130
  ];
128
131
  /**
129
132
  * A+B (AC-009): typed issue category shared by review and design change
@@ -3344,13 +3344,16 @@ async function buildFrontendHybridDagFromTask(sources) {
3344
3344
  allowedPaths: readOnlyPaths,
3345
3345
  forbiddenPaths,
3346
3346
  skills: FRONTEND_CONTRACT_SKILLS,
3347
- outputContract: "Typed requirement facts plus a concise Markdown contract. Submit through the incremental typed tools record_requirement / record_constraint / record_evidence_expectation / record_handoff_intent / record_open_question / record_split_proposal / record_openspec_selection, then call finalize_contract exactly once. Requirements use stable REQ/BR/AC identifiers with source spans and a disposition (explicit | repository-resolvable | assumption | blocking); each requirement registers evidence expectations across static/behavior/Mock/real-integration (required | optional | not-applicable), and UI-visible or interactive requirements register a non-blocking frontend-test handoff intent. End finalize_contract with a single contract disposition of ready | ready-with-assumptions | blocked. Cover scope, non-goals, acceptance criteria, UI states, target runtime environment, risks, and verification expectations; do not fix target files, components, or implementation methods as requirements. When OpenSpec candidates exist, classify only the ones you actually use: call record_openspec_selection once per required/relevant path; never enumerate irrelevant candidates (unmentioned defaults to irrelevant) and never emit a fenced selection JSON. No file writes.",
3347
+ outputContract: "Typed requirement facts plus a concise Markdown contract. Submit through the incremental typed tools record_requirement / record_constraint / record_evidence_expectation / record_handoff_intent / record_open_question / record_split_proposal / record_ui_state / record_required_deliverables / record_openspec_selection, then call finalize_contract exactly once. record_requirement takes only the canonical ledger requirement id — the runtime owns the authoritative text, source spans, fragment bindings, and disposition. UI-visible or interactive requirements register a non-blocking frontend-test handoff intent, and any source-declared UI-state table is extracted verbatim through record_ui_state. End finalize_contract with a single contract disposition of ready | ready-with-assumptions | blocked. Cover scope, non-goals, acceptance criteria, UI states, target runtime environment, risks, and verification expectations; do not fix target files, components, or implementation methods as requirements. When OpenSpec candidates exist, classify only the ones you actually use: call record_openspec_selection once per required/relevant path; never enumerate irrelevant candidates (unmentioned defaults to irrelevant) and never emit a fenced selection JSON. No file writes.",
3348
3348
  subtask_prompt: [
3349
3349
  "OUTPUT BUDGET DISCIPLINE (hard requirement, extreme-environment safe): the provider output window is small — NEVER attempt to emit the whole contract in one response; a single large JSON dump will be truncated and rejected. Incremental submission through the typed tools is the ONLY supported output mode. Start submitting with the FIRST tool call: after each read, call record_requirement for the requirements you have already confirmed, one or a few per call. Every tool-call round MUST make progress by submitting at least one record_* fact. Do not re-read the same source file that is already materialized in this session; read each file at most once.",
3350
3350
  "Read task source and produce a concise frontend implementation contract as typed requirement facts plus narrative Markdown.",
3351
- "Assign each requirement the SAME id as the ledger canonical requirement it covers (sourceBinding.requirementIds, e.g. AC-001) — do NOT invent new REQ/BR prefixed ids for canonical requirements: the compiled contract must match the ledger canonical requirement ids exactly or schema validation rejects it (unknown requirement id). Requirements use the canonical id with a source span (task-source section or repository file:line). Label each requirement's disposition as explicit | repository-resolvable | assumption | blocking; a blocking requirement must name its owner (human-decision or external-state) and evidence refs.",
3352
- "Source fidelity ledger: when the DAG sourceBinding carries a requirement→fragment mapping (requirementToFragments, e.g. REQ-SRC-* ids from the managed ledger), each record_requirement MUST declare the fragments that requirement is bound to: set sourceFragmentIds to the mapped fragment ids (the authoritative provenance evidence the design policy verifies). sourceRefs (fragment→path display refs) are optional — declare them only when you have the exact path from the materialized source; otherwise omit them rather than inventing paths. Declare exactly what the ledger binds — do not invent ids, do not omit them, and do not re-derive them from prose. A requirement that the ledger binds but the contract omits (or fabricates) fails writer admission.",
3351
+ "Confirm each requirement by the SAME id as the ledger canonical requirement it covers (sourceBinding.requirementIds, e.g. AC-001) — do NOT invent new REQ/BR prefixed ids for canonical requirements: the compiled contract must match the ledger canonical requirement ids exactly or schema validation rejects it (unknown requirement id). record_requirement takes ONLY the canonical id; the runtime commits the authoritative text and sourceFragmentIds from the frozen ledger. Never pass text/statement/sourceFragmentIds yourself — model rewrites and JSON-stringified fragment arrays are rejected.",
3352
+ "Requirement semantics, source spans, dispositions, and fragment bindings are ledger/runtime-owned. If a canonical requirement is genuinely blocked, say so in the Markdown contract narrative and finalize with the matching disposition instead of trying to encode it in the requirement fact.",
3353
3353
  "Register evidence expectations for each requirement across static, behavior, Mock, and real integration as required | optional | not-applicable; required must follow from user requirements, task risk, or project governance, never from model convenience. For UI-visible or interactive requirements, register a non-blocking frontend-test handoff intent.",
3354
+ 'Use record_evidence_expectation with {requirementId,evidence:{static,behavior,mock,"real-integration"}}; every lane is required | optional | not-applicable. Requirement text and provenance remain runtime-owned.',
3355
+ 'Before finalize_contract ready, call record_required_deliverables once with the complete {items:[{path,requirementId,sourceFragmentId}]} inventory, or {items:[]} when no file delivery is mandatory. Interpret the original source, including lists and tables: allowedPaths/only-allowed-to-modify is permission, not an obligation; do not promote prohibited files, examples or references into deliverables. Paths must occur exactly in a frozen source fragment bound to that canonical requirement. Correct the whole inventory before finalizing if needed.',
3356
+ "Authoritative UI states: when the task source declares a UI-state table (state id / trigger / observable outcome), extract it VERBATIM through record_ui_state, one call per state, using the source's own state ids. The planner must bind these ids later — do not rename, merge, or invent states.",
3354
3357
  "Cover scope, non-goals, acceptance criteria, UI states, target runtime environment, risks, and verification expectations. Do not fix target files, components, styling, or implementation methods as requirements; leave those to Scout and Plan.",
3355
3358
  "If the task is too large for one bounded writer, record a task split proposal instead of silently widening scope.",
3356
3359
  "End the contract with a single disposition: ready, ready-with-assumptions (bounded assumptions that do not change product behavior), or blocked.",
@@ -3408,6 +3411,7 @@ async function buildFrontendHybridDagFromTask(sources) {
3408
3411
  "Record only: requirement-to-file/verification coverage; component/styling choices; applicable UI state and interaction behavior; data/Mock strategy; and a dependency policy or genuine evidence gap. Reuse Scout paths. If scope is missing, record a blocking gap instead of inventing a path.",
3409
3412
  "Use the typed tool schemas as the field contract. Runtime owns schemaVersion, sourceBinding, riskLevel, targets.files, mockApi.productionDefaultOff, aliases, command allowlisting, path containment, and final validation; do not restate those rules or emit a full JSON contract.",
3410
3413
  `Cover each frozen requirement ID exactly once: ${requirementIds.join(", ") || "(none)"}. Bind every verification target to a frozen commandId from the directory above plus a Scout-confirmed file. Behavior commands prove observable behavior: one target may cover multiple related requirementIds when one test behavior proves them together; do not mechanically create one target per requirement. A behavior target id is the stable machine trace token and its file must be a test file. Static commands are project-wide checks traced by file and command only.`,
3414
+ "UX vocabulary protocol: record_state_registry FIRST with the full global vocabulary — one stable kebab-case behavior-domain name per UI state/interaction (e.g. planner-task-edit, focus-queue-move), never one name per AC number and never a rename of an already-recorded concept. Coverage slices by requirement; UX does not. Then record_state_flow entries whose names all come from that registry; uiState names must use the contract's declared authoritative ids (declaredUiStates in the plan input) when present. Retry attempts see committedUx in this input — reuse those exact names. Components: one choice may cover many state/interaction ids via covers; reuse-existing requires evidencePath naming an existing repo file (greenfield must be decision=new).",
3411
3415
  ...(requiresOpenspecClassification ? ["When a component choice uses an OpenSpec selection, cite that selection; otherwise do not classify unrelated candidates."] : []),
3412
3416
  "Call finalize_plan exactly once after the necessary typed facts. Return no Markdown narrative.",
3413
3417
  "TOOL-ONLY PLAN: Do not read Contract/Scout stdout, task sources, or Scout-confirmed target files. Contract and Scout already own evidence discovery; use the injected upstream facts, record a genuine evidence gap when those facts are insufficient, and start committing record_* facts immediately. For decision=new, pass sourceRequirementIds to record_component_choice; runtime derives the exact PRD citation from the frozen ledger.",
@@ -21,6 +21,7 @@ import "./contract-validator-registrations.js";
21
21
  import { computeNormalizedFailureFingerprint } from "./frontend-recovery-lineage.js";
22
22
  import { parseLedgerJson } from "../../task/source-prepare/ledger.js";
23
23
  import { readTypedEventStoreFromJsonl } from "./frontend-typed-event-store.js";
24
+ import { collectCanonicalStateFlowNames, extractRequiredDeliverablePaths, resolveFrontendContractRequirements, } from "./frontend-contract-facts.js";
24
25
  import { allowedRepairReadPaths, auditRepairAttemptToolUse, buildStructuredOutputRepairPrompt, freezeStructuredOutputRepairContext, hasNonEmptyStructuredCandidate, isFrontendStructuredRepairSchemaId, isStructuredRepairableFailureCategory, persistStructuredAttemptRaw, sessionEventsByteLength, GOVERNANCE_BLOCKED_CATEGORY, STRUCTURED_REPAIR_EXHAUSTED_CATEGORY, } from "./structured-output-repair.js";
25
26
  import { readFrontendCanonicalCandidate } from "./frontend-implementation-contract.js";
26
27
  import { writeDagNodeJsonArtifact } from "../../infrastructure/harness/artifact-store.js";
@@ -325,6 +326,8 @@ const FRONTEND_CONTRACT_RECORD_TOOL_NAMES_LOCAL = new Set([
325
326
  "record_handoff_intent",
326
327
  "record_open_question",
327
328
  "record_split_proposal",
329
+ "record_ui_state",
330
+ "record_required_deliverables",
328
331
  ]);
329
332
  async function countContractRecordSubmissions(runDir, nodeId) {
330
333
  const eventsPath = path.join(runDir, nodeId, "session-events.jsonl");
@@ -553,8 +556,9 @@ export function renderFrontendPlanInputContext(input) {
553
556
  : []);
554
557
  const contractFacts = committedFacts(input.contractRecords);
555
558
  const scoutFacts = committedFacts(input.scoutRecords);
556
- const requirements = contractFacts
557
- .filter((fact) => fact.kind === "requirement" && fact.origin === "contract")
559
+ const requirementFacts = resolveFrontendContractRequirements(contractFacts);
560
+ const requiredDeliverables = extractRequiredDeliverablePaths(contractFacts);
561
+ const requirements = requirementFacts
558
562
  .map((fact) => ({
559
563
  id: planInputText(fact.id, 80),
560
564
  text: planInputText(fact.text),
@@ -580,19 +584,28 @@ export function renderFrontendPlanInputContext(input) {
580
584
  paths: fact.paths,
581
585
  conflicts: fact.conflicts,
582
586
  }));
587
+ // Authoritative UI states (contract-declared): the source's UI-state table
588
+ // extracted by the contract node. The planner binds these ids instead of
589
+ // inventing list-visibility variants.
590
+ const declaredUiStates = contractFacts
591
+ .filter((fact) => fact.kind === "ui-state-declaration" && fact.origin === "contract")
592
+ .map((fact) => ({
593
+ id: planInputText(fact.id, 80),
594
+ trigger: planInputText(fact.trigger),
595
+ observableOutcome: planInputText(fact.observableOutcome),
596
+ }))
597
+ .filter((state) => state.id !== undefined);
598
+ // Replay registry edits and state-flow removals/additions in commit order.
599
+ const committedUxNames = collectCanonicalStateFlowNames(input.planRecords ?? [], true);
600
+ const committedUiStateNames = [...committedUxNames.uiStateNames];
601
+ const committedInteractionNames = [...committedUxNames.interactionNames];
583
602
  // Reviewer-rubric scaffold: the design reviewer re-runs the design-policy
584
603
  // checks on the committed facts, so publish the checklist to the producer.
585
604
  // Requirements whose contract evidence expects behavioural verification are
586
605
  // enumerated explicitly — those are the slots the reviewer finds missing
587
606
  // when the plan models interactions ad hoc (r8/r9 findings).
588
- const behaviorRequiredIds = requirements
589
- .filter((requirement) => {
590
- const fact = contractFacts.find((candidate) => candidate.kind === "requirement" &&
591
- candidate.origin === "contract" &&
592
- candidate.id === requirement.id);
593
- const evidence = fact?.evidence;
594
- return evidence?.behavior === "required";
595
- })
607
+ const behaviorRequiredIds = requirementFacts
608
+ .filter((requirement) => requirement.evidence.behavior === "required")
596
609
  .map((requirement) => requirement.id);
597
610
  const serializeAtCap = (cap) => JSON.stringify({
598
611
  requirements: requirements.map((requirement) => ({
@@ -600,6 +613,7 @@ export function renderFrontendPlanInputContext(input) {
600
613
  text: planInputText(requirement.text, cap.text),
601
614
  sourceFragmentIds: planInputStrings(requirement.sourceFragmentIds).slice(0, cap.array),
602
615
  })),
616
+ requiredDeliverables,
603
617
  targetSurface: targetSurface.map((surface) => ({
604
618
  completeness: planInputText(surface.completeness, 32),
605
619
  entrypoint: planInputText(surface.entrypoint, cap.text),
@@ -615,6 +629,18 @@ export function renderFrontendPlanInputContext(input) {
615
629
  paths: planInputStrings(evidence.paths).slice(0, cap.array),
616
630
  conflicts: planInputStrings(evidence.conflicts).slice(0, cap.array),
617
631
  })),
632
+ declaredUiStates: declaredUiStates.map((state) => ({
633
+ id: state.id,
634
+ trigger: planInputText(state.trigger, cap.text),
635
+ observableOutcome: planInputText(state.observableOutcome, cap.text),
636
+ })),
637
+ committedUx: committedUiStateNames.length > 0 ||
638
+ committedInteractionNames.length > 0
639
+ ? {
640
+ uiStateNames: committedUiStateNames,
641
+ interactionNames: committedInteractionNames,
642
+ }
643
+ : undefined,
618
644
  });
619
645
  let serialized = serializeAtCap(FRONTEND_PLAN_INPUT_CAP_LADDER[0]);
620
646
  for (const cap of FRONTEND_PLAN_INPUT_CAP_LADDER.slice(1)) {
@@ -628,6 +654,7 @@ export function renderFrontendPlanInputContext(input) {
628
654
  // to the minimum, and declare the degradation instead of corrupting JSON.
629
655
  let fallback = {
630
656
  degraded: "requirement-texts-truncated",
657
+ requiredDeliverables,
631
658
  requirements: requirements.map((requirement) => ({
632
659
  id: requirement.id,
633
660
  text: "(truncated)",
@@ -652,20 +679,20 @@ export function renderFrontendPlanInputContext(input) {
652
679
  serialized = bounded;
653
680
  }
654
681
  const checklistLines = [
655
- "1. Every interaction you record needs a uiComponentChoices entry whose purpose equals the interaction name, or one decision=reuse-existing choice covering behavioural interactions.",
656
- "2. Every applicable UI state needs a purpose-matching component choice or a stylingStrategy.",
657
- "3. Every requirement marked (behavior) below needs modelled interactions plus at least one verification target that references it.",
658
- "4. targets.files must name the concrete deliverable files; never leave the scope broader than the frozen requirements state.",
682
+ "1. Record the GLOBAL UX vocabulary with record_state_registry BEFORE any record_state_flow: one stable behavior-domain name per state/interaction (e.g. planner-task-edit), never one name per AC number, and never a rename of an already-recorded concept. Coverage slices by AC; UX does not.",
683
+ "2. Every recorded interaction/uiState name must be in that registry, and uiState names must use the contract's declared authoritative ids (declaredUiStates below) when present.",
684
+ "3. Every interaction and every applicable UI state must be covered by a uiComponentChoices entry: its purpose equals the name, or the choice lists the name in covers (one choice may cover many ids). A reuse-existing decision without evidencePath is rejected; stylingStrategy alone covers nothing.",
685
+ "4. Every requirement marked (behavior) below needs modelled interactions plus at least one verification target that references it.",
659
686
  "5. Verification targets may only reference UI states and requirements you actually recorded (the record_* tools reject unknown references).",
660
687
  `Requirements requiring behavioural coverage: ${behaviorRequiredIds.length > 0 ? behaviorRequiredIds.join(", ") : "(none)"}`,
661
- "6. A decision=new component must declare sourceRequirementIds and pass sourceFragmentId for the frozen PRD fragment whose section matches the component's purpose — the runtime validates that binding and derives specReference (path/section/line); the reviewer checks purpose↔citation consistency.",
688
+ "6. A decision=new component must declare sourceRequirementIds and pass sourceFragmentId for the frozen PRD fragment whose section matches the component's purpose — the runtime validates that binding and derives specReference (path/section/line); the reviewer checks purpose↔citation consistency. A decision=reuse-existing component must pass evidencePath pointing at the existing repo file that proves the reuse.",
662
689
  ...[...input.componentSourceCitations ?? []]
663
690
  .filter(([id]) => behaviorRequiredIds.includes(id))
664
691
  .flatMap(([id, citations]) => citations.map((citation) => ` ${id} + ${citation.fragmentId} → ${citation.section}${citation.line ? ` (line ${citation.line})` : ""}`)),
665
692
  ];
666
693
  return [
667
694
  "<frontend_plan_input>",
668
- "Committed Contract/Scout facts, compiled by the runner. Treat them as the complete planning evidence.",
695
+ "Committed Contract/Scout facts, compiled by the runner. Treat them as the complete planning evidence. declaredUiStates are the authoritative UI states from the task source; committedUx (retry attempts) is the UX vocabulary already recorded — reuse those names, never re-invent them.",
669
696
  serialized,
670
697
  "Do not read upstream artifacts, task sources, or repository files. If this input cannot support a decision, record a genuine evidence gap.",
671
698
  "</frontend_plan_input>",
@@ -692,6 +719,16 @@ export async function buildFrontendPlanInputContext(runDir, componentSourceCitat
692
719
  // forbids reading anything.
693
720
  throw new Error(`frontend-plan-input-unavailable: cannot read committed typed facts (${error instanceof Error ? error.message : String(error)})`);
694
721
  }
722
+ // Retry-attempt continuity (UX slice visibility): the plan node's own
723
+ // committed facts are absent on the first attempt and present on retries;
724
+ // a missing file is normal there, not a broken pipeline.
725
+ let planRecords = [];
726
+ try {
727
+ planRecords = await readTypedEventStoreFromJsonl(path.join(runDir, "frontend-plan-pi", "plan-typed-facts.jsonl"));
728
+ }
729
+ catch {
730
+ planRecords = [];
731
+ }
695
732
  const committedCount = [...contractRecords, ...scoutRecords].filter((record) => record.phase === "committed").length;
696
733
  if (committedCount === 0) {
697
734
  throw new Error(`frontend-plan-input-unavailable: no committed Contract/Scout facts in ${contractFactsPath} / ${scoutFactsPath}`);
@@ -699,6 +736,7 @@ export async function buildFrontendPlanInputContext(runDir, componentSourceCitat
699
736
  return renderFrontendPlanInputContext({
700
737
  contractRecords,
701
738
  scoutRecords,
739
+ planRecords,
702
740
  componentSourceCitations,
703
741
  });
704
742
  }
@@ -11,5 +11,6 @@
11
11
  - [`production-readiness.md`](production-readiness.md):交付前的生产就绪判断。
12
12
  - [`agent-worker-production-readiness.md`](agent-worker-production-readiness.md):agent-worker Feature/Task Pool 外层编排的 Production Readiness v1 操作合同。
13
13
  - [`backend-test-jacoco-coverage.md`](backend-test-jacoco-coverage.md):Java 被测服务挂载 JaCoCo tcpserver agent 的 Maven、`java -jar` 与 Docker 操作手册。
14
+ - [`console-chat-dogfood-playbook.md`](console-chat-dogfood-playbook.md):Operator Chat(含 Explore 子 Agent)真实模型 dogfood 的 CLI 驱动步骤、mutation 双 token / SSE 超时 / question 应答等已知陷阱与验证方式。
14
15
 
15
16
  验证命令仍以 [`../governance/verification-matrix.md`](../governance/verification-matrix.md) 为准。
@@ -58,6 +58,12 @@
58
58
  "type": "string",
59
59
  "minLength": 1
60
60
  }
61
+ },
62
+ "requiredDeliverables": {
63
+ "type": "array",
64
+ "items": {
65
+ "$ref": "#/$defs/path"
66
+ }
61
67
  }
62
68
  }
63
69
  },
@@ -433,8 +439,7 @@
433
439
  "required": [
434
440
  "purpose",
435
441
  "component",
436
- "decision",
437
- "rationale"
442
+ "decision"
438
443
  ],
439
444
  "properties": {
440
445
  "purpose": {
@@ -465,6 +470,16 @@
465
470
  "rationale": {
466
471
  "type": "string",
467
472
  "minLength": 1
473
+ },
474
+ "covers": {
475
+ "type": "array",
476
+ "items": {
477
+ "type": "string",
478
+ "minLength": 1
479
+ }
480
+ },
481
+ "evidencePath": {
482
+ "$ref": "#/$defs/path"
468
483
  }
469
484
  },
470
485
  "allOf": [
@@ -511,6 +526,23 @@
511
526
  }
512
527
  }
513
528
  }
529
+ },
530
+ {
531
+ "if": {
532
+ "properties": {
533
+ "decision": {
534
+ "const": "reuse-existing"
535
+ }
536
+ },
537
+ "required": [
538
+ "decision"
539
+ ]
540
+ },
541
+ "then": {
542
+ "required": [
543
+ "evidencePath"
544
+ ]
545
+ }
514
546
  }
515
547
  ]
516
548
  }