Line: the self-drill
Red Rabbit drilled its own parser. Six planted changes, each aimed at one promise of its own spec, went through the project's gates one at a time in a throwaway copy of the code. No planted change reached a branch.
Before and after
Promises guarded
2/6 → 6/6
BLIND IN PLACES AWAKE
Tests, full gate
28 → 42
Tests, examples gate
26 → 40
Line coverage
140/141 → 140/141
99.3% before and after
Kiro wrote 14 new tests from the spec. The parser, the spec and the planted changes did not change between the two runs.
Line coverage of the parser is a separate measurement of the full gate at the exhibit pin. It was the same before and after, so it did not see the gap.
| Promise | Tests before | Tests after | Kiro reviewer |
|---|---|---|---|
| Promise AC-1 Single promise per numbered criterion | Tests before ESCAPED | Tests after CAUGHT | Kiro reviewer CAUGHT |
| Promise AC-2 Promise id from source label | Tests before ESCAPED | Tests after CAUGHT | Kiro reviewer CAUGHT |
| Promise AC-3 Verbatim promise text | Tests before ESCAPED | Tests after CAUGHT | Kiro reviewer CAUGHT |
| Promise AC-4 Source line recorded | Tests before CAUGHT | Tests after CAUGHT | Kiro reviewer CAUGHT |
| Promise AC-6 Unparseable content reported, not dropped | Tests before ESCAPED | Tests after CAUGHT | Kiro reviewer CAUGHT |
| Promise AC-7 Empty or missing Acceptance Criteria section | Tests before CAUGHT | Tests after CAUGHT | Kiro reviewer CAUGHT |
The reviewer column
The Kiro reviewer agent read each change and its promise, on the same planted changes, in one record. 6/6 promises guarded. AWAKE
False alarms
A clean change should pass. The reviewer ran once on 8 clean changes. CAUGHT would be a false alarm; ESCAPED is the right answer for a clean change. DID_NOT_RUN means the gate did not count a reply.
0 of 8 clean changes flagged. 7 answered ESCAPED and 1 answered DID_NOT_RUN. The gate did not count that reply as an answer.
| Clean change | Promise | Kiro reviewer |
|---|---|---|
| Clean change 1. rename of a local variable (body to joined) in flush | Promise AC-3 Verbatim promise text | Kiro reviewer ESCAPED |
| Clean change 2. rename of a local variable (number to <redacted>) in _scan | Promise AC-4 Source line recorded | Kiro reviewer ESCAPED |
| Clean change 3. reformatting | Promise AC-1 Single promise per numbered criterion | Kiro reviewer DID_NOT_RUN The record says: reviewer marker for ctl-clean-3 missing or garbled. The reply it did not count: AGENT: red-rabbit-reviewer ctl-clean-3 ESCAPED, ctl-clean-6 ESCAPED: both changes are behavior-preserving (formatting only, and reordered resets). |
| Clean change 4. comment edits | Promise AC-6 Unparseable content reported, not dropped | Kiro reviewer ESCAPED |
| Clean change 5. docstring edit | Promise AC-7 Empty or missing Acceptance Criteria section | Kiro reviewer ESCAPED |
| Clean change 6. reordering | Promise AC-1 Single promise per numbered criterion | Kiro reviewer ESCAPED |
| Clean change 7. equivalent expression | Promise AC-2 Promise id from source label | Kiro reviewer ESCAPED |
| Clean change 8. equivalent expression | Promise AC-6 Unparseable content reported, not dropped | Kiro reviewer ESCAPED |
Clean controls are unverified for every input: they were checked on the tested documents only.
The diffs
Planted changes
Planted change 1: AC-1 Single promise per numbered criterion
The promise parser starts a new promise at an indented numbered line, so one criterion with an indented numbered continuation becomes several promises.
WHEN the parser reads arequirements.mdfile, it SHALL return onePromiseper numbered acceptance criterion; AND it SHALL never split a criterion across multiple promises, even when the criterion text contains several clauses joined by semicolons,AND, or similar connectives.
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -71,12 +71,13 @@ def _scan(
pending_blanks.append((line, endings[index]))
index += 1
continue
- if line[0] not in " <path>":
+ if line[0] not in " <path>" or _CRITERION_START_RE.match(line.lstrip(" <path>")):
if _BOUNDARY_RE.match(line):
flush()
index += 1
continue
- match = _CRITERION_RE.match(line) if _CRITERION_START_RE.match(line) else None
+ body = line.lstrip(" <path>")
+ match = _CRITERION_RE.match(body) if _CRITERION_START_RE.match(body) else None
flush()
if match:
current_id = make_id(match.group(2), match.group(1))
Planted change 2: AC-2 Promise id from source label
The promise id from a bracket label is upper-cased instead of used verbatim.
WHEN a numbered criterion carries an explicit bracket label (e.g.[AC-3]) in the source, the parser SHALL use that label verbatim as the promise id; AND WHEN no bracket label is present, the parser SHALL use the bare number (e.g.3) as the promise id.
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py index <redacted>..<redacted> 100644 --- a/skeleton/redrabbit/parser.py +++ b/skeleton/redrabbit/parser.py @@ -110,7 +110,7 @@ def _scan( def _legacy_id(label: str | None, number: str) -> str: - return label or number + return label.upper() if label else number def parse_requirements(text: str) -> ParseResult:
Planted change 3: AC-3 Verbatim promise text
The promise text has trailing whitespace stripped from its last line instead of being reproduced verbatim.
WHEN the parser extracts a promise, the promise text SHALL be every line that belongs to that criterion, reproduced verbatim with no normalisation, trimming, or reformatting; AND the original line endings (CRLF, CR or LF) SHALL be kept between the lines of the text (the line break that ends the criterion is not part of it).
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -52,7 +52,7 @@ def _scan(
nonlocal current_id, current_lines, pending_blanks
if current_id is not None:
*head, (last, _) = current_lines
- body = "".join(line + ending for line, ending in head) + last
+ body = "".join(line + ending for line, ending in head) + last.rstrip()
result.promises.append(
Promise(id=current_id, text=body, source_line=current_line)
)
Planted change 4: AC-4 Source line recorded
The recorded source line of a promise is the 0-based line index, not the 1-based line number.
WHEN the parser extracts a promise, it SHALL record the 1-based line number in the source file at which that criterion begins. Lines are separated by CRLF, CR or LF only; other characters that str.splitlines treats as breaks (for example form feed or U+2028) do not start a new line.diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -80,7 +80,7 @@ def _scan(
flush()
if match:
current_id = make_id(match.group(2), match.group(1))
- current_line = number
+ current_line = index
current_lines = [(line, endings[index])]
else:
result.warnings.append(
Planted change 5: AC-6 Unparseable content reported, not dropped
An indented line that belongs to no criterion is dropped without a ParseWarning.
WHEN the parser encounters content inside the Acceptance Criteria section that it cannot classify as a numbered criterion, it SHALL add aParseWarningto the result describing the offending lines and their line numbers; AND it SHALL still return all promises it could successfully parse; AND it SHALL never silently discard any line from the Acceptance Criteria section. Only indented lines (lines starting with at least one whitespace character) continue a criterion; an unindented non-header line inside the Acceptance Criteria section SHALL produce aParseWarning. The one exception is a sub-heading (a line starting with three or more#followed by whitespace) and a horizontal rule (a line of three or more-): each ends the current criterion without a warning. Therequirements.mdof this spec SHALL parse with zero warnings.
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -92,12 +92,6 @@ def _scan(
index += 1
continue
if current_id is None:
- result.warnings.append(
- ParseWarning(
- message=f"Indented line outside any criterion: {line!r}",
- lines=[number],
- )
- )
index += 1
continue
current_lines.extend(pending_blanks)
Planted change 6: AC-7 Empty or missing Acceptance Criteria section
A requirements file with no Acceptance Criteria section returns no promises and no ParseWarning.
WHEN arequirements.mdfile contains no Acceptance Criteria section, the parser SHALL return an empty promise list and oneParseWarningwhose message describes the missing section. WHEN the section is present but empty (contains only blank lines), the parser SHALL return an empty promise list and zero warnings.
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -166,7 +166,6 @@ def parse_requirements(text: str) -> ParseResult:
index += 1
if not found:
- result.warnings.append(ParseWarning(message=_NO_SECTION, lines=[]))
return result
# Native ids must be unique across the file. A repeated number in the source (a typo
Clean changes
Clean change 1: AC-3 Verbatim promise text
control clean (verified): rename of a local variable (body to joined) in flush
WHEN the parser extracts a promise, the promise text SHALL be every line that belongs to that criterion, reproduced verbatim with no normalisation, trimming, or reformatting; AND the original line endings (CRLF, CR or LF) SHALL be kept between the lines of the text (the line break that ends the criterion is not part of it).
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -52,9 +52,9 @@ def _scan(
nonlocal current_id, current_lines, pending_blanks
if current_id is not None:
*head, (last, _) = current_lines
- body = "".join(line + ending for line, ending in head) + last
+ joined = "".join(line + ending for line, ending in head) + last
result.promises.append(
- Promise(id=current_id, text=body, source_line=current_line)
+ Promise(id=current_id, text=joined, source_line=current_line)
)
current_id = None
current_lines = []
Clean change 2: AC-4 Source line recorded
control clean (verified): rename of a local variable (number to <redacted>) in _scan
WHEN the parser extracts a promise, it SHALL record the 1-based line number in the source file at which that criterion begins. Lines are separated by CRLF, CR or LF only; other characters that str.splitlines treats as breaks (for example form feed or U+2028) do not start a new line.diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -63,7 +63,7 @@ def _scan(
index = start
while index < len(lines):
line = lines[index]
- number = index + 1
+ <redacted> = index + 1
if stop.match(line):
break
if not line.strip():
@@ -80,13 +80,13 @@ def _scan(
flush()
if match:
current_id = make_id(match.group(2), match.group(1))
- current_line = number
+ current_line = <redacted>
current_lines = [(line, endings[index])]
else:
result.warnings.append(
ParseWarning(
message=f"Unparseable line in Acceptance Criteria section: {line!r}",
- lines=[number],
+ lines=[<redacted>],
)
)
index += 1
@@ -95,7 +95,7 @@ def _scan(
result.warnings.append(
ParseWarning(
message=f"Indented line outside any criterion: {line!r}",
- lines=[number],
+ lines=[<redacted>],
)
)
index += 1
Clean change 3: AC-1 Single promise per numbered criterion
control clean (verified): reformatting: two multi-line calls <redacted> out differently
WHEN the parser reads arequirements.mdfile, it SHALL return onePromiseper numbered acceptance criterion; AND it SHALL never split a criterion across multiple promises, even when the criterion text contains several clauses joined by semicolons,AND, or similar connectives.
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -53,9 +53,7 @@ def _scan(
if current_id is not None:
*head, (last, _) = current_lines
body = "".join(line + ending for line, ending in head) + last
- result.promises.append(
- Promise(id=current_id, text=body, source_line=current_line)
- )
+ result.promises.append(Promise(id=current_id, text=body, source_line=current_line))
current_id = None
current_lines = []
pending_blanks = []
@@ -83,12 +81,9 @@ def _scan(
current_line = number
current_lines = [(line, endings[index])]
else:
- result.warnings.append(
- ParseWarning(
- message=f"Unparseable line in Acceptance Criteria section: {line!r}",
- lines=[number],
- )
- )
+ result.warnings.append(ParseWarning(
+ message=f"Unparseable line in Acceptance Criteria section: {line!r}",
+ lines=[number]))
index += 1
continue
if current_id is None:
Clean change 4: AC-6 Unparseable content reported, not dropped
control clean (verified): comment edits: three comments <redacted> or added
WHEN the parser encounters content inside the Acceptance Criteria section that it cannot classify as a numbered criterion, it SHALL add aParseWarningto the result describing the offending lines and their line numbers; AND it SHALL still return all promises it could successfully parse; AND it SHALL never silently discard any line from the Acceptance Criteria section. Only indented lines (lines starting with at least one whitespace character) continue a criterion; an unindented non-header line inside the Acceptance Criteria section SHALL produce aParseWarning. The one exception is a sub-heading (a line starting with three or more#followed by whitespace) and a horizontal rule (a line of three or more-): each ends the current criterion without a warning. Therequirements.mdof this spec SHALL parse with zero warnings.
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -26,7 +26,8 @@ _REQUIREMENT_RE = re.compile(r"^#{2,4}[ <path> <path>", re.IGNORE
_CRITERION_RE = <path> <path>])?")
_CRITERION_START_RE = <path> <path>)")
_LINE_BREAK_RE = <path>)")
-# Sub-headings (### ...) and horizontal rules (---) end a criterion without a warning.
+# A sub-heading (### ...) or a horizontal rule (---) closes the current criterion and
+# produces no warning.
_BOUNDARY_RE = <path> <path>)")
_NO_SECTION = (
"No acceptance criteria found: expected a '## Acceptance Criteria' section, or "
@@ -91,6 +92,7 @@ def _scan(
)
index += 1
continue
+ # An indented line with no open criterion cannot belong anywhere: <redacted>, never drop it.
if current_id is None:
result.warnings.append(
ParseWarning(
@@ -105,7 +107,7 @@ def _scan(
current_lines.append((line, endings[index]))
index += 1
- flush()
+ flush() # emit the last open criterion
return index
Clean change 5: AC-7 Empty or missing Acceptance Criteria section
control clean (verified): docstring edit: one sentence added to the parse_requirements docstring
WHEN arequirements.mdfile contains no Acceptance Criteria section, the parser SHALL return an empty promise list and oneParseWarningwhose message describes the missing section. WHEN the section is present but empty (contains only blank lines), the parser SHALL return an empty promise list and zero warnings.
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -118,6 +118,7 @@ def parse_requirements(text: str) -> ParseResult:
Never raises on malformed content; problems become ParseWarning entries.
Lines are split on CRLF, CR and LF only, and ``source_line`` counts them.
+ A document with no acceptance criteria gives no promises and one warning.
Promise text is every line of the criterion, verbatim, with the original
line endings between lines (the final line break is not part of the text).
"""
Clean change 6: AC-1 Single promise per numbered criterion
control clean (verified): reordering: the three resets at the end of flush swapped
WHEN the parser reads arequirements.mdfile, it SHALL return onePromiseper numbered acceptance criterion; AND it SHALL never split a criterion across multiple promises, even when the criterion text contains several clauses joined by semicolons,AND, or similar connectives.
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -56,9 +56,9 @@ def _scan(
result.promises.append(
Promise(id=current_id, text=body, source_line=current_line)
)
- current_id = None
- current_lines = []
pending_blanks = []
+ current_lines = []
+ current_id = None
index = start
while index < len(lines):
Clean change 7: AC-2 Promise id from source label
control clean (verified): equivalent expression: 'label or number' written as a conditional expression
WHEN a numbered criterion carries an explicit bracket label (e.g.[AC-3]) in the source, the parser SHALL use that label verbatim as the promise id; AND WHEN no bracket label is present, the parser SHALL use the bare number (e.g.3) as the promise id.
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py index <redacted>..<redacted> 100644 --- a/skeleton/redrabbit/parser.py +++ b/skeleton/redrabbit/parser.py @@ -110,7 +110,7 @@ def _scan( def _legacy_id(label: str | None, number: str) -> str: - return label or number + return label if label else number def parse_requirements(text: str) -> ParseResult:
Clean change 8: AC-6 Unparseable content reported, not dropped
control clean (verified): equivalent expression: 'not line.strip()' written as 'line.strip() == ""'
WHEN the parser encounters content inside the Acceptance Criteria section that it cannot classify as a numbered criterion, it SHALL add aParseWarningto the result describing the offending lines and their line numbers; AND it SHALL still return all promises it could successfully parse; AND it SHALL never silently discard any line from the Acceptance Criteria section. Only indented lines (lines starting with at least one whitespace character) continue a criterion; an unindented non-header line inside the Acceptance Criteria section SHALL produce aParseWarning. The one exception is a sub-heading (a line starting with three or more#followed by whitespace) and a horizontal rule (a line of three or more-): each ends the current criterion without a warning. Therequirements.mdof this spec SHALL parse with zero warnings.
diff --git a/skeleton/redrabbit/parser.py b/skeleton/redrabbit/parser.py
index <redacted>..<redacted> 100644
--- a/skeleton/redrabbit/parser.py
+++ b/skeleton/redrabbit/parser.py
@@ -66,7 +66,7 @@ def _scan(
number = index + 1
if stop.match(line):
break
- if not line.strip():
+ if line.strip() == "":
if current_id is not None:
pending_blanks.append((line, endings[index]))
index += 1