docs: Bring all documentation up to date for v2.10.1

- architecture/: overview, technology stack, auth (OIDC + built-in
  IndieAuth), syndication (POSSE) rewritten; new database.md,
  deployment.md and indieweb-protocols.md; legacy stack marked historical
- decisions/: reconstructed ADR-060 and ADR-063; 31 status corrections
  (superseded auth ADRs, proposed -> accepted); INDEX rebuilt
- design/: reconstructed the v1.6.0 documents the webmention code cites;
  reports for 18 v2 releases without a design folder; INDEX rebuilt
- projectplan/: BACKLOG rewritten (shipped items removed, open issues from
  the reviews added); RELEASE.md for v2.0.0-v2.10.1; INDEX
- standards/: development setup (uv, tests, DEV_MODE), testing (CI test
  stage), git and release flow, versioning, coding standards, cookies
- README, CLAUDE.md, .env.example (every setting the code reads, with
  defaults) brought up to date
- 137 broken links repaired (old absolute paths, moved files); stale ADR
  references in code comments corrected (comments only)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PhilandClaude Opus 5.5 committed 2026-11-03 12:40:19 -07:00
1 parent fa551de197
commit 0716984958
143 files changed
+6222 -8660

No files matched your search

+42 -157
View File
@@ -1,169 +1,54 @@
# Standards Documentation Index
# Standards Index
This directory contains coding standards, conventions, processes, workflows, and best practices for StarPunk CMS development.
**Last Updated**: 2026-11-03 (v2.10.1)
## Core Standards
Standards for developing and releasing StarPunk. Folder rules are in
[../DOCUMENTATION.md](../DOCUMENTATION.md). All standards below were checked
against the code at v2.10.1.
### Code Quality
- **[python-coding-standards.md](python-coding-standards.md)** - Python code style, patterns, and best practices
- **[utility-function-patterns.md](utility-function-patterns.md)** - Patterns for writing utility functions
## Active standards
### Testing
- **[testing-checklist.md](testing-checklist.md)** - Comprehensive testing checklist and requirements
| Standard | Covers |
|---|---|
| [development-setup.md](development-setup.md) | uv environment, `.env`, running the app with `DEV_MODE`, running the tests |
| [testing-checklist.md](testing-checklist.md) | What to test, test conventions, the CI test stage, protocol validation tools |
| [git-branching-strategy.md](git-branching-strategy.md) | Branches, commits, **the release process** (worktree, `merge --no-ff`, tag, CI, deploy), migrations |
| [versioning-strategy.md](versioning-strategy.md) | Choosing MAJOR / MINOR / PATCH |
| [version-implementation-guide.md](version-implementation-guide.md) | Where the version lives, changelog entry and design note format |
| [python-coding-standards.md](python-coding-standards.md) | Style, naming, and project patterns (config, database, outbound HTTP, errors, routes, workers) |
| [utility-function-patterns.md](utility-function-patterns.md) | Patterns for small helper functions |
| [cookie-naming-convention.md](cookie-naming-convention.md) | `starpunk_` cookie prefix and the cookies in use |
| [documentation-organization.md](documentation-organization.md) | Templates and conventions for docs (folder rules: DOCUMENTATION.md) |
### Development Workflow
- **[development-setup.md](development-setup.md)** - Development environment setup guide
- **[git-branching-strategy.md](git-branching-strategy.md)** - Git workflow and branching model
- **[versioning-strategy.md](versioning-strategy.md)** - Semantic versioning guidelines
- **[version-implementation-guide.md](version-implementation-guide.md)** - How to implement version changes
## Where to start
### Conventions
- **[cookie-naming-convention.md](cookie-naming-convention.md)** - Cookie naming standards
- **[documentation-organization.md](documentation-organization.md)** - Documentation structure and organization
- **New to the code**: development-setup → python-coding-standards →
testing-checklist.
- **Making a release**: git-branching-strategy (release process), which
links to versioning-strategy and version-implementation-guide.
- **Writing an ADR or design note**: documentation-organization.
## Standards by Category
## Key rules in brief
### Python Development
- **python-coding-standards.md** - Style guide, linting, formatting
- **utility-function-patterns.md** - Reusable code patterns
- `uv` for environments, `uv run` for every command.
- Tests need `SESSION_SECRET`; the full suite takes about 6 minutes, 5 of
them in `tests/test_migration_race_condition.py`.
- Every release: branch in a worktree, bump `__version__` and
`__version_info__`, changelog entry, design note (or ADR amendment),
`git merge --no-ff`, annotated `vX.Y.Z` tag; CI tests and publishes the
image; deploy from the Ansible repository; back up the database first when
there is a migration.
- Formatters and linters are available but not enforced; match the file
you are editing.
### Version Control & Release Management
- **git-branching-strategy.md** - Branch naming, workflow, PRs
- **versioning-strategy.md** - SemVer guidelines, version bumping
- **version-implementation-guide.md** - Step-by-step version changes
## Deprecated standards
### Quality Assurance
- **testing-checklist.md** - Test coverage requirements, test types
Standards that no longer apply move to `DEPRECATED/` (none at
present). Earlier versions of the standards above are in git history.
### Development Environment
- **development-setup.md** - Local setup, dependencies, tools
## Related
### Project Organization
- **documentation-organization.md** - Where to put what docs
- **cookie-naming-convention.md** - Naming consistency
## How to Use These Standards
### For New Developers
1. **Start here**: [development-setup.md](development-setup.md)
2. **Read**: [python-coding-standards.md](python-coding-standards.md)
3. **Understand**: [git-branching-strategy.md](git-branching-strategy.md)
4. **Reference**: Other standards as needed
### Before Writing Code
- [ ] Review [python-coding-standards.md](python-coding-standards.md)
- [ ] Check [utility-function-patterns.md](utility-function-patterns.md) for reusable patterns
- [ ] Create feature branch per [git-branching-strategy.md](git-branching-strategy.md)
### Before Committing Code
- [ ] Run tests per [testing-checklist.md](testing-checklist.md)
- [ ] Verify code follows [python-coding-standards.md](python-coding-standards.md)
- [ ] Update version if needed per [versioning-strategy.md](versioning-strategy.md)
- [ ] Write clear commit message per [git-branching-strategy.md](git-branching-strategy.md)
### Before Creating PR
- [ ] All tests pass ([testing-checklist.md](testing-checklist.md))
- [ ] Documentation updated ([documentation-organization.md](documentation-organization.md))
- [ ] Version bumped if needed ([version-implementation-guide.md](version-implementation-guide.md))
- [ ] PR follows [git-branching-strategy.md](git-branching-strategy.md)
### When Reviewing Code
- [ ] Check adherence to [python-coding-standards.md](python-coding-standards.md)
- [ ] Verify test coverage per [testing-checklist.md](testing-checklist.md)
- [ ] Confirm naming conventions ([cookie-naming-convention.md](cookie-naming-convention.md))
- [ ] Validate documentation ([documentation-organization.md](documentation-organization.md))
## Key Principles
### Code Quality
- **Simplicity First**: "Every line of code must justify its existence"
- **Explicit Over Implicit**: Clear, readable code over clever tricks
- **Type Hints Required**: All functions must have type hints
- **Docstrings Required**: All public functions must have docstrings
### Testing
- **Test-Driven Development**: Write tests before implementation
- **Coverage Requirements**: Minimum 80% coverage, aim for 90%+
- **Test Types**: Unit, integration, and end-to-end tests
- **No Skipped Tests**: All tests must pass
### Version Control
- **Feature Branches**: All work happens in feature branches
- **Atomic Commits**: One logical change per commit
- **Clear Messages**: Commit messages follow conventional commits format
- **No Direct Commits to Main**: All changes via pull requests
### Versioning
- **Semantic Versioning**: MAJOR.MINOR.PATCH format
- **Version Bumping**: Update version in multiple locations consistently
- **Changelog Maintenance**: Document all user-facing changes
- **Tag Releases**: Git tags match version numbers
## Standards Compliance Checklist
Use this checklist for all code contributions:
### Code Standards
- [ ] Follows Python coding standards
- [ ] Uses approved utility patterns
- [ ] Has type hints on all functions
- [ ] Has docstrings on all public functions
- [ ] Passes linting (flake8, black)
### Testing Standards
- [ ] Unit tests written
- [ ] Integration tests if needed
- [ ] All tests pass
- [ ] Coverage meets minimum (80%)
### Git Standards
- [ ] Feature branch created
- [ ] Commits are atomic
- [ ] Commit messages are clear
- [ ] PR description is complete
### Versioning Standards
- [ ] Version updated if needed
- [ ] Changelog updated
- [ ] Version consistent across files
- [ ] Git tag created for releases
### Documentation Standards
- [ ] Code documented
- [ ] README updated if needed
- [ ] ADR created if architectural
- [ ] Implementation report written
## Enforcing Standards
### Automated Enforcement
- **Pre-commit hooks**: Run linting and formatting
- **CI/CD pipeline**: Run tests and checks
- **Code review**: Human verification of standards
### Manual Verification
- **Checklist review**: Use standards compliance checklist
- **Peer review**: Other developers verify adherence
- **Architect review**: For architectural changes
## Updating Standards
Standards are living documents that evolve:
1. **Propose Change**: Create ADR documenting why
2. **Discuss**: Get team consensus
3. **Update Standard**: Modify the relevant standard document
4. **Announce**: Communicate the change to team
5. **Enforce**: Update CI/CD and tooling
## Related Documentation
- **[../architecture/](../architecture/)** - System architecture
- **[../decisions/](../decisions/)** - Architectural Decision Records
- **[../design/](../design/)** - Feature designs
- **[../reports/](../reports/)** - Implementation reports
---
**Last Updated**: 2025-11-25
**Maintained By**: Documentation Manager Agent
**Total Standards**: 9
- [../architecture/](../architecture/): current system design
- [../decisions/](../decisions/): ADRs
- [../design/](../design/): per-release designs and reports
- [../projectplan/](../projectplan/): backlog and release plans
+31 -10
View File
@@ -1,8 +1,9 @@
# Cookie Naming Convention
**Status**: ACTIVE
**Status**: Active
**Date**: 2025-11-18
**Version**: 1.0
**Last Updated**: 2026-11-03 (v2.10.1; cookie list checked against the code)
**Version**: 1.1
## Purpose
@@ -44,9 +45,19 @@ All StarPunk cookies use the `starpunk_` prefix for clear ownership.
### Current Cookies
| Cookie Name | Purpose | Security Attributes | Max Age |
|-------------|---------|---------------------|---------|
| `starpunk_session` | Authentication session token | HttpOnly, Secure (prod), SameSite=Lax | 30 days |
| Cookie Name | Set by | Purpose | Security Attributes | Max Age |
|-------------|--------|---------|---------------------|---------|
| `starpunk_session` | `/auth/callback` (`starpunk/routes/auth.py`, constant `SESSION_COOKIE`) | Admin session token (the token's hash is stored in the `sessions` table) | HttpOnly, SameSite=Lax, Secure when `SITE_URL` starts with `https://` | `SESSION_LIFETIME` days (default 30) |
| `starpunk_session` | `/dev/login` (`starpunk/routes/dev_auth.py`, only with `DEV_MODE=true`) | Same cookie, created without authentication | HttpOnly, SameSite=Lax, never Secure | 30 days (fixed) |
`starpunk_session` is read in `starpunk/auth.py` (`require_auth`),
`starpunk/routes/auth.py`, `starpunk/routes/indieauth.py` (consent screen)
and `starpunk/__init__.py` (`before_request`, so every page knows whether
the owner is logged in), and deleted on logout.
Not cookies: the OIDC login state, nonce and PKCE verifier are kept
server-side in the `oidc_login_state` table, and Micropub clients
authenticate with bearer tokens (`indieauth_tokens` table), never cookies.
### Future Cookies
@@ -149,7 +160,11 @@ StarPunk and Flask cookies can coexist without conflict:
- `starpunk_session` - Application authentication
**Flask cookies** (framework-managed):
- `session` - Flask server-side session (for flash messages)
- `session` - Flask's signed session cookie (signed with `SECRET_KEY`, which
defaults to `SESSION_SECRET`). StarPunk stores flash messages and
`session["next"]`, the page to return to after login (set by
`require_auth` and the IndieAuth consent screen). Keep it to small,
non-secret values: it is signed, not encrypted.
Both are necessary and serve different purposes. Do not interfere with Flask's `session` cookie.
@@ -188,7 +203,7 @@ Both are necessary and serve different purposes. Do not interfere with Flask's `
```python
def test_auth_cookie_name(client):
"""Test authentication uses correct cookie name"""
"""Test authentication uses correct cookie name (app built with DEV_MODE=True)"""
response = client.post("/dev/login")
# Verify correct cookie name
@@ -202,9 +217,9 @@ def test_auth_cookie_name(client):
## References
### Internal Documentation
- **Auth Redirect Loop Fix**: `/docs/reports/2025-11-18-auth-redirect-loop-fix.md`
- **Auth Redirect Loop Fix**: `docs/design/v1.0.0/2025-11-18-auth-redirect-loop-fix.md`
- **ADR-011**: Development Authentication Mechanism
- **ADR-005**: IndieLogin Authentication
- **ADR-064**: OIDC admin login and built-in IndieAuth server (replaced ADR-005, IndieLogin, in v2.0.0)
### External Standards
- [RFC 6265 - HTTP State Management Mechanism (Cookies)](https://tools.ietf.org/html/rfc6265)
@@ -213,6 +228,12 @@ def test_auth_cookie_name(client):
## History
### Version 1.1 (2026-11-03)
- Cookie table checked against v2.10.1: `starpunk_session` lifetime follows
`SESSION_LIFETIME`, Secure follows the `SITE_URL` scheme; dev login cookie
listed; Flask `session` contents and server-side OIDC state documented
- References updated (reports folder no longer exists; ADR-064 replaced ADR-005)
### Version 1.0 (2025-11-18)
- Initial version
- Established `starpunk_` prefix convention
@@ -223,5 +244,5 @@ def test_auth_cookie_name(client):
---
**Document Owner**: StarPunk Architecture Team
**Last Updated**: 2025-11-18
**Last Updated**: 2026-11-03
**Status**: Active Standard
+107 -767
View File
@@ -1,814 +1,154 @@
# Development Setup Standards
# Development Setup
## Purpose
**Status**: Active
**Last Updated**: 2026-11-03 (v2.10.1)
This document defines the standard development setup procedure for StarPunk. It provides step-by-step instructions for developer agents and humans to create a fully functional development environment from scratch.
How to set up a local StarPunk environment, run the app and run the tests.
Each configuration variable is described in [`.env.example`](../../.env.example);
deployment is in [architecture/deployment.md](../architecture/deployment.md).
## Prerequisites
## Requirements
### System Requirements
- Python 3.11 (the container image uses `python:3.11-slim`)
- [uv](https://docs.astral.sh/uv/) for the virtual environment and packages ([ADR-006](../decisions/ADR-006-python-virtual-environment-uv.md))
- git
- Optional: Docker or Podman, to build the image and run the CI test stage locally
- **Operating System**: Linux, macOS, or Windows with WSL2
- **Python**: 3.11 or higher
- **Disk Space**: 500MB minimum
- **Network**: Internet connection for package downloads
## Environment
### Required Tools
- **Python 3.11+**: System Python installation
- **uv**: Python package and environment manager
- **git**: Version control (for cloning repository)
## Installation Steps
### Step 1: Verify Python Installation
The repository has no `pyproject.toml`; dependencies are in
`requirements.txt` (runtime) and `requirements-dev.txt` (adds pytest-cov,
pytest-mock, black, flake8, mypy).
```bash
# Check Python version
python3 --version
# Expected output: Python 3.11.x or higher
```
**If Python 3.11+ is not installed**:
**Ubuntu/Debian**:
```bash
sudo apt update
sudo apt install python3.11 python3.11-venv
```
**macOS**:
```bash
brew install python@3.11
```
**Arch Linux**:
```bash
sudo pacman -S python
```
---
### Step 2: Install uv
**Linux/macOS (Recommended)**:
```bash
# Install via official installer
curl -LsSf https://astral.sh/uv/install.sh | sh
# Verify installation
uv --version
```
**Alternative (via pip)**:
```bash
# Install uv using pip
pip install --user uv
# Verify installation
uv --version
```
**Windows**:
```powershell
# Using PowerShell
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# Verify installation
uv --version
```
**Expected Output**: `uv 0.x.x` (any recent version)
See [ADR-006](/home/phil/Projects/starpunk/docs/decisions/ADR-006-python-virtual-environment-uv.md) for full uv standards.
---
### Step 3: Clone Repository
```bash
# Clone the repository
git clone https://github.com/YOUR_USERNAME/starpunk.git
cd starpunk
# Verify you're in the correct directory
pwd
# Expected: /path/to/starpunk
# List files to confirm
ls -la
# Should see: app.py, requirements.txt, starpunk/, etc.
```
**If starting from scratch without git**:
Create the project structure manually following [Project Structure Design](/home/phil/Projects/starpunk/docs/design/project-structure.md).
---
### Step 4: Create Virtual Environment
```bash
# Create virtual environment using uv
uv venv .venv --python 3.11
# Verify creation
ls -la .venv
# Expected: bin/, lib/, include/, pyvenv.cfg
```
**Verification**:
```bash
# Check Python executable exists
.venv/bin/python --version
# Expected: Python 3.11.x
```
**Important**: Virtual environment is created in `.venv/` directory at project root.
---
### Step 5: Install Dependencies
```bash
# Install all production dependencies
uv pip install -r requirements.txt
# Verify installation
uv pip list
# Expected output should include:
# - Flask (3.0.x)
# - markdown (3.5.x)
# - feedgen (1.0.x)
# - httpx (0.27.x)
# - python-dotenv (1.0.x)
# - pytest (8.0.x)
```
**For Development** (optional):
```bash
# Install development dependencies
git clone https://git.thesatelliteoflove.com/phil/StarPunk.git
cd StarPunk
uv venv --python 3.11 # creates .venv/ (gitignored)
uv pip install -r requirements-dev.txt
# Includes: pytest-cov, black, flake8, mypy
```
**Troubleshooting**:
- If installation fails, check internet connection
- Verify uv is installed correctly: `which uv`
- Check Python version in venv: `.venv/bin/python --version`
Run everything through `uv run`, which picks up `.venv/` automatically:
`uv run pytest`, `uv run flask ...`, `uv run python ...`. Never install into
the system Python.
---
To add a dependency, add a pinned line (`package==X.Y.*`) with a short
comment to `requirements.txt`, then `uv pip install -r requirements.txt`.
The file is maintained by hand; don't overwrite it with `pip freeze`.
### Step 6: Configure Environment
## Configuration
```bash
# Copy environment template
cp .env.example .env
# Edit .env file with your settings
nano .env # or vim, code, etc.
python3 -c "import secrets; print(secrets.token_hex(32))" # paste as SESSION_SECRET
```
**Required Configuration** (edit `.env`):
`starpunk/config.py` loads `.env` (python-dotenv; real environment
variables win) and validates at startup, raising `ValueError` with every
problem it found. What is required depends on the mode:
| Setting | Production | `DEV_MODE=true` |
|---|---|---|
| `SESSION_SECRET` | required | required |
| `SITE_URL`, `SITE_NAME`, `SITE_AUTHOR` | required (have defaults) | same |
| `ADMIN_ME` | required | optional |
| `OIDC_ISSUER`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET`, `OIDC_ADMIN_SUB` | required | optional |
| `DEV_ADMIN_ME` | unused | required |
`TOKEN_ENDPOINT` and `INDIELOGIN_URL` are no longer read (v2.0.0 replaced
IndieLogin with OIDC admin login and a built-in IndieAuth server, ADR-064);
the app logs a warning if they are set.
## Running the app locally
There is no separate database step: `create_app()` creates `DATA_PATH`,
`NOTES_PATH` and the database, and applies pending migrations
(`starpunk/migrations.py`) at startup.
For local work, use development login instead of OIDC
([ADR-011](../decisions/ADR-011-development-authentication-mechanism.md)):
```bash
# Site Configuration
SITE_URL=http://localhost:5000
SITE_NAME=My StarPunk Site
SITE_AUTHOR=Your Name
# Admin Authentication
ADMIN_ME=https://your-website.com
# ^ Replace with YOUR IndieWeb identity URL
# Session Security
SESSION_SECRET=GENERATE_RANDOM_SECRET_HERE
# ^ Generate with: python3 -c "import secrets; print(secrets.token_hex(32))"
# Data Paths
DATA_PATH=./data
NOTES_PATH=./data/notes
DATABASE_PATH=./data/starpunk.db
# Flask Configuration
FLASK_ENV=development
FLASK_DEBUG=1
# in .env
DEV_MODE=true
DEV_ADMIN_ME=http://localhost:5000/
```
**Generate SESSION_SECRET**:
```bash
# Generate cryptographically secure secret
python3 -c "import secrets; print(secrets.token_hex(32))"
# Copy output and paste into .env as SESSION_SECRET value
```
**Important**:
- **NEVER commit `.env` file** to git
- `.env.example` is a template and SHOULD be committed
- Each developer/deployment has their own `.env`
---
### Step 7: Initialize Database
```bash
# Create data directory structure
mkdir -p data/notes
# Initialize database schema
.venv/bin/python -c "from starpunk.database import init_db; init_db()"
# Verify database created
ls -la data/
# Expected: starpunk.db file should exist
uv run flask --app app.py run --debug # http://localhost:5000
```
**Alternative** (if Flask CLI is set up):
```bash
# Initialize via Flask CLI
.venv/bin/flask db init
```
`DEV_MODE=true` registers `/dev/login` (otherwise those routes don't exist),
adds a "Quick Dev Login (No Auth)" button to `/auth/login` and a warning
banner to every page. It sets the `starpunk_session` cookie for
`DEV_ADMIN_ME` without any authentication: never enable it on a reachable
server.
**Verify Database Schema**:
```bash
# Check tables exist
sqlite3 data/starpunk.db ".tables"
Each app process also starts background threads: the webmention worker,
the WebSub hub worker, the memory monitor and, when a crossposting target
is configured, the syndication worker. Turn off what you don't need locally
with `WEBMENTION_WORKER_ENABLED=false`, `WEBSUB_ENABLED=false` and
`METRICS_ENABLED=false`. Leave `GOTOSOCIAL_*`, `BLUESKY_*` and `THREADS_*`
empty unless you mean to post to those accounts.
# Expected output: notes, sessions, tokens, auth_state
```
---
### Step 8: Verify Installation
Production runs the same app under gunicorn (`gunicorn app:app`, see `CMD`
in `Containerfile`). To try the image locally:
```bash
# Run all verification checks
.venv/bin/python -c "
from starpunk.config import load_config
from starpunk.database import verify_db
import flask
print('✓ Flask version:', flask.__version__)
print('✓ Config loads successfully')
print('✓ Database schema verified')
print('✓ Installation complete!')
"
docker build -t starpunk:dev -f Containerfile .
docker run --rm -p 8000:8000 --env-file .env -v ./container-data:/data starpunk:dev
```
**Manual Verification Checklist**:
```bash
# Check virtual environment
[ -d ".venv" ] && echo "✓ Virtual environment exists" || echo "✗ Missing .venv"
# Check Python version
.venv/bin/python --version | grep "3.11" && echo "✓ Python 3.11+" || echo "✗ Wrong Python version"
# Check Flask installed
.venv/bin/python -c "import flask" && echo "✓ Flask installed" || echo "✗ Flask missing"
# Check .env file exists
[ -f ".env" ] && echo "✓ .env configured" || echo "✗ Missing .env"
# Check data directory
[ -d "data/notes" ] && echo "✓ Data directory exists" || echo "✗ Missing data/"
# Check database
[ -f "data/starpunk.db" ] && echo "✓ Database initialized" || echo "✗ Missing database"
```
---
### Step 9: Run Development Server
## Running the tests
```bash
# Run Flask development server
.venv/bin/flask --app app.py run --debug
# Alternative: Run directly
.venv/bin/python app.py
SESSION_SECRET=test uv run pytest # full suite
SESSION_SECRET=test uv run pytest tests/test_websub.py # one file
SESSION_SECRET=test uv run pytest tests/test_micropub.py -k delete -x
```
**Expected Output**:
```
* Serving Flask app 'app.py'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
```
- `SESSION_SECRET` must be set (in `.env` or the environment) because
`load_config()` checks it before the test overrides are applied. The CI
test stage also sets `SITE_URL=http://localhost:5000` and
`ADMIN_ME=https://test.example.com`; set them too to reproduce CI exactly.
- `tests/conftest.py` builds each app with `TESTING=True` and a temporary
`DATA_PATH` and database, so tests never touch `./data`. Under
`TESTING=True` the background workers and memory monitor don't start and
the production OIDC check is skipped.
- `tests/test_migration_race_condition.py` is slow (about 5 minutes). While
iterating, add `--ignore=tests/test_migration_race_condition.py`; run the
full suite before releasing.
- Coverage: `SESSION_SECRET=test uv run pytest --cov=starpunk --cov-report=term-missing`.
- The CI test stage can be reproduced exactly with
`docker build --target test -f Containerfile .` (see
[testing-checklist.md](testing-checklist.md)).
**Access Application**:
- Open browser to: `http://localhost:5000`
- Should see StarPunk homepage
- No notes will exist on first run
**Stop Server**:
- Press `Ctrl+C` in terminal
---
### Step 10: Run Tests
## Useful commands
```bash
# Run all tests
.venv/bin/pytest
# Version
uv run python -c "import starpunk; print(starpunk.__version__)"
# Run with coverage report
.venv/bin/pytest --cov=starpunk tests/
# Inspect the database
sqlite3 data/starpunk.db '.tables'
sqlite3 data/starpunk.db 'SELECT migration_name, applied_at FROM schema_migrations ORDER BY id'
# Run specific test file
.venv/bin/pytest tests/test_database.py
# Run with verbose output
.venv/bin/pytest -v
# Reset local data (deletes notes, media and the database)
rm -rf data/
```
**Expected Output** (once tests are written):
```
======================== test session starts =========================
collected 45 items
tests/test_auth.py ........ [ 17%]
tests/test_database.py ....... [ 33%]
tests/test_feed.py ..... [ 44%]
tests/test_micropub.py .......... [ 66%]
tests/test_notes.py .......... [ 88%]
tests/test_utils.py ..... [100%]
========================= 45 passed in 2.34s =========================
```
---
## Configuration Management
### Environment Variables
All configuration is managed via environment variables loaded from `.env` file.
**Configuration Categories**:
1. **Site Identity**
- `SITE_URL` - Public URL of site
- `SITE_NAME` - Site title
- `SITE_AUTHOR` - Author name
- `SITE_DESCRIPTION` - Site description (for RSS)
2. **Authentication**
- `ADMIN_ME` - Admin's IndieWeb identity URL
- `SESSION_SECRET` - Secret key for session signing
- `SESSION_LIFETIME` - Session duration in days (default: 30)
3. **Data Storage**
- `DATA_PATH` - Base data directory (default: `./data`)
- `NOTES_PATH` - Notes directory (default: `./data/notes`)
- `DATABASE_PATH` - SQLite database path (default: `./data/starpunk.db`)
4. **Flask Settings**
- `FLASK_ENV` - Environment: `development` or `production`
- `FLASK_DEBUG` - Debug mode: `1` (on) or `0` (off)
- `FLASK_SECRET_KEY` - Falls back to `SESSION_SECRET`
5. **External Services**
- `INDIELOGIN_URL` - IndieLogin service URL (default: `https://indielogin.com`)
### Configuration Loading
Configuration is loaded in this priority order:
1. **Environment variables** (highest priority)
2. **`.env` file** (loaded via python-dotenv)
3. **Default values** (in `config.py`)
**Example** (`starpunk/config.py`):
```python
import os
from pathlib import Path
from dotenv import load_dotenv
# Load .env file
load_dotenv()
class Config:
# Site
SITE_URL = os.getenv('SITE_URL', 'http://localhost:5000')
SITE_NAME = os.getenv('SITE_NAME', 'StarPunk')
# Security
SECRET_KEY = os.getenv('SESSION_SECRET')
if not SECRET_KEY:
raise ValueError("SESSION_SECRET must be set in .env")
# Data paths
DATA_PATH = Path(os.getenv('DATA_PATH', './data'))
NOTES_PATH = Path(os.getenv('NOTES_PATH', './data/notes'))
DATABASE_PATH = Path(os.getenv('DATABASE_PATH', './data/starpunk.db'))
# Flask
DEBUG = os.getenv('FLASK_DEBUG', '1') == '1'
ENV = os.getenv('FLASK_ENV', 'development')
```
### Development vs Production Settings
**Development** (`.env`):
```bash
FLASK_ENV=development
FLASK_DEBUG=1
SITE_URL=http://localhost:5000
```
**Production** (`.env`):
```bash
FLASK_ENV=production
FLASK_DEBUG=0
SITE_URL=https://your-domain.com
```
**Key Differences**:
- **Debug mode**: Development has detailed errors, production hides them
- **URL**: Development uses localhost, production uses actual domain
- **HTTPS**: Production requires HTTPS, development doesn't
- **Session cookies**: Production sets `Secure` flag, development doesn't
---
## Common Development Tasks
### Starting Development
```bash
# 1. Activate virtual environment context (via uv)
cd /path/to/starpunk
# 2. Run development server
.venv/bin/flask --app app.py run --debug
# Server runs on http://localhost:5000
```
### Running Tests
```bash
# All tests
.venv/bin/pytest
# Specific module
.venv/bin/pytest tests/test_notes.py
# Specific test
.venv/bin/pytest tests/test_notes.py::test_create_note
# With coverage
.venv/bin/pytest --cov=starpunk --cov-report=html tests/
# Open htmlcov/index.html to view coverage report
```
### Code Formatting
```bash
# Format all Python code
.venv/bin/black starpunk/ tests/
# Check formatting without changing
.venv/bin/black --check starpunk/ tests/
# Format specific file
.venv/bin/black starpunk/notes.py
```
### Linting
```bash
# Lint all code
.venv/bin/flake8 starpunk/ tests/
# Lint specific file
.venv/bin/flake8 starpunk/notes.py
# Type checking (if mypy installed)
.venv/bin/mypy starpunk/
```
### Adding Dependencies
```bash
# 1. Install new package
uv pip install package-name
# 2. Update requirements.txt
uv pip freeze | sort > requirements.txt
# 3. Commit updated requirements.txt
git add requirements.txt
git commit -m "Add package-name dependency"
```
### Database Operations
```bash
# Reset database (WARNING: deletes all data)
rm data/starpunk.db
.venv/bin/python -c "from starpunk.database import init_db; init_db()"
# Backup database
cp data/starpunk.db data/starpunk.db.backup
# Inspect database
sqlite3 data/starpunk.db
# SQL> .tables
# SQL> SELECT * FROM notes;
# SQL> .quit
```
### Creating a Note Manually
```bash
# 1. Create directory for current month
mkdir -p data/notes/$(date +%Y)/$(date +%m)
# 2. Create markdown file
cat > data/notes/$(date +%Y)/$(date +%m)/test-note.md << 'EOF'
This is a test note created manually.
It has **markdown** formatting and `code`.
EOF
# 3. Add to database
.venv/bin/python -c "
from starpunk.notes import scan_and_import_notes
scan_and_import_notes()
"
```
---
## Troubleshooting
### Issue: Virtual Environment Not Found
**Symptom**: `bash: .venv/bin/python: No such file or directory`
**Solution**:
```bash
# Check if .venv exists
ls -la .venv
# If not, create it
uv venv .venv --python 3.11
```
---
### Issue: Import Errors
**Symptom**: `ModuleNotFoundError: No module named 'flask'`
**Solution**:
```bash
# Install dependencies
uv pip install -r requirements.txt
# Verify Flask is installed
.venv/bin/python -c "import flask; print(flask.__version__)"
```
---
### Issue: Database Not Found
**Symptom**: `sqlite3.OperationalError: unable to open database file`
**Solution**:
```bash
# Create data directory
mkdir -p data/notes
# Initialize database
.venv/bin/python -c "from starpunk.database import init_db; init_db()"
# Verify
ls -la data/starpunk.db
```
---
### Issue: Port Already in Use
**Symptom**: `OSError: [Errno 98] Address already in use`
**Solution**:
```bash
# Find process using port 5000
lsof -i :5000
# Kill the process
kill -9 <PID>
# Or use different port
.venv/bin/flask run --port 5001
```
---
### Issue: Missing SESSION_SECRET
**Symptom**: `ValueError: SESSION_SECRET must be set in .env`
**Solution**:
```bash
# Generate secret
python3 -c "import secrets; print(secrets.token_hex(32))"
# Add to .env file
echo "SESSION_SECRET=<generated-secret>" >> .env
```
---
### Issue: Permission Denied on data/
**Symptom**: `PermissionError: [Errno 13] Permission denied: 'data/notes'`
**Solution**:
```bash
# Fix permissions
chmod -R 755 data/
chmod 644 data/starpunk.db # If exists
# Verify
ls -la data/
```
---
## Agent-Specific Standards
### For AI Developer Agents
When setting up development environment, agents MUST:
1. **Use absolute paths** in all bash commands
```bash
# CORRECT
/home/phil/Projects/starpunk/.venv/bin/python
# WRONG
.venv/bin/python
```
2. **Check before creating** virtual environment
```bash
if [ ! -d "/home/phil/Projects/starpunk/.venv" ]; then
uv venv /home/phil/Projects/starpunk/.venv --python 3.11
fi
```
3. **Verify each step** before proceeding
```bash
# Example verification
[ -f "/home/phil/Projects/starpunk/.env" ] || echo "ERROR: .env missing"
```
4. **Never modify global Python**
```bash
# FORBIDDEN
pip install flask
# CORRECT
uv pip install flask # Uses active venv
```
See [ADR-006](/home/phil/Projects/starpunk/docs/decisions/ADR-006-python-virtual-environment-uv.md) for complete agent standards.
---
## Security Considerations
### Secrets Management
**DO**:
- Store all secrets in `.env` file
- Generate strong random secrets
- Use different secrets for dev/production
- Never log secrets
**DON'T**:
- Commit `.env` to version control
- Hardcode secrets in code
- Share secrets via email/chat
- Reuse secrets across projects
### File Permissions
**Recommended Permissions**:
```bash
# Application code
chmod 644 *.py
chmod 755 starpunk/
# Data directory
chmod 755 data/
chmod 755 data/notes/
chmod 644 data/starpunk.db
chmod 644 data/notes/**/*.md
# Configuration
chmod 600 .env # Only owner can read
```
### Development-Only Features
In development mode (FLASK_DEBUG=1):
- Detailed error pages with stack traces
- Auto-reload on code changes
- No HTTPS requirement
- More verbose logging
**NEVER run production with FLASK_DEBUG=1**
---
## Verification Checklist
After completing setup, verify:
- [ ] Python 3.11+ installed
- [ ] uv installed and working
- [ ] Virtual environment created in `.venv/`
- [ ] All dependencies installed
- [ ] `.env` file configured with SESSION_SECRET
- [ ] `data/` directory exists and is gitignored
- [ ] Database initialized with all tables
- [ ] Development server starts successfully
- [ ] Can access http://localhost:5000
- [ ] Tests run successfully
- [ ] Code formatting works (black)
- [ ] Linting works (flake8)
---
## Quick Reference
### Essential Commands
```bash
# Start development server
.venv/bin/flask --app app.py run --debug
# Run tests
.venv/bin/pytest
# Format code
.venv/bin/black starpunk/ tests/
# Install dependency
uv pip install <package>
uv pip freeze | sort > requirements.txt
# Database reset
rm data/starpunk.db
.venv/bin/python -c "from starpunk.database import init_db; init_db()"
# Generate secret
python3 -c "import secrets; print(secrets.token_hex(32))"
```
### File Locations
```
.venv/ # Virtual environment
.env # Configuration (secret, gitignored)
.env.example # Configuration template
requirements.txt # Production dependencies
data/ # User data (gitignored)
starpunk/ # Application code
tests/ # Test suite
```
---
## Next Steps
After setup is complete:
1. Read [Python Coding Standards](/home/phil/Projects/starpunk/docs/standards/python-coding-standards.md)
2. Review [Project Structure](/home/phil/Projects/starpunk/docs/design/project-structure.md)
3. Explore [Architecture Overview](/home/phil/Projects/starpunk/docs/architecture/overview.md)
4. Start implementing features following [API Contracts](/home/phil/Projects/starpunk/docs/design/api-contracts.md)
---
| Symptom | Cause |
|---|---|
| `SESSION_SECRET must be set in .env file` (also from pytest) | `SESSION_SECRET` missing from `.env` and the environment |
| `Production mode requires OIDC_ISSUER to be set` | `DEV_MODE` is not `true` and OIDC is not configured |
| `DEV_MODE=true requires DEV_ADMIN_ME to be set` | set `DEV_ADMIN_ME` |
| `ModuleNotFoundError` | run through `uv run` after `uv pip install -r requirements-dev.txt` |
| `/dev/login` returns 404 | `DEV_MODE` is not `true` |
## References
- [ADR-006: Python Virtual Environment with uv](/home/phil/Projects/starpunk/docs/decisions/ADR-006-python-virtual-environment-uv.md)
- [Project Structure Design](/home/phil/Projects/starpunk/docs/design/project-structure.md)
- [Python Coding Standards](/home/phil/Projects/starpunk/docs/standards/python-coding-standards.md)
- [Flask Configuration Handling](https://flask.palletsprojects.com/en/3.0.x/config/)
- [python-dotenv Documentation](https://pypi.org/project/python-dotenv/)
- [uv Documentation](https://docs.astral.sh/uv/)
- [ADR-006: Python virtual environment with uv](../decisions/ADR-006-python-virtual-environment-uv.md)
- [ADR-011: Development authentication](../decisions/ADR-011-development-authentication-mechanism.md)
- [ADR-064: OIDC admin login and built-in IndieAuth server](../decisions/ADR-064-oidc-admin-login-and-builtin-indieauth-server.md)
- [python-coding-standards.md](python-coding-standards.md), [testing-checklist.md](testing-checklist.md), [git-branching-strategy.md](git-branching-strategy.md)
+65 -439
View File
@@ -1,472 +1,98 @@
# Documentation Organization Standard
# Documentation Organization
## Purpose
**Status**: Active
**Last Updated**: 2026-11-03 (v2.10.1)
This document defines the organization and structure of all StarPunk documentation. It establishes clear guidelines for what types of documents belong where, naming conventions, and when to create each type.
**[docs/DOCUMENTATION.md](../DOCUMENTATION.md) is authoritative** for what
goes in which folder and supersedes this document. This standard only adds
templates and conventions for writing the documents; it does not repeat
the folder rules. If the two ever disagree, follow DOCUMENTATION.md and fix
this file.
## Philosophy
Documentation follows the same principle as code: "Every document must justify its existence." Documents should be:
- **Actionable**: Provide clear guidance for implementation
- **Discoverable**: Easy to find based on purpose
- **Maintainable**: Updated as decisions evolve
- **Minimal**: No redundant or unnecessary documentation
## Directory Structure
## Layout at a glance
```
docs/
├── architecture/ # High-level system design and overviews
├── decisions/ # Architecture Decision Records (ADRs)
├── design/ # Detailed technical designs and specifications
└── standards/ # Coding standards, conventions, and guidelines
├── DOCUMENTATION.md folder rules (authoritative)
├── architecture/ current system design, refreshed each release; INDEX.md
├── decisions/ ADR-NNN-title.md; INDEX.md
├── design/ vX.Y.Z/ per release: designs, Q&A, reports, reviews; INDEX.md
├── projectplan/ BACKLOG.md, vX.Y.Z/RELEASE.md; INDEX.md
└── standards/ this folder; INDEX.md; DEPRECATED/ for retired standards
```
## Document Types
Outside `docs/`: `README.md` (overview and quick start), `CHANGELOG.md`
(every release), `.env.example` (every setting), `CLAUDE.md` (agent
instructions).
### 1. Architecture Documents (`docs/architecture/`)
## Conventions for every document
**Purpose**: High-level system architecture, component relationships, and technology overviews.
- Start with a `# Title`, then `**Status**` and `**Last Updated**` lines
(date and the release it describes) for documents meant to stay current
(architecture, standards).
- Link with **relative paths** (`../decisions/ADR-064-...md`), never absolute
filesystem paths.
- Say what is true of the code now; history belongs in ADRs, design notes
and the changelog. When describing something that changed, name the
release ("since v2.8.1").
- Don't copy content between documents: link to the one place it lives.
Settings are documented in `.env.example`, releases in `CHANGELOG.md`,
the release process in
[git-branching-strategy.md](git-branching-strategy.md).
- Update the folder's `INDEX.md` when adding, retiring or renaming a
document.
**When to Create**:
- Describing the overall system architecture
- Documenting major subsystems and their interactions
- Explaining technology stack choices (overview)
- Defining deployment architecture
- Documenting security architecture
- Creating data flow diagrams
## Architecture decision records
**Naming Convention**: `{topic}.md`
File: `docs/decisions/ADR-NNN-short-title.md`, next free number. Create one
when choosing between technical approaches, adopting a protocol, or
establishing a pattern. Template (as in ADR-064 to ADR-071):
**Examples**:
- `overview.md` - System architecture overview
- `components.md` - Component descriptions and relationships
- `data-flow.md` - How data moves through the system
- `security.md` - Security architecture and threat model
- `deployment.md` - Deployment architecture and strategies
- `technology-stack.md` - Complete technology stack with rationale
**Characteristics**:
- Broad scope, high-level view
- Focus on "what" and "why" at system level
- Includes diagrams and visual representations
- Describes component interactions
- Documents architectural patterns
- References relevant ADRs
**Template Structure**:
```markdown
# {Topic} Architecture
## Overview
[High-level description]
## Components
[Major components and their roles]
## Interactions
[How components communicate]
## Patterns
[Architectural patterns employed]
## Diagrams
[Visual representations]
## References
[Links to related ADRs and design docs]
```
---
### 2. Architecture Decision Records (`docs/decisions/`)
**Purpose**: Document significant architectural decisions with context, rationale, and alternatives considered.
**When to Create**:
- Selecting technologies or libraries
- Choosing between architectural approaches
- Making trade-offs that affect multiple components
- Establishing patterns or standards
- Accepting technical debt
- Rejecting common alternatives
**Naming Convention**: `ADR-{NNN}-{short-title}.md`
- NNN = Zero-padded sequential number (001, 002, etc.)
- short-title = Kebab-case description
**Examples**:
- `ADR-001-python-web-framework.md`
- `ADR-002-flask-extensions.md`
- `ADR-003-frontend-technology.md`
- `ADR-004-file-based-note-storage.md`
- `ADR-005-indielogin-authentication.md`
- `ADR-006-python-virtual-environment-uv.md`
**Characteristics**:
- Focused on a single decision
- Documents the decision-making process
- Includes evaluation criteria
- Lists alternatives considered with scores
- Explains trade-offs and consequences
- Has a status (Proposed, Accepted, Superseded)
- Immutable once accepted (new ADR to change)
**Required Template**:
```markdown
# ADR-{NNN}: {Title}
# ADR-NNN: Title
## Status
{Proposed|Accepted|Superseded by ADR-XXX}
Proposed | Accepted (vX.Y.Z, YYYY-MM-DD) | Superseded by ADR-MMM
## Context
What is the issue we're addressing? What are the requirements?
What constraints do we face?
The problem, constraints, and relevant spec (with link).
## Decision
What have we decided? Be specific and clear.
## Rationale
Why did we make this decision?
### {Technology/Approach} Score: X/10
- Simplicity Score: X/10 - [explanation]
- Fitness Score: X/10 - [explanation]
- Maintenance Score: X/10 - [explanation]
- Standards Compliance: Pass/Fail - [explanation]
What we will do. Numbered subsections for larger designs, citing spec
sections.
## Consequences
What gets better, what gets worse, what to watch.
### Positive
- [List benefits]
## Alternatives considered
Each alternative and why it was not chosen.
### Negative
- [List drawbacks]
### Mitigation
- [How we address drawbacks]
## Alternatives Considered
### {Alternative 1} (Rejected/Considered)
- Simplicity: X/10 - [explanation]
- Fitness: X/10 - [explanation]
- Maintenance: X/10 - [explanation]
- Verdict: [Why rejected]
### {Alternative 2} (Rejected/Considered)
[Same structure]
## Implementation Notes
[Any specific guidance for implementing this decision]
## References
- [Links to specifications, documentation, related ADRs]
## Amendments (vX.Y.Z, YYYY-MM-DD)
Later changes to the decision, newest last.
```
**Status Values**:
- **Proposed**: Decision is under consideration
- **Accepted**: Decision is final and should be implemented
- **Superseded**: Decision has been replaced (link to new ADR)
ADRs are not rewritten after acceptance. Change them with an
**Amendments** section, or supersede them with a new ADR and set the old
one's status to "Superseded by ADR-MMM".
**Numbering Rules**:
- Numbers are sequential starting from 001
- Never reuse or skip numbers
- Numbers are assigned when ADR is created, not when accepted
- Numbers provide chronological history
## Design notes
---
### 3. Design Documents (`docs/design/`)
**Purpose**: Detailed technical specifications for implementation, including schemas, APIs, file formats, and component interfaces.
**When to Create**:
- Defining database schemas
- Specifying API contracts and endpoints
- Designing file formats and structures
- Defining component interfaces
- Specifying configuration formats
- Documenting project structure
- Creating initial setup specifications
**Naming Convention**: `{component-or-feature}.md`
**Examples**:
- `project-structure.md` - Complete directory and file organization
- `database-schema.md` - Database tables, columns, indexes, relationships
- `api-contracts.md` - RESTful API endpoint specifications
- `micropub-endpoint.md` - Micropub API implementation details
- `rss-feed-format.md` - RSS feed structure and generation
- `ui-patterns.md` - User interface patterns and components
- `component-interfaces.md` - How components communicate
- `initial-files.md` - Bootstrap files and configurations
- `authentication-flow.md` - Detailed auth implementation
**Characteristics**:
- Detailed and specific
- Implementation-ready specifications
- Includes code examples, schemas, formats
- Defines exact file contents when applicable
- Provides acceptance criteria
- Focus on "how" at implementation level
- Should be sufficient for developer to implement
**Template Structure**:
```markdown
# {Component/Feature} Design
## Purpose
[What this component/feature does]
## Overview
[High-level description]
## Specification
### {Aspect 1}
[Detailed specification with examples]
### {Aspect 2}
[Detailed specification with examples]
## Implementation Details
### File Structure
[If applicable]
### API Endpoints
[If applicable]
### Database Schema
[If applicable]
### Configuration
[If applicable]
## Examples
[Concrete examples of usage]
## Acceptance Criteria
[How to verify correct implementation]
## References
[Related ADRs, standards, specifications]
```
---
### 4. Standards Documents (`docs/standards/`)
**Purpose**: Establish coding conventions, development practices, and guidelines that ensure consistency.
**When to Create**:
- Defining coding style guidelines
- Establishing naming conventions
- Documenting development setup procedures
- Creating testing standards
- Defining commit message formats
- Establishing documentation standards
- Setting API design principles
**Naming Convention**: `{topic}-standards.md` or `{topic}-setup.md`
**Examples**:
- `documentation-organization.md` - This document
- `python-coding-standards.md` - Python style guide
- `development-setup.md` - Setup procedures
- `testing-strategy.md` - Testing approach and standards
- `api-design.md` - API design principles
- `indieweb-compliance.md` - How to meet IndieWeb specs
- `commit-conventions.md` - Git commit standards
**Characteristics**:
- Prescriptive and normative
- Define consistent practices
- Include examples of good/bad patterns
- Focus on "how we work"
- Living documents (updated as practices evolve)
- Should include rationale for standards
**Template Structure**:
```markdown
# {Topic} Standards
## Purpose
[Why these standards exist]
## Principles
[Core principles underlying the standards]
File: `docs/design/vX.Y.Z/YYYY-MM-DD-topic.md`, one folder per release
(rules in DOCUMENTATION.md). For format, see
[version-implementation-guide.md](version-implementation-guide.md#design-note).
## Standards
### {Standard Category 1}
[Detailed standard with examples]
File: `docs/standards/topic.md`. Each standard states what is required, why,
and how to check it, and is kept true to the code. A standard that no
longer applies is moved to `docs/standards/DEPRECATED/` with a note at the
top saying what replaced it, and removed from the active list in
`standards/INDEX.md`.
**Good Example**:
```[code/example]
```
## Retiring other documents
**Bad Example**:
```[code/example]
```
**Rationale**: [Why this is the standard]
### {Standard Category 2}
[Same structure]
## Enforcement
[How standards are enforced - tools, reviews, etc.]
## Exceptions
[When it's acceptable to deviate]
## References
[Related standards, tools, specifications]
```
---
## Cross-References
Documents should reference each other appropriately:
- **ADRs** → Should be referenced by Architecture, Design, and Standards docs
- **Architecture** → References ADRs, links to Design docs
- **Design** → References ADRs, may reference Standards
- **Standards** → May reference ADRs for rationale
**Reference Format**:
```markdown
See [ADR-001: Python Web Framework](/home/phil/Projects/starpunk/docs/decisions/ADR-001-python-web-framework.md)
See [Database Schema Design](/home/phil/Projects/starpunk/docs/design/database-schema.md)
See [Python Coding Standards](/home/phil/Projects/starpunk/docs/standards/python-coding-standards.md)
```
## Document Lifecycle
### Creating Documents
1. **Determine Type**: Which category does this belong in?
2. **Check for Existing**: Does a similar document already exist?
3. **Name Appropriately**: Follow naming conventions
4. **Use Template**: Start from the appropriate template
5. **Be Specific**: Include actionable details
6. **Reference Related Docs**: Link to ADRs and other docs
### Updating Documents
**ADRs**: Once accepted, ADRs are immutable. To change a decision:
- Create a new ADR
- Reference the old ADR
- Mark old ADR as "Superseded by ADR-XXX"
**Other Documents**: Living documents that should be updated:
- Add changelog section if document changes significantly
- Update references when related docs change
- Keep in sync with actual implementation
### Deprecating Documents
**Don't Delete**: Mark as deprecated instead
- Add "DEPRECATED" to title
- Add note explaining why and what replaced it
- Keep for historical reference
## Quality Checklist
Before finalizing any document:
- [ ] Is this the right document type for this content?
- [ ] Is the file in the correct directory?
- [ ] Does it follow the naming convention?
- [ ] Does it use the appropriate template?
- [ ] Is the content actionable and specific?
- [ ] Are all references correct and complete?
- [ ] Are there code examples where helpful?
- [ ] Is the rationale clear?
- [ ] Can a developer implement from this?
- [ ] Have I removed unnecessary content?
## Anti-Patterns
**Avoid**:
- Mixing document types (ADR with design specs)
- Redundant documentation (saying same thing in multiple places)
- Vague specifications ("should be fast", "user-friendly")
- Missing rationale (standards without explaining why)
- Orphaned documents (not referenced anywhere)
- Documentation for documentation's sake
- Copy-pasting without adapting
## Tools and Automation
**Validation**:
- Check links: Ensure all references point to existing files
- Naming validation: Verify naming conventions
- Template compliance: Ensure required sections exist
**Future Enhancements** (V2):
- Automated ADR numbering
- Documentation index generator
- Link checker
- Template enforcement
## Examples
### When to Create Which Document Type
**Scenario**: Choosing between SQLite and PostgreSQL
→ Create an ADR (`ADR-007-database-engine.md`)
- This is a technology decision
- Needs evaluation of alternatives
- Has long-term architectural impact
**Scenario**: Defining the exact database schema
→ Create a Design doc (`database-schema.md`)
- This is detailed specification
- Implementation-ready
- May evolve as requirements change
**Scenario**: Establishing how to write database migrations
→ Create a Standards doc (`database-migration-standards.md`)
- This is a practice/process
- Defines consistent approach
- Applies to all database changes
**Scenario**: Explaining how authentication, database, and file storage work together
→ Create an Architecture doc or update existing (`architecture/overview.md`)
- This is system-level interaction
- Cross-component relationship
- High-level understanding
## Summary
| Type | Purpose | Location | Mutability | Naming |
|------|---------|----------|------------|--------|
| **Architecture** | System-level design | `docs/architecture/` | Living | `{topic}.md` |
| **ADR** | Decision records | `docs/decisions/` | Immutable | `ADR-{NNN}-{title}.md` |
| **Design** | Implementation specs | `docs/design/` | Living | `{component}.md` |
| **Standards** | Coding/process guidelines | `docs/standards/` | Living | `{topic}-standards.md` |
## Principles Summary
1. **One Document Type Per File**: Don't mix ADR with Design specs
2. **Right Place, Right Name**: Follow conventions strictly
3. **Actionable Content**: Documentation should enable implementation
4. **Minimal but Complete**: Every document must justify its existence
5. **Reference Richly**: Link to related documents
6. **Update Living Docs**: Keep non-ADR docs current
7. **Never Delete**: Deprecate instead for historical reference
## References
- Michael Nygard's ADR pattern: https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions
- Arc42 documentation: https://arc42.org/
- Diátaxis documentation framework: https://diataxis.fr/
- Architecture documents describing a design that no longer exists are
either rewritten or renamed with a `-legacy` suffix and a note at the top
(e.g. `architecture/technology-stack-legacy.md`).
- Design notes and ADRs are historical records and stay where they are.
+129 -676
View File
@@ -1,724 +1,177 @@
# Git Branching Strategy
# Git Branching and Release Process
## Overview
**Status**: Active
**Last Updated**: 2026-11-03 (v2.10.1)
This document defines the git branching strategy for StarPunk. The strategy balances simplicity with discipline, appropriate for a personal/small-team project while supporting semantic versioning and clean releases.
How changes reach `main`, how releases are cut, and what happens after a
tag is pushed. This is the flow used for the v2 releases (see
`git log --merges`). Which version number to use is in
[versioning-strategy.md](versioning-strategy.md). The original reasoning is
in [ADR-009](../decisions/ADR-009-git-branching-strategy.md); where they
differ, this document describes current practice.
**Philosophy**: Keep it simple. Minimize long-lived branches. Integrate frequently.
## Principles
## Primary Branch
- `main` is always releasable and is never rewritten or force-pushed.
- Each release is built on its own short-lived branch, usually as a single
commit, and merged with `--no-ff` so `main` shows one merge per release.
- Every release is an annotated `vX.Y.Z` tag on `main`. The tag is what
triggers CI; CI is what publishes the image.
- Several agents may work on the repository at once, so each works in its
own git worktree, never in the main checkout's working tree.
**Branch**: `main`
## Branches
**Purpose**: The primary development branch and source of truth
| Prefix | Use | Example |
|---|---|---|
| `feat/` | new behaviour (MINOR) | `feat/v2.10.0-websub` |
| `fix/` | bug and security fixes (PATCH) | `fix/v2.10.1-websub-hardening` |
| `ci/` | build and CI changes | `ci/v2.7.1-pytest` |
| `docs/` | documentation only, no release | `docs/refresh-v2.10.1` |
**Characteristics**:
- Always contains the latest development code
- Should be stable and pass all tests
- Protected from direct commits (use pull requests)
- Tagged for releases
- Never rewritten or force-pushed
Release branches are named `<prefix>/vX.Y.Z-<short-description>`, so the
branch already states the version it will become. (Releases before v2.6.0
used `feature/`; read old history with that in mind.) There are no long-lived
`develop`, `release/` or `hotfix/` branches: a production fix is just the
next PATCH release from `main`.
**Version state**: Development version (0.x.y) until first stable release (1.0.0)
## Commits
## Branch Types
Conventional-commit style subject, with the version in parentheses on the
release commit:
### Feature Branches
**Naming**: `feature/<description>` or `<description>`
**Purpose**: Develop new features or enhancements
**Lifecycle**:
- Branch from: `main`
- Merge into: `main`
- Delete after: Merged or abandoned
**Examples**:
- `feature/micropub-endpoint`
- `feature/rss-feed`
- `indieauth-integration`
- `note-markdown-support`
**Workflow**:
```bash
# Create feature branch
git checkout -b feature/micropub-endpoint main
# Work on feature
git add .
git commit -m "Add micropub endpoint skeleton"
# Keep updated with main
git fetch origin
git rebase origin/main
# When ready, create pull request or merge
git checkout main
git merge feature/micropub-endpoint
# Delete feature branch
git branch -d feature/micropub-endpoint
```
feat: WebSub with a built-in hub (v2.10.0)
fix: Hold the migration lock for the whole run (v2.8.1)
ci: Run the test suite before building release images (v2.7.1)
docs: ADR-071 WebSub publishing with a built-in hub (proposed)
```
### Fix Branches
Types in use: `feat`, `fix`, `ci`, `docs`, `style`, `refactor`, `test`,
`chore`. The body explains why, not what. Commits made by an agent end with
the attribution trailer the agent was given.
**Naming**: `fix/<description>` or `bugfix/<description>`
An ADR can land on `main` ahead of its implementation (`docs:` commit,
status "Proposed"), as ADR-071 did before v2.10.0.
**Purpose**: Fix bugs in development code
## Release process
**Lifecycle**:
- Branch from: `main`
- Merge into: `main`
- Delete after: Merged
**Examples**:
- `fix/slug-generation-unicode`
- `bugfix/rss-invalid-xml`
- `fix/auth-redirect-loop`
**Workflow**: Same as feature branches
### Hotfix Branches
**Naming**: `hotfix/<version>-<description>`
**Purpose**: Critical fixes to production releases (post-1.0.0)
**Lifecycle**:
- Branch from: Release tag (e.g., `v1.0.0`)
- Merge into: `main`
- Tag as new release: `v1.0.1`
- Delete after: Released
**Examples**:
- `hotfix/1.0.1-security-path-traversal`
- `hotfix/1.1.1-rss-encoding`
**Workflow**:
```bash
# Create hotfix from release tag
git checkout -b hotfix/1.0.1-security-fix v1.0.0
# Fix the issue
git commit -m "Fix security vulnerability"
# Update version
# Edit starpunk/__init__.py: __version__ = "1.0.1"
# Update CHANGELOG.md
git commit -m "Bump version to 1.0.1"
# Tag the hotfix
git tag -a v1.0.1 -m "Hotfix 1.0.1: Security vulnerability fix"
# Merge into main
git checkout main
git merge hotfix/1.0.1-security-fix
# Push
git push origin main v1.0.1
# Delete hotfix branch
git branch -d hotfix/1.0.1-security-fix
```
### Release Branches (Optional)
**Naming**: `release/<version>`
**Purpose**: Prepare for release (testing, docs, version bumps)
**Used when**: Release preparation requires multiple commits and testing
**Note**: For V1 (simple project), we likely don't need release branches. We can prepare releases directly on `main` or feature branches.
**If used**:
```bash
# Create release branch
git checkout -b release/1.0.0 main
# Prepare release
# - Update version numbers
# - Update CHANGELOG.md
# - Update documentation
# - Final testing
git commit -m "Prepare release 1.0.0"
# Tag
git tag -a v1.0.0 -m "Release 1.0.0: First stable release"
# Merge to main
git checkout main
git merge release/1.0.0
# Push
git push origin main v1.0.0
# Delete release branch
git branch -d release/1.0.0
```
## Branch Naming Conventions
### Format
**Preferred**: `<type>/<description>`
**Types**:
- `feature/` - New features
- `fix/` - Bug fixes
- `bugfix/` - Bug fixes (alternative)
- `hotfix/` - Production hotfixes
- `docs/` - Documentation only
- `refactor/` - Code refactoring
- `test/` - Test additions/changes
- `chore/` - Maintenance tasks
**Description**:
- Use lowercase
- Use hyphens to separate words
- Be descriptive but concise
- Reference issue number if applicable
### Examples
**Good**:
- `feature/micropub-create-action`
- `fix/rss-pubdate-timezone`
- `docs/api-documentation`
- `refactor/note-storage-layer`
- `test/slug-generation-edge-cases`
- `chore/update-dependencies`
**Acceptable** (simple description):
- `micropub-endpoint`
- `rss-feed`
- `auth-integration`
**Avoid**:
- `my-feature` (too vague)
- `feature/Feature1` (not descriptive)
- `fix_bug` (use hyphens)
- `FEATURE-MICROPUB` (use lowercase)
## Workflows
### Development Workflow (Pre-1.0)
**For single developer**:
1. Work directly on `main` for small changes
2. Use feature branches for larger features
3. Commit frequently with clear messages
4. Tag development milestones (e.g., `v0.1.0`)
**For multiple developers**:
1. Always use feature branches
2. Create pull requests
3. Review before merging
4. Delete feature branches after merge
### Feature Development
### 1. Branch in a worktree
```bash
# Start feature
git checkout -b feature/new-feature main
# Develop
git add file.py
git commit -m "Implement core functionality"
# Keep updated
git fetch origin
git rebase origin/main
# Finish
git checkout main
git merge feature/new-feature
git push origin main
git branch -d feature/new-feature
cd ~/Documents/projects/StarPunk # main checkout, on main
git pull
git worktree add ../StarPunk-worktrees/v2.10.1 -b fix/v2.10.1-websub-hardening main
cd ../StarPunk-worktrees/v2.10.1
uv venv --python 3.11 && uv pip install -r requirements-dev.txt
```
### Release Workflow
### 2. Make the change
**For development releases (0.x.y)**:
Code, tests and docs together:
- [ ] Code and tests (see [testing-checklist.md](testing-checklist.md))
- [ ] Schema change? Add the next numbered file in `migrations/` (see
[Migrations](#migrations))
- [ ] New setting? Read it in `starpunk/config.py` and document it in
`.env.example`
- [ ] Architectural decision? New ADR in `docs/decisions/`, or an
"Amendments" section on the existing one
- [ ] Bump the version in `starpunk/__init__.py`: both `__version__` and
`__version_info__` ([version-implementation-guide.md](version-implementation-guide.md))
- [ ] Add a `## [X.Y.Z] - YYYY-MM-DD` entry at the top of `CHANGELOG.md`
- [ ] Add a design note `docs/design/vX.Y.Z/YYYY-MM-DD-<topic>.md` (what
changed and why, how it was verified). Small releases fully covered by
an ADR amendment and the changelog may skip it
- [ ] Full test suite passes:
`SESSION_SECRET=test uv run pytest`
Commit (usually one commit):
```bash
# Ensure on main
git checkout main
# Update version
# Edit starpunk/__init__.py
# Update CHANGELOG.md
# Commit
git add starpunk/__init__.py CHANGELOG.md
git commit -m "Bump version to 0.2.0"
# Tag
git tag -a v0.2.0 -m "Development release 0.2.0: Phase 1.2 complete"
# Push
git push origin main v0.2.0
git add -A
git commit -m "fix: WebSub hardening from the adversarial review (v2.10.1)"
```
**For stable releases (1.0.0+)**:
### 3. Merge, tag, push
From the main checkout:
```bash
# Option 1: Direct on main (simple)
git checkout main
# Update version, changelog, documentation
git commit -m "Prepare release 1.0.0"
git tag -a v1.0.0 -m "Release 1.0.0: First stable release"
git push origin main v1.0.0
# Option 2: Using release branch (if needed)
git checkout -b release/1.0.0 main
# Prepare release
git commit -m "Prepare release 1.0.0"
git tag -a v1.0.0 -m "Release 1.0.0: First stable release"
git checkout main
git merge release/1.0.0
git push origin main v1.0.0
git branch -d release/1.0.0
cd ~/Documents/projects/StarPunk
git checkout main && git pull
git merge --no-ff fix/v2.10.1-websub-hardening \
-m "Merge branch 'fix/v2.10.1-websub-hardening' for v2.10.1 release"
git tag -a v2.10.1 -m "v2.10.1: WebSub hardening"
git push origin main v2.10.1
```
### Hotfix Workflow
Then remove the worktree and branch:
```bash
# Create from release tag
git checkout -b hotfix/1.0.1-critical-fix v1.0.0
# Fix
git commit -m "Fix critical bug"
# Version bump
git commit -m "Bump version to 1.0.1"
# Tag
git tag -a v1.0.1 -m "Hotfix 1.0.1: Critical bug fix"
# Merge to main
git checkout main
git merge hotfix/1.0.1-critical-fix
# Push
git push origin main v1.0.1
# Clean up
git branch -d hotfix/1.0.1-critical-fix
git worktree remove ../StarPunk-worktrees/v2.10.1
git branch -d fix/v2.10.1-websub-hardening
```
## Branch Protection Rules
Merging to `main`, tagging and pushing are release actions: an agent does
them only when the project owner has asked for the release.
### Main Branch Protection
### 4. CI builds the image
**For solo development**:
- Recommended but not enforced via GitHub
- Self-discipline: treat `main` as protected
- Don't force push
- Don't rewrite history
Pushing a tag that matches `v[0-9]+.[0-9]+.[0-9]+` runs
`.gitea/workflows/build-container.yml` on the Gitea runner:
**For team development**:
- Require pull request reviews
- Require status checks to pass
- Prevent force push
- Prevent deletion
1. builds the Containerfile `test` stage, which runs the whole pytest
suite; a failure stops the workflow and nothing is published;
2. builds the runtime image and pushes
`git.thesatelliteoflove.com/phil/starpunk:vX.Y.Z` and `:latest`.
**GitHub settings** (when ready):
```
Settings → Branches → Add branch protection rule
Pre-release tags such as `v2.0.0-rc.1` don't match the pattern and are not
built by CI. The workflow can also be started by hand
(`workflow_dispatch`).
Branch name pattern: main
If CI fails, fix it on a new branch and release the next PATCH version.
Don't move or re-push an existing tag.
Protect matching branches:
☑ Require a pull request before merging
☑ Require approvals (1)
☑ Require status checks to pass before merging
☑ Require branches to be up to date before merging
☑ Require conversation resolution before merging
☑ Do not allow bypassing the above settings
☐ Allow force pushes (NEVER enable)
☐ Allow deletions (NEVER enable)
```
### 5. Deploy
## Tagging Strategy
Production is managed from the separate Ansible deployment repository, not
from this one:
### Tag Format
1. If the release has a migration, back up the production database first
(see [architecture/deployment.md](../architecture/deployment.md)).
Migrations run automatically when the new container starts.
2. In the deployment repository, set `starpunk_version` to the new tag and
deploy the `starpunk` service.
3. Check `/health`, the home page, admin login and the feature that changed.
**Version tags**: `vMAJOR.MINOR.PATCH[-PRERELEASE]`
## Migrations
**Examples**:
- `v0.1.0` - Development release
- `v1.0.0` - First stable release
- `v1.0.1` - Patch release
- `v1.1.0` - Minor release
- `v2.0.0` - Major release
- `v1.0.0-alpha.1` - Pre-release
- Files are `migrations/NNN_description.sql`, numbered sequentially.
`starpunk/migrations.py` applies the pending ones at startup and records
them in `schema_migrations`.
- Every gunicorn worker runs the migration check at startup; a
`BEGIN IMMEDIATE` lock makes one worker apply them while the others wait.
Since v2.8.1 the statements run with `conn.execute` inside that
transaction. Don't use `executescript()` (it commits and drops the lock)
and don't put `BEGIN`/`COMMIT` in migration files.
- Migrations only move forward; there are no down migrations. The backup
is the rollback.
- Test a new migration against a copy of a database at the previous
version.
### Tag Types
See [ADR-020](../decisions/ADR-020-automatic-database-migrations.md),
[ADR-037](../decisions/ADR-037-migration-race-condition-fix.md) and
`docs/design/v2.8.1/2026-11-03-migration-lock.md`.
**Annotated tags** (ALWAYS use for releases):
```bash
git tag -a v1.0.0 -m "Release 1.0.0: First stable release"
```
## Documentation-only changes
**Why annotated**:
- Contains tagger, date, message
- Can include release notes
- Can be GPG signed
- Treated as full Git objects
- Better for releases
**Lightweight tags** (NEVER use for releases):
```bash
git tag v1.0.0 # Don't do this for releases
```
### Tag Messages
**Format**:
```
Release MAJOR.MINOR.PATCH: <Brief description>
[Optional longer description]
[Release highlights]
```
**Examples**:
```bash
git tag -a v1.0.0 -m "Release 1.0.0: First stable release
Complete IndieWeb CMS implementation with:
- IndieAuth authentication
- Micropub publishing endpoint
- RSS feed generation
- File-based note storage
- Markdown support"
git tag -a v1.0.1 -m "Hotfix 1.0.1: Security vulnerability fix"
git tag -a v0.2.0 -m "Development release 0.2.0: Phase 1.2 complete"
```
### Viewing Tags
```bash
# List all tags
git tag
# List tags with messages
git tag -n
# Show tag details
git show v1.0.0
# List tags matching pattern
git tag -l "v1.0.*"
```
### Pushing Tags
```bash
# Push specific tag
git push origin v1.0.0
# Push all tags
git push origin --tags
# Delete remote tag (if needed)
git push origin :refs/tags/v1.0.0
```
## Integration with Semantic Versioning
### Version-to-Branch Mapping
**Development phase (0.x.y)**:
- Work on `main`
- Tag development milestones: `v0.1.0`, `v0.2.0`, etc.
- Breaking changes allowed
**Stable releases (1.x.y)**:
- Work on `main` or feature branches
- Tag stable releases: `v1.0.0`, `v1.1.0`, etc.
- Breaking changes require major version bump
**Major releases (2.0.0+)**:
- Work on `main` or feature branches
- Tag major releases: `v2.0.0`, `v3.0.0`, etc.
- Document breaking changes thoroughly
### Branch-to-Release Flow
```
feature/micropub → main → v0.1.0 (development)
feature/rss → main → v0.2.0 (development)
feature/auth → main → v0.3.0 (development)
main → v1.0.0 (stable)
fix/bug → main → v1.0.1 (patch)
feature/new → main → v1.1.0 (minor)
feature/breaking → main → v2.0.0 (major)
```
## Common Scenarios
### Scenario 1: Developing a New Feature
```bash
# Create feature branch
git checkout -b feature/micropub-endpoint main
# Develop
git commit -am "Add micropub create action"
git commit -am "Add micropub update action"
# Keep updated with main
git fetch origin
git rebase origin/main
# Merge when ready
git checkout main
git merge feature/micropub-endpoint
# Push and clean up
git push origin main
git branch -d feature/micropub-endpoint
```
### Scenario 2: Releasing a Development Version
```bash
# Update version
echo '__version__ = "0.2.0"' > starpunk/__init__.py
# Update changelog
# Edit CHANGELOG.md
# Commit
git commit -am "Bump version to 0.2.0"
# Tag
git tag -a v0.2.0 -m "Development release 0.2.0"
# Push
git push origin main v0.2.0
```
### Scenario 3: First Stable Release
```bash
# Final preparations on main
git commit -am "Update documentation for 1.0.0"
# Version bump
echo '__version__ = "1.0.0"' > starpunk/__init__.py
# Edit CHANGELOG.md
git commit -am "Bump version to 1.0.0"
# Tag
git tag -a v1.0.0 -m "Release 1.0.0: First stable release"
# Push
git push origin main v1.0.0
```
### Scenario 4: Critical Production Bug
```bash
# Create hotfix from last release
git checkout -b hotfix/1.0.1-security-fix v1.0.0
# Fix the bug
git commit -am "Fix security vulnerability"
# Version bump
echo '__version__ = "1.0.1"' > starpunk/__init__.py
# Edit CHANGELOG.md
git commit -am "Bump version to 1.0.1"
# Tag
git tag -a v1.0.1 -m "Hotfix 1.0.1: Security vulnerability fix"
# Merge to main
git checkout main
git merge hotfix/1.0.1-security-fix
# Push
git push origin main v1.0.1
# Clean up
git branch -d hotfix/1.0.1-security-fix
```
### Scenario 5: Multiple Features in Progress
```bash
# Developer 1: Feature A
git checkout -b feature/feature-a main
# Work on feature A
# Developer 2: Feature B
git checkout -b feature/feature-b main
# Work on feature B
# Feature A finishes first
git checkout main
git merge feature/feature-a
git push origin main
# Feature B rebases onto updated main
git checkout feature/feature-b
git rebase origin/main
# Continue work
# Feature B finishes
git checkout main
git merge feature/feature-b
git push origin main
```
## Best Practices
### Do
1. **Commit often** with clear messages
2. **Pull before push** to avoid conflicts
3. **Rebase feature branches** to keep history clean
4. **Delete merged branches** to reduce clutter
5. **Tag releases** with annotated tags
6. **Write descriptive commit messages** (50 char summary, then details)
7. **Test before merging** to main
8. **Use pull requests** for team development
9. **Keep main stable** - always passing tests
10. **Document breaking changes** in commits and changelog
### Don't
1. **Never force push** to `main`
2. **Never rewrite history** on `main`
3. **Don't commit directly** to `main` (team development)
4. **Don't merge broken code** - tests must pass
5. **Don't create long-lived branches** - integrate frequently
6. **Don't use lightweight tags** for releases
7. **Don't forget to push tags** after creating them
8. **Don't merge without updating** from origin first
9. **Don't commit secrets** or sensitive data
10. **Don't skip version bumps** before tagging
### Commit Message Format
**Format**:
```
<type>: <summary> (50 chars or less)
<optional detailed description>
<optional footer: references, breaking changes>
```
**Types**:
- `feat:` New feature
- `fix:` Bug fix
- `docs:` Documentation
- `style:` Formatting, whitespace
- `refactor:` Code refactoring
- `test:` Adding tests
- `chore:` Maintenance tasks
**Examples**:
```
feat: Add Micropub create endpoint
Implements the create action for Micropub specification.
Supports h-entry posts with content, name, and published properties.
Refs: #15
fix: Correct RSS pubDate timezone handling
Previously used local timezone, now uses UTC as per RSS spec.
Fixes: #23
docs: Update installation instructions
chore: Bump version to 1.0.0
```
## Troubleshooting
### Problem: Merge Conflict
```bash
# During merge
git merge feature/my-feature
# CONFLICT (content): Merge conflict in file.py
# Resolve conflicts
# Edit file.py, resolve conflicts
git add file.py
git commit -m "Merge feature/my-feature"
```
### Problem: Accidentally Committed to Main
```bash
# If not pushed yet
git reset HEAD~1 # Undo last commit, keep changes
git stash # Save changes
git checkout -b feature/my-feature # Create feature branch
git stash pop # Apply changes
git commit -am "Feature implementation"
```
### Problem: Need to Update Feature Branch
```bash
# Option 1: Rebase (clean history)
git checkout feature/my-feature
git rebase origin/main
# Option 2: Merge (preserves history)
git checkout feature/my-feature
git merge origin/main
```
### Problem: Wrong Tag Name
```bash
# Delete local tag
git tag -d v1.0.0
# Delete remote tag
git push origin :refs/tags/v1.0.0
# Create correct tag
git tag -a v1.0.1 -m "Release 1.0.1"
git push origin v1.0.1
```
Branch `docs/<description>`, no version bump, no changelog entry, no tag.
Merge with `--no-ff` like any other branch.
## References
### Internal Documentation
- [Versioning Strategy](/home/phil/Projects/starpunk/docs/standards/versioning-strategy.md) - Version numbering scheme
- [ADR-008: Versioning Strategy](/home/phil/Projects/starpunk/docs/decisions/ADR-008-versioning-strategy.md) - Versioning decision rationale
- [ADR-009: Git Branching Strategy](/home/phil/Projects/starpunk/docs/decisions/ADR-009-git-branching-strategy.md) - This strategy's decision record
- [Development Setup](/home/phil/Projects/starpunk/docs/standards/development-setup.md) - Development environment
### External Resources
- [Git Branching Model](https://nvie.com/posts/a-successful-git-branching-model/) - Git Flow (inspiration, not followed exactly)
- [GitHub Flow](https://guides.github.com/introduction/flow/) - Simpler flow (closer to our approach)
- [Semantic Versioning](https://semver.org/) - Version numbering
- [Git Documentation](https://git-scm.com/doc) - Official Git documentation
---
**Document**: Git Branching Strategy
**Version**: 1.0
**Last Updated**: 2025-11-18
**Status**: Active
- [versioning-strategy.md](versioning-strategy.md): choosing the version number
- [version-implementation-guide.md](version-implementation-guide.md): where the version lives, changelog and design note format
- [testing-checklist.md](testing-checklist.md): tests and CI
- [ADR-009: Git branching strategy](../decisions/ADR-009-git-branching-strategy.md)
File diff suppressed because it is too large. Load diff
+93 -104
View File
@@ -1,127 +1,116 @@
# Testing Checklist
This document provides a comprehensive checklist for testing StarPunk functionality before release.
**Status**: Active
**Last Updated**: 2026-11-03 (v2.10.1)
## Manual Testing Checklist
What to test, how to run the tests, and what CI does with them. Setup and
the environment variables the tests need are in
[development-setup.md](development-setup.md#running-the-tests).
### Core Functionality
- [ ] Create notes via web interface
- [ ] Create notes via Micropub JSON
- [ ] Create notes via Micropub form-encoded
- [ ] Notes display with proper microformats
- [ ] Markdown renders correctly
- [ ] Slugs generate uniquely
- [ ] Timestamps record accurately
## How tests run
### Authentication & Security
- [ ] IndieAuth login flow works
- [ ] Micropub client authentication
- [ ] Token expiration works
- [ ] Rate limiting functions
**Locally**
### Syndication & Standards
- [ ] RSS feed validates (W3C validator)
- [ ] API returns correct status codes
```bash
SESSION_SECRET=test uv run pytest # everything
SESSION_SECRET=test uv run pytest --ignore=tests/test_migration_race_condition.py # fast loop
```
### Automated Testing
- [ ] All unit tests pass
- [ ] All integration tests pass
- [ ] Test coverage >80%
`tests/test_migration_race_condition.py` takes about 5 minutes; skip it
while iterating, never before a release.
## Validation Tools
**In CI** (`.gitea/workflows/build-container.yml`), on every pushed
`vX.Y.Z` tag (or a manual run):
### IndieWeb Standards
- **IndieWebify.me**: https://indiewebify.me/
- Verify microformats (h-entry, h-card, h-feed)
- Check IndieAuth implementation
1. `docker buildx build --target test -f Containerfile .` builds the
Containerfile's `test` stage: the runtime dependencies plus pytest and
pytest-mock, with `SESSION_SECRET=ci-test-secret`,
`SITE_URL=http://localhost:5000` and `ADMIN_ME=https://test.example.com`,
then `python -m pytest -q -p no:cacheprovider tests`.
2. Only if that succeeds is the runtime image built and pushed as
`:vX.Y.Z` and `:latest`.
- **IndieAuth Validator**: https://indieauth.com/validate
- Test IndieAuth flow
- Validate token handling
So a failing test blocks the release image; it does not block the merge or
the tag. Run the full suite before merging (see
[git-branching-strategy.md](git-branching-strategy.md#release-process)).
To reproduce CI locally: `docker build --target test -f Containerfile .`
(pytest-cov is not installed in that stage, so don't depend on it in
tests).
- **Micropub Test Suite**: https://micropub.rocks/
- Comprehensive Micropub endpoint testing
- Verify spec compliance
## Every change
### Web Standards
- **W3C Feed Validator**: https://validator.w3.org/feed/
- Validate RSS 2.0 feed structure
- Check date formatting
- Verify CDATA wrapping
- [ ] Full suite passes locally
- [ ] New behaviour has tests; a bug fix has a test that failed before the fix
- [ ] Tests use the `app` / `client` fixtures from `tests/conftest.py`
(temporary data directory, `TESTING=True`); nothing touches `./data`
- [ ] No test makes real network requests (see below)
- [ ] Schema changes: a numbered migration in `migrations/`, plus a test
that it applies to an existing database (`tests/test_migrations.py`)
- **W3C HTML Validator**: https://validator.w3.org/
- Validate HTML5 markup
- Check semantic structure
- Verify accessibility
## Conventions
- **JSON Validator**: https://jsonlint.com/
- Validate API responses
- Check Micropub payloads
- **Where**: one file per module or feature (`tests/test_websub.py`). Work
driven by a spec review or an incident gets its own file named for the
release, with a docstring saying what it covers, e.g.
`test_micropub_v290.py`, `test_microformats_v280.py`,
`test_websub_hardening.py` ("one test per finding of the v2.10.0 review").
- **Outbound HTTP**: everything StarPunk fetches from or sends to other
servers goes through `starpunk/webmention_ssrf.py`. Tests replace its
transport and DNS instead of mocking callers:
## Testing Resources
```python
monkeypatch.setattr("starpunk.webmention_ssrf.socket.getaddrinfo", lambda *a, **k: PUBLIC)
monkeypatch.setattr("starpunk.webmention_ssrf.TRANSPORT", httpx.MockTransport(handler))
```
### Specifications
- IndieWeb Notes: https://indieweb.org/note
- Micropub Spec: https://micropub.spec.indieweb.org
- IndieAuth Spec: https://www.w3.org/TR/indieauth/
- Microformats2: http://microformats.org/wiki/h-entry
- RSS 2.0 Spec: https://www.rssboard.org/rss-specification
(see the `web` fixture in `tests/test_websub.py`). Test the private
address rejection by making `getaddrinfo` return e.g. `10.0.0.2`.
- **Background workers** don't run under `TESTING=True`. Drive them
directly, e.g. `WebSubWorker(app)` inside `app.app_context()`
(`run_worker` in `tests/test_websub.py`).
- **Crossposting** targets are configured per test with app config
overrides and mocked HTTP; never with real credentials.
- **Concurrency** fixes need a test that reproduces the race with real
processes or threads (`tests/test_migration_concurrency.py`).
### Testing & Validation
- Micropub Test Suite: https://micropub.rocks/
- IndieAuth Testing: https://indieauth.com/
- Microformats Parser: https://pin13.net/mf2/
## New or changed protocol work
### Example Implementations
- IndieWeb Examples: https://indieweb.org/examples
- Micropub Clients: https://indieweb.org/Micropub/Clients
StarPunk implements Micropub, IndieAuth, Webmention, WebSub and
microformats2. For changes to any of them:
## Pre-Release Validation Workflow
- [ ] Read the W3C Recommendation (or the living spec) and cite section
numbers in the ADR and in test names or docstrings
- [ ] Test each MUST that the change touches, including the error responses
(status codes, `error` values, headers) and not only the happy path
- [ ] Test discovery: `Link` headers and `<link>` elements still advertise
the endpoint on every page and feed that should have them
- [ ] Test what a strict client sends: form-encoded and JSON (Micropub),
case and percent-encoding variants (WebSub topics), relative URLs
(Webmention sources)
- [ ] Test that requests to user-supplied URLs are refused for private
addresses and time out
- [ ] Rendered markup: parse the page with `mf2py` and assert on the parsed
properties (`tests/test_microformats*.py`), not on raw HTML strings
- [ ] Manual check against the live site after deploy with the external
validators below
1. **Run Automated Tests**
```bash
uv run pytest
```
## Validation tools (manual, after deploy)
2. **Validate HTML**
- Test homepage output
- Test note permalink output
- Run through W3C HTML Validator
| Protocol | Tool |
|---|---|
| Micropub | [micropub.rocks](https://micropub.rocks/), a real client (Quill, Indigenous) |
| IndieAuth | Sign in to a Micropub client; [indieauth.rocks](https://indieauth.rocks/) |
| Webmention | [webmention.rocks](https://webmention.rocks/) |
| WebSub | [websub.rocks](https://websub.rocks/) (publisher and hub tests) |
| Microformats2 | [pin13.net/mf2](https://pin13.net/mf2/), [IndieWebify.me](https://indiewebify.me/) |
| Feeds | [W3C Feed Validator](https://validator.w3.org/feed/) (RSS, Atom), [JSON Feed validator](https://validator.jsonfeed.org/) |
| HTML | [W3C HTML validator](https://validator.w3.org/) |
3. **Validate RSS Feed**
- Access /feed.xml
- Run through W3C Feed Validator
- Verify in actual RSS reader
## Specifications
4. **Validate Microformats**
- Test homepage with IndieWebify.me
- Test note permalinks
- Use microformats parser
5. **Validate Micropub**
- Run micropub.rocks test suite
- Test with real Micropub client (Quill)
6. **Manual Browser Testing**
- Chrome/Chromium
- Firefox
- Safari (if available)
- Mobile browsers
7. **Security Verification**
- CSRF protection working
- XSS prevention verified
- SQL injection tests pass
- Path traversal prevention works
## Success Criteria
All checklist items must pass before V1 release. If any validation tool reports errors, they must be fixed before proceeding.
## Related Documentation
- [Testing Strategy](/home/phil/Projects/starpunk/docs/architecture/overview.md#testing-strategy)
- [Implementation Plan](/home/phil/Projects/starpunk/docs/projectplan/v1/implementation-plan.md)
- [Feature Scope](/home/phil/Projects/starpunk/docs/projectplan/v1/feature-scope.md)
**Last Updated**: 2025-11-24
- Micropub: https://www.w3.org/TR/micropub/
- IndieAuth: https://indieauth.spec.indieweb.org/
- Webmention: https://www.w3.org/TR/webmention/
- WebSub: https://www.w3.org/TR/websub/
- Microformats2 h-entry: https://microformats.org/wiki/h-entry
- RSS 2.0: https://www.rssboard.org/rss-specification, Atom: RFC 4287, JSON Feed 1.1: https://www.jsonfeed.org/version/1.1/
+10 -5
View File
@@ -1,8 +1,13 @@
# Utility Function Patterns
**Status**: Active
**Last Updated**: 2026-11-03 (v2.10.1; reviewed, content from 2025-11-18)
## Purpose
This document establishes coding patterns and conventions specifically for utility functions in StarPunk. These patterns ensure utilities are consistent, testable, and maintainable.
This document establishes coding patterns and conventions specifically for utility functions in StarPunk (`starpunk/utils.py`, `starpunk/slug_utils.py`, `starpunk/mf2_utils.py` and helpers in other modules). These patterns ensure utilities are consistent, testable, and maintainable. General rules, including project-wide patterns for configuration, database access and outbound HTTP, are in [python-coding-standards.md](python-coding-standards.md); where the two differ, that document wins.
The examples are illustrative. Several mirror real functions in `starpunk/utils.py` (`calculate_content_hash`, `write_note_file`, `validate_slug`, `generate_slug`, `validate_note_path`); others (`require_valid_slug`, `iter_note_files`) only show the pattern.
## Philosophy
@@ -481,7 +486,7 @@ def generate_slug(content: str) -> str:
# Additional validation
if not validate_slug(normalized):
# Fallback to safe default
normalized = datetime.utcnow().strftime("%Y%m%d-%H%M%S")
normalized = datetime.now(timezone.utc).strftime("%Y%m%d-%H%M%S")
return normalized
```
@@ -500,7 +505,7 @@ def generate_slug(content: str, created_at: Optional[datetime] = None) -> str:
# Only generate timestamp if needed
if not slug:
created_at = created_at or datetime.utcnow()
created_at = created_at or datetime.now(timezone.utc)
slug = created_at.strftime("%Y%m%d-%H%M%S")
return slug
@@ -705,7 +710,7 @@ def generate_slug(content: str) -> str:
slug = normalize_slug_text(content)
if not slug:
# Explicit fallback with timestamp
slug = datetime.utcnow().strftime("%Y%m%d-%H%M%S")
slug = datetime.now(timezone.utc).strftime("%Y%m%d-%H%M%S")
return slug
```
@@ -726,7 +731,7 @@ def generate_slug(content: str) -> str:
## References
- [Python Coding Standards](/home/phil/Projects/starpunk/docs/standards/python-coding-standards.md)
- [Python Coding Standards](python-coding-standards.md)
- [PEP 8 - Style Guide](https://peps.python.org/pep-0008/)
- [PEP 257 - Docstring Conventions](https://peps.python.org/pep-0257/)
- [PEP 484 - Type Hints](https://peps.python.org/pep-0484/)
+63 -571
View File
@@ -1,603 +1,95 @@
# Version Implementation Guide
## Quick Reference
**Status**: Active
**Last Updated**: 2026-11-03 (v2.10.1)
This guide shows exactly where and how version information is stored in StarPunk.
Where the version number lives and what to write for each release. Which
number to pick: [versioning-strategy.md](versioning-strategy.md). Git steps:
[git-branching-strategy.md](git-branching-strategy.md#release-process).
**See Also**: [versioning-strategy.md](versioning-strategy.md) for complete strategy documentation.
## Where the version lives
## Version Storage Locations
There is one source: `starpunk/__init__.py`, at the end of the file.
### 1. Primary Source: `starpunk/__init__.py`
**Status**: ✅ Already implemented
**Location**: `/home/phil/Projects/starpunk/starpunk/__init__.py`
**Content**:
```python
# Package version (Semantic Versioning 2.0.0)
# See docs/standards/versioning-strategy.md for details
__version__ = "0.1.0"
__version_info__ = (0, 1, 0)
__version__ = "2.10.1"
__version_info__ = (2, 10, 1)
```
**Usage**:
```python
from starpunk import __version__, __version_info__
Update both lines. Nothing else holds the number: there is no
`pyproject.toml`, and the README doesn't state a version. At runtime:
print(f"StarPunk version {__version__}")
print(f"Version info: {__version_info__}") # (0, 1, 0)
- `starpunk/config.py` sets `app.config["VERSION"]` from the `VERSION`
environment variable, defaulting to `__version__`. Leave `VERSION` unset
in deployments so the code's version is shown.
- The version appears in the page footer, `/health`, `/admin/health`
and the `User-Agent` of outgoing requests (`StarPunk/<version>`).
The git tag (`vX.Y.Z`) and the image tag CI publishes come from the tag you
push, so they must match `__version__`. Check before tagging:
```bash
uv run python -c "import starpunk; print(starpunk.__version__)"
```
**Format**:
- `__version__`: String in PEP 440 format (e.g., `"1.0.0"`, `"1.0.0a1"`, `"1.0.0rc1"`)
- `__version_info__`: Tuple of integers (major, minor, patch) for programmatic comparison
## CHANGELOG.md
---
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format. Add the
new entry under `## [Unreleased]`, newest first:
### 2. README.md
**Status**: ✅ Already implemented
**Location**: `/home/phil/Projects/starpunk/README.md`
**Content**: Shows current version at the top of the file:
```markdown
# StarPunk
## [2.10.1] - 2026-11-03
A minimal, self-hosted IndieWeb CMS for publishing notes with RSS syndication.
**Current Version**: 0.1.0 (development)
## Versioning
StarPunk follows [Semantic Versioning 2.0.0](https://semver.org/):
- Version format: `MAJOR.MINOR.PATCH`
- Current: `0.1.0` (pre-release development)
- First stable release will be `1.0.0`
```
**Update when**: Version changes (manually)
---
### 3. CHANGELOG.md
**Status**: ✅ Created
**Location**: `/home/phil/Projects/starpunk/CHANGELOG.md`
**Format**: Based on [Keep a Changelog](https://keepachangelog.com/)
**Structure**:
```markdown
# Changelog
## [Unreleased]
### Added
- Features being developed
## [1.0.0] - 2024-11-18
### Added
- New features
### Changed
- Changes to existing features
### Fixed
- Bug fixes
One optional sentence of context, e.g. which review or incident this
release comes from, with links (ADR, spec).
### Security
- Security patches
```
**Update when**: Every change (add to `[Unreleased]`), then move to versioned section on release
---
### 4. Git Tags
**Status**: ⏳ To be created when releasing
**Format**: `vMAJOR.MINOR.PATCH[-PRERELEASE]`
**Examples**:
```bash
v0.1.0 # Development version
v0.2.0 # Next development version
v1.0.0-alpha.1 # Alpha pre-release
v1.0.0-beta.1 # Beta pre-release
v1.0.0-rc.1 # Release candidate
v1.0.0 # Stable release
```
**How to Create**:
```bash
# Annotated tag (recommended)
git tag -a v0.1.0 -m "Development version 0.1.0: Phase 1.1 complete
- Core utilities implemented
- Slug generation
- File operations
- Content hashing
See CHANGELOG.md for full details."
# Push tag
git push origin v0.1.0
```
**Current Tags**: None yet (will create when Phase 1.1 is complete)
---
### 5. pyproject.toml (Optional, Future)
**Status**: ⚠️ Not currently used
**Location**: `/home/phil/Projects/starpunk/pyproject.toml` (if created)
**Content** (if we create this file):
```toml
[project]
name = "starpunk"
version = "0.1.0"
description = "Minimal IndieWeb CMS"
authors = [
{name = "Your Name", email = "your@email.com"}
]
dependencies = [
"flask>=3.0.0",
"python-markdown>=3.5.0",
"feedgen>=1.0.0",
"httpx>=0.25.0",
]
[project.urls]
Homepage = "https://github.com/YOUR_USERNAME/starpunk"
Repository = "https://github.com/YOUR_USERNAME/starpunk"
Changelog = "https://github.com/YOUR_USERNAME/starpunk/blob/main/CHANGELOG.md"
```
**Decision**: Not needed for V1 (keeping it simple)
---
## How to Update Version
### Step-by-Step Process
When you're ready to release a new version:
#### 1. Decide on Version Number
Use the decision tree from `versioning-strategy.md`:
- **Breaking changes?** → Increment MAJOR (e.g., 1.0.0 → 2.0.0)
- **New features?** → Increment MINOR (e.g., 1.0.0 → 1.1.0)
- **Bug fixes only?** → Increment PATCH (e.g., 1.0.0 → 1.0.1)
**During 0.x development**:
- **Phase complete?** → Increment MINOR (e.g., 0.1.0 → 0.2.0)
- **Bug fix?** → Increment PATCH (e.g., 0.1.0 → 0.1.1)
#### 2. Update `starpunk/__init__.py`
```python
# Change version strings
__version__ = "0.2.0" # New version
__version_info__ = (0, 2, 0) # New version tuple
```
#### 3. Update `CHANGELOG.md`
Move `[Unreleased]` items to new version section:
```markdown
## [Unreleased]
### Added
### Changed
- ...
### Fixed
## [0.2.0] - 2024-11-19
### Added
- Data models implementation
- Database schema
- Note class with validation
### Changed
- Improved error handling in utilities
[Unreleased]: https://github.com/YOUR_USERNAME/starpunk/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/YOUR_USERNAME/starpunk/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/YOUR_USERNAME/starpunk/releases/tag/v0.1.0
- ...
```
#### 4. Update `README.md`
- Sections, in this order, only those that apply: **Added**, **Changed**,
**Deprecated**, **Removed**, **Fixed**, **Security**.
- Write for the site owner: what they will notice and what they must do
(new settings, behaviour changes), not which functions changed.
- Name new settings in backticks, new migrations by number
("(migration 017)"), and link the ADR for a new feature.
- Behaviour changes a user could trip over go first under **Changed**, in
bold if they need action.
## Design note
`docs/design/vX.Y.Z/YYYY-MM-DD-<topic>.md`, written alongside the change
(rules in [docs/DOCUMENTATION.md](../DOCUMENTATION.md)). Short and factual,
for example `docs/design/v2.8.1/2026-11-03-migration-lock.md`:
Change current version:
```markdown
**Current Version**: 0.2.0 (development)
# vX.Y.Z: <what changed>
## Incident / Context what was wrong or what was asked for
## Causes / Decision why, with references to the spec or ADR
## Fix / Changes what the code now does, file by file if useful
## Verification tests added, manual checks, before/after numbers
```
#### 5. Commit Changes
Releases whose design is fully recorded in an ADR (a new ADR, or an
"Amendments" section, as v2.10.0 and v2.10.1 did in ADR-071) may skip the
design note; the changelog then links the ADR.
```bash
git add starpunk/__init__.py CHANGELOG.md README.md
git commit -m "Bump version to 0.2.0"
```
## Code comments
#### 6. Create Git Tag
New or changed behaviour is often marked with the release that introduced
it, e.g. `# Media types are case-insensitive (v2.10.1)`. This helps when
reading the code next to the changelog; it is optional.
```bash
git tag -a v0.2.0 -m "Development version 0.2.0: Phase 1.2 complete
## Checklist
- Data models implementation
- Database schema defined
- Note class with full validation
- Session and token models
See CHANGELOG.md for full details."
```
#### 7. Push to Repository
```bash
git push origin main
git push origin v0.2.0
```
#### 8. Create GitHub Release (Optional)
If using GitHub:
1. Go to repository → Releases
2. Click "Draft a new release"
3. Choose tag: `v0.2.0`
4. Release title: `Version 0.2.0`
5. Description: Copy from CHANGELOG.md
6. Publish release
---
## How to Check Version
### From Python Code
```python
# Method 1: Import from package
from starpunk import __version__
print(f"Version: {__version__}")
# Method 2: Use version_info for comparisons
from starpunk import __version_info__
if __version_info__ >= (1, 0, 0):
print("Stable release")
else:
print("Development version")
```
### From Command Line
```bash
# Method 1: Python one-liner
python -c "from starpunk import __version__; print(__version__)"
# Method 2: Check Git tags
git tag -l
# Method 3: Check current HEAD tag
git describe --tags --abbrev=0
# Method 4: Show all version info
git describe --tags
```
### From Web Interface (Future)
When implemented, will show in:
- Footer of all pages
- `/api/info` endpoint
- Admin dashboard
---
## Version Comparison Examples
### Using `__version_info__`
```python
from starpunk import __version_info__
# Check minimum version
def require_version(major, minor, patch):
return __version_info__ >= (major, minor, patch)
# Examples
if require_version(1, 0, 0):
print("Running stable version")
if require_version(0, 2, 0):
print("Has data models")
```
### Parsing `__version__` String
```python
from starpunk import __version__
from packaging.version import Version
current = Version(__version__)
required = Version("1.0.0")
if current >= required:
print("Version requirement met")
```
---
## Release Checklist
Use this checklist when releasing a new version:
### Pre-Release
- [ ] All tests pass: `pytest`
- [ ] Code formatted: `black starpunk/ tests/`
- [ ] Code linted: `flake8 starpunk/ tests/`
- [ ] Documentation updated
- [ ] All features working
- [ ] Manual testing completed
### Version Bump
- [ ] Decide version number (MAJOR.MINOR.PATCH)
- [ ] Update `starpunk/__init__.py` → `__version__`
- [ ] Update `starpunk/__init__.py` → `__version_info__`
- [ ] Update `CHANGELOG.md` with changes and date
- [ ] Update `README.md` with current version
- [ ] Review changes: `git diff`
### Commit and Tag
- [ ] Stage files: `git add starpunk/__init__.py CHANGELOG.md README.md`
- [ ] Commit: `git commit -m "Bump version to X.Y.Z"`
- [ ] Create annotated tag: `git tag -a vX.Y.Z -m "Release X.Y.Z: [description]"`
- [ ] Push commits: `git push origin main`
- [ ] Push tag: `git push origin vX.Y.Z`
### Post-Release
- [ ] Verify tag exists: `git tag -l`
- [ ] Create GitHub release (if applicable)
- [ ] Test installation from tag
- [ ] Announce release (if applicable)
- [ ] Create `[Unreleased]` section in CHANGELOG.md for next development
---
## Common Scenarios
### Scenario 1: Completing a Development Phase
**Situation**: Phase 1.2 is complete (data models implemented)
**Action**:
1. Version: 0.1.0 → 0.2.0 (increment MINOR during 0.x)
2. Update `__init__.py`: `__version__ = "0.2.0"`, `__version_info__ = (0, 2, 0)`
3. Update CHANGELOG: Add `[0.2.0]` section with date
4. Commit: `"Bump version to 0.2.0"`
5. Tag: `v0.2.0`
6. Push
### Scenario 2: Fixing a Bug
**Situation**: Found bug in slug generation, fixed it
**Action**:
1. Version: 0.2.0 → 0.2.1 (increment PATCH)
2. Update `__init__.py`: `__version__ = "0.2.1"`, `__version_info__ = (0, 2, 1)`
3. Update CHANGELOG: Add `[0.2.1]` section with bug fix
4. Commit: `"Bump version to 0.2.1"`
5. Tag: `v0.2.1`
6. Push
### Scenario 3: First Stable Release
**Situation**: All V1 features complete, ready for production
**Action**:
1. Version: 0.9.0 → 1.0.0 (first stable release!)
2. Update `__init__.py`: `__version__ = "1.0.0"`, `__version_info__ = (1, 0, 0)`
3. Update CHANGELOG: Comprehensive `[1.0.0]` section
4. Update README: Change "0.x.0 (development)" to "1.0.0 (stable)"
5. Commit: `"Bump version to 1.0.0 - First stable release"`
6. Tag: `v1.0.0` with detailed release notes
7. Push
8. Create GitHub release with announcement
### Scenario 4: Adding New Feature (Post-1.0)
**Situation**: Added tags feature in version 1.0.0, want to release it
**Action**:
1. Version: 1.0.0 → 1.1.0 (increment MINOR for new feature)
2. Update `__init__.py`: `__version__ = "1.1.0"`, `__version_info__ = (1, 1, 0)`
3. Update CHANGELOG: Add `[1.1.0]` section with "Added: Tags support"
4. Commit and tag
5. Push
### Scenario 5: Breaking Change (Post-1.0)
**Situation**: Changed Micropub API response format (breaking change)
**Action**:
1. Version: 1.5.0 → 2.0.0 (increment MAJOR for breaking change)
2. Update `__init__.py`: `__version__ = "2.0.0"`, `__version_info__ = (2, 0, 0)`
3. Update CHANGELOG: Clear "Breaking Changes" section
4. Create upgrade guide: `docs/upgrade/1.x-to-2.0.md`
5. Commit and tag
6. Push
7. Prominently announce breaking changes
---
## Troubleshooting
### Version Mismatch
**Problem**: `__version__` and `__version_info__` don't match
**Solution**: They must always match:
```python
# Correct
__version__ = "1.2.3"
__version_info__ = (1, 2, 3)
# Wrong
__version__ = "1.2.3"
__version_info__ = (1, 2, 0) # Mismatch!
```
### Forgot to Update CHANGELOG
**Problem**: Released version without updating CHANGELOG
**Solution**:
1. Update CHANGELOG now
2. Commit: `"Update CHANGELOG for version X.Y.Z"`
3. Don't change version number or tag
4. Consider creating patch release with corrected changelog
### Wrong Version Number
**Problem**: Tagged v1.1.0 but should have been v2.0.0
**Solution**:
```bash
# Delete local tag
git tag -d v1.1.0
# Delete remote tag
git push origin :refs/tags/v1.1.0
# Create correct tag
git tag -a v2.0.0 -m "Release 2.0.0"
git push origin v2.0.0
```
**Warning**: Only do this immediately after release, before anyone uses the tag!
### Git Tag vs Python Version Mismatch
**Problem**: Git tag says `v1.0.0` but `__version__` says `"0.9.0"`
**Solution**: These must always match:
1. Check Git tag: `git describe --tags`
2. Check Python version: `python -c "from starpunk import __version__; print(__version__)"`
3. They should match (ignoring `v` prefix)
4. If mismatch, fix `__init__.py` and create new tag
---
## Pre-Release Versions
### Alpha Releases
**When**: Early development, unstable, missing features
**Format**:
- Git tag: `v1.0.0-alpha.1`
- Python `__version__`: `"1.0.0a1"` (PEP 440 format)
- `__version_info__`: `(1, 0, 0, "alpha", 1)` (extended tuple)
**Example**:
```python
__version__ = "1.0.0a1"
__version_info__ = (1, 0, 0) # Simplified, or extended: (1, 0, 0, "alpha", 1)
```
### Beta Releases
**When**: Feature complete, testing phase
**Format**:
- Git tag: `v1.0.0-beta.1`
- Python `__version__`: `"1.0.0b1"`
- `__version_info__`: `(1, 0, 0)`
### Release Candidates
**When**: Final testing before stable release
**Format**:
- Git tag: `v1.0.0-rc.1`
- Python `__version__`: `"1.0.0rc1"`
- `__version_info__`: `(1, 0, 0)`
**Note**: For V1, we may skip pre-releases entirely and go straight to 1.0.0 if 0.x testing is sufficient.
---
## Integration with Other Systems
### Flask Application
```python
# In Flask app
from starpunk import __version__
@app.route('/api/info')
def api_info():
return {
"name": "StarPunk",
"version": __version__,
"micropub_endpoint": "/api/micropub"
}
```
### CLI Tool (Future)
```python
import click
from starpunk import __version__
@click.group()
@click.version_option(version=__version__, prog_name="StarPunk")
def cli():
"""StarPunk CMS"""
pass
```
### User-Agent String
```python
from starpunk import __version__
USER_AGENT = f"StarPunk/{__version__} (https://github.com/YOUR_USERNAME/starpunk)"
# Use in HTTP requests
headers = {"User-Agent": USER_AGENT}
```
---
## References
- [Versioning Strategy (complete spec)](versioning-strategy.md)
- [ADR-008: Versioning Strategy](../decisions/ADR-008-versioning-strategy.md)
- [Semantic Versioning 2.0.0](https://semver.org/)
- [PEP 440 - Version Identification](https://peps.python.org/pep-0440/)
- [Keep a Changelog](https://keepachangelog.com/)
---
**Document Version**: 1.0
**Last Updated**: 2024-11-18
**Status**: Active
- [ ] `__version__` and `__version_info__` updated in `starpunk/__init__.py`
- [ ] `CHANGELOG.md` entry with today's date
- [ ] Design note in `docs/design/vX.Y.Z/` (or ADR amendment)
- [ ] `.env.example` updated for new settings
- [ ] Commit subject ends with `(vX.Y.Z)`; tag is `vX.Y.Z`, annotated, message `vX.Y.Z: <title>`
File diff suppressed because it is too large. Load diff