Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-10-30
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Design

## Decisions

- **Store protocol defines `add_sub_issue(parent: int, child: int) -> None`**: Both arguments are issue numbers. In `GitHubRoadmapStore`, the child's REST ID is retrieved from the stored payload or fetched if not present.
- **Link sub-issue immediately after filing**: Linking happens in `_apply_placement` right after `_placement_target` files the new issue.
- **Support both full issue URLs and issue numbers in `--source`**: Extract the issue number whether `--source` is a URL to the same repository or an issue number. External URLs return None and do not link.
- **Include sub-issue write in dry-run plan**: In `intake_requests.py`, when a new candidate specifies a `--source` that names an issue in the repository, add the sub-issue write to `planned_requests`.

## Rejected Alternatives

- **Pass child REST ID in `RoadmapStore.add_sub_issue`**: Rejected because `MemoryRoadmapStore` and the CLI operate on issue numbers. The store handles REST ID translation internally.
- **Link sub-issues in a separate CLI command**: Rejected because intake already knows the parent from `--source` when filing. Manual linking is error-prone.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Proposal

## Why

Issue #2035: `devops roadmap intake --source <issue>` does not link the candidate it files as a sub-issue.

When an agent splits an issue into parts, it files each part with `devops roadmap intake --source <link>`. The new issue has no sub-issue link to its parent on GitHub. A person or an agent links each part by hand. On 2026-10-23, an agent linked 14 split parts as sub-issues one at a time. This change links the filed issue to its parent automatically at file time.

## What Changes

- Add `add_sub_issue(parent, child)` to `RoadmapStore`, `GitHubRoadmapStore`, and `MemoryRoadmapStore`.
- `GitHubRoadmapStore` implements `add_sub_issue` with `POST /repos/{owner}/{repo}/issues/{parent}/sub_issues` and the REST database ID of the child.
- `MemoryRoadmapStore` records the sub-issue relationship and updates parent and child records.
- When intake files a candidate whose `--source` links an issue of the same repository, intake adds the candidate as a sub-issue of that issue.
- The dry-run plan lists the sub-issue write as a planned write.
- Update the docstring rule in `intake.py` to name the sub-issue link write as an allowed extra write.

## Capabilities

### Modified Capabilities

- `roadmap-intake-duplicates`: adds requirement to link candidates filed from `--source` as sub-issues.

## Impact

- Code: `src/devops_cli/roadmap/store.py`, `src/devops_cli/roadmap/github_store.py`, `src/devops_cli/roadmap/memory_store.py`, `src/devops_cli/roadmap/intake.py`, `src/devops_cli/roadmap/intake_requests.py`, `src/devops_cli/roadmap/request_plan.py`, `src/devops_cli/lang/en/messages.py`.
- Tests: `tests/test_roadmap_store_contract.py`, `tests/test_roadmap_intake.py`, `tests/roadmap_github_fake.py`.
- Documentation: `docs/commands/roadmap.md` and `README.md` if options change.

## Feasibility

- GitHub REST API supports `POST /repos/{owner}/{repo}/issues/{issue_number}/sub_issues` with body `{"sub_issue_id": <id>}`.
- `POST /repos/{owner}/{repo}/issues` returns the issue with its REST ID (`id`).
- Verified against GitHub documentation and API schema on 2026-10-30.

## Existing Tool Considered

GitHub REST API provides the sub-issues endpoint `POST /repos/{owner}/{repo}/issues/{issue_number}/sub_issues`. It uses the existing GitHub REST API transport in `GitHubRoadmapStore`. No new library or external tool is needed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Spec Delta

## ADDED Requirements

### Requirement: Intake links a candidate filed from --source as a sub-issue
When intake files a candidate whose `--source` links an issue of the same repository, intake SHALL add the filed issue as a sub-issue of that issue.

#### Scenario: Candidate filed with --source linking an issue in the same repository
- **WHEN** intake files a candidate whose `--source` links an issue in the same repository
- **THEN** intake adds the filed issue as a sub-issue of that issue, and lists the write in the dry-run plan
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Tasks

## 1. Store protocol and implementations

- [x] 1.1 Add `add_sub_issue` method to `RoadmapStore` protocol and write failing contract test in `tests/test_roadmap_store_contract.py`
- [x] 1.2 Implement `add_sub_issue` in `MemoryRoadmapStore` and `GitHubRoadmapStore`
- [x] 1.3 Add sub-issues route to `tests/roadmap_github_fake.py`

## 2. Intake sub-issue linking and dry-run plan

- [x] 2.1 Add failing tests in `tests/test_roadmap_intake.py` for intake with `--source` linking sub-issues and appearing in dry-run plan
- [x] 2.2 Update `IntakeDecision`, `_apply_placement`, `plan_intake`, and `dry_run_intake` to link sub-issues and list the write in the dry-run plan
- [x] 2.3 Update module docstring in `src/devops_cli/roadmap/intake.py`

## 3. Verification and checks

- [x] 3.1 Verify OpenSpec check passes
- [x] 3.2 Verify full test suite passes
7 changes: 7 additions & 0 deletions openspec/specs/roadmap-intake-duplicates/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,10 @@ When a case's model call fails, `devops roadmap intake-eval` SHALL show that cas
#### Scenario: The dry run of the set
- **WHEN** `devops roadmap intake-eval --dry-run` runs
- **THEN** it lists the 16 cases and 16 `analysis` calls, and the model gets no call

### Requirement: Intake links a candidate filed from --source as a sub-issue
When intake files a candidate whose `--source` links an issue of the same repository, intake SHALL add the filed issue as a sub-issue of that issue.

#### Scenario: Candidate filed with --source linking an issue in the same repository
- **WHEN** intake files a candidate whose `--source` links an issue in the same repository
- **THEN** intake adds the filed issue as a sub-issue of that issue, and lists the write in the dry-run plan
5 changes: 5 additions & 0 deletions src/devops_cli/lang/en/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2482,6 +2482,7 @@ class RoadmapMessages:
"title": "<title>",
"body": "<body>",
"label": "<label>",
"sub_issue_id": "<the child's REST id>",
"node_id": "<node id>",
"original_id": "<original node id>",
"evidence": "<evidence>",
Expand Down Expand Up @@ -2526,6 +2527,7 @@ class RoadmapMessages:
"body": "the body of {subject}, its job record kept",
"comment": "comment on {subject}",
"label": "label {subject}",
"add_sub_issue": "add {subject} as a sub-issue of {parent}",
"create_issue": "open an issue for {subject}",
"close": "close {subject} with the reason {reason}",
}
Expand Down Expand Up @@ -2592,6 +2594,7 @@ class RoadmapMessages:
intake_writes: str = " - writes: {writes}"
intake_note: str = " - note: {note}"
intake_write_file: str = "file the issue with {labels}"
intake_write_sub_issue: str = "sub-issue of #{parent}"
intake_no_labels: str = "no labels"
intake_write_label: str = "label {label}"
intake_write_field: str = "{field} {value}"
Expand Down Expand Up @@ -2727,6 +2730,7 @@ class RoadmapMessages:
"evidence": "the evidence the model cites for {subject}",
"comments": "the comments on {subject}, for intake's marker",
"file": "file {subject}, with source/agent when an agent files it",
"sub_issue": "link {subject} as a sub-issue of {parent}",
"label": "label {subject} with its type/* label when it has none",
"field": (
"set {field} on {subject}: read the issue, then write its labels and its job "
Expand All @@ -2746,6 +2750,7 @@ class RoadmapMessages:
"evidence": "the model cites any",
"comments": "{subject} is placed",
"file": "no open issue with no Priority holds its title and body",
"sub_issue": "the candidate's source is an issue of the repository",
"placed": "intake places {subject}",
"field": "it has none",
"comment": "intake's is not there",
Expand Down
36 changes: 36 additions & 0 deletions src/devops_cli/roadmap/github_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def milestone(self) -> Milestone:


class _IssuePayload(BaseModel):
id: int = 0
number: int
title: str
html_url: str
Expand Down Expand Up @@ -180,6 +181,7 @@ def split(self) -> tuple[str, dict[str, Any]]:
def record(self) -> IssueRecord:
body, held = self.split()
return IssueRecord(
id=self.id,
number=self.number,
title=self.title,
url=self.html_url,
Expand Down Expand Up @@ -427,6 +429,17 @@ def create_issue_args(repo: str, title: str, body: str, labels: Sequence[str] =
return ["api", "-X", "POST", f"repos/{repo}/issues", *flags]


def add_sub_issue_args(repo: str, parent: Number, child_id: Number) -> list[str]:
return [
"api",
"-X",
"POST",
f"repos/{repo}/issues/{parent}/sub_issues",
"-F",
f"sub_issue_id={child_id}",
]


def comment_args(repo: str, number: Number, body: str) -> list[str]:
return ["api", "-X", "POST", comments_endpoint(repo, number), "-f", f"body={body}"]

Expand Down Expand Up @@ -622,6 +635,28 @@ def create_issue(self, title: str, body: str, *, labels: Sequence[str] = ()) ->
)
return self._kept(self._validate(written, _ISSUE, "issue after it was opened"))

def add_sub_issue(self, parent: int, child: int) -> None:
"""Add issue `child` as a sub-issue of issue `parent`."""
if self._all is None or parent not in self._all:
self._require_issue(parent, "roadmap.add_sub_issue")
child_id = None
if self._all is not None and child in self._all and self._all[child].id:
child_id = self._all[child].id
if child_id is None:
child_payload = self._require_issue(child, "roadmap.add_sub_issue")
child_id = child_payload.id
self._write(
add_sub_issue_args(self._repo, parent, child_id),
f"link #{child} as a sub-issue of #{parent}",
)
if self._all is not None:
if parent in self._all:
p = self._all[parent]
self._all[parent] = p.model_copy(update={"sub_issues": p.sub_issues + 1})
if child in self._all:
c = self._all[child]
self._all[child] = c.model_copy(update={"parent": parent})

def read_issue_body(self, number: int) -> str:
"""The body of issue `number`, with no record block, raising if it is not an issue of
this repository."""
Expand Down Expand Up @@ -932,6 +967,7 @@ def _failure(
"GhRunner",
"GitHubRoadmapStore",
"ListingSession",
"add_sub_issue_args",
"advisory_args",
"closures_args",
"comment_args",
Expand Down
57 changes: 46 additions & 11 deletions src/devops_cli/roadmap/intake.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,17 @@
plans the milestones. A milestone the issue already has stands.

**Writes**, in order, with Priority last, which makes the candidate an item: file the issue (a
new candidate only), add a `type/*` label when it has none, set each of Status (New), Value and
Effort that the issue holds no label for, leave one reason comment carrying
`CONST_ROADMAP_INTAKE_REASON_MARKER` unless one is there, then set Priority. Each field write
replaces the labels of its family and records the value in the issue's job record
(`RoadmapStore.set_field`). A label a person set stays, and the job record never claims it (ADR
0002); a person's change between the plan and the write stops that write.
new candidate only), link it as a sub-issue when `--source` is an issue of the repository, add a
`type/*` label when it has none, set each of Status (New), Value and Effort that the issue holds
no label for, leave one reason comment carrying `CONST_ROADMAP_INTAKE_REASON_MARKER` unless one
is there, then set Priority. Each field write replaces the labels of its family and records the
value in the issue's job record (`RoadmapStore.set_field`). A label a person set stays, and the
job record never claims it (ADR 0002); a person's change between the plan and the write stops
that write.

A run that stops part-way leaves an open issue with no Priority, a candidate, and the next run
decides it again: it writes only the fields the issue holds no label for, and no second reason
comment. Intake writes to no issue but the candidate, and closes none.
comment. Intake writes to no issue but the candidate and its parent sub-issue link, and closes none.

**Dry run, plan, confirm** (the dry-run rule of #412). `dry_run_intake` makes no request, to
GitHub or a model: it returns an `IntakePlan` marked `dry_run`, with no decision, that holds
Expand Down Expand Up @@ -317,6 +318,7 @@ class IntakeDecision:
shown: tuple[str, str, str, str] = ("", "", "", "")
notes: tuple[str, ...] = ()
reasons: tuple[tuple[str, str, str], ...] = ()
parent: int | None = None

@property
def has_writes(self) -> bool:
Expand All @@ -327,6 +329,8 @@ def writes(self) -> list[str]:
texts = MESSAGES.roadmap
filing = ", ".join(self.filing_labels) or texts.intake_no_labels
planned = [texts.intake_write_file.format(labels=filing)]
if self.parent is not None:
planned.append(texts.intake_write_sub_issue.format(parent=self.parent))
planned = planned if self.subject.number is None else []
planned += [texts.intake_write_label.format(label=label) for label in self.labels]
planned += [texts.intake_write_field.format(field=f.value, value=v) for f, v in self.fields]
Expand Down Expand Up @@ -685,15 +689,35 @@ def _comparison(run: _Run, *, agent_candidates: bool) -> list[_Entry]:
]


def source_parent_number(repo: str, source: str | None) -> int | None:
"""The issue number of `repo` that `source` names, or None when it names another
repository or is not an issue link."""
if not source:
return None
trimmed = source.strip()
if trimmed.lstrip("#").isdigit():
return int(trimmed.lstrip("#"))
parsed = urlsplit(trimmed)
if parsed.netloc and parsed.netloc != "github.com":
return None
path = parsed.path if parsed.path.startswith("/") else f"/{parsed.path}"
prefix = f"/{repo.strip('/')}/issues/"
if path.startswith(prefix):
tail = path.removeprefix(prefix)
if tail.isdigit():
return int(tail)
return None


def _source_issue(run: _Run, subject: Subject) -> int | None:
"""The issue of the repository that a new candidate's source links, such as the issue it
splits: the issue whose GitHub link is the source with no query or fragment, so a link to
one of its comments names it too (#1985)."""
source = subject.new.source if subject.new is not None else None
if not source:
parent = source_parent_number(run.repo, source)
if parent is None:
return None
link = urlsplit(source.strip())._replace(query="", fragment="").geturl()
return next((issue.number for issue in run.issues if issue.url == link), None)
return next((issue.number for issue in run.issues if issue.number == parent), None)


def _apart(run: _Run, subject: Subject) -> set[int]:
Expand Down Expand Up @@ -1119,6 +1143,7 @@ def _place(self, subject: Subject, proposal: Proposal, judgement: _Judgement) ->
if _has_comment(self.run.store, subject, CONST_ROADMAP_INTAKE_REASON_MARKER)
else _comment(placement, lines)
)
parent = _source_issue(self.run, subject) if subject.number is None else None
return IntakeDecision(
subject,
Outcome.PLACE,
Expand All @@ -1135,6 +1160,7 @@ def _place(self, subject: Subject, proposal: Proposal, judgement: _Judgement) ->
duplicate_reason=judgement.reason if judgement.possible_duplicate is not None else "",
related=judgement.related,
related_reason=judgement.reason if judgement.related is not None else "",
parent=parent,
)


Expand Down Expand Up @@ -1200,8 +1226,15 @@ def dry_run_intake(
subjects = [f"#{number}" for number in sorted(set(issues))]
else:
subjects = [MESSAGES.roadmap.intake_placeholder_each]
source_parent = source_parent_number(repo, new.source) if new is not None else None
reads, writes = planned_requests(
subjects, repo=repo, ref=ref, new=new is not None, each=each, limit=limit
subjects,
repo=repo,
ref=ref,
new=new is not None,
each=each,
limit=limit,
parent=source_parent,
)
return IntakePlan(decisions=(), limit=limit, dry_run=True, requests=reads, writes=writes)

Expand Down Expand Up @@ -1235,6 +1268,8 @@ def _apply_placement(store: RoadmapStore, decision: IntakeDecision) -> int:
if priority is None:
raise _lacks(decision, "Priority")
number, item = _placement_target(store, decision)
if decision.parent is not None:
store.add_sub_issue(decision.parent, number)
for label in decision.labels:
store.label_issue(number, label)
for item_field, value in decision.fields:
Expand Down
23 changes: 21 additions & 2 deletions src/devops_cli/roadmap/intake_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,32 @@ def decisions(self, subjects: Sequence[str], *, new: bool, repeat: str) -> list[
)
return planned

def writes(self, subjects: Sequence[str], *, new: bool, repeat: str) -> list[PlannedRequest]:
def writes(
self,
subjects: Sequence[str],
*,
new: bool,
repeat: str,
parent: int | None = None,
) -> list[PlannedRequest]:
"""The writes `--confirm` makes for each candidate it places."""
texts = MESSAGES.roadmap
planned: list[PlannedRequest] = []
for subject in subjects:
if new:
filing = self.store.create_issue(subject, (texts.plan_placeholders["label"],))
planned += self.step("file", filing, subject=subject, repeat=repeat)
if parent is not None:
sub_issue = self.store.add_sub_issue(
f"#{parent}", texts.intake_placeholder_filed
)
planned += self.step(
"sub_issue",
sub_issue,
parent=f"#{parent}",
subject=texts.intake_placeholder_filed,
repeat=repeat,
)
planned += self._placement(texts.intake_placeholder_filed if new else subject, repeat)
return planned

Expand Down Expand Up @@ -154,6 +172,7 @@ def planned_requests(
new: bool,
each: bool = False,
limit: int | None = None,
parent: int | None = None,
) -> tuple[tuple[PlannedRequest, ...], tuple[PlannedRequest, ...]]:
"""The requests a run over `subjects` makes, as reads and model calls, then the writes
`--confirm` adds after them; `new` when the one subject is a candidate that is not an issue
Expand All @@ -164,7 +183,7 @@ def planned_requests(
limited = texts.intake_repeat_limited.format(limit=limit) if limit is not None else ""
repeat = (limited or texts.intake_repeat_candidate) if each else ""
reads = steps.reads() + steps.decisions(subjects, new=new, repeat=repeat)
return tuple(reads), tuple(steps.writes(subjects, new=new, repeat=repeat))
return tuple(reads), tuple(steps.writes(subjects, new=new, repeat=repeat, parent=parent))


# ── What a run spends ─────────────────────────────────────────────────────────
Expand Down
Loading
Loading