Skip to content

Commit a5df95a

Browse files
author
aligneddev
committed
git practices
1 parent bc9a027 commit a5df95a

1 file changed

Lines changed: 110 additions & 6 deletions

File tree

.specify/memory/constitution.md

Lines changed: 110 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ Modified Sections:
1010
- Compliance Audit Checklist: Added modular boundary and contract compatibility checks
1111
- Guardrails: Added non-negotiable interface/contract boundary rules for cross-module integration
1212
Status: Approved — modular architecture and contract-first parallel delivery are now constitutional requirements
13-
Current Update (v1.12.3): Added mandatory per-migration test coverage governance requiring each migration to include a new or updated automated test, enforced by a migration coverage policy test in CI.
14-
Previous Update (v1.12.2): Added mandatory spec-completion gate requiring database migrations to be applied and E2E tests to pass before a spec can be marked done.
13+
Current Update (v1.13.0): Added Principle X — Trunk-Based Development, Continuous Integration & Delivery. Codified branching strategy (short-lived feature branches, git worktrees, PR-gated merges with validation builds), feature flag governance (max 5 active, mandatory cleanup), and PR completion policy (owner-only completion, GitHub issue linkage required).
14+
Previous Update (v1.12.3): Added mandatory per-migration test coverage governance requiring each migration to include a new or updated automated test, enforced by a migration coverage policy test in CI.
1515
Previous Updates:
16+
- v1.12.2: Added mandatory spec-completion gate requiring database migrations to be applied and E2E tests to pass before a spec can be marked done.
1617
- v1.11.0: Strengthened TDD mandate with a strict gated red-green-refactor workflow requiring explicit user confirmation of failing tests before implementation.
1718
- v1.10.2: Codified a mandatory post-change verification command matrix so every change runs explicit checks before merge.
1819
- v1.10.1: Clarified the local deployment approach for end-user machines by standardizing SQLite local-file storage as the default profile and documenting safety expectations for storage path and upgrades.
@@ -43,6 +44,7 @@ Previous Updates:
4344
- Why Minimal API? Lightweight, performant, integrates seamlessly with Aspire and domain layers
4445
- Why local-first architecture? Users own their data locally; cloud deployment optional for sharing/collaboration
4546
- Why SQLite local-file default for user-machine installs? No separate database install, reliable offline operation, and simpler support/backup through a single user-owned database file
47+
- Why Trunk-Based Development? Short-lived branches with continuous integration keep `main` always releasable, reduce merge pain, and enable continuous delivery; feature flags decouple deployment from release
4648
- **Why DevContainer (mandatory)?** Eliminates "works on my machine" problems; ensures identical development environment across all contributors; pre-configures all tooling (C#, F#, Node.js, npm, CSharpier); supports seamless onboarding; enables reproducible builds and tests; backend and frontend dependencies coexist without system-level pollution. **All development MUST occur inside the DevContainer**; no exceptions during active development.
4749

4850
For detailed amendment history, see [DECISIONS.md](./DECISIONS.md).
@@ -118,6 +120,36 @@ System capabilities must be split into cohesive modules with explicit ownership
118120

119121
**Rationale**: Strong module boundaries reduce coordination overhead, minimize merge conflicts, and allow teams to move in parallel without blocking each other. Contract-first integration preserves system cohesion as complexity grows and enables safer incremental delivery.
120122

123+
### X. Trunk-Based Development, Continuous Integration & Delivery
124+
125+
All development follows **Trunk-Based Development (TBD)** with short-lived feature branches. The `main` branch must always be in a **releasable state** — no broken builds, no failing tests, no incomplete features visible to users.
126+
127+
**Branching Strategy**:
128+
- All work happens on short-lived feature branches created from `main`. No long-lived branches.
129+
- Use **git worktrees** for parallel work streams; merge branches back to `main` as soon as possible (ideally within 1–2 days; never longer than a few days).
130+
- Direct pushes to `main` are **prohibited**. All changes enter `main` via Pull Request (PR) only.
131+
- Every PR must reference a **GitHub issue** that describes the work being done.
132+
- PR validation builds are **mandatory**: all tests (unit, integration, E2E) and code quality checks (linting, formatting, build) must pass before a PR can be completed.
133+
- **PR completion policy**: Only the repository owner may complete (merge) a PR. Squad team members may review, provide feedback, request changes, and approve — but they **cannot** complete the PR. This ensures the owner maintains final merge authority.
134+
135+
**Continuous Integration**:
136+
- Every push to a feature branch triggers the full CI validation pipeline (build, test, lint, format).
137+
- Branches must be up-to-date with `main` before merge (rebase or merge from `main` required).
138+
- Merge conflicts must be resolved before PR completion; never merge broken code.
139+
140+
**Feature Flags**:
141+
- Use feature flags to hide in-progress work that is merged to `main` but not yet ready for users. This decouples **deployment** (code in `main`) from **release** (feature visible to users).
142+
- Feature flags must be implemented at the minimum viable scope — wrap only the entry points to new features, not deep internal logic.
143+
- **Maximum 5 active feature flags** at any time to limit complexity and cognitive overhead. If the limit is reached, existing flags must be cleaned up before new ones are introduced.
144+
- After a feature behind a flag is deemed production-ready and the flag is permanently enabled, the flag, its conditional branches, the old code path, and any flag-specific tests must be **removed** in a dedicated cleanup PR. Feature flag debt is not tolerated.
145+
- Feature flag state is managed via configuration (appsettings, environment variables); never hard-coded in source.
146+
147+
**Continuous Delivery**:
148+
- `main` is always deployable. Any commit on `main` can be released to production at any time.
149+
- Deployment and release are separate concerns: code reaches `main` via PR; features reach users via feature flag enablement or configuration change.
150+
151+
**Rationale**: Trunk-Based Development minimizes integration risk by keeping branches short-lived and merging frequently. Feature flags enable continuous delivery without exposing incomplete work. PR-gated merges with mandatory validation builds ensure `main` never breaks. Owner-only PR completion provides a final quality gate. Git worktrees enable efficient parallel work without branch-switching overhead.
152+
121153
## Technology Stack Requirements
122154

123155
### Development Environment (Mandatory)
@@ -239,6 +271,66 @@ For features spanning multiple modules, delivery must be organized for parallel
239271

240272
This contract-first workflow complements vertical slices and the TDD gates; it does not replace them.
241273

274+
### Branching Strategy & Continuous Integration
275+
276+
All development follows Trunk-Based Development with git worktrees for parallel work:
277+
278+
**Branch Lifecycle**:
279+
1. Create a GitHub issue describing the work
280+
2. Create a short-lived feature branch from `main` (e.g., `feature/issue-42-record-ride`)
281+
3. Use `git worktree add` to work on the branch in a separate directory when parallel work is needed
282+
4. Commit frequently with meaningful messages; push to remote regularly
283+
5. Open a PR referencing the GitHub issue (e.g., "Closes #42") as soon as the first commit is ready (draft PR for work-in-progress)
284+
6. Keep the branch up-to-date with `main` via rebase
285+
7. Once CI passes and review feedback is addressed, the owner completes the PR
286+
8. Remove the worktree and delete the merged branch: `git worktree remove <path> && git branch -d <branch>`
287+
288+
**CI Validation Pipeline** (runs on every PR and push to feature branches):
289+
```
290+
dotnet build BikeTracking.slnx
291+
csharpier format . --check
292+
dotnet test BikeTracking.slnx
293+
cd src/BikeTracking.Frontend && npm run lint && npm run build && npm run test:unit
294+
```
295+
All checks must pass before a PR can be completed. E2E tests run on PRs targeting `main`.
296+
297+
**Git Worktree Conventions**:
298+
- Worktree directories placed in `../<repo>-worktrees/<branch-name>` (outside the main repo directory)
299+
- Each worktree shares the same `.git` object store — no duplicate clones
300+
- Clean up worktrees immediately after the branch is merged
301+
- Never leave orphaned worktrees; run `git worktree list` periodically to audit
302+
303+
**PR Requirements**:
304+
- Must reference a GitHub issue (linked via "Closes #N" or "Relates to #N")
305+
- Must have a passing validation build (CI green)
306+
- Must have at least one reviewer's feedback acknowledged
307+
- Only the repository owner can complete (merge) the PR
308+
- Squad members review, approve, or request changes — they cannot merge
309+
- Use squash merge to keep `main` history clean
310+
311+
### Feature Flag Management
312+
313+
Feature flags decouple deployment from release, allowing incomplete work to be merged to `main` safely:
314+
315+
**Implementation**:
316+
- Feature flags are boolean configuration values read from `appsettings.json` or environment variables
317+
- Backend: Use an `IFeatureFlagService` (or equivalent) injected via DI to check flag state
318+
- Frontend: Feature flags passed via API configuration endpoint or environment build variables
319+
- Wrap only the **entry point** to a new feature (route registration, menu item, endpoint mapping) — do not scatter flag checks deep in business logic
320+
321+
**Lifecycle**:
322+
1. **Create**: Add flag with `false` default in configuration; document the flag in a `FEATURE_FLAGS.md` file with owner, issue reference, and expected removal date
323+
2. **Develop**: All code behind the flag merged to `main` continuously; flag remains `false` in production config
324+
3. **Test**: Enable flag in test/staging environments; run E2E tests with flag on and off
325+
4. **Release**: Set flag to `true` in production configuration to enable for users
326+
5. **Cleanup**: Once the feature is stable in production, create a dedicated cleanup PR that removes the flag, the conditional branches, the old code path, and any flag-specific tests. Update `FEATURE_FLAGS.md`
327+
328+
**Hard Limits**:
329+
- **Maximum 5 active feature flags** at any time across the entire codebase
330+
- Before adding a new flag when at the limit, an existing flag must be cleaned up first
331+
- Feature flags older than 30 days without a cleanup plan must be escalated for review
332+
- `FEATURE_FLAGS.md` is the single source of truth for all active flags
333+
242334
### Post-Change Verification Matrix (Mandatory After Any Change)
243335

244336
After **every** code change, run verification commands based on the changed scope. These checks are required before merge and before phase transitions.
@@ -297,6 +389,10 @@ A vertical slice is **production-ready** only when all items are verified:
297389
- [ ] Events stored in event table with correct schema; projections materialized and queryable
298390
- [ ] Module boundaries preserved; cross-module interactions occur only via approved interfaces/contracts with compatibility evidence
299391
- [ ] SAMPLE_/DEMO_ data cleaned up; no test data committed to main branch
392+
- [ ] PR created from feature branch referencing GitHub issue; CI validation build passes
393+
- [ ] PR completed (merged) by repository owner only, after review feedback addressed
394+
- [ ] Feature flags used for any in-progress work visible in `main`; flag count ≤5
395+
- [ ] Feature flag cleanup PR created after feature is production-ready (removes flag, old code, flag-specific tests)
300396
- [ ] Deployed to Azure staging environment via GitHub Actions + azd
301397
- [ ] Pipeline deployment checks pass for the target environment
302398
- [ ] Security review completed; identified vulnerabilities are explained and fixed (or formally approved risk acceptance)
@@ -402,7 +498,7 @@ Tests suggested by agent must receive explicit user approval before implementati
402498
### Compliance Audit Checklist
403499

404500
#### Per-Specification Audit
405-
- [ ] Spec references all nine core principles in acceptance criteria
501+
- [ ] Spec references all ten core principles in acceptance criteria
406502
- [ ] Event schema defined; backwards compatibility verified if updating existing events
407503
- [ ] Data validation implemented at three layers: client (React), API (Minimal API), database (constraints)
408504
- [ ] Test coverage for domain logic ≥85%; F# discriminated unions and ROP patterns tested
@@ -420,6 +516,11 @@ Tests suggested by agent must receive explicit user approval before implementati
420516
- [ ] Secrets NOT committed; `.gitignore` verified; pre-commit hook prevents credential leakage
421517
- [ ] Validation rule consistency: if field required in React form, enforced in API DTOs and database constraints
422518
- [ ] OAuth isolation verified: user only accesses their data; public data clearly marked
519+
- [ ] All changes entered `main` via PR referencing a GitHub issue; no direct pushes
520+
- [ ] PR validation build passed (build, tests, lint, format) before merge
521+
- [ ] PR completed by repository owner only
522+
- [ ] Feature flags used for in-progress work; active flag count ≤5; `FEATURE_FLAGS.md` up-to-date
523+
- [ ] Feature flag cleanup completed for any flags permanently enabled during this spec
423524

424525
#### Monthly Technology Audit
425526
- [ ] NuGet packages checked via `mcp_nuget_get-latest-package-version` for security patches
@@ -464,10 +565,13 @@ Breaking these guarantees causes architectural decay and technical debt accrual:
464565
- **SAMPLE_/DEMO_ data never in production** — automated linting prevents prefixed data from deploying. Merge blocked if test data detected.
465566
- **Database provider abstraction** — application code must work across SQLite (local), SQL Server LocalDB (local), and Azure SQL (cloud) without provider-specific queries. Use EF Core abstractions; avoid raw SQL unless necessary and provider-agnostic.
466567
- **User-machine local data safety** — local deployments on end-user machines default to SQLite local-file storage in a user-writable app-data path; do not require a separate DB server for single-user installs. Before schema migration, create a backup copy of the SQLite file.
568+
- **No direct pushes to `main`** — all changes enter `main` via Pull Request only. Every PR must reference a GitHub issue, pass the full CI validation build (build, test, lint, format), and be completed (merged) exclusively by the repository owner. Squad team members may review, approve, and request changes but cannot complete a PR. Violations are treated as process failures requiring immediate revert.
569+
- **Feature flags are mandatory for in-progress work on `main`** — any incomplete feature merged to `main` must be behind a feature flag set to `false` by default. Maximum 5 active feature flags at any time. After a feature is production-ready and the flag is permanently enabled, a dedicated cleanup PR must remove the flag, old code paths, and flag-specific tests. Feature flag debt is not tolerated.
570+
- **Branches must be short-lived** — feature branches must be merged back to `main` as quickly as possible (target 1–2 days). Long-lived branches are prohibited; they create merge pain and integration risk. Use git worktrees for parallel work; clean up worktrees immediately after merge.
467571

468572
### Onboarding Checklist for New Contributors
469573

470-
1. **Read constitution** (~20 min): Understand mission, nine core principles, technology stack, development workflow
574+
1. **Read constitution** (~20 min): Understand mission, ten core principles, technology stack, development workflow
471575
2. **Review decision history** (~15 min): [DECISIONS.md](./DECISIONS.md) explains why F#, why Event Sourcing, why Aspire, why Aurelia 2
472576
3. **Clone repo and bootstrap** (~5 min): `git clone``dotnet tool install --global specify-cli``dotnet run` (Aspire orchestrates frontend, API, database)
473577
4. **Explore specification examples** (~30 min): Review `/specs/` directory; read 2–3 completed specifications to understand vertical slice completeness
@@ -508,7 +612,7 @@ Breaking these guarantees causes architectural decay and technical debt accrual:
508612
## Governance
509613

510614
### Constitution as Governing Document
511-
This constitution supersedes all other project guidance. All architectural decisions, code reviews, deployment approvals, and spec acceptance gates must verify compliance with these nine core principles and technology stack requirements.
615+
This constitution supersedes all other project guidance. All architectural decisions, code reviews, deployment approvals, and spec acceptance gates must verify compliance with these ten core principles and technology stack requirements.
512616

513617
### Amendment Procedure
514618
Amendments must:
@@ -548,5 +652,5 @@ Always commit at each TDD gate and before continuing to a new phase.
548652

549653
---
550654

551-
**Version**: 1.12.2 | **Ratified**: 2026-03-03 | **Last Amended**: 2026-03-27
655+
**Version**: 1.13.0 | **Ratified**: 2026-03-03 | **Last Amended**: 2026-04-03
552656

0 commit comments

Comments
 (0)