feat: extend harness audit integration scoring (#1990)

Salvages the useful harness-audit scoring work from #1989 while preserving the current hook registry and newer plugin install detection. Adds GitHub integration checks, conditional deploy-provider categories, dynamic applicable category metadata, and CODEOWNERS coverage.
This commit is contained in:
Affaan Mustafa
2026-05-19 06:20:54 -04:00
committed by GitHub
parent 9ee1e15564
commit af9b2c1c4c
5 changed files with 441 additions and 23 deletions

View File

@@ -126,7 +126,7 @@ function runTests() {
const parsed = JSON.parse(run(['repo', '--format', 'json']));
assert.strictEqual(parsed.deterministic, true);
assert.strictEqual(parsed.rubric_version, '2026-03-30');
assert.strictEqual(parsed.rubric_version, '2026-05-19');
assert.strictEqual(parsed.target_mode, 'repo');
assert.ok(parsed.overall_score >= 0);
assert.ok(parsed.max_score > 0);
@@ -140,6 +140,192 @@ function runTests() {
assert.ok(categoryNames.includes('Eval Coverage'));
assert.ok(categoryNames.includes('Security Guardrails'));
assert.ok(categoryNames.includes('Cost Efficiency'));
assert.ok(categoryNames.includes('GitHub Integration'));
})) passed++; else failed++;
if (test('report exposes applicable_categories and category_count', () => {
const parsed = JSON.parse(run(['repo', '--format', 'json']));
assert.ok(Array.isArray(parsed.applicable_categories), 'applicable_categories must be an array');
assert.ok(parsed.applicable_categories.length > 0);
assert.strictEqual(parsed.category_count, parsed.applicable_categories.length);
for (const name of parsed.applicable_categories) {
assert.ok(parsed.categories[name].max > 0, `${name} must have max > 0 to be applicable`);
}
})) passed++; else failed++;
if (test('GitHub Integration category scores against a fully-wired consumer fixture', () => {
const homeDir = createTempDir('harness-audit-home-gh-');
const projectRoot = createTempDir('harness-audit-project-gh-');
try {
fs.mkdirSync(path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin'), { recursive: true });
fs.writeFileSync(
path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin', 'plugin.json'),
JSON.stringify({ name: 'ecc' }, null, 2)
);
fs.mkdirSync(path.join(projectRoot, '.github', 'workflows'), { recursive: true });
fs.mkdirSync(path.join(projectRoot, '.github', 'ISSUE_TEMPLATE'), { recursive: true });
fs.writeFileSync(path.join(projectRoot, '.github', 'workflows', 'ci.yml'), 'name: ci\n');
fs.writeFileSync(path.join(projectRoot, '.github', 'PULL_REQUEST_TEMPLATE.md'), '# PR\n');
fs.writeFileSync(path.join(projectRoot, '.github', 'ISSUE_TEMPLATE', 'bug.md'), '# Bug\n');
fs.writeFileSync(path.join(projectRoot, '.github', 'CODEOWNERS'), '* @owner\n');
fs.writeFileSync(path.join(projectRoot, '.github', 'dependabot.yml'), 'version: 2\n');
fs.writeFileSync(path.join(projectRoot, 'package.json'), JSON.stringify({ name: 'gh-test' }));
const parsed = JSON.parse(run(['repo', '--format', 'json'], { cwd: projectRoot, homeDir }));
const github = parsed.categories['GitHub Integration'];
assert.ok(github, 'GitHub Integration category must exist');
assert.strictEqual(github.score, 10, `GitHub Integration should score 10/10, got ${github.score}`);
assert.strictEqual(github.earned, github.max);
assert.ok(parsed.applicable_categories.includes('GitHub Integration'));
} finally {
cleanup(homeDir);
cleanup(projectRoot);
}
})) passed++; else failed++;
if (test('provider categories are omitted unless a marker is present', () => {
const homeDir = createTempDir('harness-audit-home-no-provider-');
const projectRoot = createTempDir('harness-audit-project-no-provider-');
try {
fs.mkdirSync(path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin'), { recursive: true });
fs.writeFileSync(
path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin', 'plugin.json'),
JSON.stringify({ name: 'ecc' }, null, 2)
);
fs.writeFileSync(path.join(projectRoot, 'package.json'), JSON.stringify({ name: 'p' }));
const parsed = JSON.parse(run(['repo', '--format', 'json'], { cwd: projectRoot, homeDir }));
assert.ok(!parsed.applicable_categories.includes('Vercel Integration'));
const vercel = parsed.categories['Vercel Integration'];
assert.ok(!vercel || vercel.max === 0, 'Vercel Integration should not contribute when no marker');
} finally {
cleanup(homeDir);
cleanup(projectRoot);
}
})) passed++; else failed++;
if (test('Vercel Integration category scores when vercel.json present', () => {
const homeDir = createTempDir('harness-audit-home-vercel-');
const projectRoot = createTempDir('harness-audit-project-vercel-');
try {
fs.mkdirSync(path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin'), { recursive: true });
fs.writeFileSync(
path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin', 'plugin.json'),
JSON.stringify({ name: 'ecc' }, null, 2)
);
fs.mkdirSync(path.join(projectRoot, '.github', 'workflows'), { recursive: true });
fs.writeFileSync(path.join(projectRoot, 'vercel.json'), '{}\n');
fs.writeFileSync(path.join(projectRoot, '.env.example'), 'VERCEL_TOKEN=\n');
fs.writeFileSync(path.join(projectRoot, '.github', 'workflows', 'deploy.yml'), 'uses: amondnet/vercel-action@v25\n');
fs.writeFileSync(
path.join(projectRoot, 'package.json'),
JSON.stringify({ name: 'p', scripts: { build: 'next build', deploy: 'vercel deploy' } })
);
const parsed = JSON.parse(run(['repo', '--format', 'json'], { cwd: projectRoot, homeDir }));
const vercel = parsed.categories['Vercel Integration'];
assert.ok(vercel, 'Vercel Integration category must exist when vercel.json present');
assert.ok(vercel.max > 0);
assert.ok(parsed.applicable_categories.includes('Vercel Integration'));
assert.strictEqual(vercel.score, 10, `Vercel should score 10/10 with full wiring, got ${vercel.score}`);
} finally {
cleanup(homeDir);
cleanup(projectRoot);
}
})) passed++; else failed++;
if (test('detector map: Netlify, Cloudflare, Fly each trigger their category', () => {
const homeDir = createTempDir('harness-audit-home-multi-');
function probe(markerFile, markerContents, expectedCategory) {
const root = createTempDir('harness-audit-project-multi-');
try {
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ name: 'p' }));
fs.writeFileSync(path.join(root, markerFile), markerContents);
const parsed = JSON.parse(run(['repo', '--format', 'json'], { cwd: root, homeDir }));
assert.ok(
parsed.applicable_categories.includes(expectedCategory),
`${markerFile} should activate ${expectedCategory}`
);
} finally {
cleanup(root);
}
}
try {
fs.mkdirSync(path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin'), { recursive: true });
fs.writeFileSync(
path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin', 'plugin.json'),
JSON.stringify({ name: 'ecc' }, null, 2)
);
probe('netlify.toml', '[build]\n', 'Netlify Integration');
probe('wrangler.toml', 'name = "p"\n', 'Cloudflare Integration');
probe('fly.toml', 'app = "p"\n', 'Fly Integration');
} finally {
cleanup(homeDir);
}
})) passed++; else failed++;
if (test('max_score reflects only applicable categories', () => {
const homeDir = createTempDir('harness-audit-home-max-');
const noVercel = createTempDir('harness-audit-project-max-novercel-');
const withVercel = createTempDir('harness-audit-project-max-vercel-');
try {
fs.mkdirSync(path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin'), { recursive: true });
fs.writeFileSync(
path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin', 'plugin.json'),
JSON.stringify({ name: 'ecc' }, null, 2)
);
fs.writeFileSync(path.join(noVercel, 'package.json'), JSON.stringify({ name: 'p' }));
fs.writeFileSync(path.join(withVercel, 'package.json'), JSON.stringify({ name: 'p' }));
fs.writeFileSync(path.join(withVercel, 'vercel.json'), '{}\n');
const noVercelParsed = JSON.parse(run(['repo', '--format', 'json'], { cwd: noVercel, homeDir }));
const withVercelParsed = JSON.parse(run(['repo', '--format', 'json'], { cwd: withVercel, homeDir }));
assert.ok(
withVercelParsed.max_score > noVercelParsed.max_score,
`with-vercel max_score (${withVercelParsed.max_score}) should exceed no-vercel (${noVercelParsed.max_score})`
);
} finally {
cleanup(homeDir);
cleanup(noVercel);
cleanup(withVercel);
}
})) passed++; else failed++;
if (test('non-git directory does not crash the script', () => {
const homeDir = createTempDir('harness-audit-home-bare-');
const bare = createTempDir('harness-audit-project-bare-');
try {
fs.mkdirSync(path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin'), { recursive: true });
fs.writeFileSync(
path.join(homeDir, '.claude', 'plugins', 'ecc', '.claude-plugin', 'plugin.json'),
JSON.stringify({ name: 'ecc' }, null, 2)
);
fs.writeFileSync(path.join(bare, 'package.json'), JSON.stringify({ name: 'p' }));
const output = run(['repo', '--format', 'json'], { cwd: bare, homeDir });
const parsed = JSON.parse(output);
assert.ok(parsed.overall_score >= 0);
assert.ok(parsed.max_score > 0);
} finally {
cleanup(homeDir);
cleanup(bare);
}
})) passed++; else failed++;
if (test('scope filtering changes max score and check list', () => {
@@ -251,6 +437,7 @@ function runTests() {
);
fs.mkdirSync(path.join(projectRoot, '.claude'), { recursive: true });
fs.mkdirSync(path.join(projectRoot, '.github', 'workflows', 'nested'), { recursive: true });
fs.mkdirSync(path.join(projectRoot, '.github', 'ISSUE_TEMPLATE'), { recursive: true });
fs.mkdirSync(path.join(projectRoot, 'docs', 'adr'), { recursive: true });
fs.mkdirSync(path.join(projectRoot, 'evals'), { recursive: true });
fs.mkdirSync(path.join(projectRoot, 'src'), { recursive: true });
@@ -259,6 +446,9 @@ function runTests() {
fs.writeFileSync(path.join(projectRoot, 'CLAUDE.md'), '# Consumer instructions\n');
fs.writeFileSync(path.join(projectRoot, 'src', 'app.spec.ts'), 'test placeholder\n');
fs.writeFileSync(path.join(projectRoot, '.github', 'workflows', 'nested', 'ci.yaml'), 'name: ci\n');
fs.writeFileSync(path.join(projectRoot, '.github', 'PULL_REQUEST_TEMPLATE.md'), '# PR\n');
fs.writeFileSync(path.join(projectRoot, '.github', 'ISSUE_TEMPLATE', 'bug.md'), '# Bug\n');
fs.writeFileSync(path.join(projectRoot, '.github', 'CODEOWNERS'), '* @owner\n');
fs.writeFileSync(path.join(projectRoot, 'docs', 'adr', '001.md'), '# Record\n');
fs.writeFileSync(path.join(projectRoot, 'evals', 'smoke.json'), '{}\n');
fs.writeFileSync(path.join(projectRoot, '.github', 'dependabot.yml'), 'version: 2\n');
@@ -274,7 +464,7 @@ function runTests() {
const text = run(['repo'], { cwd: projectRoot, homeDir });
assert.ok(text.includes(`Harness Audit (repo, consumer): ${parsed.max_score}/${parsed.max_score}`));
assert.ok(text.includes('Checks: 11 total, 0 failing'));
assert.ok(text.includes('Checks: 16 total, 0 failing'));
assert.ok(!text.includes('Top 3 Actions:'));
const scopedText = run(['agents'], { cwd: projectRoot, homeDir });