Skip to content
2 changes: 1 addition & 1 deletion docs/ROADMAP_WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ A pushed branch holds the item: the stage selection leaves it out while `origin`

The stage selection leaves out the item while a recorded blocker is open. Refine waits in the same way, until each recorded blocker closes. A closed item and an archived change create no dependency. The stage job also reads a CI job-time limit that the item body states, such as `Tests & Coverage` under 300 s, compares it with the mean of the check's last 20 runs, and returns the item to New with the evidence when the mean is over the limit (#4026). The stage check refuses a plan that creates a path that another open plan also creates. The problem names that item and that path. The plan context lists matching registry and ratchet places that the item cites, with their `path:line`. The stage check refuses a plan that adds a counted item and names no task for the declared path. The stage check refuses a plan that changes a YAML manifest under `k8s/` and leaves out a test file that references the manifest (#3972). A test file references a manifest when it holds the file name of the manifest and the name of its folder, because the test builds the path from those parts. The `paths` gate names each test that the plan leaves out, and the group that changes the manifest lists the test in its `Changes:` line. The stage check also refuses a plan whose behavior group changes an existing module under `src/` and names no existing test of that module (#3414). A test file is a test of a module when it imports the module, or a package whose `__init__.py` imports it, or another module that the plan changes and that imports it (#4467). A test file that holds the name of the module in a string or a path is no test of it. A test file that the plan creates is no existing test. The `paths` gate names the group, the module and the test that the group leaves out, for each such module of the group in one refusal (#5068), so that one repair adds every test. The stage check also refuses a plan whose task adds a parameter, an argument or a keyword to a function and that leaves out a file under `src/` that calls the function (#3307). The check reads a task clause that says parameter, argument or keyword (#4467), or whose added part is one code span in parameter shape, such as `known` or `sampling: CallSampling | None = None` (#4529). A decorator, an option and a constant in capitals are no parameter. `ast` finds the calls, so a class, a longer name and a string are no call (#4467). The stage check also refuses a task group that lists more than 5 paths in `changes`, unless the group is a prefix move whose `changes` holds only the old modules of one prefix move and the modules that the group creates (#3995). Split a larger task group into smaller task groups. The stage check also refuses a plan when a decision, a rejected alternative or a feasibility line that names an internal class in a code span gives no other code span that holds text of that class at the staged commit, and a class that declares no base is read too (#3407). The stage check also refuses a feasibility line that names an earlier reply or that corrects the model, as the line `The earlier reply was wrong` does (#4111). The gate `meta-text` reads the phrases `earlier reply`, `previous reply`, `prior reply`, `this reply`, `the reply above`, `earlier answer`, `previous turn`, `I was wrong`, `I was mistaken`, `I apologize`, `let me correct` and `my earlier`. A fenced code block and a block quotation hold evidence, so the check skips their lines, and it skips the text of an inline code span. The problem names the number of the line and the phrase, and one reply lists every refused line.

The labels on the issue hold the state. The job record holds the facts behind it. The job record is a hidden block at the end of the issue body, a JSON object ([ADR 0016](adr/0016-labels-hold-the-roadmap-items-fields.md)). It also holds the last value that a job set for each field (`Status`, `Owner`), so a job can tell its own label from a person's.
The labels on the issue hold the state. The job record holds the facts behind it. The job record is a hidden block at the end of the issue body, a JSON object ([ADR 0016](adr/0016-labels-hold-the-roadmap-items-fields.md)). A body can end in a code fence or an HTML block, such as a comment or `<pre>`, that it does not close. A write of the record then adds the close on a line of its own. Thus the record stays hidden, and the next read finds it (#6729). The job record also holds the last value that a job set for each field (`Status`, `Owner`). Thus a job can tell its own label from a person's.

| State | Label | Set by | Record keys that hold the facts |
| :--- | :--- | :--- | :--- |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-11-22
skip_specs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Design

## Decisions

- **Close the open block on write, in `with_record`.**: Each adapter writes the record through `with_record`: the GitHub store in `_edit_issue`, the in-memory store in `write_issue_body` and `_relabel`, and intake in the body of a new issue. One change in `with_record` therefore covers each writer. A record inside an open fence shows as code on GitHub, so a reader that finds a record inside an open block does not fix the defect.
- **Use `close_open_block` of `body_hash.py`.**: #6627 added it for the job block markers, and its probe is a one-line comment after a blank line, as the record block is. A second parser could disagree with it on an edge case.
- **Import `close_open_block` inside `closed_body`.**: `body_hash.py` imports `Item` and `RefineRecordKey` from `store.py`, so an import at the top of `store.py` makes a cycle. The import invariant accepts an import inside a function (#848), and `get_roadmap_store` uses the same form for `github_store`.
- **Take one line break at the end off the body before the close.**: `close_open_block` puts its close after a line break. A body that ends in a line break then gets an empty line in its code. Without that one line break, markdown-it-py renders the body that a read gives back as it renders the body alone, which keeps the rendered form that #6729 asks for.
- **Keep the body as it is when no block is open.**: The acceptance of #6729 asks for the same text as before. On 2026-11-22, 834 of the 836 open issues held a record block, and the new `with_record` wrote each of the 836 bodies with the same text as the code of origin/main.
- **Compare the read-back of the GitHub store with the body that it wrote.**: `_edit_issue` compared the read-back body with the body before the close, so it counted the close as an edit of a person in `devops_cli_roadmap_record_lost_edit_total`. The body that `split_record` gives for the written text is `closed_body` of the body, which is the body that the write keeps. The first check compares the body of the Item with the body before the write. An earlier write from the same read can add the close, so that check also accepts `closed_body` of the body of the Item.
- **Accept one more round of a job on a body that ends in an open block.**: Refine and alternatives record the hash of the body that they read, and the close changes that text one time. The next round records the new hash, and the second write keeps the body, so no round after it sees a change. A test runs four rounds against each adapter.

## Rejected alternatives

- **Read the record from inside an open block.**: In a fence, GitHub shows the record text as code, and a person who closes the block later moves the record into the middle of the body.
- **Close the open block when the store reads the body.**: The read would give a body that GitHub does not hold, so the lost-edit check of the GitHub store would see a change on each write. The read would also parse each body that holds no record, which #4445 removed.
- **Move `close_open_block` to a module that `store.py` can import at the top.**: #6736 changes `body_hash.py` at the same time. A move in this change makes the two pull requests conflict. The import inside the function has no cost after the first call.
- **Record the hash of the closed body in refine and alternatives.**: The change would touch the writers of #6736 and saves one round on a rare body. On 2026-11-22, no body of the 836 open issues ended in an open block.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Proposal

## Why

`with_record` writes the job record block as a comment after the body, and `split_record` reads it only when CommonMark parses it as the last block of the body (#2630). The body can end inside a fenced code block or an HTML block, such as a comment or `<pre>`, that it does not close. Then the record comment becomes part of that block (#6729). So the read gives an empty record and a body that holds the old block. In a fence, GitHub shows the record text as code. Each later write adds one more record to the body. The GitHub store also reads no mark back, so it writes two more times and raises `RoadmapRecordMarkLostError`.

## What Changes

- `with_record` closes a fenced code block or an HTML block that the body leaves open at its end, with `close_open_block` of `src/devops_cli/roadmap/body_hash.py` (#6627), before it adds the record block. The new function `closed_body` of `store.py` gives the body with the close. The close takes the place of one line break at the end of the body, so the code of the block gets no new empty line.
- A body that leaves no block open is written with the same text as before.
- `split_record` gives back the body with the close. The docstrings of `with_record` and `split_record` say this.
- `_edit_issue` of the GitHub store compares the body that it reads back with `closed_body` of the body that it wrote. Its first check also accepts `closed_body` of the body of the Item, because an earlier write from the same read can add the close. Thus the close is no edit of a person, and `devops_cli_roadmap_record_lost_edit_total` does not count it.
- `docs/ROADMAP_WORKFLOW.md` says that a record write closes an open block.
- The spec delta adds one requirement to `roadmap-item-labels`, because the body that a read gives and the record that a write keeps are observable.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-item-labels`: A record write closes the block that the body leaves open

## Impact

- Code: `src/devops_cli/roadmap/stores/store.py`, `src/devops_cli/roadmap/stores/github_store.py`
- Documents: `docs/ROADMAP_WORKFLOW.md`
- Tests: `tests/roadmap/stores/test_roadmap_store_record_block.py`, `tests/roadmap/stores/test_roadmap_store_contract.py`, `tests/roadmap/stores/test_roadmap_github_store_record_writes.py`
- A body that ends in an open block gets one close line at its first record write. The body hash of that body changes one time, so refine or alternatives can run one more round on it. The next write keeps the body.

## Feasibility

- A scratch script on origin/main `a3e30286e` (2026-11-22) writes a record with `with_record` and reads it with `split_record`. A closed fence gives the record back. An open backtick fence, an open tilde fence, an open `<!--` and an open `<pre>` each give `{}`, and a second write makes the body longer.
- `close_open_block` (`src/devops_cli/roadmap/body_hash.py`) parses the text and a probe comment after a blank line with markdown-it-py, and adds the close of the open fence or of the HTML block of CommonMark kinds 1 to 5. The record block is a one-line comment after a blank line, as the probe is, so the same parse decides both.
- `body_hash.py` imports `Item` and `RefineRecordKey` from `store.py`, so `store.py` imports `close_open_block` inside `closed_body`. The invariant of `tests/invariants/test_architectural_invariants.py` accepts an import inside a function (#848), and `get_roadmap_store` already imports `github_store` that way.
- A CommonMark render with markdown-it-py gives the same HTML for a fence that the body leaves open at the end and for the closed fence, when the close takes the place of one line break at the end.

## Existing Tool Considered

markdown-it-py parses the body, and the change uses it through `close_open_block` of #6627. No tool adds a record block to a Markdown body or reads one back. The change builds no parser: about 50 changed lines of source, about 40k tokens and about 2 hours. It deletes no code.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## ADDED Requirements

### Requirement: A record write closes the block that the body leaves open
A body can end inside a fenced code block, or an HTML block that only an end text ends, such as a comment or `<pre>`. Then the store SHALL put the close of that block on a line of its own before the record block. The record block SHALL stay the last block of the body. The close SHALL add no empty line to the block. A body with no open block SHALL get no close. The close SHALL count as no edit of a person.

#### Scenario: A body ends in an open block
- **WHEN** a job writes a mark to an issue whose body ends in an open backtick fence, an open tilde fence, an open `<!--` or an open `<pre>`
- **THEN** the store reads the mark back, and the body that it gives is the body with the close of the block on a line of its own after it

#### Scenario: A body with no open block
- **WHEN** the store writes a record block after a body that leaves no block open
- **THEN** the text that it writes is the body, a blank line and the record block, as before

#### Scenario: The next rounds see no change
- **WHEN** a job writes the hash of the body after each round in which the hash differs from the recorded hash, four rounds in a row, on a body that ends in an open fence
- **THEN** only the first two rounds see a change, and the body holds one record block

#### Scenario: The GitHub store counts no lost edit for the close
- **WHEN** the GitHub store writes two marks from one read of the item to a body that ends in an open fence
- **THEN** it sends one `PATCH` for each mark, the record holds both marks, and `devops_cli_roadmap_record_lost_edit_total` does not change
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Tasks

## 1. Close an open block before the record block

Kind: behavior. Reads: `src/devops_cli/roadmap/body_hash.py`, `tests/support/fakes/roadmap_store.py`. Changes: `src/devops_cli/roadmap/stores/store.py`, `tests/roadmap/stores/test_roadmap_store_record_block.py`, `tests/roadmap/stores/test_roadmap_store_contract.py`.

- [x] 1.1 Write `tests/roadmap/stores/test_roadmap_store_record_block.py`: an open backtick fence, an open tilde fence, an open `<!--` and an open `<pre>` each give the record back with the close in the body; a body with no open block is written with the same text as before; a second write keeps the body and its body hashes; the code of an open fence keeps its rendered form; and a Hypothesis property over Markdown lines reads each record back. Add `test_a_body_that_leaves_a_block_open_keeps_its_record_and_settles` to the contract suite, which runs four rounds of a hash write against each adapter. Each new test but the one of a body with no open block fails on the base
- Verification: `$ uv run devops ci test tests/roadmap/stores/test_roadmap_store_record_block.py tests/roadmap/stores/test_roadmap_store_contract.py` fails on the base
- [x] 1.2 Add `closed_body` to `src/devops_cli/roadmap/stores/store.py`. It takes one line break off the end of the body, closes the open block with `close_open_block`, and keeps the body as it is when no block is open. Import `close_open_block` inside the function. `with_record` writes `closed_body` of the body before the record block. Update the docstrings of `with_record` and `split_record`
- Verification: `$ uv run devops ci test tests/roadmap/stores/test_roadmap_store_record_block.py tests/roadmap/stores/test_roadmap_store_contract.py` passes

## 2. Count no lost edit for the close

Kind: behavior. Reads: `src/devops_cli/telemetry/instruments.py`. Changes: `src/devops_cli/roadmap/stores/github_store.py`, `tests/roadmap/stores/test_roadmap_github_store_record_writes.py`.

- [x] 2.1 Write `test_the_close_of_a_block_that_the_body_leaves_open_is_no_lost_edit`: two mark writes from one read of a body that ends in an open fence send one `PATCH` each, keep both marks and count no lost edit. It fails on the base, which raises `RoadmapRecordMarkLostError`
- Verification: `$ uv run devops ci test tests/roadmap/stores/test_roadmap_github_store_record_writes.py` fails on the base
- [x] 2.2 In `_edit_issue` of `src/devops_cli/roadmap/stores/github_store.py`, compare the body that the store reads back with `closed_body` of the body that it wrote. In the first check, also accept `closed_body` of the body of the Item, because an earlier write from the same read can add the close
- Verification: `$ uv run devops ci test tests/roadmap/stores/test_roadmap_github_store_record_writes.py` passes

## 3. State the close in the roadmap document

Kind: other. Reads: `src/devops_cli/roadmap/stores/store.py`. Changes: `docs/ROADMAP_WORKFLOW.md`.

- [x] 3.1 In the job record paragraph of `docs/ROADMAP_WORKFLOW.md`, say that a record write closes a code fence or an HTML block that the body leaves open at its end
- Verification: `$ uv run devops ci docs` passes

## Workflow follow-up

- Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).
19 changes: 19 additions & 0 deletions openspec/specs/roadmap-item-labels/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,22 @@ When the label of the item that its caller read equals the derived Status, and s
#### Scenario: An equal label that someone changed since the read
- **WHEN** a caller read the item as Ready, a person then set `status/new`, and the caller writes Ready with marks and a body
- **THEN** the writer raises `RoadmapItemChangedError`, the issue holds `status/new`, and its marks and body are as they were

### Requirement: A record write closes the block that the body leaves open
A body can end inside a fenced code block, or an HTML block that only an end text ends, such as a comment or `<pre>`. Then the store SHALL put the close of that block on a line of its own before the record block. The record block SHALL stay the last block of the body. The close SHALL add no empty line to the block. A body with no open block SHALL get no close. The close SHALL count as no edit of a person.

#### Scenario: A body ends in an open block
- **WHEN** a job writes a mark to an issue whose body ends in an open backtick fence, an open tilde fence, an open `<!--` or an open `<pre>`
- **THEN** the store reads the mark back, and the body that it gives is the body with the close of the block on a line of its own after it

#### Scenario: A body with no open block
- **WHEN** the store writes a record block after a body that leaves no block open
- **THEN** the text that it writes is the body, a blank line and the record block, as before

#### Scenario: The next rounds see no change
- **WHEN** a job writes the hash of the body after each round in which the hash differs from the recorded hash, four rounds in a row, on a body that ends in an open fence
- **THEN** only the first two rounds see a change, and the body holds one record block

#### Scenario: The GitHub store counts no lost edit for the close
- **WHEN** the GitHub store writes two marks from one read of the item to a body that ends in an open fence
- **THEN** it sends one `PATCH` for each mark, the record holds both marks, and `devops_cli_roadmap_record_lost_edit_total` does not change
Loading