Files
ss-tools/.specify/templates/plan-template.md
2026-06-09 09:43:34 +03:00

144 lines
8.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Implementation Plan: [FEATURE]
**Branch**: `[###-feature-name]` | **Date**: [DATE] | **Spec**: [link]
**Input**: Feature specification from `/specs/[###-feature-name]/spec.md`
**Note**: This template is filled in by the `/speckit.plan` command. See `.specify/templates/plan-template.md` for the execution workflow.
## Summary
[Extract from feature spec: primary requirement + technical approach from research]
## Technical Context
<!--
ACTION REQUIRED: Replace the content in this section with the technical details
for the project. The structure here is presented in advisory capacity to guide
the iteration process.
-->
**Language/Version**: Python 3.13+ (backend), TypeScript (frontend Svelte 5 runes-only)
**Primary Dependencies**: FastAPI, SQLAlchemy, APScheduler (backend); SvelteKit 5, Vite, Tailwind CSS (frontend)
**Storage**: PostgreSQL 16
**Testing**: pytest (backend), vitest (L1 model tests without render + L2 UX tests with @testing-library/svelte)
**Target Platform**: Linux server (Docker), modern browsers
**Project Type**: web application (FastAPI REST + WebSocket backend, SvelteKit SPA frontend)
**Frontend Architecture**: TypeScript-first, model-first (Screen Models via `.svelte.ts`), runes-only (`$state`, `$derived`, `$effect`), typed callback props (no `createEventDispatcher`)
**Performance Goals**: [domain-specific, e.g., <200ms p95 API latency, 60fps UI]
**Constraints**: [domain-specific, e.g., <100MB memory per container, RBAC enforcement, offline-capable Docker bundle]
**Scale/Scope**: [domain-specific, e.g., 50 concurrent users, 1000 dashboards, 10 plugins]
## Constitution Check
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
[Evaluate against constitution.md and semantics.md. Explicitly confirm semantic protocol compliance, complexity-driven contract coverage, TypeScript-first frontend with typed Screen Models (`.svelte.ts`), UX-state compatibility (Svelte 5 runes-only), async boundaries (FastAPI), API-wrapper rules, RBAC/security constraints (local auth + ADFS SSO), plugin lifecycle rules, and any required belief-state/logging constraints for Complexity 4/5 Python modules.]
## Project Structure
### Documentation (this feature)
```text
specs/[###-feature]/
├── plan.md # This file (/speckit.plan command output)
├── research.md # Phase 0 output (/speckit.plan command)
├── data-model.md # Phase 1 output (/speckit.plan command)
├── quickstart.md # Phase 1 output (/speckit.plan command)
├── traceability.md # Phase 1 output — RTM: Story → Model → API → Task → Test
├── contracts/ # Phase 1 output (/speckit.plan command)
│ ├── modules.md # Module & function contracts
│ └── ux/ # UX contracts (if /speckit.ux was run)
│ ├── alternatives.md # Design space explored
│ ├── decisions.md # Final UX choices
│ ├── screen-models.md # Model inventory
│ ├── api-ux.md # API interaction shapes
│ ├── <screen>-ux.md # Per-screen UX contracts
│ └── design-tokens.md # Applied tokens & reuse
└── tasks.md # Phase 2 output (/speckit.tasks command)
```
### Source Code (repository root)
```text
# Web application (default for this repository)
backend/
├── src/
│ ├── api/ # FastAPI routes
│ ├── core/ # Core services (task_manager, auth, migration, plugins)
│ ├── models/ # SQLAlchemy ORM models
│ ├── services/ # Business logic
│ └── schemas/ # Pydantic schemas
└── tests/ # pytest tests
frontend/
├── src/
│ ├── routes/ # SvelteKit pages
│ ├── lib/
│ │ ├── components/ # Reusable Svelte 5 components (thin rendering layer)
│ │ ├── models/ # Screen Models (.svelte.ts — typed, Svelte-reactive state machines)
│ │ ├── stores/ # Svelte stores (cross-route state: auth, notifications)
│ │ └── api/ # API client modules (fetchApi/requestApi wrappers)
│ ├── types/ # TypeScript DTOs — MUST match backend Pydantic schemas
│ └── services/ # Service layer (gitService, taskService)
└── tests/ # vitest tests
docker/ # Docker configurations
```
**Structure Decision**: This is a web application with separate `backend/` (Python/FastAPI) and `frontend/` (SvelteKit) directories. Docker Compose orchestrates both services plus PostgreSQL.
## Semantic Contract Guidance
> Use this section to drive Phase 1 artifacts, especially `contracts/modules.md`.
> See `semantics-core` §VIII for the attention architecture that these rules optimize for.
### Attention Compliance Gate (MANDATORY — validate before generating contracts)
Every contract generated in Phase 1 MUST pass these checks (from `semantics-core` §VIII):
| Rule | Check | Why |
|------|-------|-----|
| **ATTN_1** | First anchor line packs `[C:N] [TYPE] [SEMANTICS]` on ONE line | CSA 4× pooling spread-out anchors lose detail |
| **ATTN_2** | IDs are hierarchical: `Domain.Sub.Name` | HCA 128× flat IDs become noise |
| **ATTN_3** | Same-domain contracts share primary `@SEMANTICS` keyword | DSA Lightning Indexer scores by keyword match |
| **ATTN_4** | Contract 150 lines, module 400 lines | Sliding window must see entire contract |
### Anchor Syntax (canonical)
- Python: `# #region Domain.Name [C:N] [TYPE TypeName] [SEMANTICS tags]` / `# #endregion Domain.Name`
- Svelte markup: `<!-- #region Domain.Name [C:N] [TYPE Component] [SEMANTICS tags] -->` / `<!-- #endregion Domain.Name -->`
- Svelte/TypeScript model: `// #region Domain.Name [C:N] [TYPE Model] [SEMANTICS tags]` / `// #endregion Domain.Name`
- Markdown/ADR: `## @{ Domain.Name [C:N] [TYPE TypeName]` / `## @} Domain.Name`
- **For modules: `@defgroup Domain Description` on line 2 declares the group.** Child contracts use `@ingroup Domain` to join.
- **Legacy `[DEF:id:Type]` syntax is deprecated** use `#region` format exclusively.
- **Model files use `.svelte.ts` extension** canonical format for contracts with Svelte reactive primitives.
### Complexity & Metadata (typical — all tags allowed at all tiers)
- C1: anchors only (DTOs, simple constants)
- C2: typically adds `@BRIEF`
- C3: typically adds `@RELATION`; Svelte also `@UX_STATE`; TypeScript also `@STATE`/`@ACTION`
- C4: typically adds `@PRE`, `@POST`, `@SIDE_EFFECT`; Svelte also `@UX_FEEDBACK`, `@UX_RECOVERY`
- C5: C4 + `@DATA_CONTRACT`, `@INVARIANT` + `@RATIONALE`/`@REJECTED` decision memory
- **Screen Models** (`[TYPE Model]`) are C4/C5 contracts. Component binds via `@RELATION BINDS_TO -> [ModelId]`. See `semantics-svelte` §IIIa.
### Relations
- Canonical form: `@RELATION PREDICATE -> TARGET_ID`
- Allowed predicates: `DEPENDS_ON`, `CALLS`, `INHERITS`, `IMPLEMENTS`, `DISPATCHES`, `BINDS_TO`, `CALLED_BY`, `VERIFIES`.
- Unknown targets `[NEED_CONTEXT: target]` never invent placeholders.
- **Cross-stack edges are critical**: backend Pydantic schema MUST have `@RELATION` to frontend TypeScript DTO and vice versa (survives HCA 128× cross-stack amnesia).
### Function-Level Contracts (C3+ only)
For C3+ functions that are API endpoints, Screen Model actions, or orchestration functions, generate full `#region` headers with `@PRE`/`@POST`/`@SIDE_EFFECT`/`@DATA_CONTRACT`/`@TEST_EDGE` in `contracts/modules.md` under their parent module. See `speckit.plan.md` "Function-Level Contracts for C3+" for the canonical template. C1/C2 functions do NOT need pre-generated contracts only C3+.
## Complexity Tracking
> **Fill ONLY if Constitution Check has violations that must be justified**
| Violation | Why Needed | Simpler Alternative Rejected Because |
|-----------|------------|-------------------------------------|
| [e.g., 4th plugin] | [current need] | [why 3 plugins insufficient] |
| [e.g., Service layer pattern] | [specific problem] | [why direct ORM access insufficient] |