Repository navigation
Description
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:
- "A body without the marker": a test replaces
_BODY_MARKDOWNwith a parser that counts each call, callssplit_recordon a body with no marker, and the counter reads 0. - "A paragraph parse": the body parse builds no inline tokens.
- "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,childrenNoneinline,children[]paragraph_close,childrenNone
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 c653bde8lists onlysrc/devops_cli/roadmap/stores/store.pyand the OpenSpec folder.git grep -n "_BODY_MARKDOWN\|_RECORD_OPENER\|disable(" origin/main -- testsfinds 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):
- Monkeypatch
store._BODY_MARKDOWNwith a wrapper that counts eachparsecall and passes the call to the real parser._record_block_spanreads the module global, so the wrapper sees each call. - A body with no
_RECORD_OPENERgives 0 calls and returns(body, {}). - 100 bodies, of which 10 hold the opener, give 10 calls.
"inline" not in store._BODY_MARKDOWN.get_active_rules()["core"], or theinlinetoken of a parse ofPlain text.haschildren == [].
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_recordreceives a body with no_RECORD_OPENER, and_BODY_MARKDOWNis a counting wrapper - THEN the parse count is 0, and
split_recordreturns(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_recordruns 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
inlinetoken in the token list haschildren == [].
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_recordmakes to the Markdown parser?: Monkeypatchstore._BODY_MARKDOWNwith a wrapper whoseparsemethod increments a counter and calls the real parser._record_block_spanreads 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_spanreadsstore._BODY_MARKDOWN, so a wrapper at that name sees every parse call. - Rejected: Monkeypatch
MarkdownIt.parseon 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.
- Chosen: Monkeypatch the module global.
- How should the test show that the
inlinecore rule is off?: ParsePlain text.and assert that theinlinetoken haschildren == []. 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
inlinetoken children. It checks the token shape that the scenario describes and fails when the rule is on. - Rejected: Assert
inlineis absent fromget_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.
- Chosen: Assert the
- 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
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
testprefix of the title gives the type.(roadmap)scope of the title gives the scope.The code works but lacks regression protection for a measured performance fix.Prevents silent loss of a measured 39-second speed-up.A few monkeypatched test functions with no new dependencies.Both concern split_record in the roadmap store, but #4445 delivers the performance change and the candidate adds tests that lock it in.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at 2f6114f (see proposed design in issue body).
Moved to new items: #4502.