diff --git a/.claude/skills/development-workflow/SKILL.md b/.claude/skills/development-workflow/SKILL.md new file mode 100644 index 00000000..aca34a0f --- /dev/null +++ b/.claude/skills/development-workflow/SKILL.md @@ -0,0 +1,95 @@ +--- +name: development-workflow +description: Use when executing change delivery work to run OpenSpec-default workflow checkpoints, TODO fallback, and evidence synchronization. +--- + +# Development Workflow + +## When to use +Use this skill for any `bug` / `feature` / `refactor` delivery that must follow the repository documentation-first SOP. +Invoke it before implementation starts and when closing the change lifecycle. + +Do not use this skill for document-only relocation/classification tasks; use `documentation-management` directly for those. + +**REQUIRED SUB-SKILL:** `documentation-management` for classification, placement, metadata, and archive moves. + +## Collaboration mode selection + +1. OpenSpec mode (default) +- build from docs-first inputs: analysis + master TODO + updated design docs +- bind one TODO slice to `openspec/changes//` +- maintain `docs/features/.md` as the single status source for that slice +- treat OpenSpec artifacts as execution records; keep canonical outcomes written in `docs/**` + +2. TODO fallback mode (only if OpenSpec unavailable) +- still start from analysis + master TODO + updated design docs +- create `docs/features/.md` with `mode: todo_fallback` and required `topic_slug` frontmatter +- create dated gap/TODO pair in `docs/todos/` +- once OpenSpec is available, migrate fallback assets into one or more OpenSpec slice changes + +## Required evidence block in feature aggregation doc + +Each active feature aggregation doc MUST contain an `## Evidence` section with at least: +- commands executed (exact commands) +- command results (pass/fail + key output summary) +- behavior verification (happy path + changed error branch) +- risks and rollback notes +- review/merge-gate evidence links (review request, key review threads, merge gate result) + +Reference contract: `docs/guides/Evidence_Truth_Implementation_Strategy.md`. + +## Lifecycle checkpoints + +1. kickoff +- classify request as `bug` / `feature` / `refactor` +- choose collaboration mode (OpenSpec default, TODO fallback only when OpenSpec unavailable) +- complete global analysis before execution +- build/update a master TODO backlog that covers the full scope +- update `docs/design/**` first (no implementation before design update) +- create or refresh feature aggregation doc as the status source +- initialize/refresh the required evidence block in feature aggregation doc before execution +- for OpenSpec mode, select one TODO slice as current change scope +- run `documentation-management` to validate type/path/frontmatter baseline + +2. execution-sync +- OpenSpec mode: execute in small increments `TODO slice item -> OpenSpec task -> implementation -> evidence` +- TODO fallback mode: execute in small increments `TODO item -> implementation -> evidence`, and record pending OpenSpec migration mapping +- keep master TODO status and feature aggregation evidence aligned in all modes +- after each completed task, update linked design/gap/TODO docs and implementation evidence +- append command outputs and behavior-check results to the feature evidence block at task granularity +- for large initiatives, continue by opening the next TODO slice in a new OpenSpec change instead of overloading one change + +3. verification +- OpenSpec mode checks: `openspec validate`, `openspec status`, tests, and repo doc checks +- TODO fallback mode checks: tests, repo doc checks, TODO ledger completeness, and migration debt note completeness +- verify current OpenSpec slice only claims TODO items actually completed in this slice +- verify coverage of interface contracts and error branches for changed behavior +- verify status consistency: feature doc is source of truth, linked docs are non-conflicting +- verify `docs/**` can stand alone as the current-state record without depending on OpenSpec internals +- verify governance CI scope is complete (frontmatter by mode, link resolution, evidence block completeness, TODO->change mapping, checkpoint mapping) +- verify feature evidence block includes commands, results, behavior verification, risks, rollback, and review links + +4. review-merge-gate +- request review with explicit evidence links from the feature aggregation doc +- process review feedback thread-by-thread and keep evidence section updated with fix commits +- require explicit non-blocking merge gate signal (approval or equivalent repo policy signal) before archive +- keep mailbox records linked: temporary coordination notes vs retained audit evidence + +5. completion-archive +- mark work done in feature aggregation and related ledgers +- run `documentation-management` archive actions +- update TODO/archive indexes (for example `docs/todos/README.md` when applicable) +- OpenSpec mode: complete OpenSpec archive when the change is finished +- TODO fallback mode: archive fallback docs/ledgers and keep an explicit migration plan/status until OpenSpec migration is completed +- if master TODO still has pending slices, keep initiative active and start next slice workflow +- ensure archived entries stay discoverable via index/evidence links + +## Output expectations +For each workflow run, report: +- mode used (`openspec` or `todo_fallback`) +- checkpoint completion (`kickoff`, `execution-sync`, `verification`, `review-merge-gate`, `completion-archive`) +- evidence commands executed +- evidence results summary (including changed happy path + error branch checks) +- evidence file updates (design, TODO, OpenSpec tasks, feature aggregation) +- review and merge-gate status +- unresolved risks or migration debt diff --git a/.claude/skills/documentation-management/SKILL.md b/.claude/skills/documentation-management/SKILL.md new file mode 100644 index 00000000..0a357b45 --- /dev/null +++ b/.claude/skills/documentation-management/SKILL.md @@ -0,0 +1,71 @@ +--- +name: documentation-management +description: Use when classifying, creating, relocating, or archiving repository documents to enforce taxonomy, directory placement, and governance metadata contracts. +--- + +# Documentation Management + +## Authoritative inputs +- `docs/governance/Documentation_Management_Model.md` defines repository governance contracts. +- `docs/guides/Evidence_Truth_Implementation_Strategy.md` defines evidence-truth rollout and gate strategy. +- This skill is the single execution entry for both documents; do not split them into a separate evidence-only skill unless responsibilities diverge beyond documentation governance. + +## When to use +Use this skill for documentation structure operations: +- create a new governance-tracked document +- move/rename documentation by type +- add or update frontmatter metadata +- archive completed documentation records + +This skill supersedes `documentation-lifecycle-governance` for documentation governance management responsibilities. + +## Core responsibilities + +1. Classify document kind +- `standard`, `design`, `feature`, `analysis`, `todo`, `temporary` + +2. Enforce type-to-path mapping +- `standard` -> `docs/guides/` or top-level governance rule docs +- `design` -> `docs/design/` +- `feature` -> `docs/features/` +- `analysis` / `todo` -> `docs/todos/` +- `temporary` -> `docs/mailbox/` with mailbox class: + - `temporary_coordination`: short-lived thread notes, removable after cleanup + - `audit_evidence`: review/approval/decision evidence, retained and archived +- archived assets -> `docs/features/archive/`, `docs/todos/archive/`, `docs/design/archive/` + +3. Enforce governance metadata +- ensure frontmatter exists for governance-tracked docs +- required keys (OpenSpec mode): `change_ids`, `doc_kind`, `topics`, `created`, `updated`, `status` +- required keys (TODO fallback mode): `topic_slug`, `mode: todo_fallback`, `doc_kind`, `topics`, `created`, `updated`, `status` +- required keys for mailbox docs: `owner_thread`, `cleanup_plan`, `mailbox_class` +- when fallback assets are migrated into OpenSpec, add `change_ids` and retain `topic_slug` as historical linkage when useful + +4. Enforce archive policy +- completed feature entries move to `docs/features/archive/` +- completed TODO/analysis entries move to `docs/todos/archive/` or be marked archived in index +- `temporary_coordination` mailbox docs may be removed only after cleanup completion is recorded +- `audit_evidence` mailbox docs MUST NOT be deleted; they must remain linked from feature evidence and archived as historical record +- do not delete historical evidence unless explicitly approved + +5. Maintain lifecycle dependency definition +- ensure documentation dependencies are explicit and consistent: + - `standards -> design update -> gap analysis -> master TODO -> feature aggregation -> execution evidence -> review/merge gate -> archive` + +6. Maintain planning-to-execution mapping +- ensure master TODO ledger exists before execution slicing +- for each OpenSpec change, record covered TODO subset (`todo_ids` or equivalent linkage) +- prevent one change from claiming unrelated TODO scope +- ensure review threads and merge-gate decisions are linked from feature evidence + +7. Keep CI gate scope complete (not skill-only) +- enforce that CI checks include metadata, link resolution, evidence completeness, and TODO/change trace mapping +- treat skill-file existence/mapping as one gate dimension, not the full governance gate +- align checks and rollout with `docs/guides/Evidence_Truth_Implementation_Strategy.md` + +## Output expectations +For each management action, provide: +- affected files +- old path -> new path mapping (if moved) +- metadata fields changed +- archive/lifecycle status change diff --git a/.codex/skills/development-workflow/SKILL.md b/.codex/skills/development-workflow/SKILL.md new file mode 100644 index 00000000..aca34a0f --- /dev/null +++ b/.codex/skills/development-workflow/SKILL.md @@ -0,0 +1,95 @@ +--- +name: development-workflow +description: Use when executing change delivery work to run OpenSpec-default workflow checkpoints, TODO fallback, and evidence synchronization. +--- + +# Development Workflow + +## When to use +Use this skill for any `bug` / `feature` / `refactor` delivery that must follow the repository documentation-first SOP. +Invoke it before implementation starts and when closing the change lifecycle. + +Do not use this skill for document-only relocation/classification tasks; use `documentation-management` directly for those. + +**REQUIRED SUB-SKILL:** `documentation-management` for classification, placement, metadata, and archive moves. + +## Collaboration mode selection + +1. OpenSpec mode (default) +- build from docs-first inputs: analysis + master TODO + updated design docs +- bind one TODO slice to `openspec/changes//` +- maintain `docs/features/.md` as the single status source for that slice +- treat OpenSpec artifacts as execution records; keep canonical outcomes written in `docs/**` + +2. TODO fallback mode (only if OpenSpec unavailable) +- still start from analysis + master TODO + updated design docs +- create `docs/features/.md` with `mode: todo_fallback` and required `topic_slug` frontmatter +- create dated gap/TODO pair in `docs/todos/` +- once OpenSpec is available, migrate fallback assets into one or more OpenSpec slice changes + +## Required evidence block in feature aggregation doc + +Each active feature aggregation doc MUST contain an `## Evidence` section with at least: +- commands executed (exact commands) +- command results (pass/fail + key output summary) +- behavior verification (happy path + changed error branch) +- risks and rollback notes +- review/merge-gate evidence links (review request, key review threads, merge gate result) + +Reference contract: `docs/guides/Evidence_Truth_Implementation_Strategy.md`. + +## Lifecycle checkpoints + +1. kickoff +- classify request as `bug` / `feature` / `refactor` +- choose collaboration mode (OpenSpec default, TODO fallback only when OpenSpec unavailable) +- complete global analysis before execution +- build/update a master TODO backlog that covers the full scope +- update `docs/design/**` first (no implementation before design update) +- create or refresh feature aggregation doc as the status source +- initialize/refresh the required evidence block in feature aggregation doc before execution +- for OpenSpec mode, select one TODO slice as current change scope +- run `documentation-management` to validate type/path/frontmatter baseline + +2. execution-sync +- OpenSpec mode: execute in small increments `TODO slice item -> OpenSpec task -> implementation -> evidence` +- TODO fallback mode: execute in small increments `TODO item -> implementation -> evidence`, and record pending OpenSpec migration mapping +- keep master TODO status and feature aggregation evidence aligned in all modes +- after each completed task, update linked design/gap/TODO docs and implementation evidence +- append command outputs and behavior-check results to the feature evidence block at task granularity +- for large initiatives, continue by opening the next TODO slice in a new OpenSpec change instead of overloading one change + +3. verification +- OpenSpec mode checks: `openspec validate`, `openspec status`, tests, and repo doc checks +- TODO fallback mode checks: tests, repo doc checks, TODO ledger completeness, and migration debt note completeness +- verify current OpenSpec slice only claims TODO items actually completed in this slice +- verify coverage of interface contracts and error branches for changed behavior +- verify status consistency: feature doc is source of truth, linked docs are non-conflicting +- verify `docs/**` can stand alone as the current-state record without depending on OpenSpec internals +- verify governance CI scope is complete (frontmatter by mode, link resolution, evidence block completeness, TODO->change mapping, checkpoint mapping) +- verify feature evidence block includes commands, results, behavior verification, risks, rollback, and review links + +4. review-merge-gate +- request review with explicit evidence links from the feature aggregation doc +- process review feedback thread-by-thread and keep evidence section updated with fix commits +- require explicit non-blocking merge gate signal (approval or equivalent repo policy signal) before archive +- keep mailbox records linked: temporary coordination notes vs retained audit evidence + +5. completion-archive +- mark work done in feature aggregation and related ledgers +- run `documentation-management` archive actions +- update TODO/archive indexes (for example `docs/todos/README.md` when applicable) +- OpenSpec mode: complete OpenSpec archive when the change is finished +- TODO fallback mode: archive fallback docs/ledgers and keep an explicit migration plan/status until OpenSpec migration is completed +- if master TODO still has pending slices, keep initiative active and start next slice workflow +- ensure archived entries stay discoverable via index/evidence links + +## Output expectations +For each workflow run, report: +- mode used (`openspec` or `todo_fallback`) +- checkpoint completion (`kickoff`, `execution-sync`, `verification`, `review-merge-gate`, `completion-archive`) +- evidence commands executed +- evidence results summary (including changed happy path + error branch checks) +- evidence file updates (design, TODO, OpenSpec tasks, feature aggregation) +- review and merge-gate status +- unresolved risks or migration debt diff --git a/.codex/skills/documentation-management/SKILL.md b/.codex/skills/documentation-management/SKILL.md new file mode 100644 index 00000000..0a357b45 --- /dev/null +++ b/.codex/skills/documentation-management/SKILL.md @@ -0,0 +1,71 @@ +--- +name: documentation-management +description: Use when classifying, creating, relocating, or archiving repository documents to enforce taxonomy, directory placement, and governance metadata contracts. +--- + +# Documentation Management + +## Authoritative inputs +- `docs/governance/Documentation_Management_Model.md` defines repository governance contracts. +- `docs/guides/Evidence_Truth_Implementation_Strategy.md` defines evidence-truth rollout and gate strategy. +- This skill is the single execution entry for both documents; do not split them into a separate evidence-only skill unless responsibilities diverge beyond documentation governance. + +## When to use +Use this skill for documentation structure operations: +- create a new governance-tracked document +- move/rename documentation by type +- add or update frontmatter metadata +- archive completed documentation records + +This skill supersedes `documentation-lifecycle-governance` for documentation governance management responsibilities. + +## Core responsibilities + +1. Classify document kind +- `standard`, `design`, `feature`, `analysis`, `todo`, `temporary` + +2. Enforce type-to-path mapping +- `standard` -> `docs/guides/` or top-level governance rule docs +- `design` -> `docs/design/` +- `feature` -> `docs/features/` +- `analysis` / `todo` -> `docs/todos/` +- `temporary` -> `docs/mailbox/` with mailbox class: + - `temporary_coordination`: short-lived thread notes, removable after cleanup + - `audit_evidence`: review/approval/decision evidence, retained and archived +- archived assets -> `docs/features/archive/`, `docs/todos/archive/`, `docs/design/archive/` + +3. Enforce governance metadata +- ensure frontmatter exists for governance-tracked docs +- required keys (OpenSpec mode): `change_ids`, `doc_kind`, `topics`, `created`, `updated`, `status` +- required keys (TODO fallback mode): `topic_slug`, `mode: todo_fallback`, `doc_kind`, `topics`, `created`, `updated`, `status` +- required keys for mailbox docs: `owner_thread`, `cleanup_plan`, `mailbox_class` +- when fallback assets are migrated into OpenSpec, add `change_ids` and retain `topic_slug` as historical linkage when useful + +4. Enforce archive policy +- completed feature entries move to `docs/features/archive/` +- completed TODO/analysis entries move to `docs/todos/archive/` or be marked archived in index +- `temporary_coordination` mailbox docs may be removed only after cleanup completion is recorded +- `audit_evidence` mailbox docs MUST NOT be deleted; they must remain linked from feature evidence and archived as historical record +- do not delete historical evidence unless explicitly approved + +5. Maintain lifecycle dependency definition +- ensure documentation dependencies are explicit and consistent: + - `standards -> design update -> gap analysis -> master TODO -> feature aggregation -> execution evidence -> review/merge gate -> archive` + +6. Maintain planning-to-execution mapping +- ensure master TODO ledger exists before execution slicing +- for each OpenSpec change, record covered TODO subset (`todo_ids` or equivalent linkage) +- prevent one change from claiming unrelated TODO scope +- ensure review threads and merge-gate decisions are linked from feature evidence + +7. Keep CI gate scope complete (not skill-only) +- enforce that CI checks include metadata, link resolution, evidence completeness, and TODO/change trace mapping +- treat skill-file existence/mapping as one gate dimension, not the full governance gate +- align checks and rollout with `docs/guides/Evidence_Truth_Implementation_Strategy.md` + +## Output expectations +For each management action, provide: +- affected files +- old path -> new path mapping (if moved) +- metadata fields changed +- archive/lifecycle status change diff --git a/.gemini/skills/development-workflow/SKILL.md b/.gemini/skills/development-workflow/SKILL.md new file mode 100644 index 00000000..aca34a0f --- /dev/null +++ b/.gemini/skills/development-workflow/SKILL.md @@ -0,0 +1,95 @@ +--- +name: development-workflow +description: Use when executing change delivery work to run OpenSpec-default workflow checkpoints, TODO fallback, and evidence synchronization. +--- + +# Development Workflow + +## When to use +Use this skill for any `bug` / `feature` / `refactor` delivery that must follow the repository documentation-first SOP. +Invoke it before implementation starts and when closing the change lifecycle. + +Do not use this skill for document-only relocation/classification tasks; use `documentation-management` directly for those. + +**REQUIRED SUB-SKILL:** `documentation-management` for classification, placement, metadata, and archive moves. + +## Collaboration mode selection + +1. OpenSpec mode (default) +- build from docs-first inputs: analysis + master TODO + updated design docs +- bind one TODO slice to `openspec/changes//` +- maintain `docs/features/.md` as the single status source for that slice +- treat OpenSpec artifacts as execution records; keep canonical outcomes written in `docs/**` + +2. TODO fallback mode (only if OpenSpec unavailable) +- still start from analysis + master TODO + updated design docs +- create `docs/features/.md` with `mode: todo_fallback` and required `topic_slug` frontmatter +- create dated gap/TODO pair in `docs/todos/` +- once OpenSpec is available, migrate fallback assets into one or more OpenSpec slice changes + +## Required evidence block in feature aggregation doc + +Each active feature aggregation doc MUST contain an `## Evidence` section with at least: +- commands executed (exact commands) +- command results (pass/fail + key output summary) +- behavior verification (happy path + changed error branch) +- risks and rollback notes +- review/merge-gate evidence links (review request, key review threads, merge gate result) + +Reference contract: `docs/guides/Evidence_Truth_Implementation_Strategy.md`. + +## Lifecycle checkpoints + +1. kickoff +- classify request as `bug` / `feature` / `refactor` +- choose collaboration mode (OpenSpec default, TODO fallback only when OpenSpec unavailable) +- complete global analysis before execution +- build/update a master TODO backlog that covers the full scope +- update `docs/design/**` first (no implementation before design update) +- create or refresh feature aggregation doc as the status source +- initialize/refresh the required evidence block in feature aggregation doc before execution +- for OpenSpec mode, select one TODO slice as current change scope +- run `documentation-management` to validate type/path/frontmatter baseline + +2. execution-sync +- OpenSpec mode: execute in small increments `TODO slice item -> OpenSpec task -> implementation -> evidence` +- TODO fallback mode: execute in small increments `TODO item -> implementation -> evidence`, and record pending OpenSpec migration mapping +- keep master TODO status and feature aggregation evidence aligned in all modes +- after each completed task, update linked design/gap/TODO docs and implementation evidence +- append command outputs and behavior-check results to the feature evidence block at task granularity +- for large initiatives, continue by opening the next TODO slice in a new OpenSpec change instead of overloading one change + +3. verification +- OpenSpec mode checks: `openspec validate`, `openspec status`, tests, and repo doc checks +- TODO fallback mode checks: tests, repo doc checks, TODO ledger completeness, and migration debt note completeness +- verify current OpenSpec slice only claims TODO items actually completed in this slice +- verify coverage of interface contracts and error branches for changed behavior +- verify status consistency: feature doc is source of truth, linked docs are non-conflicting +- verify `docs/**` can stand alone as the current-state record without depending on OpenSpec internals +- verify governance CI scope is complete (frontmatter by mode, link resolution, evidence block completeness, TODO->change mapping, checkpoint mapping) +- verify feature evidence block includes commands, results, behavior verification, risks, rollback, and review links + +4. review-merge-gate +- request review with explicit evidence links from the feature aggregation doc +- process review feedback thread-by-thread and keep evidence section updated with fix commits +- require explicit non-blocking merge gate signal (approval or equivalent repo policy signal) before archive +- keep mailbox records linked: temporary coordination notes vs retained audit evidence + +5. completion-archive +- mark work done in feature aggregation and related ledgers +- run `documentation-management` archive actions +- update TODO/archive indexes (for example `docs/todos/README.md` when applicable) +- OpenSpec mode: complete OpenSpec archive when the change is finished +- TODO fallback mode: archive fallback docs/ledgers and keep an explicit migration plan/status until OpenSpec migration is completed +- if master TODO still has pending slices, keep initiative active and start next slice workflow +- ensure archived entries stay discoverable via index/evidence links + +## Output expectations +For each workflow run, report: +- mode used (`openspec` or `todo_fallback`) +- checkpoint completion (`kickoff`, `execution-sync`, `verification`, `review-merge-gate`, `completion-archive`) +- evidence commands executed +- evidence results summary (including changed happy path + error branch checks) +- evidence file updates (design, TODO, OpenSpec tasks, feature aggregation) +- review and merge-gate status +- unresolved risks or migration debt diff --git a/.gemini/skills/documentation-management/SKILL.md b/.gemini/skills/documentation-management/SKILL.md new file mode 100644 index 00000000..0a357b45 --- /dev/null +++ b/.gemini/skills/documentation-management/SKILL.md @@ -0,0 +1,71 @@ +--- +name: documentation-management +description: Use when classifying, creating, relocating, or archiving repository documents to enforce taxonomy, directory placement, and governance metadata contracts. +--- + +# Documentation Management + +## Authoritative inputs +- `docs/governance/Documentation_Management_Model.md` defines repository governance contracts. +- `docs/guides/Evidence_Truth_Implementation_Strategy.md` defines evidence-truth rollout and gate strategy. +- This skill is the single execution entry for both documents; do not split them into a separate evidence-only skill unless responsibilities diverge beyond documentation governance. + +## When to use +Use this skill for documentation structure operations: +- create a new governance-tracked document +- move/rename documentation by type +- add or update frontmatter metadata +- archive completed documentation records + +This skill supersedes `documentation-lifecycle-governance` for documentation governance management responsibilities. + +## Core responsibilities + +1. Classify document kind +- `standard`, `design`, `feature`, `analysis`, `todo`, `temporary` + +2. Enforce type-to-path mapping +- `standard` -> `docs/guides/` or top-level governance rule docs +- `design` -> `docs/design/` +- `feature` -> `docs/features/` +- `analysis` / `todo` -> `docs/todos/` +- `temporary` -> `docs/mailbox/` with mailbox class: + - `temporary_coordination`: short-lived thread notes, removable after cleanup + - `audit_evidence`: review/approval/decision evidence, retained and archived +- archived assets -> `docs/features/archive/`, `docs/todos/archive/`, `docs/design/archive/` + +3. Enforce governance metadata +- ensure frontmatter exists for governance-tracked docs +- required keys (OpenSpec mode): `change_ids`, `doc_kind`, `topics`, `created`, `updated`, `status` +- required keys (TODO fallback mode): `topic_slug`, `mode: todo_fallback`, `doc_kind`, `topics`, `created`, `updated`, `status` +- required keys for mailbox docs: `owner_thread`, `cleanup_plan`, `mailbox_class` +- when fallback assets are migrated into OpenSpec, add `change_ids` and retain `topic_slug` as historical linkage when useful + +4. Enforce archive policy +- completed feature entries move to `docs/features/archive/` +- completed TODO/analysis entries move to `docs/todos/archive/` or be marked archived in index +- `temporary_coordination` mailbox docs may be removed only after cleanup completion is recorded +- `audit_evidence` mailbox docs MUST NOT be deleted; they must remain linked from feature evidence and archived as historical record +- do not delete historical evidence unless explicitly approved + +5. Maintain lifecycle dependency definition +- ensure documentation dependencies are explicit and consistent: + - `standards -> design update -> gap analysis -> master TODO -> feature aggregation -> execution evidence -> review/merge gate -> archive` + +6. Maintain planning-to-execution mapping +- ensure master TODO ledger exists before execution slicing +- for each OpenSpec change, record covered TODO subset (`todo_ids` or equivalent linkage) +- prevent one change from claiming unrelated TODO scope +- ensure review threads and merge-gate decisions are linked from feature evidence + +7. Keep CI gate scope complete (not skill-only) +- enforce that CI checks include metadata, link resolution, evidence completeness, and TODO/change trace mapping +- treat skill-file existence/mapping as one gate dimension, not the full governance gate +- align checks and rollout with `docs/guides/Evidence_Truth_Implementation_Strategy.md` + +## Output expectations +For each management action, provide: +- affected files +- old path -> new path mapping (if moved) +- metadata fields changed +- archive/lifecycle status change diff --git a/.github/workflows/ci-gate.yml b/.github/workflows/ci-gate.yml index 2e7656f9..1cc03027 100644 --- a/.github/workflows/ci-gate.yml +++ b/.github/workflows/ci-gate.yml @@ -132,3 +132,13 @@ jobs: - name: Check design documentation drift run: ./scripts/ci/check_design_doc_drift.sh + + governance-evidence-truth: + name: governance-evidence-truth + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check governance evidence truth contract + run: ./scripts/ci/check_governance_evidence_truth.sh diff --git a/AGENTS.md b/AGENTS.md index 35703da4..49ad486c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,8 +18,8 @@ - key interfaces - exception/error handling - For any bug fix, feature, or refactor, follow the SOP sequence: - 1. update design docs - 2. generate design-code gap analysis - 3. derive TODO list from the analysis - 4. execute fixes via OpenSpec workflow task-by-task + 1. perform full-scope analysis and create a master TODO backlog + 2. update design docs and governance docs (docs are canonical) + 3. slice TODO backlog into one or more OpenSpec changes + 4. execute fixes via OpenSpec workflow task-by-task per slice 5. update TODO/evidence and archive analysis artifacts diff --git a/docs/README.md b/docs/README.md index e7dfde14..403acfcf 100644 --- a/docs/README.md +++ b/docs/README.md @@ -41,6 +41,9 @@ ├── /CONTRIBUTING_AI.md (AI Agent 协作规范) ├── guides/Development_Constraints.md (开发约束清单) ├── guides/Documentation_First_Development_SOP.md (文档先行 SOP,Bug/Feature/Refactor 必走) + ├── guides/Evidence_Truth_Implementation_Strategy.md (Evidence Truth 固化策略与 CI 落地计划) + ├── governance/Documentation_Management_Model.md (文档目录分层、生命周期、OpenSpec/TODO 双模式协作) + ├── features/README.md (特性聚合文档规范与归档规则) └── design/Design_Doc_Minimum_Standard.md (设计文档最小完备标准) ``` @@ -91,6 +94,9 @@ | `guides/Engineering_Practice_Guide_Sandbox_and_WORM.md` | 工程实践指南:沙箱执行隔离(seccomp/网络/镜像)、WORM 落地与核查 | | `guides/Development_Constraints.md` | 开发约束:架构不破坏、测试必备、日志/命名/复用/信任边界等硬性要求 | | `guides/Documentation_First_Development_SOP.md` | 文档先行 SOP:先设计文档、再 gap 分析、再 TODO、再 OpenSpec 修复、再归档 | +| `guides/Evidence_Truth_Implementation_Strategy.md` | Evidence Truth 固化策略:证据结构、审计要求、CI 分阶段落地 | +| `governance/Documentation_Management_Model.md` | 文档管理模型:目录分层、文档类型规则、生命周期依赖、OpenSpec/无 OpenSpec 协作 | +| `features/README.md` | 特性聚合文档规范:单一状态源、证据回写与归档迁移 | | `guides/Tool_Approval_Memory.md` | 工具审批记忆使用指南:pending/grant/deny/revoke、scope/matcher、持久化与接线方式 | --- @@ -290,14 +296,26 @@ docs/ │ ├── Interface_Layer_Design_v1.1_MCP_and_Builtin.md │ ├── ARCHITECTURE_COMPARISON.md │ └── ...(更多历史文档) +├── features/ +│ ├── README.md +│ ├── .md(每个 change 一个聚合文档) +│ └── archive/ +├── governance/ +│ ├── Documentation_Management_Model.md +│ └── branch-protection.md ├── guides/ │ ├── Development_Constraints.md +│ ├── Documentation_First_Development_SOP.md │ └── Engineering_Practice_Guide_Sandbox_and_WORM.md +├── todos/ +│ ├── YYYY-MM-DD__design_code_gap_analysis.md +│ ├── YYYY-MM-DD__design_code_gap_todo.md +│ └── archive/ └── appendix/ └── Appendix_Industrial_Security_and_Auditing.md ``` --- -*最后更新:2026-02-27* +*最后更新:2026-02-28* *维护者:DARE Framework Team* diff --git a/docs/agent_rules.md b/docs/agent_rules.md index 2a49ce84..2b9b5feb 100644 --- a/docs/agent_rules.md +++ b/docs/agent_rules.md @@ -8,6 +8,11 @@ These rules apply to all agent-generated changes in this repository. 3. 不得修改公共接口/数据结构,除非任务明确且给出影响分析。 4. 必须补测试或更新测试,并附上本地/CI 的测试证据。 5. 任何跳过测试(skip/only/exclude)必须说明理由并经过 review。 +6. 文档治理任务必须遵循 `docs/governance/Documentation_Management_Model.md` 的目录分层与生命周期规则。 +7. 默认采用 OpenSpec 协作;OpenSpec 不可用时仅可使用 TODO-driven 回退模式,并需补迁移证据。 +8. 文档创建/迁移/归档时必须执行双技能流程:`.codex/skills/documentation-management/SKILL.md` + `.codex/skills/development-workflow/SKILL.md`。 +9. `docs/features/.md` 是特性状态单一真相源,其他文档不得写冲突状态。 +10. Evidence Truth 必须结构化落盘并通过 `./scripts/ci/check_governance_evidence_truth.sh`(详见 `docs/guides/Evidence_Truth_Implementation_Strategy.md`)。 ## Operating Notes - Keep diffs small to reduce merge conflicts in multi-agent parallel work. diff --git a/docs/design/Design_Reconstructability_Traceability_Matrix.md b/docs/design/Design_Reconstructability_Traceability_Matrix.md index dea29d51..fc6b33ce 100644 --- a/docs/design/Design_Reconstructability_Traceability_Matrix.md +++ b/docs/design/Design_Reconstructability_Traceability_Matrix.md @@ -27,3 +27,11 @@ 1. `Plan->Execute` 的 `APPROVE_REQUIRED` 仍以 fail-fast 为主,需与 ToolLoop 语义统一。 2. Hook payload schema 跨模块 contract 仍在收敛。 3. 文档治理链路已建立,但自动化漂移校验需要持续补强。 + +## Governance 聚合锚点(新增) + +> 说明:治理类 change 需要在本矩阵中补充 `feature aggregation` 锚点,确保从能力声明可直接跳转到变更级证据入口。 + +| Capability | Feature Aggregation Anchor | OpenSpec Change | +|---|---|---| +| Documentation-first 治理闭环 | `docs/features/enhance-doc-governance-traceability.md` | `openspec/changes/enhance-doc-governance-traceability/` | diff --git a/docs/features/README.md b/docs/features/README.md new file mode 100644 index 00000000..cc4e96f8 --- /dev/null +++ b/docs/features/README.md @@ -0,0 +1,31 @@ +# Feature Aggregation Docs + +`docs/features/` stores one aggregation document per active change/topic. + +## Rules + +1. File naming +- OpenSpec mode: `docs/features/.md` +- TODO fallback mode: `docs/features/.md` + +2. Source of truth +- Aggregation document owns lifecycle status (`draft/active/done/archived`). +- Linked analysis/todo/design docs should not override this status. + +3. Required links +- OpenSpec artifacts (`proposal/design/specs/tasks`) or TODO fallback bundle +- Related design docs +- Gap analysis + TODO evidence +- Verification evidence (commands/results) + +4. Required evidence truth structure +- `## Evidence` +- `### Commands` +- `### Results` +- `### Behavior Verification` +- `### Risks and Rollback` +- `### Review and Merge Gate Links` +- CI gate command: `./scripts/ci/check_governance_evidence_truth.sh` + +5. Archive +- Move completed docs to `docs/features/archive/` after closeout. diff --git a/docs/features/archive/.gitkeep b/docs/features/archive/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/docs/features/enhance-doc-governance-traceability.md b/docs/features/enhance-doc-governance-traceability.md new file mode 100644 index 00000000..2ee4955c --- /dev/null +++ b/docs/features/enhance-doc-governance-traceability.md @@ -0,0 +1,58 @@ +--- +change_ids: ["enhance-doc-governance-traceability"] +doc_kind: feature +topics: ["documentation-governance", "traceability", "skills"] +created: 2026-02-28 +updated: 2026-02-28 +status: active +mode: openspec +--- + +# Feature: enhance-doc-governance-traceability + +## Scope +Unify documentation management structure, lifecycle governance, and SOP-to-skill execution mapping. + +## OpenSpec Artifacts +- Proposal: `openspec/changes/enhance-doc-governance-traceability/proposal.md` +- Design: `openspec/changes/enhance-doc-governance-traceability/design.md` +- Specs: + - `openspec/changes/enhance-doc-governance-traceability/specs/documentation-lifecycle-traceability/spec.md` + - `openspec/changes/enhance-doc-governance-traceability/specs/design-reconstructability-governance/spec.md` +- Tasks: `openspec/changes/enhance-doc-governance-traceability/tasks.md` + +## Governance Anchors +- `docs/governance/Documentation_Management_Model.md` +- `docs/guides/Documentation_First_Development_SOP.md` +- `.codex/skills/documentation-management/SKILL.md` +- `.codex/skills/development-workflow/SKILL.md` + +## Evidence + +### Commands +- `./scripts/ci/check_governance_evidence_truth.sh` +- `openspec validate --changes enhance-doc-governance-traceability` +- `openspec status --change enhance-doc-governance-traceability --json` + +### Results +- governance-evidence-truth: passed. +- validate: passed (all changes validated). +- status: `isComplete: true` for `enhance-doc-governance-traceability`. + +### Behavior Verification +- Happy path: governance flow remains `analysis -> master TODO -> OpenSpec slice execution` with docs as canonical source. +- Error/fallback path: TODO fallback metadata now requires `mode: todo_fallback` + `topic_slug`, with explicit migration back to OpenSpec. + +### Risks and Rollback +- Risk: CI checks not yet fully implemented as scripts may leave policy drift windows. +- Rollback: keep contract wording changes, temporarily downgrade new CI gate checks to warning if false positives block delivery. + +### Review and Merge Gate Links +- Review request: `https://github.com/zts212653/Deterministic-Agent-Runtime-Engine/pull/126#issuecomment-3976690386` +- Key owner feedback: `https://github.com/zts212653/Deterministic-Agent-Runtime-Engine/pull/126#issuecomment-3976707233` +- Active fix threads: + - `https://github.com/zts212653/Deterministic-Agent-Runtime-Engine/pull/126#discussion_r2867257929` + - `https://github.com/zts212653/Deterministic-Agent-Runtime-Engine/pull/126#discussion_r2867257932` + +## Next Milestone +Implement tasks group 1-2 (taxonomy contract + standards alignment). diff --git a/docs/governance/Documentation_Management_Model.md b/docs/governance/Documentation_Management_Model.md new file mode 100644 index 00000000..43161906 --- /dev/null +++ b/docs/governance/Documentation_Management_Model.md @@ -0,0 +1,158 @@ +# Documentation Management Model + +> Scope: Repository-wide documentation governance for design, analysis, feature lifecycle, standards, temporary notes, and archive. + +## 1. Governance Targets + +The documentation system MUST satisfy both goals: +- Reconstructability: system behavior can be rebuilt from docs. +- Traceability: any active change can be traced end-to-end in minutes. + +### 1.1 Source-of-Truth Boundary + +- `docs/**` is the canonical, full repository documentation source of truth. +- `openspec/**` is the change-execution process record (proposal/design/spec delta/tasks/evidence trace), not a replacement for canonical docs. +- Any OpenSpec execution outcome that affects long-term understanding MUST be written back into `docs/**` (especially design, feature aggregation, and TODO/analysis ledgers). +- Readers should be able to understand current architecture and behavior from `docs/**` without relying on OpenSpec internals beyond trace links. + +### 1.2 Truth Layers (Governance Semantics) + +- Normative truth: standards and design contracts (`docs/guides/**`, `docs/design/**`, governance rules). +- Operational truth: actual runtime behavior in code + tests. +- Evidence truth: verification, review, and merge-gate records used for audit and regression prevention. +- Governance checks MUST preserve consistency across all three layers. +- Evidence-truth implementation and rollout strategy is defined in `docs/guides/Evidence_Truth_Implementation_Strategy.md`. + +## 2. Directory Taxonomy (Single Source) + +| Layer | Path | Purpose | Lifecycle | +|---|---|---|---| +| Standards | `docs/guides/`, `docs/agent_rules.md`, `AGENTS.md` | Rules, constraints, SOP, collaboration protocol | stable + versioned | +| Design | `docs/design/` | Authoritative architecture/interface/module design | active + archived | +| Governance | `docs/governance/` | Governance model, branch rules, policy checkpoints | stable | +| Feature Aggregation | `docs/features/` | One aggregation doc per change/topic (single status source) | active -> archive | +| Analysis/TODO | `docs/todos/` | Gap analysis and execution TODO ledgers | active -> archive | +| Temporary | `docs/mailbox/` | Thread-local notes + review/audit evidence artifacts | temporary -> archive/remove | +| Reference | `docs/appendix/` | Supporting references and non-normative materials | stable | +| Archives | `docs/design/archive/`, `docs/todos/archive/`, `docs/features/archive/` | Historical snapshots and closed records | immutable-ish | + +## 3. Document Types and Placement Rules + +1. Design docs: place under `docs/design/**`; must align with current implementation contract. +2. Analysis docs: place under `docs/todos/` as dated gap analysis and TODO pairs. +3. Feature docs: + - OpenSpec mode: place under `docs/features/.md` + - TODO fallback mode: place under `docs/features/.md` with `mode: todo_fallback` + `topic_slug` + - this aggregation doc remains the single source for feature/change status in either mode. +4. Standards docs: place under `docs/guides/` or top-level governance rule files. +5. Temporary docs: place under `docs/mailbox/`; must declare `mailbox_class`: + - `temporary_coordination`: linked to owner thread + cleanup plan, removable after cleanup. + - `audit_evidence`: linked to review/approval records, retained and archived (non-deletable by default). + +## 4. Lifecycle Dependencies + +The default dependency chain is: + +`standards -> design update -> gap analysis -> master TODO -> feature aggregation -> execution -> evidence -> review/merge gate -> archive` + +Status transitions: +- `draft` -> `active` -> `done` -> `archived` +- only aggregation docs own lifecycle state; linked docs SHOULD NOT duplicate conflicting status values. + +## 5. Collaboration Modes + +### 5.1 OpenSpec Mode (Default) + +Use this whenever OpenSpec is available: +1. Perform full-scope analysis and maintain a master TODO backlog in `docs/todos/`. +2. Update canonical docs (`docs/design/**` and related governance docs) before execution. +3. Select one TODO slice and create/continue `openspec/changes//` for that slice. +4. Create/update `docs/features/.md` and initialize evidence block. +5. Execute tasks iteratively; write evidence into feature aggregation + TODO ledger. +6. Verify with tests/checks; update docs consistency and evidence completeness. +7. Run review/merge gate and link decision evidence. +8. Archive the completed change and migrate feature doc to `docs/features/archive/`. +9. Repeat with next TODO slice until master TODO backlog is fully completed. + +### 5.2 No-OpenSpec Fallback Mode (TODO-driven) + +Use only when OpenSpec cannot be used (tooling/environment constraint): +1. Perform full-scope analysis and maintain a master TODO backlog in `docs/todos/`. +2. Update canonical docs (`docs/design/**` and related governance docs) before execution. +3. Create `docs/features/.md` with `mode: todo_fallback` and `topic_slug` in frontmatter. +4. Execute against TODO checklist with evidence updates per task. +5. Run review/merge gate using fallback evidence and retained mailbox audit records. +6. When OpenSpec becomes available, migrate fallback assets into one or more OpenSpec slice changes and link migration evidence. + +### 5.3 OpenSpec Slicing Policy (Large Changes) + +- OpenSpec change is an execution slice unit, not a full initiative container. +- A large feature/refactor/bug campaign SHOULD be split into multiple change-ids. +- Master TODO backlog in `docs/todos/` is the upstream planning input for slice creation. +- Each change MUST declare which TODO subset it consumes and must not claim unrelated TODO items. + +## 6. Frontmatter Contract (Governance-tracked docs) + +Governance-tracked docs MUST include frontmatter with: + +```yaml +--- +change_ids: [""] +doc_kind: feature|analysis|todo|standard|design|temporary +topics: ["..."] +created: YYYY-MM-DD +updated: YYYY-MM-DD +status: draft|active|done|archived +--- +``` + +Recommended optional fields: +- `todo_ids`: list of master TODO item IDs covered by this document/change slice +- `mode`: `openspec` or `todo_fallback` +- `topic_slug`: required in fallback mode before `change_ids` is assigned +- `owner_thread`: required for `docs/mailbox/**` documents +- `cleanup_plan`: required for `temporary_coordination` mailbox docs +- `mailbox_class`: `temporary_coordination` or `audit_evidence` + +Notes: +- `status` on non-aggregation docs is informational only. +- Aggregation doc is the status source of truth. +- Explicit exceptions, if any, must be declared in the governing standard document for that doc family. +- TODO fallback mode exception: before OpenSpec change-id exists, fallback docs MUST provide `topic_slug` and `mode: todo_fallback`; `change_ids` becomes mandatory after migration into OpenSpec. + +## 7. Checkpoint-to-Skill Mapping + +Required lifecycle checkpoints MUST be skillized: +- kickoff +- execution-sync +- verification +- review-merge-gate +- completion-archive + +Skill contract (minimum two skills): +- management skill: `.codex/skills/documentation-management/SKILL.md` +- workflow skill: `.codex/skills/development-workflow/SKILL.md` + +Checkpoint mapping: +- kickoff -> `development-workflow` (mode/scope) + `documentation-management` (baseline metadata/path) +- execution-sync -> `development-workflow` (evidence/status sync) + `documentation-management` (metadata consistency) +- verification -> `development-workflow` (gate/check commands + status conflict detection) +- review-merge-gate -> `development-workflow` (review handling + merge decision) + `documentation-management` (mailbox evidence retention + link integrity) +- completion-archive -> `development-workflow` (closure) + `documentation-management` (archive move and retention policy) + +CI MUST validate: +- required skill files exist, +- checkpoint mapping is declared, +- governance frontmatter required keys by mode (OpenSpec vs TODO fallback) are present, +- feature aggregation links to real OpenSpec artifact paths, +- evidence block required fields (commands/results/behavior checks/risks/rollback/review links) are present for active items, +- evidence-truth gate command `./scripts/ci/check_governance_evidence_truth.sh` passes, +- required assets and linkages are present. + +## 8. Effectiveness Criteria + +Governance is considered effective when: +- active change context can be located in <= 5 minutes, +- traceability mapping completeness >= 95%, +- stale/unlinked governance docs trend down each iteration, +- archive migration occurs within one iteration after completion. diff --git a/docs/guides/Development_Constraints.md b/docs/guides/Development_Constraints.md index 28da9af8..cec0e5b4 100644 --- a/docs/guides/Development_Constraints.md +++ b/docs/guides/Development_Constraints.md @@ -10,9 +10,13 @@ ## 文档先行硬门禁(新增,强制) - Agent 开发必须先遵循 `docs/guides/` 约束,最低要求:`Development_Constraints.md` + `Documentation_First_Development_SOP.md`。 +- 文档管理方式必须遵循 `docs/governance/Documentation_Management_Model.md`(目录分层、文档类型放置、生命周期迁移)。 - 所有代码开发以 `docs/design/` 全量最新设计为准;若实现与文档冲突,必须先更新文档再改代码。 - 设计文档必须可独立重建实现:至少显式描述总体架构、核心流程、数据结构、关键接口、异常错误处理(详见 `docs/design/Design_Doc_Minimum_Standard.md`)。 -- 任何 Bug/新增 Feature/重构,必须先执行“文档更新 + gap 分析 + TODO 拆解”,再按 OpenSpec 流程逐项落地。 +- 任何 Bug/新增 Feature/重构,必须先执行“全局分析 + 总体 TODO 主清单 + docs 更新”,再按 TODO 切片进入 OpenSpec 流程逐项落地(大改动通常对应多个 OpenSpec change)。 +- 默认采用 OpenSpec 协作;仅在 OpenSpec 不可用时允许 TODO-driven 回退模式,并必须在 OpenSpec 恢复后完成迁移回写。 +- 任何治理类文档任务必须使用双技能流程(`.codex/skills/documentation-management/SKILL.md` + `.codex/skills/development-workflow/SKILL.md`)或等价自动化流程。 +- Evidence Truth 必须结构化固化到 `docs/features/*.md`,并通过 `./scripts/ci/check_governance_evidence_truth.sh` 门禁校验(见 `docs/guides/Evidence_Truth_Implementation_Strategy.md`)。 - 禁止“先写代码后补文档”;除紧急止血修复外,文档缺失视为任务未开始。紧急修复需在 24 小时内补齐文档与 gap 分析。 ## 设计准则(高内聚、低耦合) diff --git a/docs/guides/Documentation_First_Development_SOP.md b/docs/guides/Documentation_First_Development_SOP.md index b4ef09d3..a99724f6 100644 --- a/docs/guides/Documentation_First_Development_SOP.md +++ b/docs/guides/Documentation_First_Development_SOP.md @@ -14,18 +14,23 @@ - 关键接口 - 异常与错误处理 4. 任何 Bug/Feature/Refactor,必须先判断是否为设计约束不清或缺失;是则先补文档。 -5. 开发闭环必须是:文档更新 -> gap 分析 -> TODO 清单 -> OpenSpec 执行 -> TODO 回写 -> 文档归档。 +5. 开发闭环必须是:全局分析 -> 总体 TODO 主清单 -> docs 更新 -> 按 TODO 切片进入 OpenSpec 执行 -> TODO/证据回写 -> 文档归档。 +6. `docs/**` 是全量事实源;`openspec/**` 仅是执行过程记录。OpenSpec 结果必须回写到 `docs/**`,禁止只留在 OpenSpec。 ## 2. 产物规范(必须) - 设计文档:`docs/design/**` +- 特性聚合文档:`docs/features/.md`(状态单一真相源) - 设计质量标准:`docs/design/Design_Doc_Minimum_Standard.md` - 差异分析:`docs/todos/YYYY-MM-DD__design_code_gap_analysis.md` +- 总体 TODO 主清单:`docs/todos/YYYY-MM-DD__master_todo.md`(可映射多个 OpenSpec change 切片) - 执行清单:`docs/todos/YYYY-MM-DD__design_code_gap_todo.md` -- OpenSpec 变更:`openspec/changes//{proposal.md,design.md,tasks.md}` +- OpenSpec 变更记录(过程):`openspec/changes//{proposal.md,design.md,tasks.md}` - 归档产物:分析文档、TODO 文档在完成后标记 `done/archived`,并补证据链接。 - 可重建追踪矩阵:`docs/design/Design_Reconstructability_Traceability_Matrix.md` - 重建执行 SOP:`docs/guides/Design_Reconstruction_SOP.md` +- 文档治理模型:`docs/governance/Documentation_Management_Model.md` +- Evidence Truth 策略:`docs/guides/Evidence_Truth_Implementation_Strategy.md` ## 3. 标准流程(一步不可省) @@ -33,52 +38,70 @@ - 输入必须归入 `bug` / `feature` / `refactor` 之一。 - 明确影响范围:模块、接口、数据结构、流程、错误处理。 -### Step 1: 文档先行更新 -- 先更新 `docs/design/` 对应文档,再进入代码实现。 +### Step 1: 全局分析(先于执行) +- 对任务做完整分析:现状、目标、影响范围、风险、依赖、边界。 +- 产出或更新 gap 分析文档,确保每条分析有文档/代码证据锚点。 +- 大改动必须先得到“可拆分切片”的分析结论,禁止直接进入执行。 + +### Step 2: 生成总体 TODO 主清单 +- 基于分析文档生成总体 TODO 主清单,覆盖完整目标范围。 +- 每条 TODO 必须标记切片边界(可独立执行、可独立验证、可独立回滚)。 +- 总体 TODO 必须支持映射多个 OpenSpec change(一个大特性通常对应多个 change)。 + +### Step 3: 先更新 docs(作为 OpenSpec 输入) +- 在执行前先更新 `docs/design/**` 与相关治理文档,形成当前基线。 +- TODO 与 design 是 OpenSpec proposal/design 的输入,不是执行后补写。 - 若缺文档,先补文档,不允许“先写代码再补文档”。 - 文档结构必须满足最小标准(见 `Design_Doc_Minimum_Standard.md`)。 -### Step 2: 设计-实现 Gap 分析 -- 生成分析文档,最少包含以下列: - - `Gap ID` - - `设计声明(Design Claim)` - - `代码现状(Code Evidence)` - - `影响评估(Impact)` - - `建议动作(Action)` - - `优先级(P0/P1/P2/P3)` -- 每条 Gap 必须带具体文件证据(文档路径 + 代码路径)。 - -### Step 3: 从 Gap 生成 TODO 清单 -- 基于 Gap 文档生成 TODO(禁止拍脑袋列 TODO)。 -- 每条 TODO 必须映射至少一个 Gap ID。 -- 每条 TODO 必须包含: - - `ID`, `Priority`, `Status`, `Owner`, `Related Gap`, `Evidence`, `Last Updated` +### Step 4: 按 TODO 切片进入 OpenSpec +- 从总体 TODO 中选择一个最小切片,创建/更新一个 OpenSpec change。 +- 每个 change 必须声明其消费的 TODO 子集与验收边界。 +- 一个 change 只处理一个切片;多切片并行时使用多个 change-id。 -### Step 4: 按 OpenSpec 逐项执行修复 -- 每个 TODO 项在 OpenSpec 中落地为可追踪任务。 -- 推荐节奏:一条 TODO -> 一个最小可验证 OpenSpec task -> 实现 -> 验证 -> 回写状态。 +### Step 5: 按 OpenSpec 切片逐项执行修复 +- 每个切片在 OpenSpec 中落地为可追踪 proposal/design/tasks。 +- 推荐节奏:一条 TODO(切片子项) -> OpenSpec task -> 实现 -> 验证 -> 回写状态。 - 禁止一次性跨多个高风险 TODO 混改。 -### Step 5: 验证与回写 -- 每次修复后必须同步更新: +### Step 6: 验证与回写 +- 每次切片修复后必须同步更新: - 对应 `docs/design/**` 文档 - - 对应 `docs/todos/*_todo.md` 状态与证据 + - 对应 `docs/todos/*_master_todo.md` 与 `docs/todos/*_todo.md` 状态与证据 - 对应 OpenSpec `tasks.md` 状态 - 验证至少覆盖:测试、接口契约、错误分支、文档一致性。 - -### Step 6: 归档 -- TODO 全部完成后: +- `docs/features/.md`(或 fallback 的 `.md`)必须按 Evidence Truth 模板回写: + - `Commands` + - `Results` + - `Behavior Verification`(happy path + error branch) + - `Risks and Rollback` + - `Review and Merge Gate Links` +- 必须执行并通过:`./scripts/ci/check_governance_evidence_truth.sh`。 + +### Step 7: 归档 +- 总体 TODO 全部切片完成后: - 将分析文档和 TODO 文档标记为 `archived` 或迁移到历史区块 - 在 `docs/todos/README.md` 更新索引 - - 在 OpenSpec 完成 archive(如适用) + - 对每个已完成 OpenSpec change 执行 archive(如适用) + +### Gap 分析最小字段(适用于 Step 1) +- 生成分析文档时,最少包含以下列: + - `Gap ID` + - `设计声明(Design Claim)` + - `代码现状(Code Evidence)` + - `影响评估(Impact)` + - `建议动作(Action)` + - `优先级(P0/P1/P2/P3)` +- 每条 Gap 必须带具体文件证据(文档路径 + 代码路径)。 ## 4. 强制门禁(DoD) -- 未完成 Step 1(文档更新)不得进入代码提交。 -- 未完成 Step 2(gap 分析)不得创建大于 P2 的实现改动。 -- 未完成 Step 3(TODO 映射)不得开始批量修复。 -- 未完成 Step 5(验证+回写)不得标记任务完成。 -- 未完成 Step 6(归档)不得关闭该轮治理任务。 +- 未完成 Step 1(全局分析)不得进入切片执行。 +- 未完成 Step 2(总体 TODO)不得创建 OpenSpec change。 +- 未完成 Step 3(docs 更新)不得进入代码提交。 +- 未完成 Step 4(切片映射)不得开始批量修复。 +- 未完成 Step 6(验证+回写)不得标记切片完成。 +- 未完成 Step 7(归档)不得关闭该轮治理任务。 ## 5. 紧急修复例外(仅限生产止血) @@ -96,3 +119,41 @@ - 归档路径统一使用日期前缀(`YYYY-MM-DD-...`)。 - 归档条目必须包含对应 OpenSpec change 路径与验证证据。 4. 若连续两轮发现同类文档漂移,必须新增自动化校验并接入 CI。 + +## 7. 协作模式(必须显式声明) + +### Mode A: OpenSpec 模式(默认) + +适用于 OpenSpec 可用场景,执行顺序如下: +1. 先完成分析 + 总体 TODO 主清单 + docs 基线更新。 +2. 从总体 TODO 选择一个切片,建立/选择 `openspec/changes//`。 +3. 创建或更新 `docs/features/.md`,登记该切片的 proposal/design/specs/tasks 链接。 +4. 按 OpenSpec tasks 执行该切片,并回写证据到 feature 聚合文档与 TODO 文档。 +5. 重复步骤 2-4,直到总体 TODO 主清单清空。 +6. 完成后执行 verify + archive,并迁移聚合文档到 `docs/features/archive/`。 +7. 确认最终可读性以 `docs/**` 为准:架构/流程/接口变更已在 docs 中可独立理解,OpenSpec 仅保留追踪链接。 + +### Mode B: 无 OpenSpec 回退(TODO-driven) + +仅在 OpenSpec 不可用(工具/环境受限)时使用: +1. 先完成分析 + 总体 TODO 主清单 + docs 基线更新。 +2. 创建 `docs/features/.md`,并在 frontmatter 声明 `mode: todo_fallback` 与 `topic_slug`。 +3. 以 TODO 清单推进并持续回写 evidence(不阻塞于 OpenSpec 工具可用性)。 +4. OpenSpec 可用后,按 TODO 切片补迁移:将 fallback 资产映射到一个或多个新的 `openspec/changes//` 并记录迁移证据。 + +## 8. SOP Skill 化(必须) + +SOP 关键阶段必须有可调用技能承载,并保持 checkpoint 与 skill 映射一致: +- kickoff +- execution-sync +- verification +- review-merge-gate +- completion-archive + +当前双技能分工: +- 文档管理技能(类型/路径/frontmatter/归档): + - `.codex/skills/documentation-management/SKILL.md` +- 开发流程技能(模式选择/checkpoint/证据回写): + - `.codex/skills/development-workflow/SKILL.md` + +若 SOP 与 skill 行为不一致,以规范文档更新 + skill 同步更新为同一任务,禁止只改其一。 diff --git a/docs/guides/Evidence_Truth_Implementation_Strategy.md b/docs/guides/Evidence_Truth_Implementation_Strategy.md new file mode 100644 index 00000000..d1a61e77 --- /dev/null +++ b/docs/guides/Evidence_Truth_Implementation_Strategy.md @@ -0,0 +1,73 @@ +# Evidence Truth Implementation Strategy + +> Scope: Governance changes that use `docs/features/*.md` as aggregation entry documents. + +## 1. Goal + +Evidence truth must be an auditable artifact, not a narrative promise. +For each active governance change, reviewers should be able to answer: +- what was executed, +- what passed/failed, +- what behavior was verified (happy path + error path), +- what risk remains and how rollback works, +- whether review/merge decisions are traceable. + +## 2. Contract (Required Structure) + +Each active feature aggregation doc MUST include: +- `## Evidence` +- `### Commands` +- `### Results` +- `### Behavior Verification` +- `### Risks and Rollback` +- `### Review and Merge Gate Links` + +Frontmatter mode requirements: +- OpenSpec mode: `change_ids` required. +- TODO fallback mode: `mode: todo_fallback` + `topic_slug` required. + +## 3. Implementation Strategy + +### Phase 1 (now): Structural gate in CI + +Use a deterministic script gate: +- script: `scripts/ci/check_governance_evidence_truth.sh` +- checks: + - required evidence headings exist in active feature aggregation docs + - frontmatter keys satisfy mode contract + - OpenSpec artifact paths listed in aggregation docs are repository-resolvable files + - review/merge gate section contains at least one GitHub PR review link + +This phase blocks obviously incomplete governance records with low false-positive risk. + +### Phase 2: Semantic consistency checks + +Add semantic assertions: +- command/result pairing is present for each listed command +- behavior verification includes both happy path and changed error branch +- unresolved risk items are explicit (or marked none with reason) +- review thread fix records reference concrete commits + +### Phase 3: Merge policy coupling + +Connect evidence truth with merge policy: +- merge gate requires evidence section completeness for active governance change docs +- fallback-mode changes require explicit migration-debt note before closeout +- archive transition requires evidence links to remain resolvable + +## 4. Operational Rules + +- Evidence truth is owned by the current change implementer. +- Reviewers validate evidence links before approval. +- `docs/mailbox/` entries tagged as `audit_evidence` are retained (not deleted by default). +- Any temporary downgrade from blocking to warning must be documented in the feature doc risk section. + +## 5. Command of Record + +Primary gate command: + +```bash +./scripts/ci/check_governance_evidence_truth.sh +``` + +This command is intended to run both locally and in CI. diff --git a/docs/todos/README.md b/docs/todos/README.md index 77f95153..9cdb3e27 100644 --- a/docs/todos/README.md +++ b/docs/todos/README.md @@ -52,7 +52,9 @@ ## 5. 与其他文档的关系 - 与 `docs/design/modules/*`:模块细节在模块文档,这里只保留跨模块视角。 -- 与 OpenSpec:执行任务拆解在 OpenSpec artifacts,这里只做方向与优先级治理。 +- 与 OpenSpec:执行任务拆解在 OpenSpec artifacts,这里只做方向与优先级治理(默认模式)。 +- 与 `docs/features/*`:每个治理/特性 change 的状态单一真相源在聚合文档,本目录负责分析与执行清单,不重复维护冲突状态。 - 与 `docs/README.md`:由文档导航统一入口。 - 与 `docs/guides/Documentation_First_Development_SOP.md`:必须遵循“gap 分析 -> TODO -> OpenSpec 执行 -> 回写/归档”的闭环流程。 +- 与 `docs/governance/Documentation_Management_Model.md`:目录分层、生命周期和回退协作模式以该模型为准。 - 与 `docs/guides/Design_Reconstruction_SOP.md`:重建场景必须遵循该 SOP,并以追踪矩阵为验收入口。 diff --git a/openspec/changes/enhance-doc-governance-traceability/.openspec.yaml b/openspec/changes/enhance-doc-governance-traceability/.openspec.yaml new file mode 100644 index 00000000..34b5b231 --- /dev/null +++ b/openspec/changes/enhance-doc-governance-traceability/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-02-28 diff --git a/openspec/changes/enhance-doc-governance-traceability/design.md b/openspec/changes/enhance-doc-governance-traceability/design.md new file mode 100644 index 00000000..945bf08f --- /dev/null +++ b/openspec/changes/enhance-doc-governance-traceability/design.md @@ -0,0 +1,95 @@ +## Context + +PR #113 已明确把“文档治理哲学互学”拆分为独立变更执行。本仓库已具备文档先行 SOP、gap/TODO 台账与 OpenSpec 流程,但“同一变更的全链路上下文”仍分散在 `openspec/changes/`、`docs/design/`、`docs/todos/`、PR 评论中,缺少统一聚合入口和可机器检索的挂接元数据。 + +本设计将“可重建性”扩展为“可重建 + 可追溯”:不仅要求文档可重建系统,还要求任何治理变更都能被快速追踪其设计声明、执行计划、证据与归档状态,并能通过 CI 自动识别流程缺口。 + +## Goals / Non-Goals + +**Goals:** +- 统一文档目录分层与各类型文档放置规则,减少“同类文档多位置散落”。 +- 为治理类变更建立统一聚合模型(single aggregation entry per change)。 +- 定义 frontmatter 最小合约并约束跨文档挂接字段。 +- 建立活跃索引与归档迁移规则,避免上下文散落。 +- 将关键门禁(文档更新、gap/TODO 映射、聚合完整性)转化为可自动检查的 checkpoint。 +- 将文档治理 SOP 关键阶段 skill 化,使治理执行不仅“有规范”,且“可调用、可复用、可审计”。 +- 明确 OpenSpec 与 TODO fallback 的协作边界及迁移策略。 +- 明确“分析 + master TODO + docs 更新”是 OpenSpec 输入,OpenSpec 作为执行切片层而非全量事实源。 + +**Non-Goals:** +- 不引入新的运行时能力或 agent 执行路径变更。 +- 不重构历史所有文档,只做“新治理变更必须遵循”的前向约束与最小回填。 +- 不改变 OpenSpec CLI 本身行为,仅在仓库侧补流程与检查。 + +## Decisions + +### Decision 1: 聚合主键使用 OpenSpec change-id,而非新增 Feature 编号体系 +- 方案 A(采用):聚合文档以 `openspec change-id` 为主键,例如 `docs/features/.md`。 +- 方案 B(不采用):引入独立 `Fxxx` 编号并维护映射表。 +- 理由:A 与现有治理流程天然对齐,避免并行编号体系导致维护成本上升。 + +### Decision 2: frontmatter 合约采用“最小必填 + 可扩展字段” +- 必填(OpenSpec mode):`change_ids`、`topics`、`doc_kind`、`created`。 +- 必填(TODO fallback mode):`topic_slug`、`mode: todo_fallback`、`topics`、`doc_kind`、`created`(迁移后补 `change_ids`)。 +- 可选:`debt_ids`、`related_specs`、`status`。 +- 理由:先保证可检索与可追踪,再逐步扩展,避免一次性要求过重。 + +### Decision 3: 治理 checkpoint 以 CI 脚本为主,人工评审为补充 +- 方案 A(采用):新增/增强脚本校验,CI gate 强制执行;人工仅处理脚本无法判定的语义问题。 +- 方案 B(不采用):完全依赖 review checklist。 +- 理由:流程门禁需要“默认可执行且可复现”,否则会被长期稀释。 + +### Decision 4: 采用“前向生效 + 最小回填”迁移策略 +- 新变更从生效日起必须满足聚合 + frontmatter + checkpoint。 +- 历史文档按活跃优先级回填,不阻塞本次治理基线落地。 + +### Decision 5: 关键治理步骤由 Skill 承载执行语义 +- 方案 A(采用):采用双技能架构,包含 `documentation-management`(文档治理管理)与 `development-workflow`(开发流程治理)两类职责,并维护“checkpoint -> skill”映射文档。 +- 方案 B(不采用):只在 SOP 文档里描述步骤,不提供可调用 skill。 +- 理由:仅文档约束容易漂移;双技能拆分可降低职责耦合并增强复用,skill 化可以将治理流程变成可执行协议并支持自动审计。 + +### Decision 6: 采用双协作模式但以 OpenSpec 为默认主干 +- 方案 A(采用):OpenSpec 作为默认执行模式;无 OpenSpec 时允许 TODO-driven fallback,并要求后续迁移回 OpenSpec。OpenSpec change 的粒度为 TODO 切片,允许一个大改动拆分为多个 change-id。 +- 方案 B(不采用):仅允许 OpenSpec,不提供回退。 +- 理由:在工具受限场景下需要保留最小可执行治理流程,但必须可回收进入统一主干。 + +### Decision 7: docs 为全量事实源,OpenSpec 为过程记录层 +- 方案 A(采用):`docs/**` 作为可独立重建的全量事实源;`openspec/**` 记录执行过程与切片追踪,并将关键结论回写 docs。 +- 方案 B(不采用):将 OpenSpec 作为主事实源并由 docs 被动引用。 +- 理由:长期维护应依赖稳定文档层,执行过程记录应服务追踪与审计,不应替代最终知识载体。 + +## Risks / Trade-offs + +- [Risk] 新增 frontmatter 与聚合文档带来短期编辑负担 + → Mitigation: 提供模板与示例,脚本错误信息给出修复建议。 + +- [Risk] 规则过严影响迭代效率 + → Mitigation: 先启用 warning 模式验证一轮,再切换到 hard gate。 + +- [Risk] 历史文档不完整导致初期误报 + → Mitigation: 校验范围优先限制到“本次变更触达文件 + 新增文件”。 + +- [Risk] skill 规范与 SOP 文档双处维护导致不一致 + → Mitigation: 强制维护 checkpoint-skill 映射源文件,并在 CI 中校验映射完整性。 + +- [Risk] 双协作模式可能产生长期并行流程 + → Mitigation: fallback 文档必须带迁移计划与截至条件,且在 OpenSpec 可用后强制迁移。 + +## Migration Plan + +1. 新增治理聚合模板与 frontmatter 合约文档。 +2. 明确 `docs/` 目录分层与文档类型放置规则,并同步导航文档。 +3. 在 `docs/guides` 与 `docs/design` 回写执行顺序与术语(含 OpenSpec/fallback 协作规则)。 +4. 增加/更新治理 skills,并建立 checkpoint 到 skill 的映射文档。 +5. 增加 CI 检查脚本(聚合入口、frontmatter、gap/TODO 映射、skill 映射完整性)。 +6. 选取一个活跃变更做样例回填,验证流程可用性。 +7. 将 checkpoint 从 warning 提升为阻断门禁并更新贡献指南。 + +回滚策略:若新 gate 导致大量误报,可临时降级为 warning,同时保留文档合约与聚合模板,不回退语义规范。 + +## Open Questions + +- `change_ids` 已作为主字段统一;是否需要提供历史 `feature_ids` 的批量迁移脚本与兼容读取窗口? +- 聚合文档目录命名是否固定为 `docs/features/`,还是放入 `docs/governance/`? +- 是否在后续迭代增加自动生成聚合骨架(由脚本从 OpenSpec change 初始化)? +- 是否在下一迭代提供脚手架命令自动生成 `documentation-management` / `development-workflow` 的最小执行模板? diff --git a/openspec/changes/enhance-doc-governance-traceability/proposal.md b/openspec/changes/enhance-doc-governance-traceability/proposal.md new file mode 100644 index 00000000..a2fcf205 --- /dev/null +++ b/openspec/changes/enhance-doc-governance-traceability/proposal.md @@ -0,0 +1,42 @@ +## Why + +PR #113 中已经确认“文档治理哲学互学”应拆到独立 OpenSpec 变更执行。当前仓库虽有文档先行约束,但缺少以“Feature/Change 生命周期”为中心的统一聚合入口、结构化挂接元数据与可自动验证的治理 checkpoint,导致跨文档追溯和长期维护成本偏高。 + +## What Changes + +- 引入“按变更聚合”的文档治理基线:每个治理变更都有单一聚合文档入口,统一挂接相关设计、讨论、TODO 与证据。 +- 统一 `docs/` 目录结构分层(标准/设计/治理/特性聚合/分析TODO/临时/归档),并明确各类型文档放置规则。 +- 定义并落地文档 `frontmatter` 最小字段合约(如 `change_ids` / `topics` / `doc_kind` / `created`),用于机器可检索追溯。 +- 增加活跃治理索引与状态迁移规则(active -> archived),避免长期任务上下文分散。 +- 把关键治理门禁转化为可验证 checkpoint(脚本/CI 检查),覆盖:文档更新、gap/TODO 关联、聚合入口完整性。 +- 将文档先行 SOP 的关键阶段(kickoff / execution / completion / verification)显式 skill 化,并明确至少拆分为“文档管理 skill + 工作流 skill”两类职责。 +- 增加协作双模式声明:OpenSpec 默认模式 + 无 OpenSpec 时的 TODO-driven 回退模式与迁移规则。 +- 明确执行顺序:先全局分析并生成总体 TODO 主清单,再更新 docs,之后按 TODO 切片创建一个或多个 OpenSpec change 执行。 +- 明确边界:`docs/**` 是全量事实源,`openspec/**` 是执行过程记录;OpenSpec 结果必须回写 docs。 +- 固化 Evidence Truth:新增实施策略文档并接入 CI 结构化校验(`scripts/ci/check_governance_evidence_truth.sh`)。 +- 在现有 `docs/guides/*` 与 `docs/design/*` 中回写统一术语与执行顺序,确保与 OpenSpec 工作流一致。 + +## Capabilities + +### New Capabilities +- `documentation-lifecycle-traceability`: 定义治理变更的聚合入口、frontmatter 挂接规范、活跃索引与归档迁移闭环。 + +### Modified Capabilities +- `design-reconstructability-governance`: 扩展为“可重建 + 可追溯”双目标,并要求治理 checkpoint 具备机器可验证性。 + +## Impact + +- Affected docs: + - `docs/guides/Documentation_First_Development_SOP.md` + - `docs/guides/Development_Constraints.md` + - `docs/design/Design_Reconstructability_Traceability_Matrix.md` + - 新增治理聚合与索引文档(路径将在 design/tasks 中定版) +- Affected automation/checks: + - `scripts/ci/check_design_doc_drift.sh`(或新增 companion check) + - CI gate 组合中的文档治理校验步骤 +- Affected skills/docs: + - `.codex/skills/documentation-management/SKILL.md` + - `.codex/skills/development-workflow/SKILL.md` + - skill 与 checkpoint 的映射文档(路径将在 design/tasks 中定版) +- API/runtime impact: + - 无运行时接口变更(non-breaking) diff --git a/openspec/changes/enhance-doc-governance-traceability/specs/design-reconstructability-governance/spec.md b/openspec/changes/enhance-doc-governance-traceability/specs/design-reconstructability-governance/spec.md new file mode 100644 index 00000000..dfcc0989 --- /dev/null +++ b/openspec/changes/enhance-doc-governance-traceability/specs/design-reconstructability-governance/spec.md @@ -0,0 +1,62 @@ +## MODIFIED Requirements + +### Requirement: 文档可重建性必须维护统一追踪矩阵 +系统 MUST 维护一份可检索的追踪矩阵,覆盖关键能力的 `design requirement -> code anchor -> test evidence -> status` 映射;对于治理类变更,矩阵还 MUST 显式关联对应 change 的聚合入口文档与 gap/TODO 证据路径。 + +#### Scenario: 追踪矩阵可定位关键能力责任 + +- **WHEN** 维护者检查某条关键设计约束 +- **THEN** 能定位到对应实现文件与验证测试 +- **AND** 能看到当前状态(implemented/partial/planned) +- **AND** 能跳转到关联治理 change 的聚合入口与证据文档 + +### Requirement: 可重建性治理必须维护 P0/P1 优先级清单 +可重建性治理 MUST 维护 P0/P1 缺口列表,并与 OpenSpec tasks 映射;该映射 MUST 具备机器可校验标识(稳定 ID 或 frontmatter 锚点),避免缺口长期悬挂或证据失联。 + +#### Scenario: 缺口治理优先级可追踪 + +- **WHEN** 评审者检查可重建性治理文档 +- **THEN** 能看到 P0/P1 列表与对应 OpenSpec change/task 映射 +- **AND** 能通过稳定标识验证该映射未失效 + +## ADDED Requirements + +### Requirement: 可重建性治理必须维护文档生命周期依赖链 +可重建性治理 MUST 明确并执行 `standards -> design update -> gap analysis -> master TODO -> feature aggregation -> execution evidence -> review/merge gate -> archive` 的生命周期依赖关系。 + +#### Scenario: 治理任务可按依赖链追溯 +- **WHEN** 评审者抽查任一治理 change +- **THEN** 能从聚合入口按依赖链定位到对应文档资产 +- **AND** 依赖链中每个阶段都有状态与证据锚点 + +### Requirement: 可重建性治理门禁必须提供自动化检查 +可重建性治理流程 MUST 将以下门禁纳入自动化检查:文档先行更新、gap 分析存在性、TODO 到 OpenSpec task 的映射完整性、frontmatter 必填字段(按 OpenSpec/fallback 模式)、聚合文档链接可解析性、证据块完整性(命令/结果/风险/回滚/review links)。 + +#### Scenario: 缺失治理门禁资产时自动阻断 +- **WHEN** 提交包含治理相关实现或文档变更但未补齐 gap/TODO 映射 +- **THEN** 自动化检查报告失败 +- **AND** 报告指出缺失项与期望文件路径 + +### Requirement: 可重建性治理必须维护 checkpoint-skill 映射 +可重建性治理 MUST 维护一份 checkpoint 到 skill 的映射清单,确保 SOP 的关键阶段具备可执行承载并可被审计;映射 MUST 至少覆盖 `documentation-management` 与 `development-workflow` 两个技能角色。 + +#### Scenario: 评审者可验证 SOP skill 化覆盖 +- **WHEN** 评审者检查治理流程资产 +- **THEN** 能定位到关键 checkpoint 对应的 skill 名称与路径(至少包含 `documentation-management` 与 `development-workflow`) +- **AND** 能确认该映射与 CI 检查项一致(且 CI 门禁不局限于 skill 映射) + +### Requirement: 特性聚合文档必须作为状态单一真相源 +治理 change 的生命周期状态 MUST 以 `docs/features/.md` 聚合文档为单一真相源,其他关联文档不得维护与其冲突的主状态。 + +#### Scenario: 状态一致性可自动校验 +- **WHEN** CI 或评审检查同一 change 的多份文档状态 +- **THEN** 聚合文档状态与关联文档不会出现冲突主状态 +- **AND** 若存在冲突,检查会报告并阻断合入 + +### Requirement: 总体 TODO 必须驱动多 change 切片追踪 +可重建性治理 MUST 维护总体 TODO 与 OpenSpec change 切片的映射关系;当单个 change 无法覆盖全部目标时,MUST 拆分为多个 change 并保持映射可追踪。 + +#### Scenario: 大型改动的切片映射可审计 +- **WHEN** 评审者检查大型治理变更 +- **THEN** 可以从总体 TODO 定位到多个 change 的覆盖边界 +- **AND** 每个 change 仅声明其负责的 TODO 子集与证据 diff --git a/openspec/changes/enhance-doc-governance-traceability/specs/documentation-lifecycle-traceability/spec.md b/openspec/changes/enhance-doc-governance-traceability/specs/documentation-lifecycle-traceability/spec.md new file mode 100644 index 00000000..cb5e47eb --- /dev/null +++ b/openspec/changes/enhance-doc-governance-traceability/specs/documentation-lifecycle-traceability/spec.md @@ -0,0 +1,82 @@ +## ADDED Requirements + +### Requirement: 文档目录结构必须维护统一分层 +系统 MUST 维护统一文档目录分层,并为设计文档、分析文档、特性聚合文档、标准文档、临时文档、归档文档定义固定放置路径。 + +#### Scenario: 文档类型有唯一放置位置 +- **WHEN** 维护者新增某类治理文档 +- **THEN** 可以根据文档类型映射到唯一推荐目录 +- **AND** 导航文档中存在与该映射一致的目录说明 + +### Requirement: 治理变更必须维护单一聚合入口文档 +每个文档治理变更 MUST 提供一个可定位的聚合入口文档,集中链接 proposal/design/specs/tasks、相关 `docs/design` 更新、gap 分析与 TODO 清单证据。 + +#### Scenario: 新治理变更创建后可定位聚合入口 +- **WHEN** 维护者创建新的治理类 OpenSpec change +- **THEN** 仓库中存在与 change-id 对应的聚合入口文档 +- **AND** 入口文档包含该 change 的 OpenSpec 与文档证据链接 + +### Requirement: 治理文档必须声明结构化 frontmatter 元数据 +纳入治理追踪的文档 MUST 包含 frontmatter,至少声明追踪主键、主题、文档类型与创建时间,且字段命名遵循仓库统一约定。 + +#### Scenario: 治理文档可被机器检索挂接 +- **WHEN** CI 或脚本扫描治理文档目录 +- **THEN** 每个被纳入治理范围的文档均可解析 frontmatter +- **AND** 可依据主键字段将文档挂接到对应 change 聚合入口 + +### Requirement: 活跃治理索引必须维护状态迁移 +系统 MUST 维护活跃治理索引,并在治理任务完成时将条目从 active 状态迁移到 archived 状态,避免活跃视图累积历史噪声。 + +#### Scenario: 治理任务完成后索引状态收敛 +- **WHEN** 某治理 change 的 OpenSpec 任务与 TODO 证据均标记完成 +- **THEN** 活跃索引不再列出该条目 +- **AND** 归档索引中可追溯到该条目的历史记录与证据路径 + +### Requirement: 治理 checkpoint 必须具备自动校验能力 +治理流程中的关键门禁(文档更新、gap/TODO 映射、聚合入口完整性、frontmatter 合约、证据块完整性、链接可解析性)MUST 有自动校验脚本并接入 CI gate;该 CI 闭环 MUST NOT 仅限 skill 文件存在性校验。 + +#### Scenario: PR 在缺少治理资产时被 gate 阻断 +- **WHEN** 变更触达治理范围文件但缺失聚合入口或 frontmatter 关键字段 +- **THEN** CI 校验失败并输出可操作修复提示 +- **AND** PR 在补齐治理资产前不得通过完整 gate +- **AND** `./scripts/ci/check_governance_evidence_truth.sh` 作为结构化证据门禁命令可被本地与 CI 一致执行 + +### Requirement: 治理 SOP 关键阶段必须 skill 化 +治理流程中的关键阶段(至少包含 kickoff、completion、verification)MUST 对应到可调用 skill,并维护 checkpoint 到 skill 的稳定映射关系;该映射 MUST 至少包含两个职责分离 skill:`documentation-management` 与 `development-workflow`。 + +#### Scenario: 治理任务可由 skill 驱动执行 +- **WHEN** 维护者或 agent 执行治理类变更 +- **THEN** 可定位到 `documentation-management` 与 `development-workflow` 的 skill 入口与使用说明 +- **AND** 能从映射关系中确认该阶段对应的 gate/checkpoint + +### Requirement: 治理流程必须保留 review/merge gate 审计证据 +治理流程 MUST 为每个活跃变更保留 review request、关键 review 线程处理记录、merge gate 决策证据,并在聚合文档中可追溯链接这些证据。 + +#### Scenario: 合入决策可审计 +- **WHEN** 评审者回溯一个已完成治理变更 +- **THEN** 可以在聚合文档中定位 review 请求、关键评论修复记录与 merge gate 结果 +- **AND** 对应 mailbox 审计证据文档仍可访问 + +### Requirement: 协作流程必须声明 OpenSpec 默认与回退模式 +治理流程 MUST 明确 OpenSpec 为默认协作模式,并定义无 OpenSpec 场景下的 TODO-driven 回退流程及后续迁移要求。 + +#### Scenario: OpenSpec 不可用时仍可保持治理闭环 +- **WHEN** OpenSpec 工具不可用 +- **THEN** 维护者可按 TODO-driven 回退模式继续执行文档治理任务 +- **AND** 一旦 OpenSpec 恢复可用,回退资产可迁移并回写到 OpenSpec change + +### Requirement: OpenSpec 执行必须以分析与总体 TODO 为输入 +治理执行 MUST 先完成全局分析并生成总体 TODO 主清单,再以 TODO 切片创建一个或多个 OpenSpec change 执行。 + +#### Scenario: 大改动通过多 OpenSpec 切片推进 +- **WHEN** 维护者处理一个范围较大的 bug/feature/refactor +- **THEN** 先在 `docs/todos/` 维护总体 TODO 主清单 +- **AND** 按 TODO 子集拆分为多个 OpenSpec change,而不是将全部范围塞入单一 change + +### Requirement: docs 必须作为全量事实源 +治理流程 MUST 将 `docs/**` 作为全量事实源,`openspec/**` 作为执行过程记录;OpenSpec 关键结论 MUST 回写到 docs。 + +#### Scenario: 不依赖 OpenSpec 也可理解当前系统 +- **WHEN** 评审者仅阅读 `docs/**` +- **THEN** 可以理解当前架构、流程和接口的最终状态 +- **AND** OpenSpec 仅用于查看执行轨迹与切片证据 diff --git a/openspec/changes/enhance-doc-governance-traceability/tasks.md b/openspec/changes/enhance-doc-governance-traceability/tasks.md new file mode 100644 index 00000000..7dac94b7 --- /dev/null +++ b/openspec/changes/enhance-doc-governance-traceability/tasks.md @@ -0,0 +1,36 @@ +## 1. Governance contract and template baseline + +- [ ] 1.0 Publish unified docs directory taxonomy and type-to-path mapping in governance model + docs navigation. +- [ ] 1.1 Define and publish the frontmatter field contract for governance-tracked documents (required vs optional fields). +- [ ] 1.2 Create a governance aggregation template keyed by OpenSpec change-id and add one example document. +- [ ] 1.3 Add an active governance index and archive index format with explicit migration rules. + +## 2. Documentation alignment updates + +- [ ] 2.1 Update `docs/guides/Documentation_First_Development_SOP.md` with aggregation/frontmatter/checkpoint execution order. +- [ ] 2.2 Update `docs/guides/Development_Constraints.md` to require governance aggregation entry + machine-checkable mapping. +- [ ] 2.3 Update `docs/design/Design_Reconstructability_Traceability_Matrix.md` to include links to governance aggregation entries. +- [ ] 2.4 Update standards to explicitly define OpenSpec default collaboration and TODO-driven fallback collaboration. +- [ ] 2.5 Update standards to explicitly define `docs/**` as canonical full record and `openspec/**` as execution trace record. +- [ ] 2.6 Define analysis-first + master-TODO-first workflow and multi-change OpenSpec slicing policy. + +## 3. Automation and CI checkpoint implementation + +- [ ] 3.1 Implement or extend CI checks to validate aggregation entry existence when governance-scoped files change. +- [ ] 3.2 Implement or extend CI checks to validate required frontmatter fields for governance-tracked docs. +- [ ] 3.3 Implement or extend CI checks to validate gap/TODO -> OpenSpec task mapping completeness. +- [ ] 3.4 Implement or extend CI checks to validate master TODO -> OpenSpec change-slice mapping consistency. +- [ ] 3.5 Implement evidence truth structural gate (`scripts/ci/check_governance_evidence_truth.sh`) and wire it into `ci-gate`. + +## 4. SOP skillization implementation + +- [ ] 4.1 Define and publish a checkpoint-to-skill mapping document for governance lifecycle stages. +- [ ] 4.2 Add or update at least two governance skills under repository-managed skills: `documentation-management` and `development-workflow`. +- [ ] 4.3 Add CI validation to ensure required governance checkpoint-skill mappings are present and non-stale. +- [ ] 4.4 Define reuse contract so `documentation-management` and `development-workflow` can be reused by both OpenSpec mode and TODO fallback mode. + +## 5. Pilot backfill and closure evidence + +- [ ] 5.1 Backfill one active governance change using the new aggregation + frontmatter + skill mapping contract as pilot evidence. +- [ ] 5.2 Run governance check scripts and capture passing command output in PR evidence. +- [ ] 5.3 Update TODO/archive records and mark this OpenSpec change as complete with evidence links. diff --git a/scripts/ci/check_governance_evidence_truth.sh b/scripts/ci/check_governance_evidence_truth.sh new file mode 100755 index 00000000..0160190e --- /dev/null +++ b/scripts/ci/check_governance_evidence_truth.sh @@ -0,0 +1,193 @@ +#!/usr/bin/env bash + +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "$ROOT_DIR" + +failures=0 + +log() { + echo "[governance-evidence-truth] $*" +} + +if command -v rg >/dev/null 2>&1; then + SEARCH_BIN="rg" +else + SEARCH_BIN="grep" +fi + +search_has_match() { + local pattern="$1" + local file="$2" + if [[ "$SEARCH_BIN" == "rg" ]]; then + rg -q -- "$pattern" "$file" + else + grep -Eq -- "$pattern" "$file" + fi +} + +extract_frontmatter() { + local file="$1" + awk ' + NR == 1 && $0 == "---" {in_fm=1; next} + in_fm && $0 == "---" {exit} + in_fm {print} + ' "$file" +} + +frontmatter_scalar() { + local block="$1" + local key="$2" + awk -v key="$key" ' + $0 ~ "^[[:space:]]*" key ":[[:space:]]*" { + sub("^[[:space:]]*" key ":[[:space:]]*", "", $0) + print + exit + } + ' <<<"$block" +} + +trim_quotes() { + local value="$1" + value="${value#\"}" + value="${value%\"}" + value="${value#\'}" + value="${value%\'}" + echo "$value" +} + +frontmatter_has_change_ids() { + local block="$1" + if grep -Eq '^[[:space:]]*change_ids:[[:space:]]*\[[^]]+\][[:space:]]*$' <<<"$block"; then + return 0 + fi + + # Support multiline YAML list form: + # change_ids: + # - id-a + # - id-b + awk ' + /^[[:space:]]*change_ids:[[:space:]]*$/ {in_list=1; next} + in_list && /^[[:space:]]*[A-Za-z_][A-Za-z0-9_]*:[[:space:]]*/ {in_list=0} + in_list && /^[[:space:]]*-[[:space:]]*.+$/ {found=1} + END {exit(found ? 0 : 1)} + ' <<<"$block" +} + +require_pattern() { + local pattern="$1" + local file="$2" + local label="$3" + if ! search_has_match "$pattern" "$file"; then + log "missing $label in $file" + failures=$((failures + 1)) + fi +} + +extract_section() { + local file="$1" + local start_heading="$2" + awk -v start="$start_heading" ' + $0 == start {in_section=1; next} + in_section && $0 ~ /^## / {in_section=0} + in_section {print} + ' "$file" +} + +extract_subsection() { + local file="$1" + local start_heading="$2" + awk -v start="$start_heading" ' + $0 == start {in_section=1; next} + in_section && $0 ~ /^### / {in_section=0} + in_section && $0 ~ /^## / {in_section=0} + in_section {print} + ' "$file" +} + +check_feature_doc() { + local file="$1" + local frontmatter status mode topic_slug + + frontmatter="$(extract_frontmatter "$file")" + if [[ -z "$frontmatter" ]]; then + log "missing frontmatter block in $file" + failures=$((failures + 1)) + return + fi + + status="$(trim_quotes "$(frontmatter_scalar "$frontmatter" "status")")" + if [[ -z "$status" ]]; then + log "missing status frontmatter in $file" + failures=$((failures + 1)) + return + fi + + # Evidence requirements are enforced for active feature docs only. + if [[ "$status" != "active" ]]; then + log "skip non-active feature doc $file (status=$status)" + return + fi + + log "checking $file" + + require_pattern "^## Evidence$" "$file" "Evidence section" + require_pattern "^### Commands$" "$file" "Commands subsection" + require_pattern "^### Results$" "$file" "Results subsection" + require_pattern "^### Behavior Verification$" "$file" "Behavior Verification subsection" + require_pattern "^### Risks and Rollback$" "$file" "Risks and Rollback subsection" + require_pattern "^### Review and Merge Gate Links$" "$file" "Review and Merge Gate Links subsection" + + mode="$(trim_quotes "$(frontmatter_scalar "$frontmatter" "mode")")" + if [[ "$mode" == "todo_fallback" ]]; then + topic_slug="$(trim_quotes "$(frontmatter_scalar "$frontmatter" "topic_slug")")" + if [[ -z "$topic_slug" ]]; then + log "missing topic_slug frontmatter (fallback mode) in $file" + failures=$((failures + 1)) + fi + else + if ! frontmatter_has_change_ids "$frontmatter"; then + log "missing change_ids frontmatter (OpenSpec mode) in $file" + failures=$((failures + 1)) + fi + fi + + # Ensure OpenSpec artifact references are resolvable from repository root. + while IFS= read -r path; do + if [[ -n "$path" ]]; then + if [[ ! -f "$path" ]]; then + log "unresolvable artifact path in $file: $path" + failures=$((failures + 1)) + fi + fi + done < <(extract_section "$file" "## OpenSpec Artifacts" | sed -n 's/.*`\([^`]*\)`.*/\1/p') + + # Require at least one GitHub PR link in review section. + local review_section + review_section="$(extract_subsection "$file" "### Review and Merge Gate Links")" + if ! grep -Eq 'https://github\.com/.+/pull/[0-9]+' <<<"$review_section"; then + log "missing GitHub PR review/merge link in $file" + failures=$((failures + 1)) + fi +} + +feature_docs=() +while IFS= read -r path; do + feature_docs+=("$path") +done < <(find docs/features -maxdepth 1 -type f -name '*.md' ! -name 'README.md' | sort) + +if [[ ${#feature_docs[@]} -eq 0 ]]; then + log "no active feature aggregation docs found under docs/features/" +fi + +for file in "${feature_docs[@]}"; do + check_feature_doc "$file" +done + +if [[ $failures -gt 0 ]]; then + log "failed with $failures issue(s)" + exit 1 +fi + +log "passed"