Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions scripts/research_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,17 +570,24 @@ def issue_drafts(text):
# contents. The shapes are indistinguishable from the
# block alone, so drop the fence only when doing so
# surfaces a draft-defining element the kept prose
# lacks: the workflow:issue marker itself (#401, #411),
# or a Concept Document pointer line the kept prose
# does not already carry (#414 — a draft whose marker
# sits before an unclosed example traps its pointer
# inside the example the same way). A properly closed
# appendix example (#410) surfaces neither: its marker
# and pointer already sit in the kept prose, so its
# exemption stands. Trapped prose that is neither
# element, in a draft already carrying both before the
# example, remains indistinguishable from a closed
# example's contents and stays exempt (#414).
# lacks entirely: the workflow:issue marker itself
# (#401, #411), or a Concept Document pointer when the
# kept prose carries no pointer at all (#414 — a draft
# whose marker sits before an unclosed example traps
# its only pointer inside the example the same way).
# The pointer signal must stay that narrow: a properly
# closed appendix example (#410) that itself depicts a
# draft carries its own distinct pointer line, and the
# broader #414 set-difference signal fired on exactly
# that, stripping the closed example's exemption
# (#422). So a draft already carrying a pointer in its
# kept prose never drops the fence on the pointer
# signal, and its appendix example stays exempt.
# Trapped prose that is neither element, and a second
# pointer trapped in a draft already carrying one
# before the example, remain indistinguishable from a
# closed example's contents and stay exempt (#414,
# #422).
lines = block.splitlines()
found = (
re.match(r"^ {0,3}(`{3,}|~{3,})\s*(.*?)\s*$", lines[-1])
Expand All @@ -593,7 +600,7 @@ def issue_drafts(text):
recovered = draft_prose(dropped)
if (
"workflow:issue" not in kept and "workflow:issue" in recovered
) or concept_pointers(recovered) - concept_pointers(kept):
) or (not concept_pointers(kept) and concept_pointers(recovered)):
block = dropped
# Nested fenced blocks inside a draft are embedded code
# examples, not draft prose: strip them whole (as
Expand Down
47 changes: 47 additions & 0 deletions scripts/tests/test_research_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,53 @@ def test_issue_draft_marker_before_unclosed_inner_code_passes_when_valid(
)
self.check(package, ok=True)

def append_issue_draft_ending_with_closed_inner_code_example_pointer(
self, package, concept_pointer
):
document = package / "concepts" / "C001-source-preservation.md"
# Byte-level append, for the same \\r\\n reason as append_issue_draft.
# The #410 appendix shape, except the properly closed example
# itself depicts a draft and so carries its own distinct
# Concept Document pointer line (#422), pointing at a target
# that does not resolve: the example must stay exempt, so only
# the draft's own pointer is checked.
draft = (
"\n\n## Trigger Issue Draft\n\n```markdown\n"
"# Research: Exact source preservation\n\n"
f"- Concept Document: [concept]({concept_pointer})\n\n"
'<!-- workflow:issue {"package": "pkg", "concept": "C001", '
'"stage": "S1"} -->\n\n'
"```python\n"
"- Concept Document: [example](missing/example-pointer.md)\n"
"print('example')\n"
"```\n"
)
document.write_bytes(document.read_bytes() + draft.encode("utf-8"))

def test_unclosed_issue_draft_ending_with_a_closed_inner_code_block_with_its_own_pointer_passes_when_valid(
self,
):
package = self.init()
# #422: PR #419's set-difference pointer signal fired on the
# closed example's distinct pointer, dropped its genuine
# closing fence, and link-checked the example's broken pointer
# as draft prose — failing this valid draft.
self.append_issue_draft_ending_with_closed_inner_code_example_pointer(
package, "C001-source-preservation.md"
)
self.check(package, ok=True)

def test_unclosed_issue_draft_ending_with_a_closed_inner_code_block_with_its_own_pointer_and_a_broken_pointer_fails_check(
self,
):
package = self.init()
# #422: keeping the example exempt must not exempt the draft's
# own prose — its broken pointer is still checked.
self.append_issue_draft_ending_with_closed_inner_code_example_pointer(
package, "concepts/C001-source-preservation.md"
)
self.check(package, ok=False)

def test_unclosed_issue_draft_with_a_broken_pointer_fails_check(self):
package = self.init()
# #393: a draft whose fence is never closed used to be dropped
Expand Down
Loading