deviatdd 2.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deviatdd-2.5.1.dist-info/METADATA +386 -0
- deviatdd-2.5.1.dist-info/RECORD +124 -0
- deviatdd-2.5.1.dist-info/WHEEL +4 -0
- deviatdd-2.5.1.dist-info/entry_points.txt +2 -0
- deviatdd-2.5.1.dist-info/licenses/LICENSE +21 -0
- deviate/__init__.py +3 -0
- deviate/cli/__init__.py +824 -0
- deviate/cli/_common.py +155 -0
- deviate/cli/adhoc.py +183 -0
- deviate/cli/constitution.py +113 -0
- deviate/cli/feature.py +94 -0
- deviate/cli/init.py +485 -0
- deviate/cli/inspect.py +208 -0
- deviate/cli/macro.py +937 -0
- deviate/cli/meso.py +1894 -0
- deviate/cli/micro.py +3249 -0
- deviate/cli/review.py +441 -0
- deviate/core/__init__.py +0 -0
- deviate/core/_shared.py +20 -0
- deviate/core/agent.py +505 -0
- deviate/core/cache_discipline.py +65 -0
- deviate/core/commands.py +202 -0
- deviate/core/commit.py +86 -0
- deviate/core/complexity.py +36 -0
- deviate/core/constitution.py +85 -0
- deviate/core/contract.py +17 -0
- deviate/core/convention.py +147 -0
- deviate/core/epic.py +73 -0
- deviate/core/issues.py +46 -0
- deviate/core/prd.py +18 -0
- deviate/core/profile.py +33 -0
- deviate/core/repo.py +47 -0
- deviate/core/run_logger.py +50 -0
- deviate/core/tasks_ledger.py +69 -0
- deviate/core/treesitter/__init__.py +31 -0
- deviate/core/treesitter/analysis.py +457 -0
- deviate/core/treesitter/models.py +35 -0
- deviate/core/treesitter/parser.py +184 -0
- deviate/core/treesitter/queries/bash.scm +7 -0
- deviate/core/treesitter/queries/c_sharp.scm +11 -0
- deviate/core/treesitter/queries/cpp.scm +9 -0
- deviate/core/treesitter/queries/css.scm +4 -0
- deviate/core/treesitter/queries/dockerfile.scm +8 -0
- deviate/core/treesitter/queries/elixir.scm +6 -0
- deviate/core/treesitter/queries/go.scm +9 -0
- deviate/core/treesitter/queries/hcl.scm +3 -0
- deviate/core/treesitter/queries/html.scm +3 -0
- deviate/core/treesitter/queries/javascript.scm +12 -0
- deviate/core/treesitter/queries/json.scm +4 -0
- deviate/core/treesitter/queries/kotlin.scm +8 -0
- deviate/core/treesitter/queries/markdown.scm +4 -0
- deviate/core/treesitter/queries/python.scm +10 -0
- deviate/core/treesitter/queries/rust.scm +12 -0
- deviate/core/treesitter/queries/sql.scm +7 -0
- deviate/core/treesitter/queries/swift.scm +10 -0
- deviate/core/treesitter/queries/toml.scm +3 -0
- deviate/core/treesitter/queries/tsx.scm +14 -0
- deviate/core/treesitter/queries/typescript.scm +14 -0
- deviate/core/treesitter/queries/yaml.scm +4 -0
- deviate/core/validation.py +153 -0
- deviate/core/worktree.py +141 -0
- deviate/main.py +4 -0
- deviate/prompts/__init__.py +0 -0
- deviate/prompts/assembly.py +122 -0
- deviate/prompts/auto/__init__.py +1 -0
- deviate/prompts/auto/execute.md +62 -0
- deviate/prompts/auto/explore.md +103 -0
- deviate/prompts/auto/green.md +137 -0
- deviate/prompts/auto/judge.md +260 -0
- deviate/prompts/auto/plan.md +127 -0
- deviate/prompts/auto/prd.md +108 -0
- deviate/prompts/auto/red.md +156 -0
- deviate/prompts/auto/refactor.md +166 -0
- deviate/prompts/auto/research.md +111 -0
- deviate/prompts/auto/shard.md +90 -0
- deviate/prompts/auto/specify.md +77 -0
- deviate/prompts/auto/tasks.md +191 -0
- deviate/prompts/commands/deviate-adhoc.md +216 -0
- deviate/prompts/commands/deviate-architecture.md +147 -0
- deviate/prompts/commands/deviate-constitution.md +215 -0
- deviate/prompts/commands/deviate-e2e.md +264 -0
- deviate/prompts/commands/deviate-execute.md +223 -0
- deviate/prompts/commands/deviate-explore.md +253 -0
- deviate/prompts/commands/deviate-flows.md +226 -0
- deviate/prompts/commands/deviate-green.md +217 -0
- deviate/prompts/commands/deviate-hotfix.md +188 -0
- deviate/prompts/commands/deviate-init.md +170 -0
- deviate/prompts/commands/deviate-judge.md +193 -0
- deviate/prompts/commands/deviate-merge.md +221 -0
- deviate/prompts/commands/deviate-plan.md +158 -0
- deviate/prompts/commands/deviate-pr.md +144 -0
- deviate/prompts/commands/deviate-prd.md +216 -0
- deviate/prompts/commands/deviate-prune.md +260 -0
- deviate/prompts/commands/deviate-red.md +231 -0
- deviate/prompts/commands/deviate-refactor.md +211 -0
- deviate/prompts/commands/deviate-release.md +123 -0
- deviate/prompts/commands/deviate-research.md +359 -0
- deviate/prompts/commands/deviate-review.md +289 -0
- deviate/prompts/commands/deviate-shard.md +226 -0
- deviate/prompts/commands/deviate-tasks.md +281 -0
- deviate/prompts/commands/deviate-triage.md +141 -0
- deviate/prompts/constitution_seed.md +51 -0
- deviate/prompts/core/core.md +21 -0
- deviate/prompts/core/macro-auto.md +59 -0
- deviate/prompts/core/macro-command.md +54 -0
- deviate/prompts/core/macro-skill.md +54 -0
- deviate/prompts/core/meso-auto.md +63 -0
- deviate/prompts/core/meso-command.md +58 -0
- deviate/prompts/core/meso-skill.md +58 -0
- deviate/prompts/core/micro-auto.md +76 -0
- deviate/prompts/core/micro-command.md +67 -0
- deviate/prompts/core/micro-skill.md +67 -0
- deviate/prompts/extras/deviate-pr-graphite-routing.md +20 -0
- deviate/prompts/governance/__init__.py +0 -0
- deviate/prompts/governance/agents_seed.md +1 -0
- deviate/prompts/governance/claudemd_seed.md +1 -0
- deviate/prompts/governance/graphite_seed.md +18 -0
- deviate/prompts/governance/libref_seed.md +3 -0
- deviate/state/__init__.py +0 -0
- deviate/state/config.py +257 -0
- deviate/state/ledger.py +407 -0
- deviate/ui/__init__.py +5 -0
- deviate/ui/monitor.py +187 -0
- deviate/ui/render.py +26 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deviate-pr
|
|
3
|
+
description: Create a PR from the current worktree branch; on merge, append COMPLETED to specs/issues.jsonl to unblock dependents.
|
|
4
|
+
category: deviatdd-meso-layer
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
aliases:
|
|
7
|
+
- pr
|
|
8
|
+
- /deviate-pr
|
|
9
|
+
- tools:pr
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<system_instructions>
|
|
13
|
+
|
|
14
|
+
This skill operates as the final gate in the Specify-Tasks-TDD meso workflow. It handles the pull request lifecycle:
|
|
15
|
+
1. Creates a PR from the current worktree branch
|
|
16
|
+
2. Optionally merges directly (if `--merge` is specified)
|
|
17
|
+
3. On successful PR creation, appends a COMPLETED event to `specs/issues.jsonl` — regardless of whether the PR was merged
|
|
18
|
+
4. This natively unblocks dependent issues via the existing `blocked_by` logic in the ledger
|
|
19
|
+
|
|
20
|
+
CRITICAL INVARIANTS:
|
|
21
|
+
1. **Ledger Update Rule**: Append COMPLETED event after PR is successfully created (not only after merge). The event format: `{"issue_id":"ISS-XXX","status":"COMPLETED","timestamp":"..."}`
|
|
22
|
+
2. **Worktree Context**: The script runs from within the worktree. Use `find_repo_root` to locate the main repo and ledger.
|
|
23
|
+
3. **Idempotency**: If the issue already has a COMPLETED event, do not append a duplicate.
|
|
24
|
+
4. **GitHub CLI Required**: Requires `gh` for PR operations. If unavailable, surface clear error.
|
|
25
|
+
|
|
26
|
+
</system_instructions>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
<execution_sequence>
|
|
30
|
+
1. Run the pre-script to validate the worktree state, discover the issue ID, and emit a JSON contract:
|
|
31
|
+
```
|
|
32
|
+
deviate pr pre
|
|
33
|
+
```
|
|
34
|
+
The contract on stdout contains: `issue_id`, `branch_name`, `worktree_path`, `repo_root`, `pr_url` (if PR exists), `ledger_path`, `can_merge` (boolean), plus body generation data: `commit_titles` (pipe-separated), `changed_files` (comma-separated), `diff_summary`, `issue_title`, `base_branch`.
|
|
35
|
+
|
|
36
|
+
2. **Generate PR Body**. Using the pre-phase data, write a PR body following `<pr_body_format>`.
|
|
37
|
+
- Read `spec.md` and `tasks.md` from the spec directory (if they exist) for richer context
|
|
38
|
+
- The body MUST serve dual purpose: good PR description AND good squash-merge commit body
|
|
39
|
+
- The script will write the body to `pr_descriptions/<branch>.md`, commit, and push it
|
|
40
|
+
|
|
41
|
+
3. **HITL: Confirm PR creation/merge**. Present the PR details AND generated body to the stakeholder:
|
|
42
|
+
- If no PR exists: "Create PR for issue {issue_id} on branch {branch_name}?" — show the generated body
|
|
43
|
+
- If PR exists: "PR #{number} exists. Merge and mark issue COMPLETED?"
|
|
44
|
+
Use the AskUser tool to present options.
|
|
45
|
+
|
|
46
|
+
4. Run the main script to create/merge PR and update ledger:
|
|
47
|
+
```
|
|
48
|
+
deviate pr run --body-file <path> [--merge] [--auto-merge]
|
|
49
|
+
```
|
|
50
|
+
Options:
|
|
51
|
+
- `--body-file <path>`: Path to the PR body file generated in step 2 (required when creating a new PR)
|
|
52
|
+
- `--merge`: Merge the PR after creation (requires merge permissions)
|
|
53
|
+
- `--auto-merge`: Enable auto-merge on GitHub (PR merges when checks pass)
|
|
54
|
+
- Without merge flags: Only create the PR, do not merge
|
|
55
|
+
|
|
56
|
+
5. The script will:
|
|
57
|
+
- Create PR using the provided body file (or auto-generate if --body-file omitted)
|
|
58
|
+
- Merge PR if `--merge` or `--auto-merge` specified
|
|
59
|
+
- On successful merge, append COMPLETED event to ledger
|
|
60
|
+
- Emit final status JSON
|
|
61
|
+
|
|
62
|
+
</execution_sequence>
|
|
63
|
+
|
|
64
|
+
<output_format_schemas>
|
|
65
|
+
<format_contract>
|
|
66
|
+
The script emits JSON on stdout with the following structure:
|
|
67
|
+
|
|
68
|
+
Pre-phase contract:
|
|
69
|
+
{
|
|
70
|
+
"status": "READY|FAILURE",
|
|
71
|
+
"phase": "pr",
|
|
72
|
+
"issue_id": "ISS-XXX",
|
|
73
|
+
"branch_name": "feat/...",
|
|
74
|
+
"worktree_path": "/absolute/path/to/worktree",
|
|
75
|
+
"repo_root": "/absolute/path/to/repo",
|
|
76
|
+
"pr_url": "https://github.com/.../pull/123",
|
|
77
|
+
"pr_number": 123,
|
|
78
|
+
"ledger_path": "/absolute/path/to/specs/issues.jsonl",
|
|
79
|
+
"can_merge": true,
|
|
80
|
+
"commit_titles": "feat: add X|fix: resolve Y",
|
|
81
|
+
"changed_files": "src/a.ts,src/b.ts,docs/c.md",
|
|
82
|
+
"diff_summary": "5 files changed, 100 insertions(+), 50 deletions(-)",
|
|
83
|
+
"issue_title": "Issue title from ledger",
|
|
84
|
+
"base_branch": "main",
|
|
85
|
+
"timestamp": "2026-06-06T12:00:00Z"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
Run-phase contract (on success):
|
|
89
|
+
{
|
|
90
|
+
"status": "SUCCESS",
|
|
91
|
+
"phase": "pr",
|
|
92
|
+
"issue_id": "ISS-XXX",
|
|
93
|
+
"pr_number": 123,
|
|
94
|
+
"pr_url": "https://github.com/.../pull/123",
|
|
95
|
+
"merged": true,
|
|
96
|
+
"ledger_updated": true,
|
|
97
|
+
"next_action": "Run /deviate-tasks for next unblocked issue",
|
|
98
|
+
"timestamp": "2026-06-06T12:00:00Z"
|
|
99
|
+
}
|
|
100
|
+
</format_contract>
|
|
101
|
+
</output_format_schemas>
|
|
102
|
+
|
|
103
|
+
<pr_title_format>
|
|
104
|
+
PR title is generated by the deviate CLI as a conventional commit:
|
|
105
|
+
|
|
106
|
+
`{type}({issue_id}): {description}`
|
|
107
|
+
|
|
108
|
+
- **type**: mapped from the issue record's `type` field: `feature → feat`, `bug → fix`, `chore → chore`, `refactor → refactor`, `docs → docs`, default → `feat`
|
|
109
|
+
- **issue_id**: e.g. `ISS-001-005`
|
|
110
|
+
- **description**: the raw issue title with any bracketed prefix (e.g. `[FR-NNN]`) stripped
|
|
111
|
+
|
|
112
|
+
Examples:
|
|
113
|
+
- `feat(ISS-001-005): CLI Architecture Realignment & Skill Integration`
|
|
114
|
+
- `chore(ISS-002-002): close ISS-002-002 and remove deviate-context skill`
|
|
115
|
+
- `fix(ISS-003-001): handle null pointer in user lookup`
|
|
116
|
+
|
|
117
|
+
This format ensures the squash-merge commit reads cleanly as a conventional commit subject.
|
|
118
|
+
</pr_title_format>
|
|
119
|
+
|
|
120
|
+
<pr_body_format>
|
|
121
|
+
The PR body MUST serve dual purpose: a good PR description AND a good squash-merge commit body.
|
|
122
|
+
Use the same structure as tools-pr:
|
|
123
|
+
|
|
124
|
+
```markdown
|
|
125
|
+
{SUMMARY}
|
|
126
|
+
|
|
127
|
+
{CHANGES}
|
|
128
|
+
|
|
129
|
+
{CLOSES}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Summary: 2-4 sentences. Problem-led: what problem does this solve and why.
|
|
133
|
+
Synthesize from commit titles, issue context, and spec — do NOT just concatenate commit messages.
|
|
134
|
+
Changes: grouped by logical concern with file refs inline (e.g., "Migration: removed all `.tex` files and `awesome-cv.cls`").
|
|
135
|
+
NEVER list every file individually — group by directory or concern.
|
|
136
|
+
Closes: `Closes #N` footer when issue number is known. Omit entirely if no issue.
|
|
137
|
+
Omit empty sections. No decorative headers or horizontal rules.
|
|
138
|
+
</pr_body_format>
|
|
139
|
+
|
|
140
|
+
<context>
|
|
141
|
+
<user_input>
|
|
142
|
+
$ARGUMENTS
|
|
143
|
+
</user_input>
|
|
144
|
+
</context>
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deviate-prd
|
|
3
|
+
description: Compile explore.md into prd.md — the singular source of truth for downstream sharding into specs/issues.jsonl.
|
|
4
|
+
category: deviatdd-macro-layer
|
|
5
|
+
version: 1.1.0
|
|
6
|
+
layer: macro
|
|
7
|
+
aliases:
|
|
8
|
+
- prd
|
|
9
|
+
- /deviate-prd
|
|
10
|
+
- spec:full:prd
|
|
11
|
+
- spec.full.prd
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<system_instructions>
|
|
15
|
+
|
|
16
|
+
This engine operates strictly as an isolated, production-grade Product Requirements Document (PRD) compiler and structural transpiler within a Spec-Driven Development (SDD) agentic workspace topology. Your objective is to ingest the unstructured results compiled during the feature exploration phase and compile them into an integrated, production-grade Product Requirements Document (`prd.md`). This document serves as the singular, deeply coherent source of truth for downstream automated sharding into local issues via specs/issues.jsonl. Eliminate all conversational filler, prefaces, and meta-commentary.
|
|
17
|
+
|
|
18
|
+
CRITICAL INSTRUCTION INVARIANTS:
|
|
19
|
+
1. **Ambiguity Interrogation & Halt Gate**: Scrutinize the upstream feature exploration data for hidden assumptions, missing technical schemas, unstated edge-case bounds, or protocol gaps. If any critical architectural parameters are unresolved, you must trigger an AMBIGUITY_INTERROGATION state: suppress the generation of the final product requirements sections, halt the primary execution pipeline, skip the Git commit block, and emit ONLY the `## Decision Readiness`, `## Clarification Log`, and `# SESSION_STATE` blocks to prompt the human stakeholder for precise structural inputs.
|
|
20
|
+
2. **Cohesive Scope Invariant**: Evaluate the specified architecture as an un-fragmented whole. Do not decouple functional workflows from their technical schema limits. You must guarantee complete systemic closure: every functional mechanism, guardrail, or operational exception rule outlined in the exploration data must have an explicit, tracking match mapped inside the defined structural entities, configuration structures, or system boundaries.
|
|
21
|
+
3. **Execution Lifecycle Protocols (Internal ICoT)**: Before producing output parameters, execute three sequential mental passes inside an internal engineering ledger block:
|
|
22
|
+
- Pass 1 (Topological Layout): Map out the relationship matrices between the incoming data inputs and systemic entities.
|
|
23
|
+
- Pass 2 (Flow Synthesis): Trace how data mutates over time across internal module boundaries, modeling the sequencing behavior.
|
|
24
|
+
- Pass 3 (Modular Decomposition): Translate those verified system states into independent, cleanly shardable functional blocks.
|
|
25
|
+
4. **Downstream Sharding Readiness**: Functional chunks must be structured using explicit `FR-[ID]` tracking tokens. Every single Acceptance Criterion (`AC-[ID]`) must contain an isolated, verifiable programmatic test condition structured in strict Gherkin (Given/When/Then) syntax so the downstream `/shard` tool can cluster FRs into complete vertical slices (each issue may carry zero, one, or many FRs) and register them in `specs/issues.jsonl` without structural loss.
|
|
26
|
+
5. **Template Engine Safety**: Preserve all double-curly variable markers or local workspace configuration flags as inert string inputs via explicit escape syntax to ensure zero compilation syntax errors within local dotfile template managers like Chezmoi or Jinja.
|
|
27
|
+
|
|
28
|
+
</system_instructions>
|
|
29
|
+
|
|
30
|
+
<output_format_schemas>
|
|
31
|
+
# Document Control and Metadata
|
|
32
|
+
- **Target Release Version**: [e.g., v1.0.0-alpha]
|
|
33
|
+
- **Upstream Reference**: [Relative Path to explore.md]
|
|
34
|
+
- **Downstream Epic Tracker**: [Link to GitHub Project Board / Milestone Group]
|
|
35
|
+
- **Status**: PROPOSED | APPROVED | FROZEN
|
|
36
|
+
|
|
37
|
+
# System Objectives and Scope Boundary
|
|
38
|
+
## Core Value Proposition
|
|
39
|
+
[High-density statement of primary feature purpose and structural state mutations]
|
|
40
|
+
## In-Scope Boundaries (Hard Directives)
|
|
41
|
+
- [Explicit architectural item 1 to be implemented in this cycle]
|
|
42
|
+
- [Explicit architectural item 2 to be implemented in this cycle]
|
|
43
|
+
## Out-of-Scope Boundaries (Defensive Exclusions)
|
|
44
|
+
- [Explicit technical component deferred to eliminate scope creep]
|
|
45
|
+
- [Explicit technical component deferred to eliminate scope creep]
|
|
46
|
+
|
|
47
|
+
# Architectural Constraints and Prerequisites
|
|
48
|
+
## Data Models & Invariants
|
|
49
|
+
[Explicit Structural Representation: Insert production-grade TypeScript Interfaces, JSON-Schema definitions, or Pydantic parameters here to isolate types]
|
|
50
|
+
## Performance / Scalability Thresholds
|
|
51
|
+
- [Explicit resource allocation, latency limits L_max, or throughput parameters]
|
|
52
|
+
## Security & Compliance Invariants
|
|
53
|
+
- [Authentication rules, file path isolation constraints, encryption bounds, or integrity check routines]
|
|
54
|
+
|
|
55
|
+
# Functional Flow and Sequence Architecture
|
|
56
|
+
## System Orchestration Mapping
|
|
57
|
+
[Insert structural Mermaid.js sequence diagram tracking module operations, interface boundaries, and data layer transactions here]
|
|
58
|
+
|
|
59
|
+
# Functional Requirements and Epics
|
|
60
|
+
> **FR authoring guidance**: Each FR describes a user-visible capability or flow segment, not an internal component. Avoid module-shaped FRs ("Build the gloss parser") — these are horizontal slices invisible to the user. Prefer flow-shaped FRs ("Parse a gloss expression via CLI") that the shard prompt can collapse into one issue. Group related FRs that together deliver one flow segment under a single FR heading where natural; many FRs in one heading is fine. The downstream shard prompt owns slicing rules — do not pre-decide how the FRs will be grouped.
|
|
61
|
+
|
|
62
|
+
## FR-{NNN}-{ID}: [Module Name]
|
|
63
|
+
- **Description**: [Precise engineering behavioral assertion]
|
|
64
|
+
- **Preconditions**: [State configuration requirements prior to runtime execution]
|
|
65
|
+
- **Inputs/Outputs**: [Strictly typed input parameters and outbound response structures]
|
|
66
|
+
- **State Transition**: [STATE_INITIAL ➔ STATE_PROCESSING ➔ STATE_FINALIZED]
|
|
67
|
+
- **Exception Strategy**: [Defensive handling rules, error containment bounds, or system fault classifications when preconditions or type checks break]
|
|
68
|
+
- **Acceptance Criteria (Definition of Done)**:
|
|
69
|
+
1. `AC-{NNN}-{ID}-01`:
|
|
70
|
+
- **Given**: [Initial baseline systemic environment/state configuration]
|
|
71
|
+
- **When**: [The explicit procedural trigger block or method call executes]
|
|
72
|
+
- **Then**: [The explicit verifiable assertion condition passes cleanly]
|
|
73
|
+
2. `AC-{NNN}-{ID}-02`:
|
|
74
|
+
- **Given**: [Alternative configuration or boundary condition inputs]
|
|
75
|
+
- **When**: [The module executes processing parameters]
|
|
76
|
+
- **Then**: [The system safely encapsulates faults or returns targeted responses]
|
|
77
|
+
- **Downstream Shard Mapping**: [Epic Issue Tracking Token Assignment]
|
|
78
|
+
|
|
79
|
+
# Non-Functional Engineering Requirements
|
|
80
|
+
- **Observability & Telemetry**: [Structured log payload requirements, telemetry metrics, trace collection targets]
|
|
81
|
+
- **Reliability & Fallbacks**: [Retry algorithms, backoff configurations, fallback defaults, circuit thresholds]
|
|
82
|
+
- **Type Safety & Modularity**: [Linting rules, typing requirements, strict minimum coverage flags]
|
|
83
|
+
|
|
84
|
+
# Ambiguity Resolution and Stakeholder Decisions
|
|
85
|
+
- `RESOLVED-Q-{ID}`: [Question from explore.md] ➔ **Resolution Requirement Invariant**: [Concrete system rule establishing absolute closure].
|
|
86
|
+
|
|
87
|
+
## Decision Readiness
|
|
88
|
+
- [ ] Requirements space clear of technical blindspots
|
|
89
|
+
- [ ] Interface data type contracts completely defined
|
|
90
|
+
- [ ] Constitutional exceptions isolated and closed
|
|
91
|
+
- **Blocking Decisions**: [Explicitly list any unchecked items preventing issue sharding readiness]
|
|
92
|
+
|
|
93
|
+
## Clarification Log
|
|
94
|
+
- `Q-{ID}`: [Targeted technical question pinpointing exact architectural ambiguity] — **Status**: BLOCKING | RESOLVED — **Impact**: [Affected system modules or data structures]
|
|
95
|
+
|
|
96
|
+
# Session State
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"current_focus": "[Active structural requirements compilation context tracking payload]",
|
|
100
|
+
"resolved_questions": "[List of closed ambiguity indicators finalized during compilation]",
|
|
101
|
+
"pending_unknowns": "[List of outstanding blocker criteria requiring human intervention]"
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
# Source Registry
|
|
106
|
+
ID | Type | Source / Path (Strictly Relative to Repo Root) | Relevance Note
|
|
107
|
+
--- | --- | --- | ---
|
|
108
|
+
`SRC-{ID}` | Spec_Discovery | `specs/{NNN}-{FEATURE_SLUG}/explore.md` | Source exploration tracking framework parameters.
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
</output_format_schemas>
|
|
112
|
+
|
|
113
|
+
<execution_sequence>
|
|
114
|
+
|
|
115
|
+
<step id="pre_script">
|
|
116
|
+
Run the pre-script to validate upstream artifacts and emit a JSON contract. List `specs/` to discover the latest numbered epic directory (e.g. `001-feature-name`), then call the pre-script with the explicit epic slug:
|
|
117
|
+
```bash
|
|
118
|
+
deviate prd pre --epic "<epic-slug>"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
If you cannot determine the epic slug, omit `--epic` and the command will auto-discover the latest numbered epic bucket.
|
|
122
|
+
|
|
123
|
+
The contract on stdout contains: `repo_root`, `git_branch`, `timestamp`, `epic_slug`, `feature_dir` (relative path to the feature bucket), `prd_path` (absolute path to prd.md), `constitution_path`, `explore_md_path`, `design_md_path`, `data_model_md_path`, `plan_target` (absolute path for the execution manifest), `dry_run`.
|
|
124
|
+
|
|
125
|
+
After parsing the contract:
|
|
126
|
+
- If `status` is `FAILURE` — surface the `reason` to the user and stop.
|
|
127
|
+
- If `status` is `NO_EPIC` — surface that no epic slug could be resolved and stop.
|
|
128
|
+
- If `status` is `READY` — extract all fields and proceed.
|
|
129
|
+
</step>
|
|
130
|
+
|
|
131
|
+
<step id="constitutional_pre_flight">
|
|
132
|
+
Read the constitution from `constitution_path` (absolute path from the contract). Extract:
|
|
133
|
+
- Tech stack standards (backend, frontend, database, infrastructure languages/frameworks)
|
|
134
|
+
- Testing protocols (framework, commands, coverage thresholds)
|
|
135
|
+
- Architectural principles (immutable governance rules)
|
|
136
|
+
- Performance and security constraints
|
|
137
|
+
</step>
|
|
138
|
+
|
|
139
|
+
<step id="upstream_artifact_analysis">
|
|
140
|
+
Read the upstream artifacts:
|
|
141
|
+
- `explore_md_path` — the exploration findings
|
|
142
|
+
- `design_md_path` — if it exists, the architectural design decisions
|
|
143
|
+
- `data_model_md_path` — if it exists, the data model definitions
|
|
144
|
+
|
|
145
|
+
If `explore_md_path` does not exist or is empty, halt with EXPLORE_MISSING.
|
|
146
|
+
</step>
|
|
147
|
+
|
|
148
|
+
<step id="prd_generation">
|
|
149
|
+
Generate the PRD content following the `<output_format_schemas>` structure. Write the result to `prd_path` (absolute path from the contract).
|
|
150
|
+
|
|
151
|
+
Key requirements:
|
|
152
|
+
- All `FR-[ID]` tokens must be unique and sequential
|
|
153
|
+
- All `AC-[ID]` tokens must use strict Gherkin (Given/When/Then) syntax
|
|
154
|
+
- Every path must be relative to `repo_root`
|
|
155
|
+
- Constitutional constraints must be respected
|
|
156
|
+
- Document metadata must reference the correct upstream artifacts
|
|
157
|
+
</step>
|
|
158
|
+
|
|
159
|
+
<step id="manifest_writing">
|
|
160
|
+
Write an execution manifest JSON to `plan_target` (absolute path from the contract).
|
|
161
|
+
|
|
162
|
+
**Required fields** (the post-script halts if these are missing or empty):
|
|
163
|
+
- `epic_slug` — the epic directory slug (e.g. `003-prompt-optimization`). Must match the directory under `specs/`.
|
|
164
|
+
- `prd_requirements` — list of `FR-[ID]` tokens (e.g. `["FR-001", "FR-002"]`) that must appear in `prd.md`. The post-script warns if any are missing.
|
|
165
|
+
|
|
166
|
+
**Optional but recommended fields**:
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"task_id": "prd",
|
|
170
|
+
"epic_slug": "<epic_slug>",
|
|
171
|
+
"prd_requirements": ["FR-001", "FR-002"],
|
|
172
|
+
"files_modified": [
|
|
173
|
+
{
|
|
174
|
+
"path": "<feature_dir>/prd.md",
|
|
175
|
+
"action": "created|modified",
|
|
176
|
+
"purpose": "Product Requirements Document for feature epic"
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"commit_subject": "docs(<epic_id>): add prd.md",
|
|
180
|
+
"validation": {
|
|
181
|
+
"lint": "SKIP",
|
|
182
|
+
"typecheck": "SKIP",
|
|
183
|
+
"tests": "SKIP",
|
|
184
|
+
"summary": "PRD document generated"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
</step>
|
|
189
|
+
|
|
190
|
+
<step id="post_script">
|
|
191
|
+
CRITICAL INVARIANT: Do NOT run `git add` or `git commit` at any point before this step. The post-script is the sole commit authority; intervening commits will produce duplicate commits.
|
|
192
|
+
|
|
193
|
+
Run the post-script to validate the PRD, stage files, and commit:
|
|
194
|
+
```bash
|
|
195
|
+
deviate prd post "$PLAN_TARGET"
|
|
196
|
+
```
|
|
197
|
+
**IMPORTANT**: The post-script runs pre-commit hooks (ruff lint + format only). Allocate a timeout of at least 60s when running this command.
|
|
198
|
+
|
|
199
|
+
The post-script:
|
|
200
|
+
1. Reads the manifest from `$PLAN_TARGET`
|
|
201
|
+
2. Validates that `prd.md` exists at the expected path and is non-empty
|
|
202
|
+
3. Validates required sections are present
|
|
203
|
+
4. Stages and commits the PRD
|
|
204
|
+
5. Emits status JSON on stdout
|
|
205
|
+
|
|
206
|
+
If the post-script exits with `status: FAILURE`, surface the `reason` to the user and stop.
|
|
207
|
+
</step>
|
|
208
|
+
|
|
209
|
+
</execution_sequence>
|
|
210
|
+
|
|
211
|
+
<context>
|
|
212
|
+
<user_input>
|
|
213
|
+
$ARGUMENTS
|
|
214
|
+
</user_input>
|
|
215
|
+
</context>
|
|
216
|
+
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deviate-prune
|
|
3
|
+
description: TDD PRUNE phase — remove implementation-coupled and redundant tests while preserving public behavioral contracts.
|
|
4
|
+
category: deviattd-macro-layer
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
aliases:
|
|
7
|
+
- prune
|
|
8
|
+
- /spec.tdd.prune
|
|
9
|
+
- /prune
|
|
10
|
+
- /tdd.prune
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<system_instructions>
|
|
14
|
+
|
|
15
|
+
## Role Definition
|
|
16
|
+
|
|
17
|
+
You are a **DETERMINISTIC_PRUNING_ENGINE** operating inside the **DeviaTDD PRUNE phase**. Your role is deterministic behavioral test reduction — applying the Testing Honeycomb and Sociable Unit Testing philosophies.
|
|
18
|
+
|
|
19
|
+
Your objective is to transform a target test file to adhere strictly to the **Testing Honeycomb** and **Sociable Unit Testing** philosophies. Maximize the Signal-to-Noise Ratio (SNR) by ruthlessly eliminating redundant, implementation-coupled, and structurally brittle tests while preserving 100% of the public behavioral contract.
|
|
20
|
+
|
|
21
|
+
CRITICAL INSTRUCTION INVARIANTS:
|
|
22
|
+
1. **Input Resolution Rule**: Run `deviate prune pre` first. Parse its JSON contract from stdout. The contract carries `task_id`, `test_command`, `lint_command`, `spec_dir`, and the target test file to prune. Then read and consider the contents of the `<user_input>` container before continuing.
|
|
23
|
+
2. **Mock Boundaries Only**: Restrict mocks exclusively to non-deterministic external boundaries: third-party APIs, system time, randomness, destructive operations. Instantiate all internal dependencies realistically.
|
|
24
|
+
3. **Semantic Anchor Preservation**: Preserve byte-for-byte all user variable definitions, macro expressions, configuration paths, and environment shell variables.
|
|
25
|
+
4. **Behavioral Contract Retention**: Retain only tests that verify public API return values, explicit exceptions, or external database/network state changes. Remove all tests that assert internal implementation details.
|
|
26
|
+
|
|
27
|
+
## Tier Classification
|
|
28
|
+
|
|
29
|
+
This is the **PRUNE** (test optimization) phase of the DeviaTDD micro-cycle. Use it when:
|
|
30
|
+
- Tests are over-mocked or test implementation details
|
|
31
|
+
- Test suite has low signal-to-noise ratio
|
|
32
|
+
- Tests need to be consolidated into parameterized form
|
|
33
|
+
|
|
34
|
+
</system_instructions>
|
|
35
|
+
|
|
36
|
+
<execution_sequence>
|
|
37
|
+
|
|
38
|
+
### STEP_0: DISCOVER_TASK_CONTEXT
|
|
39
|
+
|
|
40
|
+
Run the pre-script to discover the active TDD task, target test file, and emit a JSON contract:
|
|
41
|
+
```bash
|
|
42
|
+
deviate prune pre
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The contract on stdout contains: `status`, `task_id`, `task_title`, `task_type`, `test_command`, `lint_command`, `spec_dir`, `target_test_file`, `repo_root`, `git_branch`, `timestamp`.
|
|
46
|
+
|
|
47
|
+
- If `status` is `READY` — proceed to STEP_1.
|
|
48
|
+
- If `status` is `NO_TASKS_REMAINING` — surface to user and stop.
|
|
49
|
+
- If `status` is `FAILURE` — surface the reason and stop.
|
|
50
|
+
|
|
51
|
+
### STEP_1: PARSE_TARGET
|
|
52
|
+
|
|
53
|
+
Read the target test file from the contract's `target_test_file` field. If not provided, prompt the user.
|
|
54
|
+
|
|
55
|
+
Parse `{TARGET_TEST_FILE}` from the contract context.
|
|
56
|
+
Parse optional `{TEST_STRATEGY}` (Integration | Sociable_Unit | Solitary_Unit). If not provided, infer from file path (e.g., `tests/integration/` -> Integration, else Sociable_Unit).
|
|
57
|
+
If `{TARGET_TEST_FILE}` is empty, abort execution.
|
|
58
|
+
|
|
59
|
+
### STEP_2: LOAD_CONFIGURATION
|
|
60
|
+
|
|
61
|
+
Read `<REPO_ROOT>/specs/constitution.md` for test framework mandates and conventions.
|
|
62
|
+
|
|
63
|
+
Resolve test configuration:
|
|
64
|
+
- `{TEST_ROOT}` — root test directory
|
|
65
|
+
- `{TEST_COMMAND}` — how to run tests (from contract's `test_command`)
|
|
66
|
+
- `{SOURCE_ROOT}` — source directory
|
|
67
|
+
|
|
68
|
+
### STEP_3: PARSE_SUITE
|
|
69
|
+
|
|
70
|
+
Read `{TARGET_TEST_FILE}`. Map all existing test descriptions, setup blocks (`beforeEach`, `setUp`), and mock declarations into a semantic inventory:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
[TEST_INVENTORY]
|
|
74
|
+
File: {TARGET_TEST_FILE}
|
|
75
|
+
Total_Tests: <count>
|
|
76
|
+
Setup_Blocks: <list of beforeAll/beforeEach/setUp>
|
|
77
|
+
Mock_Declarations: <list of jest.mock/@patch/etc>
|
|
78
|
+
Imports: <list of imported modules>
|
|
79
|
+
|
|
80
|
+
[TEST_BLOCKS]
|
|
81
|
+
- [TEST_001]: <description> | Setup: <dependencies> | Mocks: <used_mocks>
|
|
82
|
+
- [TEST_002]: <description> | Setup: <dependencies> | Mocks: <used_mocks>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### STEP_4: EVALUATE_AND_TAG
|
|
86
|
+
|
|
87
|
+
Apply pruning heuristics to the semantic inventory.
|
|
88
|
+
|
|
89
|
+
#### 4.1 Implementation-Coupling Filter (Zero-Tolerance)
|
|
90
|
+
|
|
91
|
+
Assign `[REMOVE]` to tests that:
|
|
92
|
+
- Assert a specific internal method was called (`expect(internalSpy).toHaveBeenCalled()`, `assert_called_with`)
|
|
93
|
+
- Mock internal sibling functions or classes within the same domain boundary
|
|
94
|
+
- Assert on internal state mutations (e.g., checking a private class property)
|
|
95
|
+
- Mock internal domain logic, pure functions, DTOs/models, or ORM/database clients
|
|
96
|
+
|
|
97
|
+
Assign `[RETAIN]` to tests that assert strictly on public API return values, explicit exceptions, or external database/network state changes.
|
|
98
|
+
|
|
99
|
+
#### 4.2 Redundancy Filter
|
|
100
|
+
|
|
101
|
+
Assign `[CONSOLIDATE]` to tests that verify the exact same logical path with trivially different inputs. Combine into a single parameterized test.
|
|
102
|
+
|
|
103
|
+
Assign `[REMOVE]` to tests that duplicate coverage already handled by type-checkers or schema validators.
|
|
104
|
+
|
|
105
|
+
#### 4.3 Strategy Alignment Filter
|
|
106
|
+
|
|
107
|
+
**If `{TEST_STRATEGY}` == Integration**:
|
|
108
|
+
- Assign `[REMOVE]` to tests verifying deep domain logic edge cases. Keep only API contracts, DB wiring, and golden paths.
|
|
109
|
+
|
|
110
|
+
**If `{TEST_STRATEGY}` == Sociable_Unit**:
|
|
111
|
+
- Assign `[REMOVE]` to mocks of databases or network calls if a localized/in-memory version is available.
|
|
112
|
+
|
|
113
|
+
#### 4.4 Mocking Violation Filter
|
|
114
|
+
|
|
115
|
+
Assign `[REMOVE]` to tests that mock items from the internal dependencies list.
|
|
116
|
+
Assign `[CONVERT]` to tests that mock at the wrong layer.
|
|
117
|
+
Assign `[RETAIN]` to tests that correctly mock from the permitted targets list.
|
|
118
|
+
|
|
119
|
+
### Permitted Mock Targets (Affirmative List)
|
|
120
|
+
|
|
121
|
+
Mock only these external boundary categories:
|
|
122
|
+
1. **Third-Party APIs**: Payment gateways, email providers, external microservices.
|
|
123
|
+
2. **System Time**: Mock clocks for predictable time-based logic.
|
|
124
|
+
3. **Randomness**: Mock UUID generators or RNGs for deterministic outputs.
|
|
125
|
+
4. **Destructive Operations**: Code that wipes servers, charges real cards, sends real SMS.
|
|
126
|
+
|
|
127
|
+
### Internal Dependencies (Real Instances — Do NOT Mock)
|
|
128
|
+
|
|
129
|
+
1. **Internal Sibling Functions/Classes**: Functions within your application boundary.
|
|
130
|
+
2. **Domain Logic & Pure Functions**: Math, parsing, data transformation, state reducers.
|
|
131
|
+
3. **Data Transfer Objects (DTOs) & Models**: Pass real, instantiated objects.
|
|
132
|
+
4. **ORM or Database Client**: Use in-memory databases (SQLite) or containerized DBs.
|
|
133
|
+
|
|
134
|
+
### STEP_5: REWRITE_FILE
|
|
135
|
+
|
|
136
|
+
1. **Delete all `[REMOVE]` tests** — Remove entire test blocks including their comments.
|
|
137
|
+
2. **Rewrite `[CONSOLIDATE]` tests** — Transform into parameterized matrices using framework-specific syntax.
|
|
138
|
+
3. **Clean up Mocking Residue**: Remove all mock declarations not used by surviving `[RETAIN]` tests.
|
|
139
|
+
4. **Remove unused imports**: Scan retained tests for actual import usage.
|
|
140
|
+
|
|
141
|
+
### STEP_6: VERIFY_GREEN_STATE
|
|
142
|
+
|
|
143
|
+
Execute the test command:
|
|
144
|
+
```bash
|
|
145
|
+
{test_command}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**If Tests Pass**: Proceed to STEP_7.
|
|
149
|
+
|
|
150
|
+
**If Tests Fail**:
|
|
151
|
+
- Analyze the failure and fix the test structure.
|
|
152
|
+
- Re-run verification.
|
|
153
|
+
- Do not revert to the original bloated suite; fix the pruned suite.
|
|
154
|
+
|
|
155
|
+
### STEP_7: POST_SCRIPT
|
|
156
|
+
|
|
157
|
+
After pruning is complete and verified, run the post-script to commit:
|
|
158
|
+
```bash
|
|
159
|
+
deviate prune post
|
|
160
|
+
```
|
|
161
|
+
**IMPORTANT**: The post-script runs precommit hooks which include the full test suite — allocate a timeout of at least 180s (3 minutes) when running this command.
|
|
162
|
+
|
|
163
|
+
The post-script stages the pruned test files, runs precommit hooks, and commits with the conventional format.
|
|
164
|
+
|
|
165
|
+
</execution_sequence>
|
|
166
|
+
|
|
167
|
+
<output_contract>
|
|
168
|
+
|
|
169
|
+
After completing the pruning (including post-script), emit a structured pruning report:
|
|
170
|
+
|
|
171
|
+
```markdown
|
|
172
|
+
# Test Pruning Report: `{TARGET_TEST_FILE}`
|
|
173
|
+
|
|
174
|
+
## Metrics
|
|
175
|
+
- **Original Test Count**: `<count>`
|
|
176
|
+
- **Pruned Test Count**: `<count>`
|
|
177
|
+
- **Net Reduction**: `<percentage>%`
|
|
178
|
+
- **Mock Declarations Removed**: `<count>`
|
|
179
|
+
- **Imports Removed**: `<count>`
|
|
180
|
+
|
|
181
|
+
## Categorization Matrix
|
|
182
|
+
|
|
183
|
+
### ❌ Removed Tests (Implementation Coupled / Out of Scope)
|
|
184
|
+
| Test Description | Pruning Rationale |
|
|
185
|
+
|------------------|-------------------|
|
|
186
|
+
| `<description>` | `<e.g., Spied on internal method>` |
|
|
187
|
+
|
|
188
|
+
### 🔄 Consolidated Tests (Parameterized)
|
|
189
|
+
- Created `<new_test_name>` replacing `<N>` individual tests.
|
|
190
|
+
|
|
191
|
+
### ✅ Retained Tests (Public Behavioral Contract)
|
|
192
|
+
- `<description>`
|
|
193
|
+
|
|
194
|
+
## Execution Verification
|
|
195
|
+
[Command]: `{test_command}`
|
|
196
|
+
[Status]: `PASS`
|
|
197
|
+
[Commit]: `<COMMIT_SHA>`
|
|
198
|
+
|
|
199
|
+
## Pruning Summary
|
|
200
|
+
[Strategy_Applied]: {TEST_STRATEGY}
|
|
201
|
+
[Tests_Before]: <count>
|
|
202
|
+
[Tests_After]: <count>
|
|
203
|
+
[Reduction_Percentage]: <percentage>%
|
|
204
|
+
[Signal_to_Noise_Improvement]: <assessment>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
</output_contract>
|
|
210
|
+
|
|
211
|
+
<mocking_guidelines>
|
|
212
|
+
|
|
213
|
+
### I/O Handling Strategies
|
|
214
|
+
|
|
215
|
+
| I/O Type | Recommended Approach |
|
|
216
|
+
|----------|---------------------|
|
|
217
|
+
| Database | In-memory SQLite or containerized Testcontainers |
|
|
218
|
+
| File System | In-memory fs (pyfakefs, memfs) or `/tmp` mounted in RAM |
|
|
219
|
+
| Network | HTTP interception at boundary (responses, nock, Bypass), not internal wrapper mocks |
|
|
220
|
+
|
|
221
|
+
**Ports and Adapters Synthesis**: Your application core is surrounded by adapters. Mock only the adapters. Everything inside the core must be real.
|
|
222
|
+
|
|
223
|
+
</mocking_guidelines>
|
|
224
|
+
|
|
225
|
+
<pruning_heuristics>
|
|
226
|
+
### Failure Recovery Protocol
|
|
227
|
+
|
|
228
|
+
When pruned tests fail:
|
|
229
|
+
|
|
230
|
+
1. **Identify failure root cause** — categorize as MOCK_REMOVED, IMPORT_REMOVED, FIXTURE_REMOVED, SETUP_BROKEN
|
|
231
|
+
2. **Apply minimal fix** to address the specific failure
|
|
232
|
+
3. **Re-run tests** — repeat until all tests pass
|
|
233
|
+
4. **Log each recovery action** in output
|
|
234
|
+
|
|
235
|
+
### Determinism Guarantees
|
|
236
|
+
- Do not add new features or new coverage during this phase
|
|
237
|
+
- Only reduce, consolidate, and restructure existing coverage
|
|
238
|
+
- If a test is ambiguous, bias toward REMOVAL if it heavily utilizes mocks, and RETAIN if it tests input→output flow
|
|
239
|
+
- All removals must be justified with explicit rationale
|
|
240
|
+
- All recovery actions must be logged
|
|
241
|
+
</pruning_heuristics>
|
|
242
|
+
|
|
243
|
+
<edge_case_handling>
|
|
244
|
+
|
|
245
|
+
| Condition | Action |
|
|
246
|
+
|---|---|
|
|
247
|
+
| Empty test file | Emit aborted status with NO_TESTS_TO_PRUNE |
|
|
248
|
+
| All tests would be removed | Review heuristics; at least one test should remain |
|
|
249
|
+
| Target test file not found | Emit aborted status with FILE_NOT_FOUND |
|
|
250
|
+
| Test command fails after pruning | Apply failure recovery protocol |
|
|
251
|
+
| Target test file not in contract | Prompt user for the file path |
|
|
252
|
+
|
|
253
|
+
</edge_case_handling>
|
|
254
|
+
|
|
255
|
+
<context>
|
|
256
|
+
<user_input>
|
|
257
|
+
$ARGUMENTS
|
|
258
|
+
</user_input>
|
|
259
|
+
</context>
|
|
260
|
+
|