Skip to content

Commit 1f054c5

Browse files
committed
Add support for systematic, structured issue creation with copilot help
1 parent a3c3fb4 commit 1f054c5

File tree

5 files changed

+356
-0
lines changed

5 files changed

+356
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Change Validation Report: add-backlog-add-interactive-issue-creation
2+
3+
**Validation Date**: 2026-01-31T00:32:54+01:00
4+
**Change Proposal**: [proposal.md](./proposal.md)
5+
**Validation Method**: Dry-run simulation and format/OpenSpec compliance check
6+
7+
## Executive Summary
8+
9+
- **Breaking Changes**: 1 interface extension (new abstract method on BacklogAdapterMixin); all concrete backlog adapters must implement it.
10+
- **Dependent Files**: 2 affected (GitHubAdapter, AdoAdapter); no existing callers of create_issue.
11+
- **Impact Level**: Low
12+
- **Validation Result**: Pass
13+
- **User Decision**: N/A (no breaking-change options required)
14+
15+
## Breaking Changes Detected
16+
17+
### Interface: BacklogAdapterMixin.create_issue
18+
19+
- **Type**: New abstract method
20+
- **Old Signature**: (none; method does not exist)
21+
- **New Signature**: `create_issue(project_id: str, payload: dict) -> dict`
22+
- **Breaking**: Yes for implementors (any class inheriting BacklogAdapterMixin must implement the new method)
23+
- **Dependent Files**:
24+
- `src/specfact_cli/adapters/github.py`: Must implement create_issue
25+
- `src/specfact_cli/adapters/ado.py`: Must implement create_issue
26+
27+
**Mitigation**: Change scope already includes implementing create_issue in both GitHub and ADO adapters; no external dependents of BacklogAdapterMixin exist outside this repo. No scope extension needed.
28+
29+
## Dependencies Affected
30+
31+
### Critical Updates Required
32+
33+
- `src/specfact_cli/adapters/github.py`: Implement create_issue (in scope)
34+
- `src/specfact_cli/adapters/ado.py`: Implement create_issue (in scope)
35+
36+
### Recommended Updates
37+
38+
- None
39+
40+
## Impact Assessment
41+
42+
- **Code Impact**: Additive; new command and adapter method. Existing refine/sync/analyze-deps unchanged.
43+
- **Test Impact**: New tests for create_issue and add command (TDD in tasks).
44+
- **Documentation Impact**: docs/guides/agile-scrum-workflows.md, backlog guide for backlog add workflow.
45+
- **Release Impact**: Minor (new feature).
46+
47+
## Dependency on add-backlog-dependency-analysis-and-commands
48+
49+
- **Note**: The plan states this change "Depends on" add-backlog-dependency-analysis-and-commands (BacklogGraphBuilder, fetch_all_issues, fetch_relationships). If that change is not yet merged, implementation can use minimal graph usage (e.g. fetch_backlog_item to validate parent exists) as stated in proposal Impact. No ambiguity; design and tasks already allow fallback.
50+
51+
## Format Validation
52+
53+
- **proposal.md Format**: Pass
54+
- Title format: Correct (# Change: ...)
55+
- Required sections: All present (Why, What Changes, Capabilities, Impact)
56+
- "What Changes" format: Correct (NEW/EXTEND bullets)
57+
- "Capabilities" section: Present (backlog-add)
58+
- "Impact" format: Correct
59+
- Source Tracking section: Present (GitHub #173)
60+
- **tasks.md Format**: Pass
61+
- Section headers: Hierarchical numbered (## 1. ... ## 10.)
62+
- Task format: - [ ] N.N Description
63+
- Sub-task format: Indented - [ ] N.N.N
64+
- Config.yaml compliance: Pass (TDD section, branch first, PR last, version/changelog task, GitHub issue task)
65+
- **specs/backlog-add/spec.md Format**: Pass (ADDED requirements, Given/When/Then)
66+
- **design.md Format**: Pass (bridge adapter, sequence, contract, fallback)
67+
- **Config.yaml Compliance**: Pass
68+
69+
## OpenSpec Validation
70+
71+
- **Status**: Pass
72+
- **Validation Command**: `openspec validate add-backlog-add-interactive-issue-creation --strict`
73+
- **Issues Found**: 0
74+
- **Issues Fixed**: 0
75+
76+
## Validation Artifacts
77+
78+
- No temporary workspace used (validation was format and dependency analysis only).
79+
- Breaking change is in-scope (adapter implementations are part of the change).
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Design: Add backlog add (interactive issue creation)
2+
3+
## Bridge adapter integration
4+
5+
- **Create method**: Extend `BacklogAdapterMixin` with abstract `create_issue(project_id: str, payload: dict) -> dict`. Payload is unified: type (epic|feature|story|task|bug|spike|custom), title, description, optional parent_id, optional sprint, optional custom fields. Adapter maps to provider: GitHub Issues API (POST /repos/{owner}/{repo}/issues) with title, body, labels for type; ADO Create Work Item API with work item type from template type_mapping and parent relation when parent_id present.
6+
- **Adapter capability**: GitHub and ADO adapters implement create_issue; return dict with id, key (or number), url. Read-only or unsupported adapters may raise or return clear "not supported" for future extensibility.
7+
8+
## Sequence (add flow)
9+
10+
```text
11+
User → specfact backlog add --type story --parent FEAT-123 --title "T" [--body "B"] [--check-dor]
12+
→ CLI loads config & template (creation_hierarchy, type_mapping)
13+
→ CLI fetches graph (fetch_all_issues, fetch_relationships) or uses cached graph
14+
→ CLI validates: parent FEAT-123 exists, type Story allowed under parent type
15+
→ Optional: DoR check on draft (reuse backlog refine DoR loader)
16+
→ CLI builds unified payload (type, title, description, parent_id)
17+
→ adapter.create_issue(project_id, payload) → provider API
18+
→ CLI outputs created id, key, url
19+
```
20+
21+
## Contract enforcement
22+
23+
- New public methods: `create_issue` on adapters, add-command entry point and validation helpers shall have @icontract and @beartype.
24+
- Payload schema (unified) can be a Pydantic model for validation before passing to adapter.
25+
26+
## Creation hierarchy
27+
28+
- **Source**: Optional `creation_hierarchy` in template YAML or backlog_config (e.g. under .specfact/spec.yaml). Format: map child type to list of allowed parent types (e.g. story: [feature, epic], task: [story]).
29+
- **Default**: When absent, derive from dependency_rules (PARENT_CHILD) and type_mapping if possible; otherwise allow no parent or any existing type and document behavior.
30+
- **Validation**: Before create, resolve parent_id in graph; check parent's effective type is in allowed list for the new item's type.
31+
32+
## Fallback / offline
33+
34+
- Add command requires network for create. Graph load may use cached baseline if available (from add-backlog-dependency-analysis-and-commands); otherwise fetch. Failure (auth, rate limit) is reported; no silent swallow.
35+
36+
## Alignment with existing backlog commands
37+
38+
- Reuse DoR loading and rules from `specfact backlog refine --check-dor` when --check-dor is set. Reuse BacklogGraphBuilder and DependencyAnalyzer (from add-backlog-dependency-analysis-and-commands) when available for parent validation and cycle avoidance; if that change is not merged, minimal validation (e.g. parent exists via fetch_backlog_item) suffices for v1.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Change: Add backlog add (interactive issue creation)
2+
3+
## Why
4+
5+
After implementing backlog adapters and dependency analysis (add-backlog-dependency-analysis-and-commands), teams can analyze and sync backlog items but cannot create new issues from the CLI with proper scoping, hierarchy alignment, and Definition of Ready (DoR) checks. Without a dedicated add flow, users create issues manually in GitHub/ADO and risk orphaned or misaligned items. Adding `specfact backlog add` enables interactive creation with AI copilot assistance: draft → review → enhance → validate (graph, DoR) → create, so new issues fit the existing backlog structure and value chain.
6+
7+
## What Changes
8+
9+
- **NEW**: Add CLI command `specfact backlog add` (or alias `specfact backlog add-issue`) for interactive creation of backlog issues (epic, feature, story, task, bug, spike) with optional parent, title, body, and DoR validation.
10+
- **NEW**: Support multiple backlog levels (epic, feature, story, task, bug, spike, custom) with configurable creation hierarchy (allowed parent types per child type) via template or backlog_config; default derived from existing type_mapping and dependency_rules.
11+
- **NEW**: Extend `BacklogAdapterMixin` with abstract method `create_issue(project_id: str, payload: dict) -> dict` returning created item (id, key, url); implement in GitHub and ADO adapters with unified payload shape and provider-specific mapping.
12+
- **NEW**: Add spec delta and implementation for add flow: load graph (BacklogGraphBuilder, fetch_all_issues, fetch_relationships), resolve type and parent from template/hierarchy, validate parent exists and allowed type, optional DoR check (reuse backlog refine DoR), map draft to provider payload, call adapter create_issue, output created id/key/url.
13+
- **EXTEND**: Template or backlog_config with optional creation_hierarchy (allowed parent types per child type) so Scrum/SAFe/Kanban and custom hierarchies work without code changes.
14+
- **EXTEND**: Documentation (agile-scrum-workflows, backlog-refinement) for backlog add workflow, interactive creation, DoR, and slash-prompt usage.
15+
16+
## Capabilities
17+
18+
- **backlog-add**: Interactive creation of backlog issues with type/parent selection, draft validation (graph and DoR), and create via adapter; multi-level support (epic, feature, story, task, bug, spike, custom) with configurable hierarchy.
19+
20+
## Impact
21+
22+
- **Affected specs**: New `openspec/changes/add-backlog-add-interactive-issue-creation/specs/backlog-add/spec.md` (Given/When/Then for add flow, hierarchy, create via adapter).
23+
- **Affected code**: `src/specfact_cli/adapters/backlog_base.py` (abstract create_issue), `github.py` and `ado.py` (implement create_issue); `src/specfact_cli/commands/backlog_commands.py` or backlog command module (add `specfact backlog add` subcommand); optional creation_hierarchy loader and validation using BacklogGraphBuilder and DependencyAnalyzer (from add-backlog-dependency-analysis-and-commands when available).
24+
- **Affected documentation** (<https://docs.specfact.io>): docs/guides/agile-scrum-workflows.md, backlog-refinement or backlog guide for backlog add, interactive creation, DoR, slash prompt.
25+
- **Integration points**: BacklogGraphBuilder, DependencyAnalyzer, fetch_all_issues, fetch_relationships (add-backlog-dependency-analysis-and-commands); DoR from backlog-refinement; templates and backlog_config.
26+
- **Backward compatibility**: Additive only; new command and adapter method; existing refine/sync/analyze-deps unchanged. Depends on add-backlog-dependency-analysis-and-commands for graph/templates; can be implemented with minimal graph usage (e.g. fetch + validate parent) if that change is not yet merged.
27+
28+
## Source Tracking
29+
30+
- **GitHub Issue**: #173
31+
- **Issue URL**: <https://github.com/nold-ai/specfact-cli/issues/173>
32+
- **Repository**: nold-ai/specfact-cli
33+
- **Last Synced Status**: proposed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Backlog Add (Interactive Issue Creation)
2+
3+
## ADDED Requirements
4+
5+
### Requirement: Backlog adapter create method
6+
7+
The system SHALL extend backlog adapters with a create method that accepts a unified payload and returns the created item (id, key, url).
8+
9+
**Rationale**: Creation is currently out-of-band (user creates in GitHub/ADO UI). CLI-driven creation with consistent payload shape allows draft → validate → create flow.
10+
11+
#### Scenario: Create issue via GitHub adapter
12+
13+
**Given**: A GitHub adapter is configured and project_id (owner/repo) is set
14+
15+
**When**: The user or add command calls `create_issue(project_id, payload)` with payload containing type, title, description, and optional parent_id
16+
17+
**Then**: The adapter maps the unified payload to GitHub Issues API (e.g. POST /repos/{owner}/{repo}/issues) and creates the issue
18+
19+
**And**: The method returns a dict with id, key (or number), and url of the created issue
20+
21+
**Acceptance Criteria**:
22+
23+
- Payload is provider-agnostic (type, title, description, parent_id, optional fields)
24+
- Adapter performs provider-specific mapping (e.g. GitHub labels for type, body for description)
25+
- Failure (auth, validation) is reported; no silent swallow
26+
27+
#### Scenario: Create work item via ADO adapter
28+
29+
**Given**: An ADO adapter is configured and project_id is set
30+
31+
**When**: The user or add command calls `create_issue(project_id, payload)` with payload containing type, title, description, and optional parent_id
32+
33+
**Then**: The adapter maps the unified payload to ADO Create Work Item API and creates the work item
34+
35+
**And**: The method returns a dict with id, key, and url of the created work item
36+
37+
**Acceptance Criteria**:
38+
39+
- ADO work item type is derived from unified type via template type_mapping
40+
- Parent link is created when parent_id is present and adapter supports it
41+
42+
### Requirement: Backlog add command
43+
44+
The system SHALL provide a `specfact backlog add` command that supports interactive creation of backlog issues with type selection, optional parent, title/body, validation (parent exists, allowed type, optional DoR), and create via adapter.
45+
46+
**Rationale**: Teams need a single flow to add well-scoped, hierarchy-aligned issues from CLI or slash prompt.
47+
48+
#### Scenario: Add story with parent
49+
50+
**Given**: A backlog graph or project is loaded (e.g. from fetch_all_issues and fetch_relationships or existing graph)
51+
52+
**And**: Template or backlog_config defines allowed types and creation hierarchy (e.g. Story may have parent Feature or Epic)
53+
54+
**When**: The user runs `specfact backlog add --type story --parent FEAT-123 --title "Implement X" --body "As a user..."` (or equivalent interactive prompts)
55+
56+
**Then**: The system validates that parent FEAT-123 exists in the graph and that Story is allowed under that parent type
57+
58+
**And**: If validation passes, the system builds a unified payload and calls the adapter's create_issue(project_id, payload)
59+
60+
**And**: The CLI outputs the created issue id, key, and url
61+
62+
**Acceptance Criteria**:
63+
64+
- Validation fails clearly when parent does not exist or type is not allowed
65+
- Optional --check-dor runs DoR rules (from backlog-refinement / .specfact/dor.yaml) on the draft and warns or fails when not met
66+
67+
#### Scenario: Add issue with custom hierarchy
68+
69+
**Given**: backlog_config (or template) defines creation_hierarchy with custom allowed parent types per child type (e.g. Spike may have parent Epic or Feature)
70+
71+
**When**: The user runs `specfact backlog add --type spike --parent EPIC-1 --title "Spike: evaluate Y"`
72+
73+
**Then**: The system loads creation hierarchy from config and validates that Spike is allowed under Epic
74+
75+
**And**: If allowed, the system creates the issue and optionally links parent
76+
77+
**Acceptance Criteria**:
78+
79+
- Hierarchy rules are read from template or backlog_config; no hardcoded hierarchy
80+
- Multiple levels (epic, feature, story, task, bug, spike, custom) are supported
81+
82+
#### Scenario: Non-interactive (scripted) add
83+
84+
**Given**: All required options are provided on the command line (e.g. --type, --title, --non-interactive)
85+
86+
**When**: The user runs `specfact backlog add --type story --title "T" --body "B" --non-interactive`
87+
88+
**Then**: The system does not prompt for missing fields; it uses provided values or fails with clear error for missing required fields
89+
90+
**And**: Validation (parent if provided, DoR if --check-dor) runs before create
91+
92+
**Acceptance Criteria**:
93+
94+
- Required fields are documented (e.g. type, title; body may be optional per provider)
95+
- Missing required fields in non-interactive mode result in clear error exit
96+
97+
### Requirement: Creation hierarchy configuration
98+
99+
The system SHALL support configurable creation hierarchy (allowed parent types per child type) via template or backlog_config so that Scrum, SAFe, Kanban, and custom hierarchies work without code changes.
100+
101+
**Rationale**: Different frameworks and orgs use different trees (e.g. Story under Feature vs Story under Epic); configuration avoids hardcoding.
102+
103+
#### Scenario: Default hierarchy from template
104+
105+
**Given**: A template (e.g. ado_scrum) is selected and does not define creation_hierarchy
106+
107+
**When**: The add command needs to validate parent type for a new item
108+
109+
**Then**: The system derives allowed parent types from existing type_mapping and dependency_rules (e.g. PARENT_CHILD) where possible
110+
111+
**And**: If derivation is not possible, a conservative default (e.g. any type or no parent) is used and documented
112+
113+
#### Scenario: Custom hierarchy in backlog_config
114+
115+
**Given**: ProjectBundle.metadata.backlog_config (or .specfact/spec.yaml backlog section) contains creation_hierarchy with entries such as story: [feature, epic], task: [story]
116+
117+
**When**: The user adds an item with --type story --parent FEAT-1
118+
119+
**Then**: The system validates that "feature" is in the allowed parent types for "story" and that FEAT-1 exists and has type Feature
120+
121+
**And**: Validation fails clearly if parent type is not allowed
122+
123+
**Acceptance Criteria**:
124+
125+
- creation_hierarchy is optional; when absent, default or derived rules apply
126+
- Validation uses both existence of parent in graph and allowed type from hierarchy

0 commit comments

Comments
 (0)