feat(lessons): машинный журнал уроков — аддитивная таблица + observer-leaf (ORCH-098) #118

Merged
admin merged 11 commits from feature/ORCH-098-fnd into main 2026-06-10 11:02:23 +03:00
Owner

ORCH-098 — FND: машинный журнал уроков (lessons)

Шаг 1 («Фундамент», F2) эпика саморазвития: формализует свободнотекстовые «уроки» из memory/ в машинную структурированную таблицу отклонений конвейера lessons — фундамент для будущих ретроспективщика (E2), приоритизатора RICE (E3) и Стрим.

Что сделано

  • src/lessons.py — чистый observer-leaf (never-raise, kill-switch, паттерн serial_gate/coverage_gate/metrics): record()/get()/update()/snapshot() + слаг-константы. НЕ скоупится по репо (observer-only; пишет уроки про любой репо вкл. enduro; репо-разрез — на выборке).
  • src/db.py — аддитивная идемпотентная таблица lessons в init_db() (+3 индекса, restart-safe); колонки атрибуции нуллабельны и сразу (attribution/target_repo/target_domain, NFR-6 / Слава 10.06; _ensure_column форвард-safe); хелперы record_lesson/get_lessons/update_lesson/lessons_snapshot/lessons_recent_dup_exists.
  • Автозапись 4 типов (source="auto", best-effort, дедуп в окне): gate_failure (_handle_qg_failure_rollbacks), merge_hold (_handle_merge_verify HOLD), transient_retry (launcher._finalize_transient на исчерпании бюджета), deploy_degraded (post-deploy DEGRADED → set_repo_freeze).
  • Эндпоинты GET /lessons / POST /lessons / POST /lessons/{id} + read-only ключ lessons в GET /queue. Выключенный флаг → {"enabled": false}.
  • src/config.pylessons_enabled / lessons_query_limit_default / lessons_dedup_window_s.
  • Docs — CLAUDE.md, docs/architecture/README.md (компонент + схема БД + API-таблица), CHANGELOG.

Инвариант

Журнал — наблюдатель, не Quality Gate: STAGE_TRANSITIONS / QG_CHECKS / check_* / machine-verdict / схемы существующих таблиц — байт-в-байт не тронуты; enduro не затронут (общая БД, аддитивная таблица). never-raise на всех публичных функциях и врезках; kill-switch lessons_enabled=False → полная инертность.

Тесты

tests/test_lessons.py (TC-01…TC-12, unit + integration) — зелёные; полный pytest tests/ -q1564 passed.

ADR

  • docs/work-items/ORCH-098/06-adr/ADR-001-lessons-journal.md
  • сквозной docs/architecture/adr/adr-0033-lessons-journal.md

Refs: ORCH-098

🤖 Generated with Claude Code

## ORCH-098 — FND: машинный журнал уроков (lessons) Шаг 1 («Фундамент», F2) эпика саморазвития: формализует свободнотекстовые «уроки» из `memory/` в **машинную структурированную таблицу отклонений конвейера** `lessons` — фундамент для будущих ретроспективщика (E2), приоритизатора RICE (E3) и Стрим. ### Что сделано - **`src/lessons.py`** — чистый **observer-leaf** (never-raise, kill-switch, паттерн `serial_gate`/`coverage_gate`/`metrics`): `record()`/`get()`/`update()`/`snapshot()` + слаг-константы. **НЕ скоупится по репо** (observer-only; пишет уроки про любой репо вкл. enduro; репо-разрез — на выборке). - **`src/db.py`** — аддитивная идемпотентная таблица `lessons` в `init_db()` (+3 индекса, restart-safe); **колонки атрибуции нуллабельны и сразу** (`attribution`/`target_repo`/`target_domain`, NFR-6 / Слава 10.06; `_ensure_column` форвард-safe); хелперы `record_lesson`/`get_lessons`/`update_lesson`/`lessons_snapshot`/`lessons_recent_dup_exists`. - **Автозапись 4 типов** (`source="auto"`, best-effort, дедуп в окне): `gate_failure` (`_handle_qg_failure_rollbacks`), `merge_hold` (`_handle_merge_verify` HOLD), `transient_retry` (`launcher._finalize_transient` на исчерпании бюджета), `deploy_degraded` (post-deploy `DEGRADED → set_repo_freeze`). - **Эндпоинты** `GET /lessons` / `POST /lessons` / `POST /lessons/{id}` + read-only ключ `lessons` в `GET /queue`. Выключенный флаг → `{"enabled": false}`. - **`src/config.py`** — `lessons_enabled` / `lessons_query_limit_default` / `lessons_dedup_window_s`. - **Docs** — CLAUDE.md, docs/architecture/README.md (компонент + схема БД + API-таблица), CHANGELOG. ### Инвариант Журнал — **наблюдатель, не Quality Gate**: `STAGE_TRANSITIONS` / `QG_CHECKS` / `check_*` / machine-verdict / схемы существующих таблиц — **байт-в-байт не тронуты**; enduro не затронут (общая БД, аддитивная таблица). never-raise на всех публичных функциях и врезках; kill-switch `lessons_enabled=False` → полная инертность. ### Тесты `tests/test_lessons.py` (TC-01…TC-12, unit + integration) — зелёные; полный `pytest tests/ -q` — **1564 passed**. ### ADR - `docs/work-items/ORCH-098/06-adr/ADR-001-lessons-journal.md` - сквозной `docs/architecture/adr/adr-0033-lessons-journal.md` Refs: ORCH-098 🤖 Generated with [Claude Code](https://claude.com/claude-code)
admin added 7 commits 2026-06-10 10:45:13 +03:00
Step 1 ("Foundation", F2) of the self-improvement epic: formalise free-text
"lessons" from memory/ into a machine-readable `lessons` table — the foundation
for the future retrospective agent (E2), the RICE prioritiser (E3) and Стрим.

- src/lessons.py: pure never-raise observer leaf (record/get/update/snapshot),
  kill-switch only, NO repo scope (observer-only; records about any repo incl.
  enduro; repo cut on the read side). Slug-convention constants.
- src/db.py: additive idempotent `lessons` table in init_db() (+3 indexes);
  nullable attribution columns from the start (NFR-6, _ensure_column forward-safe);
  helpers record_lesson/get_lessons/update_lesson/lessons_snapshot/
  lessons_recent_dup_exists (auto-dedup window).
- 4 auto-detectors (best-effort, source="auto", deduped): gate_failure
  (_handle_qg_failure_rollbacks), merge_hold (_handle_merge_verify HOLD),
  transient_retry (launcher._finalize_transient budget-exhaustion), deploy_degraded
  (post-deploy DEGRADED -> set_repo_freeze).
- src/main.py: GET /lessons, POST /lessons, POST /lessons/{id} + read-only
  `lessons` block in GET /queue; off-switch -> {"enabled": false}.
- src/config.py: lessons_enabled / lessons_query_limit_default / lessons_dedup_window_s.
- tests/test_lessons.py: TC-01..TC-12 (unit + integration), all green.
- Docs: CLAUDE.md, docs/architecture/README.md (component + schema + API), CHANGELOG.

Invariant: the journal is an OBSERVER, not a Quality Gate — STAGE_TRANSITIONS /
QG_CHECKS / check_* / machine-verdict / existing table schemas are byte-for-byte
untouched; enduro not affected. never-raise on every public fn + injection.

Refs: ORCH-098
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix(lessons): resolve land-race with ORCH-100 — renumber ADR 0033→0034
All checks were successful
CI / test (push) Successful in 56s
CI / test (pull_request) Successful in 55s
21a47e85d3
Merge-gate auto_rebase_onto_main bounced this branch back: ORCH-100 landed
in main first and claimed global ADR number adr-0033 (adr-0033-sidecar-watchdog),
while this branch had created adr-0033-lessons-journal. Resolved the genuine
land race:

- rebased feature/ORCH-098-fnd onto current origin/main (linear history)
- resolved docs/architecture/README.md component-list conflict — both the
  Lessons-journal and Sidecar-watchdog bullets now coexist
- renamed docs/architecture/adr/adr-0033-lessons-journal.md →
  adr-0034-lessons-journal.md (next free global ADR number) + fixed the
  in-file header
- updated all cross-references (CLAUDE.md, README.md, work-item ADR-001,
  12-review.md) 0033→0034 for the lessons journal; ORCH-100's adr-0033
  (sidecar) left intact
- recovered the ORCH-098 CHANGELOG entry silently dropped by the rebase
  auto-merge (now above ORCH-100, ADR ref corrected to 0034)

No code semantics changed; src/** auto-merged cleanly (ORCH-100 did not
touch src/**). ruff: n/a locally (CI). pytest tests/ -q: 1630 passed.

Refs: ORCH-098
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
admin force-pushed feature/ORCH-098-fnd from b4e76123cb to 21a47e85d3 2026-06-10 10:45:13 +03:00 Compare
admin added 1 commit 2026-06-10 10:49:50 +03:00
reviewer(ET): auto-commit from reviewer run_id=581
All checks were successful
CI / test (push) Successful in 59s
CI / test (pull_request) Successful in 59s
de009822c0
admin added 1 commit 2026-06-10 10:52:55 +03:00
tester(ET): auto-commit from tester run_id=582
All checks were successful
CI / test (push) Successful in 57s
CI / test (pull_request) Successful in 56s
917acf3e1e
admin added 1 commit 2026-06-10 10:55:54 +03:00
docs(ORCH-098): staging gate SUCCESS — 15-staging-log.md
All checks were successful
CI / test (push) Successful in 57s
CI / test (pull_request) Successful in 1m2s
66700123ac
Staging suite (docker exec orchestrator-staging, port 8501) exit 0.
All REAL checks green; C9a/C9b INFRA-WAIVED (ORCH-061).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
admin merged commit af949afc58 into main 2026-06-10 11:02:23 +03:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/orchestrator#118