cclaw-cli 6.5.0 → 6.7.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.
Files changed (49) hide show
  1. package/dist/artifact-linter/brainstorm.js +2 -1
  2. package/dist/artifact-linter/design.js +2 -1
  3. package/dist/artifact-linter/findings-dedup.d.ts +56 -0
  4. package/dist/artifact-linter/findings-dedup.js +232 -0
  5. package/dist/artifact-linter/plan.js +4 -2
  6. package/dist/artifact-linter/review.js +2 -1
  7. package/dist/artifact-linter/scope.js +2 -1
  8. package/dist/artifact-linter/shared.d.ts +103 -0
  9. package/dist/artifact-linter/shared.js +177 -0
  10. package/dist/artifact-linter/tdd.js +2 -1
  11. package/dist/artifact-linter.d.ts +1 -1
  12. package/dist/artifact-linter.js +45 -3
  13. package/dist/content/examples.d.ts +32 -0
  14. package/dist/content/examples.js +74 -0
  15. package/dist/content/hooks.js +36 -1
  16. package/dist/content/node-hooks.js +43 -0
  17. package/dist/content/skills-elicitation.js +3 -6
  18. package/dist/content/skills.d.ts +10 -0
  19. package/dist/content/skills.js +44 -2
  20. package/dist/content/stages/brainstorm.js +7 -5
  21. package/dist/content/stages/design.js +3 -1
  22. package/dist/content/stages/plan.js +3 -1
  23. package/dist/content/stages/review.js +3 -1
  24. package/dist/content/stages/scope.js +5 -3
  25. package/dist/content/stages/ship.js +2 -1
  26. package/dist/content/stages/spec.js +3 -1
  27. package/dist/content/stages/tdd.js +3 -1
  28. package/dist/content/templates.d.ts +9 -0
  29. package/dist/content/templates.js +45 -2
  30. package/dist/delegation.d.ts +9 -0
  31. package/dist/delegation.js +3 -0
  32. package/dist/internal/advance-stage/advance.js +23 -1
  33. package/dist/internal/advance-stage/parsers.d.ts +8 -0
  34. package/dist/internal/advance-stage/parsers.js +7 -0
  35. package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +3 -0
  36. package/dist/internal/advance-stage/proactive-delegation-trace.js +8 -1
  37. package/dist/internal/advance-stage/rewind.js +2 -2
  38. package/dist/internal/advance-stage/start-flow.js +4 -1
  39. package/dist/internal/advance-stage.js +32 -2
  40. package/dist/internal/flow-state-repair.d.ts +13 -0
  41. package/dist/internal/flow-state-repair.js +65 -0
  42. package/dist/internal/waiver-grant.d.ts +62 -0
  43. package/dist/internal/waiver-grant.js +294 -0
  44. package/dist/run-persistence.d.ts +70 -0
  45. package/dist/run-persistence.js +215 -3
  46. package/dist/runs.d.ts +1 -1
  47. package/dist/runs.js +1 -1
  48. package/dist/runtime/run-hook.mjs +43 -0
  49. package/package.json +1 -1
@@ -1,9 +1,10 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { checkCriticPredictionsContract, evaluateQaLogFloor, sectionBodyByName, validateApproachesTaxonomy, headingLineIndex, meaningfulLineCount, getMarkdownTableRows, parseShortCircuitStatus, validateCalibratedSelfReview, markdownFieldRegex } from "./shared.js";
3
+ import { checkCriticPredictionsContract, evaluateInvestigationTrace, evaluateQaLogFloor, sectionBodyByName, validateApproachesTaxonomy, headingLineIndex, meaningfulLineCount, getMarkdownTableRows, parseShortCircuitStatus, validateCalibratedSelfReview, markdownFieldRegex } from "./shared.js";
4
4
  import { readFlowState } from "../run-persistence.js";
5
5
  export async function lintBrainstormStage(ctx) {
6
6
  const { projectRoot, track, raw, absFile, sections, findings, parsedFrontmatter, brainstormShortCircuitBody, brainstormShortCircuitActivated, staleDiagramAuditEnabled, isTrivialOverride } = ctx;
7
+ evaluateInvestigationTrace(ctx, "Q&A Log");
7
8
  const qaLogBody = sectionBodyByName(sections, "Q&A Log");
8
9
  const qaLogRows = qaLogBody ? getMarkdownTableRows(qaLogBody) : [];
9
10
  const qaLogOk = qaLogBody !== null && qaLogRows.length > 0;
@@ -3,7 +3,7 @@ import path from "node:path";
3
3
  import { resolveArtifactPath as resolveStageArtifactPath } from "../artifact-paths.js";
4
4
  import { exists } from "../fs-utils.js";
5
5
  import { CONFIDENCE_FINDING_REGEX_SOURCE } from "../content/skills.js";
6
- import { checkCriticPredictionsContract, evaluateLayeredDocumentReviewStatus, evaluateQaLogFloor, extractMarkdownSectionBody, getMarkdownTableRows, meaningfulLineCount, sectionBodyByName, markdownFieldRegex } from "./shared.js";
6
+ import { checkCriticPredictionsContract, evaluateInvestigationTrace, evaluateLayeredDocumentReviewStatus, evaluateQaLogFloor, extractMarkdownSectionBody, getMarkdownTableRows, meaningfulLineCount, sectionBodyByName, markdownFieldRegex } from "./shared.js";
7
7
  const DESIGN_DIAGRAM_REQUIREMENTS = {
8
8
  lightweight: [
9
9
  {
@@ -268,6 +268,7 @@ async function runStaleDiagramAudit(projectRoot, artifactPath, artifactRaw, code
268
268
  }
269
269
  export async function lintDesignStage(ctx) {
270
270
  const { projectRoot, track, raw, absFile, sections, findings, parsedFrontmatter, brainstormShortCircuitBody, brainstormShortCircuitActivated, staleDiagramAuditEnabled, isTrivialOverride, activeStageFlags } = ctx;
271
+ evaluateInvestigationTrace(ctx, "Codebase Investigation");
271
272
  const qaLogBody = sectionBodyByName(sections, "Q&A Log");
272
273
  const qaLogRows = qaLogBody ? getMarkdownTableRows(qaLogBody) : [];
273
274
  const qaLogOk = qaLogBody !== null && qaLogRows.length > 0;
@@ -0,0 +1,56 @@
1
+ import type { FlowStage } from "../types.js";
2
+ import type { LintFinding } from "./shared.js";
3
+ export declare const FINDINGS_CACHE_SCHEMA_VERSION = 1;
4
+ export type FindingStatus = {
5
+ kind: "new";
6
+ } | {
7
+ kind: "repeat";
8
+ count: number;
9
+ } | {
10
+ kind: "resolved";
11
+ };
12
+ export interface ClassifiedFinding {
13
+ finding: LintFinding;
14
+ fingerprint: string;
15
+ status: FindingStatus;
16
+ }
17
+ export interface ResolvedFinding {
18
+ fingerprint: string;
19
+ rule: string;
20
+ lastSeenAt: string;
21
+ }
22
+ export interface FindingsDedupSummary {
23
+ newCount: number;
24
+ repeatCount: number;
25
+ resolvedCount: number;
26
+ resolved: ResolvedFinding[];
27
+ }
28
+ export interface LintRunDedupResult {
29
+ classified: ClassifiedFinding[];
30
+ summary: FindingsDedupSummary;
31
+ header: string;
32
+ }
33
+ /**
34
+ * Normalize a finding detail string so volatile tokens (run IDs,
35
+ * timestamps, counts, hex hashes, temp paths) don't cause a finding
36
+ * to appear "new" on every invocation.
37
+ */
38
+ export declare function normalizeFindingDetail(detail: string): string;
39
+ export declare function fingerprintFinding(stage: FlowStage, finding: LintFinding): string;
40
+ /**
41
+ * Classify each emitted finding as `new`, `repeat:N`, or `resolved`
42
+ * relative to the cached sidecar for this stage. Persists the updated
43
+ * fingerprint set under a directory lock so concurrent lint runs for
44
+ * the same project don't clobber each other.
45
+ *
46
+ * The returned `header` is a short human string intended for inclusion
47
+ * above the linter output; it's stable across runs when findings
48
+ * repeat. Empty string when there is nothing meaningful to report
49
+ * (no findings and no carry-over state).
50
+ */
51
+ export declare function classifyAndPersistFindings(projectRoot: string, stage: FlowStage, findings: LintFinding[], options?: {
52
+ now?: Date;
53
+ }): Promise<LintRunDedupResult>;
54
+ export declare function buildDedupHeader(stage: FlowStage, summary: FindingsDedupSummary): string;
55
+ export declare function formatFindingStatusTag(status: FindingStatus): string;
56
+ export declare function findingsDedupCachePathFor(projectRoot: string): string;
@@ -0,0 +1,232 @@
1
+ import { createHash } from "node:crypto";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { RUNTIME_ROOT } from "../constants.js";
5
+ import { ensureDir, exists, withDirectoryLock, writeFileSafe } from "../fs-utils.js";
6
+ /**
7
+ * Wave 26 (v6.7.0) linter-dedup cache. The linter persists a per-stage
8
+ * fingerprint of each finding between runs so authors can tell at a
9
+ * glance what's `new`, `repeat`, or `resolved` relative to the last run.
10
+ *
11
+ * Fingerprint = `sha256(stage | rule | normalizedDetail).slice(0, 8)`.
12
+ * Details are normalized to stabilize the digest: whitespace collapsed,
13
+ * run-ids/hashes/timestamps replaced with placeholders, and enumeration
14
+ * counts (e.g. "3 approach detail card(s)") replaced with `<N>`.
15
+ *
16
+ * The cache is intentionally bounded by `MAX_PER_STAGE` so a noisy stage
17
+ * can't grow the sidecar without bound. When the active run trims the
18
+ * cache we drop the oldest `firstSeenAt` entries first.
19
+ */
20
+ const FINDINGS_CACHE_REL_PATH = `${RUNTIME_ROOT}/.linter-findings.json`;
21
+ const FINDINGS_CACHE_LOCK_REL_PATH = `${RUNTIME_ROOT}/.linter-findings.json.lock`;
22
+ export const FINDINGS_CACHE_SCHEMA_VERSION = 1;
23
+ const MAX_PER_STAGE = 200;
24
+ function cachePath(projectRoot) {
25
+ return path.join(projectRoot, FINDINGS_CACHE_REL_PATH);
26
+ }
27
+ function cacheLockPath(projectRoot) {
28
+ return path.join(projectRoot, FINDINGS_CACHE_LOCK_REL_PATH);
29
+ }
30
+ function emptyStageCache() {
31
+ return { findings: [], lastRunAt: null };
32
+ }
33
+ function emptyCacheFile() {
34
+ return { schemaVersion: FINDINGS_CACHE_SCHEMA_VERSION, stages: {} };
35
+ }
36
+ /**
37
+ * Normalize a finding detail string so volatile tokens (run IDs,
38
+ * timestamps, counts, hex hashes, temp paths) don't cause a finding
39
+ * to appear "new" on every invocation.
40
+ */
41
+ export function normalizeFindingDetail(detail) {
42
+ if (typeof detail !== "string" || detail.length === 0)
43
+ return "";
44
+ let normalized = detail;
45
+ normalized = normalized.replace(/\brun-[a-z0-9-]+\b/giu, "run-<id>");
46
+ normalized = normalized.replace(/\b[0-9a-f]{16,}\b/giu, "<hex>");
47
+ normalized = normalized.replace(/\b\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?\b/gu, "<ts>");
48
+ normalized = normalized.replace(/\b\d{10,}\b/gu, "<n>");
49
+ normalized = normalized.replace(/\b\d+\b/gu, "<n>");
50
+ normalized = normalized.replace(/[ \t]+/gu, " ");
51
+ normalized = normalized.replace(/\r?\n/gu, " ");
52
+ return normalized.trim().toLowerCase();
53
+ }
54
+ export function fingerprintFinding(stage, finding) {
55
+ const payload = `${stage}|${finding.rule.trim()}|${normalizeFindingDetail(finding.details)}`;
56
+ return createHash("sha256").update(payload, "utf8").digest("hex").slice(0, 8);
57
+ }
58
+ async function readCacheFile(projectRoot) {
59
+ const filePath = cachePath(projectRoot);
60
+ if (!(await exists(filePath)))
61
+ return emptyCacheFile();
62
+ let raw;
63
+ try {
64
+ raw = await fs.readFile(filePath, "utf8");
65
+ }
66
+ catch {
67
+ return emptyCacheFile();
68
+ }
69
+ let parsed;
70
+ try {
71
+ parsed = JSON.parse(raw);
72
+ }
73
+ catch {
74
+ return emptyCacheFile();
75
+ }
76
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
77
+ return emptyCacheFile();
78
+ }
79
+ const typed = parsed;
80
+ const stages = (typed.stages ?? {});
81
+ const next = emptyCacheFile();
82
+ for (const [stageKey, value] of Object.entries(stages)) {
83
+ if (!value || typeof value !== "object" || Array.isArray(value))
84
+ continue;
85
+ const rawStage = value;
86
+ const findingsRaw = Array.isArray(rawStage.findings) ? rawStage.findings : [];
87
+ const findings = [];
88
+ for (const row of findingsRaw) {
89
+ if (!row || typeof row !== "object" || Array.isArray(row))
90
+ continue;
91
+ const r = row;
92
+ const fingerprint = typeof r.fingerprint === "string" ? r.fingerprint : "";
93
+ const rule = typeof r.rule === "string" ? r.rule : "";
94
+ const section = typeof r.section === "string" ? r.section : "";
95
+ const firstSeenAt = typeof r.firstSeenAt === "string" ? r.firstSeenAt : "";
96
+ const lastSeenAt = typeof r.lastSeenAt === "string" ? r.lastSeenAt : "";
97
+ const runCount = typeof r.runCount === "number" && Number.isFinite(r.runCount)
98
+ ? Math.max(1, Math.floor(r.runCount))
99
+ : 1;
100
+ if (fingerprint.length === 0 || rule.length === 0)
101
+ continue;
102
+ findings.push({ fingerprint, rule, section, firstSeenAt, lastSeenAt, runCount });
103
+ }
104
+ next.stages[stageKey] = {
105
+ findings,
106
+ lastRunAt: typeof rawStage.lastRunAt === "string" ? rawStage.lastRunAt : null
107
+ };
108
+ }
109
+ return next;
110
+ }
111
+ async function writeCacheFile(projectRoot, cache) {
112
+ await ensureDir(path.dirname(cachePath(projectRoot)));
113
+ await writeFileSafe(cachePath(projectRoot), `${JSON.stringify(cache, null, 2)}\n`, { mode: 0o600 });
114
+ }
115
+ /**
116
+ * Classify each emitted finding as `new`, `repeat:N`, or `resolved`
117
+ * relative to the cached sidecar for this stage. Persists the updated
118
+ * fingerprint set under a directory lock so concurrent lint runs for
119
+ * the same project don't clobber each other.
120
+ *
121
+ * The returned `header` is a short human string intended for inclusion
122
+ * above the linter output; it's stable across runs when findings
123
+ * repeat. Empty string when there is nothing meaningful to report
124
+ * (no findings and no carry-over state).
125
+ */
126
+ export async function classifyAndPersistFindings(projectRoot, stage, findings, options = {}) {
127
+ const nowIso = (options.now ?? new Date()).toISOString();
128
+ return withDirectoryLock(cacheLockPath(projectRoot), async () => {
129
+ const cache = await readCacheFile(projectRoot);
130
+ const previous = cache.stages[stage] ?? emptyStageCache();
131
+ const previousByFingerprint = new Map();
132
+ for (const entry of previous.findings) {
133
+ previousByFingerprint.set(entry.fingerprint, entry);
134
+ }
135
+ const currentFingerprints = new Set();
136
+ const classified = [];
137
+ const nextFindings = [];
138
+ let newCount = 0;
139
+ let repeatCount = 0;
140
+ for (const finding of findings) {
141
+ const fingerprint = fingerprintFinding(stage, finding);
142
+ currentFingerprints.add(fingerprint);
143
+ const prior = previousByFingerprint.get(fingerprint);
144
+ if (prior) {
145
+ const nextEntry = {
146
+ fingerprint,
147
+ rule: finding.rule,
148
+ section: finding.section,
149
+ firstSeenAt: prior.firstSeenAt || nowIso,
150
+ lastSeenAt: nowIso,
151
+ runCount: prior.runCount + 1
152
+ };
153
+ nextFindings.push(nextEntry);
154
+ repeatCount += 1;
155
+ classified.push({
156
+ finding,
157
+ fingerprint,
158
+ status: { kind: "repeat", count: nextEntry.runCount }
159
+ });
160
+ continue;
161
+ }
162
+ const nextEntry = {
163
+ fingerprint,
164
+ rule: finding.rule,
165
+ section: finding.section,
166
+ firstSeenAt: nowIso,
167
+ lastSeenAt: nowIso,
168
+ runCount: 1
169
+ };
170
+ nextFindings.push(nextEntry);
171
+ newCount += 1;
172
+ classified.push({
173
+ finding,
174
+ fingerprint,
175
+ status: { kind: "new" }
176
+ });
177
+ }
178
+ const resolved = [];
179
+ for (const entry of previous.findings) {
180
+ if (currentFingerprints.has(entry.fingerprint))
181
+ continue;
182
+ resolved.push({
183
+ fingerprint: entry.fingerprint,
184
+ rule: entry.rule,
185
+ lastSeenAt: entry.lastSeenAt
186
+ });
187
+ }
188
+ nextFindings.sort((a, b) => {
189
+ const aTime = Date.parse(a.firstSeenAt);
190
+ const bTime = Date.parse(b.firstSeenAt);
191
+ return Number.isFinite(aTime) && Number.isFinite(bTime) ? aTime - bTime : 0;
192
+ });
193
+ const trimmed = nextFindings.length > MAX_PER_STAGE
194
+ ? nextFindings.slice(nextFindings.length - MAX_PER_STAGE)
195
+ : nextFindings;
196
+ cache.stages[stage] = {
197
+ findings: trimmed,
198
+ lastRunAt: nowIso
199
+ };
200
+ await writeCacheFile(projectRoot, cache);
201
+ const summary = {
202
+ newCount,
203
+ repeatCount,
204
+ resolvedCount: resolved.length,
205
+ resolved
206
+ };
207
+ const header = buildDedupHeader(stage, summary);
208
+ return { classified, summary, header };
209
+ });
210
+ }
211
+ export function buildDedupHeader(stage, summary) {
212
+ const parts = [];
213
+ if (summary.newCount > 0)
214
+ parts.push(`${summary.newCount} new`);
215
+ if (summary.repeatCount > 0)
216
+ parts.push(`${summary.repeatCount} repeat`);
217
+ if (summary.resolvedCount > 0)
218
+ parts.push(`${summary.resolvedCount} resolved`);
219
+ if (parts.length === 0)
220
+ return "";
221
+ return `linter findings (stage=${stage}): ${parts.join(", ")}.`;
222
+ }
223
+ export function formatFindingStatusTag(status) {
224
+ if (status.kind === "new")
225
+ return "[new]";
226
+ if (status.kind === "resolved")
227
+ return "[resolved]";
228
+ return `[repeat:${status.count}]`;
229
+ }
230
+ export function findingsDedupCachePathFor(projectRoot) {
231
+ return cachePath(projectRoot);
232
+ }
@@ -1,10 +1,11 @@
1
- import { evaluateLayeredDocumentReviewStatus, headingPresent, sectionBodyByName, collectPatternHits, PLACEHOLDER_PATTERNS, extractDecisionIds, SCOPE_REDUCTION_PATTERNS } from "./shared.js";
1
+ import { evaluateInvestigationTrace, evaluateLayeredDocumentReviewStatus, extractAuthoredBody, headingPresent, sectionBodyByName, collectPatternHits, PLACEHOLDER_PATTERNS, extractDecisionIds, SCOPE_REDUCTION_PATTERNS } from "./shared.js";
2
2
  import { resolveArtifactPath as resolveStageArtifactPath } from "../artifact-paths.js";
3
3
  import { exists } from "../fs-utils.js";
4
4
  import { FORBIDDEN_PLACEHOLDER_TOKENS, CONFIDENCE_FINDING_REGEX_SOURCE } from "../content/skills.js";
5
5
  import fs from "node:fs/promises";
6
6
  export async function lintPlanStage(ctx) {
7
7
  const { projectRoot, track, raw, absFile, sections, findings, parsedFrontmatter, brainstormShortCircuitBody, brainstormShortCircuitActivated, staleDiagramAuditEnabled, isTrivialOverride } = ctx;
8
+ evaluateInvestigationTrace(ctx, "Implementation Units");
8
9
  const strictPlanGuards = parsedFrontmatter.hasFrontmatter ||
9
10
  headingPresent(sections, "Plan Quality Scan") ||
10
11
  headingPresent(sections, "Locked Decision Coverage");
@@ -85,7 +86,8 @@ export async function lintPlanStage(ctx) {
85
86
  });
86
87
  }
87
88
  const allPlaceholderTokens = FORBIDDEN_PLACEHOLDER_TOKENS.map((token) => token.toLowerCase());
88
- const lowerRaw = raw.toLowerCase();
89
+ const authoredBody = extractAuthoredBody(raw);
90
+ const lowerRaw = authoredBody.toLowerCase();
89
91
  const planWidePlaceholderHits = allPlaceholderTokens.filter((token) => lowerRaw.includes(token));
90
92
  // Strip the "## NO PLACEHOLDERS Rule" section (which lists tokens) and
91
93
  // any acknowledgement text from the scan to avoid false positives where
@@ -1,7 +1,8 @@
1
- import { markdownFieldRegex, sectionBodyByName } from "./shared.js";
1
+ import { evaluateInvestigationTrace, markdownFieldRegex, sectionBodyByName } from "./shared.js";
2
2
  import { checkReviewTddNoCrossArtifactDuplication } from "./review-army.js";
3
3
  export async function lintReviewStage(ctx) {
4
4
  const { projectRoot, track, raw, absFile, sections, findings, parsedFrontmatter, brainstormShortCircuitBody, brainstormShortCircuitActivated, staleDiagramAuditEnabled, isTrivialOverride } = ctx;
5
+ evaluateInvestigationTrace(ctx, "Changed-File Coverage");
5
6
  // Universal Layer 2.7 structural checks (superpowers requesting + receiving).
6
7
  const frameBody = sectionBodyByName(sections, "Pre-Critic Self-Review");
7
8
  if (frameBody !== null) {
@@ -1,9 +1,10 @@
1
- import { checkCriticPredictionsContract, evaluateQaLogFloor, sectionBodyByHeadingPrefix, sectionBodyByName, extractCanonicalScopeMode, getMarkdownTableRows } from "./shared.js";
1
+ import { checkCriticPredictionsContract, evaluateInvestigationTrace, evaluateQaLogFloor, sectionBodyByHeadingPrefix, sectionBodyByName, extractCanonicalScopeMode, getMarkdownTableRows } from "./shared.js";
2
2
  import { readDelegationLedger, recordExpansionStrategistSkippedByTrack } from "../delegation.js";
3
3
  import { shouldDemoteArtifactValidationByTrack } from "../content/stage-schema.js";
4
4
  import { readFlowState } from "../run-persistence.js";
5
5
  export async function lintScopeStage(ctx) {
6
6
  const { projectRoot, track, raw, absFile, sections, findings, parsedFrontmatter, brainstormShortCircuitBody, brainstormShortCircuitActivated, staleDiagramAuditEnabled, isTrivialOverride, activeStageFlags, taskClass } = ctx;
7
+ evaluateInvestigationTrace(ctx, "Q&A Log");
7
8
  const lockedDecisionsBody = sectionBodyByHeadingPrefix(sections, "Locked Decisions") ?? "";
8
9
  const scopeSummaryBody = sectionBodyByName(sections, "Scope Summary") ?? "";
9
10
  const selectedScopeMode = extractCanonicalScopeMode(scopeSummaryBody);
@@ -123,11 +123,36 @@ export interface LintFinding {
123
123
  found: boolean;
124
124
  details: string;
125
125
  }
126
+ export interface LintFindingDedupSummary {
127
+ newCount: number;
128
+ repeatCount: number;
129
+ resolvedCount: number;
130
+ /**
131
+ * Short single-line human-facing summary of the dedup outcome. Empty
132
+ * string when there is nothing to report.
133
+ */
134
+ header: string;
135
+ /**
136
+ * Parallel to the `findings` array on `LintResult`; each status tags
137
+ * the finding at the same index as `new`, `repeat`, or `resolved`.
138
+ * `null` slots correspond to findings that weren't classified (for
139
+ * example, when the dedup cache is unreadable).
140
+ */
141
+ statuses: Array<{
142
+ kind: "new";
143
+ } | {
144
+ kind: "repeat";
145
+ count: number;
146
+ } | {
147
+ kind: "resolved";
148
+ } | null>;
149
+ }
126
150
  export interface LintResult {
127
151
  stage: string;
128
152
  file: string;
129
153
  passed: boolean;
130
154
  findings: LintFinding[];
155
+ dedup?: LintFindingDedupSummary;
131
156
  }
132
157
  export declare function normalizeHeadingTitle(title: string): string;
133
158
  export type H2SectionMap = Map<string, string>;
@@ -144,6 +169,30 @@ export type H2SectionMap = Map<string, string>;
144
169
  */
145
170
  export declare function extractH2Sections(markdown: string): H2SectionMap;
146
171
  export declare function duplicateH2Headings(markdown: string): string[];
172
+ /**
173
+ * Return the author-authored prose of an artifact, stripping linter meta
174
+ * regions so free-text scans (placeholder tokens, scope-reduction phrases,
175
+ * investigation trigger words) don't self-cannibalize by matching the
176
+ * linter's own templated meta-phrases.
177
+ *
178
+ * Stripping rules (in order):
179
+ * 1. `<!-- linter-meta --> ... <!-- /linter-meta -->` paired blocks.
180
+ * Both markers must appear on their own line; unterminated openings
181
+ * are left as-is so a malformed artifact cannot hide arbitrary
182
+ * content by omitting the closing marker.
183
+ * 2. Every other HTML comment (`<!-- ... -->`, possibly multi-line).
184
+ * 3. Fenced code blocks that are tagged `linter-rule` (e.g.
185
+ * ```` ```linter-rule ````). Plain fenced code blocks are preserved
186
+ * because many stages quote code samples that the linter should
187
+ * still see.
188
+ *
189
+ * The function guarantees the returned string is a strict subset of the
190
+ * original: no characters are synthesized, and line offsets are
191
+ * preserved for any surviving line (blank lines stand in for stripped
192
+ * regions). This keeps regex-based linter checks stable when authors
193
+ * add or remove linter-meta blocks between runs.
194
+ */
195
+ export declare function extractAuthoredBody(rawArtifact: string): string;
147
196
  export declare function headingPresent(sections: H2SectionMap, section: string): boolean;
148
197
  export declare function sectionBodyByName(sections: H2SectionMap, section: string): string | null;
149
198
  export declare function sectionBodyByAnyName(sections: H2SectionMap, sectionNames: string[]): string | null;
@@ -403,6 +452,60 @@ export declare function parseLearningSeedEntry(raw: unknown, index: number): {
403
452
  error?: string;
404
453
  };
405
454
  export declare function parseLearningsSection(sectionBody: string): LearningsParseResult;
455
+ /**
456
+ * Round 5 (v6.6.0) — file-path / reference detector for the
457
+ * `investigation_path_first_missing` advisory rule.
458
+ *
459
+ * The detector is intentionally permissive: it only needs to recognize
460
+ * "the author wrote down a path or ref" — the linter does NOT validate
461
+ * the path resolves on disk. Patterns matched (any one is enough):
462
+ * - TS/JS/MD/JSON/YAML path with extension
463
+ * (`src/foo/bar.ts`, `tests/spec.test.ts`, `docs/quality-gates.md`).
464
+ * - Slash-bearing path under a known repo root prefix
465
+ * (`src/...`, `tests/...`, `docs/...`, `scripts/...`,
466
+ * `.cclaw/...`, `.cursor/...`, `node_modules/...`,
467
+ * `examples/...`, `e2e/...`).
468
+ * - GitHub-style ref (`owner/repo#123`, `org/repo@sha`,
469
+ * `path:line`, `path:line-line`).
470
+ * - Explicit `path:` / `paths:` / `ref:` / `refs:` marker.
471
+ * - Stable cclaw IDs (`R1`, `D-12`, `AC-3`, `T-4`, `S-2`, `DD-5`,
472
+ * `ADR-1`, `R-1`, `F-1`, `CR-1`, `I-1`, `QS-1`).
473
+ * - Backticked path-like token containing a slash.
474
+ *
475
+ * Exposed for unit tests (`tests/unit/investigation-trace-evaluator.test.ts`).
476
+ */
477
+ export declare const INVESTIGATION_TRACE_PATH_PATTERNS: readonly RegExp[];
478
+ export interface InvestigationTraceFinding {
479
+ ok: boolean;
480
+ details: string;
481
+ }
482
+ /**
483
+ * Internal core that does NOT depend on `StageLintContext`. Returned
484
+ * shape is consumed by `evaluateInvestigationTrace` (which pushes a
485
+ * finding into the context) and by unit tests that exercise the
486
+ * detector directly.
487
+ *
488
+ * Returns `null` for sections that are missing, empty, or contain only
489
+ * template scaffolding (table headers, separators, placeholder rows
490
+ * with empty cells, lone `- None.` lines). Callers treat `null` as
491
+ * silent — no finding is emitted.
492
+ */
493
+ export declare function checkInvestigationTrace(sectionBody: string | null): InvestigationTraceFinding | null;
494
+ /**
495
+ * Round 5 (v6.6.0) — advisory rule wired into the brainstorm / scope /
496
+ * design / tdd / plan / review linters.
497
+ *
498
+ * Behavior contract:
499
+ * - Section missing or empty / placeholder-only: silent (no finding).
500
+ * - Section has substantive content with a recognizable file path /
501
+ * ref / explicit `path:`-style marker in the first non-empty rows:
502
+ * advisory pass (no finding).
503
+ * - Section has substantive content but no path/ref signal: advisory
504
+ * FAIL finding with ruleId `investigation_path_first_missing`.
505
+ *
506
+ * The rule is `required: false` so it never blocks `stage-complete`.
507
+ */
508
+ export declare function evaluateInvestigationTrace(ctx: StageLintContext, sectionName: string): void;
406
509
  export declare function lineContainsVagueAdjective(text: string): string | null;
407
510
  export interface ParsedFrontmatter {
408
511
  hasFrontmatter: boolean;