|
| 1 | +# OpenSpec Governance |
| 2 | + |
| 3 | +This document defines how maintainers and AI agents create changes that can be implemented, audited, documented, and archived without losing project knowledge. |
| 4 | + |
| 5 | +## Change Scope |
| 6 | + |
| 7 | +Every OpenSpec change for behavior, product, API, migration, release, architecture, database, security, permissions, deployment, or data repair work must describe its scope before implementation starts. |
| 8 | + |
| 9 | +Use this shape in `proposal.md` when a change has meaningful boundaries: |
| 10 | + |
| 11 | +```markdown |
| 12 | +## Scope |
| 13 | + |
| 14 | +### In Scope |
| 15 | + |
| 16 | +- Current behavior, system, route, package, migration, or business rule being changed. |
| 17 | + |
| 18 | +### Out Of Scope |
| 19 | + |
| 20 | +- Related work intentionally not included in this change. |
| 21 | + |
| 22 | +### Affected Areas |
| 23 | + |
| 24 | +- Code: `apps/web`, `apps/api`, `packages/db`, `packages/shared`, or other paths. |
| 25 | +- Runtime: PostgreSQL, Redis, object storage, email, deployment, or workers. |
| 26 | +- Contracts: OpenAPI, shared Zod schemas, API errors, public URLs, or CLI commands. |
| 27 | + |
| 28 | +### High-Risk Categories |
| 29 | + |
| 30 | +- Database: |
| 31 | +- Security/permissions: |
| 32 | +- API contract: |
| 33 | +- Migration/data repair: |
| 34 | +- Deployment/release: |
| 35 | +``` |
| 36 | + |
| 37 | +Small documentation corrections, spelling fixes, and mechanical formatting can skip OpenSpec when they do not change shipped behavior or durable project knowledge. |
| 38 | + |
| 39 | +## Documentation Impact |
| 40 | + |
| 41 | +Every proposal must state how `docs/` and `wiki/` are affected. The answer can be `Updated`, `Not Required`, or `Deferred`, but it must be explicit. |
| 42 | + |
| 43 | +```markdown |
| 44 | +## Documentation Impact |
| 45 | + |
| 46 | +### docs/ |
| 47 | + |
| 48 | +- Updated: `docs/<page>.md` because <current behavior or task changes>. |
| 49 | +- Not Required: <why stable task documentation is unchanged>. |
| 50 | +- Deferred: <follow-up change or task that will update docs>. |
| 51 | + |
| 52 | +### wiki/ |
| 53 | + |
| 54 | +- Updated: `wiki/<page>.md` because <business rule, legacy behavior, migration background, or sourced context changes>. |
| 55 | +- Not Required: <why knowledge base content is unchanged>. |
| 56 | +- Deferred: <follow-up change or task that will update wiki>. |
| 57 | +``` |
| 58 | + |
| 59 | +`docs/` describes current development, runtime, architecture, database, API, moderation, security, migration, and deployment tasks. `wiki/` preserves sourced business knowledge, legacy behavior, migration background, community rules, and facts that need review. Do not write implementation logs into either domain. |
| 60 | + |
| 61 | +| Change kind | Usually update | |
| 62 | +| --- | --- | |
| 63 | +| Runtime architecture, request flow, worker boundary | `docs/architecture.md` | |
| 64 | +| Local development or verification commands | `docs/development.md`, `docs/conventions.md` | |
| 65 | +| PostgreSQL schema, migration, index, data repair | `docs/database.md`, `docs/migration-runbook.md` | |
| 66 | +| Security, auth, roles, audit, secret handling | `docs/security.md` | |
| 67 | +| Content moderation operation | `docs/content-moderation.md`, `wiki/community-rules.md` | |
| 68 | +| Business rule or legacy behavior | `wiki/business-rules.md`, `wiki/legacy-behavior.md` | |
| 69 | +| Mongo to PostgreSQL mapping or migration background | `wiki/migration-background.md` | |
| 70 | + |
| 71 | +Wiki updates must follow `wiki/writing-guidelines.md`: cite sources, separate facts from inferences, and mark uncertain statements as `To Confirm`. |
| 72 | + |
| 73 | +## Diagrams |
| 74 | + |
| 75 | +Use diagrams when prose alone would hide boundaries, ordering, or risk. |
| 76 | + |
| 77 | +| Impact | Preferred form | |
| 78 | +| --- | --- | |
| 79 | +| Architecture or module boundary | Mermaid `flowchart` or `graph` | |
| 80 | +| Request, auth, or integration flow | Mermaid `sequenceDiagram` | |
| 81 | +| Data model or relationship | Mermaid `erDiagram` or a field table | |
| 82 | +| Lifecycle or state transition | Mermaid `stateDiagram-v2` | |
| 83 | +| Permission boundary | Matrix table or Mermaid `flowchart` | |
| 84 | +| Migration, backfill, or release ordering | Mermaid `flowchart LR` | |
| 85 | + |
| 86 | +If no diagram is needed, explain why the change is single-boundary or clear enough in prose. |
| 87 | + |
| 88 | +## Database Change Audit |
| 89 | + |
| 90 | +Database-related changes require a `Database Change Audit` in `design.md`. This applies to PostgreSQL schema changes, Drizzle migrations, seed/bootstrap behavior, indexes, constraints, backfills, cleanups, repair scripts, data retention, and field semantic changes. |
| 91 | + |
| 92 | +```markdown |
| 93 | +## Database Change Audit |
| 94 | + |
| 95 | +### Change Type |
| 96 | + |
| 97 | +- Schema: |
| 98 | +- Migration: |
| 99 | +- Seed/bootstrap: |
| 100 | +- Index/constraint: |
| 101 | +- Data backfill: |
| 102 | +- Data cleanup/repair: |
| 103 | +- Data semantics: |
| 104 | + |
| 105 | +### Impacted Data |
| 106 | + |
| 107 | +- Tables: |
| 108 | +- Columns: |
| 109 | +- Existing rows affected: |
| 110 | +- User-visible behavior affected: |
| 111 | +- Related docs/wiki: |
| 112 | + |
| 113 | +### Compatibility |
| 114 | + |
| 115 | +- Old code with new schema: |
| 116 | +- New code with old data: |
| 117 | +- API/shared schema compatibility: |
| 118 | +- Required deploy order: |
| 119 | + |
| 120 | +### Migration Plan |
| 121 | + |
| 122 | +- Online-safe: |
| 123 | +- Estimated data volume: |
| 124 | +- Locking/full-scan risk: |
| 125 | +- PostgreSQL-specific notes, such as `CONCURRENTLY` or constraint validation: |
| 126 | + |
| 127 | +### Rollback Plan |
| 128 | + |
| 129 | +- Reversible: |
| 130 | +- Data loss risk: |
| 131 | +- Rollback procedure or rationale if not reversible: |
| 132 | + |
| 133 | +### Verification |
| 134 | + |
| 135 | +- Migration test: |
| 136 | +- Data integrity check: |
| 137 | +- Performance check: |
| 138 | +- Docs/wiki updated: |
| 139 | +``` |
| 140 | + |
| 141 | +PostgreSQL is the only runtime database. Do not add SQLite, dialect fallback, local database compatibility paths, or tests that make SQLite a release path. |
| 142 | + |
| 143 | +## Task And Archive Checks |
| 144 | + |
| 145 | +`tasks.md` must include follow-through for the impact declared in the proposal and design. |
| 146 | + |
| 147 | +- Add docs/wiki synchronization tasks when `Documentation Impact` lists updates. |
| 148 | +- Add diagram consistency checks when design includes architecture, state, permission, data, or migration diagrams. |
| 149 | +- Add migration execution, rollback rationale, data integrity, and documentation checks when `Database Change Audit` is present. |
| 150 | +- Run `openspec validate <change> --strict` before asking to archive. |
| 151 | +- Archive only after tasks are complete, validation passes, documentation impact has been handled, and database audit evidence exists where applicable. |
0 commit comments