From a6ffbbc80ed05a79ef6f1b0b1ec588f0733d8a01 Mon Sep 17 00:00:00 2001 From: Vikram Reddy Date: Sat, 5 Sep 2026 12:02:56 +0530 Subject: [PATCH 1/7] Refactor Devspec Protocols and Lifecycle Documentation - Updated install-manifest.txt to remove obsolete architecture files. - Revised lifecycle.md to clarify state vocabulary and work item stages, including new routing options. - Enhanced repo-access.xml to include more detailed access requirements and examples. - Modified run.xml to streamline preflight checks for repository access. - Added last field to quickfix template for improved state tracking. - Updated finalize.md and review.md templates to enhance traceability and findings documentation. - Adjusted tasks.md template to ensure proper task status representation. - Improved how-to.md to clarify installation steps and repository scope confirmation. - Revised workflows.md to better outline new repository setup and command execution. - Enhanced definitions.py to establish a clear lifecycle command order. - Updated framework.py to include new lifecycle commands and improve validation checks. - Added tests for contract consistency and protocol validation to ensure alignment with documentation. - Introduced new protocols for revision and security to enhance project governance. - Created state.xml protocol to standardize state vocabulary across commands. - Implemented comprehensive tests to validate contract consistency and artifact shapes. --- .agents/skills/devspec-codebase-structure.md | 2 +- .agents/skills/devspec-coding-standards.md | 2 +- .agents/skills/devspec-extract.md | 2 +- .agents/skills/devspec-grooming.md | 2 +- .../devspec-codebase-structure/SKILL.md | 2 +- .../skills/devspec-coding-standards/SKILL.md | 2 +- .claude/skills/devspec-extract/SKILL.md | 2 +- .cursor/rules/devspec-workflow.mdc | 2 +- .../commands/devspec/codebase-structure.toml | 2 +- .../commands/devspec/coding-standards.toml | 2 +- .gemini/commands/devspec/extract.toml | 2 +- .../devspec.codebase-structure.agent.md | 2 +- .../agents/devspec.coding-standards.agent.md | 2 +- .github/agents/devspec.extract.agent.md | 2 +- .../architecture/_template/artifact-queue.md | 4 +- devspec/architecture/_template/diagram.md | 16 +- devspec/architecture/artifact-queue.md | 11 +- devspec/architecture/overview.md | 7 +- devspec/command-registry.md | 34 +-- devspec/contracts/devspec.changerequest.md | 6 +- devspec/contracts/devspec.clarify.md | 9 +- .../contracts/devspec.codebase-structure.md | 6 +- devspec/contracts/devspec.coding-standards.md | 8 +- devspec/contracts/devspec.diagram.md | 7 +- devspec/contracts/devspec.extract.md | 11 +- devspec/contracts/devspec.finalize.md | 11 +- devspec/contracts/devspec.grooming.md | 6 +- devspec/contracts/devspec.implement.md | 10 +- devspec/contracts/devspec.projectcontext.md | 7 +- devspec/contracts/devspec.quickfix.md | 8 +- devspec/contracts/devspec.review.md | 13 +- devspec/contracts/devspec.rules.md | 9 +- devspec/contracts/devspec.story.md | 8 +- devspec/contracts/devspec.tasks.md | 7 +- devspec/contracts/devspec.techstack.md | 6 +- .../_template/codebase-structure.md | 4 +- .../foundation/_template/project-context.md | 14 +- devspec/foundation/_template/rules.md | 4 +- devspec/foundation/_template/tech-stack.md | 4 +- devspec/glossary.md | 14 +- devspec/install-manifest.txt | 2 - devspec/lifecycle.md | 21 +- devspec/protocols/repo-access.xml | 2 +- devspec/protocols/revision.xml | 6 + devspec/protocols/run.xml | 2 +- devspec/protocols/security.xml | 8 + devspec/protocols/state.xml | 10 + devspec/quickfixes/_template.md | 2 + devspec/work-items/_template/finalize.md | 2 +- devspec/work-items/_template/review.md | 6 +- devspec/work-items/_template/tasks.md | 2 +- docs/how-to.md | 6 +- docs/workflows.md | 2 +- src/devspec_lite/definitions.py | 29 +++ src/devspec_lite/framework.py | 39 +++- tests/test_contract_consistency.py | 194 ++++++++++++++++++ tests/test_framework.py | 13 +- 57 files changed, 448 insertions(+), 170 deletions(-) create mode 100644 devspec/protocols/revision.xml create mode 100644 devspec/protocols/security.xml create mode 100644 devspec/protocols/state.xml create mode 100644 tests/test_contract_consistency.py diff --git a/.agents/skills/devspec-codebase-structure.md b/.agents/skills/devspec-codebase-structure.md index 785fd7b..19ab054 100644 --- a/.agents/skills/devspec-codebase-structure.md +++ b/.agents/skills/devspec-codebase-structure.md @@ -1,5 +1,5 @@ --- name: devspec-codebase-structure -description: Capture owned source roots, module boundaries, integrations, and repository access. +description: Capture or customize owned source roots, repository layouts, module boundaries, integrations, and repository access. --- Read and execute `devspec/contracts/devspec.codebase-structure.md`. diff --git a/.agents/skills/devspec-coding-standards.md b/.agents/skills/devspec-coding-standards.md index c23ee48..50c5269 100644 --- a/.agents/skills/devspec-coding-standards.md +++ b/.agents/skills/devspec-coding-standards.md @@ -1,5 +1,5 @@ --- name: devspec-coding-standards -description: Capture reusable observed or developer-defined coding standards with numbered examples. +description: Capture concise, reusable coding conventions, followable examples, and anti-patterns from source evidence or developer-defined standards. --- Read and execute `devspec/contracts/devspec.coding-standards.md`. diff --git a/.agents/skills/devspec-extract.md b/.agents/skills/devspec-extract.md index 6552a6a..e2c7fe6 100644 --- a/.agents/skills/devspec-extract.md +++ b/.agents/skills/devspec-extract.md @@ -1,5 +1,5 @@ --- name: devspec-extract -description: Backfill concise foundation evidence from an existing repository. +description: Inspect the approved existing system end-to-end, produce its technical, business, workflow, and rule baseline, and prepare an evidence-backed diagram candidate list for explicit generation approval. --- Read and execute `devspec/contracts/devspec.extract.md`. diff --git a/.agents/skills/devspec-grooming.md b/.agents/skills/devspec-grooming.md index 01194b9..d729cad 100644 --- a/.agents/skills/devspec-grooming.md +++ b/.agents/skills/devspec-grooming.md @@ -1,5 +1,5 @@ --- name: devspec-grooming -description: Make one draft story buildable through scoped review and targeted questions. +description: Make one draft story buildable through scoped review and material questions. --- Read and execute `devspec/contracts/devspec.grooming.md`. diff --git a/.claude/skills/devspec-codebase-structure/SKILL.md b/.claude/skills/devspec-codebase-structure/SKILL.md index 785fd7b..19ab054 100644 --- a/.claude/skills/devspec-codebase-structure/SKILL.md +++ b/.claude/skills/devspec-codebase-structure/SKILL.md @@ -1,5 +1,5 @@ --- name: devspec-codebase-structure -description: Capture owned source roots, module boundaries, integrations, and repository access. +description: Capture or customize owned source roots, repository layouts, module boundaries, integrations, and repository access. --- Read and execute `devspec/contracts/devspec.codebase-structure.md`. diff --git a/.claude/skills/devspec-coding-standards/SKILL.md b/.claude/skills/devspec-coding-standards/SKILL.md index b66bbe2..50c5269 100644 --- a/.claude/skills/devspec-coding-standards/SKILL.md +++ b/.claude/skills/devspec-coding-standards/SKILL.md @@ -1,5 +1,5 @@ --- name: devspec-coding-standards -description: Capture short, evidence-backed conventions and anti-patterns. +description: Capture concise, reusable coding conventions, followable examples, and anti-patterns from source evidence or developer-defined standards. --- Read and execute `devspec/contracts/devspec.coding-standards.md`. diff --git a/.claude/skills/devspec-extract/SKILL.md b/.claude/skills/devspec-extract/SKILL.md index ea65694..e2c7fe6 100644 --- a/.claude/skills/devspec-extract/SKILL.md +++ b/.claude/skills/devspec-extract/SKILL.md @@ -1,5 +1,5 @@ --- name: devspec-extract -description: Inspect the approved existing system end-to-end and produce its technical, business, workflow, rule, and diagram baseline without requiring separate foundation or diagram commands. +description: Inspect the approved existing system end-to-end, produce its technical, business, workflow, and rule baseline, and prepare an evidence-backed diagram candidate list for explicit generation approval. --- Read and execute `devspec/contracts/devspec.extract.md`. diff --git a/.cursor/rules/devspec-workflow.mdc b/.cursor/rules/devspec-workflow.mdc index 68236b8..f0fa80b 100644 --- a/.cursor/rules/devspec-workflow.mdc +++ b/.cursor/rules/devspec-workflow.mdc @@ -2,4 +2,4 @@ description: Devspec Lite workflow alwaysApply: false --- -For `devspec.changerequest`, `devspec.clarify`, `devspec.codebase-structure`, `devspec.coding-standards`, `devspec.diagram`, `devspec.extract`, `devspec.finalize`, `devspec.grooming`, `devspec.implement`, `devspec.projectcontext`, `devspec.quickfix`, `devspec.review`, `devspec.rules`, `devspec.story`, `devspec.tasks`, `devspec.techstack`, read the matching `devspec/contracts/` file and listed protocols. For a clear continuation, resolve per-worktree current context and run only the saved next action; ask before switching stories. +For `devspec.extract`, `devspec.projectcontext`, `devspec.techstack`, `devspec.codebase-structure`, `devspec.coding-standards`, `devspec.rules`, `devspec.story`, `devspec.grooming`, `devspec.clarify`, `devspec.changerequest`, `devspec.finalize`, `devspec.tasks`, `devspec.implement`, `devspec.review`, `devspec.diagram`, `devspec.quickfix`, read the matching `devspec/contracts/` file and listed protocols. For a clear continuation, resolve per-worktree current context and run only the saved next action; ask before switching stories. diff --git a/.gemini/commands/devspec/codebase-structure.toml b/.gemini/commands/devspec/codebase-structure.toml index 6d67d8d..51c6168 100644 --- a/.gemini/commands/devspec/codebase-structure.toml +++ b/.gemini/commands/devspec/codebase-structure.toml @@ -1,2 +1,2 @@ -description = "Capture owned source roots, module boundaries, integrations, and repository access." +description = "Capture or customize owned source roots, repository layouts, module boundaries, integrations, and repository access." prompt = "Read and execute devspec/contracts/devspec.codebase-structure.md" diff --git a/.gemini/commands/devspec/coding-standards.toml b/.gemini/commands/devspec/coding-standards.toml index eb62300..ff86ac3 100644 --- a/.gemini/commands/devspec/coding-standards.toml +++ b/.gemini/commands/devspec/coding-standards.toml @@ -1,2 +1,2 @@ -description = "Capture short, evidence-backed conventions and anti-patterns." +description = "Capture concise, reusable coding conventions, followable examples, and anti-patterns from source evidence or developer-defined standards." prompt = "Read and execute devspec/contracts/devspec.coding-standards.md" diff --git a/.gemini/commands/devspec/extract.toml b/.gemini/commands/devspec/extract.toml index c49329e..b121a71 100644 --- a/.gemini/commands/devspec/extract.toml +++ b/.gemini/commands/devspec/extract.toml @@ -1,2 +1,2 @@ -description = "Inspect the approved existing system end-to-end and produce its technical, business, workflow, rule, and diagram baseline without requiring separate foundation or diagram commands." +description = "Inspect the approved existing system end-to-end, produce its technical, business, workflow, and rule baseline, and prepare an evidence-backed diagram candidate list for explicit generation approval." prompt = "Read and execute devspec/contracts/devspec.extract.md" diff --git a/.github/agents/devspec.codebase-structure.agent.md b/.github/agents/devspec.codebase-structure.agent.md index 043cc53..838c9f0 100644 --- a/.github/agents/devspec.codebase-structure.agent.md +++ b/.github/agents/devspec.codebase-structure.agent.md @@ -1,6 +1,6 @@ --- name: devspec.codebase-structure -description: Capture owned source roots, module boundaries, integrations, and repository access. +description: Capture or customize owned source roots, repository layouts, module boundaries, integrations, and repository access. user-invocable: true --- Execute `devspec/contracts/devspec.codebase-structure.md`. diff --git a/.github/agents/devspec.coding-standards.agent.md b/.github/agents/devspec.coding-standards.agent.md index ee8257b..861a28f 100644 --- a/.github/agents/devspec.coding-standards.agent.md +++ b/.github/agents/devspec.coding-standards.agent.md @@ -1,6 +1,6 @@ --- name: devspec.coding-standards -description: Capture short, evidence-backed conventions and anti-patterns. +description: Capture concise, reusable coding conventions, followable examples, and anti-patterns from source evidence or developer-defined standards. user-invocable: true --- Execute `devspec/contracts/devspec.coding-standards.md`. diff --git a/.github/agents/devspec.extract.agent.md b/.github/agents/devspec.extract.agent.md index d9417d8..6f089c1 100644 --- a/.github/agents/devspec.extract.agent.md +++ b/.github/agents/devspec.extract.agent.md @@ -1,6 +1,6 @@ --- name: devspec.extract -description: Backfill concise foundation evidence from an existing repository. +description: Inspect the approved existing system end-to-end, produce its technical, business, workflow, and rule baseline, and prepare an evidence-backed diagram candidate list for explicit generation approval. user-invocable: true --- Execute `devspec/contracts/devspec.extract.md`. diff --git a/devspec/architecture/_template/artifact-queue.md b/devspec/architecture/_template/artifact-queue.md index 2aee793..f51949f 100644 --- a/devspec/architecture/_template/artifact-queue.md +++ b/devspec/architecture/_template/artifact-queue.md @@ -1,4 +1,4 @@ # Architecture Artifact Queue -| ID | Scope | Type | Subject | Output | Evidence | Status | Next | -|---|---|---|---|---|---|---|---| +| ID | Scope | Type | Subject | Output | Evidence | Duplicate check | Status | Next | +|---|---|---|---|---|---|---|---|---| diff --git a/devspec/architecture/_template/diagram.md b/devspec/architecture/_template/diagram.md index b927565..19d30d8 100644 --- a/devspec/architecture/_template/diagram.md +++ b/devspec/architecture/_template/diagram.md @@ -1,6 +1,6 @@ # Architecture Diagram -Use this optional Markdown artifact for one durable Mermaid architecture, module, feature, workflow, process-flow, user journey, sequence, state, or domain diagram when the selected output set includes `mermaid`. SVG is the default diagram output and lives under `devspec/architecture/images/`; HTML is optional and lives under `devspec/architecture/html/`. Keep diagram status in `devspec/architecture/artifact-queue.md`; keep generated content references, supporting evidence, assumptions, and maintenance notes here when this Markdown artifact is created. +Use this optional Markdown artifact for one durable Mermaid architecture, module, feature, workflow, process-flow, user journey, sequence, state, or domain diagram when the selected output set includes `mermaid`. SVG is the default diagram output and lives under `devspec/architecture/diagrams/`; HTML is optional and lives under `devspec/architecture/diagrams/`. Keep diagram status in `devspec/architecture/artifact-queue.md`; keep generated content references, supporting evidence, assumptions, and maintenance notes here when this Markdown artifact is created. ## Resume State @@ -9,7 +9,7 @@ Use this optional Markdown artifact for one durable Mermaid architecture, module | Current stage | diagram | | Current command | `/devspec.diagram` | | Current agent | devspec.diagram | -| Run status | See `devspec/glossary.md#run-status-values` | +| Run status | See `devspec/protocols/state.xml` | | Current item | | | Last completed step | | | Next required action | | @@ -35,12 +35,12 @@ Use this optional Markdown artifact for one durable Mermaid architecture, module | Architecture style | monolith, microservices, event-driven, serverless, agentic workflow, multi-repo, cloud-native, or user-provided style | | Output format | mermaid, svg+mermaid, html+mermaid, or svg+html+mermaid | | Mermaid declaration | flowchart TD, flowchart LR, flowchart BT, sequenceDiagram, journey, stateDiagram-v2, classDiagram, erDiagram, gantt, quadrantChart, mindmap, timeline | -| SVG target | `devspec/architecture/images/dia-NNN-.svg` when output format includes svg | -| HTML target | `devspec/architecture/html/dia-NNN-.html` when output format includes html | +| SVG target | `devspec/architecture/diagrams/dia-NNN-.svg` when output format includes svg | +| HTML target | `devspec/architecture/diagrams/dia-NNN-.html` when output format includes html | | Subject | `dia-NNN-` | | Confidence | observed, high-confidence, low-confidence | | Tags | | -| Queue row | `devspec/architecture/artifact-queue.md#diagram-queue-register` | +| Queue row | `devspec/architecture/artifact-queue.md` | When a request uses the structured architecture-diagram prompt format and the selected output set includes `mermaid`, reflect the provided system name, architecture style, purpose, audience, actors, components, stores, flows, boundaries, design rules, and output format in this metadata, the queue row notes, source evidence and assumptions, and generated diagram content. If the request uses structured non-architecture diagram input, reflect the matching sequence, state/lifecycle, domain model, journey, timeline/gantt, quadrant, or mindmap fields in this metadata, the queue row notes, source evidence and assumptions, generated Mermaid content, and any SVG or HTML companion output. If the request omits output format, use SVG-only output and do not create this Markdown artifact. @@ -101,9 +101,9 @@ flowchart TD ## Companion Outputs - Use this section when `Output format` includes `svg` or `html`. -- Store the durable SVG at `devspec/architecture/images/dia-NNN-.svg`. -- Store optional standalone HTML at `devspec/architecture/html/dia-NNN-.html`. -- Select SVG templates from `.github/prompts/PATTERNS.md#svg-output-pattern`: `architecture-diagram.svg`, `process-flow-diagram.svg`, `sequence-diagram.svg`, `state-lifecycle-diagram.svg`, `domain-model-diagram.svg`, `journey-map-diagram.svg`, `timeline-plan-diagram.svg`, `quadrant-analysis-diagram.svg`, or `mindmap-diagram.svg`. Every template must preserve the shared dark architecture-style visual contract unless a documented constraint requires a smaller custom SVG. +- Store the durable SVG at `devspec/architecture/diagrams/dia-NNN-.svg`. +- Store optional standalone HTML at `devspec/architecture/diagrams/dia-NNN-.html`. +- Select SVG templates from `devspec/architecture/_template/`: `architecture-diagram.svg`, `process-flow-diagram.svg`, `sequence-diagram.svg`, `state-lifecycle-diagram.svg`, `domain-model-diagram.svg`, `journey-map-diagram.svg`, `timeline-plan-diagram.svg`, `quadrant-analysis-diagram.svg`, or `mindmap-diagram.svg`. Every template must preserve the shared dark architecture-style visual contract unless a documented constraint requires a smaller custom SVG. - Generated SVG must be standalone XML with inline styles and no external assets, `