fix(hooks): route only the four discovery targets; register the skill-contract fixture as free (GST-1088 lane A)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-11-03 02:30:09 +00:00
1 parent 42ee037828
commit 93b17edf6a
4 files changed
+19 -2

No files matched your search

+1
View File
@@ -240,6 +240,7 @@ export const FREE_FIXTURES: Readonly<Record<string, readonly string[]>> = {
'test/fixtures/ship-queue/gbrain-stamp-pair.json': ['test/helpers/ship-queue-fixture.ts', 'test/tree-receipt-gbrain-pair.test.ts'],
'test/fixtures/ship-triage/**': ['test/ship-triage-labels.test.ts'],
'test/fixtures/skill-bin-drift-allowlist.json': ['test/skill-bin-drift.test.ts'],
'test/fixtures/skill-contract/**': ['test/skill-contract-stop-hook.test.ts', 'test/skill-contract.test.ts'],
'test/fixtures/skill-evals/**': ['test/skill-eval-checks.test.ts', 'test/skill-eval-tasks.test.ts'],
'test/fixtures/skill-md-size-allowlist.json': ['test/skill-md-size-guard.test.ts'],
'test/fixtures/state-matrix-6792/**': ['test/state-matrix.test.ts'],
+9 -1
View File
@@ -8,7 +8,7 @@ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
import { spawnSync } from 'node:child_process';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { PROMPT_MAX_CHARS, ROUTE_THRESHOLD, firstStep, hintLine, readSkillSwitch, routePrompt, scanInstalledSkills, scorePrompt, stem } from '../lib/skill-route';
import { PROMPT_MAX_CHARS, ROUTED_SKILLS, ROUTE_THRESHOLD, firstStep, hintLine, readSkillSwitch, routePrompt, scanInstalledSkills, scorePrompt, stem } from '../lib/skill-route';
import { ROOT, ROUTE_HOOK, SKILLS, hookEnv, runHook, skillsDir, tmpDir } from './helpers/skill-contract-fixture';
let state = '', skills = '';
@@ -52,6 +52,14 @@ describe('scorer', () => {
expect(routePrompt(`fix this bug ${'x'.repeat(PROMPT_MAX_CHARS)}`, fixtureSkills)).toMatchObject({ route: null, reason: 'prompt-too-long' });
});
test('only the four discovery targets route; another installed skill with a matching trigger does not', () => {
expect(ROUTED_SKILLS).toEqual(['investigate', 'review', 'qa', 'verify']);
const ship = { name: 'ship', file: '', frontmatter: '', triggers: ['ship this branch'] };
expect(scorePrompt('ship this branch', [ship])[0]).toMatchObject({ skill: 'ship', score: 1 });
expect(routePrompt('ship this branch', [...fixtureSkills, ship])).toMatchObject({ route: null, reason: 'below-threshold' });
expect(routePrompt('this test fails, ship this branch', [ship, ...fixtureSkills]).route?.skill).toBe('investigate');
});
test('malformed triggers are reported and skipped, never thrown', () => {
const scan = scanInstalledSkills(skillsDir(['broken', 'qa'], { nofront: 'no frontmatter here\n' }));
expect(scan.problems).toEqual(['broken: malformed triggers']);