feat: антипаттерны с жизненным циклом и seed из граблей библиотеки (BHL-015)

- spec/schemas/antipattern.schema.json: level и lifecycle разделены
- seed: 3 антипаттерна + 3 proposed-требования + домен/возможность
- валидатор: цели relations антипаттернов и ссылки требований
- реальный spec/ проходит bhl validate; пакет 18/18, корень зелёный
This commit is contained in:
Suslov-MD
2026-11-28 23:53:40 +03:00
parent 5b514272cf
commit 13ba43eb59
15 changed files with 424 additions and 35 deletions
+31
View File
@@ -65,6 +65,16 @@ const SCHEMAS = {
description: { type: 'string' },
},
},
'antipattern.schema.json': {
$id: 'https://baseline-harness.dev/spec/schemas/antipattern.schema.json',
type: 'object',
required: ['id', 'level', 'relations'],
properties: {
id: { type: 'string', pattern: '^ant-[a-z0-9-]+$' },
level: { enum: ['SHOULD NOT', 'MUST NOT'] },
relations: { type: 'array', items: { type: 'object' } },
},
},
};
const BASE_FILES = {
@@ -94,6 +104,7 @@ function fixture(t, overrides = {}) {
writeFileSync(target, contents, 'utf8');
}
mkdirSync(path.join(root, 'parameters'), { recursive: true });
mkdirSync(path.join(root, 'antipatterns'), { recursive: true });
t.after(() => rmSync(root, { recursive: true, force: true }));
return root;
}
@@ -192,3 +203,23 @@ test('обязательная структура корня: schemas и дир
assert.equal(result.code, 1);
assert.ok(codes(result).includes('missing-directory'));
});
test('антипаттерны: двусторонние ссылки проходят, висячие цели падают', (t) => {
const ok = fixture(t, {
'requirements/req-gamma.yaml':
'id: req-gamma\ndomain: dom-build\ncapability: cap-verify\nstatement: Проект MUST NOT молчать о провале.\nlevel: MUST NOT\nantipatterns:\n - ant-silent-fail\n',
'antipatterns/ant-silent-fail.yaml':
'id: ant-silent-fail\nlevel: MUST NOT\nrelations:\n - target: req-gamma\n kind: contradicts\n',
});
assert.equal(runValidate(ok).code, 0);
const dangling = fixture(t, {
'antipatterns/ant-ghost.yaml':
'id: ant-ghost\nlevel: MUST NOT\nrelations:\n - target: req-ghost\n kind: contradicts\n',
});
assert.ok(codes(runValidate(dangling)).includes('unknown-requirement'));
const orphanLink = fixture(t, {
'requirements/req-delta.yaml':
'id: req-delta\ndomain: dom-build\ncapability: cap-verify\nstatement: Проект SHOULD кэшировать артефакты.\nlevel: SHOULD\nantipatterns:\n - ant-never-defined\n',
});
assert.ok(codes(runValidate(orphanLink)).includes('unknown-antipattern'));
});