Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitleaks.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,4 +8,5 @@ description = "Docs that intentionally contain example or archived sample creden
paths = [
'''(?:^|/)docs/audits/artifacts/''',
'''(?:^|/)docs/bootstrap-templates/security-patterns\.md$''',
'''(?:^|/)scripts/__tests__/golden/bootstrap-generate\.sample-cli\.md$''',
]
14 changes: 7 additions & 7 deletions docs/audits/anvil-audit-2026-08-09.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -217,7 +217,7 @@ Remaining score delta is near-max: enforcement layer (0.8/1). Treat it as option
| `docs/bootstrap-templates/pnpm-commands.md` | anvil-bootstrap-template | governance | ✅ | 39 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/prisma-migrations.md` | anvil-bootstrap-template | governance | ✅ | 43 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/react-hooks-deps.md` | anvil-bootstrap-template | governance | ✅ | 41 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 161 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 162 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/security-patterns.md` | anvil-bootstrap-template | governance | ✅ | 82 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/tailwind-no-inline-styles.md` | anvil-bootstrap-template | governance | ✅ | 38 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/testing-patterns.md` | anvil-bootstrap-template | governance | ✅ | 136 | ✅ | ✅ | ✅ | ✅ |
Expand All@@ -237,7 +237,7 @@ Canonical governance surface:
- `docs/bootstrap-templates/pnpm-commands.md` (39 lines)
- `docs/bootstrap-templates/prisma-migrations.md` (43 lines)
- `docs/bootstrap-templates/react-hooks-deps.md` (41 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (161 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (162 lines)
- `docs/bootstrap-templates/security-patterns.md` (82 lines)
- `docs/bootstrap-templates/tailwind-no-inline-styles.md` (38 lines)
- `docs/bootstrap-templates/testing-patterns.md` (136 lines)
Expand DownExpand Up@@ -341,11 +341,11 @@ PRs analyzed: 43 · Comments reviewed: 37 · Substantive comments: 37 · Candida

| Theme | Frequency | PR Spread | Severity | Rule Signal Match | Comment Alignment |
|-------|-----------|-----------|----------|-------------------|------------------|
| Naming | 12 comments | 6 PRs (high) | medium | 🟡 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟡 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟡 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟡 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟡 signal match | 100% strong |
| Naming | 12 comments | 6 PRs (high) | medium | 🟢 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟢 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟢 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟢 signal match | 100% strong |


## Rule Portfolio Actions
Expand Down
1 change: 1 addition & 0 deletions docs/bootstrap-templates/scope-boundaries.md
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
# Bootstrap Template: Scope Boundaries

*Signal: general · Tier: alwaysApply · Glob: —*
*Last validated: 2026-05-27 · Author: Scout/Anvil · Status: Active*
*Sources: Concentrix "12 Failure Patterns" (Nov 2025), 12-Factor Agents Factor 12, Gartner 2027 cancellation data*

Expand Down
360 changes: 359 additions & 1 deletion scripts/__tests__/golden/bootstrap-generate.sample-cli.md

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions scripts/audit-report-format.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -1587,6 +1587,87 @@ test("Heuristic empty state does not invent weak lanes when all scores are alrea
);
});

test("PR mining table uses pass/partial/fail colors for rule signal match", () => {
const report = buildReport(
makeResult({
prMining: {
status: "available",
repo: "lambda-curry/anvil",
reason: null,
analyzedPrs: 4,
reviewedComments: 12,
substantiveComments: 8,
candidateCount: 3,
artifactPath: null,
findings: [
{
theme: "naming",
label: "Naming",
frequency: 4,
score: 2,
uniquePrs: 2,
severity: "low",
representativeness: "medium",
coverageStatus: "match",
commentAlignmentRate: 1,
commentAlignmentStatus: "strong",
samplePaths: ["src/names.ts"],
},
{
theme: "error-handling",
label: "Error Handling",
frequency: 3,
score: 2,
uniquePrs: 2,
severity: "medium",
representativeness: "medium",
coverageStatus: "missing",
commentAlignmentRate: 0.2,
commentAlignmentStatus: "weak",
samplePaths: ["src/errors.ts"],
},
{
theme: "general",
label: "General",
frequency: 2,
score: 1,
uniquePrs: 1,
severity: "low",
representativeness: "low",
coverageStatus: "unknown",
commentAlignmentRate: 0,
commentAlignmentStatus: "unknown",
samplePaths: [],
},
],
},
}),
);

assert(
report.includes(
"| Naming | 4 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |",
),
"successful signal matches render as green pass",
);
assert(
report.includes(
"| Error Handling | 3 comments | 2 PRs (medium) | medium | 🔴 no signal | 20% weak |",
),
"missing signal matches render as red failure",
);
assert(
report.includes(
"| General | 2 comments | 1 PRs (low) | low | — unknown | — unknown |",
),
"unknown coverage stays unlabeled instead of yellow",
);
assert(
!report.includes("🟡 signal match"),
"does not paint a successful match as degraded yellow",
);
});

test("Diagnostic navigation stage-status line points to process stages when blockers exist", () => {
const report = buildReport(
makeResult({
Expand Down
2 changes: 1 addition & 1 deletion scripts/audit.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5682,7 +5682,7 @@ export function buildReport(
for (const finding of result.prMining.findings.slice(0, 10)) {
const coverage =
finding.coverageStatus === "match"
? "🟡 signal match"
? "🟢 signal match"
: finding.coverageStatus === "missing"
? "🔴 no signal"
: "— unknown";
Expand Down
130 changes: 129 additions & 1 deletion scripts/bootstrap-generate.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,16 @@ function restoreAll() {
}

// Import after mocks are set up
import { main } from "./bootstrap-generate.ts";
import {
DOCUMENTED_TEMPLATE_EXCLUSIONS,
formatTemplateSkip,
loadTemplateCatalog,
main,
matchesSignal,
normalizeLoadingTier,
parseTemplateContent,
} from "./bootstrap-generate.ts";
import type { StackSignals } from "./bootstrap-detect.ts";

const FIXTURES_DIR = resolve(import.meta.dir, "__fixtures__");
const SAMPLE_CLI = join(FIXTURES_DIR, "sample-cli-repo");
Expand DownExpand Up@@ -424,3 +433,122 @@ describe("bootstrap-generate main()", () => {
}
});
});

function emptySignals(): StackSignals {
return {
projectName: "empty",
projectPath: "/tmp/empty",
packageManager: "npm",
runtime: "node",
framework: "none",
frameworkVersion: null,
routerType: "unknown",
ui: [],
styling: [],
orm: null,
validation: [],
testing: null,
typescript: { present: false, strict: false, paths: false, esm: false },
configFiles: [],
dirPatterns: [],
scripts: {},
dependencies: [],
devDependencies: [],
};
}

describe("bootstrap template inventory and vocabulary", () => {
test("loads all 18 templates or only documented exclusions", () => {
const catalog = loadTemplateCatalog();
const loadedIds = catalog.templates.map((template) => template.id).sort();
const skippedFiles = catalog.skipped.map((issue) => issue.file).sort();
const documented = DOCUMENTED_TEMPLATE_EXCLUSIONS.map(
(entry) => entry.file,
).sort();

expect(loadedIds.length + skippedFiles.length).toBe(18);
expect(skippedFiles).toEqual(documented);
expect(loadedIds).toContain("scope-boundaries");
expect(loadedIds).toContain("performance-measure-before-optimize");
});

test("onDemand alias is on-demand, never alwaysApply", () => {
expect(normalizeLoadingTier("onDemand")).toBe("on-demand");
expect(normalizeLoadingTier("on-demand")).toBe("on-demand");
expect(normalizeLoadingTier("glob-matched")).toBe("glob");
expect(normalizeLoadingTier("mystery-tier")).toBeNull();

const parsed = parseTemplateContent(
"performance-measure-before-optimize.md",
[
"# Performance work must start with measurement",
"",
"*Signal: general · Tier: onDemand · Glob: —*",
"",
"## Why (Failure Mode)",
"",
"Measure first.",
"",
"## The Rule",
"",
"Do not optimize from vibes.",
].join("\n"),
);
expect(parsed.ok).toBe(true);
if (parsed.ok) {
expect(parsed.template.tier).toBe("on-demand");
expect(parsed.template.signal).toBe("general");
}
});

test("unknown tier and missing signal produce named diagnostics", () => {
const unknownTier = parseTemplateContent(
"mystery.md",
["# Mystery", "", "*Signal: general · Tier: nightly · Glob: —*"].join(
"\n",
),
);
expect(unknownTier.ok).toBe(false);
if (!unknownTier.ok) {
expect(formatTemplateSkip(unknownTier.issue)).toBe(
"mystery.md: unknown Tier: nightly",
);
}

const missingSignal = parseTemplateContent(
"scope-boundaries.md",
["# Scope", "", "*Last validated: 2026-05-27*"].join("\n"),
);
expect(missingSignal.ok).toBe(false);
if (!missingSignal.ok) {
expect(formatTemplateSkip(missingSignal.issue)).toBe(
"scope-boundaries.md: missing or invalid field: Signal",
);
}

const unknownSignal = parseTemplateContent(
"odd.md",
["# Odd", "", "*Signal: mystery · Tier: alwaysApply · Glob: —*"].join(
"\n",
),
);
expect(unknownSignal.ok).toBe(false);
if (!unknownSignal.ok) {
expect(formatTemplateSkip(unknownSignal.issue)).toBe(
"odd.md: unknown Signal: mystery",
);
}
});

test("general is an explicit match-all signal", () => {
const template = {
id: "security-patterns",
title: "Security",
signal: "general",
failureMode: "x",
rule: "y",
tier: "alwaysApply" as const,
};
expect(matchesSignal(template, emptySignals())).toBe(true);
});
});
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitleaks.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,4 +8,5 @@ description = "Docs that intentionally contain example or archived sample creden
paths = [
'''(?:^|/)docs/audits/artifacts/''',
'''(?:^|/)docs/bootstrap-templates/security-patterns\.md$''',
'''(?:^|/)scripts/__tests__/golden/bootstrap-generate\.sample-cli\.md$''',
]
14 changes: 7 additions & 7 deletions docs/audits/anvil-audit-2026-08-09.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -217,7 +217,7 @@ Remaining score delta is near-max: enforcement layer (0.8/1). Treat it as option
| `docs/bootstrap-templates/pnpm-commands.md` | anvil-bootstrap-template | governance | ✅ | 39 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/prisma-migrations.md` | anvil-bootstrap-template | governance | ✅ | 43 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/react-hooks-deps.md` | anvil-bootstrap-template | governance | ✅ | 41 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 161 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 162 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/security-patterns.md` | anvil-bootstrap-template | governance | ✅ | 82 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/tailwind-no-inline-styles.md` | anvil-bootstrap-template | governance | ✅ | 38 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/testing-patterns.md` | anvil-bootstrap-template | governance | ✅ | 136 | ✅ | ✅ | ✅ | ✅ |
Expand All@@ -237,7 +237,7 @@ Canonical governance surface:
- `docs/bootstrap-templates/pnpm-commands.md` (39 lines)
- `docs/bootstrap-templates/prisma-migrations.md` (43 lines)
- `docs/bootstrap-templates/react-hooks-deps.md` (41 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (161 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (162 lines)
- `docs/bootstrap-templates/security-patterns.md` (82 lines)
- `docs/bootstrap-templates/tailwind-no-inline-styles.md` (38 lines)
- `docs/bootstrap-templates/testing-patterns.md` (136 lines)
Expand DownExpand Up@@ -341,11 +341,11 @@ PRs analyzed: 43 · Comments reviewed: 37 · Substantive comments: 37 · Candida

| Theme | Frequency | PR Spread | Severity | Rule Signal Match | Comment Alignment |
|-------|-----------|-----------|----------|-------------------|------------------|
| Naming | 12 comments | 6 PRs (high) | medium | 🟡 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟡 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟡 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟡 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟡 signal match | 100% strong |
| Naming | 12 comments | 6 PRs (high) | medium | 🟢 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟢 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟢 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟢 signal match | 100% strong |


## Rule Portfolio Actions
Expand Down
1 change: 1 addition & 0 deletions docs/bootstrap-templates/scope-boundaries.md
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
# Bootstrap Template: Scope Boundaries

*Signal: general · Tier: alwaysApply · Glob: —*
*Last validated: 2026-05-27 · Author: Scout/Anvil · Status: Active*
*Sources: Concentrix "12 Failure Patterns" (Nov 2025), 12-Factor Agents Factor 12, Gartner 2027 cancellation data*

Expand Down
360 changes: 359 additions & 1 deletion scripts/__tests__/golden/bootstrap-generate.sample-cli.md

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions scripts/audit-report-format.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -1587,6 +1587,87 @@ test("Heuristic empty state does not invent weak lanes when all scores are alrea
);
});

test("PR mining table uses pass/partial/fail colors for rule signal match", () => {
const report = buildReport(
makeResult({
prMining: {
status: "available",
repo: "lambda-curry/anvil",
reason: null,
analyzedPrs: 4,
reviewedComments: 12,
substantiveComments: 8,
candidateCount: 3,
artifactPath: null,
findings: [
{
theme: "naming",
label: "Naming",
frequency: 4,
score: 2,
uniquePrs: 2,
severity: "low",
representativeness: "medium",
coverageStatus: "match",
commentAlignmentRate: 1,
commentAlignmentStatus: "strong",
samplePaths: ["src/names.ts"],
},
{
theme: "error-handling",
label: "Error Handling",
frequency: 3,
score: 2,
uniquePrs: 2,
severity: "medium",
representativeness: "medium",
coverageStatus: "missing",
commentAlignmentRate: 0.2,
commentAlignmentStatus: "weak",
samplePaths: ["src/errors.ts"],
},
{
theme: "general",
label: "General",
frequency: 2,
score: 1,
uniquePrs: 1,
severity: "low",
representativeness: "low",
coverageStatus: "unknown",
commentAlignmentRate: 0,
commentAlignmentStatus: "unknown",
samplePaths: [],
},
],
},
}),
);

assert(
report.includes(
"| Naming | 4 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |",
),
"successful signal matches render as green pass",
);
assert(
report.includes(
"| Error Handling | 3 comments | 2 PRs (medium) | medium | 🔴 no signal | 20% weak |",
),
"missing signal matches render as red failure",
);
assert(
report.includes(
"| General | 2 comments | 1 PRs (low) | low | — unknown | — unknown |",
),
"unknown coverage stays unlabeled instead of yellow",
);
assert(
!report.includes("🟡 signal match"),
"does not paint a successful match as degraded yellow",
);
});

test("Diagnostic navigation stage-status line points to process stages when blockers exist", () => {
const report = buildReport(
makeResult({
Expand Down
2 changes: 1 addition & 1 deletion scripts/audit.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5682,7 +5682,7 @@ export function buildReport(
for (const finding of result.prMining.findings.slice(0, 10)) {
const coverage =
finding.coverageStatus === "match"
? "🟡 signal match"
? "🟢 signal match"
: finding.coverageStatus === "missing"
? "🔴 no signal"
: "— unknown";
Expand Down
130 changes: 129 additions & 1 deletion scripts/bootstrap-generate.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,16 @@ function restoreAll() {
}

// Import after mocks are set up
import { main } from "./bootstrap-generate.ts";
import {
DOCUMENTED_TEMPLATE_EXCLUSIONS,
formatTemplateSkip,
loadTemplateCatalog,
main,
matchesSignal,
normalizeLoadingTier,
parseTemplateContent,
} from "./bootstrap-generate.ts";
import type { StackSignals } from "./bootstrap-detect.ts";

const FIXTURES_DIR = resolve(import.meta.dir, "__fixtures__");
const SAMPLE_CLI = join(FIXTURES_DIR, "sample-cli-repo");
Expand DownExpand Up@@ -424,3 +433,122 @@ describe("bootstrap-generate main()", () => {
}
});
});

function emptySignals(): StackSignals {
return {
projectName: "empty",
projectPath: "/tmp/empty",
packageManager: "npm",
runtime: "node",
framework: "none",
frameworkVersion: null,
routerType: "unknown",
ui: [],
styling: [],
orm: null,
validation: [],
testing: null,
typescript: { present: false, strict: false, paths: false, esm: false },
configFiles: [],
dirPatterns: [],
scripts: {},
dependencies: [],
devDependencies: [],
};
}

describe("bootstrap template inventory and vocabulary", () => {
test("loads all 18 templates or only documented exclusions", () => {
const catalog = loadTemplateCatalog();
const loadedIds = catalog.templates.map((template) => template.id).sort();
const skippedFiles = catalog.skipped.map((issue) => issue.file).sort();
const documented = DOCUMENTED_TEMPLATE_EXCLUSIONS.map(
(entry) => entry.file,
).sort();

expect(loadedIds.length + skippedFiles.length).toBe(18);
expect(skippedFiles).toEqual(documented);
expect(loadedIds).toContain("scope-boundaries");
expect(loadedIds).toContain("performance-measure-before-optimize");
});

test("onDemand alias is on-demand, never alwaysApply", () => {
expect(normalizeLoadingTier("onDemand")).toBe("on-demand");
expect(normalizeLoadingTier("on-demand")).toBe("on-demand");
expect(normalizeLoadingTier("glob-matched")).toBe("glob");
expect(normalizeLoadingTier("mystery-tier")).toBeNull();

const parsed = parseTemplateContent(
"performance-measure-before-optimize.md",
[
"# Performance work must start with measurement",
"",
"*Signal: general · Tier: onDemand · Glob: —*",
"",
"## Why (Failure Mode)",
"",
"Measure first.",
"",
"## The Rule",
"",
"Do not optimize from vibes.",
].join("\n"),
);
expect(parsed.ok).toBe(true);
if (parsed.ok) {
expect(parsed.template.tier).toBe("on-demand");
expect(parsed.template.signal).toBe("general");
}
});

test("unknown tier and missing signal produce named diagnostics", () => {
const unknownTier = parseTemplateContent(
"mystery.md",
["# Mystery", "", "*Signal: general · Tier: nightly · Glob: —*"].join(
"\n",
),
);
expect(unknownTier.ok).toBe(false);
if (!unknownTier.ok) {
expect(formatTemplateSkip(unknownTier.issue)).toBe(
"mystery.md: unknown Tier: nightly",
);
}

const missingSignal = parseTemplateContent(
"scope-boundaries.md",
["# Scope", "", "*Last validated: 2026-05-27*"].join("\n"),
);
expect(missingSignal.ok).toBe(false);
if (!missingSignal.ok) {
expect(formatTemplateSkip(missingSignal.issue)).toBe(
"scope-boundaries.md: missing or invalid field: Signal",
);
}

const unknownSignal = parseTemplateContent(
"odd.md",
["# Odd", "", "*Signal: mystery · Tier: alwaysApply · Glob: —*"].join(
"\n",
),
);
expect(unknownSignal.ok).toBe(false);
if (!unknownSignal.ok) {
expect(formatTemplateSkip(unknownSignal.issue)).toBe(
"odd.md: unknown Signal: mystery",
);
}
});

test("general is an explicit match-all signal", () => {
const template = {
id: "security-patterns",
title: "Security",
signal: "general",
failureMode: "x",
rule: "y",
tier: "alwaysApply" as const,
};
expect(matchesSignal(template, emptySignals())).toBe(true);
});
});
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitleaks.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,4 +8,5 @@ description = "Docs that intentionally contain example or archived sample creden
paths = [
'''(?:^|/)docs/audits/artifacts/''',
'''(?:^|/)docs/bootstrap-templates/security-patterns\.md$''',
'''(?:^|/)scripts/__tests__/golden/bootstrap-generate\.sample-cli\.md$''',
]
14 changes: 7 additions & 7 deletions docs/audits/anvil-audit-2026-08-09.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -217,7 +217,7 @@ Remaining score delta is near-max: enforcement layer (0.8/1). Treat it as option
| `docs/bootstrap-templates/pnpm-commands.md` | anvil-bootstrap-template | governance | ✅ | 39 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/prisma-migrations.md` | anvil-bootstrap-template | governance | ✅ | 43 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/react-hooks-deps.md` | anvil-bootstrap-template | governance | ✅ | 41 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 161 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 162 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/security-patterns.md` | anvil-bootstrap-template | governance | ✅ | 82 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/tailwind-no-inline-styles.md` | anvil-bootstrap-template | governance | ✅ | 38 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/testing-patterns.md` | anvil-bootstrap-template | governance | ✅ | 136 | ✅ | ✅ | ✅ | ✅ |
Expand All@@ -237,7 +237,7 @@ Canonical governance surface:
- `docs/bootstrap-templates/pnpm-commands.md` (39 lines)
- `docs/bootstrap-templates/prisma-migrations.md` (43 lines)
- `docs/bootstrap-templates/react-hooks-deps.md` (41 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (161 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (162 lines)
- `docs/bootstrap-templates/security-patterns.md` (82 lines)
- `docs/bootstrap-templates/tailwind-no-inline-styles.md` (38 lines)
- `docs/bootstrap-templates/testing-patterns.md` (136 lines)
Expand DownExpand Up@@ -341,11 +341,11 @@ PRs analyzed: 43 · Comments reviewed: 37 · Substantive comments: 37 · Candida

| Theme | Frequency | PR Spread | Severity | Rule Signal Match | Comment Alignment |
|-------|-----------|-----------|----------|-------------------|------------------|
| Naming | 12 comments | 6 PRs (high) | medium | 🟡 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟡 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟡 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟡 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟡 signal match | 100% strong |
| Naming | 12 comments | 6 PRs (high) | medium | 🟢 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟢 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟢 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟢 signal match | 100% strong |


## Rule Portfolio Actions
Expand Down
1 change: 1 addition & 0 deletions docs/bootstrap-templates/scope-boundaries.md
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
# Bootstrap Template: Scope Boundaries

*Signal: general · Tier: alwaysApply · Glob: —*
*Last validated: 2026-05-27 · Author: Scout/Anvil · Status: Active*
*Sources: Concentrix "12 Failure Patterns" (Nov 2025), 12-Factor Agents Factor 12, Gartner 2027 cancellation data*

Expand Down
360 changes: 359 additions & 1 deletion scripts/__tests__/golden/bootstrap-generate.sample-cli.md

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions scripts/audit-report-format.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -1587,6 +1587,87 @@ test("Heuristic empty state does not invent weak lanes when all scores are alrea
);
});

test("PR mining table uses pass/partial/fail colors for rule signal match", () => {
const report = buildReport(
makeResult({
prMining: {
status: "available",
repo: "lambda-curry/anvil",
reason: null,
analyzedPrs: 4,
reviewedComments: 12,
substantiveComments: 8,
candidateCount: 3,
artifactPath: null,
findings: [
{
theme: "naming",
label: "Naming",
frequency: 4,
score: 2,
uniquePrs: 2,
severity: "low",
representativeness: "medium",
coverageStatus: "match",
commentAlignmentRate: 1,
commentAlignmentStatus: "strong",
samplePaths: ["src/names.ts"],
},
{
theme: "error-handling",
label: "Error Handling",
frequency: 3,
score: 2,
uniquePrs: 2,
severity: "medium",
representativeness: "medium",
coverageStatus: "missing",
commentAlignmentRate: 0.2,
commentAlignmentStatus: "weak",
samplePaths: ["src/errors.ts"],
},
{
theme: "general",
label: "General",
frequency: 2,
score: 1,
uniquePrs: 1,
severity: "low",
representativeness: "low",
coverageStatus: "unknown",
commentAlignmentRate: 0,
commentAlignmentStatus: "unknown",
samplePaths: [],
},
],
},
}),
);

assert(
report.includes(
"| Naming | 4 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |",
),
"successful signal matches render as green pass",
);
assert(
report.includes(
"| Error Handling | 3 comments | 2 PRs (medium) | medium | 🔴 no signal | 20% weak |",
),
"missing signal matches render as red failure",
);
assert(
report.includes(
"| General | 2 comments | 1 PRs (low) | low | — unknown | — unknown |",
),
"unknown coverage stays unlabeled instead of yellow",
);
assert(
!report.includes("🟡 signal match"),
"does not paint a successful match as degraded yellow",
);
});

test("Diagnostic navigation stage-status line points to process stages when blockers exist", () => {
const report = buildReport(
makeResult({
Expand Down
2 changes: 1 addition & 1 deletion scripts/audit.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5682,7 +5682,7 @@ export function buildReport(
for (const finding of result.prMining.findings.slice(0, 10)) {
const coverage =
finding.coverageStatus === "match"
? "🟡 signal match"
? "🟢 signal match"
: finding.coverageStatus === "missing"
? "🔴 no signal"
: "— unknown";
Expand Down
130 changes: 129 additions & 1 deletion scripts/bootstrap-generate.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,16 @@ function restoreAll() {
}

// Import after mocks are set up
import { main } from "./bootstrap-generate.ts";
import {
DOCUMENTED_TEMPLATE_EXCLUSIONS,
formatTemplateSkip,
loadTemplateCatalog,
main,
matchesSignal,
normalizeLoadingTier,
parseTemplateContent,
} from "./bootstrap-generate.ts";
import type { StackSignals } from "./bootstrap-detect.ts";

const FIXTURES_DIR = resolve(import.meta.dir, "__fixtures__");
const SAMPLE_CLI = join(FIXTURES_DIR, "sample-cli-repo");
Expand DownExpand Up@@ -424,3 +433,122 @@ describe("bootstrap-generate main()", () => {
}
});
});

function emptySignals(): StackSignals {
return {
projectName: "empty",
projectPath: "/tmp/empty",
packageManager: "npm",
runtime: "node",
framework: "none",
frameworkVersion: null,
routerType: "unknown",
ui: [],
styling: [],
orm: null,
validation: [],
testing: null,
typescript: { present: false, strict: false, paths: false, esm: false },
configFiles: [],
dirPatterns: [],
scripts: {},
dependencies: [],
devDependencies: [],
};
}

describe("bootstrap template inventory and vocabulary", () => {
test("loads all 18 templates or only documented exclusions", () => {
const catalog = loadTemplateCatalog();
const loadedIds = catalog.templates.map((template) => template.id).sort();
const skippedFiles = catalog.skipped.map((issue) => issue.file).sort();
const documented = DOCUMENTED_TEMPLATE_EXCLUSIONS.map(
(entry) => entry.file,
).sort();

expect(loadedIds.length + skippedFiles.length).toBe(18);
expect(skippedFiles).toEqual(documented);
expect(loadedIds).toContain("scope-boundaries");
expect(loadedIds).toContain("performance-measure-before-optimize");
});

test("onDemand alias is on-demand, never alwaysApply", () => {
expect(normalizeLoadingTier("onDemand")).toBe("on-demand");
expect(normalizeLoadingTier("on-demand")).toBe("on-demand");
expect(normalizeLoadingTier("glob-matched")).toBe("glob");
expect(normalizeLoadingTier("mystery-tier")).toBeNull();

const parsed = parseTemplateContent(
"performance-measure-before-optimize.md",
[
"# Performance work must start with measurement",
"",
"*Signal: general · Tier: onDemand · Glob: —*",
"",
"## Why (Failure Mode)",
"",
"Measure first.",
"",
"## The Rule",
"",
"Do not optimize from vibes.",
].join("\n"),
);
expect(parsed.ok).toBe(true);
if (parsed.ok) {
expect(parsed.template.tier).toBe("on-demand");
expect(parsed.template.signal).toBe("general");
}
});

test("unknown tier and missing signal produce named diagnostics", () => {
const unknownTier = parseTemplateContent(
"mystery.md",
["# Mystery", "", "*Signal: general · Tier: nightly · Glob: —*"].join(
"\n",
),
);
expect(unknownTier.ok).toBe(false);
if (!unknownTier.ok) {
expect(formatTemplateSkip(unknownTier.issue)).toBe(
"mystery.md: unknown Tier: nightly",
);
}

const missingSignal = parseTemplateContent(
"scope-boundaries.md",
["# Scope", "", "*Last validated: 2026-05-27*"].join("\n"),
);
expect(missingSignal.ok).toBe(false);
if (!missingSignal.ok) {
expect(formatTemplateSkip(missingSignal.issue)).toBe(
"scope-boundaries.md: missing or invalid field: Signal",
);
}

const unknownSignal = parseTemplateContent(
"odd.md",
["# Odd", "", "*Signal: mystery · Tier: alwaysApply · Glob: —*"].join(
"\n",
),
);
expect(unknownSignal.ok).toBe(false);
if (!unknownSignal.ok) {
expect(formatTemplateSkip(unknownSignal.issue)).toBe(
"odd.md: unknown Signal: mystery",
);
}
});

test("general is an explicit match-all signal", () => {
const template = {
id: "security-patterns",
title: "Security",
signal: "general",
failureMode: "x",
rule: "y",
tier: "alwaysApply" as const,
};
expect(matchesSignal(template, emptySignals())).toBe(true);
});
});
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitleaks.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,4 +8,5 @@ description = "Docs that intentionally contain example or archived sample creden
paths = [
'''(?:^|/)docs/audits/artifacts/''',
'''(?:^|/)docs/bootstrap-templates/security-patterns\.md$''',
'''(?:^|/)scripts/__tests__/golden/bootstrap-generate\.sample-cli\.md$''',
]
14 changes: 7 additions & 7 deletions docs/audits/anvil-audit-2026-08-09.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -217,7 +217,7 @@ Remaining score delta is near-max: enforcement layer (0.8/1). Treat it as option
| `docs/bootstrap-templates/pnpm-commands.md` | anvil-bootstrap-template | governance | ✅ | 39 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/prisma-migrations.md` | anvil-bootstrap-template | governance | ✅ | 43 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/react-hooks-deps.md` | anvil-bootstrap-template | governance | ✅ | 41 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 161 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 162 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/security-patterns.md` | anvil-bootstrap-template | governance | ✅ | 82 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/tailwind-no-inline-styles.md` | anvil-bootstrap-template | governance | ✅ | 38 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/testing-patterns.md` | anvil-bootstrap-template | governance | ✅ | 136 | ✅ | ✅ | ✅ | ✅ |
Expand All@@ -237,7 +237,7 @@ Canonical governance surface:
- `docs/bootstrap-templates/pnpm-commands.md` (39 lines)
- `docs/bootstrap-templates/prisma-migrations.md` (43 lines)
- `docs/bootstrap-templates/react-hooks-deps.md` (41 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (161 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (162 lines)
- `docs/bootstrap-templates/security-patterns.md` (82 lines)
- `docs/bootstrap-templates/tailwind-no-inline-styles.md` (38 lines)
- `docs/bootstrap-templates/testing-patterns.md` (136 lines)
Expand DownExpand Up@@ -341,11 +341,11 @@ PRs analyzed: 43 · Comments reviewed: 37 · Substantive comments: 37 · Candida

| Theme | Frequency | PR Spread | Severity | Rule Signal Match | Comment Alignment |
|-------|-----------|-----------|----------|-------------------|------------------|
| Naming | 12 comments | 6 PRs (high) | medium | 🟡 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟡 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟡 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟡 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟡 signal match | 100% strong |
| Naming | 12 comments | 6 PRs (high) | medium | 🟢 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟢 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟢 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟢 signal match | 100% strong |


## Rule Portfolio Actions
Expand Down
1 change: 1 addition & 0 deletions docs/bootstrap-templates/scope-boundaries.md
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
# Bootstrap Template: Scope Boundaries

*Signal: general · Tier: alwaysApply · Glob: —*
*Last validated: 2026-05-27 · Author: Scout/Anvil · Status: Active*
*Sources: Concentrix "12 Failure Patterns" (Nov 2025), 12-Factor Agents Factor 12, Gartner 2027 cancellation data*

Expand Down
360 changes: 359 additions & 1 deletion scripts/__tests__/golden/bootstrap-generate.sample-cli.md

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions scripts/audit-report-format.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -1587,6 +1587,87 @@ test("Heuristic empty state does not invent weak lanes when all scores are alrea
);
});

test("PR mining table uses pass/partial/fail colors for rule signal match", () => {
const report = buildReport(
makeResult({
prMining: {
status: "available",
repo: "lambda-curry/anvil",
reason: null,
analyzedPrs: 4,
reviewedComments: 12,
substantiveComments: 8,
candidateCount: 3,
artifactPath: null,
findings: [
{
theme: "naming",
label: "Naming",
frequency: 4,
score: 2,
uniquePrs: 2,
severity: "low",
representativeness: "medium",
coverageStatus: "match",
commentAlignmentRate: 1,
commentAlignmentStatus: "strong",
samplePaths: ["src/names.ts"],
},
{
theme: "error-handling",
label: "Error Handling",
frequency: 3,
score: 2,
uniquePrs: 2,
severity: "medium",
representativeness: "medium",
coverageStatus: "missing",
commentAlignmentRate: 0.2,
commentAlignmentStatus: "weak",
samplePaths: ["src/errors.ts"],
},
{
theme: "general",
label: "General",
frequency: 2,
score: 1,
uniquePrs: 1,
severity: "low",
representativeness: "low",
coverageStatus: "unknown",
commentAlignmentRate: 0,
commentAlignmentStatus: "unknown",
samplePaths: [],
},
],
},
}),
);

assert(
report.includes(
"| Naming | 4 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |",
),
"successful signal matches render as green pass",
);
assert(
report.includes(
"| Error Handling | 3 comments | 2 PRs (medium) | medium | 🔴 no signal | 20% weak |",
),
"missing signal matches render as red failure",
);
assert(
report.includes(
"| General | 2 comments | 1 PRs (low) | low | — unknown | — unknown |",
),
"unknown coverage stays unlabeled instead of yellow",
);
assert(
!report.includes("🟡 signal match"),
"does not paint a successful match as degraded yellow",
);
});

test("Diagnostic navigation stage-status line points to process stages when blockers exist", () => {
const report = buildReport(
makeResult({
Expand Down
2 changes: 1 addition & 1 deletion scripts/audit.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5682,7 +5682,7 @@ export function buildReport(
for (const finding of result.prMining.findings.slice(0, 10)) {
const coverage =
finding.coverageStatus === "match"
? "🟡 signal match"
? "🟢 signal match"
: finding.coverageStatus === "missing"
? "🔴 no signal"
: "— unknown";
Expand Down
130 changes: 129 additions & 1 deletion scripts/bootstrap-generate.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,16 @@ function restoreAll() {
}

// Import after mocks are set up
import { main } from "./bootstrap-generate.ts";
import {
DOCUMENTED_TEMPLATE_EXCLUSIONS,
formatTemplateSkip,
loadTemplateCatalog,
main,
matchesSignal,
normalizeLoadingTier,
parseTemplateContent,
} from "./bootstrap-generate.ts";
import type { StackSignals } from "./bootstrap-detect.ts";

const FIXTURES_DIR = resolve(import.meta.dir, "__fixtures__");
const SAMPLE_CLI = join(FIXTURES_DIR, "sample-cli-repo");
Expand DownExpand Up@@ -424,3 +433,122 @@ describe("bootstrap-generate main()", () => {
}
});
});

function emptySignals(): StackSignals {
return {
projectName: "empty",
projectPath: "/tmp/empty",
packageManager: "npm",
runtime: "node",
framework: "none",
frameworkVersion: null,
routerType: "unknown",
ui: [],
styling: [],
orm: null,
validation: [],
testing: null,
typescript: { present: false, strict: false, paths: false, esm: false },
configFiles: [],
dirPatterns: [],
scripts: {},
dependencies: [],
devDependencies: [],
};
}

describe("bootstrap template inventory and vocabulary", () => {
test("loads all 18 templates or only documented exclusions", () => {
const catalog = loadTemplateCatalog();
const loadedIds = catalog.templates.map((template) => template.id).sort();
const skippedFiles = catalog.skipped.map((issue) => issue.file).sort();
const documented = DOCUMENTED_TEMPLATE_EXCLUSIONS.map(
(entry) => entry.file,
).sort();

expect(loadedIds.length + skippedFiles.length).toBe(18);
expect(skippedFiles).toEqual(documented);
expect(loadedIds).toContain("scope-boundaries");
expect(loadedIds).toContain("performance-measure-before-optimize");
});

test("onDemand alias is on-demand, never alwaysApply", () => {
expect(normalizeLoadingTier("onDemand")).toBe("on-demand");
expect(normalizeLoadingTier("on-demand")).toBe("on-demand");
expect(normalizeLoadingTier("glob-matched")).toBe("glob");
expect(normalizeLoadingTier("mystery-tier")).toBeNull();

const parsed = parseTemplateContent(
"performance-measure-before-optimize.md",
[
"# Performance work must start with measurement",
"",
"*Signal: general · Tier: onDemand · Glob: —*",
"",
"## Why (Failure Mode)",
"",
"Measure first.",
"",
"## The Rule",
"",
"Do not optimize from vibes.",
].join("\n"),
);
expect(parsed.ok).toBe(true);
if (parsed.ok) {
expect(parsed.template.tier).toBe("on-demand");
expect(parsed.template.signal).toBe("general");
}
});

test("unknown tier and missing signal produce named diagnostics", () => {
const unknownTier = parseTemplateContent(
"mystery.md",
["# Mystery", "", "*Signal: general · Tier: nightly · Glob: —*"].join(
"\n",
),
);
expect(unknownTier.ok).toBe(false);
if (!unknownTier.ok) {
expect(formatTemplateSkip(unknownTier.issue)).toBe(
"mystery.md: unknown Tier: nightly",
);
}

const missingSignal = parseTemplateContent(
"scope-boundaries.md",
["# Scope", "", "*Last validated: 2026-05-27*"].join("\n"),
);
expect(missingSignal.ok).toBe(false);
if (!missingSignal.ok) {
expect(formatTemplateSkip(missingSignal.issue)).toBe(
"scope-boundaries.md: missing or invalid field: Signal",
);
}

const unknownSignal = parseTemplateContent(
"odd.md",
["# Odd", "", "*Signal: mystery · Tier: alwaysApply · Glob: —*"].join(
"\n",
),
);
expect(unknownSignal.ok).toBe(false);
if (!unknownSignal.ok) {
expect(formatTemplateSkip(unknownSignal.issue)).toBe(
"odd.md: unknown Signal: mystery",
);
}
});

test("general is an explicit match-all signal", () => {
const template = {
id: "security-patterns",
title: "Security",
signal: "general",
failureMode: "x",
rule: "y",
tier: "alwaysApply" as const,
};
expect(matchesSignal(template, emptySignals())).toBe(true);
});
});
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitleaks.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,4 +8,5 @@ description = "Docs that intentionally contain example or archived sample creden
paths = [
'''(?:^|/)docs/audits/artifacts/''',
'''(?:^|/)docs/bootstrap-templates/security-patterns\.md$''',
'''(?:^|/)scripts/__tests__/golden/bootstrap-generate\.sample-cli\.md$''',
]
14 changes: 7 additions & 7 deletions docs/audits/anvil-audit-2026-08-09.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -217,7 +217,7 @@ Remaining score delta is near-max: enforcement layer (0.8/1). Treat it as option
| `docs/bootstrap-templates/pnpm-commands.md` | anvil-bootstrap-template | governance | ✅ | 39 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/prisma-migrations.md` | anvil-bootstrap-template | governance | ✅ | 43 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/react-hooks-deps.md` | anvil-bootstrap-template | governance | ✅ | 41 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 161 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 162 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/security-patterns.md` | anvil-bootstrap-template | governance | ✅ | 82 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/tailwind-no-inline-styles.md` | anvil-bootstrap-template | governance | ✅ | 38 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/testing-patterns.md` | anvil-bootstrap-template | governance | ✅ | 136 | ✅ | ✅ | ✅ | ✅ |
Expand All@@ -237,7 +237,7 @@ Canonical governance surface:
- `docs/bootstrap-templates/pnpm-commands.md` (39 lines)
- `docs/bootstrap-templates/prisma-migrations.md` (43 lines)
- `docs/bootstrap-templates/react-hooks-deps.md` (41 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (161 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (162 lines)
- `docs/bootstrap-templates/security-patterns.md` (82 lines)
- `docs/bootstrap-templates/tailwind-no-inline-styles.md` (38 lines)
- `docs/bootstrap-templates/testing-patterns.md` (136 lines)
Expand DownExpand Up@@ -341,11 +341,11 @@ PRs analyzed: 43 · Comments reviewed: 37 · Substantive comments: 37 · Candida

| Theme | Frequency | PR Spread | Severity | Rule Signal Match | Comment Alignment |
|-------|-----------|-----------|----------|-------------------|------------------|
| Naming | 12 comments | 6 PRs (high) | medium | 🟡 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟡 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟡 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟡 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟡 signal match | 100% strong |
| Naming | 12 comments | 6 PRs (high) | medium | 🟢 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟢 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟢 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟢 signal match | 100% strong |


## Rule Portfolio Actions
Expand Down
1 change: 1 addition & 0 deletions docs/bootstrap-templates/scope-boundaries.md
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
# Bootstrap Template: Scope Boundaries

*Signal: general · Tier: alwaysApply · Glob: —*
*Last validated: 2026-05-27 · Author: Scout/Anvil · Status: Active*
*Sources: Concentrix "12 Failure Patterns" (Nov 2025), 12-Factor Agents Factor 12, Gartner 2027 cancellation data*

Expand Down
360 changes: 359 additions & 1 deletion scripts/__tests__/golden/bootstrap-generate.sample-cli.md

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions scripts/audit-report-format.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -1587,6 +1587,87 @@ test("Heuristic empty state does not invent weak lanes when all scores are alrea
);
});

test("PR mining table uses pass/partial/fail colors for rule signal match", () => {
const report = buildReport(
makeResult({
prMining: {
status: "available",
repo: "lambda-curry/anvil",
reason: null,
analyzedPrs: 4,
reviewedComments: 12,
substantiveComments: 8,
candidateCount: 3,
artifactPath: null,
findings: [
{
theme: "naming",
label: "Naming",
frequency: 4,
score: 2,
uniquePrs: 2,
severity: "low",
representativeness: "medium",
coverageStatus: "match",
commentAlignmentRate: 1,
commentAlignmentStatus: "strong",
samplePaths: ["src/names.ts"],
},
{
theme: "error-handling",
label: "Error Handling",
frequency: 3,
score: 2,
uniquePrs: 2,
severity: "medium",
representativeness: "medium",
coverageStatus: "missing",
commentAlignmentRate: 0.2,
commentAlignmentStatus: "weak",
samplePaths: ["src/errors.ts"],
},
{
theme: "general",
label: "General",
frequency: 2,
score: 1,
uniquePrs: 1,
severity: "low",
representativeness: "low",
coverageStatus: "unknown",
commentAlignmentRate: 0,
commentAlignmentStatus: "unknown",
samplePaths: [],
},
],
},
}),
);

assert(
report.includes(
"| Naming | 4 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |",
),
"successful signal matches render as green pass",
);
assert(
report.includes(
"| Error Handling | 3 comments | 2 PRs (medium) | medium | 🔴 no signal | 20% weak |",
),
"missing signal matches render as red failure",
);
assert(
report.includes(
"| General | 2 comments | 1 PRs (low) | low | — unknown | — unknown |",
),
"unknown coverage stays unlabeled instead of yellow",
);
assert(
!report.includes("🟡 signal match"),
"does not paint a successful match as degraded yellow",
);
});

test("Diagnostic navigation stage-status line points to process stages when blockers exist", () => {
const report = buildReport(
makeResult({
Expand Down
2 changes: 1 addition & 1 deletion scripts/audit.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5682,7 +5682,7 @@ export function buildReport(
for (const finding of result.prMining.findings.slice(0, 10)) {
const coverage =
finding.coverageStatus === "match"
? "🟡 signal match"
? "🟢 signal match"
: finding.coverageStatus === "missing"
? "🔴 no signal"
: "— unknown";
Expand Down
130 changes: 129 additions & 1 deletion scripts/bootstrap-generate.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,16 @@ function restoreAll() {
}

// Import after mocks are set up
import { main } from "./bootstrap-generate.ts";
import {
DOCUMENTED_TEMPLATE_EXCLUSIONS,
formatTemplateSkip,
loadTemplateCatalog,
main,
matchesSignal,
normalizeLoadingTier,
parseTemplateContent,
} from "./bootstrap-generate.ts";
import type { StackSignals } from "./bootstrap-detect.ts";

const FIXTURES_DIR = resolve(import.meta.dir, "__fixtures__");
const SAMPLE_CLI = join(FIXTURES_DIR, "sample-cli-repo");
Expand DownExpand Up@@ -424,3 +433,122 @@ describe("bootstrap-generate main()", () => {
}
});
});

function emptySignals(): StackSignals {
return {
projectName: "empty",
projectPath: "/tmp/empty",
packageManager: "npm",
runtime: "node",
framework: "none",
frameworkVersion: null,
routerType: "unknown",
ui: [],
styling: [],
orm: null,
validation: [],
testing: null,
typescript: { present: false, strict: false, paths: false, esm: false },
configFiles: [],
dirPatterns: [],
scripts: {},
dependencies: [],
devDependencies: [],
};
}

describe("bootstrap template inventory and vocabulary", () => {
test("loads all 18 templates or only documented exclusions", () => {
const catalog = loadTemplateCatalog();
const loadedIds = catalog.templates.map((template) => template.id).sort();
const skippedFiles = catalog.skipped.map((issue) => issue.file).sort();
const documented = DOCUMENTED_TEMPLATE_EXCLUSIONS.map(
(entry) => entry.file,
).sort();

expect(loadedIds.length + skippedFiles.length).toBe(18);
expect(skippedFiles).toEqual(documented);
expect(loadedIds).toContain("scope-boundaries");
expect(loadedIds).toContain("performance-measure-before-optimize");
});

test("onDemand alias is on-demand, never alwaysApply", () => {
expect(normalizeLoadingTier("onDemand")).toBe("on-demand");
expect(normalizeLoadingTier("on-demand")).toBe("on-demand");
expect(normalizeLoadingTier("glob-matched")).toBe("glob");
expect(normalizeLoadingTier("mystery-tier")).toBeNull();

const parsed = parseTemplateContent(
"performance-measure-before-optimize.md",
[
"# Performance work must start with measurement",
"",
"*Signal: general · Tier: onDemand · Glob: —*",
"",
"## Why (Failure Mode)",
"",
"Measure first.",
"",
"## The Rule",
"",
"Do not optimize from vibes.",
].join("\n"),
);
expect(parsed.ok).toBe(true);
if (parsed.ok) {
expect(parsed.template.tier).toBe("on-demand");
expect(parsed.template.signal).toBe("general");
}
});

test("unknown tier and missing signal produce named diagnostics", () => {
const unknownTier = parseTemplateContent(
"mystery.md",
["# Mystery", "", "*Signal: general · Tier: nightly · Glob: —*"].join(
"\n",
),
);
expect(unknownTier.ok).toBe(false);
if (!unknownTier.ok) {
expect(formatTemplateSkip(unknownTier.issue)).toBe(
"mystery.md: unknown Tier: nightly",
);
}

const missingSignal = parseTemplateContent(
"scope-boundaries.md",
["# Scope", "", "*Last validated: 2026-05-27*"].join("\n"),
);
expect(missingSignal.ok).toBe(false);
if (!missingSignal.ok) {
expect(formatTemplateSkip(missingSignal.issue)).toBe(
"scope-boundaries.md: missing or invalid field: Signal",
);
}

const unknownSignal = parseTemplateContent(
"odd.md",
["# Odd", "", "*Signal: mystery · Tier: alwaysApply · Glob: —*"].join(
"\n",
),
);
expect(unknownSignal.ok).toBe(false);
if (!unknownSignal.ok) {
expect(formatTemplateSkip(unknownSignal.issue)).toBe(
"odd.md: unknown Signal: mystery",
);
}
});

test("general is an explicit match-all signal", () => {
const template = {
id: "security-patterns",
title: "Security",
signal: "general",
failureMode: "x",
rule: "y",
tier: "alwaysApply" as const,
};
expect(matchesSignal(template, emptySignals())).toBe(true);
});
});
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitleaks.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,4 +8,5 @@ description = "Docs that intentionally contain example or archived sample creden
paths = [
'''(?:^|/)docs/audits/artifacts/''',
'''(?:^|/)docs/bootstrap-templates/security-patterns\.md$''',
'''(?:^|/)scripts/__tests__/golden/bootstrap-generate\.sample-cli\.md$''',
]
14 changes: 7 additions & 7 deletions docs/audits/anvil-audit-2026-08-09.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -217,7 +217,7 @@ Remaining score delta is near-max: enforcement layer (0.8/1). Treat it as option
| `docs/bootstrap-templates/pnpm-commands.md` | anvil-bootstrap-template | governance | ✅ | 39 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/prisma-migrations.md` | anvil-bootstrap-template | governance | ✅ | 43 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/react-hooks-deps.md` | anvil-bootstrap-template | governance | ✅ | 41 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 161 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 162 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/security-patterns.md` | anvil-bootstrap-template | governance | ✅ | 82 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/tailwind-no-inline-styles.md` | anvil-bootstrap-template | governance | ✅ | 38 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/testing-patterns.md` | anvil-bootstrap-template | governance | ✅ | 136 | ✅ | ✅ | ✅ | ✅ |
Expand All@@ -237,7 +237,7 @@ Canonical governance surface:
- `docs/bootstrap-templates/pnpm-commands.md` (39 lines)
- `docs/bootstrap-templates/prisma-migrations.md` (43 lines)
- `docs/bootstrap-templates/react-hooks-deps.md` (41 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (161 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (162 lines)
- `docs/bootstrap-templates/security-patterns.md` (82 lines)
- `docs/bootstrap-templates/tailwind-no-inline-styles.md` (38 lines)
- `docs/bootstrap-templates/testing-patterns.md` (136 lines)
Expand DownExpand Up@@ -341,11 +341,11 @@ PRs analyzed: 43 · Comments reviewed: 37 · Substantive comments: 37 · Candida

| Theme | Frequency | PR Spread | Severity | Rule Signal Match | Comment Alignment |
|-------|-----------|-----------|----------|-------------------|------------------|
| Naming | 12 comments | 6 PRs (high) | medium | 🟡 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟡 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟡 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟡 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟡 signal match | 100% strong |
| Naming | 12 comments | 6 PRs (high) | medium | 🟢 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟢 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟢 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟢 signal match | 100% strong |


## Rule Portfolio Actions
Expand Down
1 change: 1 addition & 0 deletions docs/bootstrap-templates/scope-boundaries.md
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
# Bootstrap Template: Scope Boundaries

*Signal: general · Tier: alwaysApply · Glob: —*
*Last validated: 2026-05-27 · Author: Scout/Anvil · Status: Active*
*Sources: Concentrix "12 Failure Patterns" (Nov 2025), 12-Factor Agents Factor 12, Gartner 2027 cancellation data*

Expand Down
360 changes: 359 additions & 1 deletion scripts/__tests__/golden/bootstrap-generate.sample-cli.md

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions scripts/audit-report-format.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -1587,6 +1587,87 @@ test("Heuristic empty state does not invent weak lanes when all scores are alrea
);
});

test("PR mining table uses pass/partial/fail colors for rule signal match", () => {
const report = buildReport(
makeResult({
prMining: {
status: "available",
repo: "lambda-curry/anvil",
reason: null,
analyzedPrs: 4,
reviewedComments: 12,
substantiveComments: 8,
candidateCount: 3,
artifactPath: null,
findings: [
{
theme: "naming",
label: "Naming",
frequency: 4,
score: 2,
uniquePrs: 2,
severity: "low",
representativeness: "medium",
coverageStatus: "match",
commentAlignmentRate: 1,
commentAlignmentStatus: "strong",
samplePaths: ["src/names.ts"],
},
{
theme: "error-handling",
label: "Error Handling",
frequency: 3,
score: 2,
uniquePrs: 2,
severity: "medium",
representativeness: "medium",
coverageStatus: "missing",
commentAlignmentRate: 0.2,
commentAlignmentStatus: "weak",
samplePaths: ["src/errors.ts"],
},
{
theme: "general",
label: "General",
frequency: 2,
score: 1,
uniquePrs: 1,
severity: "low",
representativeness: "low",
coverageStatus: "unknown",
commentAlignmentRate: 0,
commentAlignmentStatus: "unknown",
samplePaths: [],
},
],
},
}),
);

assert(
report.includes(
"| Naming | 4 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |",
),
"successful signal matches render as green pass",
);
assert(
report.includes(
"| Error Handling | 3 comments | 2 PRs (medium) | medium | 🔴 no signal | 20% weak |",
),
"missing signal matches render as red failure",
);
assert(
report.includes(
"| General | 2 comments | 1 PRs (low) | low | — unknown | — unknown |",
),
"unknown coverage stays unlabeled instead of yellow",
);
assert(
!report.includes("🟡 signal match"),
"does not paint a successful match as degraded yellow",
);
});

test("Diagnostic navigation stage-status line points to process stages when blockers exist", () => {
const report = buildReport(
makeResult({
Expand Down
2 changes: 1 addition & 1 deletion scripts/audit.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5682,7 +5682,7 @@ export function buildReport(
for (const finding of result.prMining.findings.slice(0, 10)) {
const coverage =
finding.coverageStatus === "match"
? "🟡 signal match"
? "🟢 signal match"
: finding.coverageStatus === "missing"
? "🔴 no signal"
: "— unknown";
Expand Down
130 changes: 129 additions & 1 deletion scripts/bootstrap-generate.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,16 @@ function restoreAll() {
}

// Import after mocks are set up
import { main } from "./bootstrap-generate.ts";
import {
DOCUMENTED_TEMPLATE_EXCLUSIONS,
formatTemplateSkip,
loadTemplateCatalog,
main,
matchesSignal,
normalizeLoadingTier,
parseTemplateContent,
} from "./bootstrap-generate.ts";
import type { StackSignals } from "./bootstrap-detect.ts";

const FIXTURES_DIR = resolve(import.meta.dir, "__fixtures__");
const SAMPLE_CLI = join(FIXTURES_DIR, "sample-cli-repo");
Expand DownExpand Up@@ -424,3 +433,122 @@ describe("bootstrap-generate main()", () => {
}
});
});

function emptySignals(): StackSignals {
return {
projectName: "empty",
projectPath: "/tmp/empty",
packageManager: "npm",
runtime: "node",
framework: "none",
frameworkVersion: null,
routerType: "unknown",
ui: [],
styling: [],
orm: null,
validation: [],
testing: null,
typescript: { present: false, strict: false, paths: false, esm: false },
configFiles: [],
dirPatterns: [],
scripts: {},
dependencies: [],
devDependencies: [],
};
}

describe("bootstrap template inventory and vocabulary", () => {
test("loads all 18 templates or only documented exclusions", () => {
const catalog = loadTemplateCatalog();
const loadedIds = catalog.templates.map((template) => template.id).sort();
const skippedFiles = catalog.skipped.map((issue) => issue.file).sort();
const documented = DOCUMENTED_TEMPLATE_EXCLUSIONS.map(
(entry) => entry.file,
).sort();

expect(loadedIds.length + skippedFiles.length).toBe(18);
expect(skippedFiles).toEqual(documented);
expect(loadedIds).toContain("scope-boundaries");
expect(loadedIds).toContain("performance-measure-before-optimize");
});

test("onDemand alias is on-demand, never alwaysApply", () => {
expect(normalizeLoadingTier("onDemand")).toBe("on-demand");
expect(normalizeLoadingTier("on-demand")).toBe("on-demand");
expect(normalizeLoadingTier("glob-matched")).toBe("glob");
expect(normalizeLoadingTier("mystery-tier")).toBeNull();

const parsed = parseTemplateContent(
"performance-measure-before-optimize.md",
[
"# Performance work must start with measurement",
"",
"*Signal: general · Tier: onDemand · Glob: —*",
"",
"## Why (Failure Mode)",
"",
"Measure first.",
"",
"## The Rule",
"",
"Do not optimize from vibes.",
].join("\n"),
);
expect(parsed.ok).toBe(true);
if (parsed.ok) {
expect(parsed.template.tier).toBe("on-demand");
expect(parsed.template.signal).toBe("general");
}
});

test("unknown tier and missing signal produce named diagnostics", () => {
const unknownTier = parseTemplateContent(
"mystery.md",
["# Mystery", "", "*Signal: general · Tier: nightly · Glob: —*"].join(
"\n",
),
);
expect(unknownTier.ok).toBe(false);
if (!unknownTier.ok) {
expect(formatTemplateSkip(unknownTier.issue)).toBe(
"mystery.md: unknown Tier: nightly",
);
}

const missingSignal = parseTemplateContent(
"scope-boundaries.md",
["# Scope", "", "*Last validated: 2026-05-27*"].join("\n"),
);
expect(missingSignal.ok).toBe(false);
if (!missingSignal.ok) {
expect(formatTemplateSkip(missingSignal.issue)).toBe(
"scope-boundaries.md: missing or invalid field: Signal",
);
}

const unknownSignal = parseTemplateContent(
"odd.md",
["# Odd", "", "*Signal: mystery · Tier: alwaysApply · Glob: —*"].join(
"\n",
),
);
expect(unknownSignal.ok).toBe(false);
if (!unknownSignal.ok) {
expect(formatTemplateSkip(unknownSignal.issue)).toBe(
"odd.md: unknown Signal: mystery",
);
}
});

test("general is an explicit match-all signal", () => {
const template = {
id: "security-patterns",
title: "Security",
signal: "general",
failureMode: "x",
rule: "y",
tier: "alwaysApply" as const,
};
expect(matchesSignal(template, emptySignals())).toBe(true);
});
});
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitleaks.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,4 +8,5 @@ description = "Docs that intentionally contain example or archived sample creden
paths = [
'''(?:^|/)docs/audits/artifacts/''',
'''(?:^|/)docs/bootstrap-templates/security-patterns\.md$''',
'''(?:^|/)scripts/__tests__/golden/bootstrap-generate\.sample-cli\.md$''',
]
14 changes: 7 additions & 7 deletions docs/audits/anvil-audit-2026-08-09.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -217,7 +217,7 @@ Remaining score delta is near-max: enforcement layer (0.8/1). Treat it as option
| `docs/bootstrap-templates/pnpm-commands.md` | anvil-bootstrap-template | governance | ✅ | 39 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/prisma-migrations.md` | anvil-bootstrap-template | governance | ✅ | 43 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/react-hooks-deps.md` | anvil-bootstrap-template | governance | ✅ | 41 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 161 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 162 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/security-patterns.md` | anvil-bootstrap-template | governance | ✅ | 82 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/tailwind-no-inline-styles.md` | anvil-bootstrap-template | governance | ✅ | 38 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/testing-patterns.md` | anvil-bootstrap-template | governance | ✅ | 136 | ✅ | ✅ | ✅ | ✅ |
Expand All@@ -237,7 +237,7 @@ Canonical governance surface:
- `docs/bootstrap-templates/pnpm-commands.md` (39 lines)
- `docs/bootstrap-templates/prisma-migrations.md` (43 lines)
- `docs/bootstrap-templates/react-hooks-deps.md` (41 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (161 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (162 lines)
- `docs/bootstrap-templates/security-patterns.md` (82 lines)
- `docs/bootstrap-templates/tailwind-no-inline-styles.md` (38 lines)
- `docs/bootstrap-templates/testing-patterns.md` (136 lines)
Expand DownExpand Up@@ -341,11 +341,11 @@ PRs analyzed: 43 · Comments reviewed: 37 · Substantive comments: 37 · Candida

| Theme | Frequency | PR Spread | Severity | Rule Signal Match | Comment Alignment |
|-------|-----------|-----------|----------|-------------------|------------------|
| Naming | 12 comments | 6 PRs (high) | medium | 🟡 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟡 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟡 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟡 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟡 signal match | 100% strong |
| Naming | 12 comments | 6 PRs (high) | medium | 🟢 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟢 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟢 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟢 signal match | 100% strong |


## Rule Portfolio Actions
Expand Down
1 change: 1 addition & 0 deletions docs/bootstrap-templates/scope-boundaries.md
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
# Bootstrap Template: Scope Boundaries

*Signal: general · Tier: alwaysApply · Glob: —*
*Last validated: 2026-05-27 · Author: Scout/Anvil · Status: Active*
*Sources: Concentrix "12 Failure Patterns" (Nov 2025), 12-Factor Agents Factor 12, Gartner 2027 cancellation data*

Expand Down
360 changes: 359 additions & 1 deletion scripts/__tests__/golden/bootstrap-generate.sample-cli.md

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions scripts/audit-report-format.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -1587,6 +1587,87 @@ test("Heuristic empty state does not invent weak lanes when all scores are alrea
);
});

test("PR mining table uses pass/partial/fail colors for rule signal match", () => {
const report = buildReport(
makeResult({
prMining: {
status: "available",
repo: "lambda-curry/anvil",
reason: null,
analyzedPrs: 4,
reviewedComments: 12,
substantiveComments: 8,
candidateCount: 3,
artifactPath: null,
findings: [
{
theme: "naming",
label: "Naming",
frequency: 4,
score: 2,
uniquePrs: 2,
severity: "low",
representativeness: "medium",
coverageStatus: "match",
commentAlignmentRate: 1,
commentAlignmentStatus: "strong",
samplePaths: ["src/names.ts"],
},
{
theme: "error-handling",
label: "Error Handling",
frequency: 3,
score: 2,
uniquePrs: 2,
severity: "medium",
representativeness: "medium",
coverageStatus: "missing",
commentAlignmentRate: 0.2,
commentAlignmentStatus: "weak",
samplePaths: ["src/errors.ts"],
},
{
theme: "general",
label: "General",
frequency: 2,
score: 1,
uniquePrs: 1,
severity: "low",
representativeness: "low",
coverageStatus: "unknown",
commentAlignmentRate: 0,
commentAlignmentStatus: "unknown",
samplePaths: [],
},
],
},
}),
);

assert(
report.includes(
"| Naming | 4 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |",
),
"successful signal matches render as green pass",
);
assert(
report.includes(
"| Error Handling | 3 comments | 2 PRs (medium) | medium | 🔴 no signal | 20% weak |",
),
"missing signal matches render as red failure",
);
assert(
report.includes(
"| General | 2 comments | 1 PRs (low) | low | — unknown | — unknown |",
),
"unknown coverage stays unlabeled instead of yellow",
);
assert(
!report.includes("🟡 signal match"),
"does not paint a successful match as degraded yellow",
);
});

test("Diagnostic navigation stage-status line points to process stages when blockers exist", () => {
const report = buildReport(
makeResult({
Expand Down
2 changes: 1 addition & 1 deletion scripts/audit.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5682,7 +5682,7 @@ export function buildReport(
for (const finding of result.prMining.findings.slice(0, 10)) {
const coverage =
finding.coverageStatus === "match"
? "🟡 signal match"
? "🟢 signal match"
: finding.coverageStatus === "missing"
? "🔴 no signal"
: "— unknown";
Expand Down
130 changes: 129 additions & 1 deletion scripts/bootstrap-generate.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,16 @@ function restoreAll() {
}

// Import after mocks are set up
import { main } from "./bootstrap-generate.ts";
import {
DOCUMENTED_TEMPLATE_EXCLUSIONS,
formatTemplateSkip,
loadTemplateCatalog,
main,
matchesSignal,
normalizeLoadingTier,
parseTemplateContent,
} from "./bootstrap-generate.ts";
import type { StackSignals } from "./bootstrap-detect.ts";

const FIXTURES_DIR = resolve(import.meta.dir, "__fixtures__");
const SAMPLE_CLI = join(FIXTURES_DIR, "sample-cli-repo");
Expand DownExpand Up@@ -424,3 +433,122 @@ describe("bootstrap-generate main()", () => {
}
});
});

function emptySignals(): StackSignals {
return {
projectName: "empty",
projectPath: "/tmp/empty",
packageManager: "npm",
runtime: "node",
framework: "none",
frameworkVersion: null,
routerType: "unknown",
ui: [],
styling: [],
orm: null,
validation: [],
testing: null,
typescript: { present: false, strict: false, paths: false, esm: false },
configFiles: [],
dirPatterns: [],
scripts: {},
dependencies: [],
devDependencies: [],
};
}

describe("bootstrap template inventory and vocabulary", () => {
test("loads all 18 templates or only documented exclusions", () => {
const catalog = loadTemplateCatalog();
const loadedIds = catalog.templates.map((template) => template.id).sort();
const skippedFiles = catalog.skipped.map((issue) => issue.file).sort();
const documented = DOCUMENTED_TEMPLATE_EXCLUSIONS.map(
(entry) => entry.file,
).sort();

expect(loadedIds.length + skippedFiles.length).toBe(18);
expect(skippedFiles).toEqual(documented);
expect(loadedIds).toContain("scope-boundaries");
expect(loadedIds).toContain("performance-measure-before-optimize");
});

test("onDemand alias is on-demand, never alwaysApply", () => {
expect(normalizeLoadingTier("onDemand")).toBe("on-demand");
expect(normalizeLoadingTier("on-demand")).toBe("on-demand");
expect(normalizeLoadingTier("glob-matched")).toBe("glob");
expect(normalizeLoadingTier("mystery-tier")).toBeNull();

const parsed = parseTemplateContent(
"performance-measure-before-optimize.md",
[
"# Performance work must start with measurement",
"",
"*Signal: general · Tier: onDemand · Glob: —*",
"",
"## Why (Failure Mode)",
"",
"Measure first.",
"",
"## The Rule",
"",
"Do not optimize from vibes.",
].join("\n"),
);
expect(parsed.ok).toBe(true);
if (parsed.ok) {
expect(parsed.template.tier).toBe("on-demand");
expect(parsed.template.signal).toBe("general");
}
});

test("unknown tier and missing signal produce named diagnostics", () => {
const unknownTier = parseTemplateContent(
"mystery.md",
["# Mystery", "", "*Signal: general · Tier: nightly · Glob: —*"].join(
"\n",
),
);
expect(unknownTier.ok).toBe(false);
if (!unknownTier.ok) {
expect(formatTemplateSkip(unknownTier.issue)).toBe(
"mystery.md: unknown Tier: nightly",
);
}

const missingSignal = parseTemplateContent(
"scope-boundaries.md",
["# Scope", "", "*Last validated: 2026-05-27*"].join("\n"),
);
expect(missingSignal.ok).toBe(false);
if (!missingSignal.ok) {
expect(formatTemplateSkip(missingSignal.issue)).toBe(
"scope-boundaries.md: missing or invalid field: Signal",
);
}

const unknownSignal = parseTemplateContent(
"odd.md",
["# Odd", "", "*Signal: mystery · Tier: alwaysApply · Glob: —*"].join(
"\n",
),
);
expect(unknownSignal.ok).toBe(false);
if (!unknownSignal.ok) {
expect(formatTemplateSkip(unknownSignal.issue)).toBe(
"odd.md: unknown Signal: mystery",
);
}
});

test("general is an explicit match-all signal", () => {
const template = {
id: "security-patterns",
title: "Security",
signal: "general",
failureMode: "x",
rule: "y",
tier: "alwaysApply" as const,
};
expect(matchesSignal(template, emptySignals())).toBe(true);
});
});
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitleaks.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,4 +8,5 @@ description = "Docs that intentionally contain example or archived sample creden
paths = [
'''(?:^|/)docs/audits/artifacts/''',
'''(?:^|/)docs/bootstrap-templates/security-patterns\.md$''',
'''(?:^|/)scripts/__tests__/golden/bootstrap-generate\.sample-cli\.md$''',
]
14 changes: 7 additions & 7 deletions docs/audits/anvil-audit-2026-08-09.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -217,7 +217,7 @@ Remaining score delta is near-max: enforcement layer (0.8/1). Treat it as option
| `docs/bootstrap-templates/pnpm-commands.md` | anvil-bootstrap-template | governance | ✅ | 39 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/prisma-migrations.md` | anvil-bootstrap-template | governance | ✅ | 43 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/react-hooks-deps.md` | anvil-bootstrap-template | governance | ✅ | 41 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 161 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/scope-boundaries.md` | anvil-bootstrap-template | governance | ✅ | 162 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/security-patterns.md` | anvil-bootstrap-template | governance | ✅ | 82 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/tailwind-no-inline-styles.md` | anvil-bootstrap-template | governance | ✅ | 38 | ✅ | ✅ | ✅ | ✅ |
| `docs/bootstrap-templates/testing-patterns.md` | anvil-bootstrap-template | governance | ✅ | 136 | ✅ | ✅ | ✅ | ✅ |
Expand All@@ -237,7 +237,7 @@ Canonical governance surface:
- `docs/bootstrap-templates/pnpm-commands.md` (39 lines)
- `docs/bootstrap-templates/prisma-migrations.md` (43 lines)
- `docs/bootstrap-templates/react-hooks-deps.md` (41 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (161 lines)
- `docs/bootstrap-templates/scope-boundaries.md` (162 lines)
- `docs/bootstrap-templates/security-patterns.md` (82 lines)
- `docs/bootstrap-templates/tailwind-no-inline-styles.md` (38 lines)
- `docs/bootstrap-templates/testing-patterns.md` (136 lines)
Expand DownExpand Up@@ -341,11 +341,11 @@ PRs analyzed: 43 · Comments reviewed: 37 · Substantive comments: 37 · Candida

| Theme | Frequency | PR Spread | Severity | Rule Signal Match | Comment Alignment |
|-------|-----------|-----------|----------|-------------------|------------------|
| Naming | 12 comments | 6 PRs (high) | medium | 🟡 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟡 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟡 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟡 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟡 signal match | 100% strong |
| Naming | 12 comments | 6 PRs (high) | medium | 🟢 signal match | 100% strong |
| Testing | 7 comments | 5 PRs (high) | medium | 🟢 signal match | 100% strong |
| Error Handling | 3 comments | 3 PRs (medium) | medium | 🟢 signal match | 100% strong |
| Documentation | 5 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |
| Types | 3 comments | 1 PRs (low) | medium | 🟢 signal match | 100% strong |


## Rule Portfolio Actions
Expand Down
1 change: 1 addition & 0 deletions docs/bootstrap-templates/scope-boundaries.md
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
# Bootstrap Template: Scope Boundaries

*Signal: general · Tier: alwaysApply · Glob: —*
*Last validated: 2026-05-27 · Author: Scout/Anvil · Status: Active*
*Sources: Concentrix "12 Failure Patterns" (Nov 2025), 12-Factor Agents Factor 12, Gartner 2027 cancellation data*

Expand Down
360 changes: 359 additions & 1 deletion scripts/__tests__/golden/bootstrap-generate.sample-cli.md

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions scripts/audit-report-format.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -1587,6 +1587,87 @@ test("Heuristic empty state does not invent weak lanes when all scores are alrea
);
});

test("PR mining table uses pass/partial/fail colors for rule signal match", () => {
const report = buildReport(
makeResult({
prMining: {
status: "available",
repo: "lambda-curry/anvil",
reason: null,
analyzedPrs: 4,
reviewedComments: 12,
substantiveComments: 8,
candidateCount: 3,
artifactPath: null,
findings: [
{
theme: "naming",
label: "Naming",
frequency: 4,
score: 2,
uniquePrs: 2,
severity: "low",
representativeness: "medium",
coverageStatus: "match",
commentAlignmentRate: 1,
commentAlignmentStatus: "strong",
samplePaths: ["src/names.ts"],
},
{
theme: "error-handling",
label: "Error Handling",
frequency: 3,
score: 2,
uniquePrs: 2,
severity: "medium",
representativeness: "medium",
coverageStatus: "missing",
commentAlignmentRate: 0.2,
commentAlignmentStatus: "weak",
samplePaths: ["src/errors.ts"],
},
{
theme: "general",
label: "General",
frequency: 2,
score: 1,
uniquePrs: 1,
severity: "low",
representativeness: "low",
coverageStatus: "unknown",
commentAlignmentRate: 0,
commentAlignmentStatus: "unknown",
samplePaths: [],
},
],
},
}),
);

assert(
report.includes(
"| Naming | 4 comments | 2 PRs (medium) | low | 🟢 signal match | 100% strong |",
),
"successful signal matches render as green pass",
);
assert(
report.includes(
"| Error Handling | 3 comments | 2 PRs (medium) | medium | 🔴 no signal | 20% weak |",
),
"missing signal matches render as red failure",
);
assert(
report.includes(
"| General | 2 comments | 1 PRs (low) | low | — unknown | — unknown |",
),
"unknown coverage stays unlabeled instead of yellow",
);
assert(
!report.includes("🟡 signal match"),
"does not paint a successful match as degraded yellow",
);
});

test("Diagnostic navigation stage-status line points to process stages when blockers exist", () => {
const report = buildReport(
makeResult({
Expand Down
2 changes: 1 addition & 1 deletion scripts/audit.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5682,7 +5682,7 @@ export function buildReport(
for (const finding of result.prMining.findings.slice(0, 10)) {
const coverage =
finding.coverageStatus === "match"
? "🟡 signal match"
? "🟢 signal match"
: finding.coverageStatus === "missing"
? "🔴 no signal"
: "— unknown";
Expand Down
130 changes: 129 additions & 1 deletion scripts/bootstrap-generate.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,16 @@ function restoreAll() {
}

// Import after mocks are set up
import { main } from "./bootstrap-generate.ts";
import {
DOCUMENTED_TEMPLATE_EXCLUSIONS,
formatTemplateSkip,
loadTemplateCatalog,
main,
matchesSignal,
normalizeLoadingTier,
parseTemplateContent,
} from "./bootstrap-generate.ts";
import type { StackSignals } from "./bootstrap-detect.ts";

const FIXTURES_DIR = resolve(import.meta.dir, "__fixtures__");
const SAMPLE_CLI = join(FIXTURES_DIR, "sample-cli-repo");
Expand DownExpand Up@@ -424,3 +433,122 @@ describe("bootstrap-generate main()", () => {
}
});
});

function emptySignals(): StackSignals {
return {
projectName: "empty",
projectPath: "/tmp/empty",
packageManager: "npm",
runtime: "node",
framework: "none",
frameworkVersion: null,
routerType: "unknown",
ui: [],
styling: [],
orm: null,
validation: [],
testing: null,
typescript: { present: false, strict: false, paths: false, esm: false },
configFiles: [],
dirPatterns: [],
scripts: {},
dependencies: [],
devDependencies: [],
};
}

describe("bootstrap template inventory and vocabulary", () => {
test("loads all 18 templates or only documented exclusions", () => {
const catalog = loadTemplateCatalog();
const loadedIds = catalog.templates.map((template) => template.id).sort();
const skippedFiles = catalog.skipped.map((issue) => issue.file).sort();
const documented = DOCUMENTED_TEMPLATE_EXCLUSIONS.map(
(entry) => entry.file,
).sort();

expect(loadedIds.length + skippedFiles.length).toBe(18);
expect(skippedFiles).toEqual(documented);
expect(loadedIds).toContain("scope-boundaries");
expect(loadedIds).toContain("performance-measure-before-optimize");
});

test("onDemand alias is on-demand, never alwaysApply", () => {
expect(normalizeLoadingTier("onDemand")).toBe("on-demand");
expect(normalizeLoadingTier("on-demand")).toBe("on-demand");
expect(normalizeLoadingTier("glob-matched")).toBe("glob");
expect(normalizeLoadingTier("mystery-tier")).toBeNull();

const parsed = parseTemplateContent(
"performance-measure-before-optimize.md",
[
"# Performance work must start with measurement",
"",
"*Signal: general · Tier: onDemand · Glob: —*",
"",
"## Why (Failure Mode)",
"",
"Measure first.",
"",
"## The Rule",
"",
"Do not optimize from vibes.",
].join("\n"),
);
expect(parsed.ok).toBe(true);
if (parsed.ok) {
expect(parsed.template.tier).toBe("on-demand");
expect(parsed.template.signal).toBe("general");
}
});

test("unknown tier and missing signal produce named diagnostics", () => {
const unknownTier = parseTemplateContent(
"mystery.md",
["# Mystery", "", "*Signal: general · Tier: nightly · Glob: —*"].join(
"\n",
),
);
expect(unknownTier.ok).toBe(false);
if (!unknownTier.ok) {
expect(formatTemplateSkip(unknownTier.issue)).toBe(
"mystery.md: unknown Tier: nightly",
);
}

const missingSignal = parseTemplateContent(
"scope-boundaries.md",
["# Scope", "", "*Last validated: 2026-05-27*"].join("\n"),
);
expect(missingSignal.ok).toBe(false);
if (!missingSignal.ok) {
expect(formatTemplateSkip(missingSignal.issue)).toBe(
"scope-boundaries.md: missing or invalid field: Signal",
);
}

const unknownSignal = parseTemplateContent(
"odd.md",
["# Odd", "", "*Signal: mystery · Tier: alwaysApply · Glob: —*"].join(
"\n",
),
);
expect(unknownSignal.ok).toBe(false);
if (!unknownSignal.ok) {
expect(formatTemplateSkip(unknownSignal.issue)).toBe(
"odd.md: unknown Signal: mystery",
);
}
});

test("general is an explicit match-all signal", () => {
const template = {
id: "security-patterns",
title: "Security",
signal: "general",
failureMode: "x",
rule: "y",
tier: "alwaysApply" as const,
};
expect(matchesSignal(template, emptySignals())).toBe(true);
});
});
Loading