Skip to content

feat(roadmap): stage keeps the plan size of an item after close #4815

Open

Description

@dan-petty

Problem or Motivation

A closed job record loses the plan size. When the item was filed, 138 closed records held the key stage.pr, and only 1 held a value. The stage job no longer writes stage.groups: since #6197 the task groups are in the plan-state comment of the plan pull request (src/devops_cli/roadmap/stage/plan_state.py), and in no record key. devops_cli_roadmap_stage_total has no size label. Thus the pass rate by plan size needs the OpenSpec folders, and the split thresholds child of #4780 cannot read it from the job records.

Proposed Solution & Architectural Design

  • Add the record key stage.size: the numbered groups (## N. headings), the tasks, the requirements and the planned paths. Stage writes it with the plan, and it stays after the close.
  • Add the bounded label size_bucket (s: 1, m: 2, l: 3-4, xl: 5 or more numbered groups) and the type label to devops_cli_roadmap_stage_total, and to the implement job and failure counters.

Target Subsystem

SDLC, Git & PR Governance (src/devops_cli/roadmap/stage/), with telemetry.

Existing Tool Considered

markdown-it-py counts the headings, and OpenTelemetry carries the label. Cost to build: about 50,000 tokens and 1.5 hours.

Acceptance Criteria

  • A closed item keeps stage.size.
  • A test counts only ## N. headings. A "Criteria" heading does not count.
  • The new labels add 4 x 7 series or fewer to each counter.

Dependencies

None.

Source: #4780

Alternatives check of 2026-11-26: in-use.
The repository already uses this tool.
Tool: markdown-it-py (https://pypi.org/project/markdown-it-py), MIT License, last activity 2026-11-10, maintained.
Reason: Searches and the repository facts confirm markdown-it-py, which the issue names as already used, parses the plan into heading and fence tokens so numbered ## N. groups can be counted; it does not write the record key, the buckets or the counter labels.

Covers:

  • Tokenizes level-2 headings with their text
  • Keeps headings inside fenced code out of the parse
  • Yields task and requirement text from the same parse

Lacks:

  • No stage.size record key or retention after close
  • No s, m, l, xl or none bucket classification
  • No Prometheus labels, item_class or zero-series priming
  • No count of planned paths

Proposed design

Problem statement

A closed job record loses the plan size, and the stage counter has no size or type label. The pass rate by plan size must read OpenSpec folders, and the split thresholds cannot read job records. Add a stage.size record key that survives close and add bounded size_bucket and item_class labels to the stage and implement counters.

Acceptance criteria

Requirement: stage-size-key

The values of StageRecordKey SHALL include the key stage.size.

Scenario: the stage record key set

  • WHEN a test lists the values of StageRecordKey
  • THEN the list holds stage.size

Requirement: stage-size-record-key

The stage job SHALL write the record key stage.size to the job record of an item when it writes the plan of the item.

Scenario: record written with the plan

  • WHEN the stage job stages an item whose plan holds 3 numbered groups, 9 checkbox tasks, 4 requirement headings and 12 distinct planned paths
  • THEN the job record holds stage.size with groups 3, tasks 9, requirements 4 and paths 12

Requirement: stage-size-survives-close

The removal of the staged branch of a closed item SHALL keep the stage.size value of its job record.

Scenario: closed item keeps its size

  • WHEN an item whose job record holds stage.size closes and the stage row removes its staged branch
  • THEN a read of the job record returns the same stage.size values

Requirement: numbered-group-count

The size count SHALL count only the level-2 headings whose text is a number, a full stop, a space and a title.

Scenario: a plain heading does not count

  • WHEN the plan holds the headings ## 1. First, ## 2. Second and ## Criteria
  • THEN the count of numbered groups is 2

Requirement: fenced-heading-not-counted

The size count SHALL ignore a numbered heading inside a fenced code block.

Scenario: a heading in a fence does not count

  • WHEN the plan holds the heading ## 1. First and a fenced block with the line ## 2. Example
  • THEN the count of numbered groups is 1

Requirement: size-bucket-values

The size_bucket label SHALL be s for 1 group, m for 2 groups, l for 3 or 4 groups and xl for 5 or more groups.

Scenario: four numbered groups

  • WHEN a plan holds 4 numbered groups
  • THEN the size_bucket label is l

Requirement: size-bucket-none

An item with no plan SHALL count with the size_bucket value none.

Scenario: an item skipped before its plan

  • WHEN a stage round skips an item before it writes a plan
  • THEN devops_cli_roadmap_stage_total counts the item with result="skipped" and size_bucket="none"

Requirement: stage-counter-labels

devops_cli_roadmap_stage_total SHALL carry the size_bucket and item_class labels.

Scenario: a staged item of type feat

  • WHEN a stage round stages a feat item whose plan holds 2 numbered groups
  • THEN the counter adds 1 with result="staged", size_bucket="m" and item_class="feat"

Requirement: item-class-values

The item_class label SHALL be the Conventional Commit type of the item title, or chore when the title has no listed type.

Scenario: an item with no listed type

  • WHEN a stage round counts an item whose title is security(ssh): verify host keys
  • THEN the counter counts the item with item_class="chore"

Requirement: bounded-label-series

The two new labels SHALL add at most 55 label pairs to a counter.

Scenario: the label value sets

  • WHEN a test lists the size_bucket and item_class values that the code emits
  • THEN the list holds at most 5 size_bucket values and at most 11 item_class values, the values of CONST_BRANCH_TYPES

Requirement: implement-jobs-counter-label

devops_cli_service_implement_jobs_total SHALL carry the size_bucket label beside its repo, item_class and result labels.

Scenario: a successful implement Job

  • WHEN the Service reports a succeeded Job of a fix item whose job record holds stage.size with 5 numbered groups
  • THEN the counter adds 1 with result="succeeded", item_class="fix" and size_bucket="xl"

Requirement: implement-failures-counter-labels

devops_cli_service_implement_failures_total SHALL carry the size_bucket and item_class labels beside its class and repo labels.

Scenario: a stopped implement Job

  • WHEN the Service reports a Job of a fix item whose job record holds stage.size with 2 numbered groups and that left the class test
  • THEN the counter adds 1 with class="test", item_class="fix" and size_bucket="m"

Requirement: implement-counter-none

The Service SHALL count an implement Job whose item has no stage.size with the size_bucket value none.

Scenario: an item with no stage size

  • WHEN the Service reports a succeeded Job of an item whose job record holds no stage.size
  • THEN devops_cli_service_implement_jobs_total adds 1 with result="succeeded" and size_bucket="none"

Requirement: implement-counter-priming

The Service SHALL create a zero series for each combination of the new size_bucket and item_class values of the implement job and failure counters when it starts.

Scenario: the Service starts

  • WHEN the Service starts with one repository
  • THEN prime_service_counters creates a zero series for each of the 5 x 11 combinations of both counters

Requirement: telemetry-doc-labels

docs/TELEMETRY.md SHALL list the size_bucket and item_class labels of devops_cli_roadmap_stage_total, devops_cli_service_implement_jobs_total and devops_cli_service_implement_failures_total.

Scenario: the telemetry table

  • WHEN a test reads the rows of the three counters in docs/TELEMETRY.md
  • THEN each row names size_bucket and item_class

Requirement: workflow-doc-key

docs/ROADMAP_WORKFLOW.md SHALL name the record key stage.size in its table of the stage keys.

Scenario: the workflow document invariant test

  • WHEN the test collects the code spans of docs/ROADMAP_WORKFLOW.md and the keys of StageRecordKey
  • THEN the code span stage.size is present

Existing Tool Considered

The alternatives check in the issue body gives markdown-it-py the verdict in-use and lists what it covers and lacks. The proposal uses its parser for the numbered group count. It builds the stage.size key, retention after close, bucket values, labels, series bound and path count itself. The written cost is about 50,000 tokens and 1.5 hours.

Key questions

  • Does the stage job still write stage.groups?: No. Since fix(roadmap): One plan-state comment for each plan PR #6197 the task groups are in the plan-state comment of the plan pull request, not in a record key. [sources: src/devops_cli/roadmap/stage/plan_state.py, src/devops_cli/roadmap/stage/stage.py]
  • Where does the stage job keep the plan size so that it survives the close?: In the hidden job record block of the issue body as stage.size. The stage job writes it with the plan, and the block stays on a closed issue. (best practice) [sources: docs/adr/0016-labels-hold-the-roadmap-items-fields.md, docs/ROADMAP_WORKFLOW.md, src/devops_cli/roadmap/stores/store.py]
    • Chosen: job record block of the issue body. The block holds stage.pr and stays on a closed issue. The new key is the record of the item.
    • Rejected: a file under the data directory of the Service. A later job reads the record of one item, and the data directory is not the record of an item.
    • Rejected: the OpenSpec change folder. The folder exists only for a staged item, and the split thresholds need the value from the record.
  • Which code clears the keys of a closed item's plan, and how does stage.size survive it?: _remove_staged clears the keys of STAGE_REMOVAL_KEYS when it closes the draft and deletes the branch. Do not add stage.size to STAGE_PLAN_KEYS or STAGE_REMOVAL_KEYS, so the removal and the rejection keep it. The next plan overwrites it. (best practice) [sources: src/devops_cli/roadmap/stage/stage.py, src/devops_cli/roadmap/stores/store.py]
    • Chosen: exclude stage.size from STAGE_PLAN_KEYS and STAGE_REMOVAL_KEYS. The removal and the rejection keep it, and a new plan overwrites it.
    • Rejected: add stage.size to STAGE_LEDGER_KEYS. The ledger holds the failures and the evictions, so a size in it would be cleared with a publish.
    • Rejected: keep stage.size in STAGE_PLAN_KEYS and clear it on removal. The closed record would lose the value, which is the defect the issue fixes.
  • How does the job count the numbered groups of a plan?: It reuses parse_task_groups in step_files.py. The parser reads the plan with markdown-it-py and keeps only a top-level ## heading whose text is <n>. <title>. [sources: src/devops_cli/roadmap/step_files.py]
  • How does the job count the tasks, the requirements and the planned paths?: Tasks are the TaskGroup.tasks that parse_task_groups gives. Requirements are the names that read_spec gives for each specs/**/spec.md. Paths are the distinct reads and changes of the StageGroups. (best practice) [sources: src/devops_cli/roadmap/step_files.py, src/devops_cli/roadmap/stage/stage_specs.py, src/devops_cli/roadmap/stage/stage_change.py]
    • Chosen: reuse the three readers. Each reader exists and reads the same text that the stage job writes.
    • Rejected: parse the rendered change text again. A second parser would disagree with the readers.
    • Rejected: count only the numbered groups. The issue asks for the tasks, the requirements and the planned paths.
  • Which values does the size_bucket label take?: s for 1 group, m for 2 groups, l for 3 or 4 groups, xl for 5 or more groups, and none for an item with no plan. (best practice) [sources: src/devops_cli/roadmap/step_files.py, docs/TELEMETRY.md]
    • Chosen: s, m, l, xl and none. The stage counter also counts a skipped item, which has no numbered group.
    • Rejected: s, m, l and xl only. The stage counter counts skipped items, which have no plan.
    • Rejected: s, m, l and xl, with s for no plan. A skipped item did not plan one group, so s would report a size that no plan has.
  • Which values does the item_class label take?: The Conventional Commit type of the title, one of the 11 values of CONST_BRANCH_TYPES, or chore when the title has no listed type. (best practice) [sources: src/devops_cli/config/constants.py:801, src/devops_cli/roadmap/implement/implement_submit.py, src/devops_cli/server/counter_series.py, docs/TELEMETRY.md]
    • Chosen: the 11 CONST_BRANCH_TYPES values with chore as the default. The implement counters already use these values, so the stage and implement series join on item_class.
    • Rejected: a closed set of 7 values with other. It would collapse perf, revert, test, build and style, and the join would lose those items.
    • Rejected: the type from the branch name. An item with no plan has no branch, and the title is the one source of the type.
  • Which counters get the size_bucket and item_class labels?: devops_cli_roadmap_stage_total, devops_cli_service_implement_jobs_total and devops_cli_service_implement_failures_total. (best practice) [sources: docs/TELEMETRY.md, src/devops_cli/roadmap/stage/stage.py, src/devops_cli/roadmap/implement/implement_submit.py]
    • Chosen: the stage, implement job and failure counters. The pass rate by plan size joins the stage result to the implement result and the failure class.
    • Rejected: the stage counter only. The implement result and the failure class are not on the stage counter.
    • Rejected: all implement counters, including repair rounds and tokens. Those count cost, not an outcome, and the issue names the job and failure counters.
  • Does the body's 4 x 7 series bound hold for the two labels?: No. The project records 11 Conventional Commit types, and a skipped item needs none. The bound is 5 x 11 = 55 label pairs for each counter. (best practice) [sources: src/devops_cli/config/constants.py:801, src/devops_cli/server/counter_series.py, docs/TELEMETRY.md]
    • Chosen: 5 x 11 = 55 label pairs. The join keeps every type, and a skipped item has no plan.
    • Rejected: 4 x 7 = 28 label pairs with other. It collapses perf, revert, test, build and style, and a skipped item has no plan.
    • Rejected: 4 x 11 = 44 label pairs without none. A skipped item has no plan, and the stage counter counts it.
  • Where does the Service read the size for the implement counters?: From the stage.size of the item's job record in _emit_implement_metrics. It uses none when the record holds no stage.size. (best practice) [sources: src/devops_cli/roadmap/implement/implement_submit.py, src/devops_cli/roadmap/stores/store.py, docs/ROADMAP_WORKFLOW.md]
    • Chosen: read stage.size from the record. The record keeps the size after the close, and the Service already holds the item when it reports the Job.
    • Rejected: read the OpenSpec change folder. A closed item's change may be archived, and the issue asks the record to hold the size.
    • Rejected: recount stage.groups. stage.groups is no longer a record key since fix(roadmap): One plan-state comment for each plan PR #6197.
  • Does the Service create the new label sets at zero?: Yes. prime_service_counters lists the label sets of the implement counters, and the Service starts each bounded label set at zero. [sources: docs/TELEMETRY.md, src/devops_cli/server/counter_series.py]
  • Does docs/ROADMAP_WORKFLOW.md need a row for stage.size?: Yes. The new record key belongs in the stage key table of docs/ROADMAP_WORKFLOW.md, and AGENTS.md rule 8 requires the same pull request to fix a document that the change makes wrong. [sources: AGENTS.md, docs/ROADMAP_WORKFLOW.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It enables a useful metric but does not fix a broken or blocking behaviour.
    • Value: Medium. It lets the team read pass rate by plan size from job records without external folders.
    • Effort: Low. The body estimates about 50,000 tokens and 1.5 hours of work.
    • Related: fix(roadmap): the plan group size measure differs between the stage and the Job #3265, which asks for a different change. Both deal with plan group size in the stage, but #3265 fixes a measurement inconsistency while the candidate adds a persistent size record and metric labels.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: Searches found no tool that keeps a plan size on a closed job record or labels the project's counters; the only fitting piece is a Markdown parser, and markdown-it-py (the tool the issue itself considered) turns a plan into heading tokens whose level and text let a test count exactly the ## N. groups and ignore other headings. It covers that counting step only, so the persistent stage.size key and the size_bucket/type metric labels still have to be built in the project.

    The repository already uses this tool.

    Tool: markdown-it-py (https://pypi.org/project/markdown-it-py)

    • License: MIT License
    • Last activity: 2026-11-10
    • Maintained: yes

    Covers:

    • Parses Markdown into tokens, including heading_open and inline tokens, so a test can count numbered group headings
    • Gives the heading level, so only ## N. headings count and a plain "Criteria" heading does not
    • Gives the heading text, so the N. numbering of each group can be checked
    • Actively maintained Markdown parser with a permissive licence

    Lacks:

    • Does not write or keep a stage.size record key on the job record after close
    • Does not add a size_bucket or type label to devops_cli_roadmap_stage_total or the implement job and failure counters
    • Does not bound the label series or map group counts to the s/m/l/xl buckets
    • Does not extract the tasks, requirements and planned paths of the plan

    Tools considered:

    Searches run:

    • python markdown AST count headings library maintained, results: 5
    • markdown-it-py parse headings python library, results: 5
    • markdown-it-py pypi, results: 5
    • "markdown-it-py" MarkdownIt parse tokens heading_open, results: 5
    • python library extract markdown section headings token stream mdit-py-plugins, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  6. added
    status/ready
    and removed
    status/new
    on Nov 15, 2026
  7. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at e5dfddb (see proposed design in issue body).

  8. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    Frozen on 2026-11-20. The stage, implement and fix-checks jobs grade under 60%, so the owner rule asks for a re-architecture before more fixes inside the current design (tracker #6519). This item is incremental work on those jobs, so its Dependencies section now names #6521 first. Stage and implement leave this item while #6521 is open. When the experiments of #6519 decide, a person closes #6521 (this item can then continue) or closes this item as not planned.

  9. added
    status/new
    and removed
    status/ready
    on Nov 26, 2026
  10. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.

  11. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  12. added
    status/ready
    and removed
    status/new
    on Dec 1, 2026
  13. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/roadmapsource/agentstatus/readytype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions