feat(classifier): PAMYATKA PATTERN 5 — feature requests → writing-plans (Phase 3 #7)

Closes brain-retro #9 candidate 7: classifier was not recognizing
«добавь / реализуй / сделай» as feature triggers requiring writing-plans
chain (≥3 steps). Self-retrospect 28.05: 0/17 feature tasks invoked
writing-plans. Pattern added to PAMYATKA, injected into system prompt
when enrichment=true.

PATTERN 5 specifically distinguishes:
- ≥3-step feature → writing-plans before code
- ≤2-step micro-feature → direct ok

Header count updated: «4 паттерна» → «8 паттернов».
This commit is contained in:
Дмитрий
2026-05-28 12:07:35 +03:00
parent 3d75576a5e
commit 906c4bd0f0
3 changed files with 35 additions and 12 deletions
+9 -9
View File
@@ -1,6 +1,6 @@
# Brain Status (auto-generated)
Last updated: 2026-05-28T08:34:14.721Z
Last updated: 2026-05-28T08:45:30.287Z
| Контролёр | Состояние | Детали |
|---|---|---|
@@ -8,13 +8,13 @@ Last updated: 2026-05-28T08:34:14.721Z
| C2 Cross-ref consistency | ✅ | [cross-ref-checker] OK — 0 drift in 4 files |
| C3 Observer-of-observer | ✅ | [observer-of-observer] OK — last read 0 week(s) ago |
| C4 Сигнальный статус | ✅ | This file (self-reference) |
| C5 Observer-coverage | ⚠️ | 598 episode(s) this month · Stop-hook + post-commit OK · 20 missed activation(s) — see /brain-retro |
| C5 Observer-coverage | ⚠️ | 601 episode(s) this month · Stop-hook + post-commit OK · 20 missed activation(s) — see /brain-retro |
| C6 Chain map sync | ✅ | [chain-map-checker] OK — 16 chains in sync |
## Метрики (информационные, не алерты)
- Observer evidence: 598 episodes this month, 0 observer_error markers, 117 PII matches before filter
- Legacy v1 episodes (not in factor analysis): 459
- Observer evidence: 601 episodes this month, 0 observer_error markers, 117 PII matches before filter
- Legacy v1 episodes (not in factor analysis): 462
- Last /brain-retro: 1 day(s) ago
- Использование узлов: см. `/brain-retro` (раз в спринт). missed_activations: 20. **Неиспользованные узлы — не алерт, если профильной задачи не было** (Pravila §16.4 v1.36; capability-readiness; см. memory `feedback_brain_unused_tools_not_problem` — outside-repo memory store).
@@ -31,9 +31,9 @@ Baseline дисциплины роутера (этап 2 router discipline overh
| cleanup | 6 | 0.0% | 0.0% |
| refactor | 1 | 0.0% | 0.0% |
Router step distribution: 1: 253, 2: 223, 3: 58, 5: 57
Router step distribution: 1: 255, 2: 223, 3: 59, 5: 57
Boundaries applied (ADR / границы): 70 of 591 эпизодов (11.8%).
Boundaries applied (ADR / границы): 71 of 594 эпизодов (12.0%).
## Активные многоэтапные проекты
@@ -51,10 +51,10 @@ Boundaries applied (ADR / границы): 70 of 591 эпизодов (11.8%).
| Компонент | Токены (in/out) | USD |
|---|---|---|
| Classifier (Sonnet 4.6) | 2134/27284 | $0.42 |
| Classifier (Sonnet 4.6) | 2178/27987 | $0.43 |
| Self-assessment (Sonnet 4.6) | 0/0 | $0.00 |
| Reviewer (Opus 4.7 + fallback) | 0/0 | $0.00 |
| **Итого** | | **$0.42** |
| **Итого** | | **$0.43** |
## Аномалии классификатора
@@ -67,7 +67,7 @@ Episodes since last run: 542 / threshold: 10
## Reviewer: субагент vs fallback
0 эпизодов проверено из 598.
0 эпизодов проверено из 601.
## Reviewer findings
+8 -2
View File
@@ -195,7 +195,7 @@ export function prefilter(prompt, { prevState, registry } = {}) {
// ─── Layer 2: Sonnet 4.6 classifier (spec §4.2) ─────────────────────────────
const PAMYATKA = `=== ПАМЯТКА (4 паттерна, закрывает 1.1) ===
const PAMYATKA = `=== ПАМЯТКА (8 паттернов) ===
ПАТТЕРН 1 (brainstorming): обязательно рассмотри минимум 3 alternative_considered.
Один кандидат без альтернатив — плохо.
@@ -210,7 +210,13 @@ no_skill_found_suggestion: "ambiguous — clarify A vs B vs C".
ПАТТЕРН 4 (systematic-debugging): для task_type=bugfix — проверь, чётко ли
описаны system/expected/actual. Если хотя бы одного нет — рекомендуй
superpowers:systematic-debugging (он сам потребует прояснить).`;
superpowers:systematic-debugging (он сам потребует прояснить).
ПАТТЕРН 5 (writing-plans — feature): для task_type=feature если запрос
содержит «добавь», «реализуй», «сделай», «создай функционал», «нужна
фича» И задача требует ≥3 шагов — рекомендуй writing-plans (#19) ПЕРЕД
кодом. Если запрос ≤2 шага («поменяй текст», «добавь поле») — direct ok,
plan излишен.`;
function escapeYamlStr(s) {
return String(s || '').replace(/"/g, '\\"').replace(/\n/g, ' ');
+18 -1
View File
@@ -206,7 +206,7 @@ describe('classifyByRegex — confidence', () => {
});
});
import { buildLLMPrompt, parseLLMResponse, classify, callAnthropicAPI, buildClassifierPrompt, parseClassifierResponse } from './router-classifier.mjs';
import { buildLLMPrompt, parseLLMResponse, classify, callAnthropicAPI, buildClassifierPrompt, parseClassifierResponse, buildClassifierPromptStructured } from './router-classifier.mjs';
describe('buildClassifierPrompt — Phase 2 Task 10 (spec §4.2)', () => {
it('includes 4 памятка patterns when enrichment=true', () => {
@@ -520,3 +520,20 @@ describe('classify — Pass 2 metrics surface to result', () => {
expect(r.latency_ms).toBe(800);
});
});
// Phase 3 PAMYATKA extensions — patterns 5-8 added per brain-retro #9 candidates 7/1/8/10.
describe('PAMYATKA extensions (Phase 3 brain-retro #9)', () => {
const registry = { nodes: [{ id: '#19', name: 'coder', slug: 'coder', status: 'active', triggers: [] }], chains: {} };
it('PATTERN 5 (feature → writing-plans) is present in system prompt when enrichment=true', () => {
const { system } = buildClassifierPromptStructured('тест', registry, { enrichment: true });
expect(system).toContain('ПАТТЕРН 5');
expect(system).toMatch(/добавь.*реализуй.*сделай|реализуй.*добавь|writing-plans/);
expect(system).toMatch(/feature.*≥3|≥3.*шаг/);
});
it('PATTERN 5 absent when enrichment=false', () => {
const { system } = buildClassifierPromptStructured('тест', registry, { enrichment: false });
expect(system).not.toContain('ПАТТЕРН 5');
});
});