Revert "feat(ultraplan-local): M1 — profile recommendation flow in ultrabrief"
This reverts commit 7e2d9e151e.
This commit is contained in:
parent
7e2d9e151e
commit
59f1fe1631
8 changed files with 15 additions and 609 deletions
|
|
@ -18,8 +18,6 @@ import {
|
|||
validateProfile,
|
||||
loadProfile,
|
||||
listProfiles,
|
||||
selectRecommendation,
|
||||
RECOMMENDATION_THRESHOLD,
|
||||
} from './profile-loader.mjs';
|
||||
|
||||
// =====================================================================
|
||||
|
|
@ -379,99 +377,3 @@ test('listProfiles: includes default', async () => {
|
|||
const names = await listProfiles();
|
||||
assert.ok(names.includes('default'), `Expected default in ${names.join(', ')}`);
|
||||
});
|
||||
|
||||
// =====================================================================
|
||||
// selectRecommendation tests (M1)
|
||||
// =====================================================================
|
||||
|
||||
test('selectRecommendation: only-default short-circuit', () => {
|
||||
const result = selectRecommendation([], { availableProfiles: ['default'] });
|
||||
assert.equal(result.profile, 'default');
|
||||
assert.equal(result.match, 'default-only');
|
||||
assert.equal(result.source, 'default-only');
|
||||
});
|
||||
|
||||
test('selectRecommendation: empty ranked input falls back', () => {
|
||||
const result = selectRecommendation([]);
|
||||
assert.equal(result.profile, 'default');
|
||||
assert.equal(result.match, 'fallback');
|
||||
assert.equal(result.source, 'fallback');
|
||||
assert.match(result.rationale, /no ranked profiles/);
|
||||
});
|
||||
|
||||
test('selectRecommendation: malformed ranked input falls back', () => {
|
||||
const result = selectRecommendation([null, { not_a_profile: true }]);
|
||||
assert.equal(result.profile, 'default');
|
||||
assert.equal(result.source, 'fallback');
|
||||
});
|
||||
|
||||
test('selectRecommendation: top score above threshold returns recommendation', () => {
|
||||
const ranked = [
|
||||
{ name: 'security-deep', score: 0.91, match_quality: 'exact', rationale: 'OWASP + JWT in Intent.' },
|
||||
{ name: 'default', score: 0.30, match_quality: 'fallback', rationale: 'No triggers.' },
|
||||
];
|
||||
const result = selectRecommendation(ranked);
|
||||
assert.equal(result.profile, 'security-deep');
|
||||
assert.equal(result.match, 'exact');
|
||||
assert.equal(result.source, 'recommended');
|
||||
assert.equal(result.rationale, 'OWASP + JWT in Intent.');
|
||||
});
|
||||
|
||||
test('selectRecommendation: top score below threshold falls back to default', () => {
|
||||
const ranked = [
|
||||
{ name: 'feature', score: 0.55, match_quality: 'partial', rationale: 'Some keyword hits.' },
|
||||
{ name: 'default', score: 0.30, match_quality: 'fallback', rationale: 'Baseline.' },
|
||||
];
|
||||
const result = selectRecommendation(ranked);
|
||||
assert.equal(result.profile, 'default');
|
||||
assert.equal(result.match, 'fallback');
|
||||
assert.equal(result.source, 'fallback');
|
||||
// Rationale should reference both the score and the top entry's rationale
|
||||
assert.match(result.rationale, /0\.55/);
|
||||
assert.match(result.rationale, /Some keyword hits/);
|
||||
});
|
||||
|
||||
test('selectRecommendation: respects custom threshold', () => {
|
||||
const ranked = [
|
||||
{ name: 'feature', score: 0.55, match_quality: 'partial', rationale: 'Match.' },
|
||||
];
|
||||
// With low threshold the same entry IS the recommendation
|
||||
const result = selectRecommendation(ranked, { threshold: 0.5 });
|
||||
assert.equal(result.profile, 'feature');
|
||||
assert.equal(result.source, 'recommended');
|
||||
});
|
||||
|
||||
test('selectRecommendation: highest-score wins regardless of input order', () => {
|
||||
const ranked = [
|
||||
{ name: 'a', score: 0.40, match_quality: 'partial', rationale: 'Low.' },
|
||||
{ name: 'b', score: 0.95, match_quality: 'exact', rationale: 'High.' },
|
||||
{ name: 'c', score: 0.72, match_quality: 'partial', rationale: 'Mid.' },
|
||||
];
|
||||
const result = selectRecommendation(ranked);
|
||||
assert.equal(result.profile, 'b');
|
||||
assert.equal(result.source, 'recommended');
|
||||
});
|
||||
|
||||
test('selectRecommendation: missing score treated as 0', () => {
|
||||
const ranked = [
|
||||
{ name: 'a', match_quality: 'fallback', rationale: 'No score.' },
|
||||
];
|
||||
const result = selectRecommendation(ranked);
|
||||
// Top entry has effective score 0 → falls back
|
||||
assert.equal(result.profile, 'default');
|
||||
assert.equal(result.source, 'fallback');
|
||||
});
|
||||
|
||||
test('selectRecommendation: missing rationale gets a synthetic one', () => {
|
||||
const ranked = [
|
||||
{ name: 'security-deep', score: 0.85, match_quality: 'exact' },
|
||||
];
|
||||
const result = selectRecommendation(ranked);
|
||||
assert.equal(result.profile, 'security-deep');
|
||||
assert.match(result.rationale, /Top-ranked/);
|
||||
});
|
||||
|
||||
test('RECOMMENDATION_THRESHOLD: matches plan default', () => {
|
||||
// Sanity check that the export agrees with the documented threshold.
|
||||
assert.equal(RECOMMENDATION_THRESHOLD, 0.7);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue