cclaw-cli 6.10.0 → 6.11.0

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.
@@ -5,7 +5,6 @@ import { exists } from "./fs-utils.js";
5
5
  import { stageSchema } from "./content/stage-schema.js";
6
6
  import { readFlowState } from "./run-persistence.js";
7
7
  import { duplicateH2Headings, extractEvidencePointers, extractH2Sections, extractRequirementIdsFromMarkdown, isShortCircuitActivated, normalizeHeadingTitle, parseFrontmatter, parseLearningsSection, sectionBodyByAnyName, sectionBodyByHeadingPrefix, sectionBodyByName, validateSectionBody, formatLearningsErrorsBullets } from "./artifact-linter/shared.js";
8
- import { foldTddSliceLedger, readTddSliceLedger } from "./tdd-slices.js";
9
8
  import { shouldDemoteArtifactValidationByTrack } from "./content/stage-schema.js";
10
9
  import { readDelegationLedger, recordArtifactValidationDemotedByTrack } from "./delegation.js";
11
10
  import { classifyAndPersistFindings } from "./artifact-linter/findings-dedup.js";
@@ -147,11 +146,12 @@ export async function lintArtifact(projectRoot, stage, track = "standard", optio
147
146
  }
148
147
  }
149
148
  const liteTierForValidators = shouldDemoteArtifactValidationByTrack(track, taskClass);
150
- // v6.10.0 (T3) — pre-resolve RED/GREEN Evidence pointers and sidecar
151
- // auto-satisfy state once for the whole TDD loop, then thread the
152
- // booleans through `validateSectionBody`. We do the async resolution
153
- // here (path existence + delegation spanId match) so the validators
154
- // themselves stay sync.
149
+ // v6.11.0 (D5) — pre-resolve RED/GREEN Evidence pointers AND
150
+ // delegation phase events so `validateSectionBody` (sync) can
151
+ // short-circuit. The Evidence: pointer mode (v6.10.0 T3) stays as a
152
+ // fallback alongside legacy markdown content; phase events with a
153
+ // `phase=red`/`phase=green` row plus non-empty evidenceRefs auto-pass
154
+ // the corresponding markdown validator.
155
155
  const tddEvidenceContext = stage === "tdd"
156
156
  ? await resolveTddEvidencePointerContext({
157
157
  projectRoot,
@@ -435,14 +435,21 @@ const ARTIFACT_VALIDATION_LITE_DEMOTE_SECTIONS = new Set([
435
435
  "Product Discovery Delegation (Strategist Mode)"
436
436
  ]);
437
437
  /**
438
- * v6.10.0 (T3) — pre-resolve `Evidence:` pointers and sidecar
439
- * auto-satisfy state for the TDD stage's RED/GREEN Evidence rows so
440
- * `validateSectionBody` (sync) can short-circuit. A pointer of the form
441
- * `<path>` is satisfied when the path exists on disk relative to the
442
- * project root; `spanId:<id>` is satisfied when any delegation ledger
443
- * row carries that span id. Sidecar auto-satisfy fires when
444
- * `06-tdd-slices.jsonl` carries at least one slice with a non-empty
445
- * `redOutputRef` / `greenOutputRef`.
438
+ * v6.11.0 (D5) — pre-resolve `Evidence:` pointers and delegation
439
+ * phase-event auto-satisfy state for the TDD stage's RED/GREEN
440
+ * Evidence rows so `validateSectionBody` (sync) can short-circuit.
441
+ *
442
+ * - `<path>` pointer is satisfied when the path exists on disk relative
443
+ * to the project root.
444
+ * - `spanId:<id>` pointer is satisfied when any delegation ledger row
445
+ * carries that span id.
446
+ * - Phase-event auto-satisfy fires when `delegation-events.jsonl`
447
+ * carries at least one slice-tagged event for the active run with
448
+ * `phase=red`/`phase=green` and non-empty `evidenceRefs`. This is the
449
+ * v6.11.0 replacement for the v6.10.0 sidecar auto-satisfy hook —
450
+ * slice events are now the source of truth, the RED/GREEN markdown
451
+ * tables are auto-rendered from them, and the validators MUST NOT
452
+ * demand pasted stdout when the events already prove RED/GREEN.
446
453
  */
447
454
  async function resolveTddEvidencePointerContext(input) {
448
455
  const { projectRoot, sections } = input;
@@ -451,16 +458,29 @@ async function resolveTddEvidencePointerContext(input) {
451
458
  const redPointers = extractEvidencePointers(redSection);
452
459
  const greenPointers = extractEvidencePointers(greenSection);
453
460
  let knownSpanIds = new Set();
454
- if (redPointers.length > 0 || greenPointers.length > 0) {
455
- try {
456
- const ledger = await readDelegationLedger(projectRoot);
457
- knownSpanIds = new Set(ledger.entries
458
- .map((entry) => entry.spanId)
459
- .filter((id) => typeof id === "string" && id.length > 0));
460
- }
461
- catch {
462
- knownSpanIds = new Set();
463
- }
461
+ let phaseEventsAutoSatisfy = { red: false, green: false };
462
+ try {
463
+ const ledger = await readDelegationLedger(projectRoot);
464
+ knownSpanIds = new Set(ledger.entries
465
+ .map((entry) => entry.spanId)
466
+ .filter((id) => typeof id === "string" && id.length > 0));
467
+ const runId = ledger.runId;
468
+ const slicePhaseRows = ledger.entries.filter((entry) => entry.runId === runId &&
469
+ entry.stage === "tdd" &&
470
+ typeof entry.sliceId === "string" &&
471
+ entry.sliceId.length > 0 &&
472
+ typeof entry.phase === "string");
473
+ const redOk = slicePhaseRows.some((entry) => entry.phase === "red" &&
474
+ Array.isArray(entry.evidenceRefs) &&
475
+ entry.evidenceRefs.some((ref) => typeof ref === "string" && ref.trim().length > 0));
476
+ const greenOk = slicePhaseRows.some((entry) => entry.phase === "green" &&
477
+ Array.isArray(entry.evidenceRefs) &&
478
+ entry.evidenceRefs.some((ref) => typeof ref === "string" && ref.trim().length > 0));
479
+ phaseEventsAutoSatisfy = { red: redOk, green: greenOk };
480
+ }
481
+ catch {
482
+ knownSpanIds = new Set();
483
+ phaseEventsAutoSatisfy = { red: false, green: false };
464
484
  }
465
485
  async function pointerResolves(value) {
466
486
  const trimmed = value.replace(/[`*_]/gu, "").trim();
@@ -480,28 +500,14 @@ async function resolveTddEvidencePointerContext(input) {
480
500
  }
481
501
  return false;
482
502
  }
483
- let redSidecarAutoSatisfy = false;
484
- let greenSidecarAutoSatisfy = false;
485
- try {
486
- const sidecar = await readTddSliceLedger(projectRoot);
487
- if (sidecar.entries.length > 0) {
488
- const folded = foldTddSliceLedger(sidecar.entries);
489
- redSidecarAutoSatisfy = folded.some((entry) => typeof entry.redOutputRef === "string" && entry.redOutputRef.length > 0);
490
- greenSidecarAutoSatisfy = folded.some((entry) => typeof entry.greenOutputRef === "string" && entry.greenOutputRef.length > 0);
491
- }
492
- }
493
- catch {
494
- redSidecarAutoSatisfy = false;
495
- greenSidecarAutoSatisfy = false;
496
- }
497
503
  return {
498
504
  red: {
499
505
  pointerSatisfied: await anyResolved(redPointers),
500
- sidecarAutoSatisfy: redSidecarAutoSatisfy
506
+ phaseEventsSatisfied: phaseEventsAutoSatisfy.red
501
507
  },
502
508
  green: {
503
509
  pointerSatisfied: await anyResolved(greenPointers),
504
- sidecarAutoSatisfy: greenSidecarAutoSatisfy
510
+ phaseEventsSatisfied: phaseEventsAutoSatisfy.green
505
511
  }
506
512
  };
507
513
  }
@@ -207,6 +207,20 @@ export declare const CCLAW_AGENTS: readonly [{
207
207
  readonly relatedStages: ["tdd"];
208
208
  readonly returnSchema: AgentReturnSchema;
209
209
  readonly body: string;
210
+ }, {
211
+ readonly name: "slice-documenter";
212
+ readonly description: "PARALLEL with slice-implementer in TDD GREEN. Writes per-slice prose summary to `<artifacts-dir>/tdd-slices/S-<id>.md`. Does NOT implement, does NOT write tests. Mandatory on discoveryMode=deep, opt-in elsewhere.";
213
+ readonly tools: ["Read", "Write", "Edit", "Grep", "Glob"];
214
+ readonly model: "fast";
215
+ readonly activation: "on-demand";
216
+ readonly relatedStages: ["tdd"];
217
+ readonly returnSchema: {
218
+ readonly statusField: "status";
219
+ readonly allowedStatuses: ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"];
220
+ readonly requiredFields: ["status", "summaryMd", "learnings", "evidenceRefs", "blockers"];
221
+ readonly evidenceFields: ["summaryMd", "evidenceRefs"];
222
+ };
223
+ readonly body: string;
210
224
  }, {
211
225
  readonly name: "fixer";
212
226
  readonly description: "ON-DEMAND fresh worker after review FAIL/PARTIAL evidence. Must fix only the cited criterion within explicit allowed files.";
@@ -544,6 +544,41 @@ export const CCLAW_AGENTS = [
544
544
  "**Role boundary:** do not broaden scope, do not review your own work as final approval, and do not spawn subagents."
545
545
  ].join("\n")
546
546
  },
547
+ {
548
+ name: "slice-documenter",
549
+ description: "PARALLEL with slice-implementer in TDD GREEN. Writes per-slice prose summary to `<artifacts-dir>/tdd-slices/S-<id>.md`. Does NOT implement, does NOT write tests. Mandatory on discoveryMode=deep, opt-in elsewhere.",
550
+ tools: ["Read", "Write", "Edit", "Grep", "Glob"],
551
+ model: "fast",
552
+ activation: "on-demand",
553
+ relatedStages: ["tdd"],
554
+ returnSchema: {
555
+ statusField: "status",
556
+ allowedStatuses: ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"],
557
+ requiredFields: ["status", "summaryMd", "learnings", "evidenceRefs", "blockers"],
558
+ evidenceFields: ["summaryMd", "evidenceRefs"]
559
+ },
560
+ body: [
561
+ "You are a **slice-documenter** dispatched in PARALLEL with `slice-implementer` for the same slice.",
562
+ "",
563
+ "**Mission:** capture per-slice prose summary while production code is being written.",
564
+ "Because your only `claimedPath` is `<artifacts-dir>/tdd-slices/S-<id>.md` and the implementer's `claimedPaths` are production code, the file-overlap scheduler auto-allows the parallel dispatch.",
565
+ "",
566
+ "When invoked:",
567
+ "1. Read the active plan unit, acceptance criterion, and the failing RED test for this slice.",
568
+ "2. Write a thin per-slice file at `<artifacts-dir>/tdd-slices/S-<id>.md` with the headings:",
569
+ " - `# Slice S-<id>`",
570
+ " - `## Plan unit` (T-... pointer)",
571
+ " - `## Acceptance criteria` (AC-... ids)",
572
+ " - `## Why this slice`",
573
+ " - `## What was tested`",
574
+ " - `## What was implemented`",
575
+ " - `## REFACTOR notes`",
576
+ " - `## Learnings`",
577
+ "3. Return JSON: `{ status, summaryMd, learnings: string[], evidenceRefs: [\"<artifacts-dir>/tdd-slices/S-<id>.md\"], blockers: [] }`.",
578
+ "",
579
+ "**Forbidden:** edit `06-tdd.md`, test files, or production code. Edit ONLY your slice file."
580
+ ].join("\n")
581
+ },
547
582
  {
548
583
  name: "fixer",
549
584
  description: "ON-DEMAND fresh worker after review FAIL/PARTIAL evidence. Must fix only the cited criterion within explicit allowed files.",
@@ -37,9 +37,9 @@ export const BEHAVIOR_ANCHORS = [
37
37
  {
38
38
  stage: "tdd",
39
39
  section: "Watched-RED Proof",
40
- bad: "Hand-edit `S-1 | 2026-04-15T10:00 | observed RED` into the markdown table; nothing lands in the JSONL sidecar, so retries silently overwrite the row.",
41
- good: "Run `cclaw-cli internal tdd-slice-record --slice S-1 --status red --test-file tests/feed.spec.ts --command \"npm test\" --paths src/api/feed.ts --ac AC-3`; the linter reads the sidecar.",
42
- ruleHint: "RED/GREEN/REFACTOR transitions are recorded by `cclaw-cli internal tdd-slice-record`; the markdown tables are an auto-derived view from v6.10.0 onward."
40
+ bad: "Hand-edit Watched-RED Proof rows directly in the TDD artifact; the next lint overwrites the auto-rendered region and the slice still lacks a provable RED in delegation events.",
41
+ good: "Dispatch `test-author --slice S-1 --phase red`, then `slice-implementer --slice S-1 --phase green`. The linter auto-renders the slice cycle from `delegation-events.jsonl`.",
42
+ ruleHint: "RED/GREEN/REFACTOR transitions are recorded as `delegation-events.jsonl` rows via slice-tagged dispatches; the markdown tables are auto-rendered between `auto-start: tdd-slice-summary` markers from v6.11.0 onward."
43
43
  },
44
44
  {
45
45
  stage: "review",
@@ -252,7 +252,7 @@ Plan is ready to execute after user confirmation.
252
252
  | Slice | Source ID | AC ID | Expected behavior | RED-link |
253
253
  | --- | --- | --- | --- | --- |
254
254
  | S-1 | SRC-1 | AC-1 | feed window honors 30d cap | spanId:tdd-feed-window-red |
255
- | S-2 | SRC-2 | AC-3 | degraded banner appears on disconnect | .cclaw/artifacts/06-tdd-slices.jsonl |
255
+ | S-2 | SRC-2 | AC-3 | degraded banner appears on disconnect | spanId:tdd-banner-red (auto-derived from delegation-events.jsonl) |
256
256
 
257
257
  ## GREEN
258
258
 
@@ -2,7 +2,7 @@ import { existsSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { RUNTIME_ROOT } from "../constants.js";
5
- import { DELEGATION_DISPATCH_SURFACES, DELEGATION_DISPATCH_SURFACE_PATH_PREFIXES } from "../delegation.js";
5
+ import { DELEGATION_DISPATCH_SURFACES, DELEGATION_DISPATCH_SURFACE_PATH_PREFIXES, DELEGATION_PHASES } from "../delegation.js";
6
6
  function resolveCliRuntimeForGeneratedHook() {
7
7
  const here = fileURLToPath(import.meta.url);
8
8
  // Vitest runs init/sync from src/ and expects helpers to execute the same
@@ -210,6 +210,8 @@ const TERMINAL = new Set(["completed", "failed", "waived", "stale"]);
210
210
  const VALID_DISPATCH_SURFACES = ${JSON.stringify([...DELEGATION_DISPATCH_SURFACES])};
211
211
  const VALID_DISPATCH_SURFACES_SET = new Set(VALID_DISPATCH_SURFACES);
212
212
  const SURFACE_PATH_PREFIXES = ${JSON.stringify(DELEGATION_DISPATCH_SURFACE_PATH_PREFIXES)};
213
+ const VALID_DELEGATION_PHASES = ${JSON.stringify([...DELEGATION_PHASES])};
214
+ const VALID_DELEGATION_PHASES_SET = new Set(VALID_DELEGATION_PHASES);
213
215
  const LEDGER_SCHEMA_VERSION = 3;
214
216
  const FLOW_STATE_GUARD_REL_PATH = RUNTIME_ROOT + "/.flow-state.guard.json";
215
217
 
@@ -343,6 +345,11 @@ function usage() {
343
345
  "TDD parallel scheduler (v6.10.0):",
344
346
  " --paths=<a,b,c> repo-relative paths the slice-implementer will edit; disjoint sets auto-promote to allowParallel, overlap throws DispatchOverlapError",
345
347
  " --override-cap=<int> raise the slice-implementer fan-out cap once for this dispatch (default cap " + String(5) + ", env CCLAW_MAX_PARALLEL_SLICE_IMPLEMENTERS overrides globally)",
348
+ "",
349
+ "TDD slice phase tagging (v6.11.0):",
350
+ " --slice=<id> TDD slice identifier (e.g. S-1) used by the linter to auto-derive the Watched-RED + Vertical Slice Cycle tables.",
351
+ " --phase=<phase> one of " + VALID_DELEGATION_PHASES.join(", ") + ". Pair with --slice to record a TDD slice phase event.",
352
+ " --refactor-rationale=<t> required when --phase=refactor-deferred unless --evidence-ref carries the rationale text.",
346
353
  ""
347
354
  ].join("\\n") + "\\n");
348
355
  }
@@ -451,6 +458,32 @@ function buildRow(args, status, runId, now, options) {
451
458
  .split(",")
452
459
  .map((value) => value.trim())
453
460
  .filter((value) => value.length > 0);
461
+ // v6.11.0 (D1+D2): TDD slice tagging via --slice / --phase. Phase
462
+ // must be one of the canonical enum values; the inline validator
463
+ // rejects unknown phases before the row hits the ledger.
464
+ const sliceId =
465
+ typeof args.slice === "string" && args.slice.trim().length > 0
466
+ ? args.slice.trim()
467
+ : undefined;
468
+ const phase =
469
+ typeof args.phase === "string" && args.phase.trim().length > 0
470
+ ? args.phase.trim()
471
+ : undefined;
472
+ // v6.11.0 (D2): when --refactor-rationale is supplied it is folded
473
+ // into evidenceRefs[0] so the linter (which reads evidenceRefs only)
474
+ // can surface the rationale without touching new fields. The user
475
+ // may also pass --evidence-ref containing the rationale text.
476
+ let resolvedEvidenceRefs = normalizeEvidenceRefs(args);
477
+ if (
478
+ phase === "refactor-deferred" &&
479
+ typeof args["refactor-rationale"] === "string" &&
480
+ args["refactor-rationale"].trim().length > 0
481
+ ) {
482
+ const rationale = args["refactor-rationale"].trim();
483
+ if (!resolvedEvidenceRefs.includes(rationale)) {
484
+ resolvedEvidenceRefs = [rationale, ...resolvedEvidenceRefs];
485
+ }
486
+ }
454
487
  return {
455
488
  stage: args.stage,
456
489
  agent: args.agent,
@@ -463,7 +496,7 @@ function buildRow(args, status, runId, now, options) {
463
496
  agentDefinitionPath: args["agent-definition-path"],
464
497
  fulfillmentMode,
465
498
  waiverReason: args["waiver-reason"],
466
- evidenceRefs: normalizeEvidenceRefs(args),
499
+ evidenceRefs: resolvedEvidenceRefs,
467
500
  runId,
468
501
  startTs,
469
502
  ts: now,
@@ -473,7 +506,9 @@ function buildRow(args, status, runId, now, options) {
473
506
  endTs: TERMINAL.has(status) ? now : undefined,
474
507
  schemaVersion: LEDGER_SCHEMA_VERSION,
475
508
  allowParallel: args["allow-parallel"] === true ? true : undefined,
476
- claimedPaths: claimedPaths.length > 0 ? claimedPaths : undefined
509
+ claimedPaths: claimedPaths.length > 0 ? claimedPaths : undefined,
510
+ sliceId,
511
+ phase
477
512
  };
478
513
  }
479
514
 
@@ -1014,6 +1049,36 @@ async function main() {
1014
1049
  return;
1015
1050
  }
1016
1051
 
1052
+ // v6.11.0 (D2) — TDD slice phase tagging validation. --phase is
1053
+ // strictly enum-bound; --slice must be a non-empty string when
1054
+ // provided; --phase=refactor-deferred requires either an explicit
1055
+ // --refactor-rationale or an --evidence-ref with rationale text so
1056
+ // the linter has something to render.
1057
+ if (args.phase !== undefined && !VALID_DELEGATION_PHASES_SET.has(args.phase)) {
1058
+ problems.push("invalid --phase (allowed: " + VALID_DELEGATION_PHASES.join(", ") + ")");
1059
+ emitProblems(problems, json, 2);
1060
+ return;
1061
+ }
1062
+ if (args.slice !== undefined && (typeof args.slice !== "string" || args.slice.trim().length === 0)) {
1063
+ problems.push("--slice requires a non-empty value");
1064
+ emitProblems(problems, json, 2);
1065
+ return;
1066
+ }
1067
+ if (args.phase === "refactor-deferred") {
1068
+ const rationaleProvided =
1069
+ typeof args["refactor-rationale"] === "string" && args["refactor-rationale"].trim().length > 0;
1070
+ const evidenceProvided =
1071
+ (typeof args["evidence-ref"] === "string" && args["evidence-ref"].trim().length > 0) ||
1072
+ (Array.isArray(args["evidence-refs"]) && args["evidence-refs"].some(
1073
+ (ref) => typeof ref === "string" && ref.trim().length > 0
1074
+ ));
1075
+ if (!rationaleProvided && !evidenceProvided) {
1076
+ problems.push("--phase=refactor-deferred requires --refactor-rationale=<text> or --evidence-ref=<text>");
1077
+ emitProblems(problems, json, 2);
1078
+ return;
1079
+ }
1080
+ }
1081
+
1017
1082
  if (args.status === "completed" && args["dispatch-surface"] !== "role-switch") {
1018
1083
  for (const key of ["dispatch-id", "dispatch-surface", "agent-definition-path"]) {
1019
1084
  if (!args[key]) problems.push("completed isolated/generic status requires --" + key);
@@ -102,7 +102,7 @@ Any "the failure is real" claim (failing test, broken build, regression catch, d
102
102
 
103
103
  \`proof: <iso-ts> | <observed snippet — first 200 chars> | source: <command or log path>\`
104
104
 
105
- For TDD specifically, this is the watched-RED proof and is required per new test before \`stage-complete\` accepts the stage. From v6.10.0 onward, record TDD slice transitions through the sidecar CLI \`cclaw-cli internal tdd-slice-record --slice <id> --status red|green|refactor-done|refactor-deferred ...\` rather than hand-editing the \`Watched-RED Proof\` or \`Vertical Slice Cycle\` markdown tables; the linter reads \`.cclaw/artifacts/06-tdd-slices.jsonl\` when present and treats the markdown as an auto-derived view.
105
+ For TDD specifically, this is the watched-RED proof and is required per new test before \`stage-complete\` accepts the stage. From v6.11.0 onward, the controller dispatches \`test-author --slice S-<id> --phase red\` (and later \`slice-implementer --phase green\`, \`--phase refactor\` or \`--phase refactor-deferred --refactor-rationale "<why>"\`) and the linter auto-derives the \`Watched-RED Proof\` and \`Vertical Slice Cycle\` tables in \`06-tdd.md\` from \`.cclaw/state/delegation-events.jsonl\`. Do NOT hand-edit those tables. v6.10.0 sidecar (\`06-tdd-slices.jsonl\`) is removed; \`cclaw-cli sync\` cleans the file from existing installs.
106
106
  `;
107
107
  }
108
108
  /**
@@ -357,15 +357,12 @@ const REQUIRED_ARTIFACT_SECTIONS = {
357
357
  ],
358
358
  plan: ["Task List", "Dependency Batches", "Acceptance Mapping", "Execution Posture", "WAIT_FOR_CONFIRM"],
359
359
  tdd: [
360
- "Test Discovery",
361
360
  "System-Wide Impact Check",
362
361
  "RED Evidence",
363
362
  "GREEN Evidence",
364
363
  "REFACTOR Notes",
365
364
  "Traceability",
366
365
  "Iron Law Acknowledgement",
367
- "Watched-RED Proof",
368
- "Vertical Slice Cycle",
369
366
  "Verification Ladder"
370
367
  ],
371
368
  review: ["Review Evidence Scope", "Changed-File Coverage", "Layer 1 Verdict", "Review Findings Contract", "Severity Summary", "Final Verdict"],
@@ -42,14 +42,14 @@ export const TDD = {
42
42
  "Discover the test surface — inspect existing tests, fixtures, helpers, test commands, and nearby assertions before authoring RED. Reuse the local test style unless the slice genuinely needs a new pattern.",
43
43
  "Run a system-wide impact check — name callbacks, state transitions, interfaces, schemas, CLI/config/API contracts, persistence, or event boundaries that this slice can affect. Add RED coverage for each affected public contract or record why it is out of scope.",
44
44
  "Source/test preflight — before production edits, classify planned paths using test-path patterns; verify the RED touches a test path and the GREEN touches only source paths needed for the failing behavior.",
45
- "Use the mandatory `test-author` delegation for RED — after discovery and impact check, produce failing behavior tests and RED evidence only (no production edits). Set `CCLAW_ACTIVE_AGENT=tdd-red` when the harness supports phase labels.",
46
- "RED: Capture failure output copy the exact failure output as RED evidence. Record the slice in `.cclaw/artifacts/06-tdd-slices.jsonl` via `cclaw-cli internal tdd-slice-record --slice <id> --status red --test-file <path> --command <cmd> --paths <comma-separated>` (the markdown `Watched-RED Proof` table is now auto-derived from this sidecar).",
47
- "Continue the same `test-author` delegation intent for GREEN minimal implementation plus full-suite GREEN evidence. Set `CCLAW_ACTIVE_AGENT=tdd-green` when the harness supports phase labels.",
45
+ "Use the mandatory `test-author` delegation for RED — after discovery and impact check, dispatch with `--slice S-<id> --phase red`. Produce failing behavior tests only (no production edits) and let the harness record the dispatch via the generated `delegation-record` hook. Set `CCLAW_ACTIVE_AGENT=tdd-red` when the harness supports phase labels.",
46
+ "RED: do NOT hand-edit `## Watched-RED Proof`, `## Vertical Slice Cycle`, or `## RED Evidence` markdown tables. The linter auto-renders them from `delegation-events.jsonl` slice phase rows; manual edits inside the auto-render markers are overwritten on the next lint.",
47
+ "Dispatch the `slice-implementer` for GREEN with `--slice S-<id> --phase green` and explicit `--paths` so the file-overlap scheduler can auto-allow parallel slices. Attach an evidence ref (test path, span ref, or pasted-output pointer) so the Vertical Slice Cycle row is well-formed. Set `CCLAW_ACTIVE_AGENT=tdd-green` when the harness supports phase labels.",
48
48
  "GREEN: Run full suite — execute ALL tests, not just the ones you wrote. The full suite must be GREEN.",
49
49
  "GREEN: Verify no regressions — if any existing test breaks, fix the regression before proceeding.",
50
50
  "Run verification-before-completion discipline for the slice — capture a fresh test command, explicit PASS/FAIL status, and a config-aware ref (commit SHA when VCS is present/required, or no-vcs attestation when allowed).",
51
- "GREEN: append a `green` row to `.cclaw/artifacts/06-tdd-slices.jsonl` via `cclaw-cli internal tdd-slice-record --slice <id> --status green [--green-output-ref <path|spanId:...>]` so the Vertical Slice Cycle linter validates the sidecar instead of a hand-edited table.",
52
- "REFACTOR: continue the `test-author` evidence cycle (or a dedicated refactor mode when available) to improve code quality without behavior changes, then record `--status refactor-done` (or `--status refactor-deferred --refactor-rationale \"<why>\"`) via the same `tdd-slice-record` CLI. Set `CCLAW_ACTIVE_AGENT=tdd-refactor` when the harness supports phase labels.",
51
+ "REFACTOR: re-dispatch the `slice-implementer` (or `test-author`) with `--phase refactor` once GREEN holds, OR `--phase refactor-deferred --refactor-rationale \"<why>\"` to close the slice without a refactor pass. Both options are recorded as a delegation event; the linter accepts either as REFACTOR coverage. Set `CCLAW_ACTIVE_AGENT=tdd-refactor` when the harness supports phase labels.",
52
+ "DOC (parallel): when `discoveryMode === \"deep\"` is active, dispatch `slice-documenter --slice S-<id> --phase doc` IN PARALLEL with `slice-implementer` for the same slice. The documenter only writes `<artifacts-dir>/tdd-slices/S-<id>.md`, so its `--paths` are disjoint from the implementer's production code and the file-overlap scheduler auto-allows the parallel dispatch.",
53
53
  "Record evidence — capture test discovery, system-wide impact check, RED failure, GREEN output, and REFACTOR notes in the TDD artifact. When logging a `green` row, attach the closed acceptance-criterion IDs in `acIds` so Ralph Loop status counts them.",
54
54
  "Annotate traceability — link to the active track's source: plan task ID + spec criterion on standard/medium, or spec acceptance item / bug reproduction slice on quick.",
55
55
  "**Boundary with review (do NOT escalate single-slice findings to whole-diff review).** `tdd.Per-Slice Review` OWNS severity-classified findings WITHIN one slice (correctness, edge cases, regression). `review` OWNS whole-diff Layer 1 (spec compliance) plus Layer 2 (cross-slice integration, security sweep, dependency/version audit, observability). When a single-slice finding genuinely needs whole-diff escalation, surface it in `06-tdd.md > Per-Slice Review` first; review will cite it (not re-classify) and the cross-artifact-duplication linter requires matching severity/disposition.",
@@ -58,10 +58,11 @@ export const TDD = {
58
58
  ],
59
59
  interactionProtocol: [
60
60
  "Pick one vertical slice at a time: source item, RED test, GREEN implementation, REFACTOR, and verification evidence move together.",
61
- "Slice implementers are sequential by default. Parallel implementers are allowed only when (a) lanes touch non-overlapping files, (b) the controller passes `--allow-parallel` on each ledger row, and (c) an `integration-overseer` is dispatched after the parallel lanes and writes cohesion-evidence into the artifact before the gate is marked passed.",
62
- "Controller owns orchestration; one mandatory `test-author` delegation carries phase-specific RED -> GREEN -> REFACTOR evidence instead of spawning separate workers by default.",
61
+ "Slice implementers are sequential by default. Parallel implementers are allowed only when (a) lanes touch non-overlapping files (the file-overlap scheduler auto-allows parallel when `--paths` are disjoint), and (b) an `integration-overseer` is dispatched after the parallel lanes and writes cohesion-evidence into the artifact before the gate is marked passed.",
62
+ "Controller owns orchestration. For each slice S-<id>, dispatch in this order: (1) `test-author --slice S-<id> --phase red` (RED-only, no production edits), (2) `slice-implementer --slice S-<id> --phase green --paths <comma-separated>` for GREEN, (3) re-dispatch `--phase refactor` or `--phase refactor-deferred --refactor-rationale \"<why>\"` to close REFACTOR. Each dispatch records a row in `delegation-events.jsonl` and the linter auto-derives the Watched-RED + Vertical Slice Cycle tables from those rows. Do NOT hand-edit those tables.",
63
63
  "Before writing RED tests, discover relevant existing tests and commands so the new test extends the suite instead of fighting it.",
64
64
  "Before implementation, perform a system-wide impact check across callbacks, state, interfaces, schemas, and external contracts touched by the slice.",
65
+ "Slice-documenter (Phase C, opt-in / mandatory on discoveryMode=deep): in parallel with `slice-implementer --phase green`, dispatch `slice-documenter --slice S-<id> --phase doc` whose only `claimedPaths` is `<artifacts-dir>/tdd-slices/S-<id>.md`. The two dispatches run concurrently because their paths are disjoint. The documenter writes per-slice prose so the main `06-tdd.md` stays thin.",
65
66
  "Run source/test preflight using configured TDD path patterns where feasible; if path classification is impossible (generated files, non-file side effect), record why.",
66
67
  "Write behavior-focused tests before changing implementation (RED).",
67
68
  "Capture and store failing output as RED evidence.",
@@ -104,20 +105,20 @@ export const TDD = {
104
105
  { id: "tdd_docs_drift_check", description: "When public API/config/CLI surfaces change, docs drift is addressed via a completed doc-updater pass." }
105
106
  ],
106
107
  requiredEvidence: [
107
- "Artifact updated at `.cclaw/artifacts/06-tdd.md` with Test Discovery, System-Wide Impact Check, RED, GREEN, and REFACTOR sections.",
108
+ "Artifact updated at `.cclaw/artifacts/06-tdd.md` with System-Wide Impact Check, Acceptance & Failure Map, REFACTOR Notes, Iron Law Acknowledgement, Verification Ladder, and Learnings.",
108
109
  "Relevant existing test files, helpers, fixtures, and exact commands identified before RED.",
109
110
  "Callbacks, state transitions, interfaces, schemas, and contracts checked for impact before implementation.",
110
111
  "Execution posture and vertical-slice RED/GREEN/REFACTOR checkpoint plan recorded, including commit boundaries when the repo workflow supports them.",
111
- "Failing command output captured (RED).",
112
- "Full test/build output recorded (GREEN).",
112
+ "RED observability: a `phase=red` event in `delegation-events.jsonl` for each slice with non-empty evidenceRefs (test path, span ref, or pasted-output pointer). Legacy `## Watched-RED Proof` / `## RED Evidence` markdown tables remain valid as a fallback.",
113
+ "GREEN observability: a `phase=green` event in `delegation-events.jsonl` per slice whose `completedTs` >= the matching `phase=red` `completedTs` and whose evidenceRefs name the failing-now-passing test. Legacy `## GREEN Evidence` block remains valid as a fallback.",
114
+ "REFACTOR observability: per slice, a `phase=refactor` event OR a `phase=refactor-deferred` event whose evidenceRefs / refactor rationale captures why refactor was deferred.",
113
115
  "Fresh verification evidence recorded with command, PASS/FAIL status, and commit SHA or no-VCS reason plus content/artifact hash before completion.",
114
116
  "Iron Law Acknowledgement section explicitly states `Acknowledged: yes`.",
115
- "Watched-RED Proof includes at least one populated row with an ISO timestamp.",
116
- "Vertical Slice Cycle records RED, GREEN, and REFACTOR per active slice.",
117
117
  "Acceptance mapping documented.",
118
118
  "Failure reason analysis recorded.",
119
119
  "Refactor rationale captured.",
120
- "Traceability to task identifier is documented."
120
+ "Traceability to task identifier is documented.",
121
+ "On discoveryMode=deep: per slice, a `phase=doc` event from `slice-documenter` whose evidenceRefs name `<artifacts-dir>/tdd-slices/S-<id>.md`. On other discovery modes the documenter event is advisory."
121
122
  ],
122
123
  inputs: ["approved plan slice", "spec acceptance criterion", "test harness configuration", "coding standards and constraints"],
123
124
  requiredContext: ["plan artifact", "spec artifact", "existing test patterns", "affected contracts and state boundaries"],
@@ -156,16 +157,16 @@ export const TDD = {
156
157
  },
157
158
  artifactValidation: [
158
159
  { section: "Upstream Handoff", required: false, validationRule: "Summarizes plan/spec/design decisions, constraints, open questions, and explicit drift before RED work." },
159
- { section: "Test Discovery", required: true, validationRule: "Before RED: lists existing tests, fixtures/helpers, exact commands, and the chosen local pattern to extend." },
160
+ { section: "Test Discovery", required: false, validationRule: "Overall narrative for how the stage discovered the existing test surface. Per-slice details live under `tdd-slices/S-<id>.md` from v6.11.0; the `## Test Discovery` heading is optional/advisory." },
160
161
  { section: "System-Wide Impact Check", required: true, validationRule: "Before implementation: names affected callbacks, state transitions, interfaces, schemas, public APIs/config/CLI, persistence, or event contracts, with coverage or explicit out-of-scope notes." },
161
- { section: "RED Evidence", required: true, validationRule: "Failing test output captured per slice." },
162
- { section: "Acceptance & Failure Map", required: false, validationRule: "Each slice row carries Source ID, AC ID, expected behavior, and a RED-link (delegation spanId, evidence path, or sidecar redOutputRef)." },
163
- { section: "GREEN Evidence", required: true, validationRule: "Full suite pass output captured." },
162
+ { section: "RED Evidence", required: true, validationRule: "Failing test output per slice. From v6.11.0 this section is auto-satisfied by a `phase=red` event in `delegation-events.jsonl` with non-empty evidenceRefs; the markdown block remains required as a legacy fallback when phase events are absent." },
163
+ { section: "Acceptance & Failure Map", required: false, validationRule: "Each slice row carries Source ID, AC ID, expected behavior, and a RED-link (delegation spanId or evidence path). From v6.11.0 the column is auto-derivable from `phase=red` events." },
164
+ { section: "GREEN Evidence", required: true, validationRule: "Full suite pass output. From v6.11.0 this section is auto-satisfied by a `phase=green` event in `delegation-events.jsonl` with non-empty evidenceRefs; the markdown block remains required as a legacy fallback when phase events are absent." },
164
165
  { section: "REFACTOR Notes", required: true, validationRule: "What changed, why, behavior preservation confirmed." },
165
166
  { section: "Traceability", required: true, validationRule: "Plan task ID and spec criterion linked." },
166
167
  { section: "Iron Law Acknowledgement", required: true, validationRule: "Must include `Acknowledged: yes` and list exceptions (or `None`)." },
167
- { section: "Watched-RED Proof", required: true, validationRule: "At least one populated row with ISO timestamp proving RED was observed before production edits." },
168
- { section: "Vertical Slice Cycle", required: true, validationRule: "Per active slice records RED, GREEN, and REFACTOR timestamps (refactor may be deferred only with explicit rationale)." },
168
+ { section: "Watched-RED Proof", required: false, validationRule: "From v6.11.0 the Watched-RED summary is auto-rendered from `delegation-events.jsonl` slice phase events (see auto-start: tdd-slice-summary marker). Legacy markdown tables continue to validate via the fallback path." },
169
+ { section: "Vertical Slice Cycle", required: false, validationRule: "From v6.11.0 the Vertical Slice Cycle table is auto-rendered between `auto-start: tdd-slice-summary` markers. Legacy markdown tables continue to validate via the fallback path." },
169
170
  { section: "Verification Ladder", required: true, validationRule: "Per-slice verification tier (static, command, behavioral, human) with evidence captured for the highest tier reached this turn. Must include command + PASS/FAIL + commit SHA when VCS is present, or explicit no-vcs reason plus content/artifact hash/config override." },
170
171
  { section: "TDD Blocker Taxonomy", required: false, validationRule: "When blocked, classify as NO_SOURCE_CONTEXT, NO_TEST_SURFACE, NO_IMPLEMENTABLE_SLICE, RED_NOT_EXPRESSIBLE, or NO_VCS_MODE; include blockedBecause, missingInputs, recommendedRoute, nextCommand, and resumeCriteria." },
171
172
  { section: "Coverage Targets", required: false, validationRule: "If present: per-module or per-code-type coverage thresholds with current values and measurement commands." },
@@ -304,7 +305,7 @@ function tddStageVariantForTrack(track) {
304
305
  return {
305
306
  ...row,
306
307
  required: true,
307
- validationRule: "Each slice row carries Source ID, AC ID (spec acceptance criterion ID, for example AC-1), expected behavior, and a RED-link (delegation spanId, evidence path, or sidecar redOutputRef)."
308
+ validationRule: "Each slice row carries Source ID, AC ID (spec acceptance criterion ID, for example AC-1), expected behavior, and a RED-link (delegation spanId or evidence path). From v6.11.0 a `phase=red` event in `delegation-events.jsonl` with non-empty evidenceRefs satisfies the row."
308
309
  };
309
310
  }
310
311
  if (row.section === "Traceability") {
@@ -676,7 +676,7 @@ function sliceImplementerEnhancedBody() {
676
676
  ${MARKDOWN_CODE_FENCE}
677
677
  You are a slice-implementer subagent.
678
678
 
679
- SLICE: {single vertical slice}
679
+ SLICE: {single vertical slice — controller MUST dispatch you with --slice S-<id> --phase green --paths <comma-separated>}
680
680
  RED_EVIDENCE: {failing test and expected failure}
681
681
  ALLOWED_FILES: {explicit file boundaries — surfaced to scheduler as Files: <paths>}
682
682
  FORBIDDEN_CHANGES: {scope/compatibility limits}
@@ -687,11 +687,11 @@ Rules:
687
687
  - Keep REFACTOR behavior-preserving.
688
688
  - Return the strict worker JSON schema first.
689
689
 
690
- Slice ledger contract (v6.10.0):
691
- - After observing the failing test, run \`cclaw-cli internal tdd-slice-record --slice <id> --status red --test-file <path> --command <cmd> --paths <comma-separated> [--ac <id>] [--plan-unit <id>]\`. The command appends to \`.cclaw/artifacts/06-tdd-slices.jsonl\`.
692
- - After the same test passes, run \`cclaw-cli internal tdd-slice-record --slice <id> --status green [--green-output-ref <path|spanId:...>]\`.
693
- - After REFACTOR, run \`cclaw-cli internal tdd-slice-record --slice <id> --status refactor-done\` or \`--status refactor-deferred --refactor-rationale "<why>"\`.
694
- - Do NOT hand-edit the Watched-RED Proof or Vertical Slice Cycle markdown tables; the linter reads the JSONL sidecar when present and the markdown becomes an auto-derived view.
690
+ Slice phase-event contract (v6.11.0):
691
+ - Do NOT hand-edit \`## Watched-RED Proof\`, \`## Vertical Slice Cycle\`, \`## RED Evidence\`, or \`## GREEN Evidence\` markdown tables in 06-tdd.md. The linter auto-renders them between \`<!-- auto-start: tdd-slice-summary -->\` markers from \`delegation-events.jsonl\` slice phase rows.
692
+ - Your dispatch row IS the evidence: the harness-generated delegation-record hook stamps \`sliceId=S-<id>\`, \`phase=green\`, and \`completedTs\` automatically. Attach evidenceRefs (test path, span ref, or pasted-output pointer) so the linter validates the row.
693
+ - After REFACTOR, ask the controller to re-dispatch you with \`--phase refactor\` (or \`--phase refactor-deferred --refactor-rationale "<why>"\`); each call appends a new ledger row.
694
+ - Per-slice prose summary lives in \`<artifacts-dir>/tdd-slices/S-<id>.md\` and is owned by the parallel \`slice-documenter\` (or the controller). You do NOT touch that file.
695
695
  ${MARKDOWN_CODE_FENCE}
696
696
 
697
697
  `;
@@ -935,14 +935,15 @@ FIXTURES / PATTERNS: {links to helper modules by path + naming conventions}
935
935
 
936
936
  Process (mandatory):
937
937
  1) If STAGE_MODE=TEST_RED_ONLY:
938
- - RED only add failing tests proving the gap (show failing output excerpt).
938
+ - Controller dispatched you with \`--slice S-<id> --phase red\`. Add failing tests proving the gap (show failing output excerpt).
939
939
  - Do NOT edit production code.
940
- - Append the slice to the sidecar via \`cclaw-cli internal tdd-slice-record --slice <id> --status red --test-file <path> --command <cmd> --paths <comma-separated>\` instead of editing the Watched-RED Proof markdown table.
940
+ - Do NOT hand-edit \`## Watched-RED Proof\` / \`## RED Evidence\` markdown tables in 06-tdd.md the linter auto-renders them from your dispatch row in \`delegation-events.jsonl\`. Just ensure your worker return includes evidenceRefs (test path, span ref, or pasted-output pointer) so the harness can stamp them on the ledger row.
941
941
  - Report: TESTS_ADDED, RED_COMMAND_RUN, RED_EVIDENCE, STATUS: DONE|BLOCKED.
942
942
  2) If STAGE_MODE=BUILD_GREEN_REFACTOR:
943
+ - Controller dispatched you with \`--slice S-<id> --phase green\` (and later \`--phase refactor\` or \`--phase refactor-deferred --refactor-rationale "<why>"\`).
943
944
  - GREEN — minimal production code to satisfy existing RED tests, rerun full suite.
944
945
  - REFACTOR — only after full suite is green; preserve behavior.
945
- - Append \`--status green\` (and \`--status refactor-done\` or \`--status refactor-deferred --refactor-rationale "<why>"\` after refactor) via \`cclaw-cli internal tdd-slice-record\`. The Vertical Slice Cycle markdown stays auto-derived from this sidecar.
946
+ - Do NOT hand-edit \`## Vertical Slice Cycle\` / \`## GREEN Evidence\` markdown tables auto-rendered from your dispatch row.
946
947
  - Report: FILES_EDITED, GREEN_COMMAND_RUN, REFACTOR_NOTES, STATUS: DONE|BLOCKED.
947
948
  ${MARKDOWN_CODE_FENCE}
948
949
 
@@ -17,4 +17,10 @@ export declare const RULEBOOK_MARKDOWN = "# Cclaw Rulebook\n\n## MUST_ALWAYS\n-
17
17
  */
18
18
  export declare const CURSOR_GUIDELINES_RULE_MDC = "---\ndescription: cclaw zero-install behavior baseline (always-on)\nglobs:\n - \"**/*\"\nalwaysApply: true\n---\n\n<!-- cclaw-managed-cursor-guidelines-rule -->\n\n# Cclaw Baseline Guidelines\n\nThese three rules apply to every Cursor agent session in this project,\nregardless of whether stage skills loaded.\n\n## 1. Q&A floor before drafting (brainstorm/scope/design)\n\nBefore drafting any `.cclaw/artifacts/01-brainstorm-*.md`,\n`02-scope-*.md`, or `03-design-*.md`, verify that the artifact's\n`## Q&A Log` table demonstrates Ralph-Loop convergence: every\nforcing-question topic id is tagged `[topic:<id>]` on at least one row\n(see the stage's forcing-questions checklist for the id list), the last\n2 turns produce no new decision-changing impact, OR an explicit user\nstop-signal row is recorded. Walk the stage forcing questions one at a\ntime via the `AskQuestion` tool. If you find yourself proposing a\ndraft after 1-2 questions while forcing topic ids remain untagged, STOP\nand continue the loop.\n\nThe `qa_log_unconverged` linter rule will block `stage-complete` when\nconvergence has not been reached. Wave 24 (v6.0.0) made `[topic:<id>]`\ntagging mandatory; the English keyword fallback was removed because it\nmis-reported convergence on RU/UA Q&A logs.\n\n## 2. Mandatory subagents run after Q&A approval\n\nFor brainstorm / scope / design, mandatory subagents (\n`product-discovery`, `critic`, `planner`, `architect`,\n`test-author`) run **only AFTER the user approves the elicitation\noutcome**, never before the Q&A loop converges. Dispatching them early\npreempts the user dialogue and violates the elicitation contract \u2014 the\nlinter will block stage-complete.\n\nSee each stage's \"Run Phase: post-elicitation\" rows in the materialized\nAutomatic Subagent Dispatch table.\n\n## 3. Never echo cclaw command lines to chat\n\nThe user does not run cclaw helpers (`node .cclaw/hooks/...`) manually.\nNEVER paste full command lines, `--evidence-json '{...}'` payloads,\n`--waive-delegation=...`, or shell hash commands (`shasum`,\n`sha256sum`, `Get-FileHash`, `certutil`, etc.) into chat. Run the\nhelper via the tool layer and report only the resulting summary. On\nfailure, report a compact human-readable summary plus the helper JSON in\na single fenced `json` block.\n";
19
19
  export declare const CURSOR_WORKFLOW_RULE_MDC = "---\ndescription: cclaw workflow guardrails for Cursor agent sessions\nglobs:\n - \"**/*\"\nalwaysApply: true\n---\n\n<!-- cclaw-managed-cursor-workflow-rule -->\n\n# Cclaw Workflow Guardrails\n\n## Activation Rule\n\nBefore responding to coding work:\n1. Read `.cclaw/state/flow-state.json`.\n2. Start with `/cc` or continue with `/cc`.\n3. If no software-stage flow applies, respond normally.\n\n## Stage Order\n\n`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship`\n\nTrack-specific skips are allowed only when `flow-state.track` + `skippedStages` explicitly say so.\n\n## Task Classification\n\n| Class | Route |\n|---|---|\n| non-trivial software work | `/cc <idea>` |\n| trivial software fix | `/cc <idea>` (quick track) |\n| bugfix with repro | `/cc <idea>` and enforce RED-first in tdd |\n| pure question / non-software | direct answer (no stage flow) |\n\n## Command Surface\n\n- `/cc` = entry and resume.\n- `/cc` = only progression path.\n- Knowledge capture and recall use the `learnings` skill when requested.\n\n## Verification Discipline\n\n- No completion claim without fresh command evidence in this turn.\n- Stage completion claim requires `stage-complete` exit 0 in the current turn. Quote the single-line success JSON printed to stdout (e.g. `{\"ok\":true,\"command\":\"stage-complete\",...}`); do not paraphrase, do not infer success from empty stdout or from skipped retries.\n\n## Protocol label hygiene\n\n`skip` wording means different things depending on phase: brainstorm/scope/design Q&A stop-signals may still literal **skip**/enough/move-on wording; structured ship closeout retros and compound clustering prompts should expose **no changes** (or accept-as-is language) rather than labeling the passive path as skip. Keep the verbs aligned with the harness question copy you present to the human.\n- Do not mark gates passed from memory.\n- Keep evidence in `.cclaw/artifacts/`; archive through closeout via `/cc` or cancel early via `node .cclaw/hooks/cancel-run.mjs`.\n\n## Delegation And Approvals\n\n- Machine-only checks in design/plan/tdd/review/ship should auto-dispatch when tooling supports it.\n- **For brainstorm / scope / design stages**: ask user input continuously via adaptive elicitation (one question per turn through the harness-native question tool \u2014 `AskQuestion` in Cursor). Walk the stage forcing-questions list one-by-one. **Tag each Q&A Log row's `Decision impact` cell with `[topic:<id>]`** (the id is given in the stage's forcing-questions checklist) so the linter can verify coverage in any natural language. Do NOT batch and do NOT defer to a single approval gate at the end. The `qa_log_unconverged` linter rule will block `stage-complete` when convergence is not reached (forcing topic ids untagged AND last 2 turns still produce decision-changing rows AND no stop-signal).\n- **For other stages** (spec/plan/tdd/build/review/ship): ask user input only at explicit approval gates (scope mode, plan approval, challenge resolution, ship finalization), not for routine progress updates.\n- If you find yourself proposing a draft after 1-2 questions in brainstorm/scope/design, STOP \u2014 go back to the forcing-questions list and continue.\n- Mandatory subagents in brainstorm/scope/design run only AFTER the user approves the elicitation outcome (see each stage's \"Run Phase: post-elicitation\" rows). Dispatching them before the Q&A loop converges violates the contract.\n- Never echo cclaw command lines (`node .cclaw/hooks/...`, `--evidence-json '{...}'`) to chat \u2014 the user does not run cclaw manually. Run helpers via the tool layer; report only the resulting summary.\n- If harness capabilities are partial, record waiver reasons in delegation logs.\n\n## Routing Source Of Truth\n\n- Primary router: `.cclaw/skills/using-cclaw/SKILL.md`.\n- Stage behavior: current stage skill plus `.cclaw/state/flow-state.json`.\n- Preamble budget: keep role/status announcements brief and avoid repeating\n them unless the stage or role changes.\n";
20
+ /**
21
+ * v6.11.0 (S2) — per-slice prose file written by `slice-documenter`
22
+ * (or the controller) to `<artifacts-dir>/tdd-slices/S-<id>.md`. The
23
+ * main `06-tdd.md` is auto-indexed via `## Slices Index`.
24
+ */
25
+ export declare function tddSliceFileTemplate(sliceId: string): string;
20
26
  export declare function buildRulesJson(): Record<string, unknown>;