Skip to content

test(roadmap): count the record parses of split_record #4470

Closed

Description

@dan-petty

Problem or Motivation

PR #4455 (merge commit c653bde) closed #4445. It changed split_record in src/devops_cli/roadmap/stores/store.py in two ways: a body that does not hold _RECORD_OPENER returns (body, {}) with no parse, and _BODY_MARKDOWN turns off the core rule inline. The PR added no test. No test fails if a later change removes the early return or turns the inline rule on again, so CI stays green when the speed-up goes away.

The refine section of #4445 sets six acceptance criteria. The PR gives no test for three of them:

  1. "A body without the marker": a test replaces _BODY_MARKDOWN with a parser that counts each call, calls split_record on a body with no marker, and the counter reads 0.
  2. "A paragraph parse": the body parse builds no inline tokens.
  3. "A batch of mixed bodies": 100 bodies, of which 10 hold the marker, give 10 parse calls.

The archived plan (openspec/changes/archive/2026-11-11-4445-parse-only-the-bodies-that-hold/tasks.md) uses kind: other and a run of the existing tests. It does not say why these criteria are not delivered.

The scenario text of criterion 2 is also wrong. With markdown-it-py 4.2.0 (uv.lock), MarkdownIt("commonmark").disable("inline").parse("Plain text.") gives these tokens:

  • paragraph_open, children None
  • inline, children []
  • paragraph_close, children None

With the inline rule on, the inline token has children [Token(type='text', ...)]. The first token is paragraph_open, not paragraph, and its children is None with the rule on or off. So the scenario as written cannot tell the two parsers apart.

Evidence:

  • git show --stat c653bde8 lists only src/devops_cli/roadmap/stores/store.py and the OpenSpec folder.
  • git grep -n "_BODY_MARKDOWN\|_RECORD_OPENER\|disable(" origin/main -- tests finds nothing.
  • MarkdownIt("commonmark").disable("inline").get_active_rules()["core"] is ['normalize', 'block', 'text_join'].

Proposed Solution & Architectural Design

Add tests in tests/roadmap/stores/ (the module that tests store.py):

  1. Monkeypatch store._BODY_MARKDOWN with a wrapper that counts each parse call and passes the call to the real parser. _record_block_span reads the module global, so the wrapper sees each call.
  2. A body with no _RECORD_OPENER gives 0 calls and returns (body, {}).
  3. 100 bodies, of which 10 hold the opener, give 10 calls.
  4. "inline" not in store._BODY_MARKDOWN.get_active_rules()["core"], or the inline token of a parse of Plain text. has children == [].

Correct the scenario text of criterion 2 in #4445 to the real token shape: the inline token has empty children.

Each test must fail on 7c59565, the parent of c653bde. Cite the run of devops ci fail-to-pass --base 7c595656.

Target Subsystem

roadmap

Existing Tool Considered

pytest monkeypatch and the public MarkdownIt.get_active_rules() API of markdown-it-py cover the need. The change adds no library and no product code. Cost: about 10,000 tokens to build, about 500 tokens a year to keep, and about 30 minutes of elapsed time.

Source: #4455

Proposed design

Problem statement

PR #4455 made split_record skip bodies without _RECORD_OPENER and turned off the inline core rule. It added no test. CI cannot catch a later change that removes the early return or turns the rule on again. This item adds tests that count parse calls and check the token shape.

Acceptance criteria

Requirement: No-marker body skips parse

A body that does not hold _RECORD_OPENER SHALL return the body and an empty record with no call to the Markdown parser.

Scenario: Body without record opener

  • WHEN split_record receives a body with no _RECORD_OPENER, and _BODY_MARKDOWN is a counting wrapper
  • THEN the parse count is 0, and split_record returns (body, {}).

Requirement: Mixed batch parses only marked bodies

A batch of 100 bodies with 10 record openers SHALL cause exactly 10 calls to the Markdown parser.

Scenario: Batch of mixed bodies

  • WHEN split_record runs on 100 bodies, and 10 of them hold _RECORD_OPENER
  • THEN the parse count is 10.

Requirement: Body parse builds no inline tokens

The body parser SHALL leave the children list of the inline token empty.

Scenario: Plain text parse

  • WHEN the store parser parses the text Plain text.
  • THEN the inline token in the token list has children == [].

Requirement: New tests fail on the parent commit

Each new test SHALL fail at commit 7c59565 and pass at the change head.

Scenario: Fail-to-pass run

  • WHEN the pull request runs devops ci fail-to-pass --base 7c595656
  • THEN the run reports each new test as failing on the base and passing on the head.

Existing Tool Considered

No alternatives check has run. pytest monkeypatch and the public MarkdownIt.parse and MarkdownIt.get_active_rules APIs of markdown-it-py cover the need. They lack nothing for this test-only change. The change adds no library and no product code. Cost: about 10,000 tokens to build, about 500 tokens a year to keep, and about 30 minutes of elapsed time.

Key questions

  • How should the test count the calls that split_record makes to the Markdown parser?: Monkeypatch store._BODY_MARKDOWN with a wrapper whose parse method increments a counter and calls the real parser. _record_block_span reads the module global, so the wrapper sees every call. (best practice) [sources: src/devops_cli/roadmap/stores/store.py]
    • Chosen: Monkeypatch the module global. _record_block_span reads store._BODY_MARKDOWN, so a wrapper at that name sees every parse call.
    • Rejected: Monkeypatch MarkdownIt.parse on the class. It changes every parser in the test process and hides the module global that the code reads.
    • Rejected: Mock _record_block_span. It replaces the code under test and does not count real parser calls.
  • How should the test show that the inline core rule is off?: Parse Plain text. and assert that the inline token has children == []. This checks the parse result that the criterion describes and fails on 7c59565. (best practice) [sources: src/devops_cli/roadmap/stores/store.py, uv.lock]
    • Chosen: Assert the inline token children. It checks the token shape that the scenario describes and fails when the rule is on.
    • Rejected: Assert inline is absent from get_active_rules()['core']. It checks configuration, not the tokens that the parser builds.
    • Rejected: Assert both. It adds a second check of the same setting and couples the test to the rule list.
  • Where should the corrected scenario text for perf(roadmap): parse only the bodies that hold a job record #4445 go?: File a separate docs issue for the correction. perf(roadmap): parse only the bodies that hold a job record #4445 is closed, and this test item cannot edit another issue. The new tests record the correct token shape. (best practice) [sources: openspec/changes/archive/2026-11-11-4445-parse-only-the-bodies-that-hold/tasks.md, src/devops_cli/roadmap/stores/store.py]
    • Chosen: File a separate docs issue. A closed issue needs a person's edit, and this item is a test-only pull request.
    • Rejected: Rewrite the archived change in this pull request. The archive is the historical record of perf(roadmap): parse only the bodies that hold a job record #4445, not test code.
    • Rejected: Leave the wrong text. The wrong scenario keeps misleading readers about the token shape.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/test
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  2. 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/test. The test prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The code works but lacks regression protection for a measured performance fix.
    • Value: Medium. Prevents silent loss of a measured 39-second speed-up.
    • Effort: Low. A few monkeypatched test functions with no new dependencies.
    • Related: perf(roadmap): parse only the bodies that hold a job record #4445, which asks for a different change. Both concern split_record in the roadmap store, but #4445 delivers the performance change and the candidate adds tests that lock it in.
  3. added
    priority/p2-medium
    on Nov 11, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

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

    Moved to new items: #4502.

  6. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 11, 2026
  7. removed
    status/in-review
    owner/agent
    on Nov 11, 2026
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/agenttype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions