feat: синтетическая спецификация для сквозных прогонов (BHL-018)

- examples/synthetic-spec: полный набор сущностей, профилей, пресета и антипаттерна
- bhl validate и profile resolve проходят пример без диагностик
- тест сверяет копию схем с spec/schemas и порядок разрешения
- README карты лаборатории дополнен spec/ и examples/
This commit is contained in:
Suslov-MD
2026-11-29 00:06:36 +03:00
parent 3aa8c6f944
commit c50092f7e4
28 changed files with 929 additions and 7 deletions
+2
View File
@@ -10,6 +10,8 @@ Baseline Harness Lab (BHL) — лаборатория базового стан
| `experiments/` | Самостоятельные прототипы со своими зависимостями и тестами | [Эксперименты](experiments/README.md) |
| `results/` | Датированные выводы и измерения, привязанные к версии и условиям | [Результаты](results/README.md) |
| `packages/` | Принятые владельцем расширения и инструменты | [Пакеты](packages/README.md) |
| `spec/` | Машиночитаемая спецификация BHS: схемы сущностей, журнал нормативных изменений | [Схемы](spec/schemas), [журнал изменений](spec/CHANGELOG.yaml) |
| `examples/` | Инфраструктурные примеры для прогонов валидации и разрешения | [Синтетическая спецификация](examples/synthetic-spec/README.md) |
[Pi Supervisor](experiments/pi-supervisor/README.md) — эксперимент с параллельным локальным наблюдателем рабочей сессии. Проверки кода пройдены; полезность на рабочей Qwen ещё не измерена. Принятых пакетов пока нет. [Установить и запустить супервизор](#установка-и-запуск-супервизора).
@@ -1,9 +1,10 @@
---
id: BHL-018
title: Создать синтетическую спецификацию для проверки инфраструктуры
status: To Do
status: Done
assignee: []
created_date: '2026-11-28T14:25:35Z'
updated_date: '2026-11-28T21:06:36Z'
labels: []
milestone: m-1
dependencies:
@@ -22,14 +23,26 @@ ordinal: 18000
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Синтетическая спецификация проходит полный цикл валидации и разрешения
- [ ] #2 Явно отмечена как инфраструктурный пример, не BHS 0.1.0
- [x] #1 Синтетическая спецификация проходит полный цикл валидации и разрешения
- [x] #2 Явно отмечена как инфраструктурный пример, не BHS 0.1.0
<!-- AC:END -->
## Definition of Done
<!-- DOD:BEGIN -->
- [ ] #1 npm run check пройден (для изменений материалов и документации)
- [ ] #2 Местный quality gate затронутого модуля пройден (для кода и конфигурации)
- [ ] #3 В записи нет секретов, персональных путей и непубликуемых идентификаторов
- [ ] #4 Состояние задачи в Backlog.md актуально: прогресс, блокеры, следующий шаг
- [x] #1 npm run check пройден (для изменений материалов и документации)
- [x] #2 Местный quality gate затронутого модуля пройден (для кода и конфигурации)
- [x] #3 В записи нет секретов, персональных путей и непубликуемых идентификаторов
- [x] #4 Состояние задачи в Backlog.md актуально: прогресс, блокеры, следующий шаг
<!-- DOD:END -->
## Comments
<!-- COMMENTS:BEGIN -->
created: 2026-11-28T21:06:36Z
---
examples/synthetic-spec: 3 требования (MUST/SHOULD/MUST NOT) с параметрами, домен/возможность, 2 профиля (явное ослабление + переопределения inline и реестрового параметра), пресет, антипаттерн со связью, CHANGELOG ADDED. bhl validate: 8 файлов 0 диагностик; profile resolve --preset: ожидаемый Effective Specification, идентичный при смене порядка; копия схем сверяется с spec/schemas тестом. README явно отмечает инфраструктурный характер (не BHS 0.1.0).
---
<!-- COMMENTS:END -->
+12
View File
@@ -0,0 +1,12 @@
changes:
- id: chg-synth-init
release: 0.0.0
date: 2026-11-28
type: ADDED
requirements: [req-synth-alpha, req-synth-beta, req-synth-gamma]
description: >-
Синтетические требования введены в инфраструктурный пример для
сквозных прогонов валидации и разрешения.
motivation: >-
Инфраструктура должна проверяться на полном наборе сущностей до
согласования содержательной редакции BHS 0.1.0.
+23
View File
@@ -0,0 +1,23 @@
# Синтетическая спецификация (инфраструктурный пример)
Это инфраструктурный пример для прогонов валидации, разрешения и аудита (BHL-018,
Этап 2). Он **не является** содержательной редакцией BHS 0.1.0 (D-021): сущности
вымышленные, формулировки служебные. Содержательная спецификация согласуется с
владельцем отдельно (BHL-038).
Содержимое:
- `domains/`, `capabilities/`, `requirements/`, `parameters/` — минимальный набор
сущностей со связями и типизированным параметром;
- `profiles/` и `presets/` — явное ослабление и переопределение параметра;
- `antipatterns/` — антипаттерн, связанный с требованием;
- `CHANGELOG.yaml` — одна запись ADDED;
- `schemas/` — копия `spec/schemas/`; расхождение копий ловит тест
`tests/synthetic-spec.test.mjs`.
Прогоны:
```sh
node packages/bhl/src/cli.ts validate examples/synthetic-spec
node packages/bhl/src/cli.ts profile resolve examples/synthetic-spec --preset preset-synth-all
```
@@ -0,0 +1,16 @@
id: ant-synth-late-check
title: Проверка синтетического артефакта после отправки
description: >-
Проверка выполняется после отправки артефакта в реестр примеров, тогда
как результат уже не влияет на отправку.
level: MUST NOT
lifecycle:
status: proposed
since: '2026-11-28'
note: Инфраструктурный пример (BHL-018), не содержательная редакция BHS.
relations:
- target: req-synth-gamma
kind: contradicts
sources:
- material: examples/synthetic-spec/README.md
note: Служебное происхождение — инфраструктурный пример, не грабля проекта.
@@ -0,0 +1,6 @@
id: cap-synth-verify
domain: dom-synth-build
title: Синтетическая проверка
description: >-
Вымышленная возможность проверки для прогонов валидации и разрешения
профилей. Не является частью содержательной спецификации BHS.
@@ -0,0 +1,5 @@
id: dom-synth-build
title: Синтетическая сборка
description: >-
Вымышленная область сборки для инфраструктурных прогонов валидации и
разрешения. Не является частью содержательной спецификации BHS.
@@ -0,0 +1,7 @@
id: param-synth-mode
type: enum
description: Режим вывода синтетического прогона для проверки реестра параметров.
default: json
constraints:
values: [json, plain]
overridable_by: [profile]
@@ -0,0 +1,6 @@
id: preset-synth-all
title: Полный синтетический набор
description: >-
Пресет обоих синтетических профилей для сквозных прогонов разрешения
валидации, разрешения и аудита.
profiles: [prof-synth-light, prof-synth-strict]
@@ -0,0 +1,12 @@
id: prof-synth-light
title: Облегчённый синтетический профиль
description: >-
Явно ослабляет проверку до отправки и переопределяет бюджет подготовки
для инфраструктурных прогонов разрешения.
requirements:
- requirement: req-synth-alpha
relax_to: SHOULD
note: ослабление только явное
parameter_overrides:
- parameter: param-synth-budget
value: 4
@@ -0,0 +1,12 @@
id: prof-synth-strict
title: Строгий синтетический профиль
description: >-
Не ослабляет требования и переопределяет режим вывода из реестра
параметров для инфраструктурных прогонов разрешения.
requirements:
- requirement: req-synth-alpha
- requirement: req-synth-beta
- requirement: req-synth-gamma
parameter_overrides:
- parameter: param-synth-mode
value: plain
@@ -0,0 +1,42 @@
id: req-synth-alpha
domain: dom-synth-build
capability: cap-synth-verify
title: Проверка до отправки
statement: >-
Синтетический артефакт MUST проходить проверку перед отправкой в реестр
примеров.
level: MUST
rationale: >-
Служебное требование для проверки разрешения профилей и параметров;
содержательного смысла для стандарта не несёт.
applicability:
- when: отправка синтетического артефакта
unless: отправка выполняется в dry-run режиме
parameters:
- id: param-synth-budget
type: integer
description: Часов подготовки синтетического артефакта до проверки.
default: 2
constraints:
minimum: 0
maximum: 8
acceptance_criteria:
- criterion: Проверка выполнена до отправки
measure: журнал прогона предшествует записи об отправке
verification:
kind: deterministic
procedure: Детерминированная проверка порядка событий в журнале примера.
automation: bhl audit
expected_evidence:
- kind: test-run
description: Журнал прогона проверки с отметкой времени
relations:
- target: req-synth-beta
kind: depends-on
lifecycle:
status: proposed
since: '2026-11-28'
note: Инфраструктурный пример (BHL-018), не содержательная редакция BHS.
history_ref: CHANGELOG.yaml
antipatterns:
- ant-synth-late-check
@@ -0,0 +1,34 @@
id: req-synth-beta
domain: dom-synth-build
capability: cap-synth-verify
title: Документирование шагов примера
statement: >-
Синтетический пример SHOULD документировать шаги воспроизведения в README.
level: SHOULD
rationale: >-
Служебное требование для проверки разрешения параметров из реестра;
содержательного смысла для стандарта не несёт.
applicability:
- when: публикация синтетического примера
parameters:
- id: param-synth-mode
type: enum
description: Режим вывода синтетического прогона для проверки реестра параметров.
default: json
constraints:
values: [json, plain]
acceptance_criteria:
- criterion: Шаги воспроизведения описаны
measure: README примера содержит команды прогона
verification:
kind: deterministic
procedure: Проверка наличия раздела шагов воспроизведения в README примера.
automation: bhl audit
expected_evidence:
- kind: file
description: README примера с разделом шагов
lifecycle:
status: proposed
since: '2026-11-28'
note: Инфраструктурный пример (BHL-018), не содержательная редакция BHS.
history_ref: CHANGELOG.yaml
@@ -0,0 +1,27 @@
id: req-synth-gamma
domain: dom-synth-build
capability: cap-synth-verify
title: Проверка после отправки запрещена
statement: >-
Синтетический артефакт MUST NOT проверяться после отправки в реестр примеров.
level: MUST NOT
rationale: >-
Служебное требование для проверки связей антипаттернов; содержательного
смысла для стандарта не несёт.
applicability:
- when: отправка синтетического артефакта
acceptance_criteria:
- criterion: Проверка не выполняется после отправки
measure: журнал не содержит проверок позже отметки отправки
verification:
kind: deterministic
procedure: Детерминированная проверка порядка событий в журнале примера.
automation: bhl audit
expected_evidence:
- kind: test-run
description: Журнал прогона с отметками времени относительно отправки
lifecycle:
status: proposed
since: '2026-11-28'
note: Инфраструктурный пример (BHL-018), не содержательная редакция BHS.
history_ref: CHANGELOG.yaml
@@ -0,0 +1,62 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/antipattern.schema.json",
"title": "Antipattern",
"description": "Нормативный антипаттерн с историей отказов (D-004). Нормативный уровень (level) и жизненный цикл (lifecycle) — разные enum (D-029); связи с требованиями и происхождение из материалов библиотеки обязательны.",
"type": "object",
"additionalProperties": false,
"required": ["id", "title", "description", "level", "lifecycle", "relations", "sources"],
"properties": {
"id": {
"type": "string",
"pattern": "^ant-[a-z0-9]+(-[a-z0-9]+)*$",
"description": "Постоянный идентификатор (D-031)."
},
"title": { "type": "string", "minLength": 3, "maxLength": 120 },
"description": { "type": "string", "minLength": 10 },
"level": {
"enum": ["SHOULD NOT", "MUST NOT"],
"description": "Нормативная сила запрета; не смешивается с жизненным циклом."
},
"lifecycle": {
"type": "object",
"additionalProperties": false,
"required": ["status"],
"properties": {
"status": {
"enum": ["proposed", "discouraged", "forbidden", "deprecated", "removed"],
"description": "Путь антипаттерна: proposed → discouraged → forbidden; deprecated → removed. Не нормативный уровень."
},
"since": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
"note": { "type": "string", "minLength": 3 }
}
},
"relations": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["target", "kind"],
"properties": {
"target": { "type": "string", "pattern": "^req-[a-z0-9]+(-[a-z0-9]+)*$" },
"kind": { "enum": ["contradicts"] }
}
}
},
"sources": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["material"],
"properties": {
"material": { "type": "string", "minLength": 3 },
"note": { "type": "string", "minLength": 3 }
}
}
},
"note": { "type": "string", "minLength": 3 }
}
}
@@ -0,0 +1,50 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/audit-finding.schema.json",
"title": "Audit Finding",
"description": "Проверка одного требования в отчёте аудита (D-005, D-019). Статус аудита не смешивается с уровнем и жизненным циклом требования.",
"type": "object",
"additionalProperties": false,
"required": ["requirement", "status", "method", "evidence", "rationale"],
"properties": {
"requirement": { "type": "string", "pattern": "^req-[a-z0-9]+(-[a-z0-9]+)*$" },
"status": {
"enum": ["PASS", "FAIL", "PARTIAL", "EXEMPT", "NOT_APPLICABLE", "UNKNOWN", "BLOCKED"]
},
"method": { "enum": ["deterministic", "semantic", "hybrid"] },
"evidence": {
"type": "array",
"minItems": 1,
"items": { "$ref": "https://baseline-harness.dev/spec/schemas/evidence.schema.json" }
},
"issues": { "type": "array", "items": { "type": "string", "minLength": 3 } },
"recommendations": { "type": "array", "items": { "type": "string", "minLength": 3 } },
"corrections": { "type": "array", "items": { "type": "string", "minLength": 3 } },
"rationale": { "type": "string", "minLength": 10 },
"confidence": {
"enum": ["high", "medium", "low"],
"description": "Уверенность семантической проверки; для deterministic не требуется."
},
"exemption_ref": {
"type": "string",
"minLength": 3,
"description": "Ссылка на утверждённое исключение при status EXEMPT."
}
},
"allOf": [
{
"if": { "properties": { "status": { "const": "EXEMPT" } }, "required": ["status"] },
"then": {
"required": ["exemption_ref"],
"properties": { "exemption_ref": { "type": "string", "minLength": 3 } }
}
},
{
"if": { "properties": { "method": { "const": "semantic" } }, "required": ["method"] },
"then": {
"required": ["confidence"],
"properties": { "confidence": { "enum": ["high", "medium", "low"] } }
}
}
]
}
@@ -0,0 +1,68 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/audit-report.schema.json",
"title": "Audit Report",
"description": "Структурированный отчёт аудита (D-005, D-019). Состояние проверяемого дерева фиксируется отпечатком, а не только commit SHA; процентный рейтинг отсутствует по замыслу.",
"type": "object",
"additionalProperties": false,
"required": ["id", "generated_at", "tool", "subject", "spec_version", "findings"],
"properties": {
"id": { "type": "string", "pattern": "^rep-[a-z0-9]+(-[a-z0-9]+)*$" },
"generated_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
"tool": {
"type": "object",
"additionalProperties": false,
"required": ["name", "version"],
"properties": {
"name": { "type": "string", "minLength": 1 },
"version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$" }
}
},
"agent": {
"type": "object",
"additionalProperties": false,
"required": ["name"],
"properties": {
"name": { "type": "string", "minLength": 1 },
"version": { "type": "string", "minLength": 1 }
},
"description": "Агент семантической части, если она выполнялась."
},
"subject": {
"type": "object",
"additionalProperties": false,
"required": ["kind", "fingerprint"],
"properties": {
"kind": { "enum": ["repository", "directory", "spec"] },
"fingerprint": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
"revision": { "type": "string", "minLength": 1 },
"dirty": { "type": "boolean" }
}
},
"spec_version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$" },
"profiles": {
"type": "array",
"items": { "type": "string", "pattern": "^prof-[a-z0-9]+(-[a-z0-9]+)*$" }
},
"findings": {
"type": "array",
"items": { "$ref": "https://baseline-harness.dev/spec/schemas/audit-finding.schema.json" }
},
"summary": {
"type": "object",
"additionalProperties": false,
"required": ["PASS", "FAIL", "PARTIAL", "EXEMPT", "NOT_APPLICABLE", "UNKNOWN", "BLOCKED"],
"properties": {
"PASS": { "type": "integer", "minimum": 0 },
"FAIL": { "type": "integer", "minimum": 0 },
"PARTIAL": { "type": "integer", "minimum": 0 },
"EXEMPT": { "type": "integer", "minimum": 0 },
"NOT_APPLICABLE": { "type": "integer", "minimum": 0 },
"UNKNOWN": { "type": "integer", "minimum": 0 },
"BLOCKED": { "type": "integer", "minimum": 0 }
},
"description": "Сверка сумм с findings — задача bhl report validate (BHL-023)."
},
"notes": { "type": "array", "items": { "type": "string", "minLength": 3 } }
}
}
@@ -0,0 +1,23 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/capability.schema.json",
"title": "Capability",
"description": "Средний уровень иерархии Domain → Capability → Atomic Requirement (D-009).",
"type": "object",
"additionalProperties": false,
"required": ["id", "domain", "title", "description"],
"properties": {
"id": {
"type": "string",
"pattern": "^cap-[a-z0-9]+(-[a-z0-9]+)*$",
"description": "Постоянный идентификатор (D-031)."
},
"domain": {
"type": "string",
"pattern": "^dom-[a-z0-9]+(-[a-z0-9]+)*$",
"description": "Ссылка на существующий домен; целостность проверяет валидатор (BHL-011)."
},
"title": { "type": "string", "minLength": 3 },
"description": { "type": "string", "minLength": 10 }
}
}
@@ -0,0 +1,18 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/domain.schema.json",
"title": "Domain",
"description": "Верхний уровень иерархии спецификации BHS (D-009).",
"type": "object",
"additionalProperties": false,
"required": ["id", "title", "description"],
"properties": {
"id": {
"type": "string",
"pattern": "^dom-[a-z0-9]+(-[a-z0-9]+)*$",
"description": "Постоянный идентификатор (D-031): не зависит от имени, пути и позиции."
},
"title": { "type": "string", "minLength": 3 },
"description": { "type": "string", "minLength": 10 }
}
}
@@ -0,0 +1,26 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/evidence.schema.json",
"title": "Evidence",
"description": "Доказательство для Audit Finding (D-005, D-019). Класс доказательств отличает наблюдение от интерпретации.",
"type": "object",
"additionalProperties": false,
"required": ["kind", "locator", "description"],
"properties": {
"kind": {
"enum": ["file", "command-output", "test-run", "session-observation", "review-note", "hash", "other"]
},
"locator": {
"type": "string",
"minLength": 1,
"description": "Путь, команда или идентификатор наблюдения."
},
"description": { "type": "string", "minLength": 3 },
"fingerprint": {
"type": "string",
"pattern": "^sha256:[a-f0-9]{64}$",
"description": "Отпечаток состояния источника доказательства (D-019)."
},
"captured_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" }
}
}
@@ -0,0 +1,31 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/normative-change.schema.json",
"title": "Normative Change",
"description": "Запись канонического журнала нормативных изменений BHS (D-011). История в требованиях не дублируется: требование несёт только history_ref.",
"type": "object",
"additionalProperties": false,
"required": ["id", "release", "date", "type", "requirements", "description"],
"properties": {
"id": {
"type": "string",
"pattern": "^chg-[a-z0-9]+(-[a-z0-9]+)*$",
"description": "Постоянный идентификатор (D-031)."
},
"release": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$",
"description": "Версия спецификации, в которой изменение опубликовано."
},
"date": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
"type": { "enum": ["ADDED", "STRENGTHENED", "RELAXED", "CLARIFIED", "DEPRECATED", "REMOVED"] },
"requirements": {
"type": "array",
"minItems": 1,
"items": { "type": "string", "pattern": "^req-[a-z0-9]+(-[a-z0-9]+)*$" }
},
"description": { "type": "string", "minLength": 10 },
"motivation": { "type": "string", "minLength": 3 },
"migration": { "type": "string", "minLength": 3, "description": "Инструкция переноса для потребителей при REMOVED/STRENGTHENED." }
}
}
@@ -0,0 +1,87 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/parameter.schema.json",
"title": "Parameter",
"description": "Типизированный параметр требования (D-018): значение переопределяется только в пределах ограничений.",
"type": "object",
"additionalProperties": false,
"required": ["id", "type", "description"],
"properties": {
"id": {
"type": "string",
"pattern": "^param-[a-z0-9]+(-[a-z0-9]+)*$",
"description": "Постоянный идентификатор (D-031)."
},
"type": { "enum": ["boolean", "integer", "number", "string", "enum"] },
"description": { "type": "string", "minLength": 10 },
"default": {},
"unit": { "type": "string", "minLength": 1 },
"constraints": {
"type": "object",
"additionalProperties": false,
"properties": {
"minimum": { "type": "number" },
"maximum": { "type": "number" },
"values": { "type": "array", "minItems": 1, "items": { "type": ["string", "integer", "number", "boolean"] } },
"pattern": { "type": "string" },
"minLength": { "type": "integer", "minimum": 0 },
"maxLength": { "type": "integer", "minimum": 1 }
}
},
"overridable_by": {
"type": "array",
"minItems": 0,
"uniqueItems": true,
"items": { "enum": ["profile", "project"] },
"default": ["profile", "project"]
}
},
"allOf": [
{
"if": { "properties": { "type": { "const": "boolean" } }, "required": ["type"] },
"then": {
"properties": {
"default": { "type": "boolean" },
"constraints": { "type": "object", "additionalProperties": false, "properties": {} }
}
}
},
{
"if": { "properties": { "type": { "const": "integer" } }, "required": ["type"] },
"then": {
"properties": {
"default": { "type": "integer" },
"constraints": { "type": "object", "additionalProperties": false, "properties": { "minimum": { "type": "integer" }, "maximum": { "type": "integer" } } }
}
}
},
{
"if": { "properties": { "type": { "const": "number" } }, "required": ["type"] },
"then": {
"properties": {
"default": { "type": "number" },
"constraints": { "type": "object", "additionalProperties": false, "properties": { "minimum": { "type": "number" }, "maximum": { "type": "number" } } }
}
}
},
{
"if": { "properties": { "type": { "const": "string" } }, "required": ["type"] },
"then": {
"properties": {
"default": { "type": "string" },
"constraints": { "type": "object", "additionalProperties": false, "properties": { "pattern": { "type": "string" }, "minLength": { "type": "integer", "minimum": 0 }, "maxLength": { "type": "integer", "minimum": 1 } } }
}
}
},
{
"if": { "properties": { "type": { "const": "enum" } }, "required": ["type"] },
"then": {
"required": ["constraints"],
"properties": {
"default": {},
"constraints": { "type": "object", "additionalProperties": false, "required": ["values"], "properties": { "values": { "type": "array", "minItems": 1, "items": { "type": ["string", "integer", "number", "boolean"] } } } }
}
}
}
]
}
@@ -0,0 +1,20 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/preset.schema.json",
"title": "Preset",
"description": "Именованная композиция профилей (D-013): разворачивается в набор профилей до разрешения.",
"type": "object",
"additionalProperties": false,
"required": ["id", "title", "description", "profiles"],
"properties": {
"id": { "type": "string", "pattern": "^preset-[a-z0-9]+(-[a-z0-9]+)*$" },
"title": { "type": "string", "minLength": 3 },
"description": { "type": "string", "minLength": 10 },
"profiles": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": { "type": "string", "pattern": "^prof-[a-z0-9]+(-[a-z0-9]+)*$" }
}
}
}
@@ -0,0 +1,40 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/profile.schema.json",
"title": "Profile",
"description": "Композиционный профиль (D-013, D-002): набор требований и переопределений параметров. Ослабление только явное (relax_to).",
"type": "object",
"additionalProperties": false,
"required": ["id", "title", "description", "requirements"],
"properties": {
"id": { "type": "string", "pattern": "^prof-[a-z0-9]+(-[a-z0-9]+)*$" },
"title": { "type": "string", "minLength": 3 },
"description": { "type": "string", "minLength": 10 },
"requirements": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["requirement"],
"properties": {
"requirement": { "type": "string", "pattern": "^req-[a-z0-9]+(-[a-z0-9]+)*$" },
"relax_to": { "enum": ["SHOULD", "MAY"] },
"note": { "type": "string", "minLength": 3 }
}
}
},
"parameter_overrides": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["parameter", "value"],
"properties": {
"parameter": { "type": "string", "pattern": "^param-[a-z0-9]+(-[a-z0-9]+)*$" },
"value": {}
}
}
}
}
}
@@ -0,0 +1,46 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/project-exception.schema.json",
"title": "Project Exception",
"description": "Документированное обоснованное исключение, утверждаемое владельцем (D-002, D-008). Отличие от N/A: N/A — требование неприменимо, EXEMPT — применимо, но снято обоснованным решением. Не проходит: исключение без области, причины, ссылки на решение владельца или условия пересмотра.",
"type": "object",
"additionalProperties": false,
"required": ["id", "requirement", "scope", "reason", "decision_ref", "review_condition"],
"properties": {
"id": {
"type": "string",
"pattern": "^ex-[a-z0-9]+(-[a-z0-9]+)*$",
"description": "Постоянный идентификатор (D-031)."
},
"requirement": { "type": "string", "pattern": "^req-[a-z0-9]+(-[a-z0-9]+)*$" },
"scope": {
"type": "object",
"additionalProperties": false,
"required": ["kind", "description"],
"properties": {
"kind": { "enum": ["path", "capability", "tool", "other"] },
"paths": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
"description": { "type": "string", "minLength": 10 }
},
"allOf": [
{
"if": { "properties": { "kind": { "const": "path" } }, "required": ["kind"] },
"then": { "required": ["paths"], "properties": { "paths": true } }
}
]
},
"reason": { "type": "string", "minLength": 10 },
"decision_ref": {
"type": "string",
"minLength": 3,
"description": "Ссылка на утверждённое решение владельца (например, решение Backlog D-0xx). Без неё исключение неутверждённое."
},
"review_condition": { "type": "string", "minLength": 3 },
"expires": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
"status": {
"enum": ["active", "revoked", "expired"],
"default": "active",
"description": "Состояние исключения; не смешивается с жизненным циклом требования."
}
}
}
@@ -0,0 +1,41 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/project-manifest.schema.json",
"title": "Project Manifest",
"description": "Источник истины о подключении проекта к спецификации (D-008): версия спецификации, выбранные профили/пресеты, проектный слой параметров и исключения. Манифест не переопределяет требования и не дублирует реестр проектов; независимо редактируемые копии конфигурации запрещены — проектные значения живут только здесь.",
"type": "object",
"additionalProperties": false,
"required": ["project", "spec_version", "profiles"],
"properties": {
"project": { "type": "string", "minLength": 1 },
"spec_version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$" },
"profiles": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": { "type": "string", "pattern": "^prof-[a-z0-9]+(-[a-z0-9]+)*$" }
},
"presets": {
"type": "array",
"uniqueItems": true,
"items": { "type": "string", "pattern": "^preset-[a-z0-9]+(-[a-z0-9]+)*$" }
},
"parameter_overrides": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["parameter", "value"],
"properties": {
"parameter": { "type": "string", "pattern": "^param-[a-z0-9]+(-[a-z0-9]+)*$" },
"value": {}
}
}
},
"exceptions": {
"type": "array",
"items": { "$ref": "https://baseline-harness.dev/spec/schemas/project-exception.schema.json" }
},
"note": { "type": "string", "minLength": 3 }
}
}
@@ -0,0 +1,129 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baseline-harness.dev/spec/schemas/requirement.schema.json",
"title": "Atomic Requirement",
"description": "Минимальная независимо проверяемая нормативная единица (D-009, §5 задания 0.1.0). Нормативный уровень, жизненный цикл и статус библиотечного материала — разные сущности (D-029, исправление §5.7 продолжения).",
"type": "object",
"additionalProperties": false,
"required": [
"id",
"domain",
"capability",
"title",
"statement",
"level",
"rationale",
"applicability",
"acceptance_criteria",
"verification",
"expected_evidence",
"lifecycle"
],
"properties": {
"id": {
"type": "string",
"pattern": "^req-[a-z0-9]+(-[a-z0-9]+)*$",
"description": "Постоянный идентификатор (D-031): не зависит от названия, пути и позиции; освобождённые идентификаторы не переиспользуются (проверка — валидатор)."
},
"domain": { "type": "string", "pattern": "^dom-[a-z0-9]+(-[a-z0-9]+)*$" },
"capability": { "type": "string", "pattern": "^cap-[a-z0-9]+(-[a-z0-9]+)*$" },
"title": { "type": "string", "minLength": 3, "maxLength": 120 },
"statement": {
"type": "string",
"minLength": 10,
"description": "Нормативная формулировка с ключевым словом RFC 2119/8174 (D-029); сверка слова с полем level — задача валидатора (BHL-011)."
},
"level": {
"enum": ["MUST", "MUST NOT", "SHOULD", "SHOULD NOT", "MAY"],
"description": "Нормативный уровень; не смешивается с жизненным циклом и статусом библиотеки."
},
"rationale": { "type": "string", "minLength": 10 },
"applicability": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["when"],
"properties": {
"when": { "type": "string", "minLength": 3 },
"unless": { "type": "string", "minLength": 3 }
}
}
},
"parameters": {
"type": "array",
"items": { "$ref": "https://baseline-harness.dev/spec/schemas/parameter.schema.json" },
"description": "Типизированные параметры (D-018); переопределение вне ограничений отклоняет валидатор."
},
"acceptance_criteria": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["criterion"],
"properties": {
"criterion": { "type": "string", "minLength": 3 },
"measure": { "type": "string", "minLength": 3 }
}
}
},
"verification": {
"type": "object",
"additionalProperties": false,
"required": ["kind", "procedure"],
"properties": {
"kind": { "enum": ["deterministic", "semantic", "hybrid"] },
"procedure": { "type": "string", "minLength": 10 },
"automation": { "type": "string", "minLength": 1 }
}
},
"expected_evidence": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["kind", "description"],
"properties": {
"kind": {
"enum": ["file", "command-output", "test-run", "session-observation", "review-note", "hash", "other"]
},
"description": { "type": "string", "minLength": 3 }
}
}
},
"relations": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["target", "kind"],
"properties": {
"target": { "type": "string", "pattern": "^req-[a-z0-9]+(-[a-z0-9]+)*$" },
"kind": { "enum": ["depends-on", "refines", "related", "supersedes"] }
}
}
},
"antipatterns": {
"type": "array",
"items": { "type": "string", "pattern": "^ant-[a-z0-9]+(-[a-z0-9]+)*$" }
},
"lifecycle": {
"type": "object",
"additionalProperties": false,
"required": ["status"],
"properties": {
"status": { "enum": ["draft", "proposed", "accepted", "deprecated", "removed"] },
"since": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
"note": { "type": "string", "minLength": 3 }
}
},
"history_ref": {
"type": "string",
"minLength": 3,
"description": "Ссылка на канонический источник истории нормативных изменений (spec/CHANGELOG.yaml, BHL-016); история не дублируется."
}
}
}
+64
View File
@@ -0,0 +1,64 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
import { readFileSync, readdirSync } from 'node:fs';
import path from 'node:path';
const repoRoot = path.dirname(import.meta.dirname);
const cli = path.join(repoRoot, 'packages', 'bhl', 'src', 'cli.ts');
const specRoot = path.join(repoRoot, 'examples', 'synthetic-spec');
function runCli(...args) {
const proc = spawnSync(process.execPath, [cli, ...args], { encoding: 'utf8', cwd: repoRoot });
return { code: proc.status, stdout: proc.stdout, envelope: JSON.parse(proc.stdout) };
}
test('синтетическая спецификация проходит bhl validate без диагностик', () => {
const result = runCli('validate', specRoot);
assert.equal(result.code, 0);
assert.deepEqual(result.envelope.data.errors, []);
assert.equal(result.envelope.data.files, 8);
});
test('пресет разворачивается в Effective Specification со всеми связями', () => {
const result = runCli('profile', 'resolve', specRoot, '--preset', 'preset-synth-all');
assert.equal(result.code, 0);
const { profiles, effective } = result.envelope.data;
assert.deepEqual(profiles, ['prof-synth-light', 'prof-synth-strict']);
assert.deepEqual(
effective.map((item) => [item.requirement, item.level, item.parameters]),
[
['req-synth-alpha', 'SHOULD', [{ parameter: 'param-synth-budget', value: 4, source: 'prof-synth-light' }]],
['req-synth-beta', 'SHOULD', [{ parameter: 'param-synth-mode', value: 'plain', source: 'prof-synth-strict' }]],
['req-synth-gamma', 'MUST NOT', []],
],
);
const gamma = effective.find((item) => item.requirement === 'req-synth-gamma');
assert.deepEqual(gamma.sources, ['prof-synth-strict']);
});
test('разрешение пресета не зависит от порядка явных профилей', () => {
const first = runCli('profile', 'resolve', specRoot, '--profile', 'prof-synth-light', '--profile', 'prof-synth-strict');
const second = runCli('profile', 'resolve', specRoot, '--profile', 'prof-synth-strict', '--profile', 'prof-synth-light');
assert.equal(first.code, 0);
assert.equal(second.stdout, first.stdout);
});
test('копия схем в примере синхронна с spec/schemas', () => {
const canonical = new Set(readdirSync(path.join(repoRoot, 'spec', 'schemas')));
const copy = new Set(readdirSync(path.join(specRoot, 'schemas')));
assert.deepEqual([...copy].sort(), [...canonical].sort());
for (const name of canonical) {
assert.equal(
readFileSync(path.join(specRoot, 'schemas', name), 'utf8'),
readFileSync(path.join(repoRoot, 'spec', 'schemas', name), 'utf8'),
`расхождение копии схемы ${name}`,
);
}
});
test('пример явно отмечен как инфраструктурный, а не BHS 0.1.0', () => {
const readme = readFileSync(path.join(specRoot, 'README.md'), 'utf8');
assert.ok(readme.includes('не является'), 'отметка о не-стандартности');
assert.ok(readme.includes('BHS 0.1.0'), 'ссылка на содержательную редакцию');
});