Repository navigation
Description
Problem
The refine sanitizer deletes each <word> as an HTML tag, also inside a code span. Requirements and commands in the refine section then lose their placeholders and values. A reader of the section sees a damaged requirement.
src/devops_cli/roadmap/refine.py:1215defines_HTML_TAG_RE.sanitize_text(refine.py:1343) runs it on the whole text atrefine.py:1363, with no check for code.- A direct call to
sanitize_textgives this result:- The span with
<section>.<option>becomes a span with.only. - The command span
devops <read command> --helpbecomesdevops --help. - The text
use <read command> herebecomesuse here.
- The span with
- Damage in refine sections of open items:
- fix(config): devops config audit-keys does not find a plaintext secret under a nested key such as service.github_app.private_key #2511:
.pairs. Its body says<section>.<option>. - docs(security): design a sandboxed read-only run tool for the planner #3242:
devops --help. - feat(roadmap): refuse a self-named or untested plan #3321 and fix(roadmap): the implement job refuses a plan that fails the plan check #3393:
openspec/changes//. - feat(roadmap): Require a move plan to cover each reference #3373:
from import. - fix(config): devops config unset --dry-run prints the credential that it would remove #2740:
devops config unset --dry-run. - feat(roadmap): a consolidation job proposes one task for open items that share a root cause or change surface, and a person applies it (
devops roadmap consolidate) #1127:--apply --confirm. - refactor(exceptions): let validators raise own errors and bound details once #1877:
ast-grep scan --rule src/. - feat(ai): Add --since, --until, and --by to cost report and roi #2193:
--sincewith no value. - fix(security): output masking reads the prose 'token: <word>' as a secret and rewrites error text #2613: the scenarios lost the mask marker of their expected output, so one expected value is now an empty string.
- fix(config): devops config audit-keys does not find a plaintext secret under a nested key such as service.github_app.private_key #2511:
The evidence is a state at the end of the window 2026-11-03T15:05Z to 2026-11-04T15:05Z. A scan of openspec/changes/*/*.md found none of these damaged spans, so this issue claims no damage in a plan.
Expected
The sanitizer keeps a code span as it is. Outside code, each < that opens a tag becomes <, so no raw tag renders and no text is lost. A comment opener stays neutralized also in code (refine.py:1365), because the record block and the markers are found in the raw text (#2478). This change does not repair a section that refine already wrote.
Acceptance criteria
- A test:
<section>.<option>in a code span survives. - A test:
<read command>in a code span survives. - A test:
<read command>outside a span renders as text, does not act as a tag, and loses no word. - A test: a text with a stray backtick, where
spans_are_codeis false and a span is not treated as code, renders no raw tag. - A test: an end marker or a comment opener is still neutralized, also in a code span (
tests/roadmap/test_roadmap_refine.py:3076). - A test: the input
A tag <<b></b>!-- rebuiltbuilds no comment opener. - The tests at
tests/roadmap/test_roadmap_refine.py:653and:3010assert the removal of a tag today. They change to the new form.
Existing tool considered
Existing project code: _replace_outside_code (refine.py:1273) is the code-aware path, and it reads the tokens of markdown-it-py, which is already in uv.lock. No new parse and no new regex for code are necessary.
Related
Proposed design
Problem statement
The refine sanitizer deletes each `` as an HTML tag, also inside a code span. Requirements and commands in a refine section then lose placeholders and values. The change makes the sanitizer code-aware: it keeps code spans, escapes < outside code, and neutralizes a comment opener also in code. It does not repair a section that refine already wrote.
Acceptance criteria
Requirement: Code span keeps section and option placeholder
The sanitizer SHALL keep the text of a code span unchanged, including each <...> placeholder.
Scenario: Section and option placeholder survives
- WHEN
sanitize_textreceives.in a code span. - THEN The result still contains
..
Requirement: Code span keeps command placeholder
The sanitizer SHALL keep an angle-bracket placeholder in a code span when the span holds a command.
Scenario: Read command placeholder survives
- WHEN
sanitize_textreceivesdevops --helpin a code span. - THEN The result still contains
devops --help.
Requirement: Outside code escapes tag opener
The sanitizer SHALL escape each < that opens a tag outside a code span to < and SHALL keep every word.
Scenario: Read command outside code renders as text
- WHEN
sanitize_textreceivesuse hereoutside a code span. - THEN The result contains
<read command, the wordsuseandhere, and no raw `` tag.
Requirement: Stray backtick does not mark code
The sanitizer SHALL escape a tag opener outside code when spans_are_code is false, even if a stray backtick is present.
Scenario: Stray backtick renders no raw tag
- WHEN
sanitize_textreceives a text with a stray backtick, andspans_are_codeis false, so the span is not code. - THEN The result contains no raw HTML tag and keeps every word of the text.
Requirement: Comment opener neutralized in code
The sanitizer SHALL neutralize a comment opener and an end marker in a code span as it does outside code.
Scenario: Code span keeps markers neutralized
- WHEN
sanitize_textreceives a code span that contains a comment opener or an end marker. - THEN The result contains no raw comment opener and no raw end marker.
Requirement: Combined brackets build no comment opener
The sanitizer SHALL prevent the input A tag <!-- rebuilt from forming a comment opener.
Scenario: Combined brackets do not form a comment opener
- WHEN
sanitize_textreceivesA tag <!-- rebuilt. - THEN The result contains no
<!--sequence.
Requirement: Existing tag-removal tests assert escaping
The tests at tests/roadmap/test_roadmap_refine.py:653 and tests/roadmap/test_roadmap_refine.py:3010 SHALL assert the escaped form instead of the removal of a tag.
Scenario: Tag-removal assertions change
- WHEN The test suite runs the two sanitizer tests.
- THEN Both tests pass and assert the escaped form with no text loss.
Existing Tool Considered
No alternatives check has run. The open, maintained library markdown-it-py is already in uv.lock, and the project code _replace_outside_code (src/devops_cli/roadmap/refine.py:1273) reads its tokens to find code spans. markdown-it-py lacks HTML escaping and comment-opener neutralization, so the change adds those two steps to the existing helper and builds no new parser.
Key questions
- Which code-aware path should
sanitize_textuse to tell a code span from text?: Reuse_replace_outside_code, which reads markdown-it-py tokens, and add the escape and neutralization steps there. Add no second regex or parser for code. (best practice) [sources: src/devops_cli/roadmap/refine.py:1273, src/devops_cli/roadmap/refine.py:1343, src/devops_cli/roadmap/refine.py:1363, uv.lock]- Chosen: Reuse
_replace_outside_codewith markdown-it-py tokens. The library is already in the lockfile and already gives code-aware token positions. - Rejected: Add a regex for code spans. A stray backtick and nested spans make a regex fragile, and the issue says no new regex for code.
- Rejected: Parse the whole text as HTML. An HTML parse loses markdown code spans and can remove text.
- Chosen: Reuse
- How should
sanitize_texttreat<outside a code span?: Escape each<that opens a tag to<and keep the tag text. Do not delete the tag or its words. (best practice) [sources: src/devops_cli/roadmap/refine.py:1215, src/devops_cli/roadmap/refine.py:1343, src/devops_cli/roadmap/refine.py:1363]- Chosen: Escape the tag opener to
<. The text stays visible and no raw tag renders. - Rejected: Delete the tag as today. Deletion removes placeholders and values from the requirement.
- Rejected: Leave the raw tag. GitHub hides or renders a raw tag, and a comment opener can hide text.
- Chosen: Escape the tag opener to
- How should
sanitize_texttreat a code span?: Keep the span content unchanged, except neutralize a comment opener and an end marker because the record block and the markers are found in raw text. (best practice) [sources: src/devops_cli/roadmap/refine.py:1365, tests/roadmap/test_roadmap_refine.py:3076]- Chosen: Keep the span and neutralize comment openers. It preserves placeholders and commands and still protects raw markers.
- Rejected: Keep the span with no neutralization. A comment opener in code hides text in the issue body.
- Rejected: Escape all angle brackets inside code. It changes the command or requirement and loses the placeholder form.
- Which existing tests change from tag removal to the new escaped form?: The tests at
tests/roadmap/test_roadmap_refine.py:653andtests/roadmap/test_roadmap_refine.py:3010change. [sources: tests/roadmap/test_roadmap_refine.py:653, tests/roadmap/test_roadmap_refine.py:3010]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 4, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(roadmap)scope of the title gives the scope.The sanitizer corrupts requirement and command text in ten open items, but the damage is cosmetic and the fix path is clear.Users read damaged requirements and commands in refine sections, which reduces trust in the tool output.The code-aware path _replace_outside_code already exists in the same file and the acceptance criteria are well scoped.Both target sanitize_text in refine.py and both involve code spans, but the candidate stops _HTML_TAG_RE from deleting angle-bracket text while #2525 stops link and reference rewrites.devops-cli-service commentedon Nov 5, 2026
Status set to Ready at f481be8 (see proposed design in issue body).
devops-cli-service commentedon Nov 6, 2026
Released in v0.64.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.64.0
devops-cli-service commentedon Nov 6, 2026
Live since 2026-11-06 02:22 UTC