From d29dda57484ab0572875b2b02ed53060e4f70eaf Mon Sep 17 00:00:00 2001 From: Benjamin Kapner Date: Tue, 1 Dec 2026 16:15:51 +0200 Subject: [PATCH 1/4] fix: split markdown numbered and dash acceptance criteria Recognize 1. and - list markers after Jira #/* so overflow markdown strategies keep a usable AC count. Parse NFR categories with the colon inside the bold span. Signed-off-by: Benjamin Kapner --- scripts/utils/strat_utils.py | 15 ++++++--- tests/consts/strategy_constants.py | 35 ++++++++++++++++++++- tests/unit/test_parse_strat.py | 50 +++++++++++++++++++++++++++++- 3 files changed, 93 insertions(+), 7 deletions(-) diff --git a/scripts/utils/strat_utils.py b/scripts/utils/strat_utils.py index 9c4978e..fad1044 100644 --- a/scripts/utils/strat_utils.py +++ b/scripts/utils/strat_utils.py @@ -45,8 +45,9 @@ def extract_jira_section(content: str, heading_prefix: str) -> str | None: def _extract_bulleted_texts(section: str) -> list[str]: """Split a Jira wiki section body into merged, whitespace-normalized bullet-item strings. - Handles both `#` (numbered) and `*` (plain) bullet markers, and falls back to blank-line - paragraph splitting when no bullet marker is present. + Prefers Jira markers (`#` numbered, then `*` plain) so existing STRAT fixtures stay unchanged. + Overflow markdown attachments keep `1.` / `-` after heading normalization; those are recognized + next. Falls back to blank-line paragraph splitting when no bullet marker is present. """ stripped = section.strip() @@ -54,6 +55,10 @@ def _extract_bulleted_texts(section: str) -> list[str]: bullet_marker = r"(?m)^#\s+" elif re.search(r"(?m)^\*\s+", stripped): bullet_marker = r"(?m)^\*\s+" + elif re.search(r"(?m)^\d+\.\s+", stripped): + bullet_marker = r"(?m)^\d+\.\s+" + elif re.search(r"(?m)^-\s+", stripped): + bullet_marker = r"(?m)^-\s+" else: bullet_marker = None @@ -123,7 +128,7 @@ def parse_nfr(content: str) -> dict: if section is None: return {"found": False, "requirements": []} - nfr_re = re.compile(r"^\*\s+\*([^*]+)\*:\s*(.+)") + nfr_re = re.compile(r"^\*\s+\*(?:([^*]+):\*|([^*]+)\*)\s*:?\s*(.+)") requirements = [] for raw_line in section.splitlines(): line = raw_line.strip() @@ -133,8 +138,8 @@ def parse_nfr(content: str) -> dict: if match: requirements.append( { - "category": match.group(1).strip(), - "text": match.group(2).strip(), + "category": (match.group(1) or match.group(2)).strip(), + "text": match.group(3).strip(), } ) elif requirements and not line.startswith("*"): diff --git a/tests/consts/strategy_constants.py b/tests/consts/strategy_constants.py index 3e90535..564adef 100644 --- a/tests/consts/strategy_constants.py +++ b/tests/consts/strategy_constants.py @@ -1,4 +1,4 @@ -"""Formatted strategy Markdown fixtures for the overflow-marker fetch-failure gate.""" +"""Strategy fixtures for overflow-marker fetch failures and STRAT section parsing.""" from scripts.strategy_source import OVERFLOW_MARKER @@ -28,3 +28,36 @@ The strategy has no acceptance criteria section. """ + +# Heading-normalized overflow attachments keep markdown list markers (`1.` / `-`). +# Parser input looks like this after `_normalize_strategy_headings` rewrites `###` → `h3.`. +STRAT_AC_MARKDOWN_NUMBERED = ( + "h3. Acceptance Criteria\n\n" + "1. *Attachment wins*: Given overflow When fetched Then the newest attachment is parsed\n" + "2. *Inline description*: Given a short strategy When fetched Then the body is parsed\n" + "3. *Fallback snapshot*: Given no live issue When a snapshot exists Then it is parsed\n" + "\nh3. Effort Estimate\n" +) + +STRAT_AC_MARKDOWN_DASH = ( + "h3. Acceptance Criteria\n\n" + "- Given a user opens a session, when the page loads, then a tile is visible.\n" + "- Given a user clicks the tile, when the dialog opens, then samples are shown.\n" + "- Given the dialog is open, when the user selects a filter, then results update.\n" + "\nh3. Effort Estimate\n" +) + +STRAT_AC_JIRA_HASH_WITH_MARKDOWN_NUMBERS = ( + "h3. Acceptance Criteria\n\n" + "# Given a user opens a session, when the page loads, then a tile is visible.\n" + "1. This markdown item must not split the Jira numbered list.\n" + "# Given a user clicks the tile, when the dialog opens, then samples are shown.\n" + "\nh3. Effort Estimate\n" +) + +STRAT_NFR_COLON_INSIDE_BOLD = ( + "h3. Non-Functional Requirements\n\n" + "* *Performance:* The strategy fetch completes within the request timeout\n" + "* *Security*: Auth required\n" + "\nh3. Out-of-Scope\n" +) diff --git a/tests/unit/test_parse_strat.py b/tests/unit/test_parse_strat.py index 7b93362..93d0b23 100644 --- a/tests/unit/test_parse_strat.py +++ b/tests/unit/test_parse_strat.py @@ -14,7 +14,14 @@ parse_out_of_scope, workflow_inputs, ) -from tests.consts.strategy_constants import STRATEGY_WITH_UNFETCHED_ATTACHMENT, STRATEGY_WITHOUT_AC +from tests.consts.strategy_constants import ( + STRATEGY_WITHOUT_AC, + STRATEGY_WITH_UNFETCHED_ATTACHMENT, + STRAT_AC_JIRA_HASH_WITH_MARKDOWN_NUMBERS, + STRAT_AC_MARKDOWN_DASH, + STRAT_AC_MARKDOWN_NUMBERED, + STRAT_NFR_COLON_INSIDE_BOLD, +) from tests.helpers import strat_with_testability_heading from tests.constants import ( STRAT_AC_H2_PREFIX_COLLISION, @@ -212,6 +219,38 @@ def test_star_bulleted_acs_no_blank_lines_between_entries(self): assert "Given a user submits invalid input" in result["acceptance_criteria"][1]["text"] assert "Given a duplicate name is submitted" in result["acceptance_criteria"][2]["text"] + def test_markdown_numbered_acs_are_split(self): + result = parse_acceptance_criteria(STRAT_AC_MARKDOWN_NUMBERED) + + assert result["found"] is True + assert result["count"] == 3 + assert [ac["num"] for ac in result["acceptance_criteria"]] == [1, 2, 3] + texts = [ac["text"] for ac in result["acceptance_criteria"]] + assert "Attachment wins" in texts[0] + assert "Inline description" in texts[1] + assert "Fallback snapshot" in texts[2] + assert texts[0] != texts[1] + assert "Inline description" not in texts[0] + assert gate_inputs(STRAT_AC_MARKDOWN_NUMBERED)["ac_count"] == 3 + + def test_markdown_dash_acs_are_split(self): + result = parse_acceptance_criteria(STRAT_AC_MARKDOWN_DASH) + + assert result["found"] is True + assert result["count"] == 3 + assert "opens a session" in result["acceptance_criteria"][0]["text"] + assert "clicks the tile" in result["acceptance_criteria"][1]["text"] + assert "dialog is open" in result["acceptance_criteria"][2]["text"] + + def test_jira_hash_still_wins_over_markdown_numbers(self): + result = parse_acceptance_criteria(STRAT_AC_JIRA_HASH_WITH_MARKDOWN_NUMBERS) + + assert result["found"] is True + assert result["count"] == 2 + assert "opens a session" in result["acceptance_criteria"][0]["text"] + assert "markdown item must not split" in result["acceptance_criteria"][0]["text"] + assert "clicks the tile" in result["acceptance_criteria"][1]["text"] + def test_testability_edge_cases_folded_in_with_continued_numbering(self): result = parse_acceptance_criteria(STRAT_TESTABILITY_FOLDED_INTO_AC) @@ -272,6 +311,15 @@ def test_wrapped_bullet_not_truncated(self): # A stray "*" bullet that is not a "* *Cat*: text" NFR must not be merged into Security. assert "stray bullet" not in security["text"] + def test_colon_inside_bold_category_is_kept(self): + result = parse_nfr(STRAT_NFR_COLON_INSIDE_BOLD) + + assert result["found"] is True + categories = [nfr["category"] for nfr in result["requirements"]] + assert categories == ["Performance", "Security"] + performance = result["requirements"][0] + assert performance["text"] == "The strategy fetch completes within the request timeout" + class TestGateInputs: """Tests for gate_inputs — the citation gate's deterministic ac_count + nfr_categories. From 05d73973f2f5ae736b35c483f9723286084f782b Mon Sep 17 00:00:00 2001 From: fullsend-fix <278716306+fullsend-ai-coder[bot]@users.noreply.github.com> Date: Tue, 1 Dec 2026 15:18:07 +0000 Subject: [PATCH 2/4] fix: require colon in NFR category bullets (PR #111) Require the colon inside the bold span (`*Cat:*`) or right after it (`*Cat*:`) so bare `*Note*` bullets and empty `*Security*:` bullets no longer become false NFR requirements. Add regression tests for both. Co-Authored-By: Claude Sonnet 5.5 --- scripts/utils/strat_utils.py | 2 +- tests/consts/strategy_constants.py | 14 ++++++++++++++ tests/unit/test_parse_strat.py | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/scripts/utils/strat_utils.py b/scripts/utils/strat_utils.py index fad1044..85dcae2 100644 --- a/scripts/utils/strat_utils.py +++ b/scripts/utils/strat_utils.py @@ -128,7 +128,7 @@ def parse_nfr(content: str) -> dict: if section is None: return {"found": False, "requirements": []} - nfr_re = re.compile(r"^\*\s+\*(?:([^*]+):\*|([^*]+)\*)\s*:?\s*(.+)") + nfr_re = re.compile(r"^\*\s+\*(?:([^*]+):\*|([^*]+)\*:)\s*(.+)") requirements = [] for raw_line in section.splitlines(): line = raw_line.strip() diff --git a/tests/consts/strategy_constants.py b/tests/consts/strategy_constants.py index 564adef..91ea982 100644 --- a/tests/consts/strategy_constants.py +++ b/tests/consts/strategy_constants.py @@ -61,3 +61,17 @@ "* *Security*: Auth required\n" "\nh3. Out-of-Scope\n" ) + +STRAT_NFR_BOLD_WITHOUT_COLON = ( + "h3. Non-Functional Requirements\n\n" + "* *Performance*: Responses stay under two seconds\n" + "* *Note* For discussion only\n" + "\nh3. Out-of-Scope\n" +) + +STRAT_NFR_EMPTY_CATEGORY_TEXT = ( + "h3. Non-Functional Requirements\n\n" + "* *Performance*: Responses stay under two seconds\n" + "* *Security*:\n" + "\nh3. Out-of-Scope\n" +) diff --git a/tests/unit/test_parse_strat.py b/tests/unit/test_parse_strat.py index 93d0b23..e2b0bf0 100644 --- a/tests/unit/test_parse_strat.py +++ b/tests/unit/test_parse_strat.py @@ -20,7 +20,9 @@ STRAT_AC_JIRA_HASH_WITH_MARKDOWN_NUMBERS, STRAT_AC_MARKDOWN_DASH, STRAT_AC_MARKDOWN_NUMBERED, + STRAT_NFR_BOLD_WITHOUT_COLON, STRAT_NFR_COLON_INSIDE_BOLD, + STRAT_NFR_EMPTY_CATEGORY_TEXT, ) from tests.helpers import strat_with_testability_heading from tests.constants import ( @@ -320,6 +322,19 @@ def test_colon_inside_bold_category_is_kept(self): performance = result["requirements"][0] assert performance["text"] == "The strategy fetch completes within the request timeout" + def test_bold_category_without_colon_is_not_an_nfr(self): + result = parse_nfr(STRAT_NFR_BOLD_WITHOUT_COLON) + + assert [nfr["category"] for nfr in result["requirements"]] == ["Performance"] + assert "Note" not in gate_inputs(STRAT_NFR_BOLD_WITHOUT_COLON)["nfr_categories"] + + def test_empty_category_bullet_is_not_a_requirement(self): + result = parse_nfr(STRAT_NFR_EMPTY_CATEGORY_TEXT) + + assert [nfr["category"] for nfr in result["requirements"]] == ["Performance"] + assert all(nfr["text"] != ":" for nfr in result["requirements"]) + assert "Security" not in gate_inputs(STRAT_NFR_EMPTY_CATEGORY_TEXT)["nfr_categories"] + class TestGateInputs: """Tests for gate_inputs — the citation gate's deterministic ac_count + nfr_categories. From e504c1e7e23ae17eff0dae5f8e49512ca77f46dd Mon Sep 17 00:00:00 2001 From: fullsend-fix <278716306+fullsend-ai-coder[bot]@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:41:39 +0000 Subject: [PATCH 3/4] fix: restrict markdown AC list splitting to leading, indent-aware lists (PR #111) Markdown 1./- items now split ACs only when the section's first non-blank line is a list marker; otherwise paragraph mode is kept so lead-in text is not dropped. Top-level items are matched at the first item's indent (read from the un-stripped section) so indented lists split fully and nested bullets fold into their parent. Jira # / * splitting is unchanged. Note: pre-commit could not fetch hook repos (network) and ruff/flake8 are not installed in the sandbox; full pytest suite passed and line length, whitespace and compile checks were done manually. Co-Authored-By: Claude Sonnet 5.5 --- scripts/utils/strat_utils.py | 73 ++++++++++++++++++++++++------ tests/consts/strategy_constants.py | 34 ++++++++++++++ tests/unit/test_parse_strat.py | 52 +++++++++++++++++++++ 3 files changed, 144 insertions(+), 15 deletions(-) diff --git a/scripts/utils/strat_utils.py b/scripts/utils/strat_utils.py index 85dcae2..9b87e56 100644 --- a/scripts/utils/strat_utils.py +++ b/scripts/utils/strat_utils.py @@ -15,11 +15,18 @@ _COLOR_SECTION_HEADING_RE = re.compile(r"^\{color:[^}]+\}.+\{color\}\s*$", re.IGNORECASE) -def extract_jira_section(content: str, heading_prefix: str) -> str | None: +def _trim_section(lines: list[str], keep_indent: bool) -> str: + """Join section lines; `keep_indent` drops only surrounding blank lines so the first line keeps its indent.""" + body = "\n".join(lines) + return body.strip("\r\n").rstrip() if keep_indent else body.strip() + + +def extract_jira_section(content: str, heading_prefix: str, *, keep_indent: bool = False) -> str | None: """Extract text after a Jira heading up to its next section boundary. Jira h2./h3. headings end every section. Inline bold labels also stop at the next bold, - color-marked, panel, or h2./h3. section boundary. + color-marked, panel, or h2./h3. section boundary. The result is `.strip()`ed unless `keep_indent` + is set, in which case only blank lines around the section are removed so list indentation survives. """ lines = content.splitlines() start = None @@ -38,8 +45,42 @@ def extract_jira_section(content: str, heading_prefix: str) -> str | None: or stripped == "{panel}" ) ): - return "\n".join(lines[start:i]).strip() - return "\n".join(lines[start:]).strip() if start is not None else None + return _trim_section(lines[start:i], keep_indent) + return _trim_section(lines[start:], keep_indent) if start is not None else None + + +_MARKDOWN_MARKER_RES = { + "numbered": re.compile(r"^(\s*)\d+\.\s+(.*)$"), + "dash": re.compile(r"^(\s*)-\s+(.*)$"), +} + + +def _split_markdown_list(section: str) -> list[str] | None: + """Split a section that opens with a markdown `1.` / `-` list into one string per top-level item. + + Returns None unless the first non-blank line is a list marker, so paragraphs that merely contain + example sub-bullets stay in paragraph mode. Items start at a marker of the same kind and indent as + the first one; deeper nested bullets and continuation lines fold into the current item. + """ + lines = [line.expandtabs(4) for line in section.splitlines()] + first = next((line for line in lines if line.strip()), None) + if first is None: + return None + for pattern in _MARKDOWN_MARKER_RES.values(): + if match := pattern.match(first): + marker, top_indent = pattern, len(match.group(1)) + break + else: + return None + + items: list[list[str]] = [] + for line in lines: + match = marker.match(line) + if match and len(match.group(1)) == top_indent: + items.append([match.group(2)]) + elif items: + items[-1].append(line) + return [" ".join(" ".join(parts).split()) for parts in items if "".join(parts).strip()] def _extract_bulleted_texts(section: str) -> list[str]: @@ -47,25 +88,25 @@ def _extract_bulleted_texts(section: str) -> list[str]: Prefers Jira markers (`#` numbered, then `*` plain) so existing STRAT fixtures stay unchanged. Overflow markdown attachments keep `1.` / `-` after heading normalization; those are recognized - next. Falls back to blank-line paragraph splitting when no bullet marker is present. + only when the section body starts with the list (see `_split_markdown_list`). Falls back to + blank-line paragraph splitting otherwise. Pass the section with its indentation intact + (`extract_jira_section(..., keep_indent=True)`) so indented markdown lists split correctly. """ stripped = section.strip() + bullet_marker = None if re.search(r"(?m)^#\s+", stripped): bullet_marker = r"(?m)^#\s+" elif re.search(r"(?m)^\*\s+", stripped): bullet_marker = r"(?m)^\*\s+" - elif re.search(r"(?m)^\d+\.\s+", stripped): - bullet_marker = r"(?m)^\d+\.\s+" - elif re.search(r"(?m)^-\s+", stripped): - bullet_marker = r"(?m)^-\s+" - else: - bullet_marker = None if bullet_marker: # Split on the bullet marker directly so entries survive with no blank line between them. return [" ".join(item.split()) for item in re.split(bullet_marker, stripped)[1:] if item.strip()] + if (markdown_items := _split_markdown_list(section)) is not None: + return markdown_items + merged = [] for para in re.split(r"\n\n+", stripped): if text := " ".join(para.split()): @@ -85,14 +126,14 @@ def parse_acceptance_criteria(content: str) -> dict: whose sentence exactly duplicates (case/whitespace-insensitive) one already present are skipped; semantic near-duplicates are not detected. """ - section = extract_jira_section(content, "h3. Acceptance Criteria") + section = extract_jira_section(content, "h3. Acceptance Criteria", keep_indent=True) if section is None: heading = next((line for line in content.splitlines() if _STRATEGY_AC_HEADING_RE.match(line)), None) if heading is None: heading = next((line for line in content.splitlines() if _ADDITIONAL_AC_HEADING_RE.match(line)), None) - section = extract_jira_section(content, heading) if heading is not None else None + section = extract_jira_section(content, heading, keep_indent=True) if heading is not None else None if section is None: - section = extract_jira_section(content, "*Acceptance Criteria*") + section = extract_jira_section(content, "*Acceptance Criteria*", keep_indent=True) if section is None: return {"found": False, "count": 0, "acceptance_criteria": []} @@ -105,7 +146,9 @@ def parse_acceptance_criteria(content: str) -> dict: break testability_section = ( - extract_jira_section(content, testability_heading) if testability_heading is not None else None + extract_jira_section(content, testability_heading, keep_indent=True) + if testability_heading is not None + else None ) if testability_section: seen = {" ".join(_parse_bullet_item(text)["text"].split()).casefold() for text in texts} diff --git a/tests/consts/strategy_constants.py b/tests/consts/strategy_constants.py index 91ea982..cb807dd 100644 --- a/tests/consts/strategy_constants.py +++ b/tests/consts/strategy_constants.py @@ -55,6 +55,40 @@ "\nh3. Effort Estimate\n" ) +STRAT_AC_PARAGRAPH_WITH_DASH_EXAMPLES = """h3. Acceptance Criteria + +The export must support: +- CSV +- JSON + +The import must reject malformed files.""" + +STRAT_AC_INDENTED_NUMBERED = """h3. Acceptance Criteria + + 1. Given A when B then C + 2. Given D when E then F + 3. Given G when H then I""" + +STRAT_AC_INDENTED_DASH = """h3. Acceptance Criteria + + - Given A when B then C + - Given D when E then F + - Given G when H then I""" + +STRAT_AC_INDENTED_DASH_WITH_NESTED = """h3. Acceptance Criteria + + - Given A when B then C + - nested detail for A + - Given D when E then F""" + +STRAT_AC_JIRA_HASH_WRAPPED_PARAGRAPHS = """h3. Acceptance Criteria + +# Given A when B then C + - wrapped detail for the first item + + second paragraph of the first item +# Given D when E then F""" + STRAT_NFR_COLON_INSIDE_BOLD = ( "h3. Non-Functional Requirements\n\n" "* *Performance:* The strategy fetch completes within the request timeout\n" diff --git a/tests/unit/test_parse_strat.py b/tests/unit/test_parse_strat.py index e2b0bf0..b1f6e6e 100644 --- a/tests/unit/test_parse_strat.py +++ b/tests/unit/test_parse_strat.py @@ -17,9 +17,14 @@ from tests.consts.strategy_constants import ( STRATEGY_WITHOUT_AC, STRATEGY_WITH_UNFETCHED_ATTACHMENT, + STRAT_AC_INDENTED_DASH, + STRAT_AC_INDENTED_DASH_WITH_NESTED, + STRAT_AC_INDENTED_NUMBERED, STRAT_AC_JIRA_HASH_WITH_MARKDOWN_NUMBERS, + STRAT_AC_JIRA_HASH_WRAPPED_PARAGRAPHS, STRAT_AC_MARKDOWN_DASH, STRAT_AC_MARKDOWN_NUMBERED, + STRAT_AC_PARAGRAPH_WITH_DASH_EXAMPLES, STRAT_NFR_BOLD_WITHOUT_COLON, STRAT_NFR_COLON_INSIDE_BOLD, STRAT_NFR_EMPTY_CATEGORY_TEXT, @@ -253,6 +258,53 @@ def test_jira_hash_still_wins_over_markdown_numbers(self): assert "markdown item must not split" in result["acceptance_criteria"][0]["text"] assert "clicks the tile" in result["acceptance_criteria"][1]["text"] + def test_dash_examples_inside_paragraph_keep_paragraph_mode(self): + result = parse_acceptance_criteria(STRAT_AC_PARAGRAPH_WITH_DASH_EXAMPLES) + + assert result["count"] == 2 + assert [ac["text"] for ac in result["acceptance_criteria"]] == [ + "The export must support: - CSV - JSON", + "The import must reject malformed files.", + ] + + def test_indented_numbered_list_splits_every_item(self): + result = parse_acceptance_criteria(STRAT_AC_INDENTED_NUMBERED) + + assert result["count"] == 3 + assert [ac["text"] for ac in result["acceptance_criteria"]] == [ + "Given A when B then C", + "Given D when E then F", + "Given G when H then I", + ] + assert gate_inputs(STRAT_AC_INDENTED_NUMBERED)["ac_count"] == 3 + assert workflow_inputs(STRAT_AC_INDENTED_NUMBERED)["ac_count"] == 3 + + def test_indented_dash_list_splits_every_item(self): + result = parse_acceptance_criteria(STRAT_AC_INDENTED_DASH) + + assert result["count"] == 3 + assert [ac["text"] for ac in result["acceptance_criteria"]] == [ + "Given A when B then C", + "Given D when E then F", + "Given G when H then I", + ] + + def test_nested_markdown_bullets_are_not_promoted_to_acs(self): + result = parse_acceptance_criteria(STRAT_AC_INDENTED_DASH_WITH_NESTED) + + assert [ac["text"] for ac in result["acceptance_criteria"]] == [ + "Given A when B then C - nested detail for A", + "Given D when E then F", + ] + + def test_jira_hash_wrapped_paragraphs_stay_one_ac(self): + result = parse_acceptance_criteria(STRAT_AC_JIRA_HASH_WRAPPED_PARAGRAPHS) + + assert [ac["text"] for ac in result["acceptance_criteria"]] == [ + "Given A when B then C - wrapped detail for the first item second paragraph of the first item", + "Given D when E then F", + ] + def test_testability_edge_cases_folded_in_with_continued_numbering(self): result = parse_acceptance_criteria(STRAT_TESTABILITY_FOLDED_INTO_AC) From 557c2d1649fa6d805f00c86011d9b83bcb2caf4d Mon Sep 17 00:00:00 2001 From: fullsend-fix <278716306+fullsend-ai-coder[bot]@users.noreply.github.com> Date: Wed, 2 Dec 2026 13:08:03 +0000 Subject: [PATCH 4/4] fix: skip NFR bullets with blank category (PR #111) Skip the NFR match when the stripped category is empty so a bullet like '* * :* text' no longer yields category '' in gate_inputs. Adds a regression test. Not addressed per instruction: mixed sibling indent tolerance in _split_markdown_list. Notes: pre-commit could not fetch hooks (network) and pytest/ruff are unavailable in the sandbox; behavior verified with a direct python check. Addresses #111 Co-Authored-By: Claude Sonnet 5.5 --- scripts/utils/strat_utils.py | 10 +++------- tests/unit/test_parse_strat.py | 6 ++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/utils/strat_utils.py b/scripts/utils/strat_utils.py index 9b87e56..b6ea1e3 100644 --- a/scripts/utils/strat_utils.py +++ b/scripts/utils/strat_utils.py @@ -178,13 +178,9 @@ def parse_nfr(content: str) -> dict: if not line: continue match = nfr_re.match(line) - if match: - requirements.append( - { - "category": (match.group(1) or match.group(2)).strip(), - "text": match.group(3).strip(), - } - ) + category = (match.group(1) or match.group(2)).strip() if match else "" + if category: + requirements.append({"category": category, "text": match.group(3).strip()}) elif requirements and not line.startswith("*"): # Merge wrapped continuation text, but not a new "*" bullet that failed nfr_re. requirements[-1]["text"] = f"{requirements[-1]['text']} {line}" diff --git a/tests/unit/test_parse_strat.py b/tests/unit/test_parse_strat.py index b1f6e6e..3d65a3b 100644 --- a/tests/unit/test_parse_strat.py +++ b/tests/unit/test_parse_strat.py @@ -387,6 +387,12 @@ def test_empty_category_bullet_is_not_a_requirement(self): assert all(nfr["text"] != ":" for nfr in result["requirements"]) assert "Security" not in gate_inputs(STRAT_NFR_EMPTY_CATEGORY_TEXT)["nfr_categories"] + def test_whitespace_only_category_is_not_a_requirement(self): + content = "h3. Non-Functional Requirements\n\n* * :* Response must complete within two seconds" + + assert parse_nfr(content)["requirements"] == [] + assert gate_inputs(content)["nfr_categories"] == [] # main ignored this malformed bullet + class TestGateInputs: """Tests for gate_inputs — the citation gate's deterministic ac_count + nfr_categories.