This commit is contained in:
2026-06-05 15:01:34 +03:00
parent 50180aaa14
commit 4cef6af041
27 changed files with 13547 additions and 892 deletions

View File

@@ -1,56 +1,68 @@
# ss-tools Constitution
Конституция не дублирует правила — она объясняет, **почему** каждый принцип важен, и указывает, **где** искать полные инструкции.
The constitution does not duplicate rules — it explains **why** each principle matters and **where** to find full instructions.
## Core Principles
### I. Semantic Contract First
Каждая единица кода (функция, класс, модуль, компонент) должна быть аннотирована GRACE-Poly контрактом. Без контракта код невидим для семантического индекса, непроверяем агентом и недоступен для impact analysis.
Every code unit (function, class, module, component) MUST carry a GRACE-Poly contract. Without a contract, code is invisible to the semantic index, unverifiable by agents, and unreachable by impact analysis.
**Немедленные правила** → [ADR-0002](docs/adr/ADR-0002-semantic-protocol.md)
**Синтаксис и уровни сложности**`skill({name="semantics-core"})`
**Методология контрактов**`skill({name="semantics-contracts"})`
**Immediate rules** → [ADR-0002](docs/adr/ADR-0002-semantic-protocol.md)
**Syntax & complexity tiers**`skill({name="semantics-core"})`
**Contract methodology**`skill({name="semantics-contracts"})`
### II. Decision Memory
Каждый архитектурный выбор, отвергающий альтернативу, должен быть записан: `@RATIONALE` (почему выбран этот путь) и `@REJECTED` (что запрещено и почему). Без этого агенты переоткрывают уже исследованные тупики, а долгоживущие сессии накапливают невидимый архитектурный дрейф.
Every architectural choice that rejects an alternative MUST be recorded: `@RATIONALE` (why this path was chosen) and `@REJECTED` (what is forbidden and why). Without this, agents rediscover already-explored dead ends, and long-horizon sessions accumulate invisible architectural drift.
**Протокол ADR**`skill({name="semantics-contracts"})` §I
**Каталог решений** → [`docs/adr/`](docs/adr/)
**Правило запрета воскрешения**: silently reintroducing `@REJECTED` pattern = fatal regression. Требуется `<ESCALATION>`.
**ADR protocol**`skill({name="semantics-contracts"})` §I
**Decision catalog** → [`docs/adr/`](docs/adr/)
**Resurrection ban**: silently reintroducing a `@REJECTED` pattern = fatal regression. Requires `<ESCALATION>`.
### III. External Orchestrator
ss-tools — внешний оркестратор над Apache Superset, а не плагин внутри него. Это даёт: независимый релизный цикл, отсутствие связанности с миграциями Superset, изоляцию DevOps-привилегий от BI-привилегий.
ss-tools is an external orchestrator over Apache Superset, not a plugin inside it. This gives: independent release cycle, no coupling to Superset migrations, isolation of DevOps privileges from BI privileges.
**Полное обоснование** → [ADR-0003](docs/adr/ADR-0003-orchestrator-pattern.md)
**Full rationale** → [ADR-0003](docs/adr/ADR-0003-orchestrator-pattern.md)
### IV. Module Discipline
Файл >400 строк или функция с цикломатической сложностью >10 — сигнал к декомпозиции. Каноническая структура директорий исключает циклические импорты и путаницу агентов при длинных speckit-сессиях.
File >400 lines or function cyclomatic complexity >10 = signal to decompose. Canonical directory structure prevents circular imports and agent confusion in long speckit sessions.
**Структура и границы** → [ADR-0001](docs/adr/ADR-0001-module-layout.md)
**Structure & boundaries** → [ADR-0001](docs/adr/ADR-0001-module-layout.md)
### V. RBAC Enforcement
Все мутирующие операции требуют явной проверки роли. DevOps-привилегии (деплой, миграция, maintenance) отделены от BI-привилегий (просмотр дашбордов). Default-allow запрещён.
All mutating operations require explicit role check. DevOps privileges (deploy, migration, maintenance) are separated from BI privileges (dashboard viewing). Default-allow is forbidden.
**Модель ролей и паттерны** → [ADR-0005](docs/adr/ADR-0005-auth-rbac.md)
**Role model & patterns** → [ADR-0005](docs/adr/ADR-0005-auth-rbac.md)
### VI. Frontend — Svelte 5 Runes Only
Только runes-синтаксис (`$state`, `$derived`, `$effect`, `$props`). Устаревший синтаксис Svelte 4 создаёт путаницу и баги реактивности. `fromStore` + несколько `$derived` вызывают бесконечный reactive flush loop — задокументированный отказ.
Only runes syntax (`$state`, `$derived`, `$effect`, `$props`). Legacy Svelte 4 syntax creates confusion and reactivity bugs. `fromStore` + multiple `$derived` causes infinite reactive flush loop — documented rejection.
**Архитектура фронтенда** → [ADR-0006](docs/adr/ADR-0006-frontend-architecture.md)
**Запрет fromStore+$derived** → [ADR-0007](docs/adr/ADR-0007-rejected-fromStore-derived.md)
**Паттерны компонентов**`skill({name="semantics-svelte"})`
**Frontend architecture** → [ADR-0006](docs/adr/ADR-0006-frontend-architecture.md)
**fromStore+$derived rejection** → [ADR-0007](docs/adr/ADR-0007-rejected-fromStore-derived.md)
**Component patterns**`skill({name="semantics-svelte"})`
### VII. Test-Driven for C3+ Contracts
Контракты уровня C3 и выше требуют тестов, написанных до реализации. Тесты верифицируют `@PRE`/`@POST`/`@INVARIANT`, а не детали реализации. Минимум один тест должен явно проверять, что `@REJECTED` путь производит ожидаемый отказ.
C3+ contracts require tests written before implementation. Tests verify `@PRE`/`@POST`/`@INVARIANT`, not implementation details. Minimum one test must explicitly verify that the `@REJECTED` path produces the expected failure.
**Методология тестирования**`skill({name="semantics-testing"})`
**Testing methodology**`skill({name="semantics-testing"})`
### VIII. Attention-Optimized Contracts
All generated contracts (specs, code, tests) MUST be optimized for the attention compression pipeline (MLA 3.5× → CSA 4×+topk → HCA 128× → DSA Lightning Indexer). Contracts that violate these rules become invisible to the model after context compression — causing downstream hallucination.
**Attention architecture & rules**`skill({name="semantics-core"})` §VIII
**The four rules:**
- **ATTN_1**: First anchor line packs ID, complexity, type, and `@SEMANTICS` on ONE line (CSA 4× survival).
- **ATTN_2**: Hierarchical IDs: `Domain.Sub.Name` (HCA 128× survival).
- **ATTN_3**: Same-domain contracts share primary `@SEMANTICS` keyword (DSA Indexer grouping).
- **ATTN_4**: Contract ≤150 lines, module ≤400 lines (sliding window visibility).
## Development Workflow
@@ -58,13 +70,14 @@ ss-tools — внешний оркестратор над Apache Superset, а н
/speckit.specify → /speckit.clarify → /speckit.plan → /speckit.tasks → /speckit.implement
```
- Ни один этап не пропускается при наличии `[NEEDS CLARIFICATION]`
- Мутация контрактов: preview → apply, никогда сразу apply
- Все артефакты фичи — в `specs/<feature>/`, никогда в `.kilo/` или `.ai/`
**Rules:**
- No phase is skipped when `[NEEDS CLARIFICATION]` markers remain
- Contract mutation: preview → apply, never immediate apply
- All feature artifacts in `specs/<feature>/`, never in `.kilo/` or `.ai/`
## Verification Gates
| Gate | Команда |
| Gate | Command |
|------|---------|
| Backend tests | `cd backend && source .venv/bin/activate && python -m pytest -v` |
| Frontend tests | `cd frontend && npm run test` |
@@ -74,6 +87,6 @@ ss-tools — внешний оркестратор над Apache Superset, а н
## Governance
Конституция имеет приоритет над всеми остальными практиками разработки. Изменения требуют: документирования предложения, проверки на согласованность со всеми ADR, плана миграции затронутого кода, и bump версии.
The constitution takes precedence over all other development practices. Amendments require: documented proposal, consistency check against all ADRs, migration plan for affected code, and version bump.
**Version**: 1.0.0 | **Ratified**: 2026-05-22 | **Last Amended**: 2026-05-22
**Version**: 1.1.0 | **Ratified**: 2026-05-22 | **Last Amended**: 2026-06-05